@xpert-ai/chatkit-web-component 0.3.3 → 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, mergeConfiguredPetPositionDefaults_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
- __privateGet(this, _petOverlay).setOptions(__privateMethod(this, _ChatKitElementBase_instances, getOverlayPetOptions_fn).call(this));
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
- __privateGet(this, _petOverlay).setOptions(__privateMethod(this, _ChatKitElementBase_instances, getOverlayPetOptions_fn).call(this));
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();
@@ -3069,7 +3089,31 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3069
3089
  delete this.dataset.chatOpen;
3070
3090
  }
3071
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
+ };
3072
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
+ }
3073
3117
  if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) !== "pet") {
3074
3118
  return;
3075
3119
  }
@@ -3079,6 +3123,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3079
3123
  handlePetClose_fn = function() {
3080
3124
  __privateSet(this, _petClosedByContextMenu, true);
3081
3125
  __privateSet(this, _framePetOptionsOverride, null);
3126
+ __privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, false);
3082
3127
  __privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, false);
3083
3128
  __privateGet(this, _petOverlay).setOptions(null);
3084
3129
  if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet") {