@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.
- package/README.md +6 -22
- package/dist/agentic/adaptor/create-adaptor.d.ts +19 -0
- package/dist/agentic/adaptor/fetch-bridge.d.ts +11 -0
- package/dist/agentic/adaptor/mount.d.ts +38 -0
- package/dist/agentic/context/chat-context.d.ts +15 -0
- package/dist/agentic/context/context-store.d.ts +20 -0
- package/dist/agentic/context/persistence.d.ts +12 -0
- package/dist/agentic/events/builders.d.ts +10 -0
- package/dist/agentic/events/error-taxonomy.d.ts +27 -0
- package/dist/agentic/events/product-normalize.d.ts +47 -0
- package/dist/agentic/events/ui-specs.d.ts +37 -0
- package/dist/agentic/flow/beauty-consulting-turn.d.ts +1 -0
- package/dist/agentic/flow/create-flow.d.ts +2 -0
- package/dist/agentic/flow/dispatch.d.ts +3 -0
- package/dist/agentic/index.d.ts +18 -0
- package/dist/agentic/index.js +624 -0
- package/dist/agentic/types.d.ts +212 -0
- package/dist/agentic/util/assistant-host.d.ts +11 -0
- package/dist/agentic/util/be-url.d.ts +4 -0
- package/dist/agentic/util/browser-memory.d.ts +13 -0
- package/dist/agentic/util/browser-tools.d.ts +31 -0
- package/dist/agentic/util/lazy-runtime-loader.d.ts +9 -0
- package/dist/agentic/util/request-text.d.ts +3 -0
- package/dist/agentic/util/time.d.ts +2 -0
- package/dist/agentic/worker/be-client.d.ts +15 -0
- package/dist/agentic/worker/entry.d.ts +2 -0
- package/dist/agentic/worker/flow-runner.d.ts +24 -0
- package/dist/agentic/worker/jwt-mint.d.ts +21 -0
- package/dist/agentic/worker/rpc.d.ts +24 -0
- package/dist/agentic/worker/tool-bridge.d.ts +2 -0
- package/dist/agentic/worker.d.ts +16 -0
- package/dist/agentic/worker.js +119 -0
- package/dist/agentic.iife.js +5 -0
- package/dist/{api-paths-CwzwbgQZ.js → api-paths-C4WzXzyY.js} +1 -1
- package/dist/beauty-consulting-turn-BmPXbkQg.js +1019 -0
- package/dist/chat/api.d.ts +17 -0
- package/dist/chat/assistant-mode.d.ts +20 -0
- package/dist/chat/attachment-utils.d.ts +9 -0
- package/dist/chat/catalog.d.ts +455 -0
- package/dist/chat/chat-presentation-state.d.ts +53 -0
- package/dist/chat/components/AIGroupingCards.d.ts +15 -0
- package/dist/chat/components/AISuggestedSearchCards.d.ts +13 -0
- package/dist/chat/components/AITopPicks.d.ts +9 -0
- package/dist/chat/components/BeautyPhotoStep.d.ts +31 -0
- package/dist/chat/components/CategoriesContainer.d.ts +11 -0
- package/dist/chat/components/ChatDrawer.d.ts +362 -0
- package/dist/chat/components/ChoicePrompter.d.ts +21 -0
- package/dist/chat/components/ComparisonTable.d.ts +66 -0
- package/dist/chat/components/ConsultingStylePicker.d.ts +40 -0
- package/dist/chat/components/FloatingComparisonButton.d.ts +7 -0
- package/dist/chat/components/FloatingLauncher.d.ts +79 -0
- package/dist/chat/components/GroundingReviewCard.d.ts +11 -0
- package/dist/chat/components/HandoffNotice.d.ts +9 -0
- package/dist/chat/components/KvkkBanner.d.ts +6 -0
- package/dist/chat/components/Launcher.d.ts +28 -0
- package/dist/chat/components/PanelRestoreCard.d.ts +4 -0
- package/dist/chat/components/PanelTopBar.d.ts +32 -0
- package/dist/chat/components/PhotoAnalysisCard.d.ts +27 -0
- package/dist/chat/components/ProductSummaryCard.d.ts +12 -0
- package/dist/chat/components/ProsAndCons.d.ts +8 -0
- package/dist/chat/components/ReviewHighlights.d.ts +16 -0
- package/dist/chat/components/actionClassifier.d.ts +12 -0
- package/dist/chat/components/product-price-layout.d.ts +17 -0
- package/dist/chat/components/productMentionLinker.d.ts +26 -0
- package/dist/chat/components/renderUISpec.d.ts +15 -0
- package/dist/chat/components/typewriter.d.ts +24 -0
- package/dist/chat/extendedModeManager.d.ts +32 -0
- package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +38 -0
- package/dist/chat/features/beauty-consulting/drawer-extensions.d.ts +22 -0
- package/dist/chat/features/beauty-consulting/mode-controller.d.ts +59 -0
- package/dist/chat/features/beauty-consulting/registry.d.ts +9 -0
- package/dist/chat/features/beauty-consulting/stream-handler.d.ts +45 -0
- package/dist/chat/history-storage.d.ts +85 -0
- package/dist/chat/index.d.ts +6 -0
- package/dist/chat/kvkk.d.ts +20 -0
- package/dist/chat/locales/en.d.ts +2 -0
- package/dist/chat/locales/index.d.ts +5 -0
- package/dist/chat/locales/tr.d.ts +2 -0
- package/dist/chat/panel-manager.d.ts +142 -0
- package/dist/chat/runtime.d.ts +417 -0
- package/dist/chat/session-persistence.d.ts +73 -0
- package/dist/chat/stream-error-display.d.ts +6 -0
- package/dist/chat/types.d.ts +547 -0
- package/dist/chat/utils/chat-presentation-debug.d.ts +18 -0
- package/dist/chat/utils/get-chat-scroll-element.d.ts +10 -0
- package/dist/chat/utils/ui.d.ts +10 -0
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +12 -12
- package/dist/chat.js +1 -1
- package/dist/common/action-router.d.ts +26 -0
- package/dist/common/api-paths.d.ts +23 -0
- package/dist/common/client.d.ts +27 -0
- package/dist/common/communication-bridge.d.ts +51 -0
- package/dist/common/config-constants.d.ts +1 -0
- package/dist/common/config-schema.d.ts +54 -0
- package/dist/common/connection-warning.d.ts +8 -0
- package/dist/common/consulting-sources.d.ts +8 -0
- package/dist/common/context.d.ts +64 -0
- package/dist/common/css-escape.d.ts +1 -0
- package/dist/common/customization-factories.d.ts +59 -0
- package/dist/common/debug.d.ts +13 -0
- package/dist/common/events.d.ts +55 -0
- package/dist/common/fastIntent.d.ts +1 -0
- package/dist/common/find-similar-payload.d.ts +3 -0
- package/dist/common/ga-datalayer.d.ts +80 -0
- package/dist/common/global-error-toast.d.ts +6 -0
- package/dist/common/index.d.ts +47 -0
- package/dist/common/indexed-db.d.ts +89 -0
- package/dist/common/locale.d.ts +1 -0
- package/dist/common/native-webview.d.ts +60 -0
- package/dist/common/navigation.d.ts +1 -0
- package/dist/common/overlay.d.ts +172 -0
- package/dist/common/page-detect.d.ts +36 -0
- package/dist/common/pill-launcher.d.ts +51 -0
- package/dist/common/preflight.d.ts +13 -0
- package/dist/common/price-formatter.d.ts +35 -0
- package/dist/common/product-utils.d.ts +35 -0
- package/dist/common/protocol-adapter.d.ts +108 -0
- package/dist/common/renderer/dom.d.ts +3 -0
- package/dist/common/renderer/index.d.ts +4 -0
- package/dist/common/renderer/overrides.d.ts +23 -0
- package/dist/common/renderer/registry.d.ts +2 -0
- package/dist/common/renderer/types.d.ts +19 -0
- package/dist/common/safe-html.d.ts +22 -0
- package/dist/common/sdk-version.d.ts +3 -0
- package/dist/common/streaming.d.ts +52 -0
- package/dist/common/suggested-search-keywords.d.ts +18 -0
- package/dist/common/theme-utils.d.ts +15 -0
- package/dist/common/transport.d.ts +75 -0
- package/dist/common/tts-player.d.ts +13 -0
- package/dist/common/types.d.ts +379 -0
- package/dist/common/ui-theme.d.ts +9 -0
- package/dist/common/uuidv7.d.ts +7 -0
- package/dist/common/voice-input.d.ts +74 -0
- package/dist/common/widget-base.d.ts +82 -0
- package/dist/{common-KpJP1YwP.js → common-DstAcheX.js} +90 -139
- package/dist/common.js +41 -41
- package/dist/{connection-warning-B5T_1oBn.js → connection-warning-Ddr91Y9x.js} +1 -1
- package/dist/{fastIntent--Ukm2nOh.js → fastIntent-XtUvISni.js} +199 -137
- package/dist/index.d.ts +25 -0
- package/dist/index.js +50 -50
- package/dist/native/index.d.ts +2 -0
- package/dist/{native-webview-qfjm4SHx.js → native-webview-JDC1vtde.js} +1 -1
- package/dist/native.iife.js +14 -14
- package/dist/native.js +1 -1
- package/dist/{overlay-CP5A0Hhf.js → overlay-BetAvpVZ.js} +19 -19
- package/dist/overlay.d.ts +4 -0
- package/dist/overlay.js +1 -1
- package/dist/qna/api.d.ts +23 -0
- package/dist/qna/catalog.d.ts +60 -0
- package/dist/qna/components/ButtonRow.d.ts +15 -0
- package/dist/qna/components/TextInput.d.ts +11 -0
- package/dist/qna/components/renderUISpec.d.ts +7 -0
- package/dist/qna/index.d.ts +3 -0
- package/dist/qna/locales/en.d.ts +2 -0
- package/dist/qna/locales/index.d.ts +4 -0
- package/dist/qna/locales/tr.d.ts +2 -0
- package/dist/qna/normalize-ui-specs.d.ts +15 -0
- package/dist/qna/runtime.d.ts +73 -0
- package/dist/qna/types.d.ts +98 -0
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +1 -1
- package/dist/qna.js +1 -1
- package/dist/{runtime-G3idwfkM.js → runtime-C66Wp6OR.js} +967 -923
- package/dist/{runtime-C3yOvNFK.js → runtime-CcA_r8pw.js} +3 -3
- package/dist/{runtime-BPyXOyyp.js → runtime-DJMUL882.js} +3 -3
- package/dist/simbut/index.d.ts +31 -0
- package/dist/simbut/locales.d.ts +3 -0
- package/dist/simbut/types.d.ts +43 -0
- package/dist/{simbut-CiknJI6-.js → simbut-B6L3fwI7.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/simrel/api.d.ts +25 -0
- package/dist/simrel/catalog.d.ts +77 -0
- package/dist/simrel/components/GroupTabs.d.ts +24 -0
- package/dist/simrel/components/ProductCard.d.ts +19 -0
- package/dist/simrel/components/ProductGrid.d.ts +17 -0
- package/dist/simrel/components/renderUISpec.d.ts +7 -0
- package/dist/simrel/index.d.ts +5 -0
- package/dist/simrel/locales/en.d.ts +2 -0
- package/dist/simrel/locales/index.d.ts +4 -0
- package/dist/simrel/locales/tr.d.ts +2 -0
- package/dist/simrel/renderers/default.d.ts +41 -0
- package/dist/simrel/runtime.d.ts +68 -0
- package/dist/simrel/types.d.ts +145 -0
- package/dist/{simrel-C1YN71aW.js → simrel-BB4Jrr32.js} +1 -1
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.iife.js +1 -1
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-UmvgIqDk.js → widget-base-B3Oq8pjs.js} +1 -1
- package/package.json +21 -39
|
@@ -1,131 +1,187 @@
|
|
|
1
1
|
import { j as S } from "./context-BBuSsXZ9.js";
|
|
2
|
-
import { i as
|
|
3
|
-
function
|
|
2
|
+
import { i as E } from "./widget-base-B3Oq8pjs.js";
|
|
3
|
+
function $(t, r) {
|
|
4
4
|
if (typeof window > "u" || !S(t)) return !1;
|
|
5
|
-
const
|
|
6
|
-
detail:
|
|
5
|
+
const e = new CustomEvent("gengage:navigate", {
|
|
6
|
+
detail: r === void 0 ? { url: t } : {
|
|
7
7
|
url: t,
|
|
8
|
-
newTab:
|
|
8
|
+
newTab: r
|
|
9
9
|
},
|
|
10
10
|
cancelable: !0
|
|
11
11
|
});
|
|
12
|
-
return window.dispatchEvent(
|
|
12
|
+
return window.dispatchEvent(e) ? (r ? window.open(t, "_blank", "noopener,noreferrer") : window.location.href = t, !0) : !1;
|
|
13
13
|
}
|
|
14
|
-
var
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
switch (
|
|
14
|
+
var U = console;
|
|
15
|
+
function Z(t, r, e = {}) {
|
|
16
|
+
const n = t.action, i = e.logger ?? U;
|
|
17
|
+
switch (E("action", `routing action: ${n.kind}`, n), n.kind) {
|
|
18
18
|
case "open_chat":
|
|
19
|
-
|
|
19
|
+
r.openChat?.(n.payload);
|
|
20
20
|
return;
|
|
21
21
|
case "navigate": {
|
|
22
|
-
if (typeof
|
|
23
|
-
|
|
22
|
+
if (typeof n.url != "string") {
|
|
23
|
+
g(n, r, e, i);
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
if (!S(
|
|
27
|
-
|
|
26
|
+
if (!S(n.url)) {
|
|
27
|
+
i.warn("[gengage] Blocked navigation to unsafe URL:", n.url);
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
url:
|
|
34
|
-
...
|
|
30
|
+
const a = typeof n.newTab == "boolean" ? n.newTab : void 0;
|
|
31
|
+
if (r.navigate) {
|
|
32
|
+
r.navigate({
|
|
33
|
+
url: n.url,
|
|
34
|
+
...a !== void 0 && { newTab: a }
|
|
35
35
|
});
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
(
|
|
38
|
+
(e.defaultNavigate ?? L)(n.url, a);
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
case "save_session":
|
|
42
|
-
if (typeof
|
|
43
|
-
|
|
42
|
+
if (typeof n.sessionId != "string" || typeof n.sku != "string") {
|
|
43
|
+
g(n, r, e, i);
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
sessionId:
|
|
48
|
-
sku:
|
|
46
|
+
r.saveSession?.({
|
|
47
|
+
sessionId: n.sessionId,
|
|
48
|
+
sku: n.sku
|
|
49
49
|
});
|
|
50
50
|
return;
|
|
51
51
|
case "add_to_cart":
|
|
52
|
-
if (typeof
|
|
53
|
-
|
|
52
|
+
if (typeof n.sku != "string" || typeof n.quantity != "number" || typeof n.cartCode != "string") {
|
|
53
|
+
g(n, r, e, i);
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
sku:
|
|
58
|
-
quantity:
|
|
59
|
-
cartCode:
|
|
56
|
+
r.addToCart?.({
|
|
57
|
+
sku: n.sku,
|
|
58
|
+
quantity: n.quantity,
|
|
59
|
+
cartCode: n.cartCode
|
|
60
60
|
});
|
|
61
61
|
return;
|
|
62
62
|
case "script_call": {
|
|
63
|
-
if (
|
|
64
|
-
|
|
63
|
+
if (e.allowScriptCall === !1) {
|
|
64
|
+
g(n, r, e, i);
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
if (typeof
|
|
68
|
-
|
|
67
|
+
if (typeof n.name != "string") {
|
|
68
|
+
g(n, r, e, i);
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
name:
|
|
74
|
-
...
|
|
71
|
+
const a = j(n.payload) ? n.payload : void 0;
|
|
72
|
+
r.scriptCall?.({
|
|
73
|
+
name: n.name,
|
|
74
|
+
...a !== void 0 && { payload: a }
|
|
75
75
|
});
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
default:
|
|
79
|
-
|
|
79
|
+
g(n, r, e, i);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
|
|
82
|
+
function g(t, r, e, n) {
|
|
83
|
+
const i = e.unknownActionPolicy ?? "log-and-ignore";
|
|
84
|
+
if (i === "delegate") {
|
|
85
|
+
r.unknown?.(t), r.unknown || n.warn("[gengage] Unknown action received without delegate handler", t);
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
if (
|
|
89
|
-
|
|
88
|
+
if (i === "throw") throw new Error(`[gengage] Unknown action kind: ${t.kind}`);
|
|
89
|
+
n.warn("[gengage] Unknown action ignored", t);
|
|
90
90
|
}
|
|
91
|
-
function L(t,
|
|
91
|
+
function L(t, r) {
|
|
92
92
|
if (!(typeof window > "u")) {
|
|
93
93
|
if (!S(t)) {
|
|
94
94
|
console.warn("[gengage] Blocked navigation to unsafe URL:", t);
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
$(t, r);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function j(t) {
|
|
101
101
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
const
|
|
105
|
-
if (typeof
|
|
106
|
-
const
|
|
107
|
-
return
|
|
108
|
-
const
|
|
109
|
-
return
|
|
103
|
+
function D(t) {
|
|
104
|
+
const r = globalThis.CSS?.escape;
|
|
105
|
+
if (typeof r == "function") return r(t);
|
|
106
|
+
const e = Array.from(t);
|
|
107
|
+
return e.map((n, i) => {
|
|
108
|
+
const a = n.codePointAt(0);
|
|
109
|
+
return a === void 0 ? "" : a === 0 ? "�" : a >= 1 && a <= 31 || a === 127 || i === 0 && a >= 48 && a <= 57 || i === 1 && e[0] === "-" && a >= 48 && a <= 57 ? `\\${a.toString(16)} ` : i === 0 && n === "-" && e.length === 1 ? "\\-" : a >= 128 || /[A-Za-z0-9_-]/.test(n) ? n : `\\${n}`;
|
|
110
110
|
}).join("");
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
var Q = "tr";
|
|
113
|
+
function P(t) {
|
|
114
|
+
if (!(typeof window > "u" || !t))
|
|
115
|
+
try {
|
|
116
|
+
const r = window.GengageAssistantInjector?.[t]?.streamTransport;
|
|
117
|
+
return typeof r == "function" ? r : void 0;
|
|
118
|
+
} catch {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function k(t) {
|
|
123
|
+
return t.injectorAdapter ?? P(t.accountId);
|
|
124
|
+
}
|
|
125
|
+
function X(t) {
|
|
126
|
+
return {
|
|
127
|
+
ACCOUNT_ID: t.accountId,
|
|
128
|
+
MIDDLEWARE_URL: t.middlewareUrl,
|
|
129
|
+
LOCALE: t.locale ?? "tr"
|
|
130
|
+
};
|
|
114
131
|
}
|
|
115
|
-
function
|
|
132
|
+
function J(t, r = {}) {
|
|
133
|
+
const e = {
|
|
134
|
+
accountId: t.accountId,
|
|
135
|
+
middlewareUrl: t.middlewareUrl,
|
|
136
|
+
session: { sessionId: t.sessionId },
|
|
137
|
+
variant: "floating",
|
|
138
|
+
locale: t.locale ?? "tr",
|
|
139
|
+
...r
|
|
140
|
+
}, n = k(t);
|
|
141
|
+
return n !== void 0 && (e.injectorAdapter = n), t.theme !== void 0 && (e.theme = t.theme), e;
|
|
142
|
+
}
|
|
143
|
+
function tt(t, r = {}) {
|
|
144
|
+
const e = {
|
|
145
|
+
accountId: t.accountId,
|
|
146
|
+
middlewareUrl: t.middlewareUrl,
|
|
147
|
+
session: { sessionId: t.sessionId },
|
|
148
|
+
pageContext: {
|
|
149
|
+
pageType: "pdp",
|
|
150
|
+
sku: t.sku
|
|
151
|
+
},
|
|
152
|
+
mountTarget: t.mountTarget,
|
|
153
|
+
...r
|
|
154
|
+
}, n = k(t);
|
|
155
|
+
return n !== void 0 && (e.injectorAdapter = n), t.theme !== void 0 && (e.theme = t.theme), e;
|
|
156
|
+
}
|
|
157
|
+
function et(t, r = {}) {
|
|
158
|
+
const e = {
|
|
159
|
+
accountId: t.accountId,
|
|
160
|
+
middlewareUrl: t.middlewareUrl,
|
|
161
|
+
session: { sessionId: t.sessionId },
|
|
162
|
+
sku: t.sku,
|
|
163
|
+
mountTarget: t.mountTarget,
|
|
164
|
+
...r
|
|
165
|
+
}, n = k(t);
|
|
166
|
+
return n !== void 0 && (e.injectorAdapter = n), t.theme !== void 0 && (e.theme = t.theme), e;
|
|
167
|
+
}
|
|
168
|
+
function nt() {
|
|
169
|
+
return x() !== null;
|
|
170
|
+
}
|
|
171
|
+
function x() {
|
|
116
172
|
const t = globalThis;
|
|
117
173
|
return t.SpeechRecognition ?? t.webkitSpeechRecognition ?? null;
|
|
118
174
|
}
|
|
119
|
-
var
|
|
120
|
-
constructor(t,
|
|
121
|
-
this.recognition = null, this._state = "idle", this.silenceTimer = null, this.accumulatedTranscript = "", this.intentionalStop = !1, this._lastRestartAt = 0, this.callbacks = t, this.lang =
|
|
175
|
+
var rt = class {
|
|
176
|
+
constructor(t, r) {
|
|
177
|
+
this.recognition = null, this._state = "idle", this.silenceTimer = null, this.accumulatedTranscript = "", this.intentionalStop = !1, this._lastRestartAt = 0, this.callbacks = t, this.lang = r?.lang ?? "tr-TR", this.silenceTimeoutMs = r?.silenceTimeoutMs ?? 1500, this.autoSubmit = r?.autoSubmit ?? !0;
|
|
122
178
|
}
|
|
123
179
|
get state() {
|
|
124
180
|
return this._state;
|
|
125
181
|
}
|
|
126
182
|
start() {
|
|
127
183
|
if (this._state === "listening") return;
|
|
128
|
-
const t =
|
|
184
|
+
const t = x();
|
|
129
185
|
if (!t) {
|
|
130
186
|
this.setState("error"), this.callbacks.onError?.("not-supported", "Web Speech API is not supported in this browser.");
|
|
131
187
|
return;
|
|
@@ -135,41 +191,41 @@ var X = class {
|
|
|
135
191
|
return;
|
|
136
192
|
}
|
|
137
193
|
this.accumulatedTranscript = "", this.intentionalStop = !1;
|
|
138
|
-
const
|
|
139
|
-
|
|
194
|
+
const r = new t();
|
|
195
|
+
r.continuous = !0, r.interimResults = !0, r.lang = this.lang, r.maxAlternatives = 1, r.onstart = () => {
|
|
140
196
|
this.setState("listening");
|
|
141
|
-
},
|
|
197
|
+
}, r.onresult = (e) => {
|
|
142
198
|
this.clearSilenceTimer();
|
|
143
|
-
let
|
|
144
|
-
for (let
|
|
145
|
-
const u =
|
|
199
|
+
let n = "", i = "";
|
|
200
|
+
for (let a = e.resultIndex; a < e.results.length; a++) {
|
|
201
|
+
const u = e.results[a];
|
|
146
202
|
if (!u) continue;
|
|
147
|
-
const
|
|
148
|
-
|
|
203
|
+
const p = u[0];
|
|
204
|
+
p && (u.isFinal ? i += p.transcript : n += p.transcript);
|
|
149
205
|
}
|
|
150
|
-
|
|
151
|
-
},
|
|
152
|
-
const
|
|
153
|
-
this.intentionalStop && (
|
|
154
|
-
},
|
|
206
|
+
i && (this.accumulatedTranscript += i, this.callbacks.onFinal?.(this.accumulatedTranscript)), n && this.callbacks.onInterim?.(this.accumulatedTranscript + n), this.autoSubmit && this.accumulatedTranscript && this.startSilenceTimer();
|
|
207
|
+
}, r.onerror = (e) => {
|
|
208
|
+
const n = q(e.error);
|
|
209
|
+
this.intentionalStop && (e.error === "no-speech" || e.error === "aborted") || (this.setState("error"), this.callbacks.onError?.(n, e.message || e.error));
|
|
210
|
+
}, r.onend = () => {
|
|
155
211
|
if (this.clearSilenceTimer(), this._state === "listening" && !this.intentionalStop) {
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
212
|
+
const e = Date.now();
|
|
213
|
+
if (e - this._lastRestartAt < 500) {
|
|
158
214
|
this.setState("idle");
|
|
159
215
|
return;
|
|
160
216
|
}
|
|
161
|
-
this._lastRestartAt =
|
|
217
|
+
this._lastRestartAt = e;
|
|
162
218
|
try {
|
|
163
|
-
|
|
219
|
+
r.start();
|
|
164
220
|
} catch {
|
|
165
221
|
this.setState("idle");
|
|
166
222
|
}
|
|
167
223
|
return;
|
|
168
224
|
}
|
|
169
225
|
this.setState("idle");
|
|
170
|
-
}, this.recognition =
|
|
226
|
+
}, this.recognition = r;
|
|
171
227
|
try {
|
|
172
|
-
|
|
228
|
+
r.start();
|
|
173
229
|
} catch {
|
|
174
230
|
this.setState("error"), this.callbacks.onError?.("unknown", "Failed to start speech recognition.");
|
|
175
231
|
}
|
|
@@ -210,7 +266,7 @@ var X = class {
|
|
|
210
266
|
this.silenceTimer !== null && (clearTimeout(this.silenceTimer), this.silenceTimer = null);
|
|
211
267
|
}
|
|
212
268
|
};
|
|
213
|
-
function
|
|
269
|
+
function q(t) {
|
|
214
270
|
switch (t) {
|
|
215
271
|
case "not-allowed":
|
|
216
272
|
return "not-allowed";
|
|
@@ -226,19 +282,19 @@ function P(t) {
|
|
|
226
282
|
return "unknown";
|
|
227
283
|
}
|
|
228
284
|
}
|
|
229
|
-
function
|
|
230
|
-
const { label:
|
|
285
|
+
function at(t) {
|
|
286
|
+
const { label: r, avatarUrl: e, primaryColor: n, secondaryColor: i = "#111827", fontFamily: a = "inherit", labelClassName: u = "gengage-pill-launcher-label", styleId: p = "gengage-pill-launcher-style", mobileBreakpoint: A = 768, desktopWidth: m = "188px", desktopHeight: w = "60px", iconSize: h = "46px" } = t, T = `${parseInt(m, 10) - 14}px`, v = `${parseInt(w, 10) - 4}px`, y = `${parseInt(h, 10) - 4}px`, _ = `
|
|
231
287
|
:host {
|
|
232
|
-
--pill-primary: ${
|
|
233
|
-
--pill-secondary: ${
|
|
234
|
-
--pill-font: ${
|
|
288
|
+
--pill-primary: ${n};
|
|
289
|
+
--pill-secondary: ${i};
|
|
290
|
+
--pill-font: ${a};
|
|
235
291
|
}
|
|
236
292
|
|
|
237
293
|
button[data-gengage-part="chat-launcher-button"] {
|
|
238
294
|
box-sizing: border-box;
|
|
239
|
-
width: ${
|
|
240
|
-
min-width: ${
|
|
241
|
-
max-width: ${
|
|
295
|
+
width: ${m} !important;
|
|
296
|
+
min-width: ${m} !important;
|
|
297
|
+
max-width: ${m} !important;
|
|
242
298
|
height: ${w} !important;
|
|
243
299
|
min-height: ${w} !important;
|
|
244
300
|
padding: 6px 7px 6px 22px !important;
|
|
@@ -274,9 +330,9 @@ button[data-gengage-part="chat-launcher-button"]:hover {
|
|
|
274
330
|
}
|
|
275
331
|
|
|
276
332
|
button[data-gengage-part="chat-launcher-button"] img {
|
|
277
|
-
width: ${
|
|
278
|
-
height: ${
|
|
279
|
-
flex: 0 0 ${
|
|
333
|
+
width: ${h} !important;
|
|
334
|
+
height: ${h} !important;
|
|
335
|
+
flex: 0 0 ${h} !important;
|
|
280
336
|
border-radius: 999px;
|
|
281
337
|
object-fit: cover;
|
|
282
338
|
object-position: center;
|
|
@@ -285,13 +341,13 @@ button[data-gengage-part="chat-launcher-button"] img {
|
|
|
285
341
|
box-shadow: none !important;
|
|
286
342
|
}
|
|
287
343
|
|
|
288
|
-
@media (max-width: ${
|
|
344
|
+
@media (max-width: ${A}px) {
|
|
289
345
|
button[data-gengage-part="chat-launcher-button"] {
|
|
290
346
|
width: ${T} !important;
|
|
291
347
|
min-width: ${T} !important;
|
|
292
348
|
max-width: ${T} !important;
|
|
293
|
-
height: ${
|
|
294
|
-
min-height: ${
|
|
349
|
+
height: ${v} !important;
|
|
350
|
+
min-height: ${v} !important;
|
|
295
351
|
padding-left: 20px !important;
|
|
296
352
|
padding-right: 7px !important;
|
|
297
353
|
}
|
|
@@ -306,7 +362,7 @@ button[data-gengage-part="chat-launcher-button"] img {
|
|
|
306
362
|
flex-basis: ${y} !important;
|
|
307
363
|
}
|
|
308
364
|
}
|
|
309
|
-
`.trim(),
|
|
365
|
+
`.trim(), I = () => {
|
|
310
366
|
for (const o of document.querySelectorAll("[data-gengage-widget]")) {
|
|
311
367
|
if (!(o instanceof HTMLElement)) continue;
|
|
312
368
|
const s = o.shadowRoot;
|
|
@@ -315,46 +371,46 @@ button[data-gengage-part="chat-launcher-button"] img {
|
|
|
315
371
|
}
|
|
316
372
|
return null;
|
|
317
373
|
}, f = (o) => {
|
|
318
|
-
if (o.getElementById(
|
|
374
|
+
if (o.getElementById(p)) return;
|
|
319
375
|
const s = document.createElement("style");
|
|
320
|
-
s.id =
|
|
321
|
-
},
|
|
376
|
+
s.id = p, s.textContent = _, o.appendChild(s);
|
|
377
|
+
}, R = D(u), C = (o) => {
|
|
322
378
|
f(o);
|
|
323
379
|
const s = o.querySelector('[data-gengage-part="chat-launcher-button"]');
|
|
324
380
|
if (!(s instanceof HTMLButtonElement)) return !1;
|
|
325
|
-
const
|
|
326
|
-
if (
|
|
381
|
+
const c = o.querySelector('[data-gengage-part="chat-header-avatar"]');
|
|
382
|
+
if (c instanceof HTMLImageElement) {
|
|
327
383
|
const b = o.querySelector('[data-gengage-part="chat-launcher-button"] img');
|
|
328
|
-
(!b ||
|
|
384
|
+
(!b || c.src === b.src) && c.classList.remove("gengage-chat-header-avatar--logo");
|
|
329
385
|
}
|
|
330
|
-
if (s.querySelector(`.${
|
|
331
|
-
s.setAttribute("aria-label",
|
|
332
|
-
const
|
|
333
|
-
return
|
|
386
|
+
if (s.querySelector(`.${R}`)) return !0;
|
|
387
|
+
s.setAttribute("aria-label", r);
|
|
388
|
+
const l = document.createElement("span");
|
|
389
|
+
return l.className = u, l.textContent = r, s.appendChild(l), !0;
|
|
334
390
|
};
|
|
335
391
|
return {
|
|
336
|
-
launcherImageUrl:
|
|
392
|
+
launcherImageUrl: e,
|
|
337
393
|
apply: async (o) => {
|
|
338
394
|
if (o) {
|
|
339
395
|
f(o), await Promise.resolve();
|
|
340
|
-
for (let
|
|
341
|
-
if (
|
|
342
|
-
await new Promise((
|
|
396
|
+
for (let c = 0; c < 90; c++) {
|
|
397
|
+
if (C(o)) return;
|
|
398
|
+
await new Promise((l) => requestAnimationFrame(() => l()));
|
|
343
399
|
}
|
|
344
400
|
return;
|
|
345
401
|
}
|
|
346
|
-
const s =
|
|
402
|
+
const s = I();
|
|
347
403
|
s?.shadowRoot && f(s.shadowRoot), await Promise.resolve();
|
|
348
|
-
for (let
|
|
349
|
-
const
|
|
350
|
-
if (
|
|
404
|
+
for (let c = 0; c < 90; c++) {
|
|
405
|
+
const l = I()?.shadowRoot ?? null;
|
|
406
|
+
if (l && (f(l), C(l)))
|
|
351
407
|
return;
|
|
352
408
|
await new Promise((b) => requestAnimationFrame(() => b()));
|
|
353
409
|
}
|
|
354
410
|
}
|
|
355
411
|
};
|
|
356
412
|
}
|
|
357
|
-
var
|
|
413
|
+
var N = 96, d = {
|
|
358
414
|
leadingTokens: [
|
|
359
415
|
"bana",
|
|
360
416
|
"beni",
|
|
@@ -396,28 +452,34 @@ var D = 96, p = {
|
|
|
396
452
|
"alsana"
|
|
397
453
|
],
|
|
398
454
|
compactBuyVerbs: ["satinal", "satinalsana"]
|
|
399
|
-
},
|
|
400
|
-
function
|
|
455
|
+
}, F = new Set(d.leadingTokens), B = new Set(d.trailingTokens), V = new Set(d.cartTargets), H = new Set(d.cartVerbs), M = new Set(d.buyVerbs), O = new Set(d.compactBuyVerbs);
|
|
456
|
+
function z(t) {
|
|
401
457
|
return t.toLocaleLowerCase("tr-TR").replace(/ç/g, "c").replace(/ğ/g, "g").replace(/ı/g, "i").replace(/ö/g, "o").replace(/ş/g, "s").replace(/ü/g, "u").replace(/[^a-z0-9]+/g, " ").trim().replace(/\s+/g, " ");
|
|
402
458
|
}
|
|
403
|
-
function
|
|
404
|
-
if (!t.trim() || t.length >
|
|
405
|
-
const
|
|
406
|
-
if (!
|
|
407
|
-
const
|
|
408
|
-
for (;
|
|
409
|
-
for (;
|
|
410
|
-
return
|
|
459
|
+
function G(t) {
|
|
460
|
+
if (!t.trim() || t.length > N || /[??]/.test(t)) return !1;
|
|
461
|
+
const r = z(t);
|
|
462
|
+
if (!r || d.negativePattern.test(r)) return !1;
|
|
463
|
+
const e = r.split(" ");
|
|
464
|
+
for (; e.length > 0 && F.has(e[0]); ) e.shift();
|
|
465
|
+
for (; e.length > 0 && B.has(e[e.length - 1]); ) e.pop();
|
|
466
|
+
return e.length === 1 ? O.has(e[0]) : e.length !== 2 ? !1 : V.has(e[0]) && H.has(e[1]) ? !0 : e[0] === "satin" && M.has(e[1]);
|
|
411
467
|
}
|
|
412
|
-
function
|
|
413
|
-
return
|
|
468
|
+
function it(t) {
|
|
469
|
+
return G(t) ? "directAddToCart" : null;
|
|
414
470
|
}
|
|
415
471
|
export {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
472
|
+
Q as a,
|
|
473
|
+
tt as c,
|
|
474
|
+
D as d,
|
|
475
|
+
Z as f,
|
|
476
|
+
nt as i,
|
|
477
|
+
et as l,
|
|
478
|
+
at as n,
|
|
479
|
+
X as o,
|
|
480
|
+
$ as p,
|
|
481
|
+
rt as r,
|
|
482
|
+
J as s,
|
|
483
|
+
it as t,
|
|
484
|
+
P as u
|
|
423
485
|
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gengage-assistant-fe — top-level barrel export.
|
|
3
|
+
*
|
|
4
|
+
* Import the whole library:
|
|
5
|
+
* import { GengageChat, GengageQNA, GengageSimRel, bootstrapSession } from '@gengage/assistant-fe';
|
|
6
|
+
*
|
|
7
|
+
* Or import individual widgets for smaller bundles:
|
|
8
|
+
* import { GengageChat } from '@gengage/assistant-fe/chat';
|
|
9
|
+
* import { GengageQNA } from '@gengage/assistant-fe/qna';
|
|
10
|
+
* import { GengageSimRel } from '@gengage/assistant-fe/simrel';
|
|
11
|
+
*/
|
|
12
|
+
export { GengageChat, createChatWidget } from './chat/index.js';
|
|
13
|
+
export { GengageQNA, createQNAWidget } from './qna/index.js';
|
|
14
|
+
export { GengageSimRel, createSimRelWidget, createSimRelRenderer } from './simrel/index.js';
|
|
15
|
+
export { GengageSimBut, createSimButWidget } from './simbut/index.js';
|
|
16
|
+
export { renderUISpec as renderChatUISpec, createDefaultChatUISpecRegistry, defaultChatUnknownUISpecRenderer, } from './chat/index.js';
|
|
17
|
+
export { renderQnaUISpec, createDefaultQnaUISpecRegistry, defaultQnaUnknownUISpecRenderer } from './qna/index.js';
|
|
18
|
+
export { renderSimRelUISpec, createDefaultSimRelUISpecRegistry, defaultSimRelUnknownUISpecRenderer, } from './simrel/index.js';
|
|
19
|
+
export { GENGAGE_VERSION, GENGAGE_BUILD_FLAVOR, bootstrapSession, updatePageContext, initOverlayWidgets, getOverlayWidgets, destroyOverlayWidgets, buildOverlayIdempotencyKey, detectNativeEnvironment, applyNativeSession, createNativeWebViewBridge, initNativeOverlayWidgets, wireQNAToChat, wireSimilarToChat, dispatch, listen, consumeStream, streamPost, buildChatEndpointUrl, normalizeMiddlewareUrl, routeStreamAction, renderUISpecWithRegistry, defaultUnknownUISpecRenderer, BASE_WIDGET_THEME, withBaseTheme, DEFAULT_WIDGET_THEME_TOKENS, withDefaultWidgetTheme, DEFAULT_CUSTOMIZATION_LOCALE, createAccountIdentity, createFloatingChatConfig, createPdpQnaConfig, createPdpSimRelConfig, parseAccountRuntimeConfig, safeParseAccountRuntimeConfig, createDefaultAccountRuntimeConfig, AccountRuntimeConfigSchema, UnknownActionPolicySchema, initGengageClient, preflightDiagnostics, wireGADataLayer, isVoiceInputSupported, VoiceInput, detectPageType, extractSkuFromUrl, autoDetectPageContext, configureConnectionWarning, makePillLauncher, } from './common/index.js';
|
|
20
|
+
export type { PageContext, SessionContext, BaseWidgetConfig, GengageWidget, StreamEvent, UISpec, UIElement, ActionPayload, GengageEventName, ChatPublicAPI, ChatTransportConfig, ChatEndpointName, ActionEnrichmentContext, BackendRequestMeta, InjectorAdapter, ProcessActionRequest, StreamCallbacks, AccountRuntimeConfig, UnknownActionPolicy, HostActionHandlers, ActionRouterOptions, UISpecDomComponentRenderParams, UISpecDomComponentRenderer, UISpecDomRegistry, UISpecDomUnknownRendererParams, UISpecDomUnknownRenderer, RenderUISpecWithRegistryOptions, OverlayWidgetsController, OverlayWidgetsOptions, OverlayChatOptions, OverlayQNAOptions, OverlaySimRelOptions, OverlaySimButOptions, NativeBridgeEnvironment, NativeSessionPayload, NativeBridgeMessage, NativeWebViewBridgeOptions, NativeWebViewBridge, NativeOverlayInitOptions, NativeOverlayInitResult, AccountIdentityConfig, AccountIdentity, GengageClientOptions, HostActions, PreflightResult, PreflightWarning, WireQNAToChatOptions, VoiceInputState, VoiceInputErrorCode, VoiceInputCallbacks, VoiceInputOptions, DetectablePageType, PageDetectionRule, PillLauncherOptions, PillLauncherKit, } from './common/index.js';
|
|
21
|
+
export type { ChatWidgetConfig, ChatMessage, ChatSession, ChatI18n, ChatRendererConfig, FloatingLauncherOptions, } from './chat/index.js';
|
|
22
|
+
export type { ChatUISpecRegistry, UISpecRenderContext as ChatUISpecRenderContext } from './chat/index.js';
|
|
23
|
+
export type { QNAWidgetConfig, QNAI18n, QNAChromeLayout, QNAChromeConfig, QNAUISpecRenderContext, QNAUISpecRegistry, QNARendererConfig, } from './qna/index.js';
|
|
24
|
+
export type { SimRelWidgetConfig, SimilarProduct, SimRelI18n, SimRelUISpecRenderContext, SimRelUISpecRegistry, SimRelRendererConfig, SimRelFieldPath, SimRelRendererFields, SimRelRendererLabels, SimRelRendererMedia, SimRelRendererOptions, } from './simrel/index.js';
|
|
25
|
+
export type { SimButWidgetConfig, SimButI18n, SimButInlineCardConfig, SimButLayout } from './simbut/index.js';
|