@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.
Files changed (190) hide show
  1. package/dist/agentic/adaptor/create-adaptor.d.ts +19 -0
  2. package/dist/agentic/adaptor/fetch-bridge.d.ts +11 -0
  3. package/dist/agentic/adaptor/mount.d.ts +38 -0
  4. package/dist/agentic/context/chat-context.d.ts +15 -0
  5. package/dist/agentic/context/context-store.d.ts +20 -0
  6. package/dist/agentic/context/persistence.d.ts +12 -0
  7. package/dist/agentic/events/builders.d.ts +10 -0
  8. package/dist/agentic/events/error-taxonomy.d.ts +27 -0
  9. package/dist/agentic/events/product-normalize.d.ts +47 -0
  10. package/dist/agentic/events/ui-specs.d.ts +37 -0
  11. package/dist/agentic/flow/beauty-consulting-turn.d.ts +1 -0
  12. package/dist/agentic/flow/create-flow.d.ts +2 -0
  13. package/dist/agentic/flow/dispatch.d.ts +3 -0
  14. package/dist/agentic/index.d.ts +18 -0
  15. package/dist/agentic/index.js +620 -0
  16. package/dist/agentic/types.d.ts +212 -0
  17. package/dist/agentic/util/assistant-host.d.ts +11 -0
  18. package/dist/agentic/util/be-url.d.ts +4 -0
  19. package/dist/agentic/util/browser-memory.d.ts +13 -0
  20. package/dist/agentic/util/browser-tools.d.ts +31 -0
  21. package/dist/agentic/util/lazy-runtime-loader.d.ts +9 -0
  22. package/dist/agentic/util/request-text.d.ts +3 -0
  23. package/dist/agentic/util/time.d.ts +2 -0
  24. package/dist/agentic/worker/be-client.d.ts +15 -0
  25. package/dist/agentic/worker/entry.d.ts +2 -0
  26. package/dist/agentic/worker/flow-runner.d.ts +24 -0
  27. package/dist/agentic/worker/jwt-mint.d.ts +21 -0
  28. package/dist/agentic/worker/rpc.d.ts +24 -0
  29. package/dist/agentic/worker/tool-bridge.d.ts +2 -0
  30. package/dist/agentic/worker.d.ts +16 -0
  31. package/dist/agentic/worker.js +119 -0
  32. package/dist/agentic.iife.js +5 -0
  33. package/dist/{api-paths-CwzwbgQZ.js → api-paths-DJFF9RuZ.js} +1 -1
  34. package/dist/beauty-consulting-turn-BmPXbkQg.js +1019 -0
  35. package/dist/chat/api.d.ts +17 -0
  36. package/dist/chat/assistant-mode.d.ts +20 -0
  37. package/dist/chat/attachment-utils.d.ts +9 -0
  38. package/dist/chat/catalog.d.ts +455 -0
  39. package/dist/chat/chat-presentation-state.d.ts +53 -0
  40. package/dist/chat/components/AIGroupingCards.d.ts +15 -0
  41. package/dist/chat/components/AISuggestedSearchCards.d.ts +13 -0
  42. package/dist/chat/components/AITopPicks.d.ts +9 -0
  43. package/dist/chat/components/BeautyPhotoStep.d.ts +31 -0
  44. package/dist/chat/components/CategoriesContainer.d.ts +11 -0
  45. package/dist/chat/components/ChatDrawer.d.ts +362 -0
  46. package/dist/chat/components/ChoicePrompter.d.ts +21 -0
  47. package/dist/chat/components/ComparisonTable.d.ts +66 -0
  48. package/dist/chat/components/ConsultingStylePicker.d.ts +40 -0
  49. package/dist/chat/components/FloatingComparisonButton.d.ts +7 -0
  50. package/dist/chat/components/FloatingLauncher.d.ts +79 -0
  51. package/dist/chat/components/GroundingReviewCard.d.ts +11 -0
  52. package/dist/chat/components/HandoffNotice.d.ts +9 -0
  53. package/dist/chat/components/KvkkBanner.d.ts +6 -0
  54. package/dist/chat/components/Launcher.d.ts +28 -0
  55. package/dist/chat/components/PanelRestoreCard.d.ts +4 -0
  56. package/dist/chat/components/PanelTopBar.d.ts +32 -0
  57. package/dist/chat/components/PhotoAnalysisCard.d.ts +27 -0
  58. package/dist/chat/components/ProductSummaryCard.d.ts +12 -0
  59. package/dist/chat/components/ProsAndCons.d.ts +8 -0
  60. package/dist/chat/components/ReviewHighlights.d.ts +16 -0
  61. package/dist/chat/components/actionClassifier.d.ts +12 -0
  62. package/dist/chat/components/product-price-layout.d.ts +17 -0
  63. package/dist/chat/components/productMentionLinker.d.ts +26 -0
  64. package/dist/chat/components/renderUISpec.d.ts +15 -0
  65. package/dist/chat/components/typewriter.d.ts +24 -0
  66. package/dist/chat/extendedModeManager.d.ts +32 -0
  67. package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +38 -0
  68. package/dist/chat/features/beauty-consulting/drawer-extensions.d.ts +22 -0
  69. package/dist/chat/features/beauty-consulting/mode-controller.d.ts +59 -0
  70. package/dist/chat/features/beauty-consulting/registry.d.ts +9 -0
  71. package/dist/chat/features/beauty-consulting/stream-handler.d.ts +45 -0
  72. package/dist/chat/history-storage.d.ts +85 -0
  73. package/dist/chat/index.d.ts +6 -0
  74. package/dist/chat/kvkk.d.ts +20 -0
  75. package/dist/chat/locales/en.d.ts +2 -0
  76. package/dist/chat/locales/index.d.ts +5 -0
  77. package/dist/chat/locales/tr.d.ts +2 -0
  78. package/dist/chat/panel-manager.d.ts +142 -0
  79. package/dist/chat/runtime.d.ts +416 -0
  80. package/dist/chat/session-persistence.d.ts +73 -0
  81. package/dist/chat/stream-error-display.d.ts +6 -0
  82. package/dist/chat/types.d.ts +547 -0
  83. package/dist/chat/utils/chat-presentation-debug.d.ts +18 -0
  84. package/dist/chat/utils/get-chat-scroll-element.d.ts +10 -0
  85. package/dist/chat/utils/ui.d.ts +10 -0
  86. package/dist/chat-runtime.js +1 -1
  87. package/dist/chat.iife.js +12 -12
  88. package/dist/chat.js +1 -1
  89. package/dist/common/action-router.d.ts +26 -0
  90. package/dist/common/api-paths.d.ts +23 -0
  91. package/dist/common/client.d.ts +27 -0
  92. package/dist/common/communication-bridge.d.ts +51 -0
  93. package/dist/common/config-constants.d.ts +1 -0
  94. package/dist/common/config-schema.d.ts +54 -0
  95. package/dist/common/connection-warning.d.ts +8 -0
  96. package/dist/common/consulting-sources.d.ts +8 -0
  97. package/dist/common/context.d.ts +64 -0
  98. package/dist/common/css-escape.d.ts +1 -0
  99. package/dist/common/customization-factories.d.ts +59 -0
  100. package/dist/common/debug.d.ts +13 -0
  101. package/dist/common/events.d.ts +55 -0
  102. package/dist/common/fastIntent.d.ts +1 -0
  103. package/dist/common/find-similar-payload.d.ts +3 -0
  104. package/dist/common/ga-datalayer.d.ts +80 -0
  105. package/dist/common/global-error-toast.d.ts +6 -0
  106. package/dist/common/index.d.ts +47 -0
  107. package/dist/common/indexed-db.d.ts +89 -0
  108. package/dist/common/locale.d.ts +1 -0
  109. package/dist/common/native-webview.d.ts +60 -0
  110. package/dist/common/navigation.d.ts +1 -0
  111. package/dist/common/overlay.d.ts +172 -0
  112. package/dist/common/page-detect.d.ts +36 -0
  113. package/dist/common/pill-launcher.d.ts +51 -0
  114. package/dist/common/preflight.d.ts +13 -0
  115. package/dist/common/price-formatter.d.ts +35 -0
  116. package/dist/common/product-utils.d.ts +35 -0
  117. package/dist/common/protocol-adapter.d.ts +108 -0
  118. package/dist/common/renderer/dom.d.ts +3 -0
  119. package/dist/common/renderer/index.d.ts +4 -0
  120. package/dist/common/renderer/overrides.d.ts +23 -0
  121. package/dist/common/renderer/registry.d.ts +2 -0
  122. package/dist/common/renderer/types.d.ts +19 -0
  123. package/dist/common/safe-html.d.ts +22 -0
  124. package/dist/common/sdk-version.d.ts +3 -0
  125. package/dist/common/streaming.d.ts +52 -0
  126. package/dist/common/suggested-search-keywords.d.ts +18 -0
  127. package/dist/common/theme-utils.d.ts +15 -0
  128. package/dist/common/transport.d.ts +75 -0
  129. package/dist/common/tts-player.d.ts +13 -0
  130. package/dist/common/types.d.ts +379 -0
  131. package/dist/common/ui-theme.d.ts +9 -0
  132. package/dist/common/uuidv7.d.ts +7 -0
  133. package/dist/common/voice-input.d.ts +74 -0
  134. package/dist/common/widget-base.d.ts +82 -0
  135. package/dist/{common-KpJP1YwP.js → common-BydCGBNn.js} +90 -139
  136. package/dist/common.js +41 -41
  137. package/dist/{connection-warning-B5T_1oBn.js → connection-warning-Pbvk3J8k.js} +1 -1
  138. package/dist/{fastIntent--Ukm2nOh.js → fastIntent-CkYN2UOl.js} +199 -137
  139. package/dist/index.d.ts +25 -0
  140. package/dist/index.js +50 -50
  141. package/dist/native/index.d.ts +2 -0
  142. package/dist/{native-webview-qfjm4SHx.js → native-webview-JDC1vtde.js} +1 -1
  143. package/dist/native.iife.js +14 -14
  144. package/dist/native.js +1 -1
  145. package/dist/{overlay-CP5A0Hhf.js → overlay-BetAvpVZ.js} +19 -19
  146. package/dist/overlay.d.ts +4 -0
  147. package/dist/overlay.js +1 -1
  148. package/dist/qna/api.d.ts +23 -0
  149. package/dist/qna/catalog.d.ts +60 -0
  150. package/dist/qna/components/ButtonRow.d.ts +15 -0
  151. package/dist/qna/components/TextInput.d.ts +11 -0
  152. package/dist/qna/components/renderUISpec.d.ts +7 -0
  153. package/dist/qna/index.d.ts +3 -0
  154. package/dist/qna/locales/en.d.ts +2 -0
  155. package/dist/qna/locales/index.d.ts +4 -0
  156. package/dist/qna/locales/tr.d.ts +2 -0
  157. package/dist/qna/normalize-ui-specs.d.ts +15 -0
  158. package/dist/qna/runtime.d.ts +73 -0
  159. package/dist/qna/types.d.ts +98 -0
  160. package/dist/qna-runtime.js +1 -1
  161. package/dist/qna.iife.js +1 -1
  162. package/dist/qna.js +1 -1
  163. package/dist/{runtime-BPyXOyyp.js → runtime-DbZO1qG5.js} +3 -3
  164. package/dist/{runtime-G3idwfkM.js → runtime-OpNoB3cu.js} +894 -853
  165. package/dist/{runtime-C3yOvNFK.js → runtime-iCLkUjI3.js} +3 -3
  166. package/dist/simbut/index.d.ts +31 -0
  167. package/dist/simbut/locales.d.ts +3 -0
  168. package/dist/simbut/types.d.ts +43 -0
  169. package/dist/{simbut-CiknJI6-.js → simbut-FyXolmZY.js} +1 -1
  170. package/dist/simbut.iife.js +1 -1
  171. package/dist/simbut.js +1 -1
  172. package/dist/simrel/api.d.ts +25 -0
  173. package/dist/simrel/catalog.d.ts +77 -0
  174. package/dist/simrel/components/GroupTabs.d.ts +24 -0
  175. package/dist/simrel/components/ProductCard.d.ts +19 -0
  176. package/dist/simrel/components/ProductGrid.d.ts +17 -0
  177. package/dist/simrel/components/renderUISpec.d.ts +7 -0
  178. package/dist/simrel/index.d.ts +5 -0
  179. package/dist/simrel/locales/en.d.ts +2 -0
  180. package/dist/simrel/locales/index.d.ts +4 -0
  181. package/dist/simrel/locales/tr.d.ts +2 -0
  182. package/dist/simrel/renderers/default.d.ts +41 -0
  183. package/dist/simrel/runtime.d.ts +68 -0
  184. package/dist/simrel/types.d.ts +145 -0
  185. package/dist/{simrel-C1YN71aW.js → simrel-CbLe5OAr.js} +1 -1
  186. package/dist/simrel-runtime.js +1 -1
  187. package/dist/simrel.iife.js +1 -1
  188. package/dist/simrel.js +2 -2
  189. package/dist/{widget-base-UmvgIqDk.js → widget-base-COP8QwU3.js} +1 -1
  190. package/package.json +20 -6
@@ -0,0 +1,1019 @@
1
+ function G(t) {
2
+ return !!t && typeof t == "object" && t.type === "rpc.result";
3
+ }
4
+ function W(t) {
5
+ return !!t && typeof t == "object" && t.type === "rpc.req";
6
+ }
7
+ function Bt(t = self) {
8
+ let e = 1;
9
+ const n = /* @__PURE__ */ new Map();
10
+ return t.addEventListener("message", (r) => {
11
+ const o = r.data;
12
+ if (!G(o)) return;
13
+ const a = n.get(o.rpcId);
14
+ if (a) {
15
+ if (n.delete(o.rpcId), o.ok === !1) {
16
+ const i = typeof o.error == "object" ? o.error?.message : o.error;
17
+ a.reject(new Error(i || "RPC failed"));
18
+ return;
19
+ }
20
+ a.resolve(o.value);
21
+ }
22
+ }), function(o, a, i) {
23
+ const s = e++;
24
+ return t.postMessage({
25
+ type: "rpc.req",
26
+ rpcId: s,
27
+ method: o,
28
+ payload: a
29
+ }, i || []), new Promise((c, u) => {
30
+ n.set(s, {
31
+ resolve: (l) => c(l),
32
+ reject: u
33
+ });
34
+ });
35
+ };
36
+ }
37
+ function Nt({ worker: t, tools: e = {}, beacon: n, memory: r = sessionStorage }) {
38
+ t.addEventListener("message", (o) => {
39
+ const a = o.data;
40
+ W(a) && Y(t, a, {
41
+ tools: e,
42
+ beacon: n,
43
+ memory: r
44
+ });
45
+ });
46
+ }
47
+ async function Y(t, e, n) {
48
+ try {
49
+ const r = await tt(e.method, e.payload, n);
50
+ t.postMessage({
51
+ type: "rpc.result",
52
+ rpcId: e.rpcId,
53
+ ok: !0,
54
+ value: r
55
+ });
56
+ } catch (r) {
57
+ t.postMessage({
58
+ type: "rpc.result",
59
+ rpcId: e.rpcId,
60
+ ok: !1,
61
+ error: { message: r instanceof Error ? r.message : String(r) }
62
+ });
63
+ }
64
+ }
65
+ function X(t) {
66
+ if (t && typeof t == "object" && typeof t.name == "string") return t;
67
+ throw new Error("tool.invoke requires { name, input }");
68
+ }
69
+ function Q(t) {
70
+ if (t && typeof t == "object" && t.key !== void 0) return t;
71
+ throw new Error("memory.get requires { key }");
72
+ }
73
+ function Z(t) {
74
+ if (t && typeof t == "object" && t.key !== void 0) return t;
75
+ throw new Error("memory.set requires { key }");
76
+ }
77
+ async function tt(t, e, { tools: n, beacon: r, memory: o }) {
78
+ if (t === "tool.invoke") {
79
+ const { name: a, input: i } = X(e), s = n[a];
80
+ if (typeof s != "function") throw new Error(`Unknown tool: ${a}`);
81
+ return s(i);
82
+ }
83
+ if (t === "beacon.send")
84
+ return r?.(e), { sent: !0 };
85
+ if (t === "memory.get") {
86
+ const { key: a } = Q(e), i = o.getItem(String(a));
87
+ return i ? JSON.parse(i) : null;
88
+ }
89
+ if (t === "memory.set") {
90
+ const { key: a, value: i } = Z(e);
91
+ return o.setItem(String(a), JSON.stringify(i ?? null)), { ok: !0 };
92
+ }
93
+ throw new Error(`Unknown RPC method: ${t}`);
94
+ }
95
+ function et() {
96
+ return (/* @__PURE__ */ new Date()).toISOString();
97
+ }
98
+ function E(t) {
99
+ return Math.max(0, Math.round(performance.now() - t));
100
+ }
101
+ function w(t) {
102
+ return typeof t == "object" && t !== null && !Array.isArray(t);
103
+ }
104
+ function nt(t) {
105
+ const { accountId: e, locale: n = "en-GB", parentUrl: r = "", threadId: o, incomingContext: a } = t, i = w(a) ? a : {}, s = w(i.thread) ? i.thread : {}, c = w(i.panel) ? i.panel : {}, u = w(i.meta) ? i.meta : {}, l = U(i.messages), d = {
106
+ id: String(o || s.id || self.crypto.randomUUID()),
107
+ started_at: String(s.started_at || et()),
108
+ extensions: w(s.extensions) ? { ...s.extensions } : {}
109
+ }, y = String(u.locale || n), p = String(u.parentUrl || r || typeof self < "u" && self.location?.href || "");
110
+ return {
111
+ panel: { ...c },
112
+ messages: l,
113
+ thread: d,
114
+ meta: {
115
+ locale: y,
116
+ parentUrl: p,
117
+ accountId: e
118
+ }
119
+ };
120
+ }
121
+ function rt(t, e) {
122
+ const n = U([e])[0];
123
+ return n ? {
124
+ ...t,
125
+ messages: [...t.messages, n].slice(-50)
126
+ } : t;
127
+ }
128
+ function U(t) {
129
+ return Array.isArray(t) ? t.map((e) => {
130
+ const n = e?.role;
131
+ return {
132
+ role: n === "model" ? "assistant" : typeof n == "string" ? n : "",
133
+ content: String(e?.content || "")
134
+ };
135
+ }).filter((e) => (e.role === "user" || e.role === "assistant") && !!e.content).slice(-50) : [];
136
+ }
137
+ var ot = "gengage:agent:context:";
138
+ async function it({ accountId: t, threadId: e, rpc: n }) {
139
+ const r = await n("memory.get", {
140
+ tier: "session",
141
+ key: $(t, e)
142
+ });
143
+ return r && typeof r == "object" && !Array.isArray(r) ? r : {};
144
+ }
145
+ async function at({ accountId: t, threadId: e, extensions: n, rpc: r }) {
146
+ await r("memory.set", {
147
+ tier: "session",
148
+ key: $(t, e),
149
+ value: { thread: { extensions: n } }
150
+ });
151
+ }
152
+ function $(t, e) {
153
+ return `${ot}${t}:${e}`;
154
+ }
155
+ function f(t) {
156
+ return typeof t == "object" && t !== null && !Array.isArray(t);
157
+ }
158
+ var Ut = class {
159
+ #t = /* @__PURE__ */ new Map();
160
+ #e;
161
+ #r;
162
+ #o;
163
+ #n;
164
+ constructor({ accountId: t, locale: e, parentUrl: n, rpc: r }) {
165
+ this.#e = t, this.#r = e, this.#o = n, this.#n = r;
166
+ }
167
+ async load(t) {
168
+ const e = t?.meta?.threadId || t?.session_id || t?.sessionId, n = String(e || "default"), r = this.#t.get(n);
169
+ if (r) return r;
170
+ const o = await it({
171
+ accountId: this.#e,
172
+ threadId: n,
173
+ rpc: this.#n
174
+ }), a = nt({
175
+ accountId: this.#e,
176
+ locale: t?.locale || this.#r,
177
+ parentUrl: this.#o,
178
+ threadId: n,
179
+ incomingContext: st(o, t?.context)
180
+ });
181
+ return this.#t.set(n, a), a;
182
+ }
183
+ patch(t, e) {
184
+ const n = String(t || "default"), r = this.#t.get(n);
185
+ if (!r) return null;
186
+ const o = D(r, typeof e == "function" ? e(r) : e);
187
+ return this.#t.set(n, o), o;
188
+ }
189
+ appendUserMessage(t, e) {
190
+ const n = String(t || "default");
191
+ if (!e) return this.#t.get(n) ?? null;
192
+ const r = this.#t.get(n);
193
+ if (!r) return null;
194
+ const o = rt(r, {
195
+ role: "user",
196
+ content: e
197
+ });
198
+ return this.#t.set(n, o), o;
199
+ }
200
+ async commit(t) {
201
+ const e = String(t || "default"), n = this.#t.get(e);
202
+ return n ? (await at({
203
+ accountId: this.#e,
204
+ threadId: e,
205
+ extensions: n.thread.extensions,
206
+ rpc: this.#n
207
+ }), n) : null;
208
+ }
209
+ };
210
+ function st(t, e) {
211
+ return !f(t) && !f(e) ? {} : D(f(t) ? t : {}, f(e) ? e : {});
212
+ }
213
+ function D(t, e) {
214
+ if (!f(e)) return t;
215
+ const n = t, r = e, o = f(n.panel) ? n.panel : {}, a = f(r.panel) ? r.panel : {}, i = f(n.thread) ? n.thread : {}, s = f(r.thread) ? r.thread : {}, c = f(i.extensions) ? i.extensions : {}, u = f(s.extensions) ? s.extensions : {}, l = f(n.meta) ? n.meta : {}, d = f(r.meta) ? r.meta : {};
216
+ return {
217
+ ...t,
218
+ ...e,
219
+ panel: {
220
+ ...o,
221
+ ...a
222
+ },
223
+ thread: {
224
+ ...i,
225
+ ...s,
226
+ extensions: {
227
+ ...c,
228
+ ...u
229
+ }
230
+ },
231
+ meta: {
232
+ ...l,
233
+ ...d
234
+ },
235
+ messages: Array.isArray(r.messages) ? r.messages.slice(-50) : t.messages ?? []
236
+ };
237
+ }
238
+ function J(t) {
239
+ const e = String.fromCharCode(...t);
240
+ return btoa(e).replace(/\+/gu, "-").replace(/\//gu, "_").replace(/=+$/u, "");
241
+ }
242
+ function P(t) {
243
+ return J(new TextEncoder().encode(JSON.stringify(t)));
244
+ }
245
+ async function ct({ accountId: t, devJwtSecret: e, ttlS: n = 300 }) {
246
+ if (!e) throw new Error("devJwtSecret is required for local agent mode.");
247
+ const r = Math.floor(Date.now() / 1e3), o = `${P({
248
+ alg: "HS256",
249
+ typ: "JWT"
250
+ })}.${P({
251
+ sub: t,
252
+ iat: r,
253
+ exp: r + n,
254
+ scope: "invoke",
255
+ jti: crypto.randomUUID?.() || `${r}-${Math.random()}`
256
+ })}`, a = await crypto.subtle.importKey("raw", new TextEncoder().encode(e), {
257
+ name: "HMAC",
258
+ hash: "SHA-256"
259
+ }, !1, ["sign"]), i = await crypto.subtle.sign("HMAC", a, new TextEncoder().encode(o));
260
+ return `${o}.${J(new Uint8Array(i))}`;
261
+ }
262
+ function ut({ accountId: t, devJwtSecret: e, tokenBrokerUrl: n, tokenBrokerAudience: r, refreshSkewS: o = 30, fetchImpl: a = fetch }) {
263
+ let i = null;
264
+ return async ({ signal: s, parentUrl: c } = {}) => {
265
+ if (e) return ct({
266
+ accountId: t,
267
+ devJwtSecret: e
268
+ });
269
+ if (!n) throw new Error("tokenBrokerUrl is required for production agent mode.");
270
+ const u = Math.floor(Date.now() / 1e3);
271
+ return i?.token && i.expiresAtS - o > u || (i = await lt({
272
+ accountId: t,
273
+ tokenBrokerUrl: n,
274
+ tokenBrokerAudience: r,
275
+ parentUrl: c,
276
+ signal: s,
277
+ fetchImpl: a
278
+ })), i.token;
279
+ };
280
+ }
281
+ async function lt({ accountId: t, tokenBrokerUrl: e, tokenBrokerAudience: n, parentUrl: r, signal: o, fetchImpl: a }) {
282
+ const i = await a(e, {
283
+ method: "POST",
284
+ credentials: "include",
285
+ headers: {
286
+ accept: "application/json",
287
+ "content-type": "application/json"
288
+ },
289
+ body: JSON.stringify({
290
+ accountId: t,
291
+ scope: "invoke",
292
+ audience: n || void 0,
293
+ parentUrl: r || void 0
294
+ }),
295
+ ...o ? { signal: o } : {}
296
+ });
297
+ if (!i.ok) throw new Error(`Token broker request failed (${i.status}).`);
298
+ const s = await i.json(), c = s?.token || s?.jwt || s?.access_token;
299
+ if (!c || typeof c != "string") throw new Error("Token broker response did not include a JWT.");
300
+ return {
301
+ token: c,
302
+ expiresAtS: dt(s) || pt(c) || Math.floor(Date.now() / 1e3) + 300
303
+ };
304
+ }
305
+ function dt(t) {
306
+ const e = t?.expiresAtS ?? t?.expires_at_s ?? t?.expiresInS ?? t?.expires_in_s;
307
+ if (Number.isFinite(e)) return Number(e);
308
+ const n = t?.expiresIn ?? t?.expires_in;
309
+ if (Number.isFinite(n)) return Math.floor(Date.now() / 1e3) + Number(n);
310
+ const r = t?.expiresAt ?? t?.expires_at;
311
+ if (typeof r == "string") {
312
+ const o = Date.parse(r);
313
+ if (Number.isFinite(o)) return Math.floor(o / 1e3);
314
+ }
315
+ return null;
316
+ }
317
+ function pt(t) {
318
+ try {
319
+ const [, e] = t.split(".");
320
+ if (!e) return null;
321
+ const n = e.replace(/-/gu, "+").replace(/_/gu, "/"), r = atob(n.padEnd(Math.ceil(n.length / 4) * 4, "=")), o = JSON.parse(r);
322
+ return Number.isFinite(o?.exp) ? Number(o.exp) : null;
323
+ } catch {
324
+ return null;
325
+ }
326
+ }
327
+ var M = {
328
+ unauthorized: {
329
+ code: "auth",
330
+ message: "Assistant authentication failed. Please retry."
331
+ },
332
+ forbidden: {
333
+ code: "auth",
334
+ message: "Assistant authentication failed. Please retry."
335
+ },
336
+ unknown_op: {
337
+ code: "op_unavailable",
338
+ message: "This assistant action is not available yet."
339
+ },
340
+ invalid_input: {
341
+ code: "invalid_request",
342
+ message: "The assistant request was not valid."
343
+ },
344
+ account_config: {
345
+ code: "account_config",
346
+ message: "Assistant configuration is unavailable."
347
+ },
348
+ upstream_llm: {
349
+ code: "op_failed",
350
+ message: "The assistant could not complete that request."
351
+ },
352
+ upstream_timeout: {
353
+ code: "op_timeout",
354
+ message: "The assistant took too long to respond."
355
+ },
356
+ schema_mismatch: {
357
+ code: "op_failed",
358
+ message: "The assistant could not complete that request."
359
+ },
360
+ rate_limited: {
361
+ code: "rate_limited",
362
+ message: "The assistant is receiving too many requests. Please retry shortly."
363
+ },
364
+ internal: {
365
+ code: "op_failed",
366
+ message: "The assistant could not complete that request."
367
+ },
368
+ payload_too_large: {
369
+ code: "invalid_request",
370
+ message: "The assistant request was too large."
371
+ }
372
+ }, q = class extends Error {
373
+ constructor(t, e, n = {}) {
374
+ super(e), this.name = "AgentError", this.code = t, this.source = n.source || "agent", n.sourceCode && (this.sourceCode = n.sourceCode), n.detail !== void 0 && (this.detail = n.detail);
375
+ }
376
+ };
377
+ function F(t) {
378
+ const e = String(t?.code || "upstream_llm"), n = M[e] || M.upstream_llm;
379
+ return new q(n.code, n.message, {
380
+ source: "be",
381
+ sourceCode: e,
382
+ detail: t?.detail
383
+ });
384
+ }
385
+ function ft(t, e) {
386
+ const n = e?.error && typeof e.error == "object" ? e.error : {};
387
+ return F({
388
+ code: String(n.code || mt(t)),
389
+ detail: n.detail
390
+ });
391
+ }
392
+ function $t(t) {
393
+ return t instanceof q ? {
394
+ type: "error",
395
+ code: t.code,
396
+ message: t.message
397
+ } : {
398
+ type: "error",
399
+ code: "agent_invoke_failed",
400
+ message: "The assistant could not complete that request."
401
+ };
402
+ }
403
+ function mt(t) {
404
+ return t === 401 ? "unauthorized" : t === 403 ? "forbidden" : t === 413 ? "payload_too_large" : t === 429 ? "rate_limited" : "internal";
405
+ }
406
+ async function Dt({ beUrl: t, accountId: e, devJwtSecret: n, tokenBrokerUrl: r, tokenBrokerAudience: o, jwtProvider: a, parentUrl: i, op: s, input: c, signal: u }) {
407
+ const l = {
408
+ method: "POST",
409
+ headers: {
410
+ authorization: `Bearer ${await (a || ut({
411
+ accountId: e,
412
+ devJwtSecret: n,
413
+ tokenBrokerUrl: r,
414
+ tokenBrokerAudience: o
415
+ }))({
416
+ ...u ? { signal: u } : {},
417
+ ...i ? { parentUrl: i } : {}
418
+ })}`,
419
+ "content-type": "application/json",
420
+ accept: "application/x-ndjson"
421
+ },
422
+ body: JSON.stringify({
423
+ op: s,
424
+ input: c
425
+ }),
426
+ ...u ? { signal: u } : {}
427
+ }, d = await fetch(`${String(t).replace(/\/+$/u, "")}/v1/invoke`, l);
428
+ if (!d.ok) throw ft(d.status, await yt(d));
429
+ return gt(d);
430
+ }
431
+ async function yt(t) {
432
+ try {
433
+ return await t.json();
434
+ } catch {
435
+ return { error: { code: t.statusText || "internal" } };
436
+ }
437
+ }
438
+ async function gt(t) {
439
+ const e = t.body?.getReader();
440
+ if (!e) throw new Error("BE response body is not readable.");
441
+ const n = new TextDecoder();
442
+ let r = "";
443
+ const o = {};
444
+ for (; ; ) {
445
+ const { value: i, done: s } = await e.read();
446
+ if (s) break;
447
+ r += n.decode(i, { stream: !0 });
448
+ let c = r.indexOf(`
449
+ `);
450
+ for (; c >= 0; ) {
451
+ const u = r.slice(0, c).trim();
452
+ r = r.slice(c + 1), u && O(JSON.parse(u), o), c = r.indexOf(`
453
+ `);
454
+ }
455
+ }
456
+ const a = r.trim();
457
+ return a && O(JSON.parse(a), o), o;
458
+ }
459
+ function O(t, e) {
460
+ if (t._error) throw F(t._error);
461
+ t._end || Object.assign(e, t);
462
+ }
463
+ function Jt(t = {}) {
464
+ return {
465
+ type: "metadata",
466
+ ...t
467
+ };
468
+ }
469
+ function _(t, e = !1, n = {}) {
470
+ return {
471
+ type: "text_chunk",
472
+ content: t,
473
+ final: e,
474
+ ...n
475
+ };
476
+ }
477
+ function ht(t) {
478
+ return {
479
+ type: "ui_spec",
480
+ ...t
481
+ };
482
+ }
483
+ function qt(t) {
484
+ return {
485
+ type: "action",
486
+ action: t
487
+ };
488
+ }
489
+ function wt(t, e) {
490
+ return {
491
+ type: "error",
492
+ code: t,
493
+ message: e
494
+ };
495
+ }
496
+ function z() {
497
+ return { type: "done" };
498
+ }
499
+ function kt(t, e) {
500
+ return t[e?.type || e?.action?.type || "inputText"] || t.inputText;
501
+ }
502
+ async function Ft({ request: t, accountModule: e, contextStore: n, beClient: r, toolBridge: o, emit: a, rpc: i, signal: s }) {
503
+ const c = performance.now(), u = await n.load(t), l = u.thread.id, d = Tt(t);
504
+ n.appendUserMessage(l, d);
505
+ const y = kt(e.flows, t);
506
+ if (!y)
507
+ return a(wt("unknown_action", `No agent flow for request type ${t?.type || "inputText"}`)), a(z()), {
508
+ steps: 0,
509
+ productSkusEmitted: []
510
+ };
511
+ const p = {
512
+ request: t,
513
+ context: n.patch(l, {}) || u,
514
+ bag: {},
515
+ accountConfig: e.accountConfig || {},
516
+ threadId: l,
517
+ steps: 0,
518
+ productSkusEmitted: /* @__PURE__ */ new Set(),
519
+ committed: !1
520
+ }, h = {
521
+ contextStore: n,
522
+ beClient: r,
523
+ toolBridge: o,
524
+ emit: a,
525
+ rpc: i,
526
+ ...s ? { signal: s } : {}
527
+ };
528
+ return await C(y, p, h), p.committed || await T(p, h), await i("beacon.send", {
529
+ type: "turnSummary",
530
+ threadId: l,
531
+ sessionId: t?.session_id || t?.sessionId || l,
532
+ accountId: e.accountId || p.context.meta.accountId,
533
+ steps: p.steps,
534
+ totalLatencyMs: E(c),
535
+ productSkusEmitted: [...p.productSkusEmitted]
536
+ }), {
537
+ steps: p.steps,
538
+ productSkusEmitted: [...p.productSkusEmitted]
539
+ };
540
+ }
541
+ async function C(t, e, n) {
542
+ for (const r of t) {
543
+ if (n.signal?.aborted) return;
544
+ e.steps += 1, await _t(r, e, n), e.context = n.contextStore.patch(e.threadId, {}) || e.context;
545
+ }
546
+ }
547
+ async function _t(t, e, n) {
548
+ const r = j(e);
549
+ if (t.kind === "be_op") {
550
+ await bt(t, e, n, r);
551
+ return;
552
+ }
553
+ if (t.kind === "tool") {
554
+ await St(t, e, n, r);
555
+ return;
556
+ }
557
+ if (t.kind === "emit") {
558
+ xt(t, e, n);
559
+ return;
560
+ }
561
+ if (t.kind === "branch") {
562
+ await At(t, e, n, r);
563
+ return;
564
+ }
565
+ if (t.kind === "parallel") {
566
+ await It(t, e, n);
567
+ return;
568
+ }
569
+ if (t.kind === "refusal") {
570
+ await Et(t, e, n, r);
571
+ return;
572
+ }
573
+ t.kind === "commit" && await Ct(t, e, n);
574
+ }
575
+ async function bt(t, e, n, r) {
576
+ const o = performance.now();
577
+ let a;
578
+ try {
579
+ a = await n.beClient.invoke({
580
+ op: t.op,
581
+ input: b(t.input, r),
582
+ ...n.signal ? { signal: n.signal } : {}
583
+ });
584
+ } catch (s) {
585
+ const c = s, u = String(c?.sourceCode || c?.code || "unknown"), l = {
586
+ type: "agentOp",
587
+ threadId: e.threadId,
588
+ sessionId: e.request?.session_id || e.request?.sessionId || e.threadId,
589
+ accountId: e.context.meta.accountId,
590
+ op: t.op,
591
+ status: "error",
592
+ latencyMs: E(o),
593
+ errorCode: u
594
+ };
595
+ throw await n.rpc("beacon.send", l), s;
596
+ }
597
+ t.out && (e.bag[t.out] = a), H(t, a, e, n.contextStore);
598
+ const i = {
599
+ type: "agentOp",
600
+ threadId: e.threadId,
601
+ sessionId: e.request?.session_id || e.request?.sessionId || e.threadId,
602
+ accountId: e.context.meta.accountId,
603
+ op: t.op,
604
+ status: "ok",
605
+ latencyMs: E(o)
606
+ };
607
+ await n.rpc("beacon.send", i);
608
+ }
609
+ async function St(t, e, n, r) {
610
+ const o = await n.toolBridge.invoke(t.name, b(t.input, r));
611
+ t.out && (e.bag[t.out] = o), H(t, o, e, n.contextStore);
612
+ }
613
+ function xt(t, e, n) {
614
+ const r = t.build(j(e));
615
+ jt(r, e.productSkusEmitted), n.emit(r);
616
+ }
617
+ async function At(t, e, n, r) {
618
+ const o = String(b(t.on, r) || "default");
619
+ await C(t.cases[o] || t.cases.default || [], e, n);
620
+ }
621
+ async function It(t, e, n) {
622
+ await Promise.all(t.steps.map((r) => C(r, e, n)));
623
+ }
624
+ async function Et(t, e, n, r) {
625
+ n.emit(_(b(t.message, r), !0)), await T(e, n);
626
+ }
627
+ async function Ct(t, e, n) {
628
+ await T(e, n);
629
+ }
630
+ async function T(t, { contextStore: e, emit: n }) {
631
+ t.committed || (t.context = await e.commit(t.threadId) || t.context, t.committed = !0, n(z()));
632
+ }
633
+ function H(t, e, n, r) {
634
+ if (typeof t.patch != "function") return;
635
+ const o = t.patch(n.context, e, j(n));
636
+ o && (n.context = r.patch(n.threadId, o) || n.context);
637
+ }
638
+ function j(t) {
639
+ return {
640
+ request: t.request,
641
+ context: t.context,
642
+ bag: t.bag,
643
+ accountConfig: t.accountConfig
644
+ };
645
+ }
646
+ function b(t, e) {
647
+ return typeof t == "function" ? t(e) : t;
648
+ }
649
+ function Tt(t) {
650
+ const e = t?.payload;
651
+ if (typeof e == "string") return e;
652
+ if (e && typeof e == "object" && "text" in e) {
653
+ const n = e.text;
654
+ if (typeof n == "string") return n;
655
+ }
656
+ return typeof t?.action?.payload == "string" ? t.action.payload : typeof t?.action?.title == "string" ? t.action.title : "";
657
+ }
658
+ function jt(t, e) {
659
+ const n = t, r = n.spec, o = Array.isArray(r?.items) ? r.items : void 0, a = Array.isArray(n.items) ? n.items : void 0, i = o || a;
660
+ if (Array.isArray(i)) {
661
+ for (const s of i) if (s && typeof s == "object") {
662
+ const c = s.sku;
663
+ typeof c == "string" && e.add(c);
664
+ }
665
+ }
666
+ }
667
+ function zt(t) {
668
+ return { invoke(e, n) {
669
+ return t("tool.invoke", {
670
+ name: e,
671
+ input: n
672
+ });
673
+ } };
674
+ }
675
+ function L(t) {
676
+ return t && typeof t == "object" && !Array.isArray(t) ? t : null;
677
+ }
678
+ function v(t) {
679
+ const e = L(t);
680
+ if (!e) return null;
681
+ const n = g(e.sku, e.SKU);
682
+ if (!n) return null;
683
+ const r = {
684
+ sku: n,
685
+ name: g(e.name, e.title, e.short_name, n) || n,
686
+ url: g(e.url) || ""
687
+ }, o = Array.isArray(e.images) ? e.images : void 0, a = g(e.imageUrl, e.image_url, e.image, o?.[0]);
688
+ a && (r.imageUrl = a), o && o.length > 1 && (r.images = o.filter((V) => !!V).map(String));
689
+ const i = k(e.price_discounted), s = k(e.price), c = i || s;
690
+ c > 0 && (r.price = String(c));
691
+ const u = i > 0 ? s : 0;
692
+ u > 0 && (r.originalPrice = String(u));
693
+ const l = g(e.brand);
694
+ l && (r.brand = l);
695
+ const d = k(e.rating);
696
+ d > 0 && (r.rating = d);
697
+ const y = k(e.review_count) || k(e.reviewCount);
698
+ y > 0 && (r.reviewCount = y);
699
+ const p = g(e.cart_code, e.cartCode);
700
+ p && (r.cartCode = p), typeof e.in_stock == "boolean" && (r.inStock = e.in_stock), typeof e.inStock == "boolean" && (r.inStock = e.inStock);
701
+ const h = e.category_names;
702
+ return Array.isArray(h) && (r.categoryNames = h.map(String)), r;
703
+ }
704
+ function vt(t) {
705
+ const e = L(t);
706
+ if (!e) return t;
707
+ const n = e.category_names, r = Array.isArray(n) ? n : void 0, o = e.images, a = Array.isArray(o) ? o : void 0, i = {
708
+ sku: e.sku,
709
+ name: e.name || e.title,
710
+ url: e.url,
711
+ price: e.price,
712
+ currency: e.price_currency || e.currency,
713
+ category: r?.[r.length - 1] ?? void 0,
714
+ category_names: r ? r.slice(0, 4) : void 0,
715
+ image: a ? a[0] : e.image,
716
+ in_stock: e.in_stock,
717
+ rating: e.rating,
718
+ review_count: e.review_count
719
+ };
720
+ for (const s of Object.keys(i)) i[s] === void 0 && delete i[s];
721
+ return i;
722
+ }
723
+ function K(t) {
724
+ return Array.isArray(t) ? t.map(vt).filter((e) => !!e) : [];
725
+ }
726
+ function g(...t) {
727
+ for (const e of t) if (typeof e == "string" && e.trim()) return e.trim();
728
+ return "";
729
+ }
730
+ function k(t) {
731
+ const e = Number(t);
732
+ return Number.isFinite(e) ? e : 0;
733
+ }
734
+ function R(t) {
735
+ return Array.isArray(t) ? t.map(String).filter(Boolean) : typeof t == "string" && t ? [t] : [];
736
+ }
737
+ function Pt(t = []) {
738
+ const e = {}, n = [];
739
+ return (Array.isArray(t) ? t.map(v).filter((r) => !!r) : []).forEach((r, o) => {
740
+ const a = `product-${o.toString()}`;
741
+ n.push(a);
742
+ const i = {
743
+ sku: r.sku,
744
+ product: r
745
+ };
746
+ e[a] = {
747
+ type: "ProductCard",
748
+ props: {
749
+ product: r,
750
+ index: o,
751
+ action: {
752
+ title: r.name,
753
+ type: "launchSingleProduct",
754
+ payload: i
755
+ }
756
+ }
757
+ };
758
+ }), e.root = {
759
+ type: "ProductGrid",
760
+ props: { layout: "grid" },
761
+ children: n
762
+ }, {
763
+ widget: "chat",
764
+ panelHint: "panel",
765
+ spec: {
766
+ root: "root",
767
+ elements: e
768
+ }
769
+ };
770
+ }
771
+ function Ht(t) {
772
+ return {
773
+ widget: "chat",
774
+ panelHint: "panel",
775
+ spec: {
776
+ root: "root",
777
+ elements: { root: {
778
+ type: "ProductDetailsPanel",
779
+ props: { product: v(t) || t || {} }
780
+ } }
781
+ }
782
+ };
783
+ }
784
+ function Lt(t = {}) {
785
+ const e = (t.multiple_product_details || t.products || []).map(v).filter((r) => !!r), n = t.table || {};
786
+ return {
787
+ widget: "chat",
788
+ panelHint: "panel",
789
+ spec: {
790
+ root: "root",
791
+ elements: { root: {
792
+ type: "ComparisonTable",
793
+ props: {
794
+ products: e,
795
+ recommended: e.find((r) => r.sku === t.recommended_choice_sku) || e[0],
796
+ attributes: Object.entries(n).map(([r, o]) => ({
797
+ label: r,
798
+ values: Array.isArray(o) ? o.map(String) : [String(o ?? "")]
799
+ })),
800
+ highlights: R(t.key_differences),
801
+ specialCases: R(t.special_considerations),
802
+ recommendedText: t.recommended_choice,
803
+ productActions: Object.fromEntries(e.map((r) => [r.sku, {
804
+ title: r.name,
805
+ type: "launchSingleProduct",
806
+ payload: {
807
+ sku: r.sku,
808
+ product: r
809
+ }
810
+ }]))
811
+ }
812
+ } }
813
+ }
814
+ };
815
+ }
816
+ function Kt(t = []) {
817
+ return {
818
+ widget: "chat",
819
+ panelHint: "inline",
820
+ spec: {
821
+ root: "root",
822
+ elements: { root: {
823
+ type: "ActionButtons",
824
+ props: { buttons: (Array.isArray(t) ? t : []).map((e) => {
825
+ const n = e.label || e.title || e.shortName || "", r = e.action || e.requestDetails || e.request_details;
826
+ return !n || !r?.type ? null : {
827
+ label: n,
828
+ action: {
829
+ title: n,
830
+ type: r.type,
831
+ ...r.payload !== void 0 ? { payload: r.payload } : {}
832
+ }
833
+ };
834
+ }).filter((e) => !!e) }
835
+ } }
836
+ }
837
+ };
838
+ }
839
+ function S(t) {
840
+ const e = t?.payload;
841
+ if (typeof e == "string") return e;
842
+ if (e && typeof e == "object" && "text" in e) {
843
+ const r = e.text;
844
+ if (typeof r == "string") return r;
845
+ }
846
+ const n = t?.action;
847
+ return n && typeof n.payload == "string" ? n.payload : n && typeof n.title == "string" ? n.title : "";
848
+ }
849
+ function Mt(t) {
850
+ return Object.freeze([...t]);
851
+ }
852
+ function m(t) {
853
+ return t && typeof t == "object" ? t : {};
854
+ }
855
+ function x(t) {
856
+ return t && typeof t == "object" ? t : {};
857
+ }
858
+ function B(t) {
859
+ return t.thread.extensions.beauty_profile;
860
+ }
861
+ var Vt = Mt([{
862
+ kind: "be_op",
863
+ op: "beauty-consulting-turn",
864
+ input: ({ request: t, context: e }) => ({
865
+ utterance: S(t),
866
+ prior_messages: e.messages.slice(-10),
867
+ profile: B(e),
868
+ candidate_products: Rt(t),
869
+ locale: e.meta.locale
870
+ }),
871
+ out: "consultation",
872
+ patch: N
873
+ }, {
874
+ kind: "branch",
875
+ on: ({ bag: t }) => m(t.consultation).consultation_state?.stage || "answer",
876
+ cases: {
877
+ refuse: [{
878
+ kind: "refusal",
879
+ message: ({ bag: t }) => {
880
+ const e = m(t.consultation);
881
+ return e.refusal?.message || e.plain_text || "I cannot help with that request.";
882
+ }
883
+ }],
884
+ needs_more_info: [{
885
+ kind: "emit",
886
+ build: ({ bag: t }) => _(I(m(t.consultation)), !0)
887
+ }, { kind: "commit" }],
888
+ search: [
889
+ {
890
+ kind: "tool",
891
+ name: "search",
892
+ input: ({ request: t, bag: e, context: n }) => {
893
+ const r = m(e.consultation);
894
+ return {
895
+ query: r.search_params?.query || S(t),
896
+ facets: r.search_params?.facets || {},
897
+ limit: 12,
898
+ locale: n.meta.locale
899
+ };
900
+ },
901
+ out: "products",
902
+ patch: (t, e) => {
903
+ const n = x(e);
904
+ return { panel: {
905
+ ...t.panel,
906
+ screen_sku_list: A(n).map((r) => Ot(r)).filter((r) => !!r),
907
+ last_search: { query: n.query || "" }
908
+ } };
909
+ }
910
+ },
911
+ {
912
+ kind: "emit",
913
+ build: ({ bag: t }) => ht(Pt(A(x(t.products))))
914
+ },
915
+ {
916
+ kind: "be_op",
917
+ op: "beauty-consulting-turn",
918
+ input: ({ request: t, context: e, bag: n }) => ({
919
+ utterance: S(t),
920
+ prior_messages: e.messages.slice(-10),
921
+ profile: B(e),
922
+ candidate_products: K(A(x(n.products)).slice(0, 12)),
923
+ locale: e.meta.locale
924
+ }),
925
+ out: "answer",
926
+ patch: (t, e) => {
927
+ const n = N(t, e), r = (m(e).product_mentions || []).map((o) => o.sku).filter((o) => !!o);
928
+ return {
929
+ ...n || {},
930
+ panel: {
931
+ ...t.panel,
932
+ chat_mentioned_skus: r
933
+ }
934
+ };
935
+ }
936
+ },
937
+ {
938
+ kind: "emit",
939
+ build: ({ bag: t }) => {
940
+ const e = m(t.answer);
941
+ return _(I(e), !0, { productMentions: e.product_mentions || [] });
942
+ }
943
+ },
944
+ { kind: "commit" }
945
+ ],
946
+ default: [{
947
+ kind: "emit",
948
+ build: ({ bag: t }) => {
949
+ const e = m(t.consultation);
950
+ return _(I(e), !0, { productMentions: e.product_mentions || [] });
951
+ }
952
+ }, { kind: "commit" }]
953
+ }
954
+ }]);
955
+ function N(t, e) {
956
+ const n = m(e).consultation_state?.captured_profile;
957
+ if (!n) return null;
958
+ const r = t.thread.extensions.beauty_profile && typeof t.thread.extensions.beauty_profile == "object" ? t.thread.extensions.beauty_profile : {};
959
+ return { thread: {
960
+ ...t.thread,
961
+ extensions: {
962
+ ...t.thread.extensions,
963
+ beauty_profile: {
964
+ ...r,
965
+ ...n
966
+ }
967
+ }
968
+ } };
969
+ }
970
+ function A(t) {
971
+ return Array.isArray(t?.products) ? t.products : [];
972
+ }
973
+ function Ot(t) {
974
+ if (t && typeof t == "object" && "sku" in t) {
975
+ const e = t.sku;
976
+ if (typeof e == "string") return e;
977
+ }
978
+ }
979
+ function Rt(t) {
980
+ const e = t?.payload && typeof t.payload == "object" ? t.payload.products : void 0, n = t?.action?.payload && typeof t.action.payload == "object" ? t.action.payload.products : void 0, r = e || n;
981
+ return Array.isArray(r) ? K(r.slice(0, 12)) : void 0;
982
+ }
983
+ function I(t) {
984
+ return t?.answer_html || t?.plain_text || t?.refusal?.message || "I can help with beauty shopping.";
985
+ }
986
+ export {
987
+ Bt as A,
988
+ $t as C,
989
+ Ut as D,
990
+ ct as E,
991
+ tt as M,
992
+ E as O,
993
+ F as S,
994
+ ut as T,
995
+ Jt as _,
996
+ Lt as a,
997
+ Dt as b,
998
+ v as c,
999
+ zt as d,
1000
+ Ft as f,
1001
+ wt as g,
1002
+ z as h,
1003
+ Kt as i,
1004
+ Nt as j,
1005
+ et as k,
1006
+ vt as l,
1007
+ qt as m,
1008
+ Mt as n,
1009
+ Ht as o,
1010
+ kt as p,
1011
+ S as r,
1012
+ Pt as s,
1013
+ Vt as t,
1014
+ K as u,
1015
+ _ as v,
1016
+ ft as w,
1017
+ q as x,
1018
+ ht as y
1019
+ };