@gengage/assistant-fe 0.5.7 → 0.6.1

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