tanya-chatbot 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { useEffect as bt, useState as P, useRef as Ft } from "react";
2
- import { jsx as a, jsxs as u, Fragment as ee } from "react/jsx-runtime";
1
+ import { useEffect as bt, useState as P, useRef as It } from "react";
2
+ import { jsx as a, jsxs as u, Fragment as re } from "react/jsx-runtime";
3
3
  import { createHttpLink as ir, ApolloClient as sr, InMemoryCache as lr, ApolloProvider as cr } from "@apollo/client";
4
4
  import { Provider as dr, useDispatch as Ae, useSelector as Mt } from "react-redux";
5
5
  import { createSlice as De, configureStore as ur } from "@reduxjs/toolkit";
@@ -73,7 +73,7 @@ const fr = {
73
73
  t.product = e.payload;
74
74
  }
75
75
  }
76
- }), { setProduct: re } = Ue.actions, wr = Ue.reducer, gr = ur({
76
+ }), { setProduct: oe } = Ue.actions, wr = Ue.reducer, gr = ur({
77
77
  reducer: {
78
78
  store: mr,
79
79
  product: wr
@@ -101,7 +101,7 @@ const st = () => ({ aiConversationUrl: "https://mdv3qwfi2j.execute-api.us-east-1
101
101
  const t = "https://tanya-sfcc-server.vercel.app/";
102
102
  try {
103
103
  const e = await E.post(
104
- `${t}api/auth/token-bm-grant?baseUrl=${Z()}&siteId=${R()}`
104
+ `${t}api/auth/token-bm-grant?baseUrl=${Z()}&siteId=${V()}`
105
105
  );
106
106
  return e.status === 200 && e.data.access_token ? e.data.access_token : (console.error("Failed to fetch token:", e.data), null);
107
107
  } catch (e) {
@@ -111,7 +111,7 @@ const st = () => ({ aiConversationUrl: "https://mdv3qwfi2j.execute-api.us-east-1
111
111
  const e = "https://tanya-sfcc-server.vercel.app/";
112
112
  try {
113
113
  const r = JSON.parse(sessionStorage.getItem("customerData") || "{}").dwsid, o = await E.post(
114
- `${e}api/auth/token-existing-guest-customer?dwsid=${r}&baseUrl=${Z()}&siteId=${R()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
114
+ `${e}api/auth/token-existing-guest-customer?dwsid=${r}&baseUrl=${Z()}&siteId=${V()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
115
115
  {},
116
116
  {
117
117
  headers: {
@@ -137,7 +137,7 @@ async function Ot() {
137
137
  ).usrRef;
138
138
  try {
139
139
  const d = r ? "unregister-auth" : "register-auth", i = await E.get(
140
- `${o}sc-api/${d}?dwsid=${n}&email=${l}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}&siteId=${R()}&token=true`,
140
+ `${o}sc-api/${d}?dwsid=${n}&email=${l}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}&siteId=${V()}&token=true`,
141
141
  {
142
142
  withCredentials: !0
143
143
  }
@@ -150,7 +150,7 @@ async function Ot() {
150
150
  console.log(d);
151
151
  }
152
152
  }
153
- const Z = () => sessionStorage.getItem("Host"), R = () => sessionStorage.getItem("SiteId"), tt = () => sessionStorage.getItem("pubCfg"), et = () => sessionStorage.getItem("envRef"), rt = () => sessionStorage.getItem("orgRef"), be = async (t) => {
153
+ const Z = () => sessionStorage.getItem("Host"), V = () => sessionStorage.getItem("SiteId"), tt = () => sessionStorage.getItem("pubCfg"), et = () => sessionStorage.getItem("envRef"), rt = () => sessionStorage.getItem("orgRef"), be = async (t) => {
154
154
  console.log("fetching results");
155
155
  const { serverUrl: e, basePath: r } = st();
156
156
  let o = "";
@@ -161,7 +161,7 @@ const Z = () => sessionStorage.getItem("Host"), R = () => sessionStorage.getItem
161
161
  try {
162
162
  const n = Z();
163
163
  return (await E.get(
164
- `${e}${r}/search-sfcc?baseUrl=${n}&query=${t}&siteId=${R()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
164
+ `${e}${r}/search-sfcc?baseUrl=${n}&query=${t}&siteId=${V()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
165
165
  {
166
166
  headers: {
167
167
  "Content-Type": "application/json",
@@ -178,7 +178,7 @@ const Z = () => sessionStorage.getItem("Host"), R = () => sessionStorage.getItem
178
178
  console.log("calling access");
179
179
  const { access_token: n } = await Ot();
180
180
  return console.log(n), (await E.get(
181
- `${e}${r}/product-sfcc/${t}?baseUrl=${o}&siteId=${R()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
181
+ `${e}${r}/product-sfcc/${t}?baseUrl=${o}&siteId=${V()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
182
182
  {
183
183
  headers: {
184
184
  "Content-Type": "application/json",
@@ -192,7 +192,7 @@ const Z = () => sessionStorage.getItem("Host"), R = () => sessionStorage.getItem
192
192
  e
193
193
  ), { serverUrl: o, basePath: n } = st(), s = (await Ot()).access_token;
194
194
  return (await E.get(
195
- `${o}${n}/get-interest?baseUrl=${Z()}&customerId=${t}&siteId=${R()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
195
+ `${o}${n}/get-interest?baseUrl=${Z()}&customerId=${t}&siteId=${V()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
196
196
  {
197
197
  headers: {
198
198
  "Content-Type": "application/json",
@@ -212,7 +212,7 @@ const Z = () => sessionStorage.getItem("Host"), R = () => sessionStorage.getItem
212
212
  centAmount: (r = t.masterVariant) == null ? void 0 : r.prices[0].value.centAmount,
213
213
  currencyCode: (o = t.masterVariant) == null ? void 0 : o.prices[0].value.currencyCode
214
214
  };
215
- }, Sr = (t) => t.charAt(0).toUpperCase() + t.slice(1), ke = (t, e) => t.length < e ? t : t.slice(0, e) + "...", Wt = (t) => t.split("\\n").map((e, r) => {
215
+ }, Sr = (t) => t.charAt(0).toUpperCase() + t.slice(1), ke = (t, e) => t.length < e ? t : t.slice(0, e) + "...", Xt = (t) => t.split("\\n").map((e, r) => {
216
216
  const o = e.match(/^(\d+)\.\s(.+)/);
217
217
  return o ? `<p key=${r} class="mb-2"><strong>${o[1]}.</strong> ${o[2]}</p>` : e.trim() ? `<p key=${r} class="mb-2">${e}</p>` : "<br/>";
218
218
  }).join("");
@@ -236,7 +236,7 @@ const _r = ({
236
236
  );
237
237
  }, d = async (i) => {
238
238
  const x = await He(i);
239
- e(re(x));
239
+ e(oe(x));
240
240
  };
241
241
  return /* @__PURE__ */ a("div", { className: "mt-2 overflow-x-hidden", children: /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-4 relative", children: [
242
242
  (t == null ? void 0 : t.length) > r && /* @__PURE__ */ a(
@@ -246,7 +246,9 @@ const _r = ({
246
246
  className: "absolute z-50 left-0 text-[#000000] bg-[#ffffff] rounded-full p-2 flex items-center h-fit",
247
247
  style: {
248
248
  height: "30px",
249
- width: "30px"
249
+ width: "30px",
250
+ boxShadow: "0 4px 10px rgba(0, 0, 0, 0.25)",
251
+ borderRadius: "8px"
250
252
  },
251
253
  children: "<"
252
254
  }
@@ -323,13 +325,15 @@ const _r = ({
323
325
  className: "absolute z-50 right-0 text-[#000000] bg-[#ffffff] rounded-full p-2 flex items-center h-fit",
324
326
  style: {
325
327
  height: "30px",
326
- width: "30px"
328
+ width: "30px",
329
+ boxShadow: "0 4px 10px rgba(0, 0, 0, 0.25)",
330
+ borderRadius: "8px"
327
331
  },
328
332
  children: ">"
329
333
  }
330
334
  )
331
335
  ] }) });
332
- }, Fr = ({ chat: t, storeDetails: e }) => /* @__PURE__ */ a("div", { className: "bg-[#FFFFFF] px-7 py-4 rounded-r-xl rounded-bl-2xl w-full", children: t.map((r, o) => /* @__PURE__ */ u(
336
+ }, Ir = ({ chat: t, storeDetails: e }) => /* @__PURE__ */ a("div", { className: "bg-[#FFFFFF] px-7 py-4 rounded-r-xl rounded-bl-2xl w-full", children: t.map((r, o) => /* @__PURE__ */ u(
333
337
  "div",
334
338
  {
335
339
  className: "mb-4 p-3 rounded-xl",
@@ -355,13 +359,13 @@ const _r = ({
355
359
  ]
356
360
  },
357
361
  o
358
- )) }), Ve = async (t, e) => {
362
+ )) }), Re = async (t, e) => {
359
363
  const { serverUrl: r, basePath: o } = st(), n = `${r}`;
360
364
  console.log(`customer_token
361
365
  `, t);
362
366
  try {
363
367
  return (await E.post(
364
- `${n}${o}/basket/create?baseUrl=${Z()}&siteId=${R()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
368
+ `${n}${o}/basket/create?baseUrl=${Z()}&siteId=${V()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
365
369
  e,
366
370
  {
367
371
  headers: {
@@ -373,11 +377,11 @@ const _r = ({
373
377
  } catch (l) {
374
378
  return E.isAxiosError(l) ? console.error("Error creating basket:", l.response || l.message) : console.error("Unexpected error:", l), null;
375
379
  }
376
- }, Vt = async (t, e, r) => {
380
+ }, Rt = async (t, e, r) => {
377
381
  const { serverUrl: o, basePath: n } = st(), l = `${o}`;
378
382
  try {
379
383
  const s = await E.post(
380
- `${l}${n}/basket/add-product/${t}?baseUrl=${Z()}&siteId=${R()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
384
+ `${l}${n}/basket/add-product/${t}?baseUrl=${Z()}&siteId=${V()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
381
385
  e,
382
386
  {
383
387
  headers: {
@@ -393,7 +397,7 @@ const _r = ({
393
397
  s.response || s.message
394
398
  ) : console.error("Unexpected error:", s), null;
395
399
  }
396
- }, Re = async ({
400
+ }, Ve = async ({
397
401
  basketId: t,
398
402
  customer_token: e
399
403
  }) => {
@@ -401,7 +405,7 @@ const _r = ({
401
405
  const { serverUrl: r, basePath: o } = st(), n = `${r}`;
402
406
  try {
403
407
  const s = await E.get(
404
- `${n}${o}/basket/${t}?baseUrl=${Z()}&siteId=${R()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
408
+ `${n}${o}/basket/${t}?baseUrl=${Z()}&siteId=${V()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
405
409
  {
406
410
  headers: {
407
411
  "Content-Type": "application/json",
@@ -413,18 +417,18 @@ const _r = ({
413
417
  } catch (s) {
414
418
  return E.isAxiosError(s) ? { status: (l = s.response) == null ? void 0 : l.status, data: null } : { status: null, data: null };
415
419
  }
416
- }, oe = "sfcc_basket_id", Se = "sfcc_customer_token", Tt = "sfcc_token_expiry", Ir = 300 * 1e3, It = "1.0.0";
420
+ }, Vt = "sfcc_basket_id", Se = "sfcc_customer_token", Tt = "sfcc_token_expiry", Fr = 300 * 1e3, Ft = "1.0.0";
417
421
  const xt = (t) => {
418
422
  try {
419
- t ? localStorage.setItem(oe, t) : localStorage.removeItem(oe);
423
+ t ? localStorage.setItem(Vt, t) : localStorage.removeItem(Vt);
420
424
  } catch (e) {
421
425
  console.error("Error saving basket ID to storage:", e);
422
426
  }
423
- }, Rt = (t) => {
427
+ }, Yt = (t) => {
424
428
  try {
425
429
  if (t) {
426
430
  localStorage.setItem(Se, t);
427
- const e = Date.now() + Ir;
431
+ const e = Date.now() + Fr;
428
432
  localStorage.setItem(Tt, e.toString());
429
433
  } else
430
434
  localStorage.removeItem(Se);
@@ -457,8 +461,8 @@ const xt = (t) => {
457
461
  console.log(p, "the product data");
458
462
  const _t = JSON.parse(
459
463
  sessionStorage.getItem("customerData") || "{}"
460
- ), nt = _t == null ? void 0 : _t.basketId, Jt = !1, jt = localStorage.getItem(Tt), Y = Date.now();
461
- if (!Jt || !jt || Y >= parseInt(jt)) {
464
+ ), nt = (_t == null ? void 0 : _t.basketId) || localStorage.getItem(Vt), Kt = !1, jt = localStorage.getItem(Tt), Y = Date.now();
465
+ if (!Kt || !jt || Y >= parseInt(jt)) {
462
466
  let $ = "";
463
467
  {
464
468
  const K = await Ot();
@@ -469,13 +473,13 @@ const xt = (t) => {
469
473
  return;
470
474
  }
471
475
  const At = Y + 300 * 1e3;
472
- if (Rt($), localStorage.setItem(Tt, At.toString()), nt) {
473
- const K = await Re({
476
+ if (Yt($), localStorage.setItem(Tt, At.toString()), nt) {
477
+ const K = await Ve({
474
478
  basketId: nt,
475
479
  customer_token: $
476
480
  });
477
481
  if (console.log(nt, "basket id from customer"), K.status === 200 && K) {
478
- const G = await Vt(
482
+ const G = await Rt(
479
483
  nt,
480
484
  p,
481
485
  $
@@ -491,7 +495,7 @@ const xt = (t) => {
491
495
  return;
492
496
  }
493
497
  }
494
- const Kt = {
498
+ const Gt = {
495
499
  productItems: [
496
500
  {
497
501
  productId: ((kt = e.variants) == null ? void 0 : kt[0].product_id) || ((St = e.variants) == null ? void 0 : St[0].productId) || (e == null ? void 0 : e.id),
@@ -500,7 +504,7 @@ const xt = (t) => {
500
504
  ]
501
505
  };
502
506
  console.log("before create basket");
503
- const h = await Ve($, Kt);
507
+ const h = await Re($, Gt);
504
508
  if (console.log(
505
509
  h,
506
510
  h == null ? void 0 : h.basket_id,
@@ -516,7 +520,7 @@ const xt = (t) => {
516
520
  ), xt(
517
521
  (h == null ? void 0 : h.basket_id) || (h == null ? void 0 : h.basketId)
518
522
  ), console.log("adding product to basket");
519
- const J = await Vt(
523
+ const J = await Rt(
520
524
  (h == null ? void 0 : h.basket_id) || (h == null ? void 0 : h.basketId),
521
525
  p,
522
526
  $
@@ -535,7 +539,7 @@ const xt = (t) => {
535
539
  position: "bottom-right",
536
540
  autoClose: 3e3
537
541
  }), ((zt = p == null ? void 0 : p.response) == null ? void 0 : zt.status) === 404 || // Basket not found
538
- ((Ct = p == null ? void 0 : p.response) == null ? void 0 : Ct.status) === 401 ? (((O = p == null ? void 0 : p.response) == null ? void 0 : O.status) === 404 && xt(null), ((dt = p == null ? void 0 : p.response) == null ? void 0 : dt.status) === 401 && (xt(null), Rt(null))) : (console.error("Failed to add product to basket:", p.message), U.error("Failed to add product to cart", {
542
+ ((Ct = p == null ? void 0 : p.response) == null ? void 0 : Ct.status) === 401 ? (((O = p == null ? void 0 : p.response) == null ? void 0 : O.status) === 404 && xt(null), ((dt = p == null ? void 0 : p.response) == null ? void 0 : dt.status) === 401 && (xt(null), Yt(null))) : (console.error("Failed to add product to basket:", p.message), U.error("Failed to add product to cart", {
539
543
  position: "bottom-right",
540
544
  autoClose: 3e3
541
545
  }));
@@ -543,13 +547,13 @@ const xt = (t) => {
543
547
  }, s = () => {
544
548
  e && (window.location.href = e.c_pdpUrl);
545
549
  };
546
- return console.log(e, "the prod"), /* @__PURE__ */ u(ee, { children: [
550
+ return console.log(e, "the prod"), /* @__PURE__ */ u(re, { children: [
547
551
  /* @__PURE__ */ a(
548
552
  "div",
549
553
  {
550
554
  className: "fixed inset-0 z-40 bg-black/30",
551
555
  onClick: () => {
552
- n(!1), setTimeout(() => t(re(null)), Ce);
556
+ n(!1), setTimeout(() => t(oe(null)), Ce);
553
557
  }
554
558
  }
555
559
  ),
@@ -573,7 +577,7 @@ const xt = (t) => {
573
577
  className: "text-[#555555] w-6 h-6 cursor-pointer",
574
578
  onClick: () => {
575
579
  n(!1), setTimeout(
576
- () => t(re(null)),
580
+ () => t(oe(null)),
577
581
  Ce
578
582
  );
579
583
  }
@@ -624,7 +628,9 @@ const xt = (t) => {
624
628
  "div",
625
629
  {
626
630
  className: "text-[#68656E] font-normal font-nunitoSans text-xs pl-2 mt-3",
627
- dangerouslySetInnerHTML: { __html: e.short_description || e.longDescription }
631
+ dangerouslySetInnerHTML: {
632
+ __html: e.short_description || e.longDescription
633
+ }
628
634
  }
629
635
  )
630
636
  ] }),
@@ -706,18 +712,18 @@ const xt = (t) => {
706
712
  "Niece/Nephew": "his/her niece/nephew",
707
713
  "My Friends": "his/her friends",
708
714
  Others: "others"
709
- }, o = Ft(null), n = Ft(null), l = Ft(null), s = Ft(null), [d, i] = P(null), [x, b] = P(!1), [C, S] = P(!1), [_, j] = P(!1), [q, M] = P(!1), [lt, vt] = P(!1), [Pt, ot] = P(!1), [kt, St] = P(""), [ct, $t] = P(""), zt = (c) => ({
715
+ }, o = It(null), n = It(null), l = It(null), s = It(null), [d, i] = P(null), [x, b] = P(!1), [C, S] = P(!1), [_, j] = P(!1), [q, M] = P(!1), [lt, vt] = P(!1), [Pt, ot] = P(!1), [kt, St] = P(""), [ct, $t] = P(""), zt = (c) => ({
710
716
  id: c.id,
711
717
  title: c.name,
712
718
  image: c.image ?? "",
713
719
  price: c.price ?? 0
714
- }), [Ct, O] = P([]), dt = Ft(null), p = Mt((c) => c.store.store), _t = Mt((c) => c.product.product), nt = () => {
720
+ }), [Ct, O] = P([]), dt = It(null), p = Mt((c) => c.store.store), _t = Mt((c) => c.product.product), nt = () => {
715
721
  j(!0), setTimeout(() => S(!0), 10);
716
- }, Jt = () => {
722
+ }, Kt = () => {
717
723
  S(!1), setTimeout(() => j(!1), 300);
718
724
  };
719
725
  bt(() => {
720
- x ? nt() : Jt();
726
+ x ? nt() : Kt();
721
727
  }, [x]);
722
728
  const jt = (c) => {
723
729
  $t(r[c]);
@@ -753,7 +759,7 @@ const xt = (t) => {
753
759
  } catch (c) {
754
760
  return console.error("Error obtaining JWT token:", c), Y = null, $ = null, null;
755
761
  }
756
- }, Kt = async () => {
762
+ }, Gt = async () => {
757
763
  const c = await Ot();
758
764
  c != null && i(c);
759
765
  };
@@ -762,7 +768,7 @@ const xt = (t) => {
762
768
  const { clientID: c, host: k, organizationID: w, shortCode: y, siteId: f } = t;
763
769
  sessionStorage.setItem("Host", k), sessionStorage.setItem("SiteId", f), sessionStorage.setItem("pubCfg", btoa(c)), sessionStorage.setItem("envRef", y), sessionStorage.setItem("orgRef", w);
764
770
  }
765
- Kt(), console.log("scapi environment v1");
771
+ Gt(), console.log("scapi environment v1");
766
772
  }, []);
767
773
  const h = async () => {
768
774
  const c = JSON.parse(
@@ -770,13 +776,13 @@ const xt = (t) => {
770
776
  ).customerId;
771
777
  return (await vr(c || "")).c_interests;
772
778
  }, J = async (c, k) => {
773
- console.log("in secondary flow", It);
779
+ console.log("in secondary flow", Ft);
774
780
  const w = await h();
775
- if (console.log(w, "interests of customer", It), !!w)
781
+ if (console.log(w, "interests of customer", Ft), !!w)
776
782
  try {
777
783
  O(
778
784
  (L) => L.map(
779
- (H, V) => V === L.length - 1 ? { ...H, secondaryLoading: !0 } : H
785
+ (H, R) => R === L.length - 1 ? { ...H, secondaryLoading: !0 } : H
780
786
  )
781
787
  );
782
788
  const y = await At();
@@ -809,17 +815,17 @@ const xt = (t) => {
809
815
  const { done: L, value: H } = await ft.read();
810
816
  if (L) break;
811
817
  D += mt.decode(H, { stream: !0 });
812
- const V = D.split(`
818
+ const R = D.split(`
813
819
  `);
814
- D = V.pop() || "";
815
- for (const W of V)
820
+ D = R.pop() || "";
821
+ for (const W of R)
816
822
  if (W.startsWith("data:")) {
817
823
  const m = W.slice(5).trim();
818
824
  try {
819
825
  const B = JSON.parse(m);
820
826
  B.index === 0 && O(
821
- (F) => F.map(
822
- (T, X) => X === F.length - 1 ? {
827
+ (I) => I.map(
828
+ (T, X) => X === I.length - 1 ? {
823
829
  ...T,
824
830
  secondaryResponse: B.data,
825
831
  secondaryLoading: !1
@@ -828,8 +834,8 @@ const xt = (t) => {
828
834
  );
829
835
  } catch (B) {
830
836
  O(
831
- (F) => F.map(
832
- (T, X) => X === F.length - 1 ? { ...T, secondaryLoading: !1 } : T
837
+ (I) => I.map(
838
+ (T, X) => X === I.length - 1 ? { ...T, secondaryLoading: !1 } : T
833
839
  )
834
840
  ), console.error("Secondary flow JSON parse error:", B);
835
841
  }
@@ -881,9 +887,9 @@ const xt = (t) => {
881
887
  let D = "", L = "";
882
888
  for (; ; ) {
883
889
  ot(!0);
884
- const { done: H, value: V } = await ft.read();
890
+ const { done: H, value: R } = await ft.read();
885
891
  if (H) break;
886
- D += mt.decode(V, { stream: !0 });
892
+ D += mt.decode(R, { stream: !0 });
887
893
  const W = D.split(`
888
894
  `);
889
895
  D = W.pop() || "";
@@ -891,17 +897,17 @@ const xt = (t) => {
891
897
  if (m.startsWith("data:")) {
892
898
  const B = m.slice(5).trim();
893
899
  try {
894
- const F = JSON.parse(B);
895
- F.index == 1 && (L = F.data), O(
900
+ const I = JSON.parse(B);
901
+ I.index == 1 && (L = I.data), O(
896
902
  (T) => T.map(
897
903
  (X, Dt) => Dt === T.length - 1 ? {
898
904
  ...X,
899
- [F.index == 0 ? "response" : F.index == 1 ? "keywords" : F.index == 2 ? "potentialQuestions" : "end"]: F.data
905
+ [I.index == 0 ? "response" : I.index == 1 ? "keywords" : I.index == 2 ? "potentialQuestions" : "end"]: I.data
900
906
  } : X
901
907
  )
902
908
  );
903
- } catch (F) {
904
- console.error("Error parsing JSON:", F);
909
+ } catch (I) {
910
+ console.error("Error parsing JSON:", I);
905
911
  }
906
912
  }
907
913
  }
@@ -974,11 +980,11 @@ const xt = (t) => {
974
980
  const k = JSON.parse(
975
981
  sessionStorage.getItem("customerData") || "{}"
976
982
  );
977
- (k == null ? void 0 : k.isGuest) == !1 ? (console.log("running secondary flow", It), J(o.current, 0)) : console.log("not running secondary flow", It);
983
+ (k == null ? void 0 : k.isGuest) == !1 ? (console.log("running secondary flow", Ft), J(o.current, 0)) : console.log("not running secondary flow", Ft);
978
984
  }
979
985
  ot(!1);
980
986
  }, rr = async (c, k) => {
981
- var w, y, f, g, z, ut, pt, A, ft, mt, D, L, H, V, W;
987
+ var w, y, f, g, z, ut, pt, A, ft, mt, D, L, H, R, W;
982
988
  M(!0);
983
989
  try {
984
990
  const m = await He(c.id);
@@ -995,10 +1001,10 @@ const xt = (t) => {
995
1001
  quantity: k
996
1002
  }
997
1003
  ];
998
- console.log(B, "product data", "app version", It);
999
- const F = JSON.parse(
1004
+ console.log(B, "product data", "app version", Ft);
1005
+ const I = JSON.parse(
1000
1006
  sessionStorage.getItem("customerData") || "{}"
1001
- ), T = (F == null ? void 0 : F.basketId) || localStorage.getItem(oe), X = !1, Dt = localStorage.getItem(Tt), he = Date.now();
1007
+ ), T = (I == null ? void 0 : I.basketId) || localStorage.getItem(Vt), X = !1, Dt = localStorage.getItem(Tt), he = Date.now();
1002
1008
  if (!X || !Dt || he >= parseInt(Dt)) {
1003
1009
  const or = await qe();
1004
1010
  let { customer_token: at } = await Me(
@@ -1009,18 +1015,18 @@ const xt = (t) => {
1009
1015
  return;
1010
1016
  }
1011
1017
  const nr = he + 300 * 1e3;
1012
- if (Rt(at), localStorage.setItem(Tt, nr.toString()), console.log(T, "basketIdFromCustomer"), T) {
1013
- const we = await Re({
1018
+ if (Yt(at), localStorage.setItem(Tt, nr.toString()), console.log(T, "basketIdFromCustomer"), T) {
1019
+ const we = await Ve({
1014
1020
  basketId: T,
1015
1021
  customer_token: at
1016
1022
  });
1017
1023
  if (we.status === 200 && we) {
1018
- const Gt = await Vt(
1024
+ const Wt = await Rt(
1019
1025
  T,
1020
1026
  B,
1021
1027
  at
1022
1028
  );
1023
- ((pt = Gt == null ? void 0 : Gt.product_items) == null ? void 0 : pt.length) > 0 && (U.success("Added to cart", {
1029
+ ((pt = Wt == null ? void 0 : Wt.product_items) == null ? void 0 : pt.length) > 0 && (U.success("Added to cart", {
1024
1030
  position: "bottom-right",
1025
1031
  autoClose: 3e3,
1026
1032
  hideProgressBar: !1,
@@ -1038,7 +1044,7 @@ const xt = (t) => {
1038
1044
  quantity: 1
1039
1045
  }
1040
1046
  ]
1041
- }, v = await Ve(at, ar);
1047
+ }, v = await Re(at, ar);
1042
1048
  if (console.log(
1043
1049
  v,
1044
1050
  v == null ? void 0 : v.basket_id,
@@ -1051,7 +1057,7 @@ const xt = (t) => {
1051
1057
  xt(
1052
1058
  (v == null ? void 0 : v.basket_id) || (v == null ? void 0 : v.basketId)
1053
1059
  );
1054
- const ht = await Vt(
1060
+ const ht = await Rt(
1055
1061
  (v == null ? void 0 : v.basket_id) || (v == null ? void 0 : v.basketId),
1056
1062
  B,
1057
1063
  at
@@ -1070,7 +1076,7 @@ const xt = (t) => {
1070
1076
  position: "bottom-right",
1071
1077
  autoClose: 3e3
1072
1078
  }), ((L = m == null ? void 0 : m.response) == null ? void 0 : L.status) === 404 || // Basket not found
1073
- ((H = m == null ? void 0 : m.response) == null ? void 0 : H.status) === 401 ? (((V = m == null ? void 0 : m.response) == null ? void 0 : V.status) === 404 && xt(null), ((W = m == null ? void 0 : m.response) == null ? void 0 : W.status) === 401 && (xt(null), Rt(null))) : (console.error("Failed to add product to basket:", m.message), U.error("Failed to add product to cart", {
1079
+ ((H = m == null ? void 0 : m.response) == null ? void 0 : H.status) === 401 ? (((R = m == null ? void 0 : m.response) == null ? void 0 : R.status) === 404 && xt(null), ((W = m == null ? void 0 : m.response) == null ? void 0 : W.status) === 401 && (xt(null), Yt(null))) : (console.error("Failed to add product to basket:", m.message), U.error("Failed to add product to cart", {
1074
1080
  position: "bottom-right",
1075
1081
  autoClose: 3e3
1076
1082
  }));
@@ -1141,7 +1147,7 @@ const xt = (t) => {
1141
1147
  ) })
1142
1148
  }
1143
1149
  ),
1144
- _ && /* @__PURE__ */ u(ee, { children: [
1150
+ _ && /* @__PURE__ */ u(re, { children: [
1145
1151
  /* @__PURE__ */ a(
1146
1152
  "div",
1147
1153
  {
@@ -1328,7 +1334,7 @@ const xt = (t) => {
1328
1334
  {
1329
1335
  className: "font-nunitoSans animate-pulse font-bold text-sm text-[#494949] bg-[#FFFFFF] px-7 py-1 rounded-r-xl rounded-bl-2xl w-full",
1330
1336
  dangerouslySetInnerHTML: {
1331
- __html: Wt(c.response)
1337
+ __html: Xt(c.response)
1332
1338
  }
1333
1339
  }
1334
1340
  ) }) : /* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(
@@ -1336,13 +1342,13 @@ const xt = (t) => {
1336
1342
  {
1337
1343
  className: "font-nunitoSans font-bold text-sm text-[#494949] bg-[#FFFFFF] px-7 py-1 rounded-r-xl rounded-bl-2xl w-full",
1338
1344
  dangerouslySetInnerHTML: {
1339
- __html: Wt(c.response)
1345
+ __html: Xt(c.response)
1340
1346
  }
1341
1347
  }
1342
1348
  ) }),
1343
1349
  Pt && !c.response.includes("Thinking") && ((w = c.products) == null ? void 0 : w.length) == 0 && /* @__PURE__ */ a("div", { children: /* @__PURE__ */ a("p", { className: "text-sm animate-pulse font-nunitoSans font-bold text-[#000000] bg-[#E2DBFF] border border-[#C9C2DE] rounded-l-xl p-2 m-3 mb-4 rounded-br-xl max-w-[75%]", children: "Finding best products for you" }) }),
1344
1350
  (c == null ? void 0 : c.products) && ((y = c == null ? void 0 : c.products) == null ? void 0 : y.length) > 0 && /* @__PURE__ */ a(
1345
- Fr,
1351
+ Ir,
1346
1352
  {
1347
1353
  chat: c.products,
1348
1354
  storeDetails: p
@@ -1403,7 +1409,7 @@ const xt = (t) => {
1403
1409
  ]
1404
1410
  }
1405
1411
  ) }),
1406
- c.secondaryResponse && /* @__PURE__ */ a(ee, { children: /* @__PURE__ */ u("div", { className: "mt-3 mb-8 px-4 bg-indigo-300 rounded-tr-[5px]", children: [
1412
+ c.secondaryResponse && /* @__PURE__ */ a(re, { children: /* @__PURE__ */ u("div", { className: "mt-3 mb-8 px-4 bg-indigo-300 rounded-tr-[5px]", children: [
1407
1413
  /* @__PURE__ */ a(
1408
1414
  "div",
1409
1415
  {
@@ -1412,7 +1418,7 @@ const xt = (t) => {
1412
1418
  backgroundColor: p.tanyaThemeColorLight
1413
1419
  },
1414
1420
  dangerouslySetInnerHTML: {
1415
- __html: Wt(
1421
+ __html: Xt(
1416
1422
  c.secondaryResponse
1417
1423
  )
1418
1424
  }
@@ -1652,16 +1658,16 @@ function Or(t, e) {
1652
1658
  e.indexOf(o[n]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[n]) && (r[o[n]] = t[o[n]]);
1653
1659
  return r;
1654
1660
  }
1655
- var Xt = "Invariant Violation", _e = Object.setPrototypeOf, Pr = _e === void 0 ? function(t, e) {
1661
+ var Qt = "Invariant Violation", _e = Object.setPrototypeOf, Pr = _e === void 0 ? function(t, e) {
1656
1662
  return t.__proto__ = e, t;
1657
1663
  } : _e, Ye = (
1658
1664
  /** @class */
1659
1665
  (function(t) {
1660
1666
  Tr(e, t);
1661
1667
  function e(r) {
1662
- r === void 0 && (r = Xt);
1663
- var o = t.call(this, typeof r == "number" ? Xt + ": " + r + " (see https://github.com/apollographql/invariant-packages)" : r) || this;
1664
- return o.framesToPop = 1, o.name = Xt, Pr(o, e.prototype), o;
1668
+ r === void 0 && (r = Qt);
1669
+ var o = t.call(this, typeof r == "number" ? Qt + ": " + r + " (see https://github.com/apollographql/invariant-packages)" : r) || this;
1670
+ return o.framesToPop = 1, o.name = Qt, Pr(o, e.prototype), o;
1665
1671
  }
1666
1672
  return e;
1667
1673
  })(Error)
@@ -1706,10 +1712,10 @@ const ae = wt(function() {
1706
1712
  wt(function() {
1707
1713
  return wt.constructor("return this")();
1708
1714
  });
1709
- var Fe = /* @__PURE__ */ new Map();
1715
+ var Ie = /* @__PURE__ */ new Map();
1710
1716
  function zr(t) {
1711
- var e = Fe.get(t) || 1;
1712
- return Fe.set(t, e + 1), "".concat(t, ":").concat(e, ":").concat(Math.random().toString(36).slice(2));
1717
+ var e = Ie.get(t) || 1;
1718
+ return Ie.set(t, e + 1), "".concat(t, ":").concat(e, ":").concat(Math.random().toString(36).slice(2));
1713
1719
  }
1714
1720
  function jr(t, e) {
1715
1721
  var r = zr("stringifyForDisplay");
@@ -1728,7 +1734,7 @@ function Bt(t) {
1728
1734
  t.apply(void 0, [e].concat(r));
1729
1735
  };
1730
1736
  }
1731
- var Qt = Object.assign(function(e, r) {
1737
+ var Zt = Object.assign(function(e, r) {
1732
1738
  for (var o = [], n = 2; n < arguments.length; n++)
1733
1739
  o[n - 2] = arguments[n];
1734
1740
  e || it(e, le(r, o) || ce(r, o));
@@ -1743,7 +1749,7 @@ function Ge(t) {
1743
1749
  e[r - 1] = arguments[r];
1744
1750
  return new Ye(le(t, e) || ce(t, e));
1745
1751
  }
1746
- var Ie = Symbol.for("ApolloErrorMessageHandler_" + Ke);
1752
+ var Fe = Symbol.for("ApolloErrorMessageHandler_" + Ke);
1747
1753
  function We(t) {
1748
1754
  if (typeof t == "string")
1749
1755
  return t;
@@ -1755,7 +1761,7 @@ function We(t) {
1755
1761
  }
1756
1762
  function le(t, e) {
1757
1763
  if (e === void 0 && (e = []), !!t)
1758
- return ae[Ie] && ae[Ie](t, e.map(We));
1764
+ return ae[Fe] && ae[Fe](t, e.map(We));
1759
1765
  }
1760
1766
  function ce(t, e) {
1761
1767
  if (e === void 0 && (e = []), !!t)
@@ -1772,7 +1778,7 @@ function Ar(t) {
1772
1778
  return e.name.value;
1773
1779
  })[0] || null;
1774
1780
  }
1775
- let I = null;
1781
+ let F = null;
1776
1782
  const Ne = {};
1777
1783
  let Dr = 1;
1778
1784
  const Lr = () => class {
@@ -1785,52 +1791,52 @@ const Lr = () => class {
1785
1791
  ].join(":");
1786
1792
  }
1787
1793
  hasValue() {
1788
- for (let e = I; e; e = e.parent)
1794
+ for (let e = F; e; e = e.parent)
1789
1795
  if (this.id in e.slots) {
1790
1796
  const r = e.slots[this.id];
1791
1797
  if (r === Ne)
1792
1798
  break;
1793
- return e !== I && (I.slots[this.id] = r), !0;
1799
+ return e !== F && (F.slots[this.id] = r), !0;
1794
1800
  }
1795
- return I && (I.slots[this.id] = Ne), !1;
1801
+ return F && (F.slots[this.id] = Ne), !1;
1796
1802
  }
1797
1803
  getValue() {
1798
1804
  if (this.hasValue())
1799
- return I.slots[this.id];
1805
+ return F.slots[this.id];
1800
1806
  }
1801
1807
  withValue(e, r, o, n) {
1802
1808
  const l = {
1803
1809
  __proto__: null,
1804
1810
  [this.id]: e
1805
- }, s = I;
1806
- I = { parent: s, slots: l };
1811
+ }, s = F;
1812
+ F = { parent: s, slots: l };
1807
1813
  try {
1808
1814
  return r.apply(n, o);
1809
1815
  } finally {
1810
- I = s;
1816
+ F = s;
1811
1817
  }
1812
1818
  }
1813
1819
  // Capture the current context and wrap a callback function so that it
1814
1820
  // reestablishes the captured context when called.
1815
1821
  static bind(e) {
1816
- const r = I;
1822
+ const r = F;
1817
1823
  return function() {
1818
- const o = I;
1824
+ const o = F;
1819
1825
  try {
1820
- return I = r, e.apply(this, arguments);
1826
+ return F = r, e.apply(this, arguments);
1821
1827
  } finally {
1822
- I = o;
1828
+ F = o;
1823
1829
  }
1824
1830
  };
1825
1831
  }
1826
1832
  // Immediately run a callback function without any captured context.
1827
1833
  static noContext(e, r, o) {
1828
- if (I) {
1829
- const n = I;
1834
+ if (F) {
1835
+ const n = F;
1830
1836
  try {
1831
- return I = null, e.apply(o, r);
1837
+ return F = null, e.apply(o, r);
1832
1838
  } finally {
1833
- I = n;
1839
+ F = n;
1834
1840
  }
1835
1841
  } else
1836
1842
  return e.apply(o, r);
@@ -1842,7 +1848,7 @@ function Ee(t) {
1842
1848
  } catch {
1843
1849
  }
1844
1850
  }
1845
- const Zt = "@wry/context:Slot", Br = (
1851
+ const te = "@wry/context:Slot", Br = (
1846
1852
  // Prefer globalThis when available.
1847
1853
  // https://github.com/benjamn/wryware/issues/347
1848
1854
  Ee(() => globalThis) || // Fall back to global, which works in Node.js and may be converted by some
@@ -1852,11 +1858,11 @@ const Zt = "@wry/context:Slot", Br = (
1852
1858
  // back to using the Array constructor as a namespace, but that was flagged in
1853
1859
  // https://github.com/benjamn/wryware/issues/347, and can be avoided.
1854
1860
  /* @__PURE__ */ Object.create(null)
1855
- ), Te = Br, de = Te[Zt] || // Earlier versions of this package stored the globalKey property on the Array
1861
+ ), Te = Br, de = Te[te] || // Earlier versions of this package stored the globalKey property on the Array
1856
1862
  // constructor, so we check there as well, to prevent Slot class duplication.
1857
- Array[Zt] || (function(t) {
1863
+ Array[te] || (function(t) {
1858
1864
  try {
1859
- Object.defineProperty(Te, Zt, {
1865
+ Object.defineProperty(Te, te, {
1860
1866
  value: t,
1861
1867
  enumerable: !1,
1862
1868
  writable: !1,
@@ -1918,7 +1924,7 @@ var pe = function() {
1918
1924
  };
1919
1925
  pe() && !fe("observable") && (Symbol.observable = Symbol("observable"));
1920
1926
  var Mr = me("iterator"), ie = me("observable"), Xe = me("species");
1921
- function Yt(t, e) {
1927
+ function Jt(t, e) {
1922
1928
  var r = t[e];
1923
1929
  if (r != null) {
1924
1930
  if (typeof r != "function") throw new TypeError(r + " is not a function");
@@ -1953,7 +1959,7 @@ function Qe(t) {
1953
1959
  if (typeof e == "function")
1954
1960
  e();
1955
1961
  else {
1956
- var r = Yt(e, "unsubscribe");
1962
+ var r = Jt(e, "unsubscribe");
1957
1963
  r && r.call(e);
1958
1964
  }
1959
1965
  } catch (o) {
@@ -1963,7 +1969,7 @@ function Qe(t) {
1963
1969
  function se(t) {
1964
1970
  t._observer = void 0, t._queue = void 0, t._state = "closed";
1965
1971
  }
1966
- function Vr(t) {
1972
+ function Rr(t) {
1967
1973
  var e = t._queue;
1968
1974
  if (e) {
1969
1975
  t._queue = void 0, t._state = "ready";
@@ -1975,7 +1981,7 @@ function Ze(t, e, r) {
1975
1981
  t._state = "running";
1976
1982
  var o = t._observer;
1977
1983
  try {
1978
- var n = Yt(o, e);
1984
+ var n = Jt(o, e);
1979
1985
  switch (e) {
1980
1986
  case "next":
1981
1987
  n && n.call(o, r);
@@ -1993,7 +1999,7 @@ function Ze(t, e, r) {
1993
1999
  }
1994
2000
  t._state === "closed" ? Qe(t) : t._state === "running" && (t._state = "ready");
1995
2001
  }
1996
- function te(t, e, r) {
2002
+ function ee(t, e, r) {
1997
2003
  if (t._state !== "closed") {
1998
2004
  if (t._state === "buffering") {
1999
2005
  t._queue.push({
@@ -2007,14 +2013,14 @@ function te(t, e, r) {
2007
2013
  type: e,
2008
2014
  value: r
2009
2015
  }], qt(function() {
2010
- return Vr(t);
2016
+ return Rr(t);
2011
2017
  });
2012
2018
  return;
2013
2019
  }
2014
2020
  Ze(t, e, r);
2015
2021
  }
2016
2022
  }
2017
- var Rr = /* @__PURE__ */ (function() {
2023
+ var Vr = /* @__PURE__ */ (function() {
2018
2024
  function t(r, o) {
2019
2025
  this._cleanup = void 0, this._observer = r, this._queue = void 0, this._state = "initializing";
2020
2026
  var n = new Yr(this);
@@ -2040,11 +2046,11 @@ var Rr = /* @__PURE__ */ (function() {
2040
2046
  }
2041
2047
  var e = t.prototype;
2042
2048
  return e.next = function(o) {
2043
- te(this._subscription, "next", o);
2049
+ ee(this._subscription, "next", o);
2044
2050
  }, e.error = function(o) {
2045
- te(this._subscription, "error", o);
2051
+ ee(this._subscription, "error", o);
2046
2052
  }, e.complete = function() {
2047
- te(this._subscription, "complete");
2053
+ ee(this._subscription, "complete");
2048
2054
  }, ue(t, [{
2049
2055
  key: "closed",
2050
2056
  get: function() {
@@ -2063,7 +2069,7 @@ var Rr = /* @__PURE__ */ (function() {
2063
2069
  next: o,
2064
2070
  error: arguments[1],
2065
2071
  complete: arguments[2]
2066
- }), new Rr(o, this._subscriber);
2072
+ }), new Vr(o, this._subscriber);
2067
2073
  }, e.forEach = function(o) {
2068
2074
  var n = this;
2069
2075
  return new Promise(function(l, s) {
@@ -2227,7 +2233,7 @@ var Rr = /* @__PURE__ */ (function() {
2227
2233
  }, t.from = function(o) {
2228
2234
  var n = typeof this == "function" ? this : t;
2229
2235
  if (o == null) throw new TypeError(o + " is not an object");
2230
- var l = Yt(o, ie);
2236
+ var l = Jt(o, ie);
2231
2237
  if (l) {
2232
2238
  var s = l.call(o);
2233
2239
  if (Object(s) !== s) throw new TypeError(s + " is not an object");
@@ -2235,7 +2241,7 @@ var Rr = /* @__PURE__ */ (function() {
2235
2241
  return s.subscribe(d);
2236
2242
  });
2237
2243
  }
2238
- if (fe("iterator") && (l = Yt(o, Mr), l))
2244
+ if (fe("iterator") && (l = Jt(o, Mr), l))
2239
2245
  return new n(function(d) {
2240
2246
  qt(function() {
2241
2247
  if (!d.closed) {
@@ -2387,7 +2393,7 @@ var tr = (
2387
2393
  }, t.concat = function(e, r) {
2388
2394
  var o = Et(e);
2389
2395
  if (Ut(o))
2390
- return globalThis.__DEV__ !== !1 && Qt.warn(47, o), o;
2396
+ return globalThis.__DEV__ !== !1 && Zt.warn(47, o), o;
2391
2397
  var n = Et(r), l;
2392
2398
  return Ut(n) ? l = new t(function(s) {
2393
2399
  return o.request(s, function(d) {
@@ -2406,12 +2412,12 @@ var tr = (
2406
2412
  throw Ge(48);
2407
2413
  }, t.prototype.onError = function(e, r) {
2408
2414
  if (globalThis.__DEV__ !== !1 && eo("onError", function() {
2409
- globalThis.__DEV__ !== !1 && Qt.warn(49);
2415
+ globalThis.__DEV__ !== !1 && Zt.warn(49);
2410
2416
  }), r && r.error)
2411
2417
  return r.error(e), !1;
2412
2418
  throw e;
2413
2419
  }, t.prototype.setOnError = function(e) {
2414
- return globalThis.__DEV__ !== !1 && globalThis.__DEV__ !== !1 && Qt.warn(50), this.onError = e, this;
2420
+ return globalThis.__DEV__ !== !1 && globalThis.__DEV__ !== !1 && Zt.warn(50), this.onError = e, this;
2415
2421
  }, t;
2416
2422
  })()
2417
2423
  );