@xpert-ai/chatkit-web-component 0.3.2 → 0.3.4
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.
|
@@ -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, _setThreadId_dec, _setComposerValue_dec, _sendUserMessage_dec, _fetchUpdates_dec, _focusComposer_dec, _c, _opts, _frameUrl, _frame, _wrapper, _launcherCloseButton, _launcherOpen, _framePetOptionsOverride, _petClosedByContextMenu, _shadow, _petOverlay, _resolveLoaded, _loaded, _messenger, _ChatKitElementBase_instances, emitAndThrow_fn, setOptionsDataAttributes_fn, getDisplayMode_fn, getConfiguredPetOptions_fn, getOverlayPetOptions_fn, resolvePetAssetUrl_fn, resolveOverlayPetOptions_fn, getFrameOptions_fn, setLauncherOpen_fn, handlePetActivate_fn, handlePetClose_fn, handlePetReply_fn, handlePetThreadSummaryActivate_fn, _handleLauncherClose, getFrameUrl_fn, setFrameUrl_fn, consumeFrameUrl_fn, _handleFrameLoad, _initialized, maybeInit_fn, _init;
|
|
54
|
+
var _a, _b, _setTrainingOptOut_dec, _hideHistory_dec, _showHistory_dec, _sendCustomAction_dec, _shareThread_dec, _setThreadId_dec, _setComposerValue_dec, _sendUserMessage_dec, _fetchUpdates_dec, _focusComposer_dec, _c, _opts, _frameUrl, _frame, _wrapper, _launcherCloseButton, _launcherOpen, _chatMinimizedToPet, _framePetOptionsOverride, _petClosedByContextMenu, _shadow, _petOverlay, _resolveLoaded, _loaded, _messenger, _ChatKitElementBase_instances, emitAndThrow_fn, setOptionsDataAttributes_fn, getDisplayMode_fn, getConfiguredPetOptions_fn, mergeConfiguredPetPositionDefaults_fn, getOverlayPetOptions_fn, resolvePetAssetUrl_fn, resolveOverlayPetOptions_fn, getFrameOptions_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());
|
|
@@ -2498,6 +2498,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2498
2498
|
__privateAdd(this, _wrapper);
|
|
2499
2499
|
__privateAdd(this, _launcherCloseButton);
|
|
2500
2500
|
__privateAdd(this, _launcherOpen, false);
|
|
2501
|
+
__privateAdd(this, _chatMinimizedToPet, false);
|
|
2501
2502
|
__privateAdd(this, _framePetOptionsOverride);
|
|
2502
2503
|
__privateAdd(this, _petClosedByContextMenu, false);
|
|
2503
2504
|
__privateAdd(this, _shadow, this.attachShadow({ mode: "open" }));
|
|
@@ -2634,6 +2635,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2634
2635
|
:host([data-display-mode="pet"]) {
|
|
2635
2636
|
display: contents;
|
|
2636
2637
|
}
|
|
2638
|
+
:host([data-chat-minimized-to-pet="true"]) {
|
|
2639
|
+
display: contents;
|
|
2640
|
+
}
|
|
2637
2641
|
.ck-iframe {
|
|
2638
2642
|
border: none;
|
|
2639
2643
|
position: absolute;
|
|
@@ -2744,6 +2748,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2744
2748
|
:host([data-loaded="true"]) .ck-wrapper {
|
|
2745
2749
|
opacity: 1;
|
|
2746
2750
|
}
|
|
2751
|
+
:host([data-chat-minimized-to-pet="true"]) .ck-wrapper {
|
|
2752
|
+
opacity: 0;
|
|
2753
|
+
pointer-events: none;
|
|
2754
|
+
visibility: hidden;
|
|
2755
|
+
}
|
|
2747
2756
|
:host([data-display-mode="pet"]:not([data-chat-open="true"])) .ck-wrapper {
|
|
2748
2757
|
opacity: 0;
|
|
2749
2758
|
}
|
|
@@ -2830,7 +2839,17 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2830
2839
|
__privateSet(this, _petClosedByContextMenu, false);
|
|
2831
2840
|
}
|
|
2832
2841
|
__privateSet(this, _framePetOptionsOverride, payload.pet);
|
|
2833
|
-
|
|
2842
|
+
__privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
|
|
2843
|
+
}
|
|
2844
|
+
});
|
|
2845
|
+
__privateGet(this, _messenger).on("chat_minimize_change", (data) => {
|
|
2846
|
+
const minimized = typeof data === "object" && data !== null && "minimized" in data && data.minimized === true;
|
|
2847
|
+
if (minimized && !__privateMethod(this, _ChatKitElementBase_instances, getOverlayPetOptions_fn).call(this)) {
|
|
2848
|
+
return;
|
|
2849
|
+
}
|
|
2850
|
+
__privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, minimized);
|
|
2851
|
+
if (minimized) {
|
|
2852
|
+
__privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, false);
|
|
2834
2853
|
}
|
|
2835
2854
|
});
|
|
2836
2855
|
__privateGet(this, _messenger).on("unmount", () => {
|
|
@@ -2868,7 +2887,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2868
2887
|
__privateSet(this, _opts, newOptions);
|
|
2869
2888
|
__privateSet(this, _petClosedByContextMenu, false);
|
|
2870
2889
|
__privateGet(this, _petOverlay).setLocale(newOptions.locale);
|
|
2871
|
-
|
|
2890
|
+
__privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
|
|
2872
2891
|
if (__privateGet(this, _initialized)) {
|
|
2873
2892
|
__privateMethod(this, _ChatKitElementBase_instances, setOptionsDataAttributes_fn).call(this, __privateGet(this, _opts));
|
|
2874
2893
|
__privateGet(this, _loaded).then(() => {
|
|
@@ -2948,6 +2967,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2948
2967
|
_wrapper = new WeakMap();
|
|
2949
2968
|
_launcherCloseButton = new WeakMap();
|
|
2950
2969
|
_launcherOpen = new WeakMap();
|
|
2970
|
+
_chatMinimizedToPet = new WeakMap();
|
|
2951
2971
|
_framePetOptionsOverride = new WeakMap();
|
|
2952
2972
|
_petClosedByContextMenu = new WeakMap();
|
|
2953
2973
|
_shadow = new WeakMap();
|
|
@@ -2980,11 +3000,42 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2980
3000
|
}
|
|
2981
3001
|
return options.pet ?? null;
|
|
2982
3002
|
};
|
|
3003
|
+
mergeConfiguredPetPositionDefaults_fn = function(pet) {
|
|
3004
|
+
if (!pet) {
|
|
3005
|
+
return pet;
|
|
3006
|
+
}
|
|
3007
|
+
const configured = normalizePetOptions(
|
|
3008
|
+
__privateMethod(this, _ChatKitElementBase_instances, getConfiguredPetOptions_fn).call(this) ?? null
|
|
3009
|
+
);
|
|
3010
|
+
if (!configured) {
|
|
3011
|
+
return pet;
|
|
3012
|
+
}
|
|
3013
|
+
if (pet === true) {
|
|
3014
|
+
return { position: configured.position };
|
|
3015
|
+
}
|
|
3016
|
+
if (!pet.position) {
|
|
3017
|
+
return { ...pet, position: configured.position };
|
|
3018
|
+
}
|
|
3019
|
+
return {
|
|
3020
|
+
...pet,
|
|
3021
|
+
position: {
|
|
3022
|
+
...configured.position,
|
|
3023
|
+
...pet.position,
|
|
3024
|
+
boundsPadding: pet.position.boundsPadding ?? configured.position.boundsPadding,
|
|
3025
|
+
pin: "pin" in pet.position ? pet.position.pin : configured.position.pin
|
|
3026
|
+
}
|
|
3027
|
+
};
|
|
3028
|
+
};
|
|
2983
3029
|
getOverlayPetOptions_fn = function() {
|
|
2984
3030
|
if (__privateGet(this, _petClosedByContextMenu)) {
|
|
2985
3031
|
return null;
|
|
2986
3032
|
}
|
|
2987
|
-
let pet
|
|
3033
|
+
let pet;
|
|
3034
|
+
if (__privateGet(this, _framePetOptionsOverride) !== void 0) {
|
|
3035
|
+
pet = __privateMethod(this, _ChatKitElementBase_instances, mergeConfiguredPetPositionDefaults_fn).call(this, __privateGet(this, _framePetOptionsOverride));
|
|
3036
|
+
} else {
|
|
3037
|
+
pet = __privateMethod(this, _ChatKitElementBase_instances, getConfiguredPetOptions_fn).call(this);
|
|
3038
|
+
}
|
|
2988
3039
|
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet" && !normalizePetOptions(pet ?? null)) {
|
|
2989
3040
|
pet = true;
|
|
2990
3041
|
}
|
|
@@ -3038,7 +3089,31 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3038
3089
|
delete this.dataset.chatOpen;
|
|
3039
3090
|
}
|
|
3040
3091
|
};
|
|
3092
|
+
setChatMinimizedToPet_fn = function(minimized) {
|
|
3093
|
+
const next = minimized && Boolean(__privateMethod(this, _ChatKitElementBase_instances, getOverlayPetOptions_fn).call(this));
|
|
3094
|
+
__privateSet(this, _chatMinimizedToPet, next);
|
|
3095
|
+
if (next) {
|
|
3096
|
+
this.dataset.chatMinimizedToPet = "true";
|
|
3097
|
+
} else {
|
|
3098
|
+
delete this.dataset.chatMinimizedToPet;
|
|
3099
|
+
}
|
|
3100
|
+
};
|
|
3101
|
+
syncPetOverlayOptions_fn = function() {
|
|
3102
|
+
const overlayPetOptions = __privateMethod(this, _ChatKitElementBase_instances, getOverlayPetOptions_fn).call(this);
|
|
3103
|
+
__privateGet(this, _petOverlay).setOptions(overlayPetOptions);
|
|
3104
|
+
if (!overlayPetOptions) {
|
|
3105
|
+
__privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, false);
|
|
3106
|
+
}
|
|
3107
|
+
};
|
|
3041
3108
|
handlePetActivate_fn = function() {
|
|
3109
|
+
if (__privateGet(this, _chatMinimizedToPet)) {
|
|
3110
|
+
__privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, false);
|
|
3111
|
+
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet") {
|
|
3112
|
+
__privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, true);
|
|
3113
|
+
}
|
|
3114
|
+
__privateGet(this, _loaded).then(() => this.focusComposer()).catch(() => void 0);
|
|
3115
|
+
return;
|
|
3116
|
+
}
|
|
3042
3117
|
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) !== "pet") {
|
|
3043
3118
|
return;
|
|
3044
3119
|
}
|
|
@@ -3048,6 +3123,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3048
3123
|
handlePetClose_fn = function() {
|
|
3049
3124
|
__privateSet(this, _petClosedByContextMenu, true);
|
|
3050
3125
|
__privateSet(this, _framePetOptionsOverride, null);
|
|
3126
|
+
__privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, false);
|
|
3051
3127
|
__privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, false);
|
|
3052
3128
|
__privateGet(this, _petOverlay).setOptions(null);
|
|
3053
3129
|
if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet") {
|