wineater-bot 1.5.24 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -159,7 +159,7 @@ const b = `
159
159
 
160
160
  /* Message bubble styling */
161
161
  .message {
162
- margin-bottom: 8px;
162
+ margin: 8px 0;
163
163
  padding: 12px;
164
164
  background-color: #e0e0e0; /* Light grey for message bubbles */
165
165
  border-radius: 16px;
@@ -277,16 +277,16 @@ const b = `
277
277
  .typing-indicator.visible {
278
278
  visibility: visible;
279
279
  height: 50px;
280
- }`, h = document.createElement("style");
281
- h.textContent = b;
282
- document.head.appendChild(h);
280
+ }`, g = document.createElement("style");
281
+ g.textContent = b;
282
+ document.head.appendChild(g);
283
283
  function y() {
284
284
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(o) {
285
285
  const t = Math.random() * 16 | 0;
286
286
  return (o === "x" ? t : t & 3 | 8).toString(16);
287
287
  });
288
288
  }
289
- function g(o, t, e) {
289
+ function h(o, t, e) {
290
290
  let n = "";
291
291
  if (e) {
292
292
  const i = /* @__PURE__ */ new Date();
@@ -308,7 +308,7 @@ function s(o) {
308
308
  function x() {
309
309
  const o = "uniqueUserID";
310
310
  let t = s(o);
311
- return t || (t = y(), g(o, t, 365)), t;
311
+ return t || (t = y(), h(o, t, 365)), t;
312
312
  }
313
313
  function d(o, t) {
314
314
  fetch("https://api.wineater.com/proxy/track", {
@@ -358,7 +358,7 @@ const C = ["climats", "telckel", "biobio", "weinpoint", "vinigrandi"], T = "OuhX
358
358
  class f {
359
359
  constructor(t) {
360
360
  var e;
361
- this.baseURL = "https://api.wineater.com/", this.store = C.find((n) => window.location.href.includes(n)), this.token = ((e = window == null ? void 0 : window.wineaterData) == null ? void 0 : e.CLIENT_TOKEN) || T;
361
+ this.baseURL = "http://localhost:3000/", this.store = C.find((n) => window.location.href.includes(n)), this.token = ((e = window == null ? void 0 : window.wineaterData) == null ? void 0 : e.CLIENT_TOKEN) || T;
362
362
  }
363
363
  async getStoreConfig(t) {
364
364
  console.log(t);
@@ -410,18 +410,7 @@ class B {
410
410
  price: "Prix",
411
411
  region: "Région",
412
412
  type: "Type",
413
- moreInfo: "Plus d'infos"
414
- },
415
- de: {
416
- welcomeMessage: "Sublimez votre expérience gastronomique. Il vous suffit de donner les détails de votre plat, et obtenez la recommandation de compagnon de vin idéale. Que voulez-vous manger?",
417
- noResultsFound: "Aucun résultat trouvé.",
418
- somethingWentWrong: "Désolé, quelque chose a mal tourné.",
419
- chatButton: "Accorder le vin au dîner",
420
- inputPlaceholder: "ex., Salade de thon",
421
- sendButton: "Accorder",
422
- price: "Prix",
423
- region: "Région",
424
- type: "Type",
413
+ reason: "Suggestion",
425
414
  moreInfo: "Plus d'infos"
426
415
  },
427
416
  es: {
@@ -434,6 +423,7 @@ class B {
434
423
  price: "Precio",
435
424
  region: "Región",
436
425
  type: "Tipo",
426
+ reason: "Sugerencia",
437
427
  moreInfo: "Más info"
438
428
  },
439
429
  en: {
@@ -446,6 +436,7 @@ class B {
446
436
  price: "Price",
447
437
  region: "Region",
448
438
  type: "Type",
439
+ reason: "Suggestion",
449
440
  moreInfo: "More info"
450
441
  },
451
442
  de: {
@@ -458,6 +449,7 @@ class B {
458
449
  price: "Preis",
459
450
  region: "Region",
460
451
  type: "Typ",
452
+ reason: "Anregung",
461
453
  moreInfo: "Mehr Info"
462
454
  }
463
455
  };
@@ -528,15 +520,15 @@ class W {
528
520
  ${a.translate("region")}: ${n.Region}<br>
529
521
  ${a.translate("type")}: ${n.Type}<br>
530
522
  <a href="${n.Url}" onclick="sendAnalytics(${n.Title})" target="_blank">${a.translate("moreInfo")}</a>
531
- `, i.appendChild(c), e.appendChild(i);
523
+ `, i.appendChild(c), e.appendChild(i), this.displayFirstMessage(n.Reason);
532
524
  }), e.scrollTop = e.scrollHeight;
533
525
  }
534
526
  }
535
- const P = "OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";
527
+ const L = "OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";
536
528
  document.addEventListener("DOMContentLoaded", () => {
537
529
  window.toggleChatWindow = m, window.closeChatWindow = I, window.openChatWindow = E;
538
530
  });
539
- function L() {
531
+ function P() {
540
532
  const o = `
541
533
  <div id="chatbot-container">
542
534
  <div id="chat-icon" onclick="toggleChatWindow()">
@@ -577,7 +569,7 @@ function O() {
577
569
  !t.contains(o.target) && !e.contains(o.target) && (t.classList.remove("visible"), e.style.display = "flex");
578
570
  });
579
571
  }
580
- function D(o) {
572
+ function M(o) {
581
573
  console.log(o);
582
574
  const t = document.getElementById("chat-icon"), e = document.getElementById("chat-window");
583
575
  t.className = "", e.className = "", o === "right-center" ? (t.classList.add("chat-icon-right-center"), e.classList.add("right-center-aligned")) : t.classList.add("chat-icon-bottom-right");
@@ -589,7 +581,7 @@ if (typeof window < "u") {
589
581
  var r;
590
582
  const e = ["climats", "telckel", "biobio", "weinpoint", "vinigrandi"].find((c) => window.location.href.includes(c)) || null;
591
583
  let n;
592
- e && (n = e.charAt(0).toUpperCase() + e.slice(1), n === "Biobio" && (o = "right-center")), await a.fetchConfig(n || "Demo"), L(), S(), O(), D(o), g("chatbotToken", ((r = window.wineaterData) == null ? void 0 : r.CLIENT_TOKEN) || P, 365), x(), new W().initialize();
584
+ e && (n = e.charAt(0).toUpperCase() + e.slice(1), n === "Biobio" && (o = "right-center")), await a.fetchConfig(n || "Demo"), P(), S(), O(), M(o), h("chatbotToken", ((r = window.wineaterData) == null ? void 0 : r.CLIENT_TOKEN) || L, 365), x(), new W().initialize();
593
585
  });
594
586
  }
595
587
  export {
@@ -159,7 +159,7 @@
159
159
 
160
160
  /* Message bubble styling */
161
161
  .message {
162
- margin-bottom: 8px;
162
+ margin: 8px 0;
163
163
  padding: 12px;
164
164
  background-color: #e0e0e0; /* Light grey for message bubbles */
165
165
  border-radius: 16px;
@@ -277,13 +277,13 @@
277
277
  .typing-indicator.visible {
278
278
  visibility: visible;
279
279
  height: 50px;
280
- }`,p=document.createElement("style");p.textContent=d,document.head.appendChild(p);function v(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(o){const t=Math.random()*16|0;return(o==="x"?t:t&3|8).toString(16)})}function g(o,t,e){let n="";if(e){const i=new Date;i.setTime(i.getTime()+e*24*60*60*1e3),n="; expires="+i.toUTCString()}document.cookie=o+"="+(t||"")+n+"; path=/; secure; samesite=strict"}function s(o){const t=o+"=",e=document.cookie.split(";");for(let n=0;n<e.length;n++){let i=e[n];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(t)===0)return i.substring(t.length,i.length)}return null}function k(){const o="uniqueUserID";let t=s(o);return t||(t=v(),g(o,t,365)),t}function c(o,t){fetch("https://api.wineater.com/proxy/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:o,properties:t})}).then(i=>{i.ok||console.error("Mixpanel tracking failed",i)}).catch(i=>{console.error("Mixpanel tracking error",i)})}function m(){c("Chatbot Opened",{distinct_id:s("uniqueUserID"),client:s("chatbotToken")})}function f(){c("Chatbot Closed",{distinct_id:s("uniqueUserID"),client:s("chatbotToken")})}function I(o){c("Message Sent",{distinct_id:s("uniqueUserID"),message_content:o,client:s("chatbotToken")})}function C(o){c("Products Got",{distinct_id:s("uniqueUserID"),products:o,client:s("chatbotToken")})}function E(o){c("Product Clicked",{distinct_id:s("uniqueUserID"),product_id:o,client:s("chatbotToken")})}function u(){const o=document.getElementById("chat-window"),t=document.getElementById("chat-icon");o.classList.contains("visible")?(f(),o.classList.remove("visible"),t.style.display="flex"):(m(),o.classList.add("visible"),t.style.display="none")}function b(){f(),document.getElementById("chat-window").classList.remove("visible")}function y(){m(),document.getElementById("chat-window").classList.add("visible")}document.addEventListener("DOMContentLoaded",()=>{setupCloseButton(),setupOutsideClick()});const T=["climats","telckel","biobio","weinpoint","vinigrandi"],B="OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";class x{constructor(t){var e;this.baseURL="https://api.wineater.com/",this.store=T.find(n=>window.location.href.includes(n)),this.token=((e=window==null?void 0:window.wineaterData)==null?void 0:e.CLIENT_TOKEN)||B}async getStoreConfig(t){console.log(t);try{const e=await fetch(`${this.baseURL}stores/store`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({store:t})});if(!e.ok)throw new Error(`HTTP error! Status: ${e.status}`);return await e.json()}catch(e){throw console.error("Error fetching store configuration:",e),e}}async getWineRecommendations(t){console.log(window.location.href);try{const e=await fetch(`${this.baseURL}dish/recommendations`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({text:t,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),n=await e.json();if(!e.ok)throw new Error(`API call failed with status ${e.status}: ${n.message||"No additional error information"}`);return n}catch(e){throw console.error("Fetching wine recommendations failed:",e.message),new Error(`Error in getWineRecommendations: ${e.message}`)}}}class W{constructor(){this.api=new x,this.language="en",this.translations={fr:{welcomeMessage:"Sublimez votre expérience gastronomique. Il vous suffit de donner les détails de votre plat, et obtenez la recommandation de compagnon de vin idéale. Que voulez-vous manger?",noResultsFound:"Aucun résultat trouvé.",somethingWentWrong:"Désolé, quelque chose a mal tourné.",chatButton:"Accorder le vin au dîner",inputPlaceholder:"ex., Salade de thon",sendButton:"Accorder",price:"Prix",region:"Région",type:"Type",moreInfo:"Plus d'infos"},de:{welcomeMessage:"Sublimez votre expérience gastronomique. Il vous suffit de donner les détails de votre plat, et obtenez la recommandation de compagnon de vin idéale. Que voulez-vous manger?",noResultsFound:"Aucun résultat trouvé.",somethingWentWrong:"Désolé, quelque chose a mal tourné.",chatButton:"Accorder le vin au dîner",inputPlaceholder:"ex., Salade de thon",sendButton:"Accorder",price:"Prix",region:"Région",type:"Type",moreInfo:"Plus d'infos"},es:{welcomeMessage:"Mejore su experiencia gastronómica. Solo proporcione los detalles de su plato y obtenga la recomendación de vino ideal. ¿Qué le gustaría comer?",noResultsFound:"No se encontraron resultados.",somethingWentWrong:"Lo sentimos, algo salió mal.",chatButton:"Maridar vino con cena",inputPlaceholder:"ej., Ensalada de atún",sendButton:"Maridar",price:"Precio",region:"Región",type:"Tipo",moreInfo:"Más info"},en:{welcomeMessage:"Enhance your dining experience. Just provide your dish details and get the ideal wine pairing. What would you like to eat?",noResultsFound:"No results found.",somethingWentWrong:"Sorry, something went wrong.",chatButton:"Pair wine with dinner",inputPlaceholder:"e.g., Tuna Salad",sendButton:"Pair",price:"Price",region:"Region",type:"Type",moreInfo:"More info"},de:{welcomeMessage:"Verbessern Sie Ihr kulinarisches Erlebnis. Geben Sie einfach die Details Ihres Gerichts an und erhalten Sie die ideale Weinempfehlung. Was möchten Sie essen?",noResultsFound:"Keine Ergebnisse gefunden.",somethingWentWrong:"Entschuldigung, etwas ist schief gelaufen.",chatButton:"Wein zum Abendessen",inputPlaceholder:"z.B., Thunfischsalat",sendButton:"Kombinieren",price:"Preis",region:"Region",type:"Typ",moreInfo:"Mehr Info"}}}async fetchConfig(t="Demo"){try{const e=await this.api.getStoreConfig(t);this.language=e.lang}catch{this.language="en"}}translate(t){return this.translations[this.language][t]||t}}const a=new W;class P{constructor(){this.api=new x,this.displayFirstMessage(a.translate("welcomeMessage"))}initialize(){document.getElementById("send-button").addEventListener("click",()=>this.handleUserInput()),document.getElementById("user-input").addEventListener("keypress",n=>{n.key==="Enter"&&this.handleUserInput()})}displayFirstMessage(t,e="api"){const n=document.getElementById("message-container"),i=document.createElement("div");i.className=`message ${e}`,i.textContent=t,n.appendChild(i),n.scrollTop=n.scrollHeight}async handleUserInput(){const t=document.getElementById("user-input"),e=t.value.trim();if(e){this.displayMessage(e,"user"),t.value="",this.showTypingIndicator();try{I(e);const n=await this.api.getWineRecommendations(e);this.hideTypingIndicator(),n&&n.length?this.displayResults(n):this.displayMessage("No results found.","api")}catch{this.hideTypingIndicator(),this.displayMessage(a.translate("somethingWentWrong"),"api")}}}showTypingIndicator(){document.getElementById("typing-indicator").classList.add("visible")}hideTypingIndicator(){document.getElementById("typing-indicator").classList.remove("visible")}displayMessage(t,e){const n=document.getElementById("message-container"),i=document.createElement("div");i.textContent=t,i.className="message "+e,n.appendChild(i),n.scrollTop=n.scrollHeight}sendAnalytics(t){E(t)}displayResults(t){const e=document.getElementById("message-container");C(t.map(n=>n.Title)),t.forEach(n=>{const i=document.createElement("div");i.className="wine-item";const l=document.createElement("img");l.src=n.Image,i.appendChild(l);const h=document.createElement("div");h.innerHTML=`
280
+ }`,p=document.createElement("style");p.textContent=d,document.head.appendChild(p);function v(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(o){const t=Math.random()*16|0;return(o==="x"?t:t&3|8).toString(16)})}function u(o,t,e){let n="";if(e){const i=new Date;i.setTime(i.getTime()+e*24*60*60*1e3),n="; expires="+i.toUTCString()}document.cookie=o+"="+(t||"")+n+"; path=/; secure; samesite=strict"}function s(o){const t=o+"=",e=document.cookie.split(";");for(let n=0;n<e.length;n++){let i=e[n];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(t)===0)return i.substring(t.length,i.length)}return null}function k(){const o="uniqueUserID";let t=s(o);return t||(t=v(),u(o,t,365)),t}function c(o,t){fetch("https://api.wineater.com/proxy/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:o,properties:t})}).then(i=>{i.ok||console.error("Mixpanel tracking failed",i)}).catch(i=>{console.error("Mixpanel tracking error",i)})}function m(){c("Chatbot Opened",{distinct_id:s("uniqueUserID"),client:s("chatbotToken")})}function f(){c("Chatbot Closed",{distinct_id:s("uniqueUserID"),client:s("chatbotToken")})}function I(o){c("Message Sent",{distinct_id:s("uniqueUserID"),message_content:o,client:s("chatbotToken")})}function C(o){c("Products Got",{distinct_id:s("uniqueUserID"),products:o,client:s("chatbotToken")})}function E(o){c("Product Clicked",{distinct_id:s("uniqueUserID"),product_id:o,client:s("chatbotToken")})}function g(){const o=document.getElementById("chat-window"),t=document.getElementById("chat-icon");o.classList.contains("visible")?(f(),o.classList.remove("visible"),t.style.display="flex"):(m(),o.classList.add("visible"),t.style.display="none")}function b(){f(),document.getElementById("chat-window").classList.remove("visible")}function y(){m(),document.getElementById("chat-window").classList.add("visible")}document.addEventListener("DOMContentLoaded",()=>{setupCloseButton(),setupOutsideClick()});const T=["climats","telckel","biobio","weinpoint","vinigrandi"],B="OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";class x{constructor(t){var e;this.baseURL="http://localhost:3000/",this.store=T.find(n=>window.location.href.includes(n)),this.token=((e=window==null?void 0:window.wineaterData)==null?void 0:e.CLIENT_TOKEN)||B}async getStoreConfig(t){console.log(t);try{const e=await fetch(`${this.baseURL}stores/store`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({store:t})});if(!e.ok)throw new Error(`HTTP error! Status: ${e.status}`);return await e.json()}catch(e){throw console.error("Error fetching store configuration:",e),e}}async getWineRecommendations(t){console.log(window.location.href);try{const e=await fetch(`${this.baseURL}dish/recommendations`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({text:t,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),n=await e.json();if(!e.ok)throw new Error(`API call failed with status ${e.status}: ${n.message||"No additional error information"}`);return n}catch(e){throw console.error("Fetching wine recommendations failed:",e.message),new Error(`Error in getWineRecommendations: ${e.message}`)}}}class W{constructor(){this.api=new x,this.language="en",this.translations={fr:{welcomeMessage:"Sublimez votre expérience gastronomique. Il vous suffit de donner les détails de votre plat, et obtenez la recommandation de compagnon de vin idéale. Que voulez-vous manger?",noResultsFound:"Aucun résultat trouvé.",somethingWentWrong:"Désolé, quelque chose a mal tourné.",chatButton:"Accorder le vin au dîner",inputPlaceholder:"ex., Salade de thon",sendButton:"Accorder",price:"Prix",region:"Région",type:"Type",reason:"Suggestion",moreInfo:"Plus d'infos"},es:{welcomeMessage:"Mejore su experiencia gastronómica. Solo proporcione los detalles de su plato y obtenga la recomendación de vino ideal. ¿Qué le gustaría comer?",noResultsFound:"No se encontraron resultados.",somethingWentWrong:"Lo sentimos, algo salió mal.",chatButton:"Maridar vino con cena",inputPlaceholder:"ej., Ensalada de atún",sendButton:"Maridar",price:"Precio",region:"Región",type:"Tipo",reason:"Sugerencia",moreInfo:"Más info"},en:{welcomeMessage:"Enhance your dining experience. Just provide your dish details and get the ideal wine pairing. What would you like to eat?",noResultsFound:"No results found.",somethingWentWrong:"Sorry, something went wrong.",chatButton:"Pair wine with dinner",inputPlaceholder:"e.g., Tuna Salad",sendButton:"Pair",price:"Price",region:"Region",type:"Type",reason:"Suggestion",moreInfo:"More info"},de:{welcomeMessage:"Verbessern Sie Ihr kulinarisches Erlebnis. Geben Sie einfach die Details Ihres Gerichts an und erhalten Sie die ideale Weinempfehlung. Was möchten Sie essen?",noResultsFound:"Keine Ergebnisse gefunden.",somethingWentWrong:"Entschuldigung, etwas ist schief gelaufen.",chatButton:"Wein zum Abendessen",inputPlaceholder:"z.B., Thunfischsalat",sendButton:"Kombinieren",price:"Preis",region:"Region",type:"Typ",reason:"Anregung",moreInfo:"Mehr Info"}}}async fetchConfig(t="Demo"){try{const e=await this.api.getStoreConfig(t);this.language=e.lang}catch{this.language="en"}}translate(t){return this.translations[this.language][t]||t}}const a=new W;class L{constructor(){this.api=new x,this.displayFirstMessage(a.translate("welcomeMessage"))}initialize(){document.getElementById("send-button").addEventListener("click",()=>this.handleUserInput()),document.getElementById("user-input").addEventListener("keypress",n=>{n.key==="Enter"&&this.handleUserInput()})}displayFirstMessage(t,e="api"){const n=document.getElementById("message-container"),i=document.createElement("div");i.className=`message ${e}`,i.textContent=t,n.appendChild(i),n.scrollTop=n.scrollHeight}async handleUserInput(){const t=document.getElementById("user-input"),e=t.value.trim();if(e){this.displayMessage(e,"user"),t.value="",this.showTypingIndicator();try{I(e);const n=await this.api.getWineRecommendations(e);this.hideTypingIndicator(),n&&n.length?this.displayResults(n):this.displayMessage("No results found.","api")}catch{this.hideTypingIndicator(),this.displayMessage(a.translate("somethingWentWrong"),"api")}}}showTypingIndicator(){document.getElementById("typing-indicator").classList.add("visible")}hideTypingIndicator(){document.getElementById("typing-indicator").classList.remove("visible")}displayMessage(t,e){const n=document.getElementById("message-container"),i=document.createElement("div");i.textContent=t,i.className="message "+e,n.appendChild(i),n.scrollTop=n.scrollHeight}sendAnalytics(t){E(t)}displayResults(t){const e=document.getElementById("message-container");C(t.map(n=>n.Title)),t.forEach(n=>{const i=document.createElement("div");i.className="wine-item";const l=document.createElement("img");l.src=n.Image,i.appendChild(l);const h=document.createElement("div");h.innerHTML=`
281
281
  <strong>${n.Title}</strong><br>
282
282
  ${a.translate("price")}: ${n.Price}<br>
283
283
  ${a.translate("region")}: ${n.Region}<br>
284
284
  ${a.translate("type")}: ${n.Type}<br>
285
285
  <a href="${n.Url}" onclick="sendAnalytics(${n.Title})" target="_blank">${a.translate("moreInfo")}</a>
286
- `,i.appendChild(h),e.appendChild(i)}),e.scrollTop=e.scrollHeight}}const L="OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";document.addEventListener("DOMContentLoaded",()=>{window.toggleChatWindow=u,window.closeChatWindow=b,window.openChatWindow=y});function S(){const o=`
286
+ `,i.appendChild(h),e.appendChild(i),this.displayFirstMessage(n.Reason)}),e.scrollTop=e.scrollHeight}}const P="OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";document.addEventListener("DOMContentLoaded",()=>{window.toggleChatWindow=g,window.closeChatWindow=b,window.openChatWindow=y});function S(){const o=`
287
287
  <div id="chatbot-container">
288
288
  <div id="chat-icon" onclick="toggleChatWindow()">
289
289
  <img src="https://landing-static.s3.eu-central-1.amazonaws.com/images/chat-icon.svg" alt="Chat Icon"> <!-- Update the path to your logo image -->
@@ -311,4 +311,4 @@
311
311
  </div>
312
312
  </div>
313
313
  </div>
314
- `;document.body.insertAdjacentHTML("beforeend",o)}function O(){document.getElementById("close-btn").addEventListener("click",u)}function M(){window.addEventListener("click",function(o){const t=document.getElementById("chat-window"),e=document.getElementById("chat-icon");!t.contains(o.target)&&!e.contains(o.target)&&(t.classList.remove("visible"),e.style.display="flex")})}function D(o){console.log(o);const t=document.getElementById("chat-icon"),e=document.getElementById("chat-window");t.className="",e.className="",o==="right-center"?(t.classList.add("chat-icon-right-center"),e.classList.add("right-center-aligned")):t.classList.add("chat-icon-bottom-right")}if(typeof window<"u"){let o=((w=window.wineaterData)==null?void 0:w.POSITION)||"bottom-right";window.addEventListener("DOMContentLoaded",async()=>{var l;const e=["climats","telckel","biobio","weinpoint","vinigrandi"].find(h=>window.location.href.includes(h))||null;let n;e&&(n=e.charAt(0).toUpperCase()+e.slice(1),n==="Biobio"&&(o="right-center")),await a.fetchConfig(n||"Demo"),S(),O(),M(),D(o),g("chatbotToken",((l=window.wineaterData)==null?void 0:l.CLIENT_TOKEN)||L,365),k(),new P().initialize()})}r.closeChatWindow=b,r.openChatWindow=y,r.toggleChatWindow=u,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
314
+ `;document.body.insertAdjacentHTML("beforeend",o)}function O(){document.getElementById("close-btn").addEventListener("click",g)}function M(){window.addEventListener("click",function(o){const t=document.getElementById("chat-window"),e=document.getElementById("chat-icon");!t.contains(o.target)&&!e.contains(o.target)&&(t.classList.remove("visible"),e.style.display="flex")})}function D(o){console.log(o);const t=document.getElementById("chat-icon"),e=document.getElementById("chat-window");t.className="",e.className="",o==="right-center"?(t.classList.add("chat-icon-right-center"),e.classList.add("right-center-aligned")):t.classList.add("chat-icon-bottom-right")}if(typeof window<"u"){let o=((w=window.wineaterData)==null?void 0:w.POSITION)||"bottom-right";window.addEventListener("DOMContentLoaded",async()=>{var l;const e=["climats","telckel","biobio","weinpoint","vinigrandi"].find(h=>window.location.href.includes(h))||null;let n;e&&(n=e.charAt(0).toUpperCase()+e.slice(1),n==="Biobio"&&(o="right-center")),await a.fetchConfig(n||"Demo"),S(),O(),M(),D(o),u("chatbotToken",((l=window.wineaterData)==null?void 0:l.CLIENT_TOKEN)||P,365),k(),new L().initialize()})}r.closeChatWindow=b,r.openChatWindow=y,r.toggleChatWindow=g,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wineater-bot",
3
- "version": "1.5.24",
3
+ "version": "1.6.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
package/src/js/api.js CHANGED
@@ -6,7 +6,8 @@ const DEMO_TOKEN='OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOO
6
6
  export class Api {
7
7
  constructor(apiEndpoint) {
8
8
  // Allow users of the library to specify their own endpoint if needed
9
- this.baseURL = 'https://api.wineater.com/';
9
+ // this.baseURL = 'https://api.wineater.com/';
10
+ this.baseURL = 'http://localhost:3000/'
10
11
  this.store = stores.find(value => window.location.href.includes(value));
11
12
  this.token = window?.wineaterData?.CLIENT_TOKEN || DEMO_TOKEN;
12
13
  }
package/src/js/chatbot.js CHANGED
@@ -106,8 +106,11 @@ export class Chatbot {
106
106
  <a href="${wine.Url}" onclick="sendAnalytics(${wine.Title})" target="_blank">${translator.translate('moreInfo')}</a>
107
107
  `;
108
108
  wineDiv.appendChild(contentDiv);
109
-
109
+ // const suggestionDiv = document.createElement('div');
110
+ // suggestionDiv.innerHTML = `${translator.translate('reason')}: ${wine.Reason}<br>`;
111
+ // wineDiv.appendChild(suggestionDiv);
110
112
  messageContainer.appendChild(wineDiv);
113
+ this.displayFirstMessage(wine.Reason);
111
114
  });
112
115
  messageContainer.scrollTop = messageContainer.scrollHeight;
113
116
  }
package/src/js/i18n.js CHANGED
@@ -15,18 +15,7 @@ class Translator {
15
15
  price: "Prix",
16
16
  region: "Région",
17
17
  type: "Type",
18
- moreInfo: "Plus d'infos"
19
- },
20
- de: {
21
- welcomeMessage: "Sublimez votre expérience gastronomique. Il vous suffit de donner les détails de votre plat, et obtenez la recommandation de compagnon de vin idéale. Que voulez-vous manger?",
22
- noResultsFound: "Aucun résultat trouvé.",
23
- somethingWentWrong: "Désolé, quelque chose a mal tourné.",
24
- chatButton: "Accorder le vin au dîner",
25
- inputPlaceholder: "ex., Salade de thon",
26
- sendButton: "Accorder",
27
- price: "Prix",
28
- region: "Région",
29
- type: "Type",
18
+ reason: "Suggestion",
30
19
  moreInfo: "Plus d'infos"
31
20
  },
32
21
  es: {
@@ -39,6 +28,7 @@ class Translator {
39
28
  price: "Precio",
40
29
  region: "Región",
41
30
  type: "Tipo",
31
+ reason: "Sugerencia",
42
32
  moreInfo: "Más info"
43
33
  },
44
34
  en: {
@@ -51,6 +41,7 @@ class Translator {
51
41
  price: "Price",
52
42
  region: "Region",
53
43
  type: "Type",
44
+ reason: "Suggestion",
54
45
  moreInfo: "More info"
55
46
  },
56
47
  de: {
@@ -63,6 +54,7 @@ class Translator {
63
54
  price: "Preis",
64
55
  region: "Region",
65
56
  type: "Typ",
57
+ reason: "Anregung",
66
58
  moreInfo: "Mehr Info"
67
59
  }
68
60
  };
package/src/js/styles.js CHANGED
@@ -160,7 +160,7 @@ const css = `
160
160
 
161
161
  /* Message bubble styling */
162
162
  .message {
163
- margin-bottom: 8px;
163
+ margin: 8px 0;
164
164
  padding: 12px;
165
165
  background-color: #e0e0e0; /* Light grey for message bubbles */
166
166
  border-radius: 16px;