@instockng/storefront-ui 1.0.113 → 1.0.114
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/components/AssistantDrawer.d.ts.map +1 -1
- package/dist/index100.mjs +8 -67
- package/dist/index101.mjs +71 -83
- package/dist/index102.mjs +3 -28
- package/dist/index103.mjs +2 -9
- package/dist/index104.mjs +78 -70
- package/dist/index105.mjs +53 -3
- package/dist/index106.mjs +6 -2
- package/dist/index107.mjs +4 -82
- package/dist/index108.mjs +176 -51
- package/dist/index109.mjs +53 -6
- package/dist/index110.mjs +69 -5
- package/dist/index111.mjs +37 -179
- package/dist/index112.mjs +41 -51
- package/dist/index113.mjs +2 -69
- package/dist/index115.mjs +1 -1
- package/dist/index116.mjs +1 -1
- package/dist/index117.mjs +6 -6
- package/dist/index118.mjs +4 -4
- package/dist/index119.mjs +3 -3
- package/dist/index120.mjs +1 -1
- package/dist/index121.mjs +1 -1
- package/dist/index122.mjs +1 -1
- package/dist/index123.mjs +2 -2
- package/dist/index124.mjs +2 -2
- package/dist/index125.mjs +3 -3
- package/dist/index126.mjs +1 -1
- package/dist/index127.mjs +3 -3
- package/dist/index128.mjs +2 -2
- package/dist/index129.mjs +2 -2
- package/dist/index130.mjs +1 -1
- package/dist/index131.mjs +3 -3
- package/dist/index132.mjs +1 -1
- package/dist/index133.mjs +1 -1
- package/dist/index134.mjs +3 -3
- package/dist/index135.mjs +2 -2
- package/dist/index136.mjs +4 -4
- package/dist/index137.mjs +1 -1
- package/dist/index138.mjs +3 -3
- package/dist/index139.mjs +4 -4
- package/dist/index140.mjs +1 -1
- package/dist/index141.mjs +1 -1
- package/dist/index142.mjs +1 -1
- package/dist/index143.mjs +1 -1
- package/dist/index144.mjs +1 -1
- package/dist/index145.mjs +1 -1
- package/dist/index146.mjs +1 -1
- package/dist/index147.mjs +2 -2
- package/dist/index148.mjs +3 -3
- package/dist/index151.mjs +1 -1
- package/dist/index153.mjs +21 -2
- package/dist/index154.mjs +56 -2
- package/dist/index155.mjs +29 -2
- package/dist/index156.mjs +7 -2
- package/dist/index157.mjs +50 -16
- package/dist/index158.mjs +6 -32
- package/dist/index159.mjs +11 -37
- package/dist/index160.mjs +7 -18
- package/dist/index161.mjs +28 -18
- package/dist/index162.mjs +2 -2
- package/dist/index163.mjs +70 -20
- package/dist/index164.mjs +163 -42
- package/dist/index166.mjs +2 -30
- package/dist/index167.mjs +2 -18
- package/dist/index168.mjs +2 -2
- package/dist/index169.mjs +18 -2
- package/dist/index170.mjs +32 -2
- package/dist/index171.mjs +38 -2
- package/dist/index172.mjs +13 -67
- package/dist/index173.mjs +18 -2
- package/dist/index174.mjs +2 -53
- package/dist/index175.mjs +20 -2
- package/dist/index176.mjs +39 -29
- package/dist/index177.mjs +2 -152
- package/dist/index178.mjs +30 -2
- package/dist/index179.mjs +18 -2
- package/dist/index180.mjs +2 -19
- package/dist/index181.mjs +2 -2
- package/dist/index182.mjs +2 -2
- package/dist/index183.mjs +2 -26
- package/dist/index184.mjs +72 -2
- package/dist/index185.mjs +2 -2
- package/dist/index186.mjs +49 -20
- package/dist/index187.mjs +2 -23
- package/dist/index188.mjs +36 -2
- package/dist/index189.mjs +152 -2
- package/dist/index190.mjs +2 -2
- package/dist/index191.mjs +2 -23
- package/dist/index192.mjs +19 -2
- package/dist/index193.mjs +2 -23
- package/dist/index195.mjs +26 -2
- package/dist/index196.mjs +2 -2
- package/dist/index197.mjs +2 -23
- package/dist/index198.mjs +24 -2
- package/dist/index199.mjs +15 -15
- package/dist/index200.mjs +2 -2
- package/dist/index201.mjs +2 -2
- package/dist/index202.mjs +2 -2
- package/dist/index203.mjs +23 -2
- package/dist/index204.mjs +2 -2
- package/dist/index205.mjs +23 -2
- package/dist/index206.mjs +2 -2
- package/dist/index207.mjs +2 -2
- package/dist/index208.mjs +2 -127
- package/dist/index209.mjs +23 -2
- package/dist/index210.mjs +2 -74
- package/dist/index211.mjs +20 -71
- package/dist/index212.mjs +2 -21
- package/dist/index213.mjs +2 -56
- package/dist/index214.mjs +2 -29
- package/dist/index215.mjs +2 -7
- package/dist/index216.mjs +2 -52
- package/dist/index217.mjs +2 -6
- package/dist/index218.mjs +2 -12
- package/dist/index219.mjs +2 -7
- package/dist/index22.mjs +139 -128
- package/dist/index220.mjs +127 -28
- package/dist/index221.mjs +2 -2
- package/dist/index222.mjs +73 -69
- package/dist/index223.mjs +71 -164
- package/dist/index224.mjs +31 -2
- package/dist/index225.mjs +11 -2
- package/dist/index226.mjs +4 -2
- package/dist/index227.mjs +4 -2
- package/dist/index228.mjs +13 -2
- package/dist/index229.mjs +7 -2
- package/dist/index230.mjs +12 -2
- package/dist/index231.mjs +5 -2
- package/dist/index232.mjs +33 -244
- package/dist/index233.mjs +31 -2
- package/dist/index234.mjs +27 -32
- package/dist/index235.mjs +59 -63
- package/dist/index236.mjs +2 -25
- package/dist/index237.mjs +2 -2
- package/dist/index238.mjs +2 -2
- package/dist/index239.mjs +2 -37
- package/dist/index241.mjs +2 -2
- package/dist/index242.mjs +108 -2
- package/dist/index244.mjs +2 -2
- package/dist/index245.mjs +2 -2
- package/dist/index246.mjs +2 -2
- package/dist/index247.mjs +233 -97
- package/dist/index249.mjs +33 -2
- package/dist/index250.mjs +65 -2
- package/dist/index251.mjs +25 -2
- package/dist/index253.mjs +37 -2
- package/dist/index254.mjs +2 -4
- package/dist/index255.mjs +2 -13
- package/dist/index256.mjs +2 -7
- package/dist/index257.mjs +2 -31
- package/dist/index258.mjs +2 -11
- package/dist/index259.mjs +2 -4
- package/dist/index260.mjs +2 -4
- package/dist/index261.mjs +2 -12
- package/dist/index262.mjs +2 -5
- package/dist/index263.mjs +2 -33
- package/dist/index264.mjs +2 -31
- package/dist/index265.mjs +2 -28
- package/dist/index266.mjs +4 -61
- package/dist/index267.mjs +3 -2
- package/dist/index268.mjs +2 -2
- package/dist/index269.mjs +2 -18
- package/dist/index270.mjs +16 -46
- package/dist/index271.mjs +13 -2
- package/dist/index272.mjs +6 -2
- package/dist/index273.mjs +30 -2
- package/dist/index274.mjs +2 -91
- package/dist/index275.mjs +2 -2
- package/dist/index276.mjs +18 -2
- package/dist/index277.mjs +47 -3
- package/dist/index278.mjs +2 -2
- package/dist/index279.mjs +2 -2
- package/dist/index280.mjs +2 -17
- package/dist/index281.mjs +2 -13
- package/dist/index282.mjs +91 -6
- package/dist/index283.mjs +2 -30
- package/dist/index43.mjs +1 -1
- package/dist/index44.mjs +1 -1
- package/dist/index45.mjs +1 -1
- package/dist/index46.mjs +1 -1
- package/dist/index47.mjs +1 -1
- package/dist/index48.mjs +2 -2
- package/dist/index50.mjs +1 -1
- package/dist/index54.mjs +3 -3
- package/dist/index58.mjs +1 -1
- package/dist/index63.mjs +17 -17
- package/dist/index64.mjs +2 -2
- package/dist/index65.mjs +1 -1
- package/dist/index66.mjs +1 -1
- package/dist/index67.mjs +1 -1
- package/dist/index68.mjs +1 -1
- package/dist/index69.mjs +1 -1
- package/dist/index70.mjs +1 -1
- package/dist/index71.mjs +1 -1
- package/dist/index72.mjs +1 -1
- package/dist/index73.mjs +1 -1
- package/dist/index74.mjs +1 -1
- package/dist/index75.mjs +1 -1
- package/dist/index76.mjs +1 -1
- package/dist/index77.mjs +1 -1
- package/dist/index78.mjs +1 -1
- package/dist/index79.mjs +20 -21
- package/dist/index80.mjs +24 -2
- package/dist/index82.mjs +4 -22
- package/dist/index83.mjs +2 -75
- package/dist/index84.mjs +74 -14
- package/dist/index85.mjs +14 -62
- package/dist/index86.mjs +62 -4
- package/dist/index94.mjs +235 -2
- package/dist/index95.mjs +6 -37
- package/dist/index96.mjs +130 -39
- package/dist/index97.mjs +62 -229
- package/dist/index98.mjs +86 -5
- package/dist/index99.mjs +26 -131
- package/package.json +1 -1
- package/src/components/AssistantDrawer.tsx +20 -1
package/dist/index219.mjs
CHANGED
package/dist/index22.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useState as
|
|
2
|
+
import { jsxs as c, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { useState as g, useRef as x, useCallback as O, useEffect as S } from "react";
|
|
4
4
|
import { createPortal as Z } from "react-dom";
|
|
5
5
|
import { Sparkles as Q, X as ee, MessageCircle as te, Loader2 as re, Send as se } from "lucide-react";
|
|
6
6
|
import { cn as k, formatCurrency as ne, WHATSAPP_HELP_LINK as ae } from "./index30.mjs";
|
|
@@ -8,167 +8,168 @@ import { useHideBodyOverflow as oe } from "./index53.mjs";
|
|
|
8
8
|
function le(a) {
|
|
9
9
|
return a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>").replace(/\*(.+?)\*/g, "<em>$1</em>").replace(/\n/g, "<br />");
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return a.replace(/\s*PRODUCTS:[\w\-,]*\s*/g, "").replace(/\s*CONTACT_SUPPORT\s*/gi, "");
|
|
11
|
+
function ie(a) {
|
|
12
|
+
return a.replace(/\s*PRODUCTS:[\w\-,]*\s*/g, "").replace(/\s*CONTACT_SUPPORT\s*/gi, "").replace(/\s*SUGGESTIONS:[^\n]*\s*/g, "");
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function he({
|
|
15
15
|
isOpen: a,
|
|
16
|
-
onClose:
|
|
17
|
-
apiUrl:
|
|
18
|
-
brandSlug:
|
|
19
|
-
productSlug:
|
|
20
|
-
initialQuestion:
|
|
21
|
-
assistantName:
|
|
22
|
-
className:
|
|
23
|
-
disablePortal:
|
|
16
|
+
onClose: y,
|
|
17
|
+
apiUrl: R,
|
|
18
|
+
brandSlug: j,
|
|
19
|
+
productSlug: I,
|
|
20
|
+
initialQuestion: w,
|
|
21
|
+
assistantName: L = "AI Assistant",
|
|
22
|
+
className: z,
|
|
23
|
+
disablePortal: B = !1
|
|
24
24
|
}) {
|
|
25
|
-
const [
|
|
26
|
-
J.current =
|
|
27
|
-
const
|
|
25
|
+
const [d, u] = g([]), [N, A] = g(""), [m, _] = g(!1), [$, h] = g(null), [M, W] = g(!1), [K, D] = g(!1), H = x(null), U = x(null), E = x(!1), J = x([]);
|
|
26
|
+
J.current = d, oe(a);
|
|
27
|
+
const q = O((e, l) => {
|
|
28
28
|
if (e === "token")
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
if ((
|
|
32
|
-
const n =
|
|
33
|
-
|
|
29
|
+
u((s) => {
|
|
30
|
+
const o = [...s], r = o[o.length - 1];
|
|
31
|
+
if ((r == null ? void 0 : r.role) === "assistant") {
|
|
32
|
+
const n = r.content + l, i = ie(n);
|
|
33
|
+
o[o.length - 1] = { ...r, content: i };
|
|
34
34
|
}
|
|
35
|
-
return
|
|
35
|
+
return o;
|
|
36
36
|
});
|
|
37
37
|
else if (e === "done")
|
|
38
38
|
try {
|
|
39
|
-
const s = JSON.parse(
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
const
|
|
43
|
-
return (n == null ? void 0 : n.role) === "assistant" && (
|
|
39
|
+
const s = JSON.parse(l);
|
|
40
|
+
u((o) => {
|
|
41
|
+
var i, f;
|
|
42
|
+
const r = [...o], n = r[r.length - 1];
|
|
43
|
+
return (n == null ? void 0 : n.role) === "assistant" && (r[r.length - 1] = {
|
|
44
44
|
...n,
|
|
45
45
|
content: s.answer || n.content,
|
|
46
|
-
products: ((
|
|
47
|
-
whatsapp: s.whatsapp || !1
|
|
48
|
-
|
|
46
|
+
products: ((i = s.products) == null ? void 0 : i.length) > 0 ? s.products : void 0,
|
|
47
|
+
whatsapp: s.whatsapp || !1,
|
|
48
|
+
suggestions: ((f = s.suggestions) == null ? void 0 : f.length) > 0 ? s.suggestions : void 0
|
|
49
|
+
}), r;
|
|
49
50
|
});
|
|
50
51
|
} catch {
|
|
51
52
|
}
|
|
52
53
|
else if (e === "error")
|
|
53
54
|
try {
|
|
54
|
-
const s = JSON.parse(
|
|
55
|
+
const s = JSON.parse(l);
|
|
55
56
|
h(s.message || "An error occurred");
|
|
56
57
|
} catch {
|
|
57
58
|
h("An error occurred");
|
|
58
59
|
}
|
|
59
|
-
}, []),
|
|
60
|
+
}, []), v = x(null), T = O(
|
|
60
61
|
async (e) => {
|
|
61
|
-
var
|
|
62
|
+
var o;
|
|
62
63
|
if (!e.trim()) return;
|
|
63
64
|
h(null);
|
|
64
|
-
const
|
|
65
|
-
role:
|
|
66
|
-
content:
|
|
65
|
+
const l = { role: "user", content: e }, s = J.current.slice(-20).map((r) => ({
|
|
66
|
+
role: r.role,
|
|
67
|
+
content: r.content
|
|
67
68
|
}));
|
|
68
|
-
|
|
69
|
+
u((r) => [...r, l]), A(""), _(!0), u((r) => [...r, { role: "assistant", content: "" }]);
|
|
69
70
|
try {
|
|
70
|
-
const
|
|
71
|
+
const r = await fetch(`${R}/v1/assistant/ask`, {
|
|
71
72
|
method: "POST",
|
|
72
73
|
headers: { "Content-Type": "application/json" },
|
|
73
74
|
body: JSON.stringify({
|
|
74
75
|
question: e,
|
|
75
|
-
brandSlug:
|
|
76
|
-
productSlug:
|
|
76
|
+
brandSlug: j,
|
|
77
|
+
productSlug: I,
|
|
77
78
|
history: s
|
|
78
79
|
})
|
|
79
80
|
});
|
|
80
|
-
if (!
|
|
81
|
-
const
|
|
81
|
+
if (!r.ok) {
|
|
82
|
+
const p = await r.json().catch(() => ({}));
|
|
82
83
|
throw new Error(
|
|
83
|
-
((
|
|
84
|
+
((o = p == null ? void 0 : p.error) == null ? void 0 : o.message) || `Request failed (${r.status})`
|
|
84
85
|
);
|
|
85
86
|
}
|
|
86
|
-
if (!
|
|
87
|
-
const n =
|
|
88
|
-
let
|
|
87
|
+
if (!r.body) throw new Error("No response body");
|
|
88
|
+
const n = r.body.getReader(), i = new TextDecoder();
|
|
89
|
+
let f = "", C = "";
|
|
89
90
|
for (; ; ) {
|
|
90
|
-
const { done:
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
const
|
|
91
|
+
const { done: p, value: X } = await n.read();
|
|
92
|
+
if (p) break;
|
|
93
|
+
f += i.decode(X, { stream: !0 });
|
|
94
|
+
const G = f.split(`
|
|
94
95
|
`);
|
|
95
|
-
|
|
96
|
-
for (const
|
|
97
|
-
if (
|
|
98
|
-
|
|
96
|
+
f = G.pop() || "";
|
|
97
|
+
for (const b of G) {
|
|
98
|
+
if (b.trim() === "") {
|
|
99
|
+
C = "";
|
|
99
100
|
continue;
|
|
100
101
|
}
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
else if (
|
|
104
|
-
const
|
|
105
|
-
|
|
102
|
+
if (b.trimStart().startsWith("event:"))
|
|
103
|
+
C = b.trimStart().slice(6).trim();
|
|
104
|
+
else if (b.trimStart().startsWith("data:")) {
|
|
105
|
+
const P = b.trimStart().slice(5), Y = P.startsWith(" ") ? P.slice(1) : P;
|
|
106
|
+
q(C || "token", Y);
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
|
-
} catch (
|
|
110
|
-
h(
|
|
111
|
-
const
|
|
112
|
-
return (
|
|
110
|
+
} catch (r) {
|
|
111
|
+
h(r.message || "Something went wrong"), u((n) => {
|
|
112
|
+
const i = n[n.length - 1];
|
|
113
|
+
return (i == null ? void 0 : i.role) === "assistant" && !i.content ? n.slice(0, -1) : n;
|
|
113
114
|
});
|
|
114
115
|
} finally {
|
|
115
|
-
|
|
116
|
+
_(!1);
|
|
116
117
|
}
|
|
117
118
|
},
|
|
118
|
-
[
|
|
119
|
+
[R, j, I, q]
|
|
119
120
|
);
|
|
120
|
-
|
|
121
|
+
v.current = T, S(() => {
|
|
121
122
|
if (a)
|
|
122
|
-
|
|
123
|
+
D(!0), requestAnimationFrame(() => {
|
|
123
124
|
requestAnimationFrame(() => {
|
|
124
|
-
|
|
125
|
+
W(!0);
|
|
125
126
|
});
|
|
126
127
|
});
|
|
127
128
|
else {
|
|
128
|
-
|
|
129
|
+
W(!1);
|
|
129
130
|
const e = setTimeout(() => {
|
|
130
|
-
|
|
131
|
+
D(!1), u([]), A(""), h(null), E.current = !1;
|
|
131
132
|
}, 300);
|
|
132
133
|
return () => clearTimeout(e);
|
|
133
134
|
}
|
|
134
|
-
}, [a]),
|
|
135
|
-
a &&
|
|
135
|
+
}, [a]), S(() => {
|
|
136
|
+
a && w && !E.current && (E.current = !0, w.trim() ? setTimeout(() => {
|
|
136
137
|
var e;
|
|
137
|
-
return (e =
|
|
138
|
+
return (e = v.current) == null ? void 0 : e.call(v, w);
|
|
138
139
|
}, 100) : setTimeout(() => {
|
|
139
140
|
var e;
|
|
140
|
-
return (e =
|
|
141
|
+
return (e = U.current) == null ? void 0 : e.focus();
|
|
141
142
|
}, 350));
|
|
142
|
-
}, [a,
|
|
143
|
+
}, [a, w]), S(() => {
|
|
143
144
|
var e;
|
|
144
|
-
(e =
|
|
145
|
-
}, [
|
|
146
|
-
const e = (
|
|
147
|
-
|
|
145
|
+
(e = H.current) == null || e.scrollIntoView({ behavior: "smooth" });
|
|
146
|
+
}, [d]), S(() => {
|
|
147
|
+
const e = (l) => {
|
|
148
|
+
l.key === "Escape" && a && y();
|
|
148
149
|
};
|
|
149
150
|
if (a)
|
|
150
151
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
151
|
-
}, [a,
|
|
152
|
-
const
|
|
153
|
-
e.preventDefault(),
|
|
152
|
+
}, [a, y]);
|
|
153
|
+
const V = (e) => {
|
|
154
|
+
e.preventDefault(), N.trim() && T(N.trim());
|
|
154
155
|
};
|
|
155
|
-
if (!
|
|
156
|
-
const F = /* @__PURE__ */
|
|
156
|
+
if (!K) return null;
|
|
157
|
+
const F = /* @__PURE__ */ c(
|
|
157
158
|
"div",
|
|
158
159
|
{
|
|
159
160
|
className: k(
|
|
160
161
|
"fixed inset-0 z-50 transition-opacity duration-300",
|
|
161
|
-
|
|
162
|
+
M ? "opacity-100" : "opacity-0"
|
|
162
163
|
),
|
|
163
164
|
children: [
|
|
164
|
-
/* @__PURE__ */
|
|
165
|
+
/* @__PURE__ */ t(
|
|
165
166
|
"div",
|
|
166
167
|
{
|
|
167
168
|
className: "absolute inset-0 bg-black/40 backdrop-blur-sm",
|
|
168
|
-
onClick:
|
|
169
|
+
onClick: y
|
|
169
170
|
}
|
|
170
171
|
),
|
|
171
|
-
/* @__PURE__ */
|
|
172
|
+
/* @__PURE__ */ c(
|
|
172
173
|
"div",
|
|
173
174
|
{
|
|
174
175
|
className: k(
|
|
@@ -178,57 +179,57 @@ function ge({
|
|
|
178
179
|
// Desktop: left side drawer
|
|
179
180
|
"sm:inset-y-0 sm:left-0 sm:right-auto sm:w-[420px] sm:max-w-full sm:rounded-t-none sm:rounded-r-2xl",
|
|
180
181
|
// Animation
|
|
181
|
-
|
|
182
|
-
|
|
182
|
+
M ? "translate-y-0 sm:translate-x-0" : "translate-y-full sm:translate-y-0 sm:-translate-x-full",
|
|
183
|
+
z
|
|
183
184
|
),
|
|
184
185
|
children: [
|
|
185
|
-
/* @__PURE__ */
|
|
186
|
-
/* @__PURE__ */
|
|
187
|
-
/* @__PURE__ */
|
|
188
|
-
/* @__PURE__ */
|
|
189
|
-
/* @__PURE__ */
|
|
186
|
+
/* @__PURE__ */ c("div", { className: "flex items-center justify-between border-b border-gray-200 px-4 py-3 flex-shrink-0", children: [
|
|
187
|
+
/* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
|
|
188
|
+
/* @__PURE__ */ t(Q, { className: "h-5 w-5 text-orange-500" }),
|
|
189
|
+
/* @__PURE__ */ t("span", { className: "font-semibold text-gray-900", children: L }),
|
|
190
|
+
/* @__PURE__ */ t("span", { className: "text-xs text-gray-400 bg-gray-100 rounded px-1.5 py-0.5", children: "beta" })
|
|
190
191
|
] }),
|
|
191
|
-
/* @__PURE__ */
|
|
192
|
+
/* @__PURE__ */ t(
|
|
192
193
|
"button",
|
|
193
194
|
{
|
|
194
195
|
type: "button",
|
|
195
|
-
onClick:
|
|
196
|
+
onClick: y,
|
|
196
197
|
className: "p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-colors",
|
|
197
198
|
"aria-label": "Close",
|
|
198
|
-
children: /* @__PURE__ */
|
|
199
|
+
children: /* @__PURE__ */ t(ee, { className: "h-5 w-5" })
|
|
199
200
|
}
|
|
200
201
|
)
|
|
201
202
|
] }),
|
|
202
|
-
/* @__PURE__ */
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
/* @__PURE__ */
|
|
206
|
-
/* @__PURE__ */
|
|
207
|
-
|
|
203
|
+
/* @__PURE__ */ c("div", { className: "flex-1 overflow-y-auto p-4 space-y-4 min-h-0", children: [
|
|
204
|
+
d.length === 0 && !m && /* @__PURE__ */ t("div", { className: "text-center text-gray-400 text-sm py-8", children: "Ask me anything about our products!" }),
|
|
205
|
+
d.map((e, l) => /* @__PURE__ */ t("div", { children: e.role === "user" ? /* @__PURE__ */ t("div", { className: "flex justify-end", children: /* @__PURE__ */ t("div", { className: "bg-gray-800 text-white rounded-2xl rounded-br-sm px-4 py-2 max-w-[80%] text-sm", children: e.content }) }) : /* @__PURE__ */ c("div", { className: "space-y-3", children: [
|
|
206
|
+
/* @__PURE__ */ c("div", { className: "text-sm text-gray-800 leading-relaxed", children: [
|
|
207
|
+
/* @__PURE__ */ t("span", { dangerouslySetInnerHTML: { __html: le(e.content) } }),
|
|
208
|
+
m && l === d.length - 1 && /* @__PURE__ */ t("span", { className: "inline-block w-1.5 h-4 bg-gray-400 animate-pulse ml-0.5 align-text-bottom" })
|
|
208
209
|
] }),
|
|
209
|
-
e.products && e.products.length > 0 && /* @__PURE__ */
|
|
210
|
+
e.products && e.products.length > 0 && /* @__PURE__ */ t("div", { className: "space-y-2", children: e.products.map((s) => /* @__PURE__ */ c(
|
|
210
211
|
"a",
|
|
211
212
|
{
|
|
212
213
|
href: `/product/${s.slug}`,
|
|
213
214
|
className: "flex items-center gap-3 w-full rounded-xl border border-gray-200 p-2 hover:bg-gray-50 transition-colors text-left no-underline",
|
|
214
215
|
children: [
|
|
215
|
-
s.thumbnailUrl ? /* @__PURE__ */
|
|
216
|
+
s.thumbnailUrl ? /* @__PURE__ */ t(
|
|
216
217
|
"img",
|
|
217
218
|
{
|
|
218
219
|
src: s.thumbnailUrl,
|
|
219
220
|
alt: s.name,
|
|
220
221
|
className: "h-16 w-16 rounded-lg object-cover flex-shrink-0"
|
|
221
222
|
}
|
|
222
|
-
) : /* @__PURE__ */
|
|
223
|
-
/* @__PURE__ */
|
|
224
|
-
/* @__PURE__ */
|
|
225
|
-
/* @__PURE__ */
|
|
223
|
+
) : /* @__PURE__ */ t("div", { className: "h-16 w-16 rounded-lg bg-gray-100 flex-shrink-0" }),
|
|
224
|
+
/* @__PURE__ */ c("div", { className: "min-w-0", children: [
|
|
225
|
+
/* @__PURE__ */ t("p", { className: "text-sm font-medium text-gray-900 line-clamp-2", children: s.name }),
|
|
226
|
+
/* @__PURE__ */ t("p", { className: "text-sm font-semibold text-blue-600", children: ne(s.price) })
|
|
226
227
|
] })
|
|
227
228
|
]
|
|
228
229
|
},
|
|
229
230
|
s.slug
|
|
230
231
|
)) }),
|
|
231
|
-
e.whatsapp && /* @__PURE__ */
|
|
232
|
+
e.whatsapp && /* @__PURE__ */ c(
|
|
232
233
|
"a",
|
|
233
234
|
{
|
|
234
235
|
href: ae,
|
|
@@ -236,25 +237,35 @@ function ge({
|
|
|
236
237
|
rel: "noopener noreferrer",
|
|
237
238
|
className: "inline-flex items-center gap-2 rounded-full bg-green-500 px-4 py-2 text-sm font-medium text-white hover:bg-green-600 transition-colors no-underline",
|
|
238
239
|
children: [
|
|
239
|
-
/* @__PURE__ */
|
|
240
|
+
/* @__PURE__ */ t(te, { className: "h-4 w-4" }),
|
|
240
241
|
"Chat on WhatsApp"
|
|
241
242
|
]
|
|
242
243
|
}
|
|
243
|
-
)
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
),
|
|
245
|
+
e.suggestions && e.suggestions.length > 0 && !m && l === d.length - 1 && /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2", children: e.suggestions.map((s, o) => /* @__PURE__ */ t(
|
|
246
|
+
"button",
|
|
247
|
+
{
|
|
248
|
+
type: "button",
|
|
249
|
+
onClick: () => T(s),
|
|
250
|
+
className: "rounded-full border border-gray-200 bg-gray-50 px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100 hover:border-gray-300 transition-colors text-left",
|
|
251
|
+
children: s
|
|
252
|
+
},
|
|
253
|
+
o
|
|
254
|
+
)) })
|
|
255
|
+
] }) }, l)),
|
|
256
|
+
$ && /* @__PURE__ */ t("div", { className: "rounded-lg bg-red-50 border border-red-200 p-3 text-sm text-red-700", children: $ }),
|
|
257
|
+
/* @__PURE__ */ t("div", { ref: H })
|
|
247
258
|
] }),
|
|
248
|
-
/* @__PURE__ */
|
|
249
|
-
/* @__PURE__ */
|
|
259
|
+
/* @__PURE__ */ t("div", { className: "border-t border-gray-200 p-3 flex-shrink-0", children: /* @__PURE__ */ c("form", { onSubmit: V, className: "flex items-center gap-2", children: [
|
|
260
|
+
/* @__PURE__ */ t(
|
|
250
261
|
"input",
|
|
251
262
|
{
|
|
252
|
-
ref:
|
|
263
|
+
ref: U,
|
|
253
264
|
type: "text",
|
|
254
|
-
value:
|
|
255
|
-
onChange: (e) =>
|
|
256
|
-
placeholder: `Ask ${
|
|
257
|
-
disabled:
|
|
265
|
+
value: N,
|
|
266
|
+
onChange: (e) => A(e.target.value),
|
|
267
|
+
placeholder: `Ask ${L} a question`,
|
|
268
|
+
disabled: m,
|
|
258
269
|
className: k(
|
|
259
270
|
"flex-1 rounded-full border border-gray-300 px-4 py-2.5 text-sm",
|
|
260
271
|
"focus:border-blue-400 focus:outline-none focus:ring-2 focus:ring-blue-400/30",
|
|
@@ -262,18 +273,18 @@ function ge({
|
|
|
262
273
|
)
|
|
263
274
|
}
|
|
264
275
|
),
|
|
265
|
-
/* @__PURE__ */
|
|
276
|
+
/* @__PURE__ */ t(
|
|
266
277
|
"button",
|
|
267
278
|
{
|
|
268
279
|
type: "submit",
|
|
269
|
-
disabled: !
|
|
280
|
+
disabled: !N.trim() || m,
|
|
270
281
|
className: k(
|
|
271
282
|
"flex h-10 w-10 items-center justify-center rounded-full",
|
|
272
283
|
"bg-gray-800 text-white",
|
|
273
284
|
"hover:bg-gray-700 transition-colors",
|
|
274
285
|
"disabled:opacity-40 disabled:cursor-not-allowed"
|
|
275
286
|
),
|
|
276
|
-
children:
|
|
287
|
+
children: m ? /* @__PURE__ */ t(re, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ t(se, { className: "h-4 w-4" })
|
|
277
288
|
}
|
|
278
289
|
)
|
|
279
290
|
] }) })
|
|
@@ -283,8 +294,8 @@ function ge({
|
|
|
283
294
|
]
|
|
284
295
|
}
|
|
285
296
|
);
|
|
286
|
-
return
|
|
297
|
+
return B ? F : Z(F, document.body);
|
|
287
298
|
}
|
|
288
299
|
export {
|
|
289
|
-
|
|
300
|
+
he as AssistantDrawer
|
|
290
301
|
};
|
package/dist/index220.mjs
CHANGED
|
@@ -1,31 +1,130 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
2
|
+
import { __module as b } from "./index265.mjs";
|
|
3
|
+
import S from "./index266.mjs";
|
|
4
|
+
var _;
|
|
5
|
+
function $() {
|
|
6
|
+
return _ ? b.exports : (_ = 1, (() => {
|
|
7
|
+
var O = { 154: (t, m, n) => {
|
|
8
|
+
var i = n(781), u = ["write", "end", "destroy"], f = ["resume", "pause"], l = ["data", "close"], c = Array.prototype.slice;
|
|
9
|
+
t.exports = s;
|
|
10
|
+
function r(o, a) {
|
|
11
|
+
if (o.forEach)
|
|
12
|
+
return o.forEach(a);
|
|
13
|
+
for (var e = 0; e < o.length; e++)
|
|
14
|
+
a(o[e], e);
|
|
15
|
+
}
|
|
16
|
+
function s(o, a) {
|
|
17
|
+
var e = new i(), d = !1;
|
|
18
|
+
return r(u, x), r(f, z), r(l, E), a.on("end", F), o.on("drain", function() {
|
|
19
|
+
e.emit("drain");
|
|
20
|
+
}), o.on("error", w), a.on("error", w), e.writable = o.writable, e.readable = a.readable, e;
|
|
21
|
+
function x(p) {
|
|
22
|
+
e[p] = h;
|
|
23
|
+
function h() {
|
|
24
|
+
return o[p].apply(o, arguments);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function z(p) {
|
|
28
|
+
e[p] = h;
|
|
29
|
+
function h() {
|
|
30
|
+
e.emit(p);
|
|
31
|
+
var y = a[p];
|
|
32
|
+
if (y)
|
|
33
|
+
return y.apply(a, arguments);
|
|
34
|
+
a.emit(p);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function E(p) {
|
|
38
|
+
a.on(p, h);
|
|
39
|
+
function h() {
|
|
40
|
+
var y = c.call(arguments);
|
|
41
|
+
y.unshift(p), e.emit.apply(e, y);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function F() {
|
|
45
|
+
if (!d) {
|
|
46
|
+
d = !0;
|
|
47
|
+
var p = c.call(arguments);
|
|
48
|
+
p.unshift("end"), e.emit.apply(e, p);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function w(p) {
|
|
52
|
+
e.emit("error", p);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, 349: (t, m, n) => {
|
|
56
|
+
const i = n(147), u = n(781), f = n(796), l = n(154), c = n(530), r = (s) => Object.assign({ level: 9 }, s);
|
|
57
|
+
t.exports = (s, o) => s ? c(f.gzip)(s, r(o)).then((a) => a.length).catch((a) => 0) : Promise.resolve(0), t.exports.sync = (s, o) => f.gzipSync(s, r(o)).length, t.exports.stream = (s) => {
|
|
58
|
+
const o = new u.PassThrough(), a = new u.PassThrough(), e = l(o, a);
|
|
59
|
+
let d = 0;
|
|
60
|
+
const x = f.createGzip(r(s)).on("data", (z) => {
|
|
61
|
+
d += z.length;
|
|
62
|
+
}).on("error", () => {
|
|
63
|
+
e.gzipSize = 0;
|
|
64
|
+
}).on("end", () => {
|
|
65
|
+
e.gzipSize = d, e.emit("gzip-size", d), a.end();
|
|
66
|
+
});
|
|
67
|
+
return o.pipe(x), o.pipe(a, { end: !1 }), e;
|
|
68
|
+
}, t.exports.file = (s, o) => new Promise((a, e) => {
|
|
69
|
+
const d = i.createReadStream(s);
|
|
70
|
+
d.on("error", e);
|
|
71
|
+
const x = d.pipe(t.exports.stream(o));
|
|
72
|
+
x.on("error", e), x.on("gzip-size", a);
|
|
73
|
+
}), t.exports.fileSync = (s, o) => t.exports.sync(i.readFileSync(s), o);
|
|
74
|
+
}, 530: (t) => {
|
|
75
|
+
const m = (n, i) => function(...u) {
|
|
76
|
+
const f = i.promiseModule;
|
|
77
|
+
return new f((l, c) => {
|
|
78
|
+
i.multiArgs ? u.push((...r) => {
|
|
79
|
+
i.errorFirst ? r[0] ? c(r) : (r.shift(), l(r)) : l(r);
|
|
80
|
+
}) : i.errorFirst ? u.push((r, s) => {
|
|
81
|
+
r ? c(r) : l(s);
|
|
82
|
+
}) : u.push(l), n.apply(this, u);
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
t.exports = (n, i) => {
|
|
86
|
+
i = Object.assign({ exclude: [/.+(Sync|Stream)$/], errorFirst: !0, promiseModule: Promise }, i);
|
|
87
|
+
const u = typeof n;
|
|
88
|
+
if (!(n !== null && (u === "object" || u === "function")))
|
|
89
|
+
throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${n === null ? "null" : u}\``);
|
|
90
|
+
const f = (c) => {
|
|
91
|
+
const r = (s) => typeof s == "string" ? c === s : s.test(c);
|
|
92
|
+
return i.include ? i.include.some(r) : !i.exclude.some(r);
|
|
93
|
+
};
|
|
94
|
+
let l;
|
|
95
|
+
u === "function" ? l = function(...c) {
|
|
96
|
+
return i.excludeMain ? n(...c) : m(n, i).apply(this, c);
|
|
97
|
+
} : l = Object.create(Object.getPrototypeOf(n));
|
|
98
|
+
for (const c in n) {
|
|
99
|
+
const r = n[c];
|
|
100
|
+
l[c] = typeof r == "function" && f(c) ? m(r, i) : r;
|
|
101
|
+
}
|
|
102
|
+
return l;
|
|
103
|
+
};
|
|
104
|
+
}, 147: (t) => {
|
|
105
|
+
t.exports = S;
|
|
106
|
+
}, 781: (t) => {
|
|
107
|
+
t.exports = S;
|
|
108
|
+
}, 796: (t) => {
|
|
109
|
+
t.exports = S;
|
|
110
|
+
} }, v = {};
|
|
111
|
+
function g(t) {
|
|
112
|
+
var m = v[t];
|
|
113
|
+
if (m !== void 0)
|
|
114
|
+
return m.exports;
|
|
115
|
+
var n = v[t] = { exports: {} }, i = !0;
|
|
116
|
+
try {
|
|
117
|
+
O[t](n, n.exports, g), i = !1;
|
|
118
|
+
} finally {
|
|
119
|
+
i && delete v[t];
|
|
120
|
+
}
|
|
121
|
+
return n.exports;
|
|
122
|
+
}
|
|
123
|
+
typeof g < "u" && (g.ab = __dirname + "/");
|
|
124
|
+
var j = g(349);
|
|
125
|
+
b.exports = j;
|
|
126
|
+
})(), b.exports);
|
|
127
|
+
}
|
|
29
128
|
export {
|
|
30
|
-
|
|
129
|
+
$ as __require
|
|
31
130
|
};
|
package/dist/index221.mjs
CHANGED