@syntrologie/adapt-chatbot 2.42.0 → 2.43.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.
- package/dist/LeaveAMessage.leadconnector.integration.test.d.ts +2 -0
- package/dist/LeaveAMessage.leadconnector.integration.test.d.ts.map +1 -0
- package/dist/runtime.js +289 -85
- package/dist/runtime.js.map +4 -4
- package/dist/schema.d.ts +28 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +14 -3
- package/dist/schema.js.map +2 -2
- package/dist/support-chat/__tests__/lc-fetch-stub.d.ts +27 -0
- package/dist/support-chat/__tests__/lc-fetch-stub.d.ts.map +1 -0
- package/dist/support-chat/boot.d.ts +3 -0
- package/dist/support-chat/boot.d.ts.map +1 -1
- package/dist/support-chat/leadconnector.d.ts +13 -0
- package/dist/support-chat/leadconnector.d.ts.map +1 -0
- package/dist/support-chat/leadconnector.test.d.ts +2 -0
- package/dist/support-chat/leadconnector.test.d.ts.map +1 -0
- package/dist/support-chat/schema-widgetid.test.d.ts +2 -0
- package/dist/support-chat/schema-widgetid.test.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LeaveAMessage.leadconnector.integration.test.d.ts","sourceRoot":"","sources":["../src/LeaveAMessage.leadconnector.integration.test.ts"],"names":[],"mappings":""}
|
package/dist/runtime.js
CHANGED
|
@@ -695,11 +695,11 @@ var ChatTransport = class {
|
|
|
695
695
|
this._sessionStreamAbort = abort;
|
|
696
696
|
const baseUrl = this._config.backendUrl.replace(/\/$/, "");
|
|
697
697
|
const url = `${baseUrl}/api/adaptive/session`;
|
|
698
|
-
const
|
|
698
|
+
const headers2 = {};
|
|
699
699
|
const token = readRuntimeToken(this._config?.runtime);
|
|
700
|
-
if (token)
|
|
700
|
+
if (token) headers2.Authorization = `Bearer ${token}`;
|
|
701
701
|
const cft = await this._acquireTurnstileWithChallenge();
|
|
702
|
-
if (cft)
|
|
702
|
+
if (cft) headers2["CF-Turnstile-Token"] = cft;
|
|
703
703
|
if (abort.signal.aborted) return;
|
|
704
704
|
const readIds = () => {
|
|
705
705
|
try {
|
|
@@ -728,8 +728,8 @@ var ChatTransport = class {
|
|
|
728
728
|
ids = readIds();
|
|
729
729
|
}
|
|
730
730
|
if (abort.signal.aborted) return;
|
|
731
|
-
if (ids.did)
|
|
732
|
-
if (ids.sid)
|
|
731
|
+
if (ids.did) headers2["X-Distinct-Id"] = ids.did;
|
|
732
|
+
if (ids.sid) headers2["X-Syntro-Session"] = ids.sid;
|
|
733
733
|
const runReader = async () => {
|
|
734
734
|
const connAbort = new AbortController();
|
|
735
735
|
const onOuterAbort = () => connAbort.abort();
|
|
@@ -745,7 +745,7 @@ var ChatTransport = class {
|
|
|
745
745
|
});
|
|
746
746
|
try {
|
|
747
747
|
const response = await fetch(url, {
|
|
748
|
-
headers,
|
|
748
|
+
headers: headers2,
|
|
749
749
|
credentials: "include",
|
|
750
750
|
signal: connAbort.signal
|
|
751
751
|
});
|
|
@@ -801,8 +801,8 @@ var ChatTransport = class {
|
|
|
801
801
|
await new Promise((r) => setTimeout(r, this._sessionStreamBackoffMs));
|
|
802
802
|
this._sessionStreamBackoffMs = Math.min(this._sessionStreamBackoffMs * 2, 3e4);
|
|
803
803
|
const fresh = readIds();
|
|
804
|
-
if (fresh.did)
|
|
805
|
-
if (fresh.sid)
|
|
804
|
+
if (fresh.did) headers2["X-Distinct-Id"] = fresh.did;
|
|
805
|
+
if (fresh.sid) headers2["X-Syntro-Session"] = fresh.sid;
|
|
806
806
|
}
|
|
807
807
|
})();
|
|
808
808
|
await Promise.resolve();
|
|
@@ -1594,7 +1594,7 @@ var ObserverQueue = class {
|
|
|
1594
1594
|
* Returns false when the sender rejected delivery and restores the batch so
|
|
1595
1595
|
* the caller can fall back to fetch({ keepalive: true }).
|
|
1596
1596
|
*/
|
|
1597
|
-
flushOnPageHide(
|
|
1597
|
+
flushOnPageHide(send2) {
|
|
1598
1598
|
if (this._disabled || this._buffer.length === 0) return true;
|
|
1599
1599
|
this._clearInterval();
|
|
1600
1600
|
const overflow = Math.max(0, this._buffer.length - 50);
|
|
@@ -1603,7 +1603,7 @@ var ObserverQueue = class {
|
|
|
1603
1603
|
this._dropped += overflow;
|
|
1604
1604
|
}
|
|
1605
1605
|
const batch = this._buffer.splice(0, 50);
|
|
1606
|
-
if (!
|
|
1606
|
+
if (!send2(batch)) {
|
|
1607
1607
|
this._buffer.unshift(...batch);
|
|
1608
1608
|
return false;
|
|
1609
1609
|
}
|
|
@@ -1896,18 +1896,222 @@ function registerCrispBridge() {
|
|
|
1896
1896
|
}
|
|
1897
1897
|
registerCrispBridge();
|
|
1898
1898
|
|
|
1899
|
+
// src/support-chat/leadconnector.ts
|
|
1900
|
+
var LC_SERVICES = "https://services.leadconnectorhq.com";
|
|
1901
|
+
var LC_POLL_MS = 1e4;
|
|
1902
|
+
var LC_PAGE_LIMIT = 20;
|
|
1903
|
+
function lcStorageKey(widgetId) {
|
|
1904
|
+
return `syntro:supportchat:leadconnector:${widgetId}`;
|
|
1905
|
+
}
|
|
1906
|
+
var cfg;
|
|
1907
|
+
var locationIdCache;
|
|
1908
|
+
function warn(what, detail) {
|
|
1909
|
+
console.warn(`supportChat.bridge: leadconnector ${what}`, detail);
|
|
1910
|
+
}
|
|
1911
|
+
function load() {
|
|
1912
|
+
if (!cfg) return void 0;
|
|
1913
|
+
try {
|
|
1914
|
+
const raw = sessionStorage.getItem(lcStorageKey(cfg.widgetId));
|
|
1915
|
+
return raw ? JSON.parse(raw) : void 0;
|
|
1916
|
+
} catch (err) {
|
|
1917
|
+
warn("state read failed", err);
|
|
1918
|
+
return void 0;
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
function save(id) {
|
|
1922
|
+
if (!cfg) return;
|
|
1923
|
+
try {
|
|
1924
|
+
sessionStorage.setItem(lcStorageKey(cfg.widgetId), JSON.stringify(id));
|
|
1925
|
+
} catch (err) {
|
|
1926
|
+
warn("state write failed", err);
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
async function resolveLocationId() {
|
|
1930
|
+
const persisted = load();
|
|
1931
|
+
if (persisted?.locationId) return persisted.locationId;
|
|
1932
|
+
if (!cfg) return void 0;
|
|
1933
|
+
const widgetId = cfg.widgetId;
|
|
1934
|
+
locationIdCache ?? (locationIdCache = (async () => {
|
|
1935
|
+
try {
|
|
1936
|
+
const r = await fetch(`${LC_SERVICES}/chat-widget/public/config/${widgetId}`);
|
|
1937
|
+
if (!r.ok) {
|
|
1938
|
+
warn("public config fetch failed", r.status);
|
|
1939
|
+
return void 0;
|
|
1940
|
+
}
|
|
1941
|
+
const j = await r.json();
|
|
1942
|
+
const loc = j?.config?.["location-id"];
|
|
1943
|
+
return typeof loc === "string" && loc ? loc : void 0;
|
|
1944
|
+
} catch (err) {
|
|
1945
|
+
warn("public config fetch threw", err);
|
|
1946
|
+
return void 0;
|
|
1947
|
+
}
|
|
1948
|
+
})());
|
|
1949
|
+
return locationIdCache;
|
|
1950
|
+
}
|
|
1951
|
+
function headers(token) {
|
|
1952
|
+
const h = { "Content-Type": "application/json" };
|
|
1953
|
+
if (token) h.Authorization = `Bearer ${token}`;
|
|
1954
|
+
return h;
|
|
1955
|
+
}
|
|
1956
|
+
async function doSend(text) {
|
|
1957
|
+
if (!cfg) return;
|
|
1958
|
+
const locationId = await resolveLocationId();
|
|
1959
|
+
if (!locationId) {
|
|
1960
|
+
warn("no locationId \u2014 send dropped", cfg.widgetId);
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
1963
|
+
const prior = load();
|
|
1964
|
+
const body = {
|
|
1965
|
+
locationId,
|
|
1966
|
+
widgetId: cfg.widgetId,
|
|
1967
|
+
defaultWidget: true,
|
|
1968
|
+
message: text,
|
|
1969
|
+
subType: "liveChat"
|
|
1970
|
+
};
|
|
1971
|
+
if (prior?.conversationId) body.conversationId = prior.conversationId;
|
|
1972
|
+
try {
|
|
1973
|
+
const r = await fetch(`${LC_SERVICES}/conversations/providers/live-chat/messages`, {
|
|
1974
|
+
method: "POST",
|
|
1975
|
+
headers: headers(prior?.token),
|
|
1976
|
+
body: JSON.stringify(body)
|
|
1977
|
+
});
|
|
1978
|
+
if (!r.ok) {
|
|
1979
|
+
warn("send rejected", r.status);
|
|
1980
|
+
return;
|
|
1981
|
+
}
|
|
1982
|
+
const j = await r.json();
|
|
1983
|
+
const fresh = load();
|
|
1984
|
+
save({
|
|
1985
|
+
...fresh,
|
|
1986
|
+
locationId,
|
|
1987
|
+
visitorId: j.visitorId ?? fresh?.visitorId ?? prior?.visitorId,
|
|
1988
|
+
conversationId: j.conversationId ?? fresh?.conversationId ?? prior?.conversationId,
|
|
1989
|
+
contactId: j.contactId ?? fresh?.contactId ?? prior?.contactId,
|
|
1990
|
+
token: j.token ?? fresh?.token ?? prior?.token
|
|
1991
|
+
});
|
|
1992
|
+
} catch (err) {
|
|
1993
|
+
warn("send threw", err);
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
var sendChain = Promise.resolve();
|
|
1997
|
+
function send(text) {
|
|
1998
|
+
const result = sendChain.then(() => doSend(text));
|
|
1999
|
+
sendChain = result;
|
|
2000
|
+
return result;
|
|
2001
|
+
}
|
|
2002
|
+
var pollWarned = false;
|
|
2003
|
+
var pollInFlight = false;
|
|
2004
|
+
async function pollOnce(cb, isActive) {
|
|
2005
|
+
const id = load();
|
|
2006
|
+
if (!id?.conversationId || !id.token) return;
|
|
2007
|
+
if (pollInFlight) return;
|
|
2008
|
+
pollInFlight = true;
|
|
2009
|
+
try {
|
|
2010
|
+
const qs = new URLSearchParams({
|
|
2011
|
+
conversationId: id.conversationId,
|
|
2012
|
+
locationId: id.locationId,
|
|
2013
|
+
lastMessageId: id.lastMessageId ?? "",
|
|
2014
|
+
pageLimit: String(LC_PAGE_LIMIT)
|
|
2015
|
+
});
|
|
2016
|
+
try {
|
|
2017
|
+
const r = await fetch(
|
|
2018
|
+
`${LC_SERVICES}/conversations/providers/live-chat/messages/search?${qs}`,
|
|
2019
|
+
{
|
|
2020
|
+
headers: headers(id.token)
|
|
2021
|
+
}
|
|
2022
|
+
);
|
|
2023
|
+
if (!r.ok) {
|
|
2024
|
+
if (!pollWarned) {
|
|
2025
|
+
warn("poll rejected", r.status);
|
|
2026
|
+
pollWarned = true;
|
|
2027
|
+
}
|
|
2028
|
+
return;
|
|
2029
|
+
}
|
|
2030
|
+
const j = await r.json();
|
|
2031
|
+
if (!isActive()) return;
|
|
2032
|
+
const messages = j.messages ?? [];
|
|
2033
|
+
for (const m of messages) {
|
|
2034
|
+
if (m.direction === "outbound" && typeof m.body === "string") cb(m.body);
|
|
2035
|
+
}
|
|
2036
|
+
const lastMessage = messages[messages.length - 1];
|
|
2037
|
+
const nextLastMessageId = typeof j.lastMessageId === "string" && j.lastMessageId ? j.lastMessageId : typeof lastMessage?.id === "string" && lastMessage.id ? lastMessage.id : void 0;
|
|
2038
|
+
if (nextLastMessageId) {
|
|
2039
|
+
const current = load();
|
|
2040
|
+
save({ ...id, ...current, lastMessageId: nextLastMessageId });
|
|
2041
|
+
}
|
|
2042
|
+
pollWarned = false;
|
|
2043
|
+
} catch (err) {
|
|
2044
|
+
if (!pollWarned) {
|
|
2045
|
+
warn("poll threw", err);
|
|
2046
|
+
pollWarned = true;
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
} finally {
|
|
2050
|
+
pollInFlight = false;
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
var leadConnectorBridge = {
|
|
2054
|
+
vendor: "leadconnector",
|
|
2055
|
+
configure(c) {
|
|
2056
|
+
cfg = c;
|
|
2057
|
+
locationIdCache = void 0;
|
|
2058
|
+
},
|
|
2059
|
+
detect: () => Boolean(cfg?.widgetId),
|
|
2060
|
+
hideNative: () => {
|
|
2061
|
+
try {
|
|
2062
|
+
window.leadConnector?.chatWidget?.closeWidget?.();
|
|
2063
|
+
} catch (err) {
|
|
2064
|
+
warn("closeWidget failed", err);
|
|
2065
|
+
}
|
|
2066
|
+
},
|
|
2067
|
+
setVisitorEmail: (email) => {
|
|
2068
|
+
const trimmed = email.trim();
|
|
2069
|
+
if (!trimmed) return;
|
|
2070
|
+
void send(`[Visitor email: ${trimmed}]`);
|
|
2071
|
+
},
|
|
2072
|
+
sendMessage: (text) => send(text),
|
|
2073
|
+
onOperatorReply: (cb) => {
|
|
2074
|
+
let active = true;
|
|
2075
|
+
pollWarned = false;
|
|
2076
|
+
const isActive = () => active;
|
|
2077
|
+
const tick = async () => {
|
|
2078
|
+
if (!active) return;
|
|
2079
|
+
await pollOnce(cb, isActive);
|
|
2080
|
+
};
|
|
2081
|
+
const timer = setInterval(() => void tick(), LC_POLL_MS);
|
|
2082
|
+
return () => {
|
|
2083
|
+
active = false;
|
|
2084
|
+
clearInterval(timer);
|
|
2085
|
+
};
|
|
2086
|
+
}
|
|
2087
|
+
};
|
|
2088
|
+
function registerLeadConnectorBridge() {
|
|
2089
|
+
registerSupportChatBridge(leadConnectorBridge);
|
|
2090
|
+
}
|
|
2091
|
+
registerLeadConnectorBridge();
|
|
2092
|
+
|
|
1899
2093
|
// src/support-chat/boot.ts
|
|
1900
|
-
function bootSupportChat(
|
|
1901
|
-
if (!
|
|
2094
|
+
function bootSupportChat(cfg2) {
|
|
2095
|
+
if (!cfg2?.vendor) return void 0;
|
|
1902
2096
|
registerCrispBridge();
|
|
1903
|
-
|
|
2097
|
+
registerLeadConnectorBridge();
|
|
2098
|
+
if (cfg2.vendor === "leadconnector") {
|
|
2099
|
+
if (!cfg2.widgetId) {
|
|
2100
|
+
console.warn(
|
|
2101
|
+
"supportChat.bridge: leadconnector needs supportChat.widgetId \u2014 handoff disabled"
|
|
2102
|
+
);
|
|
2103
|
+
return void 0;
|
|
2104
|
+
}
|
|
2105
|
+
leadConnectorBridge.configure({ widgetId: cfg2.widgetId });
|
|
2106
|
+
}
|
|
2107
|
+
const bridge = getSupportChatBridge(cfg2.vendor);
|
|
1904
2108
|
if (!bridge || !bridge.detect()) {
|
|
1905
2109
|
console.warn(
|
|
1906
|
-
`supportChat.bridge: vendor '${
|
|
2110
|
+
`supportChat.bridge: vendor '${cfg2.vendor}' not detected on this page \u2014 handoff disabled`
|
|
1907
2111
|
);
|
|
1908
2112
|
return void 0;
|
|
1909
2113
|
}
|
|
1910
|
-
if (
|
|
2114
|
+
if (cfg2.suppressNative) bridge.hideNative();
|
|
1911
2115
|
return bridge;
|
|
1912
2116
|
}
|
|
1913
2117
|
|
|
@@ -1919,16 +2123,16 @@ function getState(container) {
|
|
|
1919
2123
|
function setState(container, state) {
|
|
1920
2124
|
container[STATE_KEY] = state;
|
|
1921
2125
|
}
|
|
1922
|
-
function applyPlaceholder(bar,
|
|
1923
|
-
if (
|
|
1924
|
-
if (
|
|
1925
|
-
if (
|
|
1926
|
-
if (
|
|
1927
|
-
if (
|
|
1928
|
-
bar.introSuggestion =
|
|
1929
|
-
bar.forceExpanded =
|
|
1930
|
-
if (typeof
|
|
1931
|
-
bar.maximized =
|
|
2126
|
+
function applyPlaceholder(bar, cfg2) {
|
|
2127
|
+
if (cfg2.placeholder !== void 0) bar.placeholder = cfg2.placeholder;
|
|
2128
|
+
if (cfg2.assistantName !== void 0) bar.assistantName = cfg2.assistantName;
|
|
2129
|
+
if (cfg2.personas !== void 0) bar.personas = cfg2.personas;
|
|
2130
|
+
if (cfg2.greeting !== void 0) bar.greeting = cfg2.greeting;
|
|
2131
|
+
if (cfg2.voiceInput !== void 0) bar.voiceInput = cfg2.voiceInput;
|
|
2132
|
+
bar.introSuggestion = cfg2.introSuggestion;
|
|
2133
|
+
bar.forceExpanded = cfg2.forceExpanded === true;
|
|
2134
|
+
if (typeof cfg2.maximized === "boolean") {
|
|
2135
|
+
bar.maximized = cfg2.maximized;
|
|
1932
2136
|
}
|
|
1933
2137
|
}
|
|
1934
2138
|
var _elementStore = null;
|
|
@@ -2059,49 +2263,49 @@ function wireNudgeSurface(runtime2, backendUrl) {
|
|
|
2059
2263
|
};
|
|
2060
2264
|
document.addEventListener("syntro:nudge", _nudgeListener);
|
|
2061
2265
|
}
|
|
2062
|
-
function configureTransportIfPossible(
|
|
2063
|
-
if (!
|
|
2064
|
-
const backendUrl =
|
|
2266
|
+
function configureTransportIfPossible(cfg2) {
|
|
2267
|
+
if (!cfg2.runtime) return;
|
|
2268
|
+
const backendUrl = cfg2.runtime.backendUrl;
|
|
2065
2269
|
if (!backendUrl) return;
|
|
2066
|
-
const elementsActive =
|
|
2067
|
-
refreshTemplateWidgetMap(elementsActive ?
|
|
2068
|
-
const forwardedProps = elementsActive ? { elementsEnabled: true, uiTemplates:
|
|
2069
|
-
if (elementsActive) publishTemplatesIfPossible(backendUrl,
|
|
2070
|
-
const runtime2 =
|
|
2270
|
+
const elementsActive = cfg2.elementsEnabled === true && cfg2.uiTemplates != null;
|
|
2271
|
+
refreshTemplateWidgetMap(elementsActive ? cfg2.uiTemplates : void 0);
|
|
2272
|
+
const forwardedProps = elementsActive ? { elementsEnabled: true, uiTemplates: cfg2.uiTemplates } : void 0;
|
|
2273
|
+
if (elementsActive) publishTemplatesIfPossible(backendUrl, cfg2.uiTemplates, cfg2.runtime?.token);
|
|
2274
|
+
const runtime2 = cfg2.runtime;
|
|
2071
2275
|
const onElementMutation = elementsActive ? (mutations) => {
|
|
2072
2276
|
void getOrCreateElementStore(runtime2).apply(mutations);
|
|
2073
2277
|
} : void 0;
|
|
2074
2278
|
if (elementsActive) {
|
|
2075
2279
|
hydrateOnce(runtime2, backendUrl);
|
|
2076
2280
|
}
|
|
2077
|
-
const persona = pickPersona(
|
|
2281
|
+
const persona = pickPersona(cfg2.personas ?? null);
|
|
2078
2282
|
chatTransport.configure({
|
|
2079
|
-
...
|
|
2283
|
+
...cfg2,
|
|
2080
2284
|
backendUrl,
|
|
2081
2285
|
forwardedProps,
|
|
2082
2286
|
onElementMutation,
|
|
2083
|
-
activeLidSlot:
|
|
2287
|
+
activeLidSlot: cfg2._syntroSlotName,
|
|
2084
2288
|
personaId: persona?.id,
|
|
2085
2289
|
personaName: persona?.name,
|
|
2086
2290
|
personaRole: persona?.role_title
|
|
2087
2291
|
});
|
|
2088
2292
|
void chatTransport.startSessionStream();
|
|
2089
2293
|
wireNudgeSurface(runtime2, backendUrl);
|
|
2090
|
-
startObserverIfPossible(
|
|
2294
|
+
startObserverIfPossible(cfg2);
|
|
2091
2295
|
}
|
|
2092
2296
|
var _templatesPublished = false;
|
|
2093
2297
|
function publishTemplatesIfPossible(backendUrl, uiTemplates, token) {
|
|
2094
2298
|
if (_templatesPublished || typeof window === "undefined") return;
|
|
2095
2299
|
if (!uiTemplates || typeof uiTemplates !== "object") return;
|
|
2096
2300
|
_templatesPublished = true;
|
|
2097
|
-
const
|
|
2098
|
-
if (token)
|
|
2301
|
+
const headers2 = { "Content-Type": "application/json" };
|
|
2302
|
+
if (token) headers2.Authorization = `Bearer ${token}`;
|
|
2099
2303
|
const editorToken = readEditorToken();
|
|
2100
|
-
if (editorToken)
|
|
2304
|
+
if (editorToken) headers2["X-Syntro-Editor-Token"] = editorToken;
|
|
2101
2305
|
const trimmed = backendUrl.replace(/\/$/, "");
|
|
2102
2306
|
void fetch(`${trimmed}/api/adaptive/templates`, {
|
|
2103
2307
|
method: "POST",
|
|
2104
|
-
headers,
|
|
2308
|
+
headers: headers2,
|
|
2105
2309
|
credentials: "include",
|
|
2106
2310
|
body: JSON.stringify({ ui_templates: uiTemplates })
|
|
2107
2311
|
}).catch(() => {
|
|
@@ -2128,9 +2332,9 @@ var _observerStarted = false;
|
|
|
2128
2332
|
var _observerRuntime = null;
|
|
2129
2333
|
var _observerHandle = null;
|
|
2130
2334
|
var _observerBusUnsubscribe = null;
|
|
2131
|
-
function startObserverIfPossible(
|
|
2335
|
+
function startObserverIfPossible(cfg2) {
|
|
2132
2336
|
if (typeof window === "undefined") return;
|
|
2133
|
-
const runtimeRef =
|
|
2337
|
+
const runtimeRef = cfg2.runtime;
|
|
2134
2338
|
if (!runtimeRef?.events?.subscribe) return;
|
|
2135
2339
|
if (_observerStarted && _observerRuntime === runtimeRef) return;
|
|
2136
2340
|
if (_observerStarted) {
|
|
@@ -2199,13 +2403,13 @@ function wireListeners(bar, state) {
|
|
|
2199
2403
|
}
|
|
2200
2404
|
var AdaptiveChatBarMountable = {
|
|
2201
2405
|
mount(container, mountConfig) {
|
|
2202
|
-
const
|
|
2203
|
-
configureTransportIfPossible(
|
|
2204
|
-
bootSupportChat(
|
|
2406
|
+
const cfg2 = mountConfig ?? {};
|
|
2407
|
+
configureTransportIfPossible(cfg2);
|
|
2408
|
+
bootSupportChat(cfg2.supportChat);
|
|
2205
2409
|
wireDiveDeeperListener();
|
|
2206
2410
|
const bar = document.createElement("adaptive-chat-bar");
|
|
2207
|
-
applyPlaceholder(bar,
|
|
2208
|
-
const widgets =
|
|
2411
|
+
applyPlaceholder(bar, cfg2);
|
|
2412
|
+
const widgets = cfg2.runtime?.widgets;
|
|
2209
2413
|
if (widgets) {
|
|
2210
2414
|
bar.mountInlineWidget = (widgetId, container2, props) => {
|
|
2211
2415
|
if (!widgets.has(widgetId)) return null;
|
|
@@ -2223,7 +2427,7 @@ var AdaptiveChatBarMountable = {
|
|
|
2223
2427
|
bar.inFlight = s.inFlight;
|
|
2224
2428
|
bar.thinkingText = s.thinkingText;
|
|
2225
2429
|
});
|
|
2226
|
-
const runtimeEvents =
|
|
2430
|
+
const runtimeEvents = cfg2.runtime ? cfg2.runtime.events : void 0;
|
|
2227
2431
|
const refreshReceipts = () => {
|
|
2228
2432
|
const store = _elementStore;
|
|
2229
2433
|
if (store) {
|
|
@@ -2240,7 +2444,7 @@ var AdaptiveChatBarMountable = {
|
|
|
2240
2444
|
}
|
|
2241
2445
|
refreshReceipts();
|
|
2242
2446
|
const state = { bar, cleanup: () => {
|
|
2243
|
-
}, cfg };
|
|
2447
|
+
}, cfg: cfg2 };
|
|
2244
2448
|
const unwireListeners = wireListeners(bar, state);
|
|
2245
2449
|
container.appendChild(bar);
|
|
2246
2450
|
const unsubFallback = chatTransport.onFallback(() => {
|
|
@@ -2261,10 +2465,10 @@ var AdaptiveChatBarMountable = {
|
|
|
2261
2465
|
update(container, mountConfig) {
|
|
2262
2466
|
const state = getState(container);
|
|
2263
2467
|
if (!state) return;
|
|
2264
|
-
const
|
|
2265
|
-
configureTransportIfPossible(
|
|
2266
|
-
applyPlaceholder(state.bar,
|
|
2267
|
-
state.cfg =
|
|
2468
|
+
const cfg2 = mountConfig ?? {};
|
|
2469
|
+
configureTransportIfPossible(cfg2);
|
|
2470
|
+
applyPlaceholder(state.bar, cfg2);
|
|
2471
|
+
state.cfg = cfg2;
|
|
2268
2472
|
}
|
|
2269
2473
|
};
|
|
2270
2474
|
|
|
@@ -2276,23 +2480,23 @@ function getState2(container) {
|
|
|
2276
2480
|
function setState2(container, state) {
|
|
2277
2481
|
container[STATE_KEY2] = state;
|
|
2278
2482
|
}
|
|
2279
|
-
function applyProps(strip,
|
|
2280
|
-
if (
|
|
2281
|
-
if (
|
|
2282
|
-
strip.runtimeRef =
|
|
2483
|
+
function applyProps(strip, cfg2) {
|
|
2484
|
+
if (cfg2.chips !== void 0) strip.chips = cfg2.chips;
|
|
2485
|
+
if (cfg2.runtime !== void 0) {
|
|
2486
|
+
strip.runtimeRef = cfg2.runtime;
|
|
2283
2487
|
}
|
|
2284
|
-
if (
|
|
2488
|
+
if (cfg2.chromeless !== void 0) strip.chromeless = cfg2.chromeless;
|
|
2285
2489
|
}
|
|
2286
2490
|
var AdaptiveChipsStripMountable = {
|
|
2287
2491
|
mount(container, mountConfig) {
|
|
2288
|
-
const
|
|
2492
|
+
const cfg2 = mountConfig ?? {};
|
|
2289
2493
|
const strip = document.createElement("adaptive-chips-strip");
|
|
2290
|
-
applyProps(strip,
|
|
2494
|
+
applyProps(strip, cfg2);
|
|
2291
2495
|
const state = {
|
|
2292
2496
|
strip,
|
|
2293
2497
|
listeners: {
|
|
2294
2498
|
revealed: (e) => {
|
|
2295
|
-
const cb =
|
|
2499
|
+
const cb = cfg2.onChipRevealed;
|
|
2296
2500
|
if (cb) {
|
|
2297
2501
|
cb(
|
|
2298
2502
|
e.detail
|
|
@@ -2300,7 +2504,7 @@ var AdaptiveChipsStripMountable = {
|
|
|
2300
2504
|
}
|
|
2301
2505
|
},
|
|
2302
2506
|
dismissed: (e) => {
|
|
2303
|
-
const cb =
|
|
2507
|
+
const cb = cfg2.onChipDismissed;
|
|
2304
2508
|
if (cb) cb(e.detail);
|
|
2305
2509
|
}
|
|
2306
2510
|
}
|
|
@@ -2319,18 +2523,18 @@ var AdaptiveChipsStripMountable = {
|
|
|
2319
2523
|
update(container, mountConfig) {
|
|
2320
2524
|
const state = getState2(container);
|
|
2321
2525
|
if (!state) return;
|
|
2322
|
-
const
|
|
2323
|
-
applyProps(state.strip,
|
|
2526
|
+
const cfg2 = mountConfig ?? {};
|
|
2527
|
+
applyProps(state.strip, cfg2);
|
|
2324
2528
|
state.strip.removeEventListener("chip-revealed", state.listeners.revealed);
|
|
2325
2529
|
state.strip.removeEventListener("chip-dismissed", state.listeners.dismissed);
|
|
2326
2530
|
state.listeners.revealed = (e) => {
|
|
2327
|
-
const cb =
|
|
2531
|
+
const cb = cfg2.onChipRevealed;
|
|
2328
2532
|
if (cb) {
|
|
2329
2533
|
cb(e.detail);
|
|
2330
2534
|
}
|
|
2331
2535
|
};
|
|
2332
2536
|
state.listeners.dismissed = (e) => {
|
|
2333
|
-
const cb =
|
|
2537
|
+
const cb = cfg2.onChipDismissed;
|
|
2334
2538
|
if (cb) cb(e.detail);
|
|
2335
2539
|
};
|
|
2336
2540
|
state.strip.addEventListener("chip-revealed", state.listeners.revealed);
|
|
@@ -2859,7 +3063,7 @@ function navigateTo(rawUrl) {
|
|
|
2859
3063
|
window.history.pushState(null, "", resolved.toString());
|
|
2860
3064
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
2861
3065
|
}
|
|
2862
|
-
function buildButton(
|
|
3066
|
+
function buildButton(cfg2) {
|
|
2863
3067
|
const button = document.createElement("button");
|
|
2864
3068
|
button.type = "button";
|
|
2865
3069
|
button.dataset.syntroNavLink = "";
|
|
@@ -2875,26 +3079,26 @@ function buildButton(cfg) {
|
|
|
2875
3079
|
button.style.color = "var(--sc-accent-foreground, currentColor)";
|
|
2876
3080
|
button.style.background = "hsl(var(--sc-accent-color) / 0.85)";
|
|
2877
3081
|
button.style.border = "1px solid hsl(var(--sc-accent-color) / 0.30)";
|
|
2878
|
-
applyLabel(button,
|
|
3082
|
+
applyLabel(button, cfg2);
|
|
2879
3083
|
return button;
|
|
2880
3084
|
}
|
|
2881
|
-
function applyLabel(button,
|
|
2882
|
-
const url = String(
|
|
2883
|
-
const label =
|
|
3085
|
+
function applyLabel(button, cfg2) {
|
|
3086
|
+
const url = String(cfg2.url ?? "");
|
|
3087
|
+
const label = cfg2.label ?? (url ? `Go to ${url}` : "Go");
|
|
2884
3088
|
button.textContent = label;
|
|
2885
3089
|
}
|
|
2886
3090
|
var NavLinkMountable = {
|
|
2887
3091
|
mount(container, mountConfig) {
|
|
2888
|
-
const
|
|
2889
|
-
const button = buildButton(
|
|
3092
|
+
const cfg2 = mountConfig ?? {};
|
|
3093
|
+
const button = buildButton(cfg2);
|
|
2890
3094
|
const onClick = (_e) => {
|
|
2891
3095
|
const current = getState3(container);
|
|
2892
|
-
const url = current?.cfg.url ??
|
|
3096
|
+
const url = current?.cfg.url ?? cfg2.url;
|
|
2893
3097
|
navigateTo(String(url ?? ""));
|
|
2894
3098
|
};
|
|
2895
3099
|
button.addEventListener("click", onClick);
|
|
2896
3100
|
container.appendChild(button);
|
|
2897
|
-
setState3(container, { button, cfg, onClick });
|
|
3101
|
+
setState3(container, { button, cfg: cfg2, onClick });
|
|
2898
3102
|
return () => {
|
|
2899
3103
|
button.removeEventListener("click", onClick);
|
|
2900
3104
|
button.remove();
|
|
@@ -2904,9 +3108,9 @@ var NavLinkMountable = {
|
|
|
2904
3108
|
update(container, mountConfig) {
|
|
2905
3109
|
const state = getState3(container);
|
|
2906
3110
|
if (!state) return;
|
|
2907
|
-
const
|
|
2908
|
-
applyLabel(state.button,
|
|
2909
|
-
state.cfg =
|
|
3111
|
+
const cfg2 = mountConfig ?? {};
|
|
3112
|
+
applyLabel(state.button, cfg2);
|
|
3113
|
+
state.cfg = cfg2;
|
|
2910
3114
|
}
|
|
2911
3115
|
};
|
|
2912
3116
|
|
|
@@ -2923,16 +3127,16 @@ function applyText(p, text) {
|
|
|
2923
3127
|
}
|
|
2924
3128
|
var TextAnswerMountable = {
|
|
2925
3129
|
mount(container, mountConfig) {
|
|
2926
|
-
const
|
|
3130
|
+
const cfg2 = mountConfig ?? {};
|
|
2927
3131
|
const paragraph = document.createElement("p");
|
|
2928
3132
|
paragraph.dataset.syntroTextAnswer = "";
|
|
2929
3133
|
paragraph.style.margin = "0";
|
|
2930
3134
|
paragraph.style.fontSize = "12px";
|
|
2931
3135
|
paragraph.style.lineHeight = "1.55";
|
|
2932
3136
|
paragraph.style.color = "var(--sc-tile-text-color, currentColor)";
|
|
2933
|
-
applyText(paragraph, String(
|
|
3137
|
+
applyText(paragraph, String(cfg2.text ?? ""));
|
|
2934
3138
|
container.appendChild(paragraph);
|
|
2935
|
-
setState4(container, { paragraph, cfg });
|
|
3139
|
+
setState4(container, { paragraph, cfg: cfg2 });
|
|
2936
3140
|
return () => {
|
|
2937
3141
|
paragraph.remove();
|
|
2938
3142
|
setState4(container, null);
|
|
@@ -2941,9 +3145,9 @@ var TextAnswerMountable = {
|
|
|
2941
3145
|
update(container, mountConfig) {
|
|
2942
3146
|
const state = getState4(container);
|
|
2943
3147
|
if (!state) return;
|
|
2944
|
-
const
|
|
2945
|
-
applyText(state.paragraph, String(
|
|
2946
|
-
state.cfg =
|
|
3148
|
+
const cfg2 = mountConfig ?? {};
|
|
3149
|
+
applyText(state.paragraph, String(cfg2.text ?? ""));
|
|
3150
|
+
state.cfg = cfg2;
|
|
2947
3151
|
}
|
|
2948
3152
|
};
|
|
2949
3153
|
|