@headwai/chat-bubble 2.0.3 → 2.0.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/README.dev.md CHANGED
@@ -177,7 +177,7 @@ VITE_CHAT_BUBBLE_FAVICON_BG_COLOR=#667eea
177
177
  **Via runtime configuration (Script Embed - Option 2):**
178
178
  ```html
179
179
  <script>
180
- window.HEADWAI_CHAT_BUBBLE_CONFIG = {
180
+ window.DEEP_CHAT_CONFIG = {
181
181
  apiUrl: 'https://customer-api.com/chat',
182
182
  apiKey: 'customer-api-key',
183
183
  userMessageBackgroundColor: '#4a90e2', // Blue background for user messages
@@ -283,7 +283,7 @@ npm publish
283
283
  <!-- Configure via global variables -->
284
284
  <script>
285
285
  // Runtime configuration override
286
- window.HEADWAI_CHAT_BUBBLE_CONFIG = {
286
+ window.DEEP_CHAT_CONFIG = {
287
287
  apiUrl: 'https://customer-api.com/chat',
288
288
  apiKey: 'customer-api-key',
289
289
  modelId: 'gpt-4',
package/README.md CHANGED
@@ -21,7 +21,7 @@ Add the Headwai Chat Bubble to the respective .html file.
21
21
  <!-- Configure via global variables -->
22
22
  <script>
23
23
  // Runtime configuration override
24
- window.HEADWAI_CHAT_BUBBLE_CONFIG = {
24
+ window.DEEP_CHAT_CONFIG = {
25
25
  apiUrl: 'https://company.localchat.at', // required
26
26
  apiKey: 'customer-support-user-api-key', // required
27
27
  modelId: 'customer-support-model-id', // required
@@ -111,7 +111,7 @@ For multiple instances use data attributes of the `<div>` tag for configuration
111
111
 
112
112
  ## Configuration
113
113
 
114
- The Headwai Chat Bubble can be configured using either the global `window.HEADWAI_CHAT_BUBBLE_CONFIG` object or data attributes on individual chat bubble elements. Below are all available configuration options:
114
+ The Headwai Chat Bubble can be configured using either the global `window.DEEP_CHAT_CONFIG` object or data attributes on individual chat bubble elements. Below are all available configuration options:
115
115
 
116
116
  ### Required Configuration
117
117
 
@@ -278,4 +278,4 @@ ${r.map((t,e)=>{const n=t.name||"Untitled Reference";let a=`**[${e+1}]** `;retur
278
278
 
279
279
  `)}`}function Ns(r){let s,t,e,n,a;return{c(){s=ct("div"),t=ct("img"),js(t.src,e=r[5])||Ee(t,"src",e),Ee(t,"alt","AI Assistant"),Ee(t,"class","svelte-bjand4"),Ee(s,"class","ai-assistant-icon svelte-bjand4"),Br(s,"background",r[2]),Ee(s,"role","button"),Ee(s,"tabindex","0")},m(i,o){Ln(i,s,o),Rn(s,t),n||(a=[Nr(s,"click",r[10]),Nr(s,"keydown",r[27])],n=!0)},p(i,o){o[0]&4&&Br(s,"background",i[2])},d(i){i&&Zt(s),n=!1,ut(a)}}}function Bs(r){let s,t;return{c(){s=ct("div"),t=ct("deep-chat"),me(t,"demo","false"),me(t,"textInput",r[9]),me(t,"messageStyles",r[3]),me(t,"history",r[6]),me(t,"connect",r[4]),me(t,"requestBodyLimits",r[8]),me(t,"requestInterceptor",r[12]),me(t,"responseInterceptor",r[13]),me(t,"customButtons",r[7]),me(t,"onMessage",r[11]),Ee(s,"class","chat-container svelte-bjand4")},m(e,n){Ln(e,s,n),Rn(s,t),r[28](t)},p(e,n){n[0]&8&&me(t,"messageStyles",e[3]),n[0]&16&&me(t,"connect",e[4])},d(e){e&&Zt(s),r[28](null)}}}function tc(r){let s,t,e=!r[0]&&Ns(r),n=r[0]&&Bs(r);return{c(){s=ct("main"),e&&e.c(),t=Vs(),n&&n.c(),Ee(s,"class","svelte-bjand4")},m(a,i){Ln(a,s,i),e&&e.m(s,null),Rn(s,t),n&&n.m(s,null)},p(a,i){a[0]?e&&(e.d(1),e=null):e?e.p(a,i):(e=Ns(a),e.c(),e.m(s,t)),a[0]?n?n.p(a,i):(n=Bs(a),n.c(),n.m(s,null)):n&&(n.d(1),n=null)},i:pe,o:pe,d(a){a&&Zt(s),e&&e.d(),n&&n.d()}}}function nc(r,s){r=r.replace("#","");const t=parseInt(r,16),e=(t>>16)+s,n=(t>>8&255)+s,a=(t&255)+s,i=Math.max(0,Math.min(255,e)),o=Math.max(0,Math.min(255,n)),l=Math.max(0,Math.min(255,a));return`#${(i<<16|o<<8|l).toString(16).padStart(6,"0")}`}function rc(r){return r.map(s=>{let t=s.text||s.content;return(s.role==="ai"||s.role==="assistant")&&(t=t.replace(/\n\n---\n\n\*\*References:\*\*[\s\S]*$/,"")),{role:s.role==="ai"?"assistant":s.role,content:t}})}function ac(r,s,t){let e,n,a,{apiUrl:i=void 0}=s,{apiKey:o=void 0}=s,{modelId:l=void 0}=s,{maxMessages:u=void 0}=s,{placeholderText:c=void 0}=s,{faviconPath:d=void 0}=s,{initialMessage:p=void 0}=s,{userMessageBackgroundColor:h=void 0}=s,{aiMessageBackgroundColor:v=void 0}=s,{userMessageTextColor:f=void 0}=s,{aiMessageTextColor:g=void 0}=s,{faviconBackgroundColor:y=void 0}=s,_=!1,C=null,I=[],w="",A="",U=[],P="",G;const x=d||void 0||Zu,T=p||"Hey, how can I assist you?",E=[{role:"ai",text:T}],F=[{styles:{button:{default:{container:{default:{backgroundColor:"transparent",borderRadius:"4px",width:"24px",height:"24px",border:"1px solid #e0e0e0",cursor:"pointer",transition:"all 0.2s ease"},hover:{backgroundColor:"#2196F3",borderColor:"#2196F3",transform:"scale(1.05)"},click:{backgroundColor:"#1976D2",borderColor:"#1976D2"}},svg:{content:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none">
280
280
  <path d="M19 14L12 21L5 14" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
281
- </svg>`,styles:{default:{width:"14px",height:"14px",color:"#666"},hover:{color:"white"}}}}}},position:"outside-right",tooltip:{text:"Minimize chat",timeout:300,style:{backgroundColor:"#333",color:"white",fontSize:"12px",padding:"4px 8px",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}},onClick:()=>(Y(),"default")}],M={maxMessages:parseInt(u||"0")||0},K={placeholder:{text:c||"Welcome to the demo!"}};function Y(){_?(t(26,C=null),I=[]):$([{role:"assistant",content:T}]),t(0,_=!_)}function le(){if(console.log("=== Message History ==="),I.length===0){console.log("No messages in history");return}I.forEach((R,W)=>{const se=R.content.length>50?R.content.substring(0,50)+"...":R.content;console.log(`${W+1}. ${R.role.toUpperCase()}: ${se}`)}),console.log("=====================")}async function $(R){var W;try{const se=Math.floor(Date.now()/1e3),Se=[l||"test-model"],ue=[],at={};let st=null;R.forEach((Ne,ot)=>{const lt=Mn(),Jt=ot<R.length-1?Mn():null,Xt={id:lt,parentId:st,childrenIds:Jt?[Jt]:[],role:Ne.role,content:Ne.content,timestamp:se,models:Se};Ne.role==="assistant"&&(Xt.model=Se[0],Xt.modelId=Se[0],Xt.modelIdx=0),ue.push(Xt),at[lt]=Xt,st=lt}),ue.forEach((Ne,ot)=>{ot<ue.length-1&&(Ne.childrenIds=[ue[ot+1].id])});const it=(W=ue[ue.length-1])==null?void 0:W.id,Rr={chat:{id:"",title:"New Chatbubble Chat",models:Se,params:{},history:{messages:at,currentId:it},messages:ue,tags:[],timestamp:Date.now()},folder_id:null},In=`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/v1/chats/new`,$t=await fetch(In,{method:"POST",headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},body:JSON.stringify(Rr)});if($t.ok){const Ne=await $t.json();return t(26,C=Ne.id),console.log("New chat created with ID:",C),I=ue,le(),C}else return console.error("Failed to create new chat:",$t.statusText),null}catch(se){return console.error("Error creating new chat:",se),null}}async function re(R,W,se){if(!C){console.error("Cannot store chat history: no chat ID available");return}console.log("assistantMessageSources:",se);try{const Se=Math.floor(Date.now()/1e3),ue=[l||"test-model"],at=Mn(),st=Mn(),it=I[I.length-1],Rr={id:at,parentId:it?it.id:null,childrenIds:[st],role:"user",content:R,timestamp:Se,models:ue},Fs={id:st,parentId:at,childrenIds:[],role:"assistant",content:W,model:ue[0],modelId:ue[0],modelIdx:0,timestamp:Se,sources:se};it&&(it.childrenIds=[at]),I.push(Rr,Fs);const In={};I.forEach(Jt=>{In[Jt.id]=Jt});const $t={chat:{models:ue,history:{messages:In,currentId:st},messages:I,params:{}}},ot=`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/v1/chats/${C}`,lt=await fetch(ot,{method:"POST",headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},body:JSON.stringify($t)});lt.ok?(console.log("Chat history stored successfully"),le()):console.error("Failed to store chat history:",lt.statusText)}catch(Se){console.error("Error storing chat history:",Se)}}async function ve(R){const{message:W,isHistory:se}=R;if(console.log(R),console.log(W),!se&&(W.role==="ai"||W.role==="assistant")&&(console.log("🤖 AI answered:",W.text||W.content),P&&G)){console.log("📚 Updating AI message with references");const ue=(W.text||W.content||"")+P;console.log(G.getMessages()),console.log(G.getMessages().length-1),G.updateMessage({text:ue},G.getMessages().length-1),P=""}}const ge=async R=>{if(R.body&&R.body.messages){R.body.messages=rc(R.body.messages);const W=R.body.messages.filter(se=>se.role==="user");W.length>0&&(w=W[W.length-1].content),C&&(R.body.chat_id=C)}return R},xn=R=>{console.log(R),R.sources&&Array.isArray(R.sources)&&(U=R.sources,console.log(`Found ${U.length} sources in response`),console.log("assistantMessageSources:",U));try{const W=Qu(R);W.length>0&&(P=ec(W),console.log(`Found ${W.length} references in response`))}catch(W){console.error("Error extracting references:",W)}if(R.choices&&R.choices[0]&&R.choices[0].delta){const W=R.choices[0].delta,se=W.content||"";return se&&(A+=se),R.choices[0].finish_reason&&(console.log("Streaming response ended"),w&&A&&re(w,A,U),A="",w=""),{text:se,role:W.role==="assistant"?"ai":W.role||"ai"}}if(R.choices&&R.choices[0]&&R.choices[0].message){const W=R.choices[0].message;return console.log("Non-streaming response received"),w&&W.content&&(re(w,W.content),w=""),{text:W.content,role:W.role==="assistant"?"ai":W.role}}return R.text||R.html||R.files?R:typeof R=="string"?{text:R}:R},Wt=R=>R.key==="Enter"&&Y();function Je(R){Pn[R?"unshift":"push"](()=>{G=R,t(1,G)})}return r.$$set=R=>{"apiUrl"in R&&t(14,i=R.apiUrl),"apiKey"in R&&t(15,o=R.apiKey),"modelId"in R&&t(16,l=R.modelId),"maxMessages"in R&&t(17,u=R.maxMessages),"placeholderText"in R&&t(18,c=R.placeholderText),"faviconPath"in R&&t(19,d=R.faviconPath),"initialMessage"in R&&t(20,p=R.initialMessage),"userMessageBackgroundColor"in R&&t(21,h=R.userMessageBackgroundColor),"aiMessageBackgroundColor"in R&&t(22,v=R.aiMessageBackgroundColor),"userMessageTextColor"in R&&t(23,f=R.userMessageTextColor),"aiMessageTextColor"in R&&t(24,g=R.aiMessageTextColor),"faviconBackgroundColor"in R&&t(25,y=R.faviconBackgroundColor)},r.$$.update=()=>{r.$$.dirty[0]&67223552&&t(4,e={type:"websocket",url:`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/chat/completions`,headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},additionalBodyProps:{model:l||"test-model",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"},...C&&{chat_id:C},background_tasks:{title_generation:!0,tags_generation:!1,follow_up_generation:!1}},stream:!0}),r.$$.dirty[0]&31457280&&t(3,n={default:{user:{bubble:{backgroundColor:h||"green",color:f||"white"}},ai:{bubble:{backgroundColor:v||"gray",color:g||"black"}}}}),r.$$.dirty[0]&33554432&&t(2,a=(()=>{const R=y||"lightgreen",W=nc(R,-20);return`linear-gradient(135deg, ${R} 0%, ${W} 100%)`})())},[_,G,a,n,e,x,E,F,M,K,Y,ve,ge,xn,i,o,l,u,c,d,p,h,v,f,g,y,C,Wt,Je]}class Ds extends ti{constructor(s){super(),ei(this,s,ac,tc,Us,{apiUrl:14,apiKey:15,modelId:16,maxMessages:17,placeholderText:18,faviconPath:19,initialMessage:20,userMessageBackgroundColor:21,aiMessageBackgroundColor:22,userMessageTextColor:23,aiMessageTextColor:24,faviconBackgroundColor:25},null,[-1,-1])}}function Ir(r,s={}){return new Ds({target:r,props:s})}typeof window<"u"&&window.document&&document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[data-chat-bubble]").forEach(s=>{const t=window.HEADWAI_CHAT_BUBBLE_CONFIG||{};Object.keys(s.dataset).forEach(e=>{if(e.startsWith("chatBubble")){const n=e.replace("chatBubble","").toLowerCase();t[n]=s.dataset[e]}}),Ir(s,t)})});const sc={ChatBubble,createChatBubble:Ir};return ye.ChatBubble=Ds,ye.createChatBubble=Ir,ye.default=sc,Object.defineProperties(ye,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),ye}({});
281
+ </svg>`,styles:{default:{width:"14px",height:"14px",color:"#666"},hover:{color:"white"}}}}}},position:"outside-right",tooltip:{text:"Minimize chat",timeout:300,style:{backgroundColor:"#333",color:"white",fontSize:"12px",padding:"4px 8px",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}},onClick:()=>(Y(),"default")}],M={maxMessages:parseInt(u||"0")||0},K={placeholder:{text:c||"Welcome to the demo!"}};function Y(){_?(t(26,C=null),I=[]):$([{role:"assistant",content:T}]),t(0,_=!_)}function le(){if(console.log("=== Message History ==="),I.length===0){console.log("No messages in history");return}I.forEach((R,W)=>{const se=R.content.length>50?R.content.substring(0,50)+"...":R.content;console.log(`${W+1}. ${R.role.toUpperCase()}: ${se}`)}),console.log("=====================")}async function $(R){var W;try{const se=Math.floor(Date.now()/1e3),Se=[l||"test-model"],ue=[],at={};let st=null;R.forEach((Ne,ot)=>{const lt=Mn(),Jt=ot<R.length-1?Mn():null,Xt={id:lt,parentId:st,childrenIds:Jt?[Jt]:[],role:Ne.role,content:Ne.content,timestamp:se,models:Se};Ne.role==="assistant"&&(Xt.model=Se[0],Xt.modelId=Se[0],Xt.modelIdx=0),ue.push(Xt),at[lt]=Xt,st=lt}),ue.forEach((Ne,ot)=>{ot<ue.length-1&&(Ne.childrenIds=[ue[ot+1].id])});const it=(W=ue[ue.length-1])==null?void 0:W.id,Rr={chat:{id:"",title:"New Chatbubble Chat",models:Se,params:{},history:{messages:at,currentId:it},messages:ue,tags:[],timestamp:Date.now()},folder_id:null},In=`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/v1/chats/new`,$t=await fetch(In,{method:"POST",headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},body:JSON.stringify(Rr)});if($t.ok){const Ne=await $t.json();return t(26,C=Ne.id),console.log("New chat created with ID:",C),I=ue,le(),C}else return console.error("Failed to create new chat:",$t.statusText),null}catch(se){return console.error("Error creating new chat:",se),null}}async function re(R,W,se){if(!C){console.error("Cannot store chat history: no chat ID available");return}console.log("assistantMessageSources:",se);try{const Se=Math.floor(Date.now()/1e3),ue=[l||"test-model"],at=Mn(),st=Mn(),it=I[I.length-1],Rr={id:at,parentId:it?it.id:null,childrenIds:[st],role:"user",content:R,timestamp:Se,models:ue},Fs={id:st,parentId:at,childrenIds:[],role:"assistant",content:W,model:ue[0],modelId:ue[0],modelIdx:0,timestamp:Se,sources:se};it&&(it.childrenIds=[at]),I.push(Rr,Fs);const In={};I.forEach(Jt=>{In[Jt.id]=Jt});const $t={chat:{models:ue,history:{messages:In,currentId:st},messages:I,params:{}}},ot=`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/v1/chats/${C}`,lt=await fetch(ot,{method:"POST",headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},body:JSON.stringify($t)});lt.ok?(console.log("Chat history stored successfully"),le()):console.error("Failed to store chat history:",lt.statusText)}catch(Se){console.error("Error storing chat history:",Se)}}async function ve(R){const{message:W,isHistory:se}=R;if(console.log(R),console.log(W),!se&&(W.role==="ai"||W.role==="assistant")&&(console.log("🤖 AI answered:",W.text||W.content),P&&G)){console.log("📚 Updating AI message with references");const ue=(W.text||W.content||"")+P;console.log(G.getMessages()),console.log(G.getMessages().length-1),G.updateMessage({text:ue},G.getMessages().length-1),P=""}}const ge=async R=>{if(R.body&&R.body.messages){R.body.messages=rc(R.body.messages);const W=R.body.messages.filter(se=>se.role==="user");W.length>0&&(w=W[W.length-1].content),C&&(R.body.chat_id=C)}return R},xn=R=>{console.log(R),R.sources&&Array.isArray(R.sources)&&(U=R.sources,console.log(`Found ${U.length} sources in response`),console.log("assistantMessageSources:",U));try{const W=Qu(R);W.length>0&&(P=ec(W),console.log(`Found ${W.length} references in response`))}catch(W){console.error("Error extracting references:",W)}if(R.choices&&R.choices[0]&&R.choices[0].delta){const W=R.choices[0].delta,se=W.content||"";return se&&(A+=se),R.choices[0].finish_reason&&(console.log("Streaming response ended"),w&&A&&re(w,A,U),A="",w=""),{text:se,role:W.role==="assistant"?"ai":W.role||"ai"}}if(R.choices&&R.choices[0]&&R.choices[0].message){const W=R.choices[0].message;return console.log("Non-streaming response received"),w&&W.content&&(re(w,W.content),w=""),{text:W.content,role:W.role==="assistant"?"ai":W.role}}return R.text||R.html||R.files?R:typeof R=="string"?{text:R}:R},Wt=R=>R.key==="Enter"&&Y();function Je(R){Pn[R?"unshift":"push"](()=>{G=R,t(1,G)})}return r.$$set=R=>{"apiUrl"in R&&t(14,i=R.apiUrl),"apiKey"in R&&t(15,o=R.apiKey),"modelId"in R&&t(16,l=R.modelId),"maxMessages"in R&&t(17,u=R.maxMessages),"placeholderText"in R&&t(18,c=R.placeholderText),"faviconPath"in R&&t(19,d=R.faviconPath),"initialMessage"in R&&t(20,p=R.initialMessage),"userMessageBackgroundColor"in R&&t(21,h=R.userMessageBackgroundColor),"aiMessageBackgroundColor"in R&&t(22,v=R.aiMessageBackgroundColor),"userMessageTextColor"in R&&t(23,f=R.userMessageTextColor),"aiMessageTextColor"in R&&t(24,g=R.aiMessageTextColor),"faviconBackgroundColor"in R&&t(25,y=R.faviconBackgroundColor)},r.$$.update=()=>{r.$$.dirty[0]&67223552&&t(4,e={type:"websocket",url:`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/chat/completions`,headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},additionalBodyProps:{model:l||"test-model",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"},...C&&{chat_id:C},background_tasks:{title_generation:!0,tags_generation:!1,follow_up_generation:!1}},stream:!0}),r.$$.dirty[0]&31457280&&t(3,n={default:{user:{bubble:{backgroundColor:h||"green",color:f||"white"}},ai:{bubble:{backgroundColor:v||"gray",color:g||"black"}}}}),r.$$.dirty[0]&33554432&&t(2,a=(()=>{const R=y||"lightgreen",W=nc(R,-20);return`linear-gradient(135deg, ${R} 0%, ${W} 100%)`})())},[_,G,a,n,e,x,E,F,M,K,Y,ve,ge,xn,i,o,l,u,c,d,p,h,v,f,g,y,C,Wt,Je]}class Ds extends ti{constructor(s){super(),ei(this,s,ac,tc,Us,{apiUrl:14,apiKey:15,modelId:16,maxMessages:17,placeholderText:18,faviconPath:19,initialMessage:20,userMessageBackgroundColor:21,aiMessageBackgroundColor:22,userMessageTextColor:23,aiMessageTextColor:24,faviconBackgroundColor:25},null,[-1,-1])}}function Ir(r,s={}){return new Ds({target:r,props:s})}typeof window<"u"&&window.document&&document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[data-chat-bubble]").forEach(s=>{const t=window.DEEP_CHAT_CONFIG||{};Object.keys(s.dataset).forEach(e=>{if(e.startsWith("chatBubble")){const n=e.replace("chatBubble","").toLowerCase();t[n]=s.dataset[e]}}),Ir(s,t)})});const sc={ChatBubble,createChatBubble:Ir};return ye.ChatBubble=Ds,ye.createChatBubble=Ir,ye.default=sc,Object.defineProperties(ye,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),ye}({});
package/dist/index.js CHANGED
@@ -16258,7 +16258,7 @@ function Bs(r, s = {}) {
16258
16258
  }
16259
16259
  typeof window < "u" && window.document && document.addEventListener("DOMContentLoaded", () => {
16260
16260
  document.querySelectorAll("[data-chat-bubble]").forEach((s) => {
16261
- const t = window.HEADWAI_CHAT_BUBBLE_CONFIG || {};
16261
+ const t = window.DEEP_CHAT_CONFIG || {};
16262
16262
  Object.keys(s.dataset).forEach((e) => {
16263
16263
  if (e.startsWith("chatBubble")) {
16264
16264
  const n = e.replace("chatBubble", "").toLowerCase();
@@ -278,4 +278,4 @@ ${r.map((t,e)=>{const n=t.name||"Untitled Reference";let a=`**[${e+1}]** `;retur
278
278
 
279
279
  `)}`}function Ns(r){let s,t,e,n,a;return{c(){s=ct("div"),t=ct("img"),js(t.src,e=r[5])||Ee(t,"src",e),Ee(t,"alt","AI Assistant"),Ee(t,"class","svelte-bjand4"),Ee(s,"class","ai-assistant-icon svelte-bjand4"),Br(s,"background",r[2]),Ee(s,"role","button"),Ee(s,"tabindex","0")},m(i,o){Ln(i,s,o),Rn(s,t),n||(a=[Nr(s,"click",r[10]),Nr(s,"keydown",r[27])],n=!0)},p(i,o){o[0]&4&&Br(s,"background",i[2])},d(i){i&&Zt(s),n=!1,ut(a)}}}function Bs(r){let s,t;return{c(){s=ct("div"),t=ct("deep-chat"),ve(t,"demo","false"),ve(t,"textInput",r[9]),ve(t,"messageStyles",r[3]),ve(t,"history",r[6]),ve(t,"connect",r[4]),ve(t,"requestBodyLimits",r[8]),ve(t,"requestInterceptor",r[12]),ve(t,"responseInterceptor",r[13]),ve(t,"customButtons",r[7]),ve(t,"onMessage",r[11]),Ee(s,"class","chat-container svelte-bjand4")},m(e,n){Ln(e,s,n),Rn(s,t),r[28](t)},p(e,n){n[0]&8&&ve(t,"messageStyles",e[3]),n[0]&16&&ve(t,"connect",e[4])},d(e){e&&Zt(s),r[28](null)}}}function tc(r){let s,t,e=!r[0]&&Ns(r),n=r[0]&&Bs(r);return{c(){s=ct("main"),e&&e.c(),t=Vs(),n&&n.c(),Ee(s,"class","svelte-bjand4")},m(a,i){Ln(a,s,i),e&&e.m(s,null),Rn(s,t),n&&n.m(s,null)},p(a,i){a[0]?e&&(e.d(1),e=null):e?e.p(a,i):(e=Ns(a),e.c(),e.m(s,t)),a[0]?n?n.p(a,i):(n=Bs(a),n.c(),n.m(s,null)):n&&(n.d(1),n=null)},i:ae,o:ae,d(a){a&&Zt(s),e&&e.d(),n&&n.d()}}}function nc(r,s){r=r.replace("#","");const t=parseInt(r,16),e=(t>>16)+s,n=(t>>8&255)+s,a=(t&255)+s,i=Math.max(0,Math.min(255,e)),o=Math.max(0,Math.min(255,n)),l=Math.max(0,Math.min(255,a));return`#${(i<<16|o<<8|l).toString(16).padStart(6,"0")}`}function rc(r){return r.map(s=>{let t=s.text||s.content;return(s.role==="ai"||s.role==="assistant")&&(t=t.replace(/\n\n---\n\n\*\*References:\*\*[\s\S]*$/,"")),{role:s.role==="ai"?"assistant":s.role,content:t}})}function ac(r,s,t){let e,n,a,{apiUrl:i=void 0}=s,{apiKey:o=void 0}=s,{modelId:l=void 0}=s,{maxMessages:u=void 0}=s,{placeholderText:c=void 0}=s,{faviconPath:d=void 0}=s,{initialMessage:p=void 0}=s,{userMessageBackgroundColor:h=void 0}=s,{aiMessageBackgroundColor:v=void 0}=s,{userMessageTextColor:f=void 0}=s,{aiMessageTextColor:g=void 0}=s,{faviconBackgroundColor:y=void 0}=s,_=!1,C=null,I=[],w="",A="",U=[],P="",G;const x=d||void 0||Zu,T=p||"Hey, how can I assist you?",E=[{role:"ai",text:T}],F=[{styles:{button:{default:{container:{default:{backgroundColor:"transparent",borderRadius:"4px",width:"24px",height:"24px",border:"1px solid #e0e0e0",cursor:"pointer",transition:"all 0.2s ease"},hover:{backgroundColor:"#2196F3",borderColor:"#2196F3",transform:"scale(1.05)"},click:{backgroundColor:"#1976D2",borderColor:"#1976D2"}},svg:{content:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none">
280
280
  <path d="M19 14L12 21L5 14" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
281
- </svg>`,styles:{default:{width:"14px",height:"14px",color:"#666"},hover:{color:"white"}}}}}},position:"outside-right",tooltip:{text:"Minimize chat",timeout:300,style:{backgroundColor:"#333",color:"white",fontSize:"12px",padding:"4px 8px",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}},onClick:()=>(Y(),"default")}],M={maxMessages:parseInt(u||"0")||0},K={placeholder:{text:c||"Welcome to the demo!"}};function Y(){_?(t(26,C=null),I=[]):$([{role:"assistant",content:T}]),t(0,_=!_)}function ue(){if(console.log("=== Message History ==="),I.length===0){console.log("No messages in history");return}I.forEach((R,W)=>{const ie=R.content.length>50?R.content.substring(0,50)+"...":R.content;console.log(`${W+1}. ${R.role.toUpperCase()}: ${ie}`)}),console.log("=====================")}async function $(R){var W;try{const ie=Math.floor(Date.now()/1e3),Se=[l||"test-model"],ce=[],at={};let st=null;R.forEach((Ne,ot)=>{const lt=Mn(),Jt=ot<R.length-1?Mn():null,Xt={id:lt,parentId:st,childrenIds:Jt?[Jt]:[],role:Ne.role,content:Ne.content,timestamp:ie,models:Se};Ne.role==="assistant"&&(Xt.model=Se[0],Xt.modelId=Se[0],Xt.modelIdx=0),ce.push(Xt),at[lt]=Xt,st=lt}),ce.forEach((Ne,ot)=>{ot<ce.length-1&&(Ne.childrenIds=[ce[ot+1].id])});const it=(W=ce[ce.length-1])==null?void 0:W.id,Rr={chat:{id:"",title:"New Chatbubble Chat",models:Se,params:{},history:{messages:at,currentId:it},messages:ce,tags:[],timestamp:Date.now()},folder_id:null},In=`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/v1/chats/new`,$t=await fetch(In,{method:"POST",headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},body:JSON.stringify(Rr)});if($t.ok){const Ne=await $t.json();return t(26,C=Ne.id),console.log("New chat created with ID:",C),I=ce,ue(),C}else return console.error("Failed to create new chat:",$t.statusText),null}catch(ie){return console.error("Error creating new chat:",ie),null}}async function re(R,W,ie){if(!C){console.error("Cannot store chat history: no chat ID available");return}console.log("assistantMessageSources:",ie);try{const Se=Math.floor(Date.now()/1e3),ce=[l||"test-model"],at=Mn(),st=Mn(),it=I[I.length-1],Rr={id:at,parentId:it?it.id:null,childrenIds:[st],role:"user",content:R,timestamp:Se,models:ce},Fs={id:st,parentId:at,childrenIds:[],role:"assistant",content:W,model:ce[0],modelId:ce[0],modelIdx:0,timestamp:Se,sources:ie};it&&(it.childrenIds=[at]),I.push(Rr,Fs);const In={};I.forEach(Jt=>{In[Jt.id]=Jt});const $t={chat:{models:ce,history:{messages:In,currentId:st},messages:I,params:{}}},ot=`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/v1/chats/${C}`,lt=await fetch(ot,{method:"POST",headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},body:JSON.stringify($t)});lt.ok?(console.log("Chat history stored successfully"),ue()):console.error("Failed to store chat history:",lt.statusText)}catch(Se){console.error("Error storing chat history:",Se)}}async function ge(R){const{message:W,isHistory:ie}=R;if(console.log(R),console.log(W),!ie&&(W.role==="ai"||W.role==="assistant")&&(console.log("🤖 AI answered:",W.text||W.content),P&&G)){console.log("📚 Updating AI message with references");const ce=(W.text||W.content||"")+P;console.log(G.getMessages()),console.log(G.getMessages().length-1),G.updateMessage({text:ce},G.getMessages().length-1),P=""}}const ye=async R=>{if(R.body&&R.body.messages){R.body.messages=rc(R.body.messages);const W=R.body.messages.filter(ie=>ie.role==="user");W.length>0&&(w=W[W.length-1].content),C&&(R.body.chat_id=C)}return R},xn=R=>{console.log(R),R.sources&&Array.isArray(R.sources)&&(U=R.sources,console.log(`Found ${U.length} sources in response`),console.log("assistantMessageSources:",U));try{const W=Qu(R);W.length>0&&(P=ec(W),console.log(`Found ${W.length} references in response`))}catch(W){console.error("Error extracting references:",W)}if(R.choices&&R.choices[0]&&R.choices[0].delta){const W=R.choices[0].delta,ie=W.content||"";return ie&&(A+=ie),R.choices[0].finish_reason&&(console.log("Streaming response ended"),w&&A&&re(w,A,U),A="",w=""),{text:ie,role:W.role==="assistant"?"ai":W.role||"ai"}}if(R.choices&&R.choices[0]&&R.choices[0].message){const W=R.choices[0].message;return console.log("Non-streaming response received"),w&&W.content&&(re(w,W.content),w=""),{text:W.content,role:W.role==="assistant"?"ai":W.role}}return R.text||R.html||R.files?R:typeof R=="string"?{text:R}:R},Wt=R=>R.key==="Enter"&&Y();function Je(R){Pn[R?"unshift":"push"](()=>{G=R,t(1,G)})}return r.$$set=R=>{"apiUrl"in R&&t(14,i=R.apiUrl),"apiKey"in R&&t(15,o=R.apiKey),"modelId"in R&&t(16,l=R.modelId),"maxMessages"in R&&t(17,u=R.maxMessages),"placeholderText"in R&&t(18,c=R.placeholderText),"faviconPath"in R&&t(19,d=R.faviconPath),"initialMessage"in R&&t(20,p=R.initialMessage),"userMessageBackgroundColor"in R&&t(21,h=R.userMessageBackgroundColor),"aiMessageBackgroundColor"in R&&t(22,v=R.aiMessageBackgroundColor),"userMessageTextColor"in R&&t(23,f=R.userMessageTextColor),"aiMessageTextColor"in R&&t(24,g=R.aiMessageTextColor),"faviconBackgroundColor"in R&&t(25,y=R.faviconBackgroundColor)},r.$$.update=()=>{r.$$.dirty[0]&67223552&&t(4,e={type:"websocket",url:`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/chat/completions`,headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},additionalBodyProps:{model:l||"test-model",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"},...C&&{chat_id:C},background_tasks:{title_generation:!0,tags_generation:!1,follow_up_generation:!1}},stream:!0}),r.$$.dirty[0]&31457280&&t(3,n={default:{user:{bubble:{backgroundColor:h||"green",color:f||"white"}},ai:{bubble:{backgroundColor:v||"gray",color:g||"black"}}}}),r.$$.dirty[0]&33554432&&t(2,a=(()=>{const R=y||"lightgreen",W=nc(R,-20);return`linear-gradient(135deg, ${R} 0%, ${W} 100%)`})())},[_,G,a,n,e,x,E,F,M,K,Y,ge,ye,xn,i,o,l,u,c,d,p,h,v,f,g,y,C,Wt,Je]}class Ds extends ti{constructor(s){super(),ei(this,s,ac,tc,Us,{apiUrl:14,apiKey:15,modelId:16,maxMessages:17,placeholderText:18,faviconPath:19,initialMessage:20,userMessageBackgroundColor:21,aiMessageBackgroundColor:22,userMessageTextColor:23,aiMessageTextColor:24,faviconBackgroundColor:25},null,[-1,-1])}}function Ir(r,s={}){return new Ds({target:r,props:s})}typeof window<"u"&&window.document&&document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[data-chat-bubble]").forEach(s=>{const t=window.HEADWAI_CHAT_BUBBLE_CONFIG||{};Object.keys(s.dataset).forEach(e=>{if(e.startsWith("chatBubble")){const n=e.replace("chatBubble","").toLowerCase();t[n]=s.dataset[e]}}),Ir(s,t)})});const sc={ChatBubble,createChatBubble:Ir};de.ChatBubble=Ds,de.createChatBubble=Ir,de.default=sc,Object.defineProperties(de,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
281
+ </svg>`,styles:{default:{width:"14px",height:"14px",color:"#666"},hover:{color:"white"}}}}}},position:"outside-right",tooltip:{text:"Minimize chat",timeout:300,style:{backgroundColor:"#333",color:"white",fontSize:"12px",padding:"4px 8px",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}},onClick:()=>(Y(),"default")}],M={maxMessages:parseInt(u||"0")||0},K={placeholder:{text:c||"Welcome to the demo!"}};function Y(){_?(t(26,C=null),I=[]):$([{role:"assistant",content:T}]),t(0,_=!_)}function ue(){if(console.log("=== Message History ==="),I.length===0){console.log("No messages in history");return}I.forEach((R,W)=>{const ie=R.content.length>50?R.content.substring(0,50)+"...":R.content;console.log(`${W+1}. ${R.role.toUpperCase()}: ${ie}`)}),console.log("=====================")}async function $(R){var W;try{const ie=Math.floor(Date.now()/1e3),Se=[l||"test-model"],ce=[],at={};let st=null;R.forEach((Ne,ot)=>{const lt=Mn(),Jt=ot<R.length-1?Mn():null,Xt={id:lt,parentId:st,childrenIds:Jt?[Jt]:[],role:Ne.role,content:Ne.content,timestamp:ie,models:Se};Ne.role==="assistant"&&(Xt.model=Se[0],Xt.modelId=Se[0],Xt.modelIdx=0),ce.push(Xt),at[lt]=Xt,st=lt}),ce.forEach((Ne,ot)=>{ot<ce.length-1&&(Ne.childrenIds=[ce[ot+1].id])});const it=(W=ce[ce.length-1])==null?void 0:W.id,Rr={chat:{id:"",title:"New Chatbubble Chat",models:Se,params:{},history:{messages:at,currentId:it},messages:ce,tags:[],timestamp:Date.now()},folder_id:null},In=`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/v1/chats/new`,$t=await fetch(In,{method:"POST",headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},body:JSON.stringify(Rr)});if($t.ok){const Ne=await $t.json();return t(26,C=Ne.id),console.log("New chat created with ID:",C),I=ce,ue(),C}else return console.error("Failed to create new chat:",$t.statusText),null}catch(ie){return console.error("Error creating new chat:",ie),null}}async function re(R,W,ie){if(!C){console.error("Cannot store chat history: no chat ID available");return}console.log("assistantMessageSources:",ie);try{const Se=Math.floor(Date.now()/1e3),ce=[l||"test-model"],at=Mn(),st=Mn(),it=I[I.length-1],Rr={id:at,parentId:it?it.id:null,childrenIds:[st],role:"user",content:R,timestamp:Se,models:ce},Fs={id:st,parentId:at,childrenIds:[],role:"assistant",content:W,model:ce[0],modelId:ce[0],modelIdx:0,timestamp:Se,sources:ie};it&&(it.childrenIds=[at]),I.push(Rr,Fs);const In={};I.forEach(Jt=>{In[Jt.id]=Jt});const $t={chat:{models:ce,history:{messages:In,currentId:st},messages:I,params:{}}},ot=`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/v1/chats/${C}`,lt=await fetch(ot,{method:"POST",headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},body:JSON.stringify($t)});lt.ok?(console.log("Chat history stored successfully"),ue()):console.error("Failed to store chat history:",lt.statusText)}catch(Se){console.error("Error storing chat history:",Se)}}async function ge(R){const{message:W,isHistory:ie}=R;if(console.log(R),console.log(W),!ie&&(W.role==="ai"||W.role==="assistant")&&(console.log("🤖 AI answered:",W.text||W.content),P&&G)){console.log("📚 Updating AI message with references");const ce=(W.text||W.content||"")+P;console.log(G.getMessages()),console.log(G.getMessages().length-1),G.updateMessage({text:ce},G.getMessages().length-1),P=""}}const ye=async R=>{if(R.body&&R.body.messages){R.body.messages=rc(R.body.messages);const W=R.body.messages.filter(ie=>ie.role==="user");W.length>0&&(w=W[W.length-1].content),C&&(R.body.chat_id=C)}return R},xn=R=>{console.log(R),R.sources&&Array.isArray(R.sources)&&(U=R.sources,console.log(`Found ${U.length} sources in response`),console.log("assistantMessageSources:",U));try{const W=Qu(R);W.length>0&&(P=ec(W),console.log(`Found ${W.length} references in response`))}catch(W){console.error("Error extracting references:",W)}if(R.choices&&R.choices[0]&&R.choices[0].delta){const W=R.choices[0].delta,ie=W.content||"";return ie&&(A+=ie),R.choices[0].finish_reason&&(console.log("Streaming response ended"),w&&A&&re(w,A,U),A="",w=""),{text:ie,role:W.role==="assistant"?"ai":W.role||"ai"}}if(R.choices&&R.choices[0]&&R.choices[0].message){const W=R.choices[0].message;return console.log("Non-streaming response received"),w&&W.content&&(re(w,W.content),w=""),{text:W.content,role:W.role==="assistant"?"ai":W.role}}return R.text||R.html||R.files?R:typeof R=="string"?{text:R}:R},Wt=R=>R.key==="Enter"&&Y();function Je(R){Pn[R?"unshift":"push"](()=>{G=R,t(1,G)})}return r.$$set=R=>{"apiUrl"in R&&t(14,i=R.apiUrl),"apiKey"in R&&t(15,o=R.apiKey),"modelId"in R&&t(16,l=R.modelId),"maxMessages"in R&&t(17,u=R.maxMessages),"placeholderText"in R&&t(18,c=R.placeholderText),"faviconPath"in R&&t(19,d=R.faviconPath),"initialMessage"in R&&t(20,p=R.initialMessage),"userMessageBackgroundColor"in R&&t(21,h=R.userMessageBackgroundColor),"aiMessageBackgroundColor"in R&&t(22,v=R.aiMessageBackgroundColor),"userMessageTextColor"in R&&t(23,f=R.userMessageTextColor),"aiMessageTextColor"in R&&t(24,g=R.aiMessageTextColor),"faviconBackgroundColor"in R&&t(25,y=R.faviconBackgroundColor)},r.$$.update=()=>{r.$$.dirty[0]&67223552&&t(4,e={type:"websocket",url:`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/chat/completions`,headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},additionalBodyProps:{model:l||"test-model",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"},...C&&{chat_id:C},background_tasks:{title_generation:!0,tags_generation:!1,follow_up_generation:!1}},stream:!0}),r.$$.dirty[0]&31457280&&t(3,n={default:{user:{bubble:{backgroundColor:h||"green",color:f||"white"}},ai:{bubble:{backgroundColor:v||"gray",color:g||"black"}}}}),r.$$.dirty[0]&33554432&&t(2,a=(()=>{const R=y||"lightgreen",W=nc(R,-20);return`linear-gradient(135deg, ${R} 0%, ${W} 100%)`})())},[_,G,a,n,e,x,E,F,M,K,Y,ge,ye,xn,i,o,l,u,c,d,p,h,v,f,g,y,C,Wt,Je]}class Ds extends ti{constructor(s){super(),ei(this,s,ac,tc,Us,{apiUrl:14,apiKey:15,modelId:16,maxMessages:17,placeholderText:18,faviconPath:19,initialMessage:20,userMessageBackgroundColor:21,aiMessageBackgroundColor:22,userMessageTextColor:23,aiMessageTextColor:24,faviconBackgroundColor:25},null,[-1,-1])}}function Ir(r,s={}){return new Ds({target:r,props:s})}typeof window<"u"&&window.document&&document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[data-chat-bubble]").forEach(s=>{const t=window.DEEP_CHAT_CONFIG||{};Object.keys(s.dataset).forEach(e=>{if(e.startsWith("chatBubble")){const n=e.replace("chatBubble","").toLowerCase();t[n]=s.dataset[e]}}),Ir(s,t)})});const sc={ChatBubble,createChatBubble:Ir};de.ChatBubble=Ds,de.createChatBubble=Ir,de.default=sc,Object.defineProperties(de,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -278,4 +278,4 @@ ${r.map((t,e)=>{const n=t.name||"Untitled Reference";let a=`**[${e+1}]** `;retur
278
278
 
279
279
  `)}`}function Ba(r){let s,t,e,n,a;return{c(){s=Ut("div"),t=Ut("img"),Hs(t.src,e=r[5])||Ee(t,"src",e),Ee(t,"alt","AI Assistant"),Ee(t,"class","svelte-bjand4"),Ee(s,"class","ai-assistant-icon svelte-bjand4"),Pr(s,"background",r[2]),Ee(s,"role","button"),Ee(s,"tabindex","0")},m(i,o){hr(i,s,o),dr(s,t),n||(a=[Or(s,"click",r[10]),Or(s,"keydown",r[27])],n=!0)},p(i,o){o[0]&4&&Pr(s,"background",i[2])},d(i){i&&_n(s),n=!1,Kt(a)}}}function Da(r){let s,t;return{c(){s=Ut("div"),t=Ut("deep-chat"),ve(t,"demo","false"),ve(t,"textInput",r[9]),ve(t,"messageStyles",r[3]),ve(t,"history",r[6]),ve(t,"connect",r[4]),ve(t,"requestBodyLimits",r[8]),ve(t,"requestInterceptor",r[12]),ve(t,"responseInterceptor",r[13]),ve(t,"customButtons",r[7]),ve(t,"onMessage",r[11]),Ee(s,"class","chat-container svelte-bjand4")},m(e,n){hr(e,s,n),dr(s,t),r[28](t)},p(e,n){n[0]&8&&ve(t,"messageStyles",e[3]),n[0]&16&&ve(t,"connect",e[4])},d(e){e&&_n(s),r[28](null)}}}function nc(r){let s,t,e=!r[0]&&Ba(r),n=r[0]&&Da(r);return{c(){s=Ut("main"),e&&e.c(),t=zs(),n&&n.c(),Ee(s,"class","svelte-bjand4")},m(a,i){hr(a,s,i),e&&e.m(s,null),dr(s,t),n&&n.m(s,null)},p(a,i){a[0]?e&&(e.d(1),e=null):e?e.p(a,i):(e=Ba(a),e.c(),e.m(s,t)),a[0]?n?n.p(a,i):(n=Da(a),n.c(),n.m(s,null)):n&&(n.d(1),n=null)},i:Ft,o:Ft,d(a){a&&_n(s),e&&e.d(),n&&n.d()}}}function rc(r,s){r=r.replace("#","");const t=parseInt(r,16),e=(t>>16)+s,n=(t>>8&255)+s,a=(t&255)+s,i=Math.max(0,Math.min(255,e)),o=Math.max(0,Math.min(255,n)),l=Math.max(0,Math.min(255,a));return`#${(i<<16|o<<8|l).toString(16).padStart(6,"0")}`}function ac(r){return r.map(s=>{let t=s.text||s.content;return(s.role==="ai"||s.role==="assistant")&&(t=t.replace(/\n\n---\n\n\*\*References:\*\*[\s\S]*$/,"")),{role:s.role==="ai"?"assistant":s.role,content:t}})}function sc(r,s,t){let e,n,a,{apiUrl:i=void 0}=s,{apiKey:o=void 0}=s,{modelId:l=void 0}=s,{maxMessages:u=void 0}=s,{placeholderText:c=void 0}=s,{faviconPath:d=void 0}=s,{initialMessage:p=void 0}=s,{userMessageBackgroundColor:h=void 0}=s,{aiMessageBackgroundColor:v=void 0}=s,{userMessageTextColor:f=void 0}=s,{aiMessageTextColor:g=void 0}=s,{faviconBackgroundColor:y=void 0}=s,_=!1,C=null,I=[],w="",A="",U=[],P="",G;const x=d||void 0||Qu,T=p||"Hey, how can I assist you?",E=[{role:"ai",text:T}],B=[{styles:{button:{default:{container:{default:{backgroundColor:"transparent",borderRadius:"4px",width:"24px",height:"24px",border:"1px solid #e0e0e0",cursor:"pointer",transition:"all 0.2s ease"},hover:{backgroundColor:"#2196F3",borderColor:"#2196F3",transform:"scale(1.05)"},click:{backgroundColor:"#1976D2",borderColor:"#1976D2"}},svg:{content:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none">
280
280
  <path d="M19 14L12 21L5 14" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
281
- </svg>`,styles:{default:{width:"14px",height:"14px",color:"#666"},hover:{color:"white"}}}}}},position:"outside-right",tooltip:{text:"Minimize chat",timeout:300,style:{backgroundColor:"#333",color:"white",fontSize:"12px",padding:"4px 8px",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}},onClick:()=>(Y(),"default")}],M={maxMessages:parseInt(u||"0")||0},K={placeholder:{text:c||"Welcome to the demo!"}};function Y(){_?(t(26,C=null),I=[]):$([{role:"assistant",content:T}]),t(0,_=!_)}function ie(){if(console.log("=== Message History ==="),I.length===0){console.log("No messages in history");return}I.forEach((R,W)=>{const se=R.content.length>50?R.content.substring(0,50)+"...":R.content;console.log(`${W+1}. ${R.role.toUpperCase()}: ${se}`)}),console.log("=====================")}async function $(R){var W;try{const se=Math.floor(Date.now()/1e3),ge=[l||"test-model"],oe=[],We={};let $e=null;R.forEach((Me,Xe)=>{const Ye=rn(),lt=Xe<R.length-1?rn():null,ut={id:Ye,parentId:$e,childrenIds:lt?[lt]:[],role:Me.role,content:Me.content,timestamp:se,models:ge};Me.role==="assistant"&&(ut.model=ge[0],ut.modelId=ge[0],ut.modelIdx=0),oe.push(ut),We[Ye]=ut,$e=Ye}),oe.forEach((Me,Xe)=>{Xe<oe.length-1&&(Me.childrenIds=[oe[Xe+1].id])});const Je=(W=oe[oe.length-1])==null?void 0:W.id,xn={chat:{id:"",title:"New Chatbubble Chat",models:ge,params:{},history:{messages:We,currentId:Je},messages:oe,tags:[],timestamp:Date.now()},folder_id:null},Xt=`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/v1/chats/new`,ot=await fetch(Xt,{method:"POST",headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},body:JSON.stringify(xn)});if(ot.ok){const Me=await ot.json();return t(26,C=Me.id),console.log("New chat created with ID:",C),I=oe,ie(),C}else return console.error("Failed to create new chat:",ot.statusText),null}catch(se){return console.error("Error creating new chat:",se),null}}async function ne(R,W,se){if(!C){console.error("Cannot store chat history: no chat ID available");return}console.log("assistantMessageSources:",se);try{const ge=Math.floor(Date.now()/1e3),oe=[l||"test-model"],We=rn(),$e=rn(),Je=I[I.length-1],xn={id:We,parentId:Je?Je.id:null,childrenIds:[$e],role:"user",content:R,timestamp:ge,models:oe},Rr={id:$e,parentId:We,childrenIds:[],role:"assistant",content:W,model:oe[0],modelId:oe[0],modelIdx:0,timestamp:ge,sources:se};Je&&(Je.childrenIds=[We]),I.push(xn,Rr);const Xt={};I.forEach(lt=>{Xt[lt.id]=lt});const ot={chat:{models:oe,history:{messages:Xt,currentId:$e},messages:I,params:{}}},Xe=`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/v1/chats/${C}`,Ye=await fetch(Xe,{method:"POST",headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},body:JSON.stringify(ot)});Ye.ok?(console.log("Chat history stored successfully"),ie()):console.error("Failed to store chat history:",Ye.statusText)}catch(ge){console.error("Error storing chat history:",ge)}}async function fe(R){const{message:W,isHistory:se}=R;if(console.log(R),console.log(W),!se&&(W.role==="ai"||W.role==="assistant")&&(console.log("🤖 AI answered:",W.text||W.content),P&&G)){console.log("📚 Updating AI message with references");const oe=(W.text||W.content||"")+P;console.log(G.getMessages()),console.log(G.getMessages().length-1),G.updateMessage({text:oe},G.getMessages().length-1),P=""}}const me=async R=>{if(R.body&&R.body.messages){R.body.messages=ac(R.body.messages);const W=R.body.messages.filter(se=>se.role==="user");W.length>0&&(w=W[W.length-1].content),C&&(R.body.chat_id=C)}return R},Jt=R=>{console.log(R),R.sources&&Array.isArray(R.sources)&&(U=R.sources,console.log(`Found ${U.length} sources in response`),console.log("assistantMessageSources:",U));try{const W=ec(R);W.length>0&&(P=tc(W),console.log(`Found ${W.length} references in response`))}catch(W){console.error("Error extracting references:",W)}if(R.choices&&R.choices[0]&&R.choices[0].delta){const W=R.choices[0].delta,se=W.content||"";return se&&(A+=se),R.choices[0].finish_reason&&(console.log("Streaming response ended"),w&&A&&ne(w,A,U),A="",w=""),{text:se,role:W.role==="assistant"?"ai":W.role||"ai"}}if(R.choices&&R.choices[0]&&R.choices[0].message){const W=R.choices[0].message;return console.log("Non-streaming response received"),w&&W.content&&(ne(w,W.content),w=""),{text:W.content,role:W.role==="assistant"?"ai":W.role}}return R.text||R.html||R.files?R:typeof R=="string"?{text:R}:R},it=R=>R.key==="Enter"&&Y();function Pe(R){Fn[R?"unshift":"push"](()=>{G=R,t(1,G)})}return r.$$set=R=>{"apiUrl"in R&&t(14,i=R.apiUrl),"apiKey"in R&&t(15,o=R.apiKey),"modelId"in R&&t(16,l=R.modelId),"maxMessages"in R&&t(17,u=R.maxMessages),"placeholderText"in R&&t(18,c=R.placeholderText),"faviconPath"in R&&t(19,d=R.faviconPath),"initialMessage"in R&&t(20,p=R.initialMessage),"userMessageBackgroundColor"in R&&t(21,h=R.userMessageBackgroundColor),"aiMessageBackgroundColor"in R&&t(22,v=R.aiMessageBackgroundColor),"userMessageTextColor"in R&&t(23,f=R.userMessageTextColor),"aiMessageTextColor"in R&&t(24,g=R.aiMessageTextColor),"faviconBackgroundColor"in R&&t(25,y=R.faviconBackgroundColor)},r.$$.update=()=>{r.$$.dirty[0]&67223552&&t(4,e={type:"websocket",url:`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/chat/completions`,headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},additionalBodyProps:{model:l||"test-model",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"},...C&&{chat_id:C},background_tasks:{title_generation:!0,tags_generation:!1,follow_up_generation:!1}},stream:!0}),r.$$.dirty[0]&31457280&&t(3,n={default:{user:{bubble:{backgroundColor:h||"green",color:f||"white"}},ai:{bubble:{backgroundColor:v||"gray",color:g||"black"}}}}),r.$$.dirty[0]&33554432&&t(2,a=(()=>{const R=y||"lightgreen",W=rc(R,-20);return`linear-gradient(135deg, ${R} 0%, ${W} 100%)`})())},[_,G,a,n,e,x,E,B,M,K,Y,fe,me,Jt,i,o,l,u,c,d,p,h,v,f,g,y,C,it,Pe]}class cr extends ni{constructor(s){super(),ti(this,s,sc,nc,js,{apiUrl:14,apiKey:15,modelId:16,maxMessages:17,placeholderText:18,faviconPath:19,initialMessage:20,userMessageBackgroundColor:21,aiMessageBackgroundColor:22,userMessageTextColor:23,aiMessageTextColor:24,faviconBackgroundColor:25},null,[-1,-1])}}function Ds(){const r={apiUrl:"https://localchat.headwai.org/",apiKey:"sk-47ec23c1fd214846ada1e9c812596eef",modelId:"test-model",connectionType:void 0,contentType:void 0,maxMessages:"0",placeholderText:"Welcome to the demo!",demoMode:void 0,userMessageBackgroundColor:"green",aiMessageBackgroundColor:"gray",userMessageTextColor:"white",aiMessageTextColor:"black",faviconBackgroundColor:"lightgreen"},s=typeof window<"u"&&window.HEADWAI_CHAT_BUBBLE_CONFIG||{},t=Object.fromEntries(Object.entries(r).filter(([n,a])=>a!==void 0));console.log("Environment config:",t),console.log("Global config:",s);const e={...t,...s};return console.log("Final merged config:",e),e}typeof window<"u"&&window.document&&document.addEventListener("DOMContentLoaded",()=>{const r=Ds(),s=document.querySelectorAll("[data-chat-bubble]");if(s.length===0){const t=document.getElementById("chat-bubble-container");t&&new cr({target:t,props:r})}else s.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"};Object.keys(t.dataset).forEach(a=>{n[a]&&(e[n[a]]=t.dataset[a])}),new cr({target:t,props:e})})});window.ChatBubble={init:(r,s={})=>new cr({target:r,props:{...Ds(),...s}})};
281
+ </svg>`,styles:{default:{width:"14px",height:"14px",color:"#666"},hover:{color:"white"}}}}}},position:"outside-right",tooltip:{text:"Minimize chat",timeout:300,style:{backgroundColor:"#333",color:"white",fontSize:"12px",padding:"4px 8px",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}},onClick:()=>(Y(),"default")}],M={maxMessages:parseInt(u||"0")||0},K={placeholder:{text:c||"Welcome to the demo!"}};function Y(){_?(t(26,C=null),I=[]):$([{role:"assistant",content:T}]),t(0,_=!_)}function ie(){if(console.log("=== Message History ==="),I.length===0){console.log("No messages in history");return}I.forEach((R,W)=>{const se=R.content.length>50?R.content.substring(0,50)+"...":R.content;console.log(`${W+1}. ${R.role.toUpperCase()}: ${se}`)}),console.log("=====================")}async function $(R){var W;try{const se=Math.floor(Date.now()/1e3),ge=[l||"test-model"],oe=[],We={};let $e=null;R.forEach((Me,Xe)=>{const Ye=rn(),lt=Xe<R.length-1?rn():null,ut={id:Ye,parentId:$e,childrenIds:lt?[lt]:[],role:Me.role,content:Me.content,timestamp:se,models:ge};Me.role==="assistant"&&(ut.model=ge[0],ut.modelId=ge[0],ut.modelIdx=0),oe.push(ut),We[Ye]=ut,$e=Ye}),oe.forEach((Me,Xe)=>{Xe<oe.length-1&&(Me.childrenIds=[oe[Xe+1].id])});const Je=(W=oe[oe.length-1])==null?void 0:W.id,xn={chat:{id:"",title:"New Chatbubble Chat",models:ge,params:{},history:{messages:We,currentId:Je},messages:oe,tags:[],timestamp:Date.now()},folder_id:null},Xt=`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/v1/chats/new`,ot=await fetch(Xt,{method:"POST",headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},body:JSON.stringify(xn)});if(ot.ok){const Me=await ot.json();return t(26,C=Me.id),console.log("New chat created with ID:",C),I=oe,ie(),C}else return console.error("Failed to create new chat:",ot.statusText),null}catch(se){return console.error("Error creating new chat:",se),null}}async function ne(R,W,se){if(!C){console.error("Cannot store chat history: no chat ID available");return}console.log("assistantMessageSources:",se);try{const ge=Math.floor(Date.now()/1e3),oe=[l||"test-model"],We=rn(),$e=rn(),Je=I[I.length-1],xn={id:We,parentId:Je?Je.id:null,childrenIds:[$e],role:"user",content:R,timestamp:ge,models:oe},Rr={id:$e,parentId:We,childrenIds:[],role:"assistant",content:W,model:oe[0],modelId:oe[0],modelIdx:0,timestamp:ge,sources:se};Je&&(Je.childrenIds=[We]),I.push(xn,Rr);const Xt={};I.forEach(lt=>{Xt[lt.id]=lt});const ot={chat:{models:oe,history:{messages:Xt,currentId:$e},messages:I,params:{}}},Xe=`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/v1/chats/${C}`,Ye=await fetch(Xe,{method:"POST",headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},body:JSON.stringify(ot)});Ye.ok?(console.log("Chat history stored successfully"),ie()):console.error("Failed to store chat history:",Ye.statusText)}catch(ge){console.error("Error storing chat history:",ge)}}async function fe(R){const{message:W,isHistory:se}=R;if(console.log(R),console.log(W),!se&&(W.role==="ai"||W.role==="assistant")&&(console.log("🤖 AI answered:",W.text||W.content),P&&G)){console.log("📚 Updating AI message with references");const oe=(W.text||W.content||"")+P;console.log(G.getMessages()),console.log(G.getMessages().length-1),G.updateMessage({text:oe},G.getMessages().length-1),P=""}}const me=async R=>{if(R.body&&R.body.messages){R.body.messages=ac(R.body.messages);const W=R.body.messages.filter(se=>se.role==="user");W.length>0&&(w=W[W.length-1].content),C&&(R.body.chat_id=C)}return R},Jt=R=>{console.log(R),R.sources&&Array.isArray(R.sources)&&(U=R.sources,console.log(`Found ${U.length} sources in response`),console.log("assistantMessageSources:",U));try{const W=ec(R);W.length>0&&(P=tc(W),console.log(`Found ${W.length} references in response`))}catch(W){console.error("Error extracting references:",W)}if(R.choices&&R.choices[0]&&R.choices[0].delta){const W=R.choices[0].delta,se=W.content||"";return se&&(A+=se),R.choices[0].finish_reason&&(console.log("Streaming response ended"),w&&A&&ne(w,A,U),A="",w=""),{text:se,role:W.role==="assistant"?"ai":W.role||"ai"}}if(R.choices&&R.choices[0]&&R.choices[0].message){const W=R.choices[0].message;return console.log("Non-streaming response received"),w&&W.content&&(ne(w,W.content),w=""),{text:W.content,role:W.role==="assistant"?"ai":W.role}}return R.text||R.html||R.files?R:typeof R=="string"?{text:R}:R},it=R=>R.key==="Enter"&&Y();function Pe(R){Fn[R?"unshift":"push"](()=>{G=R,t(1,G)})}return r.$$set=R=>{"apiUrl"in R&&t(14,i=R.apiUrl),"apiKey"in R&&t(15,o=R.apiKey),"modelId"in R&&t(16,l=R.modelId),"maxMessages"in R&&t(17,u=R.maxMessages),"placeholderText"in R&&t(18,c=R.placeholderText),"faviconPath"in R&&t(19,d=R.faviconPath),"initialMessage"in R&&t(20,p=R.initialMessage),"userMessageBackgroundColor"in R&&t(21,h=R.userMessageBackgroundColor),"aiMessageBackgroundColor"in R&&t(22,v=R.aiMessageBackgroundColor),"userMessageTextColor"in R&&t(23,f=R.userMessageTextColor),"aiMessageTextColor"in R&&t(24,g=R.aiMessageTextColor),"faviconBackgroundColor"in R&&t(25,y=R.faviconBackgroundColor)},r.$$.update=()=>{r.$$.dirty[0]&67223552&&t(4,e={type:"websocket",url:`${(i||"https://localchat.headwai.org/").replace(/\/$/,"")}/api/chat/completions`,headers:{Authorization:`Bearer ${o||"sk-47ec23c1fd214846ada1e9c812596eef"}`,"Content-Type":"application/json"},additionalBodyProps:{model:l||"test-model",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"},...C&&{chat_id:C},background_tasks:{title_generation:!0,tags_generation:!1,follow_up_generation:!1}},stream:!0}),r.$$.dirty[0]&31457280&&t(3,n={default:{user:{bubble:{backgroundColor:h||"green",color:f||"white"}},ai:{bubble:{backgroundColor:v||"gray",color:g||"black"}}}}),r.$$.dirty[0]&33554432&&t(2,a=(()=>{const R=y||"lightgreen",W=rc(R,-20);return`linear-gradient(135deg, ${R} 0%, ${W} 100%)`})())},[_,G,a,n,e,x,E,B,M,K,Y,fe,me,Jt,i,o,l,u,c,d,p,h,v,f,g,y,C,it,Pe]}class cr extends ni{constructor(s){super(),ti(this,s,sc,nc,js,{apiUrl:14,apiKey:15,modelId:16,maxMessages:17,placeholderText:18,faviconPath:19,initialMessage:20,userMessageBackgroundColor:21,aiMessageBackgroundColor:22,userMessageTextColor:23,aiMessageTextColor:24,faviconBackgroundColor:25},null,[-1,-1])}}function Ds(){const r={apiUrl:"https://localchat.headwai.org/",apiKey:"sk-47ec23c1fd214846ada1e9c812596eef",modelId:"test-model",connectionType:void 0,contentType:void 0,maxMessages:"0",placeholderText:"Welcome to the demo!",demoMode:void 0,userMessageBackgroundColor:"green",aiMessageBackgroundColor:"gray",userMessageTextColor:"white",aiMessageTextColor:"black",faviconBackgroundColor:"lightgreen"},s=typeof window<"u"&&window.DEEP_CHAT_CONFIG||{};return{...r,...s}}typeof window<"u"&&window.document&&document.addEventListener("DOMContentLoaded",()=>{const r=Ds(),s=document.querySelectorAll("[data-chat-bubble]");if(s.length===0){const t=document.getElementById("chat-bubble-container");t&&new cr({target:t,props:r})}else s.forEach(t=>{const e={...r};Object.keys(t.dataset).forEach(n=>{if(n.startsWith("chatBubble")){const a=n.replace("chatBubble","").toLowerCase();e[a]=t.dataset[n]}}),new cr({target:t,props:e})})});window.ChatBubble={init:(r,s={})=>new cr({target:r,props:{...Ds(),...s}})};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headwai/chat-bubble",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "A chat bubble component for LocalChat by headwAI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",