@gengage/assistant-fe 0.6.50 → 0.7.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 (50) hide show
  1. package/dist/chat/api.d.ts +1 -1
  2. package/dist/chat/components/ChatDrawer.d.ts +4 -1
  3. package/dist/chat/features/beauty-consulting/mode-controller.d.ts +1 -1
  4. package/dist/chat/features/beauty-consulting/stream-handler.d.ts +7 -1
  5. package/dist/chat/history-storage.d.ts +36 -4
  6. package/dist/chat/runtime.d.ts +2 -2
  7. package/dist/chat/utils/chat-presentation-debug.d.ts +0 -14
  8. package/dist/chat-runtime.js +1 -1
  9. package/dist/chat.iife.js +56 -56
  10. package/dist/chat.js +1 -1
  11. package/dist/common/connection-warning.d.ts +10 -0
  12. package/dist/common/indexed-db.d.ts +35 -2
  13. package/dist/common/native-webview.d.ts +1 -1
  14. package/dist/common/streaming.d.ts +6 -1
  15. package/dist/common/transport.d.ts +2 -1
  16. package/dist/common/types.d.ts +16 -0
  17. package/dist/{common-DJFI5t11.js → common-CW6814pZ.js} +61 -65
  18. package/dist/common.js +30 -30
  19. package/dist/{connection-warning-TXqyeFaf.js → connection-warning-C0e2byq5.js} +31 -25
  20. package/dist/{fastIntent-539wPavr.js → fastIntent-CJGhUTpS.js} +2 -2
  21. package/dist/global-error-toast-DvaKvPNA.js +798 -0
  22. package/dist/index.js +29 -29
  23. package/dist/native-webview-CHKpwixw.js +303 -0
  24. package/dist/native.iife.js +27 -27
  25. package/dist/native.js +1 -1
  26. package/dist/{overlay-BPZEIyo_.js → overlay-C3XzoSKd.js} +51 -32
  27. package/dist/overlay.js +6 -6
  28. package/dist/{price-formatter-CHUmYq8I.js → price-formatter-Q3wUKrl1.js} +2 -1
  29. package/dist/qna/runtime.d.ts +1 -0
  30. package/dist/qna-runtime.js +1 -1
  31. package/dist/qna.iife.js +32 -32
  32. package/dist/qna.js +1 -1
  33. package/dist/{request-response-cache-DwADBDeB.js → request-response-cache-DItrp4fO.js} +478 -454
  34. package/dist/{runtime-9f9SB4WE.js → runtime-B9m0kyTB.js} +2796 -2697
  35. package/dist/{runtime-Do3qShrH.js → runtime-CZ363BP8.js} +231 -219
  36. package/dist/{runtime-rTw1jMhB.js → runtime-DKkw_dca.js} +230 -212
  37. package/dist/{simbut-DlWvDoPI.js → simbut-D_j8YgHS.js} +5 -5
  38. package/dist/simbut.iife.js +2 -2
  39. package/dist/simbut.js +1 -1
  40. package/dist/simrel/components/GroupTabs.d.ts +6 -0
  41. package/dist/simrel/runtime.d.ts +8 -0
  42. package/dist/{simrel-BFPU2n5p.js → simrel-BkAtQjNa.js} +15 -15
  43. package/dist/simrel-runtime.js +1 -1
  44. package/dist/simrel.iife.js +22 -22
  45. package/dist/simrel.js +2 -2
  46. package/dist/widget-base-BnUjuCt7.js +141 -0
  47. package/package.json +1 -1
  48. package/dist/context-UTzCGyR9.js +0 -543
  49. package/dist/native-webview-CYX30O3Q.js +0 -273
  50. package/dist/widget-base-BwU6SI2o.js +0 -365
@@ -1,273 +0,0 @@
1
- import { i as k } from "./overlay-BPZEIyo_.js";
2
- var _ = [
3
- "gengage:chat:open",
4
- "gengage:chat:close",
5
- "gengage:chat:ready",
6
- "gengage:chat:add-to-cart",
7
- "gengage:qna:action",
8
- "gengage:qna:open-chat",
9
- "gengage:similar:product-click",
10
- "gengage:similar:grouping-click",
11
- "gengage:similar:products-impression",
12
- "gengage:similar:add-to-cart",
13
- "gengage:global:error",
14
- "gengage:context:update"
15
- ], S = 32, E = "#gengage-qna", w = "#gengage-simrel";
16
- function A(n) {
17
- let e = n;
18
- if (typeof n == "string") {
19
- const s = n.trim();
20
- if (s.length === 0) return null;
21
- if (!s.startsWith("{") && !s.startsWith("[")) return { type: s };
22
- try {
23
- e = JSON.parse(s);
24
- } catch {
25
- return null;
26
- }
27
- }
28
- if (!e || typeof e != "object") return null;
29
- const t = e, d = [
30
- t.type,
31
- t.command,
32
- t.action,
33
- t.event
34
- ].find((s) => typeof s == "string" && s.length > 0);
35
- if (!d) return null;
36
- let a = t.payload;
37
- if (a === void 0 && "data" in t && (a = t.data), d === "setSession" && a === void 0) {
38
- const s = {};
39
- typeof t.sessionId == "string" && (s.sessionId = t.sessionId), typeof t.userId == "string" && (s.userId = t.userId), (s.sessionId !== void 0 || s.userId !== void 0) && (a = s);
40
- }
41
- return a === void 0 ? { type: d } : {
42
- type: d,
43
- payload: a
44
- };
45
- }
46
- function L(n) {
47
- if (typeof n == "string" && n.length > 0) return { sku: n };
48
- if (n && typeof n == "object" && "sku" in n) {
49
- const e = n.sku;
50
- if (typeof e == "string" && e.length > 0) {
51
- const t = n.pageType;
52
- return t !== void 0 ? {
53
- sku: e,
54
- pageType: t
55
- } : { sku: e };
56
- }
57
- }
58
- return null;
59
- }
60
- function b(n, e) {
61
- return e instanceof HTMLElement ? !0 : typeof e != "string" ? !1 : n.document.querySelector(e) !== null;
62
- }
63
- function T(n, e, t) {
64
- if (e instanceof HTMLElement || b(n, e) || typeof e != "string") return e;
65
- if (e.startsWith("#")) {
66
- const s = e.slice(1);
67
- if (s.length > 0) {
68
- const f = n.document.getElementById(s);
69
- if (f) return f;
70
- const u = n.document.createElement("div");
71
- return u.id = s, n.document.body.appendChild(u), u;
72
- }
73
- }
74
- const d = n.document.getElementById(t);
75
- if (d) return d;
76
- const a = n.document.createElement("div");
77
- return a.id = t, n.document.body.appendChild(a), a;
78
- }
79
- function C(n, e) {
80
- const t = n.webkit?.messageHandlers?.[e];
81
- return t && typeof t.postMessage == "function" ? t.postMessage.bind(t) : null;
82
- }
83
- function y(n, e) {
84
- const t = n[e];
85
- return t && typeof t == "object" && typeof t.postMessage == "function" ? t : null;
86
- }
87
- function O(n = {}) {
88
- const e = n.win ?? window, t = n.iosHandlerName ?? "gengage", d = n.androidInterfaceName ?? "GengageNative", a = n.reactNativeInterfaceName ?? "ReactNativeWebView";
89
- return C(e, t) ? "ios" : y(e, d) ? "android" : y(e, a) ? "react-native" : "browser";
90
- }
91
- function U(n, e = {}) {
92
- const t = e.win ?? window;
93
- if (n.sessionId !== void 0) {
94
- t.__gengageSessionId = n.sessionId, t.gengage || (t.gengage = {}), t.gengage.sessionId = n.sessionId;
95
- try {
96
- t.sessionStorage.setItem("gengage_session_id", n.sessionId);
97
- } catch {
98
- }
99
- }
100
- if (n.userId !== void 0) {
101
- t.gengage || (t.gengage = {});
102
- const d = t.gengage, a = d.session ?? {};
103
- a.userId = n.userId, d.session = a;
104
- }
105
- }
106
- function W(n = {}) {
107
- const e = n.win ?? window, t = e;
108
- if (t.gengageNative) return t.gengageNative;
109
- const d = n.iosHandlerName ?? "gengage", a = n.androidInterfaceName ?? "GengageNative", s = n.reactNativeInterfaceName ?? "ReactNativeWebView", f = n.trackedEvents ?? [..._], u = O({
110
- win: e,
111
- iosHandlerName: d,
112
- androidInterfaceName: a,
113
- reactNativeInterfaceName: s
114
- });
115
- let o = e.gengage?.overlay ?? null;
116
- const g = [], m = (r, i) => {
117
- const l = i === void 0 ? { type: r } : {
118
- type: r,
119
- payload: i
120
- };
121
- if (u === "ios") {
122
- C(e, d)?.(l);
123
- return;
124
- }
125
- if (u === "android") {
126
- y(e, a)?.postMessage(JSON.stringify(l));
127
- return;
128
- }
129
- if (u === "react-native") {
130
- y(e, s)?.postMessage(JSON.stringify(l));
131
- return;
132
- }
133
- }, v = (r) => {
134
- const i = r.detail;
135
- !i || typeof i.namespace != "string" || typeof i.type != "string" || m("bridge_message", {
136
- namespace: i.namespace,
137
- type: i.type,
138
- payload: i.payload
139
- });
140
- };
141
- e.addEventListener("gengage:bridge:message", v);
142
- const q = f.map((r) => {
143
- const i = (l) => {
144
- const c = l.detail;
145
- m("widget_event", {
146
- event: r,
147
- detail: c
148
- });
149
- };
150
- return e.addEventListener(r, i), {
151
- event: r,
152
- handler: i
153
- };
154
- }), p = (r) => {
155
- g.length >= S && g.shift(), g.push(r);
156
- }, M = () => {
157
- if (!o || g.length === 0) return;
158
- const r = g.splice(0, g.length);
159
- for (const i of r) I(i);
160
- }, I = (r) => {
161
- const i = A(r);
162
- if (!i || typeof i.type != "string") {
163
- console.warn("[gengage:native-bridge] Invalid message:", r);
164
- return;
165
- }
166
- const l = i.type, c = i.payload;
167
- switch (l) {
168
- case "openChat":
169
- o ? o.openChat(c && typeof c == "object" ? c : c === "half" || c === "full" ? { state: c } : void 0) : p(i);
170
- return;
171
- case "closeChat":
172
- o ? o.closeChat() : p(i);
173
- return;
174
- case "updateContext":
175
- case "updatePageContext":
176
- case "setPageContext":
177
- o && c && typeof c == "object" ? o.updateContext(c) : o ? console.warn(`[gengage:native-bridge] ${l}: missing payload`) : p(i);
178
- return;
179
- case "updateSku": {
180
- const h = L(c);
181
- if (o && h) {
182
- o.updateSku(h.sku, h.pageType);
183
- return;
184
- }
185
- o ? console.warn("[gengage:native-bridge] updateSku: missing sku") : p(i);
186
- return;
187
- }
188
- case "setSession":
189
- c && typeof c == "object" && U(c, { win: e });
190
- return;
191
- case "destroy":
192
- o?.destroy();
193
- return;
194
- default:
195
- e.postMessage({
196
- gengage: "native",
197
- type: l,
198
- payload: c
199
- }, e.location.origin), n.logUnhandled && console.warn("[gengage:native-bridge] Unhandled inbound type forwarded:", l);
200
- }
201
- }, N = {
202
- env: u,
203
- sendToNative: m,
204
- receive: I,
205
- setController(r) {
206
- o = r, M();
207
- },
208
- destroy() {
209
- e.removeEventListener("gengage:bridge:message", v);
210
- for (const r of q) e.removeEventListener(r.event, r.handler);
211
- g.splice(0, g.length), e.gengageNative === N && delete e.gengageNative;
212
- }
213
- };
214
- return t.gengageNative = N, N;
215
- }
216
- async function V(n) {
217
- const { nativeBridge: e, emitReadyEvent: t = !0, ...d } = n, a = W(e), s = { ...d };
218
- s.onAddToCart || (s.onAddToCart = (g) => {
219
- a.sendToNative("addToCart", {
220
- sku: g.sku,
221
- quantity: g.quantity,
222
- cartCode: g.cartCode
223
- });
224
- }), s.onProductNavigate || (s.onProductNavigate = (g, m, v) => {
225
- a.sendToNative("productNavigate", {
226
- url: g,
227
- sku: m,
228
- sessionId: v
229
- });
230
- });
231
- const f = s.qna?.enabled === !0 || s.qna?.mountTarget !== void 0;
232
- if (s.qna?.enabled !== !1)
233
- if (f) {
234
- const g = T(window, s.qna?.mountTarget ?? E, "gengage-qna");
235
- s.qna = {
236
- ...s.qna,
237
- enabled: !0,
238
- mountTarget: g
239
- };
240
- } else b(window, E) || (s.qna = { enabled: !1 });
241
- const u = s.simrel?.enabled === !0 || s.simrel?.mountTarget !== void 0;
242
- if (s.simrel?.enabled !== !1)
243
- if (u) {
244
- const g = T(window, s.simrel?.mountTarget ?? w, "gengage-simrel");
245
- s.simrel = {
246
- ...s.simrel,
247
- enabled: !0,
248
- mountTarget: g
249
- };
250
- } else b(window, w) || (s.simrel = { enabled: !1 });
251
- const o = await k(s);
252
- return a.setController(o), t && a.sendToNative("ready", {
253
- sessionId: o.session.sessionId,
254
- widgets: {
255
- chat: o.chat !== null,
256
- qna: o.qna !== null,
257
- simrel: o.simrel !== null
258
- }
259
- }), {
260
- controller: o,
261
- bridge: a,
262
- destroy() {
263
- o.destroy(), a.destroy();
264
- }
265
- };
266
- }
267
- export {
268
- V as a,
269
- O as i,
270
- U as n,
271
- W as r,
272
- _ as t
273
- };
@@ -1,365 +0,0 @@
1
- import { o as m, r as x } from "./context-UTzCGyR9.js";
2
- var l = {
3
- "--gengage-chat-offset": "20px",
4
- "--gengage-chat-launcher-width": "56px",
5
- "--gengage-chat-launcher-height": "56px",
6
- "--gengage-chat-width": "400px",
7
- "--gengage-chat-shell-radius": "1rem",
8
- "--gengage-chat-header-height": "72px",
9
- "--gengage-chat-conversation-width": "396px",
10
- "--gengage-chat-panel-min-width": "320px",
11
- "--gengage-chat-panel-max-width": "1200px",
12
- "--gengage-chat-input-height": "48px",
13
- "--gengage-qna-pill-radius": "999px",
14
- "--gengage-qna-input-radius": "12px",
15
- "--gengage-simrel-card-radius": "0.75rem",
16
- "--radius-control": "12px",
17
- "--radius-card": "16px",
18
- "--radius-panel": "24px",
19
- "--radius-pill": "999px",
20
- "--surface-card-muted": "#f8fafc",
21
- "--text-secondary": "#4b5563",
22
- "--text-muted": "#6b7280",
23
- "--border-default": "rgba(17, 24, 39, 0.10)"
24
- };
25
- function w(e) {
26
- if (!e) return { ...l };
27
- const t = {
28
- ...l,
29
- ...e
30
- }, r = e["--gengage-chat-launcher-size"];
31
- return r !== void 0 && (e["--gengage-chat-launcher-width"] === void 0 && (t["--gengage-chat-launcher-width"] = r), e["--gengage-chat-launcher-height"] === void 0 && (t["--gengage-chat-launcher-height"] = r)), t;
32
- }
33
- var i = {
34
- primaryColor: "#b7102a",
35
- primaryForeground: "#ffffff",
36
- backgroundColor: "#ffffff",
37
- foregroundColor: "#111827",
38
- borderRadius: "0.75rem",
39
- fontFamily: '"Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
40
- fontSize: "14px",
41
- zIndex: "1000",
42
- "--glov-chatbot-width": "420px",
43
- "--glov-left-spacing": "260px",
44
- "--chatbot-padding": "16px",
45
- "--root-wrapper-background-color": "#f8f9fa",
46
- "--root-wrapper-border-color": "#edeeef",
47
- "--gengage-chat-width": "400px",
48
- "--gengage-chat-shell-radius": "1rem",
49
- "--gengage-chat-header-height": "72px",
50
- "--gengage-chat-conversation-width": "396px",
51
- "--gengage-chat-panel-min-width": "320px",
52
- "--gengage-chat-panel-max-width": "1200px",
53
- "--gengage-chat-input-height": "48px",
54
- "--gengage-qna-pill-radius": "999px",
55
- "--gengage-qna-input-radius": "0.75rem",
56
- "--gengage-simrel-card-radius": "0.75rem",
57
- "--client-primary": "#b7102a",
58
- "--client-primary-hover": "color-mix(in srgb, #b7102a 88%, black 12%)",
59
- "--client-primary-active": "color-mix(in srgb, #b7102a 78%, black 22%)",
60
- "--client-primary-subtle": "color-mix(in srgb, #b7102a 12%, white)",
61
- "--client-primary-soft": "color-mix(in srgb, #b7102a 20%, white)",
62
- "--client-on-primary": "#ffffff",
63
- "--client-focus-ring": "color-mix(in srgb, #b7102a 32%, transparent)",
64
- "--surface-page": "#f6f7fb",
65
- "--surface-shell": "#10131a",
66
- "--surface-card": "#ffffff",
67
- "--surface-card-muted": "#f8fafc",
68
- "--surface-card-soft": "#f8fafc",
69
- "--surface-elevated": "#ffffff",
70
- "--surface-input": "#ffffff",
71
- "--surface-overlay": "rgba(16, 19, 26, 0.52)",
72
- "--text-primary": "#111827",
73
- "--text-secondary": "#4b5563",
74
- "--text-muted": "#6b7280",
75
- "--text-inverse": "#f9fafb",
76
- "--border-subtle": "rgba(17, 24, 39, 0.06)",
77
- "--border-default": "rgba(17, 24, 39, 0.10)",
78
- "--border-strong": "rgba(17, 24, 39, 0.18)",
79
- "--shadow-1": "0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06)",
80
- "--shadow-2": "0 4px 12px rgba(16, 24, 40, 0.08)",
81
- "--shadow-3": "0 10px 24px rgba(16, 24, 40, 0.12)",
82
- "--radius-control": "12px",
83
- "--radius-card": "16px",
84
- "--radius-panel": "24px",
85
- "--radius-pill": "999px",
86
- "--success": "#16a34a",
87
- "--warning": "#d97706",
88
- "--error": "#dc2626",
89
- "--info": "#2563eb",
90
- "--rating": "#f5b301",
91
- "--gengage-brand-accent-start": "#0b24d6",
92
- "--gengage-brand-accent-mid": "#f768f2",
93
- "--gengage-brand-accent-end": "#ffed74",
94
- "--ai-accent-start": "#0b24d6",
95
- "--ai-accent-end": "#f768f2",
96
- "--ai-accent-soft": "linear-gradient(135deg, rgba(11, 36, 214, 0.08), rgba(247, 104, 242, 0.08))"
97
- };
98
- function F(e) {
99
- return {
100
- ...i,
101
- ...e
102
- };
103
- }
104
- var o = "gengage-global-toast-root", u = "gengage-global-toast-style", c = "gengage-global-toast-root--visible", v = 4200, _ = 1500, E = 15e3, T = [
105
- "--gengage-font-family",
106
- "--surface-card",
107
- "--text-primary",
108
- "--text-muted",
109
- "--border-default",
110
- "--radius-card",
111
- "--shadow-3",
112
- "--error",
113
- "--ds-toast-error-bg",
114
- "--ds-toast-error-border",
115
- "--ds-toast-error-accent",
116
- "--ds-toast-error-fg",
117
- "--ds-toast-error-shadow"
118
- ], f = !1, s = null, C = [
119
- /failed to fetch/i,
120
- /networkerror/i,
121
- /network request failed/i,
122
- /load failed/i,
123
- /err_network/i,
124
- /fetch failed/i,
125
- /network error/i
126
- ];
127
- function h(e) {
128
- return typeof e == "string" && e.toLowerCase().startsWith("tr");
129
- }
130
- function I(e) {
131
- if (typeof navigator < "u" && navigator.onLine === !1) return !0;
132
- const t = e instanceof Error ? e.message.trim() : "";
133
- return t ? C.some((r) => r.test(t)) : !1;
134
- }
135
- function H(e, t) {
136
- return I(t) ? h(e) ? "Bağlantı sorunu oluştu. Lütfen tekrar deneyin." : "Connection issue. Please try again." : h(e) ? "Bir hata oluştu. Lütfen tekrar deneyin." : "Something went wrong. Please try again.";
137
- }
138
- function S() {
139
- f || typeof window > "u" || typeof document > "u" || (f = !0, m("gengage:global:error", (e) => {
140
- k(e);
141
- }));
142
- }
143
- function k(e) {
144
- if (typeof document > "u") return;
145
- const t = e.message.trim();
146
- if (!t) return;
147
- A();
148
- const r = $();
149
- M(r), r.innerHTML = "";
150
- const a = document.createElement("section");
151
- a.className = "gengage-global-toast gengage-global-toast--error", a.setAttribute("role", "status"), a.setAttribute("aria-live", "polite");
152
- const n = document.createElement("div");
153
- n.className = "gengage-global-toast-title", n.textContent = R(e.source);
154
- const g = document.createElement("div");
155
- g.className = "gengage-global-toast-message", g.textContent = t, a.appendChild(n), a.appendChild(g), r.appendChild(a), r.classList.add(c), s && (clearTimeout(s), s = null), e.sticky !== !0 && (s = setTimeout(() => {
156
- L();
157
- }, N(e.durationMs)));
158
- }
159
- function L() {
160
- if (typeof document > "u") return;
161
- const e = document.getElementById(o);
162
- e && (e.classList.remove(c), e.innerHTML = "", s && (clearTimeout(s), s = null));
163
- }
164
- function R(e) {
165
- switch (e) {
166
- case "chat":
167
- return "Chat warning";
168
- case "qna":
169
- return "QnA warning";
170
- case "simrel":
171
- return "Widget warning";
172
- default:
173
- return "Connection warning";
174
- }
175
- }
176
- function $() {
177
- const e = document.getElementById(o);
178
- if (e instanceof HTMLElement) return e;
179
- const t = document.createElement("div");
180
- return t.id = o, t.className = "gengage-global-toast-root", document.body.appendChild(t), t;
181
- }
182
- function M(e) {
183
- if (typeof document > "u" || typeof window > "u") return;
184
- const t = document.querySelector(".gengage-chat-root, .gengage-qna-container, .gengage-simrel-container, .gengage-simbut-root");
185
- if (!t) return;
186
- const r = window.getComputedStyle(t);
187
- for (const a of T) {
188
- const n = r.getPropertyValue(a).trim();
189
- n ? e.style.setProperty(a, n) : e.style.removeProperty(a);
190
- }
191
- }
192
- function N(e) {
193
- return typeof e != "number" || !Number.isFinite(e) ? v : Math.min(E, Math.max(_, Math.round(e)));
194
- }
195
- function A() {
196
- if (document.getElementById(u)) return;
197
- const e = document.createElement("style");
198
- e.id = u;
199
- const t = i["--surface-card"] ?? i.backgroundColor ?? "#ffffff", r = i["--text-primary"] ?? i.foregroundColor ?? "#111827", a = i["--border-default"] ?? "rgba(17, 24, 39, 0.10)", n = i["--error"] ?? "#dc2626", g = i["--shadow-3"] ?? "0 10px 24px rgba(16, 24, 40, 0.12)", b = i["--radius-card"] ?? "16px", y = i["--text-muted"] ?? "#6b7280";
200
- e.textContent = `
201
- #${o} {
202
- position: fixed;
203
- top: 16px;
204
- right: 16px;
205
- z-index: 2147483646;
206
- pointer-events: none;
207
- }
208
- #${o}.${c} {
209
- pointer-events: auto;
210
- }
211
- #${o} .gengage-global-toast {
212
- min-width: 260px;
213
- max-width: min(92vw, 420px);
214
- border-radius: var(--radius-card, ${b});
215
- border: 1px solid var(--ds-toast-error-border, color-mix(in srgb, var(--error, ${n}) 18%, var(--border-default, ${a})));
216
- border-left: 4px solid var(--ds-toast-error-accent, var(--error, ${n}));
217
- background: var(--ds-toast-error-bg, color-mix(in srgb, var(--error, ${n}) 5%, var(--surface-card, ${t})));
218
- color: var(--ds-toast-error-fg, color-mix(in srgb, var(--error, ${n}) 22%, var(--text-primary, ${r})));
219
- box-shadow: var(--ds-toast-error-shadow, var(--shadow-3, ${g}));
220
- padding: 10px 12px;
221
- font-family: var(--gengage-font-family, ${JSON.stringify(i.fontFamily ?? '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif')});
222
- font-size: 13px;
223
- line-height: 1.4;
224
- animation: gengage-global-toast-in 180ms ease-out forwards;
225
- }
226
- #${o} .gengage-global-toast-title {
227
- margin: 0 0 4px;
228
- font-size: 12px;
229
- font-weight: 700;
230
- color: var(--text-muted, ${y});
231
- }
232
- #${o} .gengage-global-toast-message {
233
- margin: 0;
234
- font-weight: 500;
235
- }
236
- @keyframes gengage-global-toast-in {
237
- from {
238
- opacity: 0;
239
- transform: translateY(-8px);
240
- }
241
- to {
242
- opacity: 1;
243
- transform: translateY(0);
244
- }
245
- }
246
- `, document.head.appendChild(e);
247
- }
248
- var d = null;
249
- function O() {
250
- if (d !== null) return d;
251
- try {
252
- d = localStorage.getItem("gengage:debug") === "1";
253
- } catch {
254
- d = !1;
255
- }
256
- return d;
257
- }
258
- function p(e, t, r) {
259
- if (!O()) return;
260
- const a = [`[gengage:${e}]`, t];
261
- r !== void 0 && a.push(r), console.debug(...a);
262
- }
263
- var D = ("0.6.50".trim(), "0.6.50".trim()), B = ("package-build".trim(), "package-build".trim());
264
- function G() {
265
- if (typeof window > "u") return;
266
- const e = window;
267
- e.__gengageSdkRuntimeInfoLogged || (e.__gengageSdkRuntimeInfoLogged = !0, console.info(`[gengage] @gengage/assistant-fe v${D} (${B})`));
268
- }
269
- var P = class {
270
- constructor() {
271
- this.isVisible = !1, this.isInitialised = !1, this._handlers = /* @__PURE__ */ new Map(), this._cleanups = [], this._ownsRoot = !1, this._destroying = !1;
272
- }
273
- async init(e) {
274
- if (this.isInitialised) {
275
- console.warn("[gengage] Widget already initialised. Call update() instead.");
276
- return;
277
- }
278
- const t = w(e.theme);
279
- G(), this.config = {
280
- ...e,
281
- theme: t,
282
- session: x(e.session)
283
- }, this.root = this._resolveMount(e.mountTarget), this._applyTheme(t), S();
284
- const r = m("gengage:context:update", (a) => this.update(a));
285
- this._cleanups.push(r), p("lifecycle", `${this.constructor.name}.init`, {
286
- accountId: e.accountId,
287
- sku: e.pageContext?.sku
288
- });
289
- try {
290
- await this.onInit(this.config);
291
- } catch (a) {
292
- throw this.destroy(), a;
293
- }
294
- this._destroying || (this.isInitialised = !0, p("lifecycle", `${this.constructor.name} ready`), this.emit("ready"));
295
- }
296
- update(e) {
297
- this.isInitialised && (this.config.pageContext ? this.config = {
298
- ...this.config,
299
- pageContext: {
300
- ...this.config.pageContext,
301
- ...e
302
- }
303
- } : e.pageType !== void 0 && (this.config = {
304
- ...this.config,
305
- pageContext: e
306
- }), this.onUpdate(e), this.emit("context-update", this.config.pageContext));
307
- }
308
- show() {
309
- this.isVisible || (this.isVisible = !0, this.root.style.display = "", this.onShow(), this.emit("show"));
310
- }
311
- hide() {
312
- this.isVisible && (this.isVisible = !1, this.root.style.display = "none", this.onHide(), this.emit("hide"));
313
- }
314
- destroy() {
315
- this._destroying || (this._destroying = !0, this.emit("destroy"), this._cleanups.forEach((e) => e()), this._cleanups.length = 0, this._handlers.clear(), this.onDestroy(), this._cleanupRoot(), this.isInitialised = !1);
316
- }
317
- _cleanupRoot() {
318
- this._ownsRoot ? this.root.remove() : this.root.innerHTML = "";
319
- }
320
- on(e, t) {
321
- return this._handlers.has(e) || this._handlers.set(e, /* @__PURE__ */ new Set()), this._handlers.get(e).add(t), () => this._handlers.get(e)?.delete(t);
322
- }
323
- emit(e, ...t) {
324
- this._handlers.get(e)?.forEach((r) => r(...t));
325
- }
326
- addCleanup(e) {
327
- this._cleanups.push(e);
328
- }
329
- _resolveMount(e) {
330
- if (e instanceof HTMLElement) return e;
331
- if (typeof e == "string") {
332
- const r = document.querySelector(e);
333
- if (!r) throw new Error(`[gengage] Mount target not found: "${e}"`);
334
- return r;
335
- }
336
- const t = document.createElement("div");
337
- return t.dataset.gengageWidget = this.constructor.name.toLowerCase(), document.body.insertBefore(t, document.body.firstChild), this._ownsRoot = !0, t;
338
- }
339
- _applyTheme(e) {
340
- if (e) {
341
- for (const [t, r] of Object.entries(e)) if (r !== void 0) {
342
- const a = t.startsWith("--") ? t : `--gengage-${V(t)}`;
343
- this.root.style.setProperty(a, r);
344
- }
345
- }
346
- }
347
- };
348
- function V(e) {
349
- return e.replace(/([A-Z])/g, "-$1").toLowerCase();
350
- }
351
- export {
352
- L as a,
353
- S as c,
354
- F as d,
355
- l as f,
356
- p as i,
357
- k as l,
358
- B as n,
359
- H as o,
360
- w as p,
361
- D as r,
362
- I as s,
363
- P as t,
364
- i as u
365
- };