@gengage/assistant-fe 0.4.21 → 0.5.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 (34) hide show
  1. package/README.md +1 -1
  2. package/dist/{api-paths-Bg6iwO5w.js → api-paths-y5nkfEBG.js} +1 -1
  3. package/dist/chat-runtime.js +1 -1
  4. package/dist/chat.iife.js +43 -43
  5. package/dist/chat.js +1 -1
  6. package/dist/common-BKPSOoIP.js +324 -0
  7. package/dist/common.js +64 -81
  8. package/dist/{connection-warning-BeD-B0Ec.js → connection-warning-DJiyLM46.js} +1 -1
  9. package/dist/{fastIntent-BeeDIwd2.js → fastIntent-1T2g9art.js} +2 -2
  10. package/dist/index.js +49 -52
  11. package/dist/{native-webview-Bbcvvi_5.js → native-webview-y3a9R9hH.js} +1 -1
  12. package/dist/native.iife.js +23 -23
  13. package/dist/native.js +1 -1
  14. package/dist/{overlay-O4nlUrzw.js → overlay-v3nvcGlE.js} +2 -5
  15. package/dist/overlay.js +2 -2
  16. package/dist/qna-runtime.js +1 -1
  17. package/dist/qna.iife.js +36 -36
  18. package/dist/qna.js +1 -1
  19. package/dist/{runtime-C8ZBidd2.js → runtime-BMNOS2Mq.js} +176 -196
  20. package/dist/runtime-DOS9yRRx.js +650 -0
  21. package/dist/{runtime-Ct1qOl8V.js → runtime-DsP6go8z.js} +2194 -2225
  22. package/dist/{simbut-BrAeZ6SH.js → simbut-BwxzoBcY.js} +7 -7
  23. package/dist/simbut.iife.js +12 -12
  24. package/dist/simbut.js +1 -1
  25. package/dist/{simrel-Cha5de6P.js → simrel-C07wZN8Q.js} +2 -2
  26. package/dist/simrel-runtime.js +1 -1
  27. package/dist/simrel.iife.js +35 -35
  28. package/dist/simrel.js +2 -2
  29. package/dist/widget-base-Dliq3QAf.js +362 -0
  30. package/package.json +1 -2
  31. package/dist/common-DDJSeQhg.js +0 -491
  32. package/dist/runtime-CRSFPLku.js +0 -688
  33. package/dist/widget-base-BtBl_PCR.js +0 -589
  34. /package/dist/{context-DGz5F81j.js → context-BBuSsXZ9.js} +0 -0
package/dist/simrel.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a, i as r, n as t, r as i, t as m } from "./runtime-CRSFPLku.js";
2
- import { n as R, t as n } from "./simrel-Cha5de6P.js";
1
+ import { a, i as r, n as t, r as i, t as m } from "./runtime-DOS9yRRx.js";
2
+ import { n as R, t as n } from "./simrel-C07wZN8Q.js";
3
3
  export {
4
4
  m as GengageSimRel,
5
5
  i as createDefaultSimRelUISpecRegistry,
@@ -0,0 +1,362 @@
1
+ import { o as m, r as x } from "./context-BBuSsXZ9.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
+ "--ai-accent-start": "#0b24d6",
92
+ "--ai-accent-end": "#f768f2",
93
+ "--ai-accent-soft": "linear-gradient(135deg, rgba(11, 36, 214, 0.08), rgba(247, 104, 242, 0.08))"
94
+ };
95
+ function F(e) {
96
+ return {
97
+ ...i,
98
+ ...e
99
+ };
100
+ }
101
+ var o = "gengage-global-toast-root", u = "gengage-global-toast-style", c = "gengage-global-toast-root--visible", v = 4200, _ = 1500, E = 15e3, T = [
102
+ "--gengage-font-family",
103
+ "--surface-card",
104
+ "--text-primary",
105
+ "--text-muted",
106
+ "--border-default",
107
+ "--radius-card",
108
+ "--shadow-3",
109
+ "--error",
110
+ "--ds-toast-error-bg",
111
+ "--ds-toast-error-border",
112
+ "--ds-toast-error-accent",
113
+ "--ds-toast-error-fg",
114
+ "--ds-toast-error-shadow"
115
+ ], f = !1, s = null, C = [
116
+ /failed to fetch/i,
117
+ /networkerror/i,
118
+ /network request failed/i,
119
+ /load failed/i,
120
+ /err_network/i,
121
+ /fetch failed/i,
122
+ /network error/i
123
+ ];
124
+ function h(e) {
125
+ return typeof e == "string" && e.toLowerCase().startsWith("tr");
126
+ }
127
+ function I(e) {
128
+ if (typeof navigator < "u" && navigator.onLine === !1) return !0;
129
+ const t = e instanceof Error ? e.message.trim() : "";
130
+ return t ? C.some((r) => r.test(t)) : !1;
131
+ }
132
+ function H(e, t) {
133
+ 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.";
134
+ }
135
+ function S() {
136
+ f || typeof window > "u" || typeof document > "u" || (f = !0, m("gengage:global:error", (e) => {
137
+ k(e);
138
+ }));
139
+ }
140
+ function k(e) {
141
+ if (typeof document > "u") return;
142
+ const t = e.message.trim();
143
+ if (!t) return;
144
+ A();
145
+ const r = $();
146
+ M(r), r.innerHTML = "";
147
+ const a = document.createElement("section");
148
+ a.className = "gengage-global-toast gengage-global-toast--error", a.setAttribute("role", "status"), a.setAttribute("aria-live", "polite");
149
+ const n = document.createElement("div");
150
+ n.className = "gengage-global-toast-title", n.textContent = R(e.source);
151
+ const g = document.createElement("div");
152
+ 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(() => {
153
+ L();
154
+ }, N(e.durationMs)));
155
+ }
156
+ function L() {
157
+ if (typeof document > "u") return;
158
+ const e = document.getElementById(o);
159
+ e && (e.classList.remove(c), e.innerHTML = "", s && (clearTimeout(s), s = null));
160
+ }
161
+ function R(e) {
162
+ switch (e) {
163
+ case "chat":
164
+ return "Chat warning";
165
+ case "qna":
166
+ return "QnA warning";
167
+ case "simrel":
168
+ return "Widget warning";
169
+ default:
170
+ return "Connection warning";
171
+ }
172
+ }
173
+ function $() {
174
+ const e = document.getElementById(o);
175
+ if (e instanceof HTMLElement) return e;
176
+ const t = document.createElement("div");
177
+ return t.id = o, t.className = "gengage-global-toast-root", document.body.appendChild(t), t;
178
+ }
179
+ function M(e) {
180
+ if (typeof document > "u" || typeof window > "u") return;
181
+ const t = document.querySelector(".gengage-chat-root, .gengage-qna-container, .gengage-simrel-container, .gengage-simbut-root");
182
+ if (!t) return;
183
+ const r = window.getComputedStyle(t);
184
+ for (const a of T) {
185
+ const n = r.getPropertyValue(a).trim();
186
+ n ? e.style.setProperty(a, n) : e.style.removeProperty(a);
187
+ }
188
+ }
189
+ function N(e) {
190
+ return typeof e != "number" || !Number.isFinite(e) ? v : Math.min(E, Math.max(_, Math.round(e)));
191
+ }
192
+ function A() {
193
+ if (document.getElementById(u)) return;
194
+ const e = document.createElement("style");
195
+ e.id = u;
196
+ 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";
197
+ e.textContent = `
198
+ #${o} {
199
+ position: fixed;
200
+ top: 16px;
201
+ right: 16px;
202
+ z-index: 2147483646;
203
+ pointer-events: none;
204
+ }
205
+ #${o}.${c} {
206
+ pointer-events: auto;
207
+ }
208
+ #${o} .gengage-global-toast {
209
+ min-width: 260px;
210
+ max-width: min(92vw, 420px);
211
+ border-radius: var(--radius-card, ${b});
212
+ border: 1px solid var(--ds-toast-error-border, color-mix(in srgb, var(--error, ${n}) 18%, var(--border-default, ${a})));
213
+ border-left: 4px solid var(--ds-toast-error-accent, var(--error, ${n}));
214
+ background: var(--ds-toast-error-bg, color-mix(in srgb, var(--error, ${n}) 5%, var(--surface-card, ${t})));
215
+ color: var(--ds-toast-error-fg, color-mix(in srgb, var(--error, ${n}) 22%, var(--text-primary, ${r})));
216
+ box-shadow: var(--ds-toast-error-shadow, var(--shadow-3, ${g}));
217
+ padding: 10px 12px;
218
+ font-family: var(--gengage-font-family, ${JSON.stringify(i.fontFamily ?? '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif')});
219
+ font-size: 13px;
220
+ line-height: 1.4;
221
+ animation: gengage-global-toast-in 180ms ease-out forwards;
222
+ }
223
+ #${o} .gengage-global-toast-title {
224
+ margin: 0 0 4px;
225
+ font-size: 12px;
226
+ font-weight: 700;
227
+ color: var(--text-muted, ${y});
228
+ }
229
+ #${o} .gengage-global-toast-message {
230
+ margin: 0;
231
+ font-weight: 500;
232
+ }
233
+ @keyframes gengage-global-toast-in {
234
+ from {
235
+ opacity: 0;
236
+ transform: translateY(-8px);
237
+ }
238
+ to {
239
+ opacity: 1;
240
+ transform: translateY(0);
241
+ }
242
+ }
243
+ `, document.head.appendChild(e);
244
+ }
245
+ var d = null;
246
+ function O() {
247
+ if (d !== null) return d;
248
+ try {
249
+ d = localStorage.getItem("gengage:debug") === "1";
250
+ } catch {
251
+ d = !1;
252
+ }
253
+ return d;
254
+ }
255
+ function p(e, t, r) {
256
+ if (!O()) return;
257
+ const a = [`[gengage:${e}]`, t];
258
+ r !== void 0 && a.push(r), console.debug(...a);
259
+ }
260
+ var D = ("0.5.0".trim(), "0.5.0".trim()), B = ("package-build".trim(), "package-build".trim());
261
+ function G() {
262
+ if (typeof window > "u") return;
263
+ const e = window;
264
+ e.__gengageSdkRuntimeInfoLogged || (e.__gengageSdkRuntimeInfoLogged = !0, console.info(`[gengage] @gengage/assistant-fe v${D} (${B})`));
265
+ }
266
+ var P = class {
267
+ constructor() {
268
+ this.isVisible = !1, this.isInitialised = !1, this._handlers = /* @__PURE__ */ new Map(), this._cleanups = [], this._ownsRoot = !1, this._destroying = !1;
269
+ }
270
+ async init(e) {
271
+ if (this.isInitialised) {
272
+ console.warn("[gengage] Widget already initialised. Call update() instead.");
273
+ return;
274
+ }
275
+ const t = w(e.theme);
276
+ G(), this.config = {
277
+ ...e,
278
+ theme: t,
279
+ session: x(e.session)
280
+ }, this.root = this._resolveMount(e.mountTarget), this._applyTheme(t), S();
281
+ const r = m("gengage:context:update", (a) => this.update(a));
282
+ this._cleanups.push(r), p("lifecycle", `${this.constructor.name}.init`, {
283
+ accountId: e.accountId,
284
+ sku: e.pageContext?.sku
285
+ });
286
+ try {
287
+ await this.onInit(this.config);
288
+ } catch (a) {
289
+ throw this.destroy(), a;
290
+ }
291
+ this._destroying || (this.isInitialised = !0, p("lifecycle", `${this.constructor.name} ready`), this.emit("ready"));
292
+ }
293
+ update(e) {
294
+ this.isInitialised && (this.config.pageContext ? this.config = {
295
+ ...this.config,
296
+ pageContext: {
297
+ ...this.config.pageContext,
298
+ ...e
299
+ }
300
+ } : e.pageType !== void 0 && (this.config = {
301
+ ...this.config,
302
+ pageContext: e
303
+ }), this.onUpdate(e), this.emit("context-update", this.config.pageContext));
304
+ }
305
+ show() {
306
+ this.isVisible || (this.isVisible = !0, this.root.style.display = "", this.onShow(), this.emit("show"));
307
+ }
308
+ hide() {
309
+ this.isVisible && (this.isVisible = !1, this.root.style.display = "none", this.onHide(), this.emit("hide"));
310
+ }
311
+ destroy() {
312
+ 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);
313
+ }
314
+ _cleanupRoot() {
315
+ this._ownsRoot ? this.root.remove() : this.root.innerHTML = "";
316
+ }
317
+ on(e, t) {
318
+ return this._handlers.has(e) || this._handlers.set(e, /* @__PURE__ */ new Set()), this._handlers.get(e).add(t), () => this._handlers.get(e)?.delete(t);
319
+ }
320
+ emit(e, ...t) {
321
+ this._handlers.get(e)?.forEach((r) => r(...t));
322
+ }
323
+ addCleanup(e) {
324
+ this._cleanups.push(e);
325
+ }
326
+ _resolveMount(e) {
327
+ if (e instanceof HTMLElement) return e;
328
+ if (typeof e == "string") {
329
+ const r = document.querySelector(e);
330
+ if (!r) throw new Error(`[gengage] Mount target not found: "${e}"`);
331
+ return r;
332
+ }
333
+ const t = document.createElement("div");
334
+ return t.dataset.gengageWidget = this.constructor.name.toLowerCase(), document.body.insertBefore(t, document.body.firstChild), this._ownsRoot = !0, t;
335
+ }
336
+ _applyTheme(e) {
337
+ if (e) {
338
+ for (const [t, r] of Object.entries(e)) if (r !== void 0) {
339
+ const a = t.startsWith("--") ? t : `--gengage-${V(t)}`;
340
+ this.root.style.setProperty(a, r);
341
+ }
342
+ }
343
+ }
344
+ };
345
+ function V(e) {
346
+ return e.replace(/([A-Z])/g, "-$1").toLowerCase();
347
+ }
348
+ export {
349
+ L as a,
350
+ S as c,
351
+ F as d,
352
+ l as f,
353
+ p as i,
354
+ k as l,
355
+ B as n,
356
+ H as o,
357
+ w as p,
358
+ D as r,
359
+ I as s,
360
+ P as t,
361
+ i as u
362
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gengage/assistant-fe",
3
- "version": "0.4.21",
3
+ "version": "0.5.0",
4
4
  "description": "Source-available frontend widgets for Gengage AI Assistant — chat, Q&A, and similar-products. Backend is SaaS (gengage.ai).",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -179,7 +179,6 @@
179
179
  }
180
180
  },
181
181
  "dependencies": {
182
- "@json-render/core": "^0.19.0",
183
182
  "zod": "^4.3.6"
184
183
  },
185
184
  "overrides": {