tanya-chatbot 0.9.5 → 0.9.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.
package/dist/tanya-chatbot.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect as me, useState as v, useRef as He, forwardRef as En, createElement as mr, useMemo as Wr } from "react";
|
|
2
2
|
import { jsx as a, jsxs as d, Fragment as ge } from "react/jsx-runtime";
|
|
3
|
-
import { createHttpLink as
|
|
3
|
+
import { createHttpLink as Lo, ApolloClient as Do, InMemoryCache as zo, ApolloProvider as Mo } from "@apollo/client";
|
|
4
4
|
import { Provider as Bo, useDispatch as Tn, useSelector as Wt } from "react-redux";
|
|
5
5
|
import { createSlice as An, configureStore as Uo } from "@reduxjs/toolkit";
|
|
6
6
|
import * as On from "@radix-ui/react-popover";
|
|
@@ -66,7 +66,7 @@ const Vo = {
|
|
|
66
66
|
}
|
|
67
67
|
}), { setStore: di } = jn.actions, Yo = jn.reducer, Jo = {
|
|
68
68
|
product: null
|
|
69
|
-
},
|
|
69
|
+
}, $n = An({
|
|
70
70
|
name: "product",
|
|
71
71
|
initialState: Jo,
|
|
72
72
|
reducers: {
|
|
@@ -74,7 +74,7 @@ const Vo = {
|
|
|
74
74
|
e.product = t.payload;
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
}), { setProduct: hr } =
|
|
77
|
+
}), { setProduct: hr } = $n.actions, Ko = $n.reducer, Wo = Uo({
|
|
78
78
|
reducer: {
|
|
79
79
|
store: Yo,
|
|
80
80
|
product: Ko
|
|
@@ -98,7 +98,7 @@ function Xo({
|
|
|
98
98
|
}) {
|
|
99
99
|
return /* @__PURE__ */ a(On.Trigger, { "data-slot": "popover-trigger", ...e });
|
|
100
100
|
}
|
|
101
|
-
const it = () => ({ aiConversationUrl: "https://mdv3qwfi2j.execute-api.us-east-1.amazonaws.com/dev/api/bedrock/invoke/stream", xAPIKey: "BJBtjpPkqGatuoa3qJqdR8aHXSsHkgvGaootbubi", serverUrl: "https://tanya-sfcc-server.vercel.app/", basePath: "sc-api" }),
|
|
101
|
+
const it = () => ({ aiConversationUrl: "https://mdv3qwfi2j.execute-api.us-east-1.amazonaws.com/dev/api/bedrock/invoke/stream", xAPIKey: "BJBtjpPkqGatuoa3qJqdR8aHXSsHkgvGaootbubi", serverUrl: "https://tanya-sfcc-server.vercel.app/", basePath: "sc-api" }), Ln = async () => {
|
|
102
102
|
const e = "https://tanya-sfcc-server.vercel.app/";
|
|
103
103
|
try {
|
|
104
104
|
const t = await he.post(
|
|
@@ -194,7 +194,7 @@ const pr = async (e, t) => {
|
|
|
194
194
|
)).data;
|
|
195
195
|
}, ea = async (e) => {
|
|
196
196
|
if (!e) throw new Error("customerId is required");
|
|
197
|
-
const t = await
|
|
197
|
+
const t = await Ln(), { customer_token: r } = await Dn(
|
|
198
198
|
t
|
|
199
199
|
), { serverUrl: n, basePath: o } = it(), i = (await kt()).access_token;
|
|
200
200
|
return (await he.get(
|
|
@@ -788,7 +788,7 @@ const at = (e) => {
|
|
|
788
788
|
const Y = localStorage.getItem("customerNumber"), z = localStorage.getItem("isLoggedIn"), te = `https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({
|
|
789
789
|
registered: String(z || !1),
|
|
790
790
|
userId: String(Y || (/* @__PURE__ */ new Date()).getTime())
|
|
791
|
-
}).toString()}`,
|
|
791
|
+
}).toString()}`, L = JSON.stringify({
|
|
792
792
|
flowId: "Q166PR519W",
|
|
793
793
|
flowAliasId: "HKFUVLWVH2",
|
|
794
794
|
input: {
|
|
@@ -804,7 +804,7 @@ const at = (e) => {
|
|
|
804
804
|
"Content-Type": "application/json",
|
|
805
805
|
Authorization: `Bearer ${W}`
|
|
806
806
|
},
|
|
807
|
-
body:
|
|
807
|
+
body: L
|
|
808
808
|
});
|
|
809
809
|
if (!Q.body) throw new Error("Readable stream not supported");
|
|
810
810
|
const Ce = Q.body.getReader(), ve = new TextDecoder();
|
|
@@ -862,7 +862,7 @@ const at = (e) => {
|
|
|
862
862
|
const te = `https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({
|
|
863
863
|
registered: String(Y || !1),
|
|
864
864
|
userId: String(W || (/* @__PURE__ */ new Date()).getTime())
|
|
865
|
-
}).toString()}`,
|
|
865
|
+
}).toString()}`, L = JSON.stringify({
|
|
866
866
|
flowId: "MMHQKYI1NE",
|
|
867
867
|
flowAliasId: "SZF9ZK1ATE",
|
|
868
868
|
input: {
|
|
@@ -876,7 +876,7 @@ const at = (e) => {
|
|
|
876
876
|
"Content-Type": "application/json",
|
|
877
877
|
Authorization: `Bearer ${z}`
|
|
878
878
|
},
|
|
879
|
-
body:
|
|
879
|
+
body: L
|
|
880
880
|
});
|
|
881
881
|
if (!Q.ok)
|
|
882
882
|
throw new Error(`HTTP error! status: ${Q.status}`);
|
|
@@ -927,21 +927,21 @@ const at = (e) => {
|
|
|
927
927
|
F(!0);
|
|
928
928
|
try {
|
|
929
929
|
const z = await Promise.all(
|
|
930
|
-
R.map((
|
|
930
|
+
R.map((L) => Zo(L).catch(() => []))
|
|
931
931
|
// prevent Promise.all crash
|
|
932
|
-
), fe = R.map((
|
|
933
|
-
keyword:
|
|
932
|
+
), fe = R.map((L, Q) => ({
|
|
933
|
+
keyword: L,
|
|
934
934
|
items: z[Q] ?? [],
|
|
935
935
|
loading: !1
|
|
936
|
-
})).filter((
|
|
936
|
+
})).filter((L) => L.items.length > 0), te = (W = (j = fe[0]) == null ? void 0 : j.items) == null ? void 0 : W[0];
|
|
937
937
|
if (te) {
|
|
938
938
|
i.current = te.product_id, s.current = te.product_name, c.current = (Y = te.image) == null ? void 0 : Y.link;
|
|
939
|
-
const
|
|
940
|
-
l.current =
|
|
939
|
+
const L = typeof te.price == "number" ? te.price : null;
|
|
940
|
+
l.current = L;
|
|
941
941
|
}
|
|
942
942
|
if (ue(
|
|
943
|
-
(
|
|
944
|
-
(Q, Ce) => Ce ===
|
|
943
|
+
(L) => L.map(
|
|
944
|
+
(Q, Ce) => Ce === L.length - 1 ? {
|
|
945
945
|
...Q,
|
|
946
946
|
products: fe,
|
|
947
947
|
productSnapshot: te ? {
|
|
@@ -955,10 +955,10 @@ const at = (e) => {
|
|
|
955
955
|
} : Q
|
|
956
956
|
)
|
|
957
957
|
), te) {
|
|
958
|
-
const
|
|
958
|
+
const L = JSON.parse(
|
|
959
959
|
sessionStorage.getItem("customerData") || "{}"
|
|
960
960
|
);
|
|
961
|
-
|
|
961
|
+
L != null && L.isGuest || (console.log("running secondary flow", Bt), Se(s.current, 0));
|
|
962
962
|
}
|
|
963
963
|
} catch (z) {
|
|
964
964
|
console.error("error in keyword search", z);
|
|
@@ -966,7 +966,7 @@ const at = (e) => {
|
|
|
966
966
|
F(!1);
|
|
967
967
|
}
|
|
968
968
|
}, nr = async (m, R) => {
|
|
969
|
-
var j, W, Y, z, fe, te,
|
|
969
|
+
var j, W, Y, z, fe, te, L, Q, Ce, ve, re, ke, Z, ne, _e;
|
|
970
970
|
V(!0);
|
|
971
971
|
try {
|
|
972
972
|
const b = await zn(m.id);
|
|
@@ -988,7 +988,7 @@ const at = (e) => {
|
|
|
988
988
|
sessionStorage.getItem("customerData") || "{}"
|
|
989
989
|
), J = (G == null ? void 0 : G.basketId) || localStorage.getItem(Gt), X = !1, Je = localStorage.getItem(At), pe = Date.now();
|
|
990
990
|
if (!X || !Je || pe >= parseInt(Je)) {
|
|
991
|
-
const Be = await
|
|
991
|
+
const Be = await Ln();
|
|
992
992
|
let { customer_token: ee } = await Dn(
|
|
993
993
|
Be
|
|
994
994
|
);
|
|
@@ -1008,7 +1008,7 @@ const at = (e) => {
|
|
|
1008
1008
|
le,
|
|
1009
1009
|
ee
|
|
1010
1010
|
);
|
|
1011
|
-
((
|
|
1011
|
+
((L = ft == null ? void 0 : ft.product_items) == null ? void 0 : L.length) > 0 && (ze.success("Added to cart", {
|
|
1012
1012
|
position: "bottom-right",
|
|
1013
1013
|
autoClose: 3e3,
|
|
1014
1014
|
hideProgressBar: !1,
|
|
@@ -2409,7 +2409,7 @@ var Wn = (
|
|
|
2409
2409
|
}, e;
|
|
2410
2410
|
})()
|
|
2411
2411
|
);
|
|
2412
|
-
function
|
|
2412
|
+
function $a(e) {
|
|
2413
2413
|
return new Wn(function(t, r) {
|
|
2414
2414
|
var n = da(t, []);
|
|
2415
2415
|
return new de(function(o) {
|
|
@@ -2428,7 +2428,7 @@ function La(e) {
|
|
|
2428
2428
|
});
|
|
2429
2429
|
});
|
|
2430
2430
|
}
|
|
2431
|
-
const
|
|
2431
|
+
const La = async () => {
|
|
2432
2432
|
const e = "https://auth.australia-southeast1.gcp.commercetools.com/oauth/token", n = "Basic " + btoa(encodeURIComponent("tfegsSBVOYnR7e_yE-AjxVVN") + ":" + encodeURIComponent("pyKWgHuTxuMwDygh9JH1ehLEaLvAhBo4"));
|
|
2433
2433
|
try {
|
|
2434
2434
|
const o = await he.post(
|
|
@@ -2446,10 +2446,10 @@ const $a = async () => {
|
|
|
2446
2446
|
} catch (o) {
|
|
2447
2447
|
return he.isAxiosError(o) ? console.error("Error fetching token:", o.response || o.message) : console.error("Unexpected error:", o), null;
|
|
2448
2448
|
}
|
|
2449
|
-
}, Da = "https://api.australia-southeast1.gcp.commercetools.com/kt-demo/graphql", za =
|
|
2449
|
+
}, Da = "https://api.australia-southeast1.gcp.commercetools.com/kt-demo/graphql", za = Lo({
|
|
2450
2450
|
uri: `${Da}`
|
|
2451
|
-
}), Ma =
|
|
2452
|
-
const r = await
|
|
2451
|
+
}), Ma = $a(async (e, { headers: t }) => {
|
|
2452
|
+
const r = await La();
|
|
2453
2453
|
return {
|
|
2454
2454
|
headers: {
|
|
2455
2455
|
...t,
|
|
@@ -2789,7 +2789,7 @@ function is(e, t) {
|
|
|
2789
2789
|
const r = Or(t);
|
|
2790
2790
|
return r === null ? !1 : (jr[e] = r, !0);
|
|
2791
2791
|
}
|
|
2792
|
-
function
|
|
2792
|
+
function $r(e) {
|
|
2793
2793
|
return jr[e];
|
|
2794
2794
|
}
|
|
2795
2795
|
const ls = () => {
|
|
@@ -2801,7 +2801,7 @@ const ls = () => {
|
|
|
2801
2801
|
};
|
|
2802
2802
|
let yn = ls();
|
|
2803
2803
|
function cs(e, t) {
|
|
2804
|
-
const r =
|
|
2804
|
+
const r = $r(e);
|
|
2805
2805
|
if (!r) return 0;
|
|
2806
2806
|
let n;
|
|
2807
2807
|
if (!r.maxURL) n = 0;
|
|
@@ -2837,7 +2837,7 @@ const us = (e, t, r) => {
|
|
|
2837
2837
|
};
|
|
2838
2838
|
function fs(e) {
|
|
2839
2839
|
if (typeof e == "string") {
|
|
2840
|
-
const t =
|
|
2840
|
+
const t = $r(e);
|
|
2841
2841
|
if (t) return t.path;
|
|
2842
2842
|
}
|
|
2843
2843
|
return "/";
|
|
@@ -3111,7 +3111,7 @@ function xn() {
|
|
|
3111
3111
|
const fr = /* @__PURE__ */ Object.create(null);
|
|
3112
3112
|
function ks(e) {
|
|
3113
3113
|
if (!fr[e]) {
|
|
3114
|
-
const t =
|
|
3114
|
+
const t = $r(e);
|
|
3115
3115
|
if (!t) return;
|
|
3116
3116
|
const r = ao(t), n = {
|
|
3117
3117
|
config: t,
|
|
@@ -3302,11 +3302,11 @@ function Os(e) {
|
|
|
3302
3302
|
function js(e) {
|
|
3303
3303
|
return "data:image/svg+xml," + Os(e);
|
|
3304
3304
|
}
|
|
3305
|
-
function
|
|
3305
|
+
function $s(e) {
|
|
3306
3306
|
return 'url("' + js(e) + '")';
|
|
3307
3307
|
}
|
|
3308
3308
|
let Tt;
|
|
3309
|
-
function
|
|
3309
|
+
function Ls() {
|
|
3310
3310
|
try {
|
|
3311
3311
|
Tt = window.trustedTypes.createPolicy("iconify", { createHTML: (e) => e });
|
|
3312
3312
|
} catch {
|
|
@@ -3314,7 +3314,7 @@ function $s() {
|
|
|
3314
3314
|
}
|
|
3315
3315
|
}
|
|
3316
3316
|
function Ds(e) {
|
|
3317
|
-
return Tt === void 0 &&
|
|
3317
|
+
return Tt === void 0 && Ls(), Tt ? Tt.createHTML(e) : e;
|
|
3318
3318
|
}
|
|
3319
3319
|
const so = {
|
|
3320
3320
|
...no,
|
|
@@ -3434,7 +3434,7 @@ const Us = (e, t, r) => {
|
|
|
3434
3434
|
});
|
|
3435
3435
|
return l.style = {
|
|
3436
3436
|
...i,
|
|
3437
|
-
"--svg":
|
|
3437
|
+
"--svg": $s(A),
|
|
3438
3438
|
width: Sn(g.width),
|
|
3439
3439
|
height: Sn(g.height),
|
|
3440
3440
|
...Ms,
|
|
@@ -3654,7 +3654,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
3654
3654
|
onClose: t,
|
|
3655
3655
|
product: r,
|
|
3656
3656
|
index: n,
|
|
3657
|
-
|
|
3657
|
+
addresses: o,
|
|
3658
3658
|
addressLoading: s,
|
|
3659
3659
|
variationAttributes: i
|
|
3660
3660
|
}) => {
|
|
@@ -3673,13 +3673,13 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
3673
3673
|
}
|
|
3674
3674
|
}, [r]);
|
|
3675
3675
|
const A = (u, h, f) => {
|
|
3676
|
-
const { colorMap: w, sizeMap: _ } = N(f),
|
|
3676
|
+
const { colorMap: w, sizeMap: _ } = N(f), $ = {};
|
|
3677
3677
|
h == null || h.forEach((E) => {
|
|
3678
|
-
var oe, Ie,
|
|
3678
|
+
var oe, Ie, $e;
|
|
3679
3679
|
const U = (oe = E.variationAttributes) == null ? void 0 : oe.find(
|
|
3680
|
-
(
|
|
3681
|
-
), O = (
|
|
3682
|
-
O && (
|
|
3680
|
+
(Le) => Le.id === "color"
|
|
3681
|
+
), O = ($e = (Ie = U == null ? void 0 : U.values) == null ? void 0 : Ie[0]) == null ? void 0 : $e.value;
|
|
3682
|
+
O && ($[O] || ($[O] = {}), $[O][E.viewType] = E.images);
|
|
3683
3683
|
});
|
|
3684
3684
|
const H = u.reduce((E, U) => {
|
|
3685
3685
|
const O = U.variationValues.color, oe = U.variationValues.size;
|
|
@@ -3687,7 +3687,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
3687
3687
|
color: O,
|
|
3688
3688
|
name: w[O] || O,
|
|
3689
3689
|
// ✅ DISPLAY NAME
|
|
3690
|
-
images:
|
|
3690
|
+
images: $[O] || {},
|
|
3691
3691
|
variants: []
|
|
3692
3692
|
}), E[O].variants.push({
|
|
3693
3693
|
size: oe,
|
|
@@ -3714,7 +3714,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
3714
3714
|
f[_.value] = _.name;
|
|
3715
3715
|
});
|
|
3716
3716
|
}), { colorMap: h, sizeMap: f };
|
|
3717
|
-
}, I = p.length, [V, q] = v(g), [M, Ee] = v(null), [F, K] = v(null), we = He(null), ye = He(null), k = Ys(r, V), [Ye, Me] = v(""), [ue, B] = v(!1), [D, Ne] = v(!1), [Te, Ae] = v(!1), [Ze, xe] = v(""), [je, be] = v(!1), [C, Se] = v(null), [Oe, se] = v([]), [rr, nr] = v([]), [m, R] = v([]), [j, W] = v(!1), [Y, z] = v(), [fe, te] = v(!0), [
|
|
3717
|
+
}, I = p.length, [V, q] = v(g), [M, Ee] = v(null), [F, K] = v(null), we = He(null), ye = He(null), k = Ys(r, V), [Ye, Me] = v(""), [ue, B] = v(!1), [D, Ne] = v(!1), [Te, Ae] = v(!1), [Ze, xe] = v(""), [je, be] = v(!1), [C, Se] = v(null), [Oe, se] = v([]), [rr, nr] = v([]), [m, R] = v([]), [j, W] = v(!1), [Y, z] = v(), [fe, te] = v(!0), [L, Q] = v(!1), [Ce, ve] = v(!1), [re, ke] = v("standard"), [Z, ne] = v(!1), [_e, b] = v(!1), [le, G] = v("card"), [J, X] = v(!1), [Je, pe] = v(!1), [Be, ee] = v(!1), [jt, or] = v(null), [T, Ue] = v(null), [ut, ft] = v(""), [Lr, Dr] = v(!1), [Nt, uo] = v(r == null ? void 0 : r.id), $t = He(null);
|
|
3718
3718
|
me(() => {
|
|
3719
3719
|
const u = Jt(r), h = Math.min(
|
|
3720
3720
|
Math.max(0, n || 0),
|
|
@@ -3724,11 +3724,11 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
3724
3724
|
const f = co(r), w = wt(f), _ = yt(f);
|
|
3725
3725
|
we.current = w || null, ye.current = _ || null, Ee(w || null), K(_ || null);
|
|
3726
3726
|
}, [n, r]), me(() => {
|
|
3727
|
-
|
|
3727
|
+
$t.current && ($t.current.scrollTop = $t.current.scrollHeight);
|
|
3728
3728
|
}, [
|
|
3729
3729
|
Oe,
|
|
3730
3730
|
j,
|
|
3731
|
-
|
|
3731
|
+
L,
|
|
3732
3732
|
Ce,
|
|
3733
3733
|
Z,
|
|
3734
3734
|
_e,
|
|
@@ -3738,7 +3738,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
3738
3738
|
ue,
|
|
3739
3739
|
D
|
|
3740
3740
|
]);
|
|
3741
|
-
const mt = "var(--tanya)", zr = "var(--tanya-contrast)",
|
|
3741
|
+
const mt = "var(--tanya)", zr = "var(--tanya-contrast)", Lt = mt, qe = "#804c9e", fo = () => {
|
|
3742
3742
|
console.log("AgenticShopping feedback:", {
|
|
3743
3743
|
rating: T,
|
|
3744
3744
|
comment: ut
|
|
@@ -3762,7 +3762,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
3762
3762
|
}
|
|
3763
3763
|
)
|
|
3764
3764
|
] }),
|
|
3765
|
-
|
|
3765
|
+
!Lr && /* @__PURE__ */ d("div", { className: "mt-4 rounded-lg bg-white/70 p-3 text-gray-900", children: [
|
|
3766
3766
|
/* @__PURE__ */ a("h4", { className: "font-semibold mb-1", children: "Please post your feedback here" }),
|
|
3767
3767
|
/* @__PURE__ */ a("p", { className: "text-sm text-gray-700 mb-3", children: "Rate us on how much our response was helpful" }),
|
|
3768
3768
|
/* @__PURE__ */ a("div", { className: "flex items-center gap-1 mb-3", children: [1, 2, 3, 4, 5].map((w) => /* @__PURE__ */ a(
|
|
@@ -3816,7 +3816,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
3816
3816
|
)
|
|
3817
3817
|
] })
|
|
3818
3818
|
] }),
|
|
3819
|
-
|
|
3819
|
+
Lr && /* @__PURE__ */ a("div", { className: "mt-3 text-xs text-green-900 font-medium", children: "Thanks for your feedback! 💚" })
|
|
3820
3820
|
] })
|
|
3821
3821
|
] }) : null;
|
|
3822
3822
|
}, ho = async () => {
|
|
@@ -3868,17 +3868,17 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
3868
3868
|
return Number.isFinite(f) && f > 0 ? +(f / 100) : +(Pn(r, k) * h);
|
|
3869
3869
|
}, qr = (u) => {
|
|
3870
3870
|
var E;
|
|
3871
|
-
const h = C, f = Kt(k), w = u || (h == null ? void 0 : h.currency) || f.currency || st, _ = Ur(h),
|
|
3872
|
-
return { product_total: _, tax:
|
|
3871
|
+
const h = C, f = Kt(k), w = u || (h == null ? void 0 : h.currency) || f.currency || st, _ = Ur(h), $ = +(_ * 0.08).toFixed(2), H = ((E = nt[re]) == null ? void 0 : E.fee) || 0;
|
|
3872
|
+
return { product_total: _, tax: $, shipping_fee: H, currency: w };
|
|
3873
3873
|
}, ar = async (u, h, f) => {
|
|
3874
3874
|
Br(), go(), Ae(!0), be(!0), B(!1), Ne(!1);
|
|
3875
3875
|
const w = rr.slice(-Fn);
|
|
3876
3876
|
try {
|
|
3877
3877
|
const _ = await pr(null, null);
|
|
3878
3878
|
if (!_) throw new Error("Failed to fetch token");
|
|
3879
|
-
const
|
|
3879
|
+
const $ = localStorage.getItem("customerNumber"), H = localStorage.getItem("isLoggedIn"), U = `https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({
|
|
3880
3880
|
registered: String(H || !1),
|
|
3881
|
-
userId: String(
|
|
3881
|
+
userId: String($ || (/* @__PURE__ */ new Date()).getTime())
|
|
3882
3882
|
}).toString()}`, O = await fetch(`${U}`, {
|
|
3883
3883
|
method: "POST",
|
|
3884
3884
|
headers: {
|
|
@@ -3901,28 +3901,28 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
3901
3901
|
});
|
|
3902
3902
|
if (!O.body) throw new Error("Readable stream not supported");
|
|
3903
3903
|
const oe = O.body.getReader(), Ie = new TextDecoder();
|
|
3904
|
-
let
|
|
3904
|
+
let $e = "", Le = "", et = "";
|
|
3905
3905
|
for (; ; ) {
|
|
3906
3906
|
const { done: Fe, value: Ke } = await oe.read();
|
|
3907
3907
|
if (Fe) break;
|
|
3908
|
-
|
|
3909
|
-
const ht =
|
|
3908
|
+
$e += Ie.decode(Ke, { stream: !0 });
|
|
3909
|
+
const ht = $e.split(`
|
|
3910
3910
|
`);
|
|
3911
|
-
|
|
3911
|
+
$e = ht.pop() || "";
|
|
3912
3912
|
for (const pt of ht) {
|
|
3913
3913
|
if (!pt.startsWith("data:")) continue;
|
|
3914
3914
|
const tt = pt.slice(5).trim();
|
|
3915
3915
|
try {
|
|
3916
3916
|
const Re = JSON.parse(tt), De = Re.index, ce = Re.data;
|
|
3917
|
-
De === 0 ?
|
|
3917
|
+
De === 0 ? Le = String(ce ?? "") : De === 1 && (et = String(ce ?? ""));
|
|
3918
3918
|
} catch (Re) {
|
|
3919
3919
|
console.error("Error parsing JSON chunk:", Re);
|
|
3920
3920
|
}
|
|
3921
3921
|
}
|
|
3922
3922
|
}
|
|
3923
3923
|
let Pe = null;
|
|
3924
|
-
if (
|
|
3925
|
-
const Fe = String(
|
|
3924
|
+
if (Le) {
|
|
3925
|
+
const Fe = String(Le).replace(/\\n/g, "").trim();
|
|
3926
3926
|
if (Fe.startsWith("{") && Fe.endsWith("}"))
|
|
3927
3927
|
try {
|
|
3928
3928
|
Pe = JSON.parse(Fe), Pe.product_id = h, Pe.sku_id = h, localStorage.setItem("agentic_order", JSON.stringify(Pe));
|
|
@@ -3941,7 +3941,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
3941
3941
|
...Fe,
|
|
3942
3942
|
{
|
|
3943
3943
|
userQuery: u,
|
|
3944
|
-
mainResponse:
|
|
3944
|
+
mainResponse: Le || "",
|
|
3945
3945
|
keywords: et || ""
|
|
3946
3946
|
}
|
|
3947
3947
|
].slice(-Fn));
|
|
@@ -4025,15 +4025,15 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4025
4025
|
localStorage.getItem("agentic_order_address") || "null"
|
|
4026
4026
|
), f = localStorage.getItem(
|
|
4027
4027
|
"agentic_order_delivery"
|
|
4028
|
-
), w = localStorage.getItem("agentic_order_payment") || "card", { product_total: _, tax:
|
|
4028
|
+
), w = localStorage.getItem("agentic_order_payment") || "card", { product_total: _, tax: $, shipping_fee: H, currency: E } = qr(), U = u.shopper_id || localStorage.getItem("customerId") || void 0, O = (h == null ? void 0 : h.addressId) || (h == null ? void 0 : h.id) || void 0, oe = f ? Vs[f] : "GROUND", Ie = "card-visa", $e = k == null ? void 0 : k.sku, Le = (r == null ? void 0 : r.id) || "", et = _t(u), Pe = typeof u.max_price_minor == "number" ? u.max_price_minor : Math.round(_ * 100), ht = {
|
|
4029
4029
|
shopper_id: U,
|
|
4030
4030
|
shipping_address_id: O,
|
|
4031
4031
|
shipping_method_id: oe,
|
|
4032
4032
|
payment_method_id: Ie,
|
|
4033
|
-
sku:
|
|
4033
|
+
sku: $e,
|
|
4034
4034
|
platform: "SFCC",
|
|
4035
4035
|
storeCode: "Sites-SiteGenesis-Site",
|
|
4036
|
-
product_id:
|
|
4036
|
+
product_id: Le,
|
|
4037
4037
|
quantity: et,
|
|
4038
4038
|
max_price_minor: Pe,
|
|
4039
4039
|
currency: E,
|
|
@@ -4063,8 +4063,8 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4063
4063
|
body: JSON.stringify(ht)
|
|
4064
4064
|
});
|
|
4065
4065
|
if (!De.ok) {
|
|
4066
|
-
const
|
|
4067
|
-
console.error("intent-mandate failed", De.status,
|
|
4066
|
+
const $o = await De.text().catch(() => "");
|
|
4067
|
+
console.error("intent-mandate failed", De.status, $o), alert(
|
|
4068
4068
|
"Something went wrong while saving your smart order. Please try again."
|
|
4069
4069
|
), Ae(!1);
|
|
4070
4070
|
return;
|
|
@@ -4078,7 +4078,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4078
4078
|
address: h,
|
|
4079
4079
|
delivery: f,
|
|
4080
4080
|
payment: w,
|
|
4081
|
-
summary: { product_total: _, tax:
|
|
4081
|
+
summary: { product_total: _, tax: $, shipping_fee: H, currency: E },
|
|
4082
4082
|
intent_mandate_id: rt
|
|
4083
4083
|
};
|
|
4084
4084
|
localStorage.setItem("agentic_order_final", JSON.stringify(Mt)), ee(!0), te(!1), St("final", Mt), St("success", { intentMandateId: rt }), Dt();
|
|
@@ -4102,7 +4102,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4102
4102
|
]);
|
|
4103
4103
|
}, Eo = ({ selectedIndex: u }) => {
|
|
4104
4104
|
var O;
|
|
4105
|
-
const h = ((O = y[u]) == null ? void 0 : O.images.large[0].link) || _n(r, k), f = In(r), w = Nt || "", _ = wt(k) || "",
|
|
4105
|
+
const h = ((O = y[u]) == null ? void 0 : O.images.large[0].link) || _n(r, k), f = In(r), w = Nt || "", _ = wt(k) || "", $ = yt(k) || "", { amount: H } = Kt(k), E = !!(r != null && r.id), U = E;
|
|
4106
4106
|
return /* @__PURE__ */ a("div", { className: "mx-4 mt-2 rounded-xl border border-gray-200 bg-white p-4", children: /* @__PURE__ */ d("div", { className: "flex flex-col sm:flex-row items-center sm:items-center gap-4", children: [
|
|
4107
4107
|
/* @__PURE__ */ a("div", { className: "flex-shrink-0 flex justify-center sm:justify-start", children: /* @__PURE__ */ a("div", { className: "w-[150px] h-[150px] rounded-lg bg-gray-50 border border-gray-200 flex items-center justify-center overflow-hidden", children: h ? /* @__PURE__ */ a(
|
|
4108
4108
|
"img",
|
|
@@ -4124,7 +4124,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4124
4124
|
/* @__PURE__ */ a("div", { className: "text-sm text-gray-700 mb-1", children: [
|
|
4125
4125
|
w && `SKU: ${w}`,
|
|
4126
4126
|
_ && `Color: ${_}`,
|
|
4127
|
-
|
|
4127
|
+
$ && `Size: ${$}`
|
|
4128
4128
|
].filter(Boolean).join(" • ") || "—" }),
|
|
4129
4129
|
/* @__PURE__ */ a("div", { className: "mt-1 text-xl font-semibold text-gray-900", children: E ? (
|
|
4130
4130
|
// ? formatCurrency(Number(unitPrice) || 0, CURRENCY_PREF)
|
|
@@ -4147,7 +4147,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4147
4147
|
M && /* @__PURE__ */ a("div", { className: "text-sm text-gray-600", children: M })
|
|
4148
4148
|
] }),
|
|
4149
4149
|
/* @__PURE__ */ a("div", { className: "flex flex-wrap gap-4 mt-2", children: y.map((w, _) => {
|
|
4150
|
-
const
|
|
4150
|
+
const $ = w.name, H = M === $, E = w.images.large[0].disBaseLink || w.images.large[0].link;
|
|
4151
4151
|
return /* @__PURE__ */ a(
|
|
4152
4152
|
"div",
|
|
4153
4153
|
{
|
|
@@ -4157,22 +4157,22 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4157
4157
|
"button",
|
|
4158
4158
|
{
|
|
4159
4159
|
onClick: () => {
|
|
4160
|
-
Ee(
|
|
4160
|
+
Ee($), K(null), q(null), S(_);
|
|
4161
4161
|
},
|
|
4162
4162
|
className: "w-full h-20 flex items-center justify-center overflow-hidden",
|
|
4163
|
-
title:
|
|
4163
|
+
title: $,
|
|
4164
4164
|
children: E ? /* @__PURE__ */ a(
|
|
4165
4165
|
"img",
|
|
4166
4166
|
{
|
|
4167
4167
|
src: E,
|
|
4168
|
-
alt:
|
|
4168
|
+
alt: $,
|
|
4169
4169
|
className: "w/full h-full object-contain"
|
|
4170
4170
|
}
|
|
4171
|
-
) : /* @__PURE__ */ a("div", { className: "w-full h-full flex items-center justify-center text-xs px-1", children:
|
|
4171
|
+
) : /* @__PURE__ */ a("div", { className: "w-full h-full flex items-center justify-center text-xs px-1", children: $ })
|
|
4172
4172
|
}
|
|
4173
4173
|
)
|
|
4174
4174
|
},
|
|
4175
|
-
|
|
4175
|
+
$
|
|
4176
4176
|
);
|
|
4177
4177
|
}) })
|
|
4178
4178
|
] }),
|
|
@@ -4185,13 +4185,13 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4185
4185
|
const w = y.find(
|
|
4186
4186
|
(_) => _.name === M
|
|
4187
4187
|
);
|
|
4188
|
-
return w ? w.variants.map((_,
|
|
4188
|
+
return w ? w.variants.map((_, $) => {
|
|
4189
4189
|
const H = _.name;
|
|
4190
4190
|
return /* @__PURE__ */ a(
|
|
4191
4191
|
"button",
|
|
4192
4192
|
{
|
|
4193
4193
|
onClick: () => {
|
|
4194
|
-
K(H), q(
|
|
4194
|
+
K(H), q($), uo(_.productId);
|
|
4195
4195
|
},
|
|
4196
4196
|
className: `px-4 py-2 rounded-md border text-sm ${F === H ? "border-2 border-[#804c9e] font-semibold" : "border-gray-300"}`,
|
|
4197
4197
|
title: H,
|
|
@@ -4217,7 +4217,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4217
4217
|
!(u != null && u.extractedDetails) && u && (u = { extractedDetails: u });
|
|
4218
4218
|
const f = (u == null ? void 0 : u.extractedDetails) || C;
|
|
4219
4219
|
if (!f) return null;
|
|
4220
|
-
const w = _t(f), { currency: _ } = Kt(k),
|
|
4220
|
+
const w = _t(f), { currency: _ } = Kt(k), $ = Pn(r, k), H = Number((f == null ? void 0 : f.max_price_minor) ?? 0), U = Number.isFinite(H) && H > 0 ? +(H / 100) : +($ * w), O = (f == null ? void 0 : f.currency) || _ || st, oe = k != null && k.sku ? k.sku : f.product_id;
|
|
4221
4221
|
return /* @__PURE__ */ d(
|
|
4222
4222
|
"div",
|
|
4223
4223
|
{
|
|
@@ -4321,7 +4321,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4321
4321
|
);
|
|
4322
4322
|
}, Kr = (u, h = !0) => {
|
|
4323
4323
|
var pt, tt, Re, De, ce, rt;
|
|
4324
|
-
const f = u || {}, w = ((pt = f == null ? void 0 : f.summary) == null ? void 0 : pt.currency) || (C == null ? void 0 : C.currency) || st, _ = _n(r, k),
|
|
4324
|
+
const f = u || {}, w = ((pt = f == null ? void 0 : f.summary) == null ? void 0 : pt.currency) || (C == null ? void 0 : C.currency) || st, _ = _n(r, k), $ = In(r), H = k != null && k.sku ? k.sku : (r == null ? void 0 : r.id) ?? (C == null ? void 0 : C.product_id), E = (k == null ? void 0 : k.sku) ?? Ks(r), U = wt(k) || Ws(r), O = yt(k) || Qs(r), oe = _t(f), Ie = ((tt = f == null ? void 0 : f.summary) == null ? void 0 : tt.product_total) != null ? +f.summary.product_total : Ur(f), $e = oe > 0 ? +(Ie / oe).toFixed(2) : 0, Le = Ie, et = ((Re = f == null ? void 0 : f.summary) == null ? void 0 : Re.tax) ?? +(Ie * 0.08).toFixed(2), Pe = ((De = f == null ? void 0 : f.summary) == null ? void 0 : De.shipping_fee) ?? (((ce = nt[re]) == null ? void 0 : ce.fee) || 0), Fe = f != null && f.address ? [
|
|
4325
4325
|
f.address.addressLine1,
|
|
4326
4326
|
f.address.addressLine2,
|
|
4327
4327
|
f.address.street,
|
|
@@ -4349,7 +4349,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4349
4349
|
"img",
|
|
4350
4350
|
{
|
|
4351
4351
|
src: _,
|
|
4352
|
-
alt:
|
|
4352
|
+
alt: $,
|
|
4353
4353
|
className: "w-full h-full object-contain"
|
|
4354
4354
|
}
|
|
4355
4355
|
) : /* @__PURE__ */ a(
|
|
@@ -4362,7 +4362,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4362
4362
|
) }) }),
|
|
4363
4363
|
/* @__PURE__ */ d("div", { className: "sm:col-span-10", children: [
|
|
4364
4364
|
/* @__PURE__ */ d("div", { className: "mb-3", children: [
|
|
4365
|
-
/* @__PURE__ */ a("div", { className: "text-lg text-center font-bold text-gray-900", children:
|
|
4365
|
+
/* @__PURE__ */ a("div", { className: "text-lg text-center font-bold text-gray-900", children: $ }),
|
|
4366
4366
|
/* @__PURE__ */ d("div", { className: "text-xs text-center font-bold text-gray-600", children: [
|
|
4367
4367
|
/* @__PURE__ */ a("span", { className: "font-medium", children: "SKU:" }),
|
|
4368
4368
|
" ",
|
|
@@ -4391,7 +4391,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4391
4391
|
/* @__PURE__ */ d("div", { className: "grid grid-cols-1 md-grid-cols-3 md:grid-cols-3 gap-3", children: [
|
|
4392
4392
|
/* @__PURE__ */ d("div", { className: "flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center", children: [
|
|
4393
4393
|
/* @__PURE__ */ a("div", { className: "text-[11px] uppercase tracking-wide text-gray-500", children: "Unit Price" }),
|
|
4394
|
-
/* @__PURE__ */ a("div", { className: "mt-0.5 text-base font-bold text-gray-900", children: Qe(
|
|
4394
|
+
/* @__PURE__ */ a("div", { className: "mt-0.5 text-base font-bold text-gray-900", children: Qe($e, w) })
|
|
4395
4395
|
] }),
|
|
4396
4396
|
/* @__PURE__ */ d("div", { className: "flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center", children: [
|
|
4397
4397
|
/* @__PURE__ */ a("div", { className: "text-[11px] uppercase tracking-wide text-gray-500", children: "Quantity" }),
|
|
@@ -4399,7 +4399,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4399
4399
|
] }),
|
|
4400
4400
|
/* @__PURE__ */ d("div", { className: "flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center", children: [
|
|
4401
4401
|
/* @__PURE__ */ a("div", { className: "text-[11px] uppercase tracking-wide text-gray-500", children: "Subtotal" }),
|
|
4402
|
-
/* @__PURE__ */ a("div", { className: "mt-0.5 text-base font-bold text-gray-900", children: Qe(
|
|
4402
|
+
/* @__PURE__ */ a("div", { className: "mt-0.5 text-base font-bold text-gray-900", children: Qe(Le, w) })
|
|
4403
4403
|
] })
|
|
4404
4404
|
] })
|
|
4405
4405
|
] })
|
|
@@ -4437,7 +4437,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4437
4437
|
"div",
|
|
4438
4438
|
{
|
|
4439
4439
|
className: "mt-4 rounded-xl p-4 text-center text-white shadow-sm",
|
|
4440
|
-
style: { background:
|
|
4440
|
+
style: { background: Lt },
|
|
4441
4441
|
children: [
|
|
4442
4442
|
/* @__PURE__ */ a("div", { className: "text-sm/5 opacity-95", children: "🔹 Total Payable" }),
|
|
4443
4443
|
/* @__PURE__ */ a("div", { className: "mt-1 text-3xl font-extrabold tracking-tight", children: Qe(Ie + et + Pe, w) })
|
|
@@ -4454,7 +4454,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4454
4454
|
{
|
|
4455
4455
|
onClick: Fo,
|
|
4456
4456
|
className: "inline-flex items-center justify-center rounded-full px-6 py-2.5 font-semibold text-white shadow-md transition-transform duration-150 hover:-translate-y-0.5 hover:shadow-lg",
|
|
4457
|
-
style: { background:
|
|
4457
|
+
style: { background: Lt },
|
|
4458
4458
|
children: "Confirm"
|
|
4459
4459
|
}
|
|
4460
4460
|
),
|
|
@@ -4463,7 +4463,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4463
4463
|
{
|
|
4464
4464
|
onClick: Vr,
|
|
4465
4465
|
className: "inline-flex items-center justify-center rounded-full border px-6 py-2.5 font-semibold hover:bg-gray-50",
|
|
4466
|
-
style: { borderColor:
|
|
4466
|
+
style: { borderColor: Lt, color: Lt },
|
|
4467
4467
|
children: "Cancel"
|
|
4468
4468
|
}
|
|
4469
4469
|
)
|
|
@@ -4654,7 +4654,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4654
4654
|
/* @__PURE__ */ d(
|
|
4655
4655
|
"div",
|
|
4656
4656
|
{
|
|
4657
|
-
ref:
|
|
4657
|
+
ref: $t,
|
|
4658
4658
|
className: "overflow-y-auto pr-5 pb-4 space-y-4 hide-scrollbar flex-grow",
|
|
4659
4659
|
children: [
|
|
4660
4660
|
/* @__PURE__ */ d(
|
|
@@ -4778,7 +4778,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4778
4778
|
),
|
|
4779
4779
|
"Select a Delivery Address"
|
|
4780
4780
|
] }),
|
|
4781
|
-
|
|
4781
|
+
L && /* @__PURE__ */ d(ge, { children: [
|
|
4782
4782
|
/* @__PURE__ */ a("span", { className: "ml-2 text-xs px-2 py-1 rounded-full bg-green-100 text-green-700 font-semibold", children: "Selected" }),
|
|
4783
4783
|
!Be && /* @__PURE__ */ a(
|
|
4784
4784
|
"button",
|
|
@@ -4805,18 +4805,18 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4805
4805
|
}
|
|
4806
4806
|
),
|
|
4807
4807
|
/* @__PURE__ */ a("p", { className: "ml-3 text-gray-600", children: "Fetching your addresses..." })
|
|
4808
|
-
] }) : m.length > 0 ? /* @__PURE__ */ d(
|
|
4808
|
+
] }) : (m == null ? void 0 : m.length) > 0 ? /* @__PURE__ */ d(
|
|
4809
4809
|
"div",
|
|
4810
4810
|
{
|
|
4811
|
-
className: `space-y-3 ${
|
|
4811
|
+
className: `space-y-3 ${L ? "opacity-70" : ""}`,
|
|
4812
4812
|
children: [
|
|
4813
4813
|
m.map((u) => {
|
|
4814
|
-
const h = [u.addressLine1, u.addressLine2].filter(Boolean).map((E) => We(E || "")).join(" "), f = We(u.city || ""), w = `${We(u.state || "")}${u.state && u.postalCode ? ", " : ""}${u.postalCode || ""}`, _ = We(u.country || ""),
|
|
4814
|
+
const h = [u.addressLine1, u.addressLine2].filter(Boolean).map((E) => We(E || "")).join(" "), f = We(u.city || ""), w = `${We(u.state || "")}${u.state && u.postalCode ? ", " : ""}${u.postalCode || ""}`, _ = We(u.country || ""), $ = String(u.addressId ?? u.id), H = Y === $;
|
|
4815
4815
|
return /* @__PURE__ */ d(
|
|
4816
4816
|
"label",
|
|
4817
4817
|
{
|
|
4818
|
-
className: `flex items-start gap-3 p-4 border rounded-lg cursor-pointer transition hover:shadow-sm ${H ? "border-tanya-light" : "border-gray-300"} ${
|
|
4819
|
-
title:
|
|
4818
|
+
className: `flex items-start gap-3 p-4 border rounded-lg cursor-pointer transition hover:shadow-sm ${H ? "border-tanya-light" : "border-gray-300"} ${L ? "pointer-events-none" : ""}`,
|
|
4819
|
+
title: L ? "Address already submitted" : "",
|
|
4820
4820
|
children: [
|
|
4821
4821
|
/* @__PURE__ */ a(
|
|
4822
4822
|
"input",
|
|
@@ -4825,9 +4825,9 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4825
4825
|
name: "address",
|
|
4826
4826
|
className: "mt-1 accent-tanya-light",
|
|
4827
4827
|
checked: H,
|
|
4828
|
-
disabled:
|
|
4829
|
-
onChange: () => z(
|
|
4830
|
-
value:
|
|
4828
|
+
disabled: L,
|
|
4829
|
+
onChange: () => z($),
|
|
4830
|
+
value: $
|
|
4831
4831
|
}
|
|
4832
4832
|
),
|
|
4833
4833
|
/* @__PURE__ */ d("div", { className: "flex-1", children: [
|
|
@@ -4842,7 +4842,7 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4842
4842
|
] })
|
|
4843
4843
|
]
|
|
4844
4844
|
},
|
|
4845
|
-
|
|
4845
|
+
$
|
|
4846
4846
|
);
|
|
4847
4847
|
}),
|
|
4848
4848
|
/* @__PURE__ */ d("div", { className: "flex justify-between pt-2", children: [
|
|
@@ -4862,10 +4862,10 @@ const st = "USD", qs = (e, t = st) => {
|
|
|
4862
4862
|
"button",
|
|
4863
4863
|
{
|
|
4864
4864
|
onClick: ko,
|
|
4865
|
-
disabled:
|
|
4866
|
-
className: `px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${
|
|
4865
|
+
disabled: L,
|
|
4866
|
+
className: `px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${L ? "opacity-60 cursor-not-allowed" : "hover:-translate-y-0.5 hover:shadow-lg"}`,
|
|
4867
4867
|
style: { background: qe },
|
|
4868
|
-
children:
|
|
4868
|
+
children: L ? "Address Submitted" : "Submit Address"
|
|
4869
4869
|
}
|
|
4870
4870
|
)
|
|
4871
4871
|
] })
|