@gengage/assistant-fe 0.5.7 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agentic/adaptor/create-adaptor.d.ts +19 -0
- package/dist/agentic/adaptor/fetch-bridge.d.ts +11 -0
- package/dist/agentic/adaptor/mount.d.ts +38 -0
- package/dist/agentic/context/chat-context.d.ts +15 -0
- package/dist/agentic/context/context-store.d.ts +20 -0
- package/dist/agentic/context/persistence.d.ts +12 -0
- package/dist/agentic/events/builders.d.ts +10 -0
- package/dist/agentic/events/error-taxonomy.d.ts +27 -0
- package/dist/agentic/events/product-normalize.d.ts +47 -0
- package/dist/agentic/events/ui-specs.d.ts +37 -0
- package/dist/agentic/flow/beauty-consulting-turn.d.ts +1 -0
- package/dist/agentic/flow/create-flow.d.ts +2 -0
- package/dist/agentic/flow/dispatch.d.ts +3 -0
- package/dist/agentic/index.d.ts +18 -0
- package/dist/agentic/index.js +620 -0
- package/dist/agentic/types.d.ts +212 -0
- package/dist/agentic/util/assistant-host.d.ts +11 -0
- package/dist/agentic/util/be-url.d.ts +4 -0
- package/dist/agentic/util/browser-memory.d.ts +13 -0
- package/dist/agentic/util/browser-tools.d.ts +31 -0
- package/dist/agentic/util/lazy-runtime-loader.d.ts +9 -0
- package/dist/agentic/util/request-text.d.ts +3 -0
- package/dist/agentic/util/time.d.ts +2 -0
- package/dist/agentic/worker/be-client.d.ts +15 -0
- package/dist/agentic/worker/entry.d.ts +2 -0
- package/dist/agentic/worker/flow-runner.d.ts +24 -0
- package/dist/agentic/worker/jwt-mint.d.ts +21 -0
- package/dist/agentic/worker/rpc.d.ts +24 -0
- package/dist/agentic/worker/tool-bridge.d.ts +2 -0
- package/dist/agentic/worker.d.ts +16 -0
- package/dist/agentic/worker.js +119 -0
- package/dist/agentic.iife.js +5 -0
- package/dist/{api-paths-CwzwbgQZ.js → api-paths-DJFF9RuZ.js} +1 -1
- package/dist/beauty-consulting-turn-BmPXbkQg.js +1019 -0
- package/dist/chat/api.d.ts +17 -0
- package/dist/chat/assistant-mode.d.ts +20 -0
- package/dist/chat/attachment-utils.d.ts +9 -0
- package/dist/chat/catalog.d.ts +455 -0
- package/dist/chat/chat-presentation-state.d.ts +53 -0
- package/dist/chat/components/AIGroupingCards.d.ts +15 -0
- package/dist/chat/components/AISuggestedSearchCards.d.ts +13 -0
- package/dist/chat/components/AITopPicks.d.ts +9 -0
- package/dist/chat/components/BeautyPhotoStep.d.ts +31 -0
- package/dist/chat/components/CategoriesContainer.d.ts +11 -0
- package/dist/chat/components/ChatDrawer.d.ts +362 -0
- package/dist/chat/components/ChoicePrompter.d.ts +21 -0
- package/dist/chat/components/ComparisonTable.d.ts +66 -0
- package/dist/chat/components/ConsultingStylePicker.d.ts +40 -0
- package/dist/chat/components/FloatingComparisonButton.d.ts +7 -0
- package/dist/chat/components/FloatingLauncher.d.ts +79 -0
- package/dist/chat/components/GroundingReviewCard.d.ts +11 -0
- package/dist/chat/components/HandoffNotice.d.ts +9 -0
- package/dist/chat/components/KvkkBanner.d.ts +6 -0
- package/dist/chat/components/Launcher.d.ts +28 -0
- package/dist/chat/components/PanelRestoreCard.d.ts +4 -0
- package/dist/chat/components/PanelTopBar.d.ts +32 -0
- package/dist/chat/components/PhotoAnalysisCard.d.ts +27 -0
- package/dist/chat/components/ProductSummaryCard.d.ts +12 -0
- package/dist/chat/components/ProsAndCons.d.ts +8 -0
- package/dist/chat/components/ReviewHighlights.d.ts +16 -0
- package/dist/chat/components/actionClassifier.d.ts +12 -0
- package/dist/chat/components/product-price-layout.d.ts +17 -0
- package/dist/chat/components/productMentionLinker.d.ts +26 -0
- package/dist/chat/components/renderUISpec.d.ts +15 -0
- package/dist/chat/components/typewriter.d.ts +24 -0
- package/dist/chat/extendedModeManager.d.ts +32 -0
- package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +38 -0
- package/dist/chat/features/beauty-consulting/drawer-extensions.d.ts +22 -0
- package/dist/chat/features/beauty-consulting/mode-controller.d.ts +59 -0
- package/dist/chat/features/beauty-consulting/registry.d.ts +9 -0
- package/dist/chat/features/beauty-consulting/stream-handler.d.ts +45 -0
- package/dist/chat/history-storage.d.ts +85 -0
- package/dist/chat/index.d.ts +6 -0
- package/dist/chat/kvkk.d.ts +20 -0
- package/dist/chat/locales/en.d.ts +2 -0
- package/dist/chat/locales/index.d.ts +5 -0
- package/dist/chat/locales/tr.d.ts +2 -0
- package/dist/chat/panel-manager.d.ts +142 -0
- package/dist/chat/runtime.d.ts +416 -0
- package/dist/chat/session-persistence.d.ts +73 -0
- package/dist/chat/stream-error-display.d.ts +6 -0
- package/dist/chat/types.d.ts +547 -0
- package/dist/chat/utils/chat-presentation-debug.d.ts +18 -0
- package/dist/chat/utils/get-chat-scroll-element.d.ts +10 -0
- package/dist/chat/utils/ui.d.ts +10 -0
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +12 -12
- package/dist/chat.js +1 -1
- package/dist/common/action-router.d.ts +26 -0
- package/dist/common/api-paths.d.ts +23 -0
- package/dist/common/client.d.ts +27 -0
- package/dist/common/communication-bridge.d.ts +51 -0
- package/dist/common/config-constants.d.ts +1 -0
- package/dist/common/config-schema.d.ts +54 -0
- package/dist/common/connection-warning.d.ts +8 -0
- package/dist/common/consulting-sources.d.ts +8 -0
- package/dist/common/context.d.ts +64 -0
- package/dist/common/css-escape.d.ts +1 -0
- package/dist/common/customization-factories.d.ts +59 -0
- package/dist/common/debug.d.ts +13 -0
- package/dist/common/events.d.ts +55 -0
- package/dist/common/fastIntent.d.ts +1 -0
- package/dist/common/find-similar-payload.d.ts +3 -0
- package/dist/common/ga-datalayer.d.ts +80 -0
- package/dist/common/global-error-toast.d.ts +6 -0
- package/dist/common/index.d.ts +47 -0
- package/dist/common/indexed-db.d.ts +89 -0
- package/dist/common/locale.d.ts +1 -0
- package/dist/common/native-webview.d.ts +60 -0
- package/dist/common/navigation.d.ts +1 -0
- package/dist/common/overlay.d.ts +172 -0
- package/dist/common/page-detect.d.ts +36 -0
- package/dist/common/pill-launcher.d.ts +51 -0
- package/dist/common/preflight.d.ts +13 -0
- package/dist/common/price-formatter.d.ts +35 -0
- package/dist/common/product-utils.d.ts +35 -0
- package/dist/common/protocol-adapter.d.ts +108 -0
- package/dist/common/renderer/dom.d.ts +3 -0
- package/dist/common/renderer/index.d.ts +4 -0
- package/dist/common/renderer/overrides.d.ts +23 -0
- package/dist/common/renderer/registry.d.ts +2 -0
- package/dist/common/renderer/types.d.ts +19 -0
- package/dist/common/safe-html.d.ts +22 -0
- package/dist/common/sdk-version.d.ts +3 -0
- package/dist/common/streaming.d.ts +52 -0
- package/dist/common/suggested-search-keywords.d.ts +18 -0
- package/dist/common/theme-utils.d.ts +15 -0
- package/dist/common/transport.d.ts +75 -0
- package/dist/common/tts-player.d.ts +13 -0
- package/dist/common/types.d.ts +379 -0
- package/dist/common/ui-theme.d.ts +9 -0
- package/dist/common/uuidv7.d.ts +7 -0
- package/dist/common/voice-input.d.ts +74 -0
- package/dist/common/widget-base.d.ts +82 -0
- package/dist/{common-KpJP1YwP.js → common-BydCGBNn.js} +90 -139
- package/dist/common.js +41 -41
- package/dist/{connection-warning-B5T_1oBn.js → connection-warning-Pbvk3J8k.js} +1 -1
- package/dist/{fastIntent--Ukm2nOh.js → fastIntent-CkYN2UOl.js} +199 -137
- package/dist/index.d.ts +25 -0
- package/dist/index.js +50 -50
- package/dist/native/index.d.ts +2 -0
- package/dist/{native-webview-qfjm4SHx.js → native-webview-JDC1vtde.js} +1 -1
- package/dist/native.iife.js +14 -14
- package/dist/native.js +1 -1
- package/dist/{overlay-CP5A0Hhf.js → overlay-BetAvpVZ.js} +19 -19
- package/dist/overlay.d.ts +4 -0
- package/dist/overlay.js +1 -1
- package/dist/qna/api.d.ts +23 -0
- package/dist/qna/catalog.d.ts +60 -0
- package/dist/qna/components/ButtonRow.d.ts +15 -0
- package/dist/qna/components/TextInput.d.ts +11 -0
- package/dist/qna/components/renderUISpec.d.ts +7 -0
- package/dist/qna/index.d.ts +3 -0
- package/dist/qna/locales/en.d.ts +2 -0
- package/dist/qna/locales/index.d.ts +4 -0
- package/dist/qna/locales/tr.d.ts +2 -0
- package/dist/qna/normalize-ui-specs.d.ts +15 -0
- package/dist/qna/runtime.d.ts +73 -0
- package/dist/qna/types.d.ts +98 -0
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +1 -1
- package/dist/qna.js +1 -1
- package/dist/{runtime-BPyXOyyp.js → runtime-DbZO1qG5.js} +3 -3
- package/dist/{runtime-G3idwfkM.js → runtime-OpNoB3cu.js} +894 -853
- package/dist/{runtime-C3yOvNFK.js → runtime-iCLkUjI3.js} +3 -3
- package/dist/simbut/index.d.ts +31 -0
- package/dist/simbut/locales.d.ts +3 -0
- package/dist/simbut/types.d.ts +43 -0
- package/dist/{simbut-CiknJI6-.js → simbut-FyXolmZY.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/simrel/api.d.ts +25 -0
- package/dist/simrel/catalog.d.ts +77 -0
- package/dist/simrel/components/GroupTabs.d.ts +24 -0
- package/dist/simrel/components/ProductCard.d.ts +19 -0
- package/dist/simrel/components/ProductGrid.d.ts +17 -0
- package/dist/simrel/components/renderUISpec.d.ts +7 -0
- package/dist/simrel/index.d.ts +5 -0
- package/dist/simrel/locales/en.d.ts +2 -0
- package/dist/simrel/locales/index.d.ts +4 -0
- package/dist/simrel/locales/tr.d.ts +2 -0
- package/dist/simrel/renderers/default.d.ts +41 -0
- package/dist/simrel/runtime.d.ts +68 -0
- package/dist/simrel/types.d.ts +145 -0
- package/dist/{simrel-C1YN71aW.js → simrel-CbLe5OAr.js} +1 -1
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.iife.js +1 -1
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-UmvgIqDk.js → widget-base-COP8QwU3.js} +1 -1
- package/package.json +20 -6
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
import { C as L, D as j, M as q, O as le, S as de, T as O, _ as fe, a as ge, b as $, c as pe, d as C, f as D, g as me, h as we, i as he, j as M, k as ye, l as be, m as Se, n as Ee, o as Ae, p as Re, r as ve, s as Te, t as Ue, u as xe, v as Pe, w as _e, x as Le, y as je } from "../beauty-consulting-turn-BmPXbkQg.js";
|
|
2
|
+
function B({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: c, defaultLocale: i, tools: g = {}, beacon: w }) {
|
|
3
|
+
let m = 1;
|
|
4
|
+
const d = /* @__PURE__ */ new Map();
|
|
5
|
+
return M({
|
|
6
|
+
worker: t,
|
|
7
|
+
tools: g,
|
|
8
|
+
beacon: (u) => w?.({
|
|
9
|
+
...u,
|
|
10
|
+
accountId: u.accountId || e
|
|
11
|
+
}),
|
|
12
|
+
memory: sessionStorage
|
|
13
|
+
}), t.addEventListener("message", (u) => {
|
|
14
|
+
const a = u.data || {}, s = typeof a.id == "number" ? a.id : null;
|
|
15
|
+
if (s == null) return;
|
|
16
|
+
const l = d.get(s);
|
|
17
|
+
if (l) {
|
|
18
|
+
if (a.type === "event" && a.event) {
|
|
19
|
+
b(l, a.event);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (a.type === "error") {
|
|
23
|
+
l.onError(new Error(a.message || "Agent worker failed")), d.delete(s);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
a.type === "end" && d.delete(s);
|
|
27
|
+
}
|
|
28
|
+
}), (u, a, s) => {
|
|
29
|
+
const l = m++;
|
|
30
|
+
d.set(l, a);
|
|
31
|
+
const p = () => {
|
|
32
|
+
d.delete(l), t.postMessage({
|
|
33
|
+
id: l,
|
|
34
|
+
type: "abort"
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
if (s.aborted) {
|
|
38
|
+
p();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
s.addEventListener("abort", p, { once: !0 }), t.postMessage({
|
|
42
|
+
id: l,
|
|
43
|
+
type: "invoke",
|
|
44
|
+
accountId: e,
|
|
45
|
+
beUrl: r,
|
|
46
|
+
devJwtSecret: n,
|
|
47
|
+
tokenBrokerUrl: o,
|
|
48
|
+
tokenBrokerAudience: c,
|
|
49
|
+
defaultLocale: i,
|
|
50
|
+
request: u,
|
|
51
|
+
parentUrl: window.location.href
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function F({ accountId: e, accountModule: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: c, defaultLocale: i, tools: g = {}, beacon: w }) {
|
|
56
|
+
let m = null;
|
|
57
|
+
const d = k({
|
|
58
|
+
accountId: e,
|
|
59
|
+
tools: g,
|
|
60
|
+
beacon: w
|
|
61
|
+
}), u = C(d), a = O({
|
|
62
|
+
accountId: e,
|
|
63
|
+
...n ? { devJwtSecret: n } : {},
|
|
64
|
+
...o ? { tokenBrokerUrl: o } : {},
|
|
65
|
+
...c ? { tokenBrokerAudience: c } : {}
|
|
66
|
+
});
|
|
67
|
+
return async (s, l, p) => {
|
|
68
|
+
m ||= new j({
|
|
69
|
+
accountId: e,
|
|
70
|
+
locale: s?.locale || i,
|
|
71
|
+
parentUrl: window.location.href,
|
|
72
|
+
rpc: d
|
|
73
|
+
});
|
|
74
|
+
try {
|
|
75
|
+
await D({
|
|
76
|
+
request: s || {},
|
|
77
|
+
accountModule: {
|
|
78
|
+
...t,
|
|
79
|
+
accountId: e
|
|
80
|
+
},
|
|
81
|
+
contextStore: m,
|
|
82
|
+
beClient: { invoke({ op: f, input: y, signal: h }) {
|
|
83
|
+
return $({
|
|
84
|
+
beUrl: r,
|
|
85
|
+
accountId: e,
|
|
86
|
+
jwtProvider: a,
|
|
87
|
+
parentUrl: window.location.href,
|
|
88
|
+
op: f,
|
|
89
|
+
input: y,
|
|
90
|
+
...h ? { signal: h } : {}
|
|
91
|
+
});
|
|
92
|
+
} },
|
|
93
|
+
toolBridge: u,
|
|
94
|
+
emit: (f) => b(l, f),
|
|
95
|
+
rpc: d,
|
|
96
|
+
signal: p
|
|
97
|
+
});
|
|
98
|
+
} catch (f) {
|
|
99
|
+
p?.aborted || (b(l, L(f)), l.onDone());
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function k({ accountId: e, tools: t, beacon: r }) {
|
|
104
|
+
const n = (o) => r?.({
|
|
105
|
+
...o,
|
|
106
|
+
accountId: o.accountId || e
|
|
107
|
+
});
|
|
108
|
+
return ((o, c) => q(o, c, {
|
|
109
|
+
tools: t,
|
|
110
|
+
beacon: n,
|
|
111
|
+
memory: sessionStorage
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
function b(e, t) {
|
|
115
|
+
switch (t?.type) {
|
|
116
|
+
case "text_chunk": {
|
|
117
|
+
const r = t;
|
|
118
|
+
e.onTextChunk(r.content || "", r.final === !0, r);
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case "ui_spec": {
|
|
122
|
+
const r = t;
|
|
123
|
+
e.onUISpec(r.spec, r.widget, r.panelHint, r.clearPanel === !0);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case "action":
|
|
127
|
+
e.onAction(t);
|
|
128
|
+
break;
|
|
129
|
+
case "metadata":
|
|
130
|
+
e.onMetadata(t);
|
|
131
|
+
break;
|
|
132
|
+
case "error":
|
|
133
|
+
e.onError(N(t));
|
|
134
|
+
break;
|
|
135
|
+
case "done":
|
|
136
|
+
e.onDone();
|
|
137
|
+
break;
|
|
138
|
+
default:
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function N(e) {
|
|
143
|
+
const t = new Error(e.message || e.code || "Agent error");
|
|
144
|
+
return e.code && (t.code = e.code), t;
|
|
145
|
+
}
|
|
146
|
+
var v = "__gengageAgentFetchBridge";
|
|
147
|
+
function qe({ accountId: e, streamTransport: t }) {
|
|
148
|
+
if (!e) throw new Error("accountId is required.");
|
|
149
|
+
if (typeof t != "function") throw new Error("streamTransport is required.");
|
|
150
|
+
const r = G(), n = `https://gengage-injector.invalid/${encodeURIComponent(e)}`, o = `${n}/chat/process_action`;
|
|
151
|
+
return r.routes.set(o, { streamTransport: t }), {
|
|
152
|
+
middlewareUrl: n,
|
|
153
|
+
stop() {
|
|
154
|
+
r.routes.delete(o);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function G() {
|
|
159
|
+
const e = window, t = e[v];
|
|
160
|
+
if (t) return t;
|
|
161
|
+
const r = e.fetch.bind(e), n = {
|
|
162
|
+
routes: /* @__PURE__ */ new Map(),
|
|
163
|
+
originalFetch: r
|
|
164
|
+
};
|
|
165
|
+
return e.fetch = (o, c) => {
|
|
166
|
+
const i = I(o), g = n.routes.get(i);
|
|
167
|
+
return g ? V(g, o, c) : r(o, c);
|
|
168
|
+
}, e[v] = n, n;
|
|
169
|
+
}
|
|
170
|
+
function I(e) {
|
|
171
|
+
return typeof e == "string" ? e : e instanceof URL ? e.href : e?.url || "";
|
|
172
|
+
}
|
|
173
|
+
function J(e, t) {
|
|
174
|
+
if (t?.signal) return t.signal;
|
|
175
|
+
if (typeof Request < "u" && e instanceof Request) return e.signal;
|
|
176
|
+
}
|
|
177
|
+
function W(e, t) {
|
|
178
|
+
return t?.body !== void 0 && t?.body !== null ? t.body : typeof Request < "u" && e instanceof Request ? e.clone().text() : null;
|
|
179
|
+
}
|
|
180
|
+
async function H(e, t) {
|
|
181
|
+
const r = W(e, t);
|
|
182
|
+
if (r instanceof FormData) {
|
|
183
|
+
const o = r.get("request"), c = r.get("attachment");
|
|
184
|
+
return {
|
|
185
|
+
request: JSON.parse(String(o || "{}")),
|
|
186
|
+
...c instanceof File ? { attachment: c } : {}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const n = await Promise.resolve(r);
|
|
190
|
+
return typeof n == "string" ? { request: JSON.parse(n || "{}") } : { request: {} };
|
|
191
|
+
}
|
|
192
|
+
function V(e, t, r) {
|
|
193
|
+
const n = new TextEncoder(), o = new AbortController(), c = J(t, r);
|
|
194
|
+
let i = !1, g = null;
|
|
195
|
+
const w = new ReadableStream({
|
|
196
|
+
async start(m) {
|
|
197
|
+
const d = (s) => {
|
|
198
|
+
i || m.enqueue(n.encode(`${JSON.stringify(s)}
|
|
199
|
+
`));
|
|
200
|
+
}, u = () => {
|
|
201
|
+
i || (i = !0, g?.(), m.close());
|
|
202
|
+
}, a = (s) => {
|
|
203
|
+
d({
|
|
204
|
+
type: "error",
|
|
205
|
+
code: s?.code || "agent_bridge_error",
|
|
206
|
+
message: s instanceof Error ? s.message : String(s)
|
|
207
|
+
}), d({ type: "done" }), u();
|
|
208
|
+
};
|
|
209
|
+
if (c) {
|
|
210
|
+
const s = () => {
|
|
211
|
+
o.abort(), i || (i = !0, g?.(), m.error(new DOMException("Aborted", "AbortError")));
|
|
212
|
+
};
|
|
213
|
+
if (c.aborted) {
|
|
214
|
+
s();
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
c.addEventListener("abort", s, { once: !0 }), g = () => c.removeEventListener("abort", s);
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
const { request: s, attachment: l } = await H(t, r), p = e.streamTransport(s, {
|
|
221
|
+
onTextChunk: (f, y, h = {}) => d({
|
|
222
|
+
type: "text_chunk",
|
|
223
|
+
content: f,
|
|
224
|
+
final: y === !0,
|
|
225
|
+
...h
|
|
226
|
+
}),
|
|
227
|
+
onUISpec: (f, y, h, _) => d({
|
|
228
|
+
type: "ui_spec",
|
|
229
|
+
spec: f,
|
|
230
|
+
widget: y,
|
|
231
|
+
...h ? { panelHint: h } : {},
|
|
232
|
+
..._ ? { clearPanel: !0 } : {}
|
|
233
|
+
}),
|
|
234
|
+
onAction: (f) => {
|
|
235
|
+
d(f?.type === "action" ? f : {
|
|
236
|
+
type: "action",
|
|
237
|
+
action: f
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
onMetadata: (f) => {
|
|
241
|
+
d(f?.type === "metadata" ? f : {
|
|
242
|
+
type: "metadata",
|
|
243
|
+
...f
|
|
244
|
+
});
|
|
245
|
+
},
|
|
246
|
+
onError: a,
|
|
247
|
+
onDone: () => {
|
|
248
|
+
d({ type: "done" }), u();
|
|
249
|
+
}
|
|
250
|
+
}, o.signal, l);
|
|
251
|
+
Y(p) && (await p, o.signal.aborted || (d({ type: "done" }), u()));
|
|
252
|
+
} catch (s) {
|
|
253
|
+
o.signal.aborted || a(s);
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
cancel() {
|
|
257
|
+
o.abort(), g?.(), i = !0;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
return Promise.resolve(new Response(w, {
|
|
261
|
+
status: 200,
|
|
262
|
+
headers: { "Content-Type": "application/x-ndjson" }
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
265
|
+
function Y(e) {
|
|
266
|
+
return e !== null && (typeof e == "object" || typeof e == "function") && typeof e.then == "function";
|
|
267
|
+
}
|
|
268
|
+
function Oe({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenBrokerAudience: o, workerUrl: c, defaultLocale: i = "en-GB", accountModule: g, tools: w = {}, beacon: m, allowBlobWorker: d = !1 }) {
|
|
269
|
+
if (!e) throw new Error("accountId is required.");
|
|
270
|
+
const u = window, a = u.GengageAssistantInjector || (u.GengageAssistantInjector = {}), s = a[e] || (a[e] = {});
|
|
271
|
+
if (s.agentController) return s.agentController;
|
|
272
|
+
const l = P(c) || d ? z(c, `gengage-${e}-agent`, { allowBlobWorker: d }) : null;
|
|
273
|
+
s.streamTransport = l ? B({
|
|
274
|
+
accountId: e,
|
|
275
|
+
worker: l.worker,
|
|
276
|
+
beUrl: t,
|
|
277
|
+
...r ? { devJwtSecret: r } : {},
|
|
278
|
+
...n ? { tokenBrokerUrl: n } : {},
|
|
279
|
+
...o ? { tokenBrokerAudience: o } : {},
|
|
280
|
+
defaultLocale: i,
|
|
281
|
+
tools: w,
|
|
282
|
+
...m ? { beacon: m } : {}
|
|
283
|
+
}) : F({
|
|
284
|
+
accountId: e,
|
|
285
|
+
accountModule: g,
|
|
286
|
+
beUrl: t,
|
|
287
|
+
...r ? { devJwtSecret: r } : {},
|
|
288
|
+
...n ? { tokenBrokerUrl: n } : {},
|
|
289
|
+
...o ? { tokenBrokerAudience: o } : {},
|
|
290
|
+
defaultLocale: i,
|
|
291
|
+
tools: w,
|
|
292
|
+
...m ? { beacon: m } : {}
|
|
293
|
+
});
|
|
294
|
+
const p = {
|
|
295
|
+
type: "agent",
|
|
296
|
+
stop() {
|
|
297
|
+
delete s.streamTransport, l?.worker.terminate(), l?.cleanup(), delete s.agentController;
|
|
298
|
+
},
|
|
299
|
+
diagnostics() {
|
|
300
|
+
return {
|
|
301
|
+
accountId: e,
|
|
302
|
+
beUrl: t,
|
|
303
|
+
workerUrl: c,
|
|
304
|
+
mounted: !0,
|
|
305
|
+
transport: l ? "worker" : "main-thread",
|
|
306
|
+
flows: Object.keys(g?.flows || {})
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
return s.agentController = p, p;
|
|
311
|
+
}
|
|
312
|
+
function P(e) {
|
|
313
|
+
const t = new URL(e, window.location.href);
|
|
314
|
+
return t.origin === window.location.origin || t.protocol === "blob:";
|
|
315
|
+
}
|
|
316
|
+
function z(e, t, r = {}) {
|
|
317
|
+
const n = new URL(e, window.location.href);
|
|
318
|
+
if (P(e)) return {
|
|
319
|
+
worker: new Worker(n.href, {
|
|
320
|
+
type: "module",
|
|
321
|
+
name: t
|
|
322
|
+
}),
|
|
323
|
+
cleanup() {
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
if (!r.allowBlobWorker) throw new Error("Cross-origin agent workers require allowBlobWorker=true or a same-origin workerUrl.");
|
|
327
|
+
const o = new Blob([`import ${JSON.stringify(n.href)};
|
|
328
|
+
`], { type: "text/javascript" }), c = URL.createObjectURL(o);
|
|
329
|
+
try {
|
|
330
|
+
return {
|
|
331
|
+
worker: new Worker(c, {
|
|
332
|
+
type: "module",
|
|
333
|
+
name: t
|
|
334
|
+
}),
|
|
335
|
+
cleanup() {
|
|
336
|
+
URL.revokeObjectURL(c);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
} catch (i) {
|
|
340
|
+
throw URL.revokeObjectURL(c), i;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function K(e) {
|
|
344
|
+
const t = (e?.chat || e?._chat)?.root || e?._chat?.root;
|
|
345
|
+
return t ? t.getRootNode?.()?.host || t : Array.from(document.querySelectorAll("*")).find((r) => r.shadowRoot?.querySelector?.(".gengage-chat-root, .gengage-chat-launcher-container"));
|
|
346
|
+
}
|
|
347
|
+
function $e(e, t) {
|
|
348
|
+
const r = K(e);
|
|
349
|
+
r?.style && (t ? r.style.removeProperty("display") : r.style.setProperty("display", "none", "important")), t || (e?.chat || e?._chat)?.close?.();
|
|
350
|
+
}
|
|
351
|
+
var Q = "https://be.gengage.ai", X = "nd_be_url";
|
|
352
|
+
function Ce(e = {}, t = Q) {
|
|
353
|
+
return Z() || e.beUrl || t;
|
|
354
|
+
}
|
|
355
|
+
function Z() {
|
|
356
|
+
try {
|
|
357
|
+
const e = new URLSearchParams(window.location.search).get(X)?.trim();
|
|
358
|
+
if (!e) return null;
|
|
359
|
+
const t = new URL(e);
|
|
360
|
+
return t.protocol !== "https:" && t.protocol !== "http:" ? null : t.toString().replace(/\/+$/u, "");
|
|
361
|
+
} catch {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
var ee = "entries", te = 1, re = {
|
|
366
|
+
volatile: "Hot per-page state and sensitive request context.",
|
|
367
|
+
session: "Current-visit tool context without raw tokens or PII-heavy payloads.",
|
|
368
|
+
local: "Small, non-sensitive capability facts or user preferences.",
|
|
369
|
+
indexedDb: "Larger product/search payload caches with short TTLs."
|
|
370
|
+
}, T = /* @__PURE__ */ new Map();
|
|
371
|
+
function S() {
|
|
372
|
+
return Date.now();
|
|
373
|
+
}
|
|
374
|
+
function A(e) {
|
|
375
|
+
return e?.expiresAt != null && e.expiresAt <= S();
|
|
376
|
+
}
|
|
377
|
+
function R(e, t) {
|
|
378
|
+
return {
|
|
379
|
+
value: e,
|
|
380
|
+
createdAt: S(),
|
|
381
|
+
expiresAt: t ? S() + t : null
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
function ne(e, t, r) {
|
|
385
|
+
try {
|
|
386
|
+
const n = e.getItem(`${t}${r}`);
|
|
387
|
+
if (!n) return null;
|
|
388
|
+
const o = JSON.parse(n);
|
|
389
|
+
return A(o) ? (e.removeItem(`${t}${r}`), null) : o.value;
|
|
390
|
+
} catch {
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
function oe(e, t, r, n, o) {
|
|
395
|
+
try {
|
|
396
|
+
return e.setItem(`${t}${r}`, JSON.stringify(R(n, o))), !0;
|
|
397
|
+
} catch {
|
|
398
|
+
return !1;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
function se(e, t, r) {
|
|
402
|
+
try {
|
|
403
|
+
e.removeItem(`${t}${r}`);
|
|
404
|
+
} catch {
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function U(e) {
|
|
408
|
+
try {
|
|
409
|
+
return window[e];
|
|
410
|
+
} catch {
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function x(e, t) {
|
|
415
|
+
return e ? {
|
|
416
|
+
get: (r) => ne(e, t, r),
|
|
417
|
+
set: (r, n, o = {}) => oe(e, t, r, n, o.ttlMs),
|
|
418
|
+
remove: (r) => se(e, t, r)
|
|
419
|
+
} : {
|
|
420
|
+
get: () => null,
|
|
421
|
+
set: () => !1,
|
|
422
|
+
remove: () => {
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function E(e) {
|
|
427
|
+
if (Array.isArray(e)) return `[${e.map(E).join(",")}]`;
|
|
428
|
+
if (e && typeof e == "object") {
|
|
429
|
+
const t = e;
|
|
430
|
+
return `{${Object.keys(t).sort().map((r) => `${JSON.stringify(r)}:${E(t[r])}`).join(",")}}`;
|
|
431
|
+
}
|
|
432
|
+
return JSON.stringify(e);
|
|
433
|
+
}
|
|
434
|
+
function ae(e) {
|
|
435
|
+
let t = 2166136261;
|
|
436
|
+
const r = E(e);
|
|
437
|
+
for (let n = 0; n < r.length; n += 1)
|
|
438
|
+
t ^= r.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
439
|
+
return (t >>> 0).toString(36);
|
|
440
|
+
}
|
|
441
|
+
function ie(e, t) {
|
|
442
|
+
const r = t.dbName || `gengage-${e}`, n = t.dbStore || ee, o = t.dbVersion || te, c = /* @__PURE__ */ new Map();
|
|
443
|
+
let i = null;
|
|
444
|
+
const g = () => "indexedDB" in window ? i || (i = new Promise((u) => {
|
|
445
|
+
const a = indexedDB.open(r, o);
|
|
446
|
+
a.onupgradeneeded = () => {
|
|
447
|
+
a.result.createObjectStore(n, { keyPath: "key" });
|
|
448
|
+
}, a.onsuccess = () => u(a.result), a.onerror = () => u(null), a.onblocked = () => u(null);
|
|
449
|
+
}), i) : Promise.resolve(null);
|
|
450
|
+
return {
|
|
451
|
+
volatileEntries: c,
|
|
452
|
+
idbGet: async (u) => {
|
|
453
|
+
const a = await g();
|
|
454
|
+
return a ? new Promise((s) => {
|
|
455
|
+
const l = a.transaction(n, "readwrite").objectStore(n), p = l.get(u);
|
|
456
|
+
p.onsuccess = () => {
|
|
457
|
+
const f = p.result;
|
|
458
|
+
if (!f || A(f)) {
|
|
459
|
+
f && l.delete(u), s(null);
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
s(f.value);
|
|
463
|
+
}, p.onerror = () => s(null);
|
|
464
|
+
}) : null;
|
|
465
|
+
},
|
|
466
|
+
idbSet: async (u, a, s = {}) => {
|
|
467
|
+
const l = await g();
|
|
468
|
+
return l ? new Promise((p) => {
|
|
469
|
+
const f = l.transaction(n, "readwrite");
|
|
470
|
+
f.oncomplete = () => p(!0), f.onerror = () => p(!1), f.objectStore(n).put({
|
|
471
|
+
key: u,
|
|
472
|
+
...R(a, s.ttlMs)
|
|
473
|
+
});
|
|
474
|
+
}) : !1;
|
|
475
|
+
},
|
|
476
|
+
idbRemove: async (u) => {
|
|
477
|
+
const a = await g();
|
|
478
|
+
a && a.transaction(n, "readwrite").objectStore(n).delete(u);
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
function De(e, t = {}) {
|
|
483
|
+
const r = window, n = r.gengage || (r.gengage = {}), o = n.memory || (n.memory = {}), c = o[e];
|
|
484
|
+
if (c) return c;
|
|
485
|
+
const i = T.get(e) || ie(e, t);
|
|
486
|
+
T.set(e, i);
|
|
487
|
+
const g = t.sessionPrefix || `gengage:${e}:session:`, w = t.localPrefix || `gengage:${e}:local:`, d = {
|
|
488
|
+
get: (s) => {
|
|
489
|
+
const l = i.volatileEntries.get(s);
|
|
490
|
+
return l ? A(l) ? (i.volatileEntries.delete(s), null) : l.value : null;
|
|
491
|
+
},
|
|
492
|
+
set: (s, l, p = {}) => (i.volatileEntries.set(s, R(l, p.ttlMs)), !0),
|
|
493
|
+
remove: (s) => {
|
|
494
|
+
i.volatileEntries.delete(s);
|
|
495
|
+
},
|
|
496
|
+
clear: () => i.volatileEntries.clear()
|
|
497
|
+
}, u = {
|
|
498
|
+
get: i.idbGet,
|
|
499
|
+
set: i.idbSet,
|
|
500
|
+
remove: i.idbRemove
|
|
501
|
+
}, a = {
|
|
502
|
+
accountId: e,
|
|
503
|
+
volatile: d,
|
|
504
|
+
session: x(U("sessionStorage"), g),
|
|
505
|
+
local: x(U("localStorage"), w),
|
|
506
|
+
indexedDb: u,
|
|
507
|
+
stableKey: ae,
|
|
508
|
+
policy: {
|
|
509
|
+
...re,
|
|
510
|
+
...t.policy || {}
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
o[e] = a;
|
|
514
|
+
for (const s of t.aliases || []) o[s] = a;
|
|
515
|
+
return a;
|
|
516
|
+
}
|
|
517
|
+
var ce = [
|
|
518
|
+
"addToCart",
|
|
519
|
+
"search",
|
|
520
|
+
"searchKeyword",
|
|
521
|
+
"facetedSearch",
|
|
522
|
+
"searchGiftOptions",
|
|
523
|
+
"similaritySearch"
|
|
524
|
+
];
|
|
525
|
+
function Me(e, t, r = {}) {
|
|
526
|
+
const n = window, o = n.gengage || (n.gengage = {}), c = o.tools || (o.tools = {});
|
|
527
|
+
c[e] = t;
|
|
528
|
+
for (const i of r.accountAliases || []) c[i] = t;
|
|
529
|
+
if (r.exposeStandardAliases !== !1) for (const i of r.standardAliases || ce) {
|
|
530
|
+
const g = t[i];
|
|
531
|
+
typeof g == "function" && (c[i] = c[i] || g);
|
|
532
|
+
}
|
|
533
|
+
return t;
|
|
534
|
+
}
|
|
535
|
+
function Be({ getPageType: e, getProduct: t }) {
|
|
536
|
+
return () => ({
|
|
537
|
+
url: window.location.href,
|
|
538
|
+
title: document.title,
|
|
539
|
+
pageType: e(),
|
|
540
|
+
product: t()
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
function Fe({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getSearchCapabilities: o, getMemory: c }) {
|
|
544
|
+
return async () => ({
|
|
545
|
+
accountId: e,
|
|
546
|
+
url: window.location.href,
|
|
547
|
+
pageType: t(),
|
|
548
|
+
productSku: r()?.sku ?? null,
|
|
549
|
+
toolNames: n(),
|
|
550
|
+
...o ? { searchCapabilities: o() } : {},
|
|
551
|
+
...c ? { memoryPolicy: c().policy } : {},
|
|
552
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
function ke({ accountId: e, runtimeFile: t = "runtime.js", startExport: r = "start", globalBaseUrlKey: n, errorLabel: o } = {}) {
|
|
556
|
+
if (!e) throw new Error("accountId is required.");
|
|
557
|
+
const c = o || e, i = window, g = () => {
|
|
558
|
+
const u = i.GengageInjectorConfig || {}, a = u[e] || {};
|
|
559
|
+
return {
|
|
560
|
+
...u,
|
|
561
|
+
...a
|
|
562
|
+
};
|
|
563
|
+
}, w = () => {
|
|
564
|
+
const u = g();
|
|
565
|
+
if (u.runtimeUrl) return u.runtimeUrl;
|
|
566
|
+
const a = u.assetBaseUrl || u.baseUrl || document.currentScript?.getAttribute("src") || (n ? i[n] : null);
|
|
567
|
+
if (!a) throw new Error(`${c} runtime URL cannot be resolved.`);
|
|
568
|
+
return new URL(t, a).href;
|
|
569
|
+
}, m = i.GengageAssistantInjector || (i.GengageAssistantInjector = {}), d = m[e] || (m[e] = {});
|
|
570
|
+
return d.loaderPromise || (d.loaderPromise = import(
|
|
571
|
+
/* @vite-ignore */
|
|
572
|
+
w()
|
|
573
|
+
).then((u) => {
|
|
574
|
+
const a = u[r];
|
|
575
|
+
if (typeof a != "function") throw new Error(`${c} runtime export ${r} is unavailable.`);
|
|
576
|
+
return a();
|
|
577
|
+
}).catch((u) => {
|
|
578
|
+
throw console.error(`[Gengage][${e}] runtime load failed`, u), u;
|
|
579
|
+
})), d.loaderPromise;
|
|
580
|
+
}
|
|
581
|
+
export {
|
|
582
|
+
Le as AgentError,
|
|
583
|
+
j as ContextStore,
|
|
584
|
+
Se as action,
|
|
585
|
+
he as actionButtonsUiSpec,
|
|
586
|
+
de as beErrorToAgentError,
|
|
587
|
+
Ue as beautyConsultingTurnFlow,
|
|
588
|
+
P as canUseModuleWorker,
|
|
589
|
+
L as caughtToStreamError,
|
|
590
|
+
ge as comparisonUiSpec,
|
|
591
|
+
De as createBrowserMemory,
|
|
592
|
+
Fe as createDiagnosticsTool,
|
|
593
|
+
Ee as createFlow,
|
|
594
|
+
B as createInjectorAdapter,
|
|
595
|
+
F as createMainThreadInjectorAdapter,
|
|
596
|
+
z as createModuleWorker,
|
|
597
|
+
Be as createReadPageTool,
|
|
598
|
+
we as done,
|
|
599
|
+
le as elapsedMs,
|
|
600
|
+
me as error,
|
|
601
|
+
_e as httpErrorToAgentError,
|
|
602
|
+
Me as installBrowserTools,
|
|
603
|
+
qe as installFetchTransportBridge,
|
|
604
|
+
fe as metadata,
|
|
605
|
+
Oe as mountAccount,
|
|
606
|
+
pe as normalizeProduct,
|
|
607
|
+
ye as nowIso,
|
|
608
|
+
Ae as productDetailsUiSpec,
|
|
609
|
+
Te as productsUiSpec,
|
|
610
|
+
ve as requestText,
|
|
611
|
+
Ce as resolveBeUrl,
|
|
612
|
+
Re as resolveFlow,
|
|
613
|
+
$e as setAssistantHostVisible,
|
|
614
|
+
ae as stableKey,
|
|
615
|
+
ke as startLazyRuntimeLoader,
|
|
616
|
+
Pe as textChunk,
|
|
617
|
+
be as trimProductFactsCore,
|
|
618
|
+
xe as trimProductFactsListCore,
|
|
619
|
+
je as uiSpec
|
|
620
|
+
};
|