wineater-bot 1.1.6 → 1.1.7

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.
@@ -1,7 +1,7 @@
1
- var l = Object.defineProperty;
2
- var p = (n, t, e) => t in n ? l(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var r = (n, t, e) => (p(n, typeof t != "symbol" ? t + "" : t, e), e);
4
- const g = `
1
+ var p = Object.defineProperty;
2
+ var g = (i, e, t) => e in i ? p(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var r = (i, e, t) => (g(i, typeof e != "symbol" ? e + "" : e, t), t);
4
+ const h = `
5
5
  @font-face {
6
6
  font-family: 'Poppins';
7
7
  src: url('https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap');
@@ -276,65 +276,65 @@ const g = `
276
276
  .typing-indicator.visible {
277
277
  visibility: visible;
278
278
  height: 50px;
279
- }`, d = document.createElement("style");
280
- d.textContent = g;
281
- document.head.appendChild(d);
282
- function c() {
283
- const n = document.getElementById("chat-window"), t = document.getElementById("chat-icon");
284
- n.classList.contains("visible") ? (n.classList.remove("visible"), t.style.display = "flex") : (n.classList.add("visible"), t.style.display = "none");
285
- }
286
- function h() {
287
- document.getElementById("chat-window").classList.remove("visible");
279
+ }`, c = document.createElement("style");
280
+ c.textContent = h;
281
+ document.head.appendChild(c);
282
+ function l() {
283
+ const i = document.getElementById("chat-window"), e = document.getElementById("chat-icon");
284
+ i.classList.contains("visible") ? (i.classList.remove("visible"), e.style.display = "flex") : (i.classList.add("visible"), e.style.display = "none");
288
285
  }
289
286
  function m() {
287
+ document.getElementById("chat-window").classList.remove("visible");
288
+ }
289
+ function u() {
290
290
  document.getElementById("chat-window").classList.add("visible");
291
291
  }
292
292
  document.addEventListener("DOMContentLoaded", () => {
293
293
  setupCloseButton(), setupOutsideClick();
294
294
  });
295
- const u = ["climats", "telckel", "biobio"];
296
- class f {
297
- constructor(t) {
298
- this.apiEndpoint = t || "https://api.wineater.com/dish/recommendations", this.store = u.find((e) => window.location.href.includes(e)), console.log(this.store);
295
+ const f = ["climats", "telckel", "biobio"];
296
+ class b {
297
+ constructor(e) {
298
+ this.apiEndpoint = e || "https://api.wineater.com/dish/recommendations", this.store = f.find((t) => window.location.href.includes(t)), console.log(this.store);
299
299
  }
300
- async getWineRecommendations(t) {
300
+ async getWineRecommendations(e) {
301
301
  console.log(window.location.href);
302
302
  try {
303
- const e = await fetch(this.apiEndpoint, {
303
+ const t = await fetch(this.apiEndpoint, {
304
304
  method: "POST",
305
305
  headers: {
306
306
  "Content-Type": "application/json"
307
307
  },
308
- body: JSON.stringify({ text: t, store: this.store ? this.store.toString().charAt(0).toUpperCase() + this.store.slice(1) : void 0 })
309
- }), o = await e.json();
310
- if (!e.ok)
311
- throw new Error(`API call failed with status ${e.status}: ${o.message || "No additional error information"}`);
308
+ body: JSON.stringify({ text: e, store: this.store ? this.store.toString().charAt(0).toUpperCase() + this.store.slice(1) : void 0 })
309
+ }), o = await t.json();
310
+ if (!t.ok)
311
+ throw new Error(`API call failed with status ${t.status}: ${o.message || "No additional error information"}`);
312
312
  return o;
313
- } catch (e) {
314
- throw console.error("Fetching wine recommendations failed:", e.message), new Error(`Error in getWineRecommendations: ${e.message}`);
313
+ } catch (t) {
314
+ throw console.error("Fetching wine recommendations failed:", t.message), new Error(`Error in getWineRecommendations: ${t.message}`);
315
315
  }
316
316
  }
317
317
  }
318
- class b {
318
+ class y {
319
319
  constructor() {
320
320
  r(this, "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?");
321
- this.api = new f(), this.displayFirstMessage(this.welcomeMessage);
321
+ this.api = new b(), this.displayFirstMessage(this.welcomeMessage);
322
322
  }
323
323
  initialize() {
324
324
  document.getElementById("send-button").addEventListener("click", () => this.handleUserInput()), document.getElementById("user-input").addEventListener("keypress", (o) => {
325
325
  o.key === "Enter" && this.handleUserInput();
326
326
  });
327
327
  }
328
- displayFirstMessage(t, e = "api") {
329
- const o = document.getElementById("message-container"), i = document.createElement("div");
330
- i.className = `message ${e}`, i.textContent = t, o.appendChild(i), o.scrollTop = o.scrollHeight;
328
+ displayFirstMessage(e, t = "api") {
329
+ const o = document.getElementById("message-container"), n = document.createElement("div");
330
+ n.className = `message ${t}`, n.textContent = e, o.appendChild(n), o.scrollTop = o.scrollHeight;
331
331
  }
332
332
  async handleUserInput() {
333
- const t = document.getElementById("user-input"), e = t.value.trim();
334
- if (e) {
335
- this.displayMessage(e, "user"), t.value = "", this.showTypingIndicator();
333
+ const e = document.getElementById("user-input"), t = e.value.trim();
334
+ if (t) {
335
+ this.displayMessage(t, "user"), e.value = "", this.showTypingIndicator();
336
336
  try {
337
- const o = await this.api.getWineRecommendations(e);
337
+ const o = await this.api.getWineRecommendations(t);
338
338
  this.hideTypingIndicator(), o && o.length ? this.displayResults(o) : this.displayMessage("No results found.", "api");
339
339
  } catch (o) {
340
340
  this.hideTypingIndicator(), console.error("Error fetching wine recommendations:", o), this.displayMessage("Sorry, something went wrong.", "api");
@@ -347,17 +347,17 @@ class b {
347
347
  hideTypingIndicator() {
348
348
  document.getElementById("typing-indicator").classList.remove("visible");
349
349
  }
350
- displayMessage(t, e) {
351
- const o = document.getElementById("message-container"), i = document.createElement("div");
352
- i.textContent = t, i.className = "message " + e, o.appendChild(i), o.scrollTop = o.scrollHeight;
350
+ displayMessage(e, t) {
351
+ const o = document.getElementById("message-container"), n = document.createElement("div");
352
+ n.textContent = e, n.className = "message " + t, o.appendChild(n), o.scrollTop = o.scrollHeight;
353
353
  }
354
- displayResults(t) {
355
- const e = document.getElementById("message-container");
356
- t.forEach((o) => {
357
- const i = document.createElement("div");
358
- i.className = "wine-item";
354
+ displayResults(e) {
355
+ const t = document.getElementById("message-container");
356
+ e.forEach((o) => {
357
+ const n = document.createElement("div");
358
+ n.className = "wine-item";
359
359
  const s = document.createElement("img");
360
- s.src = o.Image, i.appendChild(s);
360
+ s.src = o.Image, n.appendChild(s);
361
361
  const a = document.createElement("div");
362
362
  a.innerHTML = `
363
363
  <strong>${o.Title}</strong><br>
@@ -365,14 +365,14 @@ class b {
365
365
  Région: ${o.Region}<br>
366
366
  Type: ${o.Type}<br>
367
367
  <a href="${o.Url}" target="_blank">Plus d'infos</a>
368
- `, i.appendChild(a), e.appendChild(i);
369
- }), e.scrollTop = e.scrollHeight;
368
+ `, n.appendChild(a), t.appendChild(n);
369
+ }), t.scrollTop = t.scrollHeight;
370
370
  }
371
371
  }
372
372
  document.addEventListener("DOMContentLoaded", () => {
373
- window.toggleChatWindow = c, window.closeChatWindow = h, window.openChatWindow = m;
373
+ window.toggleChatWindow = l, window.closeChatWindow = m, window.openChatWindow = u;
374
374
  });
375
- function y() {
375
+ function w() {
376
376
  document.body.insertAdjacentHTML("beforeend", `
377
377
  <div id="chatbot-container">
378
378
  <div id="chat-icon" onclick="toggleChatWindow()">
@@ -401,25 +401,26 @@ function y() {
401
401
  </div>
402
402
  `);
403
403
  }
404
- function w() {
405
- document.getElementById("close-btn").addEventListener("click", c);
406
- }
407
404
  function x() {
408
- window.addEventListener("click", function(n) {
409
- const t = document.getElementById("chat-window"), e = document.getElementById("chat-icon");
410
- !t.contains(n.target) && !e.contains(n.target) && (t.classList.remove("visible"), e.style.display = "flex");
405
+ document.getElementById("close-btn").addEventListener("click", l);
406
+ }
407
+ function v() {
408
+ window.addEventListener("click", function(i) {
409
+ const e = document.getElementById("chat-window"), t = document.getElementById("chat-icon");
410
+ !e.contains(i.target) && !t.contains(i.target) && (e.classList.remove("visible"), t.style.display = "flex");
411
411
  });
412
412
  }
413
- function v(n) {
414
- console.log(n);
415
- const t = document.getElementById("chat-icon"), e = document.getElementById("chat-window");
416
- t.className = "", e.className = "", n === "right-center" ? (t.classList.add("chat-icon-right-center"), e.classList.add("right-center-aligned")) : t.classList.add("chat-icon-bottom-right");
413
+ function d(i) {
414
+ console.log(i);
415
+ const e = document.getElementById("chat-icon"), t = document.getElementById("chat-window");
416
+ e.className = "", t.className = "", i === "right-center" ? (e.classList.add("chat-icon-right-center"), t.classList.add("right-center-aligned")) : e.classList.add("chat-icon-bottom-right");
417
417
  }
418
418
  typeof window < "u" && window.addEventListener("DOMContentLoaded", () => {
419
- y(), w(), x(), v("right-center"), new b().initialize();
419
+ const e = ["climats", "telckel", "biobio"].find((o) => window.location.href.includes(o)) || null;
420
+ w(), x(), v(), d(e && e === "biobio" ? "right-center" : "bottom-right"), new y().initialize();
420
421
  });
421
422
  export {
422
- h as closeChatWindow,
423
- m as openChatWindow,
424
- c as toggleChatWindow
423
+ m as closeChatWindow,
424
+ u as openChatWindow,
425
+ l as toggleChatWindow
425
426
  };
@@ -1,4 +1,4 @@
1
- (function(i,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(i=typeof globalThis<"u"?globalThis:i||self,s(i.WineaterChatbot={}))})(this,function(i){"use strict";var v=Object.defineProperty;var E=(i,s,r)=>s in i?v(i,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[s]=r;var h=(i,s,r)=>(E(i,typeof s!="symbol"?s+"":s,r),r);const s=`
1
+ (function(n,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(n=typeof globalThis<"u"?globalThis:n||self,s(n.WineaterChatbot={}))})(this,function(n){"use strict";var v=Object.defineProperty;var E=(n,s,r)=>s in n?v(n,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[s]=r;var u=(n,s,r)=>(E(n,typeof s!="symbol"?s+"":s,r),r);const s=`
2
2
  @font-face {
3
3
  font-family: 'Poppins';
4
4
  src: url('https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap');
@@ -273,13 +273,13 @@
273
273
  .typing-indicator.visible {
274
274
  visibility: visible;
275
275
  height: 50px;
276
- }`,r=document.createElement("style");r.textContent=s,document.head.appendChild(r);function d(){const n=document.getElementById("chat-window"),t=document.getElementById("chat-icon");n.classList.contains("visible")?(n.classList.remove("visible"),t.style.display="flex"):(n.classList.add("visible"),t.style.display="none")}function c(){document.getElementById("chat-window").classList.remove("visible")}function l(){document.getElementById("chat-window").classList.add("visible")}document.addEventListener("DOMContentLoaded",()=>{setupCloseButton(),setupOutsideClick()});const u=["climats","telckel","biobio"];class m{constructor(t){this.apiEndpoint=t||"https://api.wineater.com/dish/recommendations",this.store=u.find(e=>window.location.href.includes(e)),console.log(this.store)}async getWineRecommendations(t){console.log(window.location.href);try{const e=await fetch(this.apiEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),o=await e.json();if(!e.ok)throw new Error(`API call failed with status ${e.status}: ${o.message||"No additional error information"}`);return o}catch(e){throw console.error("Fetching wine recommendations failed:",e.message),new Error(`Error in getWineRecommendations: ${e.message}`)}}}class f{constructor(){h(this,"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?");this.api=new m,this.displayFirstMessage(this.welcomeMessage)}initialize(){document.getElementById("send-button").addEventListener("click",()=>this.handleUserInput()),document.getElementById("user-input").addEventListener("keypress",o=>{o.key==="Enter"&&this.handleUserInput()})}displayFirstMessage(t,e="api"){const o=document.getElementById("message-container"),a=document.createElement("div");a.className=`message ${e}`,a.textContent=t,o.appendChild(a),o.scrollTop=o.scrollHeight}async handleUserInput(){const t=document.getElementById("user-input"),e=t.value.trim();if(e){this.displayMessage(e,"user"),t.value="",this.showTypingIndicator();try{const o=await this.api.getWineRecommendations(e);this.hideTypingIndicator(),o&&o.length?this.displayResults(o):this.displayMessage("No results found.","api")}catch(o){this.hideTypingIndicator(),console.error("Error fetching wine recommendations:",o),this.displayMessage("Sorry, something went wrong.","api")}}}showTypingIndicator(){document.getElementById("typing-indicator").classList.add("visible")}hideTypingIndicator(){document.getElementById("typing-indicator").classList.remove("visible")}displayMessage(t,e){const o=document.getElementById("message-container"),a=document.createElement("div");a.textContent=t,a.className="message "+e,o.appendChild(a),o.scrollTop=o.scrollHeight}displayResults(t){const e=document.getElementById("message-container");t.forEach(o=>{const a=document.createElement("div");a.className="wine-item";const p=document.createElement("img");p.src=o.Image,a.appendChild(p);const g=document.createElement("div");g.innerHTML=`
276
+ }`,r=document.createElement("style");r.textContent=s,document.head.appendChild(r);function d(){const i=document.getElementById("chat-window"),t=document.getElementById("chat-icon");i.classList.contains("visible")?(i.classList.remove("visible"),t.style.display="flex"):(i.classList.add("visible"),t.style.display="none")}function c(){document.getElementById("chat-window").classList.remove("visible")}function l(){document.getElementById("chat-window").classList.add("visible")}document.addEventListener("DOMContentLoaded",()=>{setupCloseButton(),setupOutsideClick()});const m=["climats","telckel","biobio"];class f{constructor(t){this.apiEndpoint=t||"https://api.wineater.com/dish/recommendations",this.store=m.find(e=>window.location.href.includes(e)),console.log(this.store)}async getWineRecommendations(t){console.log(window.location.href);try{const e=await fetch(this.apiEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),o=await e.json();if(!e.ok)throw new Error(`API call failed with status ${e.status}: ${o.message||"No additional error information"}`);return o}catch(e){throw console.error("Fetching wine recommendations failed:",e.message),new Error(`Error in getWineRecommendations: ${e.message}`)}}}class b{constructor(){u(this,"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?");this.api=new f,this.displayFirstMessage(this.welcomeMessage)}initialize(){document.getElementById("send-button").addEventListener("click",()=>this.handleUserInput()),document.getElementById("user-input").addEventListener("keypress",o=>{o.key==="Enter"&&this.handleUserInput()})}displayFirstMessage(t,e="api"){const o=document.getElementById("message-container"),a=document.createElement("div");a.className=`message ${e}`,a.textContent=t,o.appendChild(a),o.scrollTop=o.scrollHeight}async handleUserInput(){const t=document.getElementById("user-input"),e=t.value.trim();if(e){this.displayMessage(e,"user"),t.value="",this.showTypingIndicator();try{const o=await this.api.getWineRecommendations(e);this.hideTypingIndicator(),o&&o.length?this.displayResults(o):this.displayMessage("No results found.","api")}catch(o){this.hideTypingIndicator(),console.error("Error fetching wine recommendations:",o),this.displayMessage("Sorry, something went wrong.","api")}}}showTypingIndicator(){document.getElementById("typing-indicator").classList.add("visible")}hideTypingIndicator(){document.getElementById("typing-indicator").classList.remove("visible")}displayMessage(t,e){const o=document.getElementById("message-container"),a=document.createElement("div");a.textContent=t,a.className="message "+e,o.appendChild(a),o.scrollTop=o.scrollHeight}displayResults(t){const e=document.getElementById("message-container");t.forEach(o=>{const a=document.createElement("div");a.className="wine-item";const g=document.createElement("img");g.src=o.Image,a.appendChild(g);const h=document.createElement("div");h.innerHTML=`
277
277
  <strong>${o.Title}</strong><br>
278
278
  Prix: ${o.Price}<br>
279
279
  Région: ${o.Region}<br>
280
280
  Type: ${o.Type}<br>
281
281
  <a href="${o.Url}" target="_blank">Plus d'infos</a>
282
- `,a.appendChild(g),e.appendChild(a)}),e.scrollTop=e.scrollHeight}}document.addEventListener("DOMContentLoaded",()=>{window.toggleChatWindow=d,window.closeChatWindow=c,window.openChatWindow=l});function b(){document.body.insertAdjacentHTML("beforeend",`
282
+ `,a.appendChild(h),e.appendChild(a)}),e.scrollTop=e.scrollHeight}}document.addEventListener("DOMContentLoaded",()=>{window.toggleChatWindow=d,window.closeChatWindow=c,window.openChatWindow=l});function y(){document.body.insertAdjacentHTML("beforeend",`
283
283
  <div id="chatbot-container">
284
284
  <div id="chat-icon" onclick="toggleChatWindow()">
285
285
  <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 -->
@@ -305,4 +305,4 @@
305
305
  </div>
306
306
  </div>
307
307
  </div>
308
- `)}function y(){document.getElementById("close-btn").addEventListener("click",d)}function w(){window.addEventListener("click",function(n){const t=document.getElementById("chat-window"),e=document.getElementById("chat-icon");!t.contains(n.target)&&!e.contains(n.target)&&(t.classList.remove("visible"),e.style.display="flex")})}function x(n){console.log(n);const t=document.getElementById("chat-icon"),e=document.getElementById("chat-window");t.className="",e.className="",n==="right-center"?(t.classList.add("chat-icon-right-center"),e.classList.add("right-center-aligned")):t.classList.add("chat-icon-bottom-right")}typeof window<"u"&&window.addEventListener("DOMContentLoaded",()=>{b(),y(),w(),x("right-center"),new f().initialize()}),i.closeChatWindow=c,i.openChatWindow=l,i.toggleChatWindow=d,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
308
+ `)}function w(){document.getElementById("close-btn").addEventListener("click",d)}function x(){window.addEventListener("click",function(i){const t=document.getElementById("chat-window"),e=document.getElementById("chat-icon");!t.contains(i.target)&&!e.contains(i.target)&&(t.classList.remove("visible"),e.style.display="flex")})}function p(i){console.log(i);const t=document.getElementById("chat-icon"),e=document.getElementById("chat-window");t.className="",e.className="",i==="right-center"?(t.classList.add("chat-icon-right-center"),e.classList.add("right-center-aligned")):t.classList.add("chat-icon-bottom-right")}typeof window<"u"&&window.addEventListener("DOMContentLoaded",()=>{const t=["climats","telckel","biobio"].find(o=>window.location.href.includes(o))||null;y(),w(),x(),p(t&&t==="biobio"?"right-center":"bottom-right"),new b().initialize()}),n.closeChatWindow=c,n.openChatWindow=l,n.toggleChatWindow=d,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wineater-bot",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
package/src/index.js CHANGED
@@ -92,10 +92,16 @@ function toggleChatIconPosition(position) {
92
92
  // If you want to initialize your chatbot automatically when the script is loaded
93
93
  if (typeof window !== 'undefined') {
94
94
  window.addEventListener('DOMContentLoaded', () => {
95
+ const stores = ['climats', 'telckel', 'biobio'];
96
+ const store = stores.find(value => window.location.href.includes(value)) || null;
95
97
  createChatbotUI(); // Create the UI
96
98
  setupCloseButton();
97
99
  setupOutsideClick();
98
- toggleChatIconPosition('right-center');
100
+ if (store && store === 'biobio') {
101
+ toggleChatIconPosition('right-center');
102
+ } else {
103
+ toggleChatIconPosition('bottom-right');
104
+ }
99
105
  const myChatbot = new Chatbot();
100
106
  myChatbot.initialize();
101
107
  });