@xpert-ai/chatkit-ui5 0.18.0 → 0.18.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/index.js CHANGED
@@ -47,7 +47,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
47
47
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
48
48
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
49
49
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
50
- 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, 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;
50
+ 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;
51
51
  import { normalizePetOptions, DEFAULT_PET_STORAGE_KEY, resolvePetCharacter, normalizeBoundsPadding, getPinnedPetPosition, clampPetPosition, getPetAssetsBaseUrl } from "@xpert-ai/chatkit-types";
52
52
  class EventEmitter {
53
53
  constructor() {
@@ -270,10 +270,12 @@ class HttpError extends Error {
270
270
  super(message);
271
271
  __publicField(this, "status");
272
272
  __publicField(this, "statusText");
273
+ __publicField(this, "retryAfterMs");
273
274
  __publicField(this, "metadata");
274
275
  this.name = "HttpError";
275
276
  this.statusText = res.statusText;
276
277
  this.status = res.status;
278
+ this.retryAfterMs = res.retryAfterMs;
277
279
  this.metadata = metadata;
278
280
  }
279
281
  static fromPossibleFrameSafeError(error) {
@@ -286,7 +288,8 @@ class HttpError extends Error {
286
288
  safeError.message,
287
289
  {
288
290
  status: safeError.status,
289
- statusText: safeError.statusText
291
+ statusText: safeError.statusText,
292
+ retryAfterMs: safeError.retryAfterMs
290
293
  },
291
294
  safeError.metadata
292
295
  );
@@ -304,11 +307,13 @@ const _FrameSafeHttpError = class _FrameSafeHttpError {
304
307
  __publicField(this, "stack");
305
308
  __publicField(this, "status");
306
309
  __publicField(this, "statusText");
310
+ __publicField(this, "retryAfterMs");
307
311
  __publicField(this, "metadata");
308
312
  this.message = message;
309
313
  this.stack = new Error(message).stack;
310
314
  this.status = res.status;
311
315
  this.statusText = res.statusText;
316
+ this.retryAfterMs = res.retryAfterMs;
312
317
  this.metadata = metadata;
313
318
  }
314
319
  static fromHttpError(error) {
@@ -316,7 +321,8 @@ const _FrameSafeHttpError = class _FrameSafeHttpError {
316
321
  error.message,
317
322
  {
318
323
  status: error.status,
319
- statusText: error.statusText
324
+ statusText: error.statusText,
325
+ retryAfterMs: error.retryAfterMs
320
326
  },
321
327
  error.metadata
322
328
  );
@@ -438,19 +444,42 @@ class FrameSafeIntegrationError {
438
444
  }
439
445
  }
440
446
  function serializeFrameError(error) {
447
+ if (error instanceof HttpError || error instanceof FrameSafeHttpError) {
448
+ try {
449
+ return structuredClone(
450
+ error instanceof HttpError ? FrameSafeHttpError.fromHttpError(error) : error
451
+ );
452
+ } catch {
453
+ }
454
+ }
455
+ if (error && typeof error === "object" && "status" in error && typeof error.status === "number") {
456
+ const message = "message" in error && typeof error.message === "string" ? error.message : "ChatKit host request failed";
457
+ return new FrameSafeHttpError(message, {
458
+ status: error.status,
459
+ statusText: "statusText" in error && typeof error.statusText === "string" ? error.statusText : void 0,
460
+ retryAfterMs: readRetryAfterMs(error)
461
+ });
462
+ }
441
463
  try {
442
464
  return structuredClone(error);
443
465
  } catch {
444
466
  const message = error && typeof error === "object" && "message" in error && typeof error.message === "string" ? error.message : "ChatKit host request failed";
445
- if (error && typeof error === "object" && "status" in error && typeof error.status === "number") {
446
- return new FrameSafeHttpError(message, {
447
- status: error.status,
448
- statusText: "statusText" in error && typeof error.statusText === "string" ? error.statusText : void 0
449
- });
450
- }
451
467
  return new Error(message);
452
468
  }
453
469
  }
470
+ function readRetryAfterMs(error) {
471
+ if ("retryAfterMs" in error && typeof error.retryAfterMs === "number" && Number.isFinite(error.retryAfterMs)) {
472
+ return Math.max(0, error.retryAfterMs);
473
+ }
474
+ if (!("headers" in error) || !error.headers || typeof error.headers !== "object")
475
+ return;
476
+ const headers = error.headers;
477
+ if (!("get" in headers) || typeof headers.get !== "function") return;
478
+ const value = headers.get("Retry-After");
479
+ if (typeof value !== "string" || !value.trim()) return;
480
+ const duration = /^\d+(\.\d+)?$/.test(value.trim()) ? Number(value) * 1e3 : Date.parse(value) - Date.now();
481
+ return Number.isFinite(duration) ? Math.max(0, duration) : void 0;
482
+ }
454
483
  class BaseMessenger {
455
484
  constructor({
456
485
  handlers,
@@ -1007,6 +1036,7 @@ const PET_SUMMARY_FONT_FAMILY = 'system-ui, -apple-system, BlinkMacSystemFont, "
1007
1036
  const PET_OVERLAY_COPY = {
1008
1037
  "en-US": {
1009
1038
  closePetMenuItem: "Close pet",
1039
+ reopenPet: "Show pet",
1010
1040
  hideMessage: "Hide message",
1011
1041
  expandMessage: "Expand message",
1012
1042
  collapseMessage: "Collapse message",
@@ -1019,6 +1049,7 @@ const PET_OVERLAY_COPY = {
1019
1049
  },
1020
1050
  "zh-CN": {
1021
1051
  closePetMenuItem: "关闭宠物",
1052
+ reopenPet: "显示宠物",
1022
1053
  hideMessage: "隐藏消息",
1023
1054
  expandMessage: "展开消息",
1024
1055
  collapseMessage: "收起消息",
@@ -1229,6 +1260,7 @@ function parseThreadSummaryLogPayload(value) {
1229
1260
  }
1230
1261
  class PetOverlay {
1231
1262
  constructor(root, options) {
1263
+ this.reopenButton = null;
1232
1264
  this.overlayElement = null;
1233
1265
  this.petElement = null;
1234
1266
  this.contextMenuElement = null;
@@ -1476,6 +1508,7 @@ class PetOverlay {
1476
1508
  this.root = root;
1477
1509
  this.onActivate = options == null ? void 0 : options.onActivate;
1478
1510
  this.onClose = options == null ? void 0 : options.onClose;
1511
+ this.onReopen = options == null ? void 0 : options.onReopen;
1479
1512
  this.onReply = options == null ? void 0 : options.onReply;
1480
1513
  this.onThreadSummaryActivate = options == null ? void 0 : options.onThreadSummaryActivate;
1481
1514
  this.connect();
@@ -1519,6 +1552,44 @@ class PetOverlay {
1519
1552
  this.resolveCharacter();
1520
1553
  this.render();
1521
1554
  }
1555
+ setReopenVisible(visible, zIndex) {
1556
+ var _a2, _b2, _c2, _d, _e, _f;
1557
+ if (!visible) {
1558
+ (_a2 = this.reopenButton) == null ? void 0 : _a2.remove();
1559
+ this.reopenButton = null;
1560
+ return;
1561
+ }
1562
+ if (!this.reopenButton) {
1563
+ const button2 = document.createElement("button");
1564
+ button2.type = "button";
1565
+ button2.addEventListener("click", () => {
1566
+ var _a3;
1567
+ return (_a3 = this.onReopen) == null ? void 0 : _a3.call(this);
1568
+ });
1569
+ this.root.append(button2);
1570
+ this.reopenButton = button2;
1571
+ }
1572
+ const button = this.reopenButton;
1573
+ const theme = typeof this.theme === "object" ? this.theme : null;
1574
+ const metrics = getSummaryThemeMetrics(this.theme);
1575
+ button.textContent = this.copy.reopenPet;
1576
+ Object.assign(button.style, {
1577
+ position: "fixed",
1578
+ insetInlineEnd: `${PET_SUMMARY_MARGIN}px`,
1579
+ bottom: `${PET_SUMMARY_MARGIN}px`,
1580
+ zIndex: String(zIndex ?? ((_b2 = normalizePetOptions(true)) == null ? void 0 : _b2.position.zIndex)),
1581
+ pointerEvents: "auto",
1582
+ cursor: "pointer",
1583
+ colorScheme: typeof this.theme === "string" ? this.theme : (theme == null ? void 0 : theme.colorScheme) ?? "light",
1584
+ color: ((_d = (_c2 = theme == null ? void 0 : theme.color) == null ? void 0 : _c2.surface) == null ? void 0 : _d.foreground) ?? "ButtonText",
1585
+ background: ((_f = (_e = theme == null ? void 0 : theme.color) == null ? void 0 : _e.surface) == null ? void 0 : _f.background) ?? "ButtonFace",
1586
+ border: "1px solid ButtonBorder",
1587
+ borderRadius: `${metrics.radius}px`,
1588
+ padding: metrics.padding,
1589
+ fontFamily: metrics.fontFamily,
1590
+ fontSize: `${metrics.bodySize}px`
1591
+ });
1592
+ }
1522
1593
  setState(state) {
1523
1594
  var _a2;
1524
1595
  const previous = this.lastAutoState;
@@ -1582,6 +1653,7 @@ class PetOverlay {
1582
1653
  return;
1583
1654
  }
1584
1655
  this.connected = false;
1656
+ this.setReopenVisible(false);
1585
1657
  this.clearRestingDelayTimer();
1586
1658
  this.clearTimers();
1587
1659
  this.removeDragListeners();
@@ -2489,9 +2561,6 @@ class PetOverlay {
2489
2561
  window.removeEventListener("pointercancel", this.handlePointerUp);
2490
2562
  }
2491
2563
  }
2492
- function getInnerOptions(options) {
2493
- return removeMethods(options);
2494
- }
2495
2564
  function requireCommandCapability(value, context) {
2496
2565
  const command = String(context.name);
2497
2566
  return function(...args) {
@@ -2518,10 +2587,13 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
2518
2587
  __privateAdd(this, _chatMinimizedToPet, false);
2519
2588
  __privateAdd(this, _framePetOptionsOverride);
2520
2589
  __privateAdd(this, _petClosedByContextMenu, false);
2590
+ __privateAdd(this, _hostLauncherEnabled, true);
2591
+ __privateAdd(this, _launcherVisible, true);
2521
2592
  __privateAdd(this, _shadow, this.attachShadow({ mode: "open" }));
2522
2593
  __privateAdd(this, _petOverlay, new PetOverlay(__privateGet(this, _shadow), {
2523
2594
  onActivate: () => __privateMethod(this, _ChatKitElementBase_instances, handlePetActivate_fn).call(this),
2524
2595
  onClose: () => __privateMethod(this, _ChatKitElementBase_instances, handlePetClose_fn).call(this),
2596
+ onReopen: () => __privateMethod(this, _ChatKitElementBase_instances, requestLauncherVisibility_fn).call(this, true),
2525
2597
  onReply: (text) => __privateMethod(this, _ChatKitElementBase_instances, handlePetReply_fn).call(this, text),
2526
2598
  onThreadSummaryActivate: (threadId) => void __privateMethod(this, _ChatKitElementBase_instances, handlePetThreadSummaryActivate_fn).call(this, threadId)
2527
2599
  }));
@@ -2714,6 +2786,7 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
2714
2786
  }
2715
2787
  connectedCallback() {
2716
2788
  __privateGet(this, _petOverlay).connect();
2789
+ if (__privateGet(this, _opts)) __privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
2717
2790
  const style = document.createElement("style");
2718
2791
  style.textContent = `
2719
2792
  :host {
@@ -2992,19 +3065,26 @@ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requir
2992
3065
  __privateGet(this, _petOverlay).destroy();
2993
3066
  }
2994
3067
  applySanitizedOptions(newOptions) {
2995
- var _a2, _b2;
3068
+ var _a2, _b2, _c2, _d;
3069
+ 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);
3070
+ const pet = newOptions.pet;
3071
+ const enabled = typeof pet === "boolean" ? pet : (pet == null ? void 0 : pet.enabled) ?? true;
3072
+ if (sessionChanged || enabled !== __privateGet(this, _hostLauncherEnabled)) {
3073
+ __privateSet(this, _launcherVisible, enabled);
3074
+ }
3075
+ __privateSet(this, _hostLauncherEnabled, enabled);
3076
+ if (sessionChanged) {
3077
+ __privateSet(this, _framePetOptionsOverride, void 0);
3078
+ __privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, false);
3079
+ }
2996
3080
  __privateSet(this, _opts, newOptions);
2997
- if (!((_a2 = newOptions.header) == null ? void 0 : _a2.windowDrag)) (_b2 = __privateGet(this, _windowDrag)) == null ? void 0 : _b2.clear();
3081
+ if (!((_c2 = newOptions.header) == null ? void 0 : _c2.windowDrag)) (_d = __privateGet(this, _windowDrag)) == null ? void 0 : _d.clear();
2998
3082
  __privateSet(this, _petClosedByContextMenu, false);
2999
3083
  __privateGet(this, _petOverlay).setLocale(newOptions.locale);
3000
3084
  __privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
3001
3085
  if (__privateGet(this, _initialized)) {
3002
3086
  __privateMethod(this, _ChatKitElementBase_instances, setOptionsDataAttributes_fn).call(this, __privateGet(this, _opts));
3003
- __privateGet(this, _loaded).then(() => {
3004
- __privateGet(this, _messenger).commands.setOptions(
3005
- getInnerOptions(__privateMethod(this, _ChatKitElementBase_instances, getFrameOptions_fn).call(this, newOptions))
3006
- );
3007
- });
3087
+ __privateMethod(this, _ChatKitElementBase_instances, updateFrameOptions_fn).call(this);
3008
3088
  } else {
3009
3089
  __privateMethod(this, _ChatKitElementBase_instances, maybeInit_fn).call(this);
3010
3090
  }
@@ -3096,6 +3176,8 @@ _launcherOpen = new WeakMap();
3096
3176
  _chatMinimizedToPet = new WeakMap();
3097
3177
  _framePetOptionsOverride = new WeakMap();
3098
3178
  _petClosedByContextMenu = new WeakMap();
3179
+ _hostLauncherEnabled = new WeakMap();
3180
+ _launcherVisible = new WeakMap();
3099
3181
  _shadow = new WeakMap();
3100
3182
  _petOverlay = new WeakMap();
3101
3183
  _resolveLoaded = new WeakMap();
@@ -3118,14 +3200,9 @@ setOptionsDataAttributes_fn = function(options) {
3118
3200
  getDisplayMode_fn = function(options = __privateGet(this, _opts)) {
3119
3201
  return (options == null ? void 0 : options.displayMode) === "pet" ? "pet" : "chat";
3120
3202
  };
3121
- getConfiguredPetOptions_fn = function(options = __privateGet(this, _opts)) {
3122
- if (!options) {
3123
- return null;
3124
- }
3125
- if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this, options) === "pet" && !normalizePetOptions(options.pet ?? null)) {
3126
- return typeof options.pet === "object" ? { ...options.pet, enabled: true } : true;
3127
- }
3128
- return options.pet ?? null;
3203
+ getConfiguredPetOptions_fn = function() {
3204
+ if (!__privateGet(this, _opts)) return null;
3205
+ return __privateMethod(this, _ChatKitElementBase_instances, effectivePet_fn).call(this, __privateGet(this, _opts)) ?? (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet" ? true : null);
3129
3206
  };
3130
3207
  mergeConfiguredPetPositionDefaults_fn = function(pet) {
3131
3208
  if (!pet) {
@@ -3153,9 +3230,41 @@ mergeConfiguredPetPositionDefaults_fn = function(pet) {
3153
3230
  }
3154
3231
  };
3155
3232
  };
3233
+ effectivePet_fn = function(options) {
3234
+ const pet = options.pet;
3235
+ if (options.displayMode !== "pet" || __privateGet(this, _launcherVisible) === __privateGet(this, _hostLauncherEnabled)) {
3236
+ return pet;
3237
+ }
3238
+ return typeof pet === "object" ? { ...pet, enabled: __privateGet(this, _launcherVisible) } : __privateGet(this, _launcherVisible);
3239
+ };
3240
+ innerOptions_fn = function(options) {
3241
+ return removeMethods({
3242
+ ...options,
3243
+ pet: __privateMethod(this, _ChatKitElementBase_instances, effectivePet_fn).call(this, options)
3244
+ });
3245
+ };
3246
+ updateFrameOptions_fn = function() {
3247
+ __privateGet(this, _loaded).then(() => {
3248
+ if (__privateGet(this, _opts))
3249
+ __privateGet(this, _messenger).commands.setOptions(__privateMethod(this, _ChatKitElementBase_instances, innerOptions_fn).call(this, __privateGet(this, _opts)));
3250
+ });
3251
+ };
3252
+ isLauncherHidden_fn = function() {
3253
+ return __privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet" && !__privateGet(this, _launcherVisible);
3254
+ };
3255
+ requestLauncherVisibility_fn = function(visible) {
3256
+ __privateSet(this, _launcherVisible, visible);
3257
+ __privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
3258
+ __privateMethod(this, _ChatKitElementBase_instances, updateFrameOptions_fn).call(this);
3259
+ this.dispatchEvent(
3260
+ new CustomEvent("chatkit.pet.launcher.visibility.change", {
3261
+ detail: { visible }
3262
+ })
3263
+ );
3264
+ };
3156
3265
  getOverlayPetOptions_fn = function() {
3157
3266
  var _a2;
3158
- if (__privateGet(this, _petClosedByContextMenu) || ((_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.pet) === false && __privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) !== "pet") {
3267
+ 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") {
3159
3268
  return null;
3160
3269
  }
3161
3270
  let pet;
@@ -3165,7 +3274,7 @@ getOverlayPetOptions_fn = function() {
3165
3274
  pet = __privateMethod(this, _ChatKitElementBase_instances, getConfiguredPetOptions_fn).call(this);
3166
3275
  }
3167
3276
  if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet" && !normalizePetOptions(pet ?? null)) {
3168
- pet = true;
3277
+ pet = __privateMethod(this, _ChatKitElementBase_instances, getConfiguredPetOptions_fn).call(this);
3169
3278
  }
3170
3279
  return __privateMethod(this, _ChatKitElementBase_instances, resolveOverlayPetOptions_fn).call(this, pet);
3171
3280
  };
@@ -3200,19 +3309,6 @@ resolveOverlayPetOptions_fn = function(pet) {
3200
3309
  imageRendering: normalized.imageRendering
3201
3310
  };
3202
3311
  };
3203
- getFrameOptions_fn = function(options) {
3204
- const pet = __privateMethod(this, _ChatKitElementBase_instances, getConfiguredPetOptions_fn).call(this, options);
3205
- if (pet === (options.pet ?? null)) {
3206
- return options;
3207
- }
3208
- const nextOptions = { ...options };
3209
- if (pet === null) {
3210
- delete nextOptions.pet;
3211
- } else {
3212
- nextOptions.pet = pet;
3213
- }
3214
- return nextOptions;
3215
- };
3216
3312
  setLauncherOpen_fn = function(open) {
3217
3313
  __privateSet(this, _launcherOpen, open);
3218
3314
  if (open) {
@@ -3231,9 +3327,14 @@ setChatMinimizedToPet_fn = function(minimized) {
3231
3327
  }
3232
3328
  };
3233
3329
  syncPetOverlayOptions_fn = function() {
3234
- var _a2;
3330
+ var _a2, _b2, _c2;
3331
+ if (__privateMethod(this, _ChatKitElementBase_instances, isLauncherHidden_fn).call(this)) __privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, false);
3235
3332
  const overlayPetOptions = __privateMethod(this, _ChatKitElementBase_instances, getOverlayPetOptions_fn).call(this);
3236
3333
  __privateGet(this, _petOverlay).setOptions(overlayPetOptions, (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.theme);
3334
+ __privateGet(this, _petOverlay).setReopenVisible(
3335
+ __privateMethod(this, _ChatKitElementBase_instances, isLauncherHidden_fn).call(this),
3336
+ typeof ((_b2 = __privateGet(this, _opts)) == null ? void 0 : _b2.pet) === "object" ? (_c2 = __privateGet(this, _opts).pet.position) == null ? void 0 : _c2.zIndex : void 0
3337
+ );
3237
3338
  if (!overlayPetOptions) {
3238
3339
  __privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, false);
3239
3340
  }
@@ -3254,14 +3355,14 @@ handlePetActivate_fn = function() {
3254
3355
  __privateGet(this, _loaded).then(() => this.focusComposer()).catch(() => void 0);
3255
3356
  };
3256
3357
  handlePetClose_fn = function() {
3257
- __privateSet(this, _petClosedByContextMenu, true);
3258
- __privateSet(this, _framePetOptionsOverride, null);
3259
- __privateMethod(this, _ChatKitElementBase_instances, setChatMinimizedToPet_fn).call(this, false);
3260
3358
  __privateMethod(this, _ChatKitElementBase_instances, setLauncherOpen_fn).call(this, false);
3261
- __privateGet(this, _petOverlay).setOptions(null);
3262
3359
  if (__privateMethod(this, _ChatKitElementBase_instances, getDisplayMode_fn).call(this) === "pet") {
3360
+ __privateMethod(this, _ChatKitElementBase_instances, requestLauncherVisibility_fn).call(this, false);
3263
3361
  return;
3264
3362
  }
3363
+ __privateSet(this, _petClosedByContextMenu, true);
3364
+ __privateSet(this, _framePetOptionsOverride, null);
3365
+ __privateMethod(this, _ChatKitElementBase_instances, syncPetOverlayOptions_fn).call(this);
3265
3366
  __privateGet(this, _loaded).then(() => __privateGet(this, _messenger).commands.setPetEnabled({ enabled: false })).catch(() => void 0);
3266
3367
  };
3267
3368
  handlePetReply_fn = async function(text) {
@@ -3314,7 +3415,7 @@ maybeInit_fn = function() {
3314
3415
  const frameURL = new URL(__privateMethod(this, _ChatKitElementBase_instances, getFrameUrl_fn).call(this), window.location.origin);
3315
3416
  __privateGet(this, _messenger).setTargetOrigin(frameURL.origin);
3316
3417
  frameURL.hash = encodeBase64({
3317
- options: getInnerOptions(__privateMethod(this, _ChatKitElementBase_instances, getFrameOptions_fn).call(this, __privateGet(this, _opts))),
3418
+ options: __privateMethod(this, _ChatKitElementBase_instances, innerOptions_fn).call(this, __privateGet(this, _opts)),
3318
3419
  referrer: window.location.origin,
3319
3420
  profile: this.profile,
3320
3421
  ...__privateGet(this, _channelId) ? { channelId: __privateGet(this, _channelId) } : {}
@@ -3363,6 +3464,7 @@ const EVENT_HANDLER_MAP = {
3363
3464
  "chatkit.response.start": "onResponseStart",
3364
3465
  "chatkit.log": "onLog",
3365
3466
  "chatkit.thread.change": "onThreadChange",
3467
+ "chatkit.pet.launcher.visibility.change": "onPetLauncherVisibilityChange",
3366
3468
  "chatkit.project.change": "onProjectChange",
3367
3469
  "chatkit.connectors.change": "onConnectorsChange",
3368
3470
  "chatkit.thread.load.start": "onThreadLoadStart",
@@ -3376,6 +3478,7 @@ const UI5_EVENT_NAME_MAP = {
3376
3478
  "chatkit.response.start": "responseStart",
3377
3479
  "chatkit.log": "log",
3378
3480
  "chatkit.thread.change": "threadChange",
3481
+ "chatkit.pet.launcher.visibility.change": "petLauncherVisibilityChange",
3379
3482
  "chatkit.project.change": "projectChange",
3380
3483
  "chatkit.connectors.change": "connectorsChange",
3381
3484
  "chatkit.thread.load.start": "threadLoadStart",
@@ -3442,6 +3545,7 @@ const ChatKit = ControlBase.extend("xpertai.chatkit.ui5.ChatKit", {
3442
3545
  responseStart: { parameters: { detail: { type: "object" } } },
3443
3546
  log: { parameters: { detail: { type: "object" } } },
3444
3547
  threadChange: { parameters: { detail: { type: "object" } } },
3548
+ petLauncherVisibilityChange: { parameters: { detail: { type: "object" } } },
3445
3549
  threadLoadStart: { parameters: { detail: { type: "object" } } },
3446
3550
  threadLoadEnd: { parameters: { detail: { type: "object" } } },
3447
3551
  ready: { parameters: { detail: { type: "object" } } },