@xpert-ai/chatkit-web-component 0.19.0 → 0.19.2
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/xpert-chatkit.js +149 -48
- package/dist/xpert-chatkit.js.map +1 -1
- package/dist/xpert-chatkit.umd.cjs +149 -48
- package/dist/xpert-chatkit.umd.cjs.map +1 -1
- package/package.json +3 -3
|
@@ -51,7 +51,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
51
51
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
52
52
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
53
53
|
|
|
54
|
-
var _a, _b, _setTrainingOptOut_dec, _hideHistory_dec, _showHistory_dec, _sendCustomAction_dec, _shareThread_dec, _focusMessage_dec, _prepareLeave_dec, _setThreadId_dec, _setRuntimeCapabilities_dec, _setComposerValue_dec, _sendUserMessage_dec, _fetchUpdates_dec, _focusComposer_dec, _c, _opts, _frameUrl, _frame, _wrapper, _windowDrag, _launcherCloseButton, _launcherOpen, _chatMinimizedToPet, _framePetOptionsOverride, _petClosedByContextMenu, _shadow, _petOverlay, _resolveLoaded, _loaded, _channelId, _messenger, _ChatKitElementBase_instances, emitAndThrow_fn, setOptionsDataAttributes_fn, getDisplayMode_fn, getConfiguredPetOptions_fn, mergeConfiguredPetPositionDefaults_fn, getOverlayPetOptions_fn, resolvePetAssetUrl_fn, resolveOverlayPetOptions_fn,
|
|
54
|
+
var _a, _b, _setTrainingOptOut_dec, _hideHistory_dec, _showHistory_dec, _sendCustomAction_dec, _shareThread_dec, _focusMessage_dec, _prepareLeave_dec, _setThreadId_dec, _setRuntimeCapabilities_dec, _setComposerValue_dec, _sendUserMessage_dec, _fetchUpdates_dec, _focusComposer_dec, _c, _opts, _frameUrl, _frame, _wrapper, _windowDrag, _launcherCloseButton, _launcherOpen, _chatMinimizedToPet, _framePetOptionsOverride, _petClosedByContextMenu, _hostLauncherEnabled, _launcherVisible, _shadow, _petOverlay, _resolveLoaded, _loaded, _channelId, _messenger, _ChatKitElementBase_instances, emitAndThrow_fn, setOptionsDataAttributes_fn, getDisplayMode_fn, getConfiguredPetOptions_fn, mergeConfiguredPetPositionDefaults_fn, effectivePet_fn, innerOptions_fn, updateFrameOptions_fn, isLauncherHidden_fn, requestLauncherVisibility_fn, getOverlayPetOptions_fn, resolvePetAssetUrl_fn, resolveOverlayPetOptions_fn, setLauncherOpen_fn, setChatMinimizedToPet_fn, syncPetOverlayOptions_fn, handlePetActivate_fn, handlePetClose_fn, handlePetReply_fn, handlePetThreadSummaryActivate_fn, _handleLauncherClose, getFrameUrl_fn, setFrameUrl_fn, consumeFrameUrl_fn, _handleFrameLoad, _initialized, maybeInit_fn, _init;
|
|
55
55
|
class EventEmitter {
|
|
56
56
|
constructor() {
|
|
57
57
|
__publicField(this, "callbacks", /* @__PURE__ */ new Map());
|
|
@@ -273,10 +273,12 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
273
273
|
super(message);
|
|
274
274
|
__publicField(this, "status");
|
|
275
275
|
__publicField(this, "statusText");
|
|
276
|
+
__publicField(this, "retryAfterMs");
|
|
276
277
|
__publicField(this, "metadata");
|
|
277
278
|
this.name = "HttpError";
|
|
278
279
|
this.statusText = res.statusText;
|
|
279
280
|
this.status = res.status;
|
|
281
|
+
this.retryAfterMs = res.retryAfterMs;
|
|
280
282
|
this.metadata = metadata;
|
|
281
283
|
}
|
|
282
284
|
static fromPossibleFrameSafeError(error) {
|
|
@@ -289,7 +291,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
289
291
|
safeError.message,
|
|
290
292
|
{
|
|
291
293
|
status: safeError.status,
|
|
292
|
-
statusText: safeError.statusText
|
|
294
|
+
statusText: safeError.statusText,
|
|
295
|
+
retryAfterMs: safeError.retryAfterMs
|
|
293
296
|
},
|
|
294
297
|
safeError.metadata
|
|
295
298
|
);
|
|
@@ -307,11 +310,13 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
307
310
|
__publicField(this, "stack");
|
|
308
311
|
__publicField(this, "status");
|
|
309
312
|
__publicField(this, "statusText");
|
|
313
|
+
__publicField(this, "retryAfterMs");
|
|
310
314
|
__publicField(this, "metadata");
|
|
311
315
|
this.message = message;
|
|
312
316
|
this.stack = new Error(message).stack;
|
|
313
317
|
this.status = res.status;
|
|
314
318
|
this.statusText = res.statusText;
|
|
319
|
+
this.retryAfterMs = res.retryAfterMs;
|
|
315
320
|
this.metadata = metadata;
|
|
316
321
|
}
|
|
317
322
|
static fromHttpError(error) {
|
|
@@ -319,7 +324,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
319
324
|
error.message,
|
|
320
325
|
{
|
|
321
326
|
status: error.status,
|
|
322
|
-
statusText: error.statusText
|
|
327
|
+
statusText: error.statusText,
|
|
328
|
+
retryAfterMs: error.retryAfterMs
|
|
323
329
|
},
|
|
324
330
|
error.metadata
|
|
325
331
|
);
|
|
@@ -441,19 +447,42 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
441
447
|
}
|
|
442
448
|
}
|
|
443
449
|
function serializeFrameError(error) {
|
|
450
|
+
if (error instanceof HttpError || error instanceof FrameSafeHttpError) {
|
|
451
|
+
try {
|
|
452
|
+
return structuredClone(
|
|
453
|
+
error instanceof HttpError ? FrameSafeHttpError.fromHttpError(error) : error
|
|
454
|
+
);
|
|
455
|
+
} catch {
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (error && typeof error === "object" && "status" in error && typeof error.status === "number") {
|
|
459
|
+
const message = "message" in error && typeof error.message === "string" ? error.message : "ChatKit host request failed";
|
|
460
|
+
return new FrameSafeHttpError(message, {
|
|
461
|
+
status: error.status,
|
|
462
|
+
statusText: "statusText" in error && typeof error.statusText === "string" ? error.statusText : void 0,
|
|
463
|
+
retryAfterMs: readRetryAfterMs(error)
|
|
464
|
+
});
|
|
465
|
+
}
|
|
444
466
|
try {
|
|
445
467
|
return structuredClone(error);
|
|
446
468
|
} catch {
|
|
447
469
|
const message = error && typeof error === "object" && "message" in error && typeof error.message === "string" ? error.message : "ChatKit host request failed";
|
|
448
|
-
if (error && typeof error === "object" && "status" in error && typeof error.status === "number") {
|
|
449
|
-
return new FrameSafeHttpError(message, {
|
|
450
|
-
status: error.status,
|
|
451
|
-
statusText: "statusText" in error && typeof error.statusText === "string" ? error.statusText : void 0
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
470
|
return new Error(message);
|
|
455
471
|
}
|
|
456
472
|
}
|
|
473
|
+
function readRetryAfterMs(error) {
|
|
474
|
+
if ("retryAfterMs" in error && typeof error.retryAfterMs === "number" && Number.isFinite(error.retryAfterMs)) {
|
|
475
|
+
return Math.max(0, error.retryAfterMs);
|
|
476
|
+
}
|
|
477
|
+
if (!("headers" in error) || !error.headers || typeof error.headers !== "object")
|
|
478
|
+
return;
|
|
479
|
+
const headers = error.headers;
|
|
480
|
+
if (!("get" in headers) || typeof headers.get !== "function") return;
|
|
481
|
+
const value = headers.get("Retry-After");
|
|
482
|
+
if (typeof value !== "string" || !value.trim()) return;
|
|
483
|
+
const duration = /^\d+(\.\d+)?$/.test(value.trim()) ? Number(value) * 1e3 : Date.parse(value) - Date.now();
|
|
484
|
+
return Number.isFinite(duration) ? Math.max(0, duration) : void 0;
|
|
485
|
+
}
|
|
457
486
|
class BaseMessenger {
|
|
458
487
|
constructor({
|
|
459
488
|
handlers,
|
|
@@ -1271,6 +1300,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1271
1300
|
const PET_OVERLAY_COPY = {
|
|
1272
1301
|
"en-US": {
|
|
1273
1302
|
closePetMenuItem: "Close pet",
|
|
1303
|
+
reopenPet: "Show pet",
|
|
1274
1304
|
hideMessage: "Hide message",
|
|
1275
1305
|
expandMessage: "Expand message",
|
|
1276
1306
|
collapseMessage: "Collapse message",
|
|
@@ -1283,6 +1313,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1283
1313
|
},
|
|
1284
1314
|
"zh-CN": {
|
|
1285
1315
|
closePetMenuItem: "关闭宠物",
|
|
1316
|
+
reopenPet: "显示宠物",
|
|
1286
1317
|
hideMessage: "隐藏消息",
|
|
1287
1318
|
expandMessage: "展开消息",
|
|
1288
1319
|
collapseMessage: "收起消息",
|
|
@@ -1493,6 +1524,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1493
1524
|
}
|
|
1494
1525
|
class PetOverlay {
|
|
1495
1526
|
constructor(root, options) {
|
|
1527
|
+
this.reopenButton = null;
|
|
1496
1528
|
this.overlayElement = null;
|
|
1497
1529
|
this.petElement = null;
|
|
1498
1530
|
this.contextMenuElement = null;
|
|
@@ -1740,6 +1772,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1740
1772
|
this.root = root;
|
|
1741
1773
|
this.onActivate = options == null ? void 0 : options.onActivate;
|
|
1742
1774
|
this.onClose = options == null ? void 0 : options.onClose;
|
|
1775
|
+
this.onReopen = options == null ? void 0 : options.onReopen;
|
|
1743
1776
|
this.onReply = options == null ? void 0 : options.onReply;
|
|
1744
1777
|
this.onThreadSummaryActivate = options == null ? void 0 : options.onThreadSummaryActivate;
|
|
1745
1778
|
this.connect();
|
|
@@ -1783,6 +1816,44 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1783
1816
|
this.resolveCharacter();
|
|
1784
1817
|
this.render();
|
|
1785
1818
|
}
|
|
1819
|
+
setReopenVisible(visible, zIndex) {
|
|
1820
|
+
var _a2, _b2, _c2, _d, _e, _f;
|
|
1821
|
+
if (!visible) {
|
|
1822
|
+
(_a2 = this.reopenButton) == null ? void 0 : _a2.remove();
|
|
1823
|
+
this.reopenButton = null;
|
|
1824
|
+
return;
|
|
1825
|
+
}
|
|
1826
|
+
if (!this.reopenButton) {
|
|
1827
|
+
const button2 = document.createElement("button");
|
|
1828
|
+
button2.type = "button";
|
|
1829
|
+
button2.addEventListener("click", () => {
|
|
1830
|
+
var _a3;
|
|
1831
|
+
return (_a3 = this.onReopen) == null ? void 0 : _a3.call(this);
|
|
1832
|
+
});
|
|
1833
|
+
this.root.append(button2);
|
|
1834
|
+
this.reopenButton = button2;
|
|
1835
|
+
}
|
|
1836
|
+
const button = this.reopenButton;
|
|
1837
|
+
const theme = typeof this.theme === "object" ? this.theme : null;
|
|
1838
|
+
const metrics = getSummaryThemeMetrics(this.theme);
|
|
1839
|
+
button.textContent = this.copy.reopenPet;
|
|
1840
|
+
Object.assign(button.style, {
|
|
1841
|
+
position: "fixed",
|
|
1842
|
+
insetInlineEnd: `${PET_SUMMARY_MARGIN}px`,
|
|
1843
|
+
bottom: `${PET_SUMMARY_MARGIN}px`,
|
|
1844
|
+
zIndex: String(zIndex ?? ((_b2 = normalizePetOptions(true)) == null ? void 0 : _b2.position.zIndex)),
|
|
1845
|
+
pointerEvents: "auto",
|
|
1846
|
+
cursor: "pointer",
|
|
1847
|
+
colorScheme: typeof this.theme === "string" ? this.theme : (theme == null ? void 0 : theme.colorScheme) ?? "light",
|
|
1848
|
+
color: ((_d = (_c2 = theme == null ? void 0 : theme.color) == null ? void 0 : _c2.surface) == null ? void 0 : _d.foreground) ?? "ButtonText",
|
|
1849
|
+
background: ((_f = (_e = theme == null ? void 0 : theme.color) == null ? void 0 : _e.surface) == null ? void 0 : _f.background) ?? "ButtonFace",
|
|
1850
|
+
border: "1px solid ButtonBorder",
|
|
1851
|
+
borderRadius: `${metrics.radius}px`,
|
|
1852
|
+
padding: metrics.padding,
|
|
1853
|
+
fontFamily: metrics.fontFamily,
|
|
1854
|
+
fontSize: `${metrics.bodySize}px`
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1786
1857
|
setState(state) {
|
|
1787
1858
|
var _a2;
|
|
1788
1859
|
const previous = this.lastAutoState;
|
|
@@ -1846,6 +1917,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1846
1917
|
return;
|
|
1847
1918
|
}
|
|
1848
1919
|
this.connected = false;
|
|
1920
|
+
this.setReopenVisible(false);
|
|
1849
1921
|
this.clearRestingDelayTimer();
|
|
1850
1922
|
this.clearTimers();
|
|
1851
1923
|
this.removeDragListeners();
|
|
@@ -2753,9 +2825,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2753
2825
|
window.removeEventListener("pointercancel", this.handlePointerUp);
|
|
2754
2826
|
}
|
|
2755
2827
|
}
|
|
2756
|
-
function getInnerOptions(options) {
|
|
2757
|
-
return removeMethods(options);
|
|
2758
|
-
}
|
|
2759
2828
|
function requireCommandCapability(value, context) {
|
|
2760
2829
|
const command = String(context.name);
|
|
2761
2830
|
return function(...args) {
|
|
@@ -2782,10 +2851,13 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2782
2851
|
__privateAdd(this, _chatMinimizedToPet, false);
|
|
2783
2852
|
__privateAdd(this, _framePetOptionsOverride);
|
|
2784
2853
|
__privateAdd(this, _petClosedByContextMenu, false);
|
|
2854
|
+
__privateAdd(this, _hostLauncherEnabled, true);
|
|
2855
|
+
__privateAdd(this, _launcherVisible, true);
|
|
2785
2856
|
__privateAdd(this, _shadow, this.attachShadow({ mode: "open" }));
|
|
2786
2857
|
__privateAdd(this, _petOverlay, new PetOverlay(__privateGet(this, _shadow), {
|
|
2787
2858
|
onActivate: () => __privateMethod(this, _ChatKitElementBase_instances, handlePetActivate_fn).call(this),
|
|
2788
2859
|
onClose: () => __privateMethod(this, _ChatKitElementBase_instances, handlePetClose_fn).call(this),
|
|
2860
|
+
onReopen: () => __privateMethod(this, _ChatKitElementBase_instances, requestLauncherVisibility_fn).call(this, true),
|
|
2789
2861
|
onReply: (text) => __privateMethod(this, _ChatKitElementBase_instances, handlePetReply_fn).call(this, text),
|
|
2790
2862
|
onThreadSummaryActivate: (threadId) => void __privateMethod(this, _ChatKitElementBase_instances, handlePetThreadSummaryActivate_fn).call(this, threadId)
|
|
2791
2863
|
}));
|
|
@@ -2978,6 +3050,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2978
3050
|
}
|
|
2979
3051
|
connectedCallback() {
|
|
2980
3052
|
__privateGet(this, _petOverlay).connect();
|
|
3053
|
+
if (__privateGet(this, _opts)) __privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
|
|
2981
3054
|
const style = document.createElement("style");
|
|
2982
3055
|
style.textContent = `
|
|
2983
3056
|
:host {
|
|
@@ -3256,19 +3329,26 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3256
3329
|
__privateGet(this, _petOverlay).destroy();
|
|
3257
3330
|
}
|
|
3258
3331
|
applySanitizedOptions(newOptions) {
|
|
3259
|
-
var _a2, _b2;
|
|
3332
|
+
var _a2, _b2, _c2, _d;
|
|
3333
|
+
const sessionChanged = ((_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.sessionKey) !== newOptions.sessionKey || ((_b2 = __privateGet(this, _opts)) == null ? void 0 : _b2.api.xpertId) !== newOptions.api.xpertId || __privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) !== __privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this, newOptions);
|
|
3334
|
+
const pet = newOptions.pet;
|
|
3335
|
+
const enabled = typeof pet === "boolean" ? pet : (pet == null ? void 0 : pet.enabled) ?? true;
|
|
3336
|
+
if (sessionChanged || enabled !== __privateGet(this, _hostLauncherEnabled)) {
|
|
3337
|
+
__privateSet(this, _launcherVisible, enabled);
|
|
3338
|
+
}
|
|
3339
|
+
__privateSet(this, _hostLauncherEnabled, enabled);
|
|
3340
|
+
if (sessionChanged) {
|
|
3341
|
+
__privateSet(this, _framePetOptionsOverride, void 0);
|
|
3342
|
+
__privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, false);
|
|
3343
|
+
}
|
|
3260
3344
|
__privateSet(this, _opts, newOptions);
|
|
3261
|
-
if (!((
|
|
3345
|
+
if (!((_c2 = newOptions.header) == null ? void 0 : _c2.windowDrag)) (_d = __privateGet(this, _windowDrag)) == null ? void 0 : _d.clear();
|
|
3262
3346
|
__privateSet(this, _petClosedByContextMenu, false);
|
|
3263
3347
|
__privateGet(this, _petOverlay).setLocale(newOptions.locale);
|
|
3264
3348
|
__privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
|
|
3265
3349
|
if (__privateGet(this, _initialized)) {
|
|
3266
3350
|
__privateMethod(this, _ChatKitElementBase_instances, setOptionsDataAttributes_fn).call(this, __privateGet(this, _opts));
|
|
3267
|
-
|
|
3268
|
-
__privateGet(this, _messenger).commands.setOptions(
|
|
3269
|
-
getInnerOptions(__privateMethod(this, _ChatKitElementBase_instances, getFrameOptions_fn).call(this, newOptions))
|
|
3270
|
-
);
|
|
3271
|
-
});
|
|
3351
|
+
__privateMethod(this, _ChatKitElementBase_instances, updateFrameOptions_fn).call(this);
|
|
3272
3352
|
} else {
|
|
3273
3353
|
__privateMethod(this, _ChatKitElementBase_instances, maybeInit_fn).call(this);
|
|
3274
3354
|
}
|
|
@@ -3360,6 +3440,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3360
3440
|
_chatMinimizedToPet = new WeakMap();
|
|
3361
3441
|
_framePetOptionsOverride = new WeakMap();
|
|
3362
3442
|
_petClosedByContextMenu = new WeakMap();
|
|
3443
|
+
_hostLauncherEnabled = new WeakMap();
|
|
3444
|
+
_launcherVisible = new WeakMap();
|
|
3363
3445
|
_shadow = new WeakMap();
|
|
3364
3446
|
_petOverlay = new WeakMap();
|
|
3365
3447
|
_resolveLoaded = new WeakMap();
|
|
@@ -3382,14 +3464,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3382
3464
|
getDisplayMode_fn = function(options = __privateGet(this, _opts)) {
|
|
3383
3465
|
return (options == null ? void 0 : options.displayMode) === "pet" ? "pet" : "chat";
|
|
3384
3466
|
};
|
|
3385
|
-
getConfiguredPetOptions_fn = function(
|
|
3386
|
-
if (!
|
|
3387
|
-
|
|
3388
|
-
}
|
|
3389
|
-
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this, options) === "pet" && !normalizePetOptions(options.pet ?? null)) {
|
|
3390
|
-
return typeof options.pet === "object" ? { ...options.pet, enabled: true } : true;
|
|
3391
|
-
}
|
|
3392
|
-
return options.pet ?? null;
|
|
3467
|
+
getConfiguredPetOptions_fn = function() {
|
|
3468
|
+
if (!__privateGet(this, _opts)) return null;
|
|
3469
|
+
return __privateMethod(this, _ChatKitElementBase_instances, effectivePet_fn).call(this, __privateGet(this, _opts)) ?? (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet" ? true : null);
|
|
3393
3470
|
};
|
|
3394
3471
|
mergeConfiguredPetPositionDefaults_fn = function(pet) {
|
|
3395
3472
|
if (!pet) {
|
|
@@ -3417,9 +3494,41 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3417
3494
|
}
|
|
3418
3495
|
};
|
|
3419
3496
|
};
|
|
3497
|
+
effectivePet_fn = function(options) {
|
|
3498
|
+
const pet = options.pet;
|
|
3499
|
+
if (options.displayMode !== "pet" || __privateGet(this, _launcherVisible) === __privateGet(this, _hostLauncherEnabled)) {
|
|
3500
|
+
return pet;
|
|
3501
|
+
}
|
|
3502
|
+
return typeof pet === "object" ? { ...pet, enabled: __privateGet(this, _launcherVisible) } : __privateGet(this, _launcherVisible);
|
|
3503
|
+
};
|
|
3504
|
+
innerOptions_fn = function(options) {
|
|
3505
|
+
return removeMethods({
|
|
3506
|
+
...options,
|
|
3507
|
+
pet: __privateMethod(this, _ChatKitElementBase_instances, effectivePet_fn).call(this, options)
|
|
3508
|
+
});
|
|
3509
|
+
};
|
|
3510
|
+
updateFrameOptions_fn = function() {
|
|
3511
|
+
__privateGet(this, _loaded).then(() => {
|
|
3512
|
+
if (__privateGet(this, _opts))
|
|
3513
|
+
__privateGet(this, _messenger).commands.setOptions(__privateMethod(this, _ChatKitElementBase_instances, innerOptions_fn).call(this, __privateGet(this, _opts)));
|
|
3514
|
+
});
|
|
3515
|
+
};
|
|
3516
|
+
isLauncherHidden_fn = function() {
|
|
3517
|
+
return __privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet" && !__privateGet(this, _launcherVisible);
|
|
3518
|
+
};
|
|
3519
|
+
requestLauncherVisibility_fn = function(visible) {
|
|
3520
|
+
__privateSet(this, _launcherVisible, visible);
|
|
3521
|
+
__privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
|
|
3522
|
+
__privateMethod(this, _ChatKitElementBase_instances, updateFrameOptions_fn).call(this);
|
|
3523
|
+
this.dispatchEvent(
|
|
3524
|
+
new CustomEvent("chatkit.pet.launcher.visibility.change", {
|
|
3525
|
+
detail: { visible }
|
|
3526
|
+
})
|
|
3527
|
+
);
|
|
3528
|
+
};
|
|
3420
3529
|
getOverlayPetOptions_fn = function() {
|
|
3421
3530
|
var _a2;
|
|
3422
|
-
if (__privateGet(this, _petClosedByContextMenu) || ((_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.pet) === false && __privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) !== "pet") {
|
|
3531
|
+
if (__privateMethod(this, _ChatKitElementBase_instances, isLauncherHidden_fn).call(this) || __privateGet(this, _petClosedByContextMenu) || ((_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.pet) === false && __privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) !== "pet") {
|
|
3423
3532
|
return null;
|
|
3424
3533
|
}
|
|
3425
3534
|
let pet;
|
|
@@ -3429,7 +3538,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3429
3538
|
pet = __privateMethod(this, _ChatKitElementBase_instances, getConfiguredPetOptions_fn).call(this);
|
|
3430
3539
|
}
|
|
3431
3540
|
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet" && !normalizePetOptions(pet ?? null)) {
|
|
3432
|
-
pet =
|
|
3541
|
+
pet = __privateMethod(this, _ChatKitElementBase_instances, getConfiguredPetOptions_fn).call(this);
|
|
3433
3542
|
}
|
|
3434
3543
|
return __privateMethod(this, _ChatKitElementBase_instances, resolveOverlayPetOptions_fn).call(this, pet);
|
|
3435
3544
|
};
|
|
@@ -3464,19 +3573,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3464
3573
|
imageRendering: normalized.imageRendering
|
|
3465
3574
|
};
|
|
3466
3575
|
};
|
|
3467
|
-
getFrameOptions_fn = function(options) {
|
|
3468
|
-
const pet = __privateMethod(this, _ChatKitElementBase_instances, getConfiguredPetOptions_fn).call(this, options);
|
|
3469
|
-
if (pet === (options.pet ?? null)) {
|
|
3470
|
-
return options;
|
|
3471
|
-
}
|
|
3472
|
-
const nextOptions = { ...options };
|
|
3473
|
-
if (pet === null) {
|
|
3474
|
-
delete nextOptions.pet;
|
|
3475
|
-
} else {
|
|
3476
|
-
nextOptions.pet = pet;
|
|
3477
|
-
}
|
|
3478
|
-
return nextOptions;
|
|
3479
|
-
};
|
|
3480
3576
|
setLauncherOpen_fn = function(open) {
|
|
3481
3577
|
__privateSet(this, _launcherOpen, open);
|
|
3482
3578
|
if (open) {
|
|
@@ -3495,9 +3591,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3495
3591
|
}
|
|
3496
3592
|
};
|
|
3497
3593
|
syncPetOverlayOptions_fn = function() {
|
|
3498
|
-
var _a2;
|
|
3594
|
+
var _a2, _b2, _c2;
|
|
3595
|
+
if (__privateMethod(this, _ChatKitElementBase_instances, isLauncherHidden_fn).call(this)) __privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, false);
|
|
3499
3596
|
const overlayPetOptions = __privateMethod(this, _ChatKitElementBase_instances, getOverlayPetOptions_fn).call(this);
|
|
3500
3597
|
__privateGet(this, _petOverlay).setOptions(overlayPetOptions, (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.theme);
|
|
3598
|
+
__privateGet(this, _petOverlay).setReopenVisible(
|
|
3599
|
+
__privateMethod(this, _ChatKitElementBase_instances, isLauncherHidden_fn).call(this),
|
|
3600
|
+
typeof ((_b2 = __privateGet(this, _opts)) == null ? void 0 : _b2.pet) === "object" ? (_c2 = __privateGet(this, _opts).pet.position) == null ? void 0 : _c2.zIndex : void 0
|
|
3601
|
+
);
|
|
3501
3602
|
if (!overlayPetOptions) {
|
|
3502
3603
|
__privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, false);
|
|
3503
3604
|
}
|
|
@@ -3518,14 +3619,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3518
3619
|
__privateGet(this, _loaded).then(() => this.focusComposer()).catch(() => void 0);
|
|
3519
3620
|
};
|
|
3520
3621
|
handlePetClose_fn = function() {
|
|
3521
|
-
__privateSet(this, _petClosedByContextMenu, true);
|
|
3522
|
-
__privateSet(this, _framePetOptionsOverride, null);
|
|
3523
|
-
__privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, false);
|
|
3524
3622
|
__privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, false);
|
|
3525
|
-
__privateGet(this, _petOverlay).setOptions(null);
|
|
3526
3623
|
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet") {
|
|
3624
|
+
__privateMethod(this, _ChatKitElementBase_instances, requestLauncherVisibility_fn).call(this, false);
|
|
3527
3625
|
return;
|
|
3528
3626
|
}
|
|
3627
|
+
__privateSet(this, _petClosedByContextMenu, true);
|
|
3628
|
+
__privateSet(this, _framePetOptionsOverride, null);
|
|
3629
|
+
__privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
|
|
3529
3630
|
__privateGet(this, _loaded).then(() => __privateGet(this, _messenger).commands.setPetEnabled({ enabled: false })).catch(() => void 0);
|
|
3530
3631
|
};
|
|
3531
3632
|
handlePetReply_fn = async function(text) {
|
|
@@ -3578,7 +3679,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3578
3679
|
const frameURL = new URL(__privateMethod(this, _ChatKitElementBase_instances, getFrameUrl_fn).call(this), window.location.origin);
|
|
3579
3680
|
__privateGet(this, _messenger).setTargetOrigin(frameURL.origin);
|
|
3580
3681
|
frameURL.hash = encodeBase64({
|
|
3581
|
-
options:
|
|
3682
|
+
options: __privateMethod(this, _ChatKitElementBase_instances, innerOptions_fn).call(this, __privateGet(this, _opts)),
|
|
3582
3683
|
referrer: window.location.origin,
|
|
3583
3684
|
profile: this.profile,
|
|
3584
3685
|
...__privateGet(this, _channelId) ? { channelId: __privateGet(this, _channelId) } : {}
|