@michengai/dsh-codex-pet 1.0.6 → 1.0.8

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/lib/client.js CHANGED
@@ -38,42 +38,62 @@ __export(client_exports, {
38
38
  module.exports = __toCommonJS(client_exports);
39
39
 
40
40
  // src/session-compat.ts
41
+ var DEFAULT_OWNER = "pet";
41
42
  function compatibleSessions(sessions, navigate, status) {
42
- const refs = /* @__PURE__ */ new Map();
43
+ const held = /* @__PURE__ */ new Map();
44
+ const drop = (id) => {
45
+ const entry = held.get(id);
46
+ if (entry === void 0) return;
47
+ try {
48
+ entry.ref.release();
49
+ } catch {
50
+ }
51
+ held.delete(id);
52
+ };
43
53
  const sweep = () => {
54
+ if (held.size === 0) return;
44
55
  const ids = new Set(sessions.list?.getSnapshot?.()?.ids ?? []);
45
- for (const [id, ref] of refs) if (!ids.has(id)) {
46
- try {
47
- ref.release();
48
- } catch {
49
- }
50
- refs.delete(id);
56
+ for (const id of [...held.keys()]) if (!ids.has(id)) drop(id);
57
+ };
58
+ const releaseBindings = (owner = DEFAULT_OWNER) => {
59
+ for (const [id, entry] of [...held]) {
60
+ entry.owners.delete(owner);
61
+ if (entry.owners.size === 0) drop(id);
51
62
  }
52
63
  };
64
+ function releaseBinding(id, owner = DEFAULT_OWNER) {
65
+ const entry = held.get(id);
66
+ if (entry === void 0) return;
67
+ entry.owners.delete(owner);
68
+ if (entry.owners.size === 0) drop(id);
69
+ }
53
70
  sessions.list?.subscribe?.(sweep);
54
71
  return {
55
72
  list: sessions.list,
56
73
  status: status ?? sessions.status,
57
74
  using: sessions.using?.bind(sessions),
58
75
  open: navigate,
76
+ releaseBinding,
77
+ releaseBindings,
78
+ sweepBindings: sweep,
59
79
  create: (options) => {
60
80
  if (!sessions.create) throw new Error("\u521B\u5EFA\u4F1A\u8BDD\u5C1A\u4E0D\u53EF\u7528\uFF0C\u8BF7\u91CD\u8BD5");
61
81
  return sessions.create(options);
62
82
  },
63
- binding(id) {
64
- sweep();
83
+ binding(id, owner = DEFAULT_OWNER) {
65
84
  let binding = sessions.binding(id);
66
85
  if (!binding && sessions.retain) {
67
- let ref = refs.get(id);
68
- if (!ref) {
86
+ let entry = held.get(id);
87
+ if (!entry) {
69
88
  try {
70
- ref = sessions.retain(id, { source: "controllerOperation" });
71
- refs.set(id, ref);
89
+ entry = { ref: sessions.retain(id, { source: "controllerOperation" }), owners: /* @__PURE__ */ new Set() };
90
+ held.set(id, entry);
72
91
  } catch {
73
92
  return void 0;
74
93
  }
75
94
  }
76
- binding = ref.binding;
95
+ entry.owners.add(owner);
96
+ binding = entry.ref.binding;
77
97
  }
78
98
  return binding;
79
99
  }
@@ -271,8 +291,8 @@ function translator(language) {
271
291
  }
272
292
 
273
293
  // src/client.tsx
274
- var import_react7 = require("react");
275
- var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
294
+ var import_react8 = require("react");
295
+ var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
276
296
 
277
297
  // src/library-store.ts
278
298
  function createLibraryStore(request2) {
@@ -329,7 +349,7 @@ function createLibraryStore(request2) {
329
349
  }
330
350
 
331
351
  // src/plugin-update-ui.tsx
332
- var import_react2 = require("react");
352
+ var import_react3 = require("react");
333
353
 
334
354
  // src/project-icons.tsx
335
355
  var import_react = __toESM(require("react"), 1);
@@ -394,11 +414,18 @@ function updateErrorMessage(code, language) {
394
414
  }
395
415
 
396
416
  // src/shared-plugin-update-ui.ts
417
+ var import_react2 = __toESM(require("react"), 1);
418
+ var import_client = require("react-dom/client");
419
+ var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
397
420
  var UPDATE_HEADER = "x-michengai-plugin-update";
398
- var STYLE_ID = "michengai-plugin-update-ui";
421
+ var STYLE_ID = "michengai-dsh-codex-pet-update-ui";
399
422
  var CSS = `
400
- .mpi-version{margin-left:8px;color:var(--dsw-alias-label-tertiary,#9da1aa);font-family:inherit;font-size:12px;font-weight:500;line-height:18px;letter-spacing:0;white-space:nowrap;vertical-align:baseline}.mpi-check{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:28px;height:28px;padding:0 10px;border:0.5px solid var(--dsw-alias-border-l3,var(--dsw-alias-border-l2,#4b4d52));border-radius:var(--dsw-radius-sm,7px);background:transparent;color:var(--dsw-alias-label-secondary,#b8bbc2);font:inherit;font-size:12px;font-weight:500;line-height:18px;white-space:nowrap;cursor:pointer}.mpi-check:hover{background:var(--dsw-alias-interactive-bg-hover,#3a3b3f);color:var(--dsw-alias-label-primary,#fff)}.mpi-check:focus-visible,.mpi-dialog .mpi-action:focus-visible,.mpi-dialog .mpi-dialog-close:focus-visible{outline:var(--dsw-focus-ring-width,1px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary,#4f8cff));outline-offset:2px}.mpi-icon{display:inline-flex;flex:0 0 auto;width:16px;height:16px;align-items:center;justify-content:center;pointer-events:none}.mpi-icon svg{display:block;width:16px;height:16px}
401
- .mpi-overlay{position:fixed;inset:0;z-index:2147483647;display:flex;align-items:center;justify-content:center;padding:24px;background:var(--dsw-alias-bg-mask-1,rgba(0,0,0,.62));backdrop-filter:var(--dsw-mask-blur,none)}.mpi-dialog{position:relative;box-sizing:border-box;width:min(680px,100%);max-height:calc(100vh - 48px);overflow:auto;border:0;border-radius:var(--dsw-radius-panel,14px);padding:22px;background:var(--dsw-alias-bg-layer-2,var(--dsw-specific-menu,#202124));color:var(--dsw-alias-label-primary,#fff);box-shadow:var(--dsw-elevation-prominent,var(--dsw-shadow-lv3,0 16px 48px rgba(0,0,0,.24)));font-family:inherit}.mpi-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.mpi-dialog h2{margin:0;font-size:16px;line-height:24px;font-weight:500}.mpi-dialog .mpi-dialog-close{display:inline-flex;flex:0 0 28px;width:28px;height:28px;align-items:center;justify-content:center;padding:0;border:0;border-radius:var(--dsw-radius-sm,8px);background:transparent;color:var(--dsw-alias-label-secondary,#b8bbc2);cursor:pointer}.mpi-dialog .mpi-dialog-close:hover{background:var(--dsw-alias-interactive-bg-hover,#3a3b3f);color:var(--dsw-alias-label-primary,#fff)}.mpi-intro{margin:8px 0 18px;color:var(--dsw-alias-label-secondary,#c2c4ca);font-size:13px;line-height:20px}.mpi-meta{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:8px 18px;margin:0 0 16px;font-size:12px;line-height:18px}.mpi-meta dt{color:var(--dsw-alias-label-secondary,#c2c4ca)}.mpi-meta dd{margin:0;font-family:ui-monospace,SFMono-Regular,Consolas,monospace}.mpi-status{margin:0 0 18px;border-radius:var(--dsw-radius-sm,7px);padding:12px 14px;background:var(--dsw-alias-bg-layer-3,var(--dsw-specific-menu-item-hover,#252527));font-size:13px;font-weight:600;line-height:20px}.mpi-status[data-kind=error]{color:var(--dsw-alias-state-error-primary,#ff6464)}.mpi-status[data-kind=success]{color:var(--dsw-alias-state-success-primary,#36d67a)}.mpi-status[data-kind=update]{color:var(--dsw-alias-state-warn-primary,#e8b15a)}.mpi-manual{border-top:1px solid var(--dsw-alias-border-l2,#4b4d52);padding-top:16px}.mpi-manual h3{margin:0 0 6px;font-size:14px;line-height:20px}.mpi-manual p{margin:0 0 10px;color:var(--dsw-alias-label-secondary,#c2c4ca);font-size:12px;line-height:18px}.mpi-command{display:flex;align-items:center;gap:8px;border:1px solid var(--dsw-alias-border-l2,#4b4d52);border-radius:var(--dsw-radius-sm,7px);padding:10px;background:var(--dsw-alias-bg-layer-3,var(--dsw-specific-menu-item-hover,#252527))}.mpi-command code{min-width:0;flex:1;overflow:auto;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px;line-height:18px;white-space:nowrap}.mpi-actions{display:flex;align-items:center;justify-content:flex-end;gap:12px;margin-top:18px}.mpi-actions-group{display:flex;gap:8px}.mpi-dialog .mpi-action{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:32px;border:1px solid var(--dsw-alias-border-l2,#4b4d52);border-radius:var(--dsw-radius-sm,7px);padding:6px 10px;background:transparent;color:inherit;font:inherit;font-size:12px;cursor:pointer}.mpi-dialog .mpi-action:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,#414247)}.mpi-dialog .mpi-action:disabled{cursor:not-allowed;opacity:.55}.mpi-dialog .mpi-primary{border-color:var(--dsw-alias-button-primary-fill,var(--dsw-alias-state-business-primary,#4f8cff));background:var(--dsw-alias-button-primary-fill,var(--dsw-alias-state-business-primary,#4f8cff));color:var(--dsw-alias-label-primary-foreground,#fff)}.mpi-progress{height:4px;margin-top:10px;overflow:hidden;border-radius:99px;background:var(--dsw-alias-border-l2,#4b4d52)}.mpi-progress::after{display:block;width:32%;height:100%;background:var(--dsw-alias-state-business-primary,#4f8cff);content:'';animation:mpi-wave 1.15s ease-in-out infinite}@keyframes mpi-wave{from{transform:translateX(-110%)}to{transform:translateX(330%)}}@media(max-width:560px){.mpi-overlay{padding:10px}.mpi-dialog{max-height:calc(100vh - 20px);padding:16px}.mpi-actions{align-items:stretch}.mpi-actions-group{justify-content:flex-end;flex-wrap:wrap}.mpi-meta{grid-template-columns:1fr;gap:2px}.mpi-meta dd{margin-bottom:6px}}
423
+ .dcp-update-version{margin-left:8px;color:var(--dsw-alias-label-tertiary,#9da1aa);font-family:inherit;font-size:12px;font-weight:500;line-height:18px;letter-spacing:0;white-space:nowrap;vertical-align:baseline}.dcp-update-check{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:28px;height:28px;padding:0 10px;border:0.5px solid var(--dsw-alias-border-l3,var(--dsw-alias-border-l2,#4b4d52));border-radius:var(--dsw-radius-sm,7px);background:transparent;color:var(--dsw-alias-label-secondary,#b8bbc2);font:inherit;font-size:12px;font-weight:500;line-height:18px;white-space:nowrap;cursor:pointer}.dcp-update-check:hover{background:var(--dsw-alias-interactive-bg-hover,#3a3b3f);color:var(--dsw-alias-label-primary,#fff)}.dcp-update-icon{display:inline-flex;flex:0 0 auto;width:16px;height:16px;align-items:center;justify-content:center;pointer-events:none}.dcp-update-icon svg{display:block;width:16px;height:16px}
424
+ .dcp-update-footer{display:flex;align-items:center;gap:8px}.dcp-update-sheet{display:block;min-width:0}
425
+ .dcp-update-content{min-width:0;display:flex;flex-direction:column;gap:0;font-family:inherit;color:var(--dsw-alias-label-primary,#fff)}
426
+ .dcp-update-intro{margin:0 0 16px;color:var(--dsw-alias-label-secondary,#c2c4ca);font-size:13px;line-height:20px}.dcp-update-meta{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:8px 18px;margin:0 0 16px;font-size:12px;line-height:18px}.dcp-update-meta dt{color:var(--dsw-alias-label-secondary,#c2c4ca)}.dcp-update-meta dd{margin:0;font-family:ui-monospace,SFMono-Regular,Consolas,monospace}.dcp-update-status{margin:0 0 18px;border-radius:var(--dsw-radius-sm,7px);padding:12px 14px;background:var(--dsw-alias-bg-layer-3,var(--dsw-specific-menu-item-hover,#252527));font-size:13px;font-weight:600;line-height:20px}.dcp-update-status[data-kind=error]{color:var(--dsw-alias-state-error-primary,#ff6464)}.dcp-update-status[data-kind=success]{color:var(--dsw-alias-state-success-primary,#36d67a)}.dcp-update-status[data-kind=update]{color:var(--dsw-alias-state-warn-primary,#e8b15a)}.dcp-update-manual{border-top:1px solid var(--dsw-alias-border-l2,#4b4d52);padding-top:16px}.dcp-update-manual h3{margin:0 0 6px;font-size:14px;line-height:20px}.dcp-update-manual p{margin:0 0 10px;color:var(--dsw-alias-label-secondary,#c2c4ca);font-size:12px;line-height:18px}.dcp-update-command{display:flex;align-items:center;gap:8px;border:1px solid var(--dsw-alias-border-l2,#4b4d52);border-radius:var(--dsw-radius-sm,7px);padding:10px;background:var(--dsw-alias-bg-layer-3,var(--dsw-specific-menu-item-hover,#252527))}.dcp-update-command code{min-width:0;flex:1;overflow:auto;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px;line-height:18px;white-space:nowrap}
427
+ .dcp-update-action{display:inline-flex;align-items:center;justify-content:center;gap:6px;box-sizing:border-box;min-height:28px;height:28px;border:0.5px solid var(--dsw-alias-border-l3,var(--dsw-alias-border-l2,#4b4d52));border-radius:var(--dsw-radius-sm,7px);padding:0 10px;background:transparent;color:var(--dsw-alias-label-primary,inherit);font:inherit;font-size:12px;font-weight:500;line-height:18px;white-space:nowrap;cursor:pointer}.dcp-update-action:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,#414247)}.dcp-update-action:disabled{cursor:not-allowed;opacity:.55}.dcp-update-primary{border-color:var(--dsw-alias-button-primary-fill,var(--dsw-alias-state-business-primary,#4f8cff));background:var(--dsw-alias-button-primary-fill,var(--dsw-alias-state-business-primary,#4f8cff));color:var(--dsw-alias-label-primary-foreground,#fff)}.dcp-update-action:focus-visible,.dcp-update-check:focus-visible{outline:var(--dsw-focus-ring-width,1px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary,#4f8cff));outline-offset:2px}
428
+ .dcp-update-progress{height:4px;margin-top:10px;overflow:hidden;border-radius:99px;background:var(--dsw-alias-border-l2,#4b4d52)}.dcp-update-progress::after{display:block;width:32%;height:100%;background:var(--dsw-alias-state-business-primary,#4f8cff);content:'';animation:dcp-update-wave 1.15s ease-in-out infinite}@keyframes dcp-update-wave{from{transform:translateX(-110%)}to{transform:translateX(330%)}}@media(max-width:560px){.dcp-update-meta{grid-template-columns:1fr;gap:2px}.dcp-update-meta dd{margin-bottom:6px}}
402
429
  `;
403
430
  var ZH = {
404
431
  unpublished: "\u5C1A\u672A\u53D1\u5E03\u5230 npm\uFF0C\u53D1\u5E03\u540E\u5373\u53EF\u68C0\u67E5\u5E76\u5B89\u88C5\u66F4\u65B0\u3002",
@@ -491,14 +518,6 @@ function manualPluginUpdateCommand(profileName, packageName, version) {
491
518
  const profile = profileName.trim() === "" ? "" : ` --profile ${profileName.trim()}`;
492
519
  return `dsh plugin${profile} add ${packageName}@${version} --registry=https://registry.npmjs.org/`;
493
520
  }
494
- function handlePluginUpdateEscape(event, close) {
495
- if (event.key !== "Escape") return false;
496
- event.preventDefault();
497
- event.stopPropagation();
498
- event.stopImmediatePropagation();
499
- close();
500
- return true;
501
- }
502
521
  function observePluginUpdate(options) {
503
522
  if (typeof document === "undefined" || document.body === null)
504
523
  return () => {
@@ -506,11 +525,11 @@ function observePluginUpdate(options) {
506
525
  ensureStyle();
507
526
  const controller = new AbortController();
508
527
  let payload;
509
- let overlay;
528
+ let mount;
510
529
  let frame;
511
530
  const setButtonContent = (button, label, iconName) => {
512
531
  const icon = options.createIcon(iconName);
513
- icon.classList.add("mpi-icon");
532
+ icon.classList.add("dcp-update-icon");
514
533
  icon.setAttribute("aria-hidden", "true");
515
534
  const text = document.createElement("span");
516
535
  text.dataset.mpiLabel = "";
@@ -530,7 +549,7 @@ function observePluginUpdate(options) {
530
549
  return;
531
550
  const button = document.createElement("button");
532
551
  button.type = "button";
533
- button.className = "mpi-check";
552
+ button.className = "dcp-update-check";
534
553
  button.dataset.mpiCheck = options.packageName;
535
554
  setButtonContent(button, strings(options.language).check, "refresh");
536
555
  button.addEventListener("click", openDialog);
@@ -547,45 +566,39 @@ function observePluginUpdate(options) {
547
566
  return payload;
548
567
  };
549
568
  const closeDialog = () => {
550
- overlay?.remove();
551
- overlay = void 0;
569
+ if (mount === void 0) return;
570
+ const { host, root } = mount;
571
+ mount = void 0;
572
+ root.unmount();
573
+ host.remove();
552
574
  };
553
575
  function openDialog() {
554
576
  closeDialog();
555
577
  const text = strings(options.language);
556
- overlay = document.createElement("div");
557
- overlay.className = "mpi-overlay";
558
578
  const dialog = document.createElement("section");
559
- dialog.className = "mpi-dialog";
560
- dialog.setAttribute("role", "dialog");
561
- dialog.setAttribute("aria-modal", "true");
562
- dialog.innerHTML = `<header class="mpi-head"><h2></h2><button type="button" class="mpi-dialog-close" data-action="close"></button></header><p class="mpi-intro"></p><dl class="mpi-meta"><dt></dt><dd data-role="current"></dd><dt></dt><dd data-role="latest"></dd><dt></dt><dd data-role="profile"></dd></dl><div class="mpi-status" role="status"></div><div class="mpi-progress" hidden></div><section class="mpi-manual"><h3></h3><p></p><div class="mpi-command"><code></code><button type="button" class="mpi-action" data-action="copy"></button></div></section><footer class="mpi-actions"><div class="mpi-actions-group"><button type="button" class="mpi-action" data-action="check"></button><button type="button" class="mpi-action mpi-primary" data-action="update"></button></div></footer>`;
579
+ dialog.className = "dcp-update-sheet";
580
+ dialog.innerHTML = `<p class="dcp-update-intro"></p><dl class="dcp-update-meta"><dt></dt><dd data-role="current"></dd><dt></dt><dd data-role="latest"></dd><dt></dt><dd data-role="profile"></dd></dl><div class="dcp-update-status" role="status"></div><div class="dcp-update-progress" hidden></div><section class="dcp-update-manual"><h3></h3><p></p><div class="dcp-update-command"><code></code><button type="button" class="dcp-update-action" data-action="copy"></button></div></section>`;
563
581
  const name2 = /^zh(?:-|$)/i.test(options.language) ? options.zhName : options.enName;
564
- dialog.querySelector("h2").textContent = `${name2} ${text.update}`;
565
- dialog.querySelector(".mpi-intro").textContent = text.intro;
582
+ dialog.querySelector(".dcp-update-intro").textContent = text.intro;
566
583
  const terms = dialog.querySelectorAll("dt");
567
584
  terms[0].textContent = text.current;
568
585
  terms[1].textContent = text.latestLabel;
569
586
  terms[2].textContent = text.profile;
570
- dialog.querySelector(".mpi-manual h3").textContent = text.manual;
571
- dialog.querySelector(".mpi-manual p").textContent = payload?.profileName === "desktop" ? text.manualHintDesktop : text.manualHint;
572
- const status = dialog.querySelector(".mpi-status");
573
- const progress = dialog.querySelector(".mpi-progress");
574
- const command = dialog.querySelector(".mpi-command code");
575
- const close = dialog.querySelector(
576
- "[data-action=close]"
577
- );
578
- const check = dialog.querySelector(
579
- "[data-action=check]"
580
- );
581
- const update = dialog.querySelector(
582
- "[data-action=update]"
583
- );
587
+ dialog.querySelector(".dcp-update-manual h3").textContent = text.manual;
588
+ dialog.querySelector(".dcp-update-manual p").textContent = payload?.profileName === "desktop" ? text.manualHintDesktop : text.manualHint;
589
+ const status = dialog.querySelector(".dcp-update-status");
590
+ const progress = dialog.querySelector(".dcp-update-progress");
591
+ const command = dialog.querySelector(".dcp-update-command code");
592
+ const check = document.createElement("button");
593
+ check.type = "button";
594
+ check.className = "dcp-update-action";
595
+ check.dataset.action = "check";
596
+ check.dataset.modalAutofocus = "true";
597
+ const update = document.createElement("button");
598
+ update.type = "button";
599
+ update.className = "dcp-update-action dcp-update-primary";
600
+ update.dataset.action = "update";
584
601
  const copy = dialog.querySelector("[data-action=copy]");
585
- setButtonContent(close, text.close, "close");
586
- close.querySelector("[data-mpi-label]")?.remove();
587
- close.setAttribute("aria-label", text.close);
588
- close.title = text.close;
589
602
  setButtonContent(check, text.recheck, "refresh");
590
603
  setButtonContent(update, text.auto, "download");
591
604
  setButtonContent(copy, text.copy, "copy");
@@ -606,7 +619,7 @@ function observePluginUpdate(options) {
606
619
  dialog.querySelector("[data-role=current]").textContent = payload === void 0 ? text.unknown : `v${payload.currentVersion}`;
607
620
  dialog.querySelector("[data-role=latest]").textContent = payload?.latestVersion === void 0 ? text.unknown : `v${payload.latestVersion}`;
608
621
  dialog.querySelector("[data-role=profile]").textContent = payload?.profileName ?? text.unknown;
609
- const hint = dialog.querySelector(".mpi-manual p");
622
+ const hint = dialog.querySelector(".dcp-update-manual p");
610
623
  if (hint !== null)
611
624
  hint.textContent = payload?.profileName === "desktop" ? text.manualHintDesktop : text.manualHint;
612
625
  command.textContent = manualPluginUpdateCommand(
@@ -669,7 +682,6 @@ function observePluginUpdate(options) {
669
682
  setBusy(false);
670
683
  }
671
684
  };
672
- close.addEventListener("click", closeDialog);
673
685
  check.addEventListener("click", () => {
674
686
  void checkNow();
675
687
  });
@@ -686,20 +698,33 @@ function observePluginUpdate(options) {
686
698
  setButtonLabel(copy, text.copyFailed);
687
699
  });
688
700
  });
689
- overlay.addEventListener("click", (event) => {
690
- if (event.target === overlay) closeDialog();
691
- });
692
- overlay.addEventListener(
693
- "keydown",
694
- (event) => {
695
- handlePluginUpdateEscape(event, closeDialog);
696
- },
697
- true
701
+ const host = document.createElement("div");
702
+ host.className = "dcp-update-host";
703
+ document.body.append(host);
704
+ const root = (0, import_client.createRoot)(host);
705
+ mount = { host, root };
706
+ root.render(
707
+ import_react2.default.createElement(import_dsh_client_ui_primitives.Modal, {
708
+ open: true,
709
+ className: "dcp-update-dialog",
710
+ title: `${name2} ${text.update}`,
711
+ closeLabel: text.close,
712
+ onClose: closeDialog,
713
+ footer: import_react2.default.createElement("div", {
714
+ className: "dcp-update-footer",
715
+ ref: (node) => {
716
+ if (node !== null && check.parentElement !== node) node.append(check, update);
717
+ }
718
+ }),
719
+ children: import_react2.default.createElement("div", {
720
+ className: "dcp-update-content",
721
+ ref: (node) => {
722
+ if (node !== null && !node.contains(dialog)) node.append(dialog);
723
+ }
724
+ })
725
+ })
698
726
  );
699
- overlay.append(dialog);
700
- (options.root?.closest("dialog[open]") ?? document.body).append(overlay);
701
727
  render();
702
- close.focus();
703
728
  void checkNow();
704
729
  }
705
730
  const observer = new MutationObserver(() => {
@@ -722,7 +747,7 @@ function observePluginUpdate(options) {
722
747
  closeDialog();
723
748
  if (frame !== void 0) window.cancelAnimationFrame(frame);
724
749
  (options.root ?? document).querySelectorAll(
725
- `[data-mpi-check="${options.packageName}"],.mpi-version[data-package="${options.packageName}"]`
750
+ `[data-mpi-check="${options.packageName}"],.dcp-update-version[data-package="${options.packageName}"]`
726
751
  ).forEach((node) => node.remove());
727
752
  };
728
753
  }
@@ -808,14 +833,14 @@ function createPluginUpdateIcon(name2) {
808
833
  return element;
809
834
  }
810
835
  function PluginUpdateHeader({ locale }) {
811
- const language = (0, import_react2.useSyncExternalStore)(
836
+ const language = (0, import_react3.useSyncExternalStore)(
812
837
  (fn) => locale?.subscribe(fn) ?? (() => {
813
838
  }),
814
839
  () => locale?.getSnapshot().active ?? "zh"
815
840
  );
816
841
  const zh2 = /^zh(?:-|$)/i.test(language);
817
- const root = (0, import_react2.useRef)(null);
818
- (0, import_react2.useEffect)(() => {
842
+ const root = (0, import_react3.useRef)(null);
843
+ (0, import_react3.useEffect)(() => {
819
844
  if (!root.current) return;
820
845
  return observePluginUpdate({
821
846
  language,
@@ -830,41 +855,49 @@ function PluginUpdateHeader({ locale }) {
830
855
  });
831
856
  }, [language]);
832
857
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
833
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { children: `.dcp-project-head{display:flex;align-items:center;justify-content:flex-start;gap:8px 12px;flex-wrap:wrap;margin-bottom:0}.dcp-project-head h1{display:inline-flex;align-items:baseline;margin:0;white-space:nowrap}.dcp-version{font-size:12px;font-weight:500;line-height:18px;color:var(--dsw-alias-label-tertiary,#9da1aa);margin-left:10px}.dcp-project-links{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.dcp-project-links a,.dcp-project-links button{display:inline-flex;align-items:center;justify-content:center;gap:4px;box-sizing:border-box;min-height:28px;height:28px;padding:0 10px;border:0.5px solid var(--dsw-alias-border-l3,var(--dsw-alias-border-l2,#383838));border-radius:var(--dsw-radius-sm,7px);background:transparent;color:var(--dsw-alias-label-primary,inherit);font-family:inherit;font-size:12px;font-weight:500;line-height:18px;text-decoration:none;white-space:nowrap;cursor:pointer}.dcp-project-links a:hover,.dcp-project-links button:hover{background:var(--dsw-alias-interactive-bg-hover,#ffffff0a);color:var(--dsw-alias-label-primary,inherit)}.dcp-project-links a:focus-visible,.dcp-project-links button:focus-visible{outline:var(--dsw-focus-ring-width,1px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary,#4f8cff));outline-offset:2px}.dcp-project-links svg{display:block;flex:none;width:16px;height:16px}` }),
858
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { children: `.dcp-project-head{display:flex;align-items:center;justify-content:flex-start;gap:8px 12px;flex-wrap:wrap;margin-bottom:0}.dcp-project-head h1{display:inline-flex;align-items:baseline;margin:0;white-space:nowrap}.dcp-version{font-size:12px;font-weight:500;line-height:18px;color:var(--dsw-alias-label-tertiary,#9da1aa);margin-left:10px}.dcp-project-links{display:flex;align-items:center;justify-content:flex-start;gap:8px;flex-wrap:nowrap;flex:0 0 auto}.dcp-project-links a,.dcp-project-links button{display:inline-flex;align-items:center;justify-content:center;gap:4px;box-sizing:border-box;min-height:28px;height:28px;padding:0 10px;border:0.5px solid var(--dsw-alias-border-l3,var(--dsw-alias-border-l2,#383838));border-radius:var(--dsw-radius-sm,7px);background:transparent;color:var(--dsw-alias-label-primary,inherit);font-family:inherit;font-size:12px;font-weight:500;line-height:18px;text-decoration:none;white-space:nowrap;cursor:pointer}.dcp-project-links a:hover,.dcp-project-links button:hover{background:var(--dsw-alias-interactive-bg-hover,#ffffff0a);color:var(--dsw-alias-label-primary,inherit)}.dcp-project-links a:focus-visible,.dcp-project-links button:focus-visible{outline:var(--dsw-focus-ring-width,1px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary,#4f8cff));outline-offset:2px}.dcp-project-links svg{display:block;flex:none;width:16px;height:16px}` }),
834
859
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { ref: root, className: "dcp-project-head", children: [
835
860
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h1", { children: [
836
861
  zh2 ? "\u5BA0\u7269" : "Pets",
837
862
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dcp-version", children: [
838
863
  "v",
839
- "1.0.6"
864
+ "1.0.8"
840
865
  ] })
841
866
  ] }),
842
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("nav", { className: "dcp-project-links", children: [
843
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
844
- "a",
845
- {
846
- href: "https://github.com/MichengAI/dsh-codex-pet",
847
- target: "_blank",
848
- rel: "noreferrer",
849
- children: [
850
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GithubMark16, {}),
851
- "GitHub"
852
- ]
853
- }
854
- ),
855
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
856
- "a",
857
- {
858
- href: "https://github.com/MichengAI/dsh-codex-pet/issues",
859
- target: "_blank",
860
- rel: "noreferrer",
861
- children: [
862
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FeedbackMark16, {}),
863
- zh2 ? "\u95EE\u9898\u53CD\u9988" : "Issues"
864
- ]
865
- }
866
- )
867
- ] })
867
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
868
+ "div",
869
+ {
870
+ className: "dcp-project-links",
871
+ role: "navigation",
872
+ "aria-label": zh2 ? "\u9879\u76EE\u94FE\u63A5" : "Project links",
873
+ children: [
874
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
875
+ "a",
876
+ {
877
+ href: "https://github.com/MichengAI/dsh-codex-pet",
878
+ target: "_blank",
879
+ rel: "noreferrer",
880
+ children: [
881
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GithubMark16, {}),
882
+ "GitHub"
883
+ ]
884
+ }
885
+ ),
886
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
887
+ "a",
888
+ {
889
+ href: "https://github.com/MichengAI/dsh-codex-pet/issues",
890
+ target: "_blank",
891
+ rel: "noreferrer",
892
+ children: [
893
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FeedbackMark16, {}),
894
+ zh2 ? "\u95EE\u9898\u53CD\u9988" : "Issues"
895
+ ]
896
+ }
897
+ )
898
+ ]
899
+ }
900
+ )
868
901
  ] })
869
902
  ] });
870
903
  }
@@ -890,7 +923,7 @@ function localizePet(pet, locale) {
890
923
  }
891
924
 
892
925
  // node_modules/@radix-ui/react-icons/dist/react-icons.esm.js
893
- var import_react3 = require("react");
926
+ var import_react4 = require("react");
894
927
  function _objectWithoutPropertiesLoose(source, excluded) {
895
928
  if (source == null) return {};
896
929
  var target = {};
@@ -904,9 +937,9 @@ function _objectWithoutPropertiesLoose(source, excluded) {
904
937
  return target;
905
938
  }
906
939
  var _excluded$i = ["color"];
907
- var ArrowTopRightIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, forwardedRef) {
940
+ var ArrowTopRightIcon = /* @__PURE__ */ (0, import_react4.forwardRef)(function(_ref, forwardedRef) {
908
941
  var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$i);
909
- return (0, import_react3.createElement)("svg", Object.assign({
942
+ return (0, import_react4.createElement)("svg", Object.assign({
910
943
  width: "15",
911
944
  height: "15",
912
945
  viewBox: "0 0 15 15",
@@ -914,7 +947,7 @@ var ArrowTopRightIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_
914
947
  xmlns: "http://www.w3.org/2000/svg"
915
948
  }, props, {
916
949
  ref: forwardedRef
917
- }), (0, import_react3.createElement)("path", {
950
+ }), (0, import_react4.createElement)("path", {
918
951
  d: "M3.64645 11.3536C3.45118 11.1583 3.45118 10.8417 3.64645 10.6465L10.2929 4L6 4C5.72386 4 5.5 3.77614 5.5 3.5C5.5 3.22386 5.72386 3 6 3L11.5 3C11.6326 3 11.7598 3.05268 11.8536 3.14645C11.9473 3.24022 12 3.36739 12 3.5L12 9.00001C12 9.27615 11.7761 9.50001 11.5 9.50001C11.2239 9.50001 11 9.27615 11 9.00001V4.70711L4.35355 11.3536C4.15829 11.5488 3.84171 11.5488 3.64645 11.3536Z",
919
952
  fill: color,
920
953
  fillRule: "evenodd",
@@ -922,9 +955,9 @@ var ArrowTopRightIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_
922
955
  }));
923
956
  });
924
957
  var _excluded$W = ["color"];
925
- var ChevronDownIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, forwardedRef) {
958
+ var ChevronDownIcon = /* @__PURE__ */ (0, import_react4.forwardRef)(function(_ref, forwardedRef) {
926
959
  var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$W);
927
- return (0, import_react3.createElement)("svg", Object.assign({
960
+ return (0, import_react4.createElement)("svg", Object.assign({
928
961
  width: "15",
929
962
  height: "15",
930
963
  viewBox: "0 0 15 15",
@@ -932,7 +965,7 @@ var ChevronDownIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_re
932
965
  xmlns: "http://www.w3.org/2000/svg"
933
966
  }, props, {
934
967
  ref: forwardedRef
935
- }), (0, import_react3.createElement)("path", {
968
+ }), (0, import_react4.createElement)("path", {
936
969
  d: "M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z",
937
970
  fill: color,
938
971
  fillRule: "evenodd",
@@ -940,9 +973,9 @@ var ChevronDownIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_re
940
973
  }));
941
974
  });
942
975
  var _excluded$1r = ["color"];
943
- var Cross2Icon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, forwardedRef) {
976
+ var Cross2Icon = /* @__PURE__ */ (0, import_react4.forwardRef)(function(_ref, forwardedRef) {
944
977
  var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$1r);
945
- return (0, import_react3.createElement)("svg", Object.assign({
978
+ return (0, import_react4.createElement)("svg", Object.assign({
946
979
  width: "15",
947
980
  height: "15",
948
981
  viewBox: "0 0 15 15",
@@ -950,7 +983,7 @@ var Cross2Icon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, fo
950
983
  xmlns: "http://www.w3.org/2000/svg"
951
984
  }, props, {
952
985
  ref: forwardedRef
953
- }), (0, import_react3.createElement)("path", {
986
+ }), (0, import_react4.createElement)("path", {
954
987
  d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",
955
988
  fill: color,
956
989
  fillRule: "evenodd",
@@ -958,9 +991,9 @@ var Cross2Icon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, fo
958
991
  }));
959
992
  });
960
993
  var _excluded$3a = ["color"];
961
- var MixerHorizontalIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, forwardedRef) {
994
+ var MixerHorizontalIcon = /* @__PURE__ */ (0, import_react4.forwardRef)(function(_ref, forwardedRef) {
962
995
  var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$3a);
963
- return (0, import_react3.createElement)("svg", Object.assign({
996
+ return (0, import_react4.createElement)("svg", Object.assign({
964
997
  width: "15",
965
998
  height: "15",
966
999
  viewBox: "0 0 15 15",
@@ -968,7 +1001,7 @@ var MixerHorizontalIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function
968
1001
  xmlns: "http://www.w3.org/2000/svg"
969
1002
  }, props, {
970
1003
  ref: forwardedRef
971
- }), (0, import_react3.createElement)("path", {
1004
+ }), (0, import_react4.createElement)("path", {
972
1005
  d: "M5.5 3C4.67157 3 4 3.67157 4 4.5C4 5.32843 4.67157 6 5.5 6C6.32843 6 7 5.32843 7 4.5C7 3.67157 6.32843 3 5.5 3ZM3 5C3.01671 5 3.03323 4.99918 3.04952 4.99758C3.28022 6.1399 4.28967 7 5.5 7C6.71033 7 7.71978 6.1399 7.95048 4.99758C7.96677 4.99918 7.98329 5 8 5H13.5C13.7761 5 14 4.77614 14 4.5C14 4.22386 13.7761 4 13.5 4H8C7.98329 4 7.96677 4.00082 7.95048 4.00242C7.71978 2.86009 6.71033 2 5.5 2C4.28967 2 3.28022 2.86009 3.04952 4.00242C3.03323 4.00082 3.01671 4 3 4H1.5C1.22386 4 1 4.22386 1 4.5C1 4.77614 1.22386 5 1.5 5H3ZM11.9505 10.9976C11.7198 12.1399 10.7103 13 9.5 13C8.28967 13 7.28022 12.1399 7.04952 10.9976C7.03323 10.9992 7.01671 11 7 11H1.5C1.22386 11 1 10.7761 1 10.5C1 10.2239 1.22386 10 1.5 10H7C7.01671 10 7.03323 10.0008 7.04952 10.0024C7.28022 8.8601 8.28967 8 9.5 8C10.7103 8 11.7198 8.8601 11.9505 10.0024C11.9668 10.0008 11.9833 10 12 10H13.5C13.7761 10 14 10.2239 14 10.5C14 10.7761 13.7761 11 13.5 11H12C11.9833 11 11.9668 10.9992 11.9505 10.9976ZM8 10.5C8 9.67157 8.67157 9 9.5 9C10.3284 9 11 9.67157 11 10.5C11 11.3284 10.3284 12 9.5 12C8.67157 12 8 11.3284 8 10.5Z",
973
1006
  fill: color,
974
1007
  fillRule: "evenodd",
@@ -976,9 +1009,9 @@ var MixerHorizontalIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function
976
1009
  }));
977
1010
  });
978
1011
  var _excluded$3x = ["color"];
979
- var PlusIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, forwardedRef) {
1012
+ var PlusIcon = /* @__PURE__ */ (0, import_react4.forwardRef)(function(_ref, forwardedRef) {
980
1013
  var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$3x);
981
- return (0, import_react3.createElement)("svg", Object.assign({
1014
+ return (0, import_react4.createElement)("svg", Object.assign({
982
1015
  width: "15",
983
1016
  height: "15",
984
1017
  viewBox: "0 0 15 15",
@@ -986,7 +1019,7 @@ var PlusIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, forw
986
1019
  xmlns: "http://www.w3.org/2000/svg"
987
1020
  }, props, {
988
1021
  ref: forwardedRef
989
- }), (0, import_react3.createElement)("path", {
1022
+ }), (0, import_react4.createElement)("path", {
990
1023
  d: "M8 2.75C8 2.47386 7.77614 2.25 7.5 2.25C7.22386 2.25 7 2.47386 7 2.75V7H2.75C2.47386 7 2.25 7.22386 2.25 7.5C2.25 7.77614 2.47386 8 2.75 8H7V12.25C7 12.5261 7.22386 12.75 7.5 12.75C7.77614 12.75 8 12.5261 8 12.25V8H12.25C12.5261 8 12.75 7.77614 12.75 7.5C12.75 7.22386 12.5261 7 12.25 7H8V2.75Z",
991
1024
  fill: color,
992
1025
  fillRule: "evenodd",
@@ -994,9 +1027,9 @@ var PlusIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, forw
994
1027
  }));
995
1028
  });
996
1029
  var _excluded$3A = ["color"];
997
- var QuestionMarkCircledIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, forwardedRef) {
1030
+ var QuestionMarkCircledIcon = /* @__PURE__ */ (0, import_react4.forwardRef)(function(_ref, forwardedRef) {
998
1031
  var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$3A);
999
- return (0, import_react3.createElement)("svg", Object.assign({
1032
+ return (0, import_react4.createElement)("svg", Object.assign({
1000
1033
  width: "15",
1001
1034
  height: "15",
1002
1035
  viewBox: "0 0 15 15",
@@ -1004,7 +1037,7 @@ var QuestionMarkCircledIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(func
1004
1037
  xmlns: "http://www.w3.org/2000/svg"
1005
1038
  }, props, {
1006
1039
  ref: forwardedRef
1007
- }), (0, import_react3.createElement)("path", {
1040
+ }), (0, import_react4.createElement)("path", {
1008
1041
  d: "M0.877075 7.49972C0.877075 3.84204 3.84222 0.876892 7.49991 0.876892C11.1576 0.876892 14.1227 3.84204 14.1227 7.49972C14.1227 11.1574 11.1576 14.1226 7.49991 14.1226C3.84222 14.1226 0.877075 11.1574 0.877075 7.49972ZM7.49991 1.82689C4.36689 1.82689 1.82708 4.36671 1.82708 7.49972C1.82708 10.6327 4.36689 13.1726 7.49991 13.1726C10.6329 13.1726 13.1727 10.6327 13.1727 7.49972C13.1727 4.36671 10.6329 1.82689 7.49991 1.82689ZM8.24993 10.5C8.24993 10.9142 7.91414 11.25 7.49993 11.25C7.08571 11.25 6.74993 10.9142 6.74993 10.5C6.74993 10.0858 7.08571 9.75 7.49993 9.75C7.91414 9.75 8.24993 10.0858 8.24993 10.5ZM6.05003 6.25C6.05003 5.57211 6.63511 4.925 7.50003 4.925C8.36496 4.925 8.95003 5.57211 8.95003 6.25C8.95003 6.74118 8.68002 6.99212 8.21447 7.27494C8.16251 7.30651 8.10258 7.34131 8.03847 7.37854L8.03841 7.37858C7.85521 7.48497 7.63788 7.61119 7.47449 7.73849C7.23214 7.92732 6.95003 8.23198 6.95003 8.7C6.95004 9.00376 7.19628 9.25 7.50004 9.25C7.8024 9.25 8.04778 9.00601 8.05002 8.70417L8.05056 8.7033C8.05924 8.6896 8.08493 8.65735 8.15058 8.6062C8.25207 8.52712 8.36508 8.46163 8.51567 8.37436L8.51571 8.37433C8.59422 8.32883 8.68296 8.27741 8.78559 8.21506C9.32004 7.89038 10.05 7.35382 10.05 6.25C10.05 4.92789 8.93511 3.825 7.50003 3.825C6.06496 3.825 4.95003 4.92789 4.95003 6.25C4.95003 6.55376 5.19628 6.8 5.50003 6.8C5.80379 6.8 6.05003 6.55376 6.05003 6.25Z",
1009
1042
  fill: color,
1010
1043
  fillRule: "evenodd",
@@ -1012,9 +1045,9 @@ var QuestionMarkCircledIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(func
1012
1045
  }));
1013
1046
  });
1014
1047
  var _excluded$3E = ["color"];
1015
- var ReloadIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, forwardedRef) {
1048
+ var ReloadIcon = /* @__PURE__ */ (0, import_react4.forwardRef)(function(_ref, forwardedRef) {
1016
1049
  var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$3E);
1017
- return (0, import_react3.createElement)("svg", Object.assign({
1050
+ return (0, import_react4.createElement)("svg", Object.assign({
1018
1051
  width: "15",
1019
1052
  height: "15",
1020
1053
  viewBox: "0 0 15 15",
@@ -1022,7 +1055,7 @@ var ReloadIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, fo
1022
1055
  xmlns: "http://www.w3.org/2000/svg"
1023
1056
  }, props, {
1024
1057
  ref: forwardedRef
1025
- }), (0, import_react3.createElement)("path", {
1058
+ }), (0, import_react4.createElement)("path", {
1026
1059
  d: "M1.84998 7.49998C1.84998 4.66458 4.05979 1.84998 7.49998 1.84998C10.2783 1.84998 11.6515 3.9064 12.2367 5H10.5C10.2239 5 10 5.22386 10 5.5C10 5.77614 10.2239 6 10.5 6H13.5C13.7761 6 14 5.77614 14 5.5V2.5C14 2.22386 13.7761 2 13.5 2C13.2239 2 13 2.22386 13 2.5V4.31318C12.2955 3.07126 10.6659 0.849976 7.49998 0.849976C3.43716 0.849976 0.849976 4.18537 0.849976 7.49998C0.849976 10.8146 3.43716 14.15 7.49998 14.15C9.44382 14.15 11.0622 13.3808 12.2145 12.2084C12.8315 11.5806 13.3133 10.839 13.6418 10.0407C13.7469 9.78536 13.6251 9.49315 13.3698 9.38806C13.1144 9.28296 12.8222 9.40478 12.7171 9.66014C12.4363 10.3425 12.0251 10.9745 11.5013 11.5074C10.5295 12.4963 9.16504 13.15 7.49998 13.15C4.05979 13.15 1.84998 10.3354 1.84998 7.49998Z",
1027
1060
  fill: color,
1028
1061
  fillRule: "evenodd",
@@ -1030,9 +1063,9 @@ var ReloadIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, fo
1030
1063
  }));
1031
1064
  });
1032
1065
  var _excluded$3F = ["color"];
1033
- var ResetIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, forwardedRef) {
1066
+ var ResetIcon = /* @__PURE__ */ (0, import_react4.forwardRef)(function(_ref, forwardedRef) {
1034
1067
  var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$3F);
1035
- return (0, import_react3.createElement)("svg", Object.assign({
1068
+ return (0, import_react4.createElement)("svg", Object.assign({
1036
1069
  width: "15",
1037
1070
  height: "15",
1038
1071
  viewBox: "0 0 15 15",
@@ -1040,7 +1073,7 @@ var ResetIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, for
1040
1073
  xmlns: "http://www.w3.org/2000/svg"
1041
1074
  }, props, {
1042
1075
  ref: forwardedRef
1043
- }), (0, import_react3.createElement)("path", {
1076
+ }), (0, import_react4.createElement)("path", {
1044
1077
  d: "M4.85355 2.14645C5.04882 2.34171 5.04882 2.65829 4.85355 2.85355L3.70711 4H9C11.4853 4 13.5 6.01472 13.5 8.5C13.5 10.9853 11.4853 13 9 13H5C4.72386 13 4.5 12.7761 4.5 12.5C4.5 12.2239 4.72386 12 5 12H9C10.933 12 12.5 10.433 12.5 8.5C12.5 6.567 10.933 5 9 5H3.70711L4.85355 6.14645C5.04882 6.34171 5.04882 6.65829 4.85355 6.85355C4.65829 7.04882 4.34171 7.04882 4.14645 6.85355L2.14645 4.85355C1.95118 4.65829 1.95118 4.34171 2.14645 4.14645L4.14645 2.14645C4.34171 1.95118 4.65829 1.95118 4.85355 2.14645Z",
1045
1078
  fill: color,
1046
1079
  fillRule: "evenodd",
@@ -1048,9 +1081,9 @@ var ResetIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, for
1048
1081
  }));
1049
1082
  });
1050
1083
  var _excluded$4d = ["color"];
1051
- var StopIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, forwardedRef) {
1084
+ var StopIcon = /* @__PURE__ */ (0, import_react4.forwardRef)(function(_ref, forwardedRef) {
1052
1085
  var _ref$color = _ref.color, color = _ref$color === void 0 ? "currentColor" : _ref$color, props = _objectWithoutPropertiesLoose(_ref, _excluded$4d);
1053
- return (0, import_react3.createElement)("svg", Object.assign({
1086
+ return (0, import_react4.createElement)("svg", Object.assign({
1054
1087
  width: "15",
1055
1088
  height: "15",
1056
1089
  viewBox: "0 0 15 15",
@@ -1058,7 +1091,7 @@ var StopIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, forw
1058
1091
  xmlns: "http://www.w3.org/2000/svg"
1059
1092
  }, props, {
1060
1093
  ref: forwardedRef
1061
- }), (0, import_react3.createElement)("path", {
1094
+ }), (0, import_react4.createElement)("path", {
1062
1095
  d: "M2 3C2 2.44772 2.44772 2 3 2H12C12.5523 2 13 2.44772 13 3V12C13 12.5523 12.5523 13 12 13H3C2.44772 13 2 12.5523 2 12V3ZM12 3H3V12H12V3Z",
1063
1096
  fill: color,
1064
1097
  fillRule: "evenodd",
@@ -1067,12 +1100,12 @@ var StopIcon = /* @__PURE__ */ (0, import_react3.forwardRef)(function(_ref, forw
1067
1100
  });
1068
1101
 
1069
1102
  // src/notification-tray.tsx
1070
- var import_react4 = require("react");
1103
+ var import_react5 = require("react");
1071
1104
  var import_jsx_runtime2 = require("react/jsx-runtime");
1072
1105
  function RequestForm({ item, command, language }) {
1073
1106
  const t = translator(language ?? "zh");
1074
- const [answers, setAnswers] = (0, import_react4.useState)({ answers: (item.request?.questions ?? []).map((q) => ({ id: q.id, selected: [] })) });
1075
- const [busy, setBusy] = (0, import_react4.useState)(false), [error, setError] = (0, import_react4.useState)("");
1107
+ const [answers, setAnswers] = (0, import_react5.useState)({ answers: (item.request?.questions ?? []).map((q) => ({ id: q.id, selected: [] })) });
1108
+ const [busy, setBusy] = (0, import_react5.useState)(false), [error, setError] = (0, import_react5.useState)("");
1076
1109
  const request2 = item.request;
1077
1110
  const run = async (value) => {
1078
1111
  setBusy(true);
@@ -1113,9 +1146,9 @@ function RequestForm({ item, command, language }) {
1113
1146
  }
1114
1147
  function NotificationTray({ state, command, language }) {
1115
1148
  const t = translator(language ?? "zh");
1116
- const [expanded, setExpanded] = (0, import_react4.useState)(false), [detail, setDetail] = (0, import_react4.useState)(null);
1117
- const [error, setError] = (0, import_react4.useState)("");
1118
- const [latest, setLatest] = (0, import_react4.useState)(false);
1149
+ const [expanded, setExpanded] = (0, import_react5.useState)(false), [detail, setDetail] = (0, import_react5.useState)(null);
1150
+ const [error, setError] = (0, import_react5.useState)("");
1151
+ const [latest, setLatest] = (0, import_react5.useState)(false);
1119
1152
  const run = async (value) => {
1120
1153
  setError("");
1121
1154
  try {
@@ -1175,8 +1208,8 @@ var polishedTrayStyles = `
1175
1208
  `;
1176
1209
 
1177
1210
  // src/ui.tsx
1178
- var import_react5 = require("react");
1179
- var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
1211
+ var import_react6 = require("react");
1212
+ var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
1180
1213
 
1181
1214
  // src/styles.ts
1182
1215
  var styles = `
@@ -1185,12 +1218,47 @@ var styles = `
1185
1218
  .dcp-page{box-sizing:border-box;display:flex;flex-direction:column;gap:14px;width:100%;min-width:0;padding:2px 0 36px;font-size:14px;line-height:1.5;container-type:inline-size}.dcp-page h1{font-size:24px;line-height:32px;font-weight:600;letter-spacing:-.4px;margin:0}.dcp-page h2{font-size:14px;line-height:22px;font-weight:600;margin:0}.dcp-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}.dcp-sub{color:var(--dsw-alias-label-tertiary,var(--pet-muted));margin:4px 0 0;font-size:14px;line-height:22px}.dcp-actions{display:flex;align-items:center;gap:8px}.dcp-icon-button{width:22px;min-width:22px;height:22px;padding:0;border-radius:var(--dsw-radius-sm,8px);background:transparent;color:var(--dsw-alias-label-secondary,#b9b9b9);border-color:var(--dsw-alias-border-l2)}.dcp-icon-button:hover:not(:disabled){color:var(--dsw-alias-link,#4176e6);border-color:var(--dsw-alias-link,#4176e6)}.dcp svg{width:16px;height:16px;flex-shrink:0}
1186
1219
  .dcp-card{border:0.5px solid var(--pet-line);border-radius:var(--dsw-radius-lg,16px);background:var(--dsw-alias-bg-layer-1,var(--pet-card));overflow:hidden;padding:0 14px}.dcp-row{display:flex;align-items:center;gap:12px;min-height:76px;border-bottom:0.5px solid var(--dsw-alias-border-l1,var(--pet-line))}.dcp-preview{width:52px;flex-shrink:0;display:flex;justify-content:center;align-items:center}.dcp-info{flex:1;min-width:0}.dcp-name{font-size:14px;font-weight:650;margin-bottom:3px}.dcp-description{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,var(--pet-muted));overflow-wrap:anywhere}.dcp-folder{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px 0}.dcp-path{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:11px;line-height:17px;color:var(--dsw-alias-label-tertiary,var(--pet-muted));overflow-wrap:anywhere}.dcp-folder-button{white-space:nowrap}.dcp-appearance{display:flex;flex-direction:column;gap:14px}.dcp-size{min-height:62px;display:flex;align-items:center;justify-content:space-between;padding:12px 16px}.dcp-size label{font-weight:600}.dcp-size input{width:160px;height:2px;accent-color:var(--dsw-alias-brand-primary,#fff);cursor:pointer}.dcp-size small{display:block;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,var(--pet-muted));font-weight:400;margin-top:2px}.dcp-note{margin:0;color:var(--dsw-alias-label-tertiary,var(--pet-muted));font-size:11px;line-height:17px}.dcp-error{padding:12px 14px;border:0.5px solid color-mix(in srgb,var(--dsw-alias-state-error-primary,#ed7272) 40%,transparent);border-radius:var(--dsw-radius-sm,8px);color:var(--dsw-alias-state-error-primary,#edb7a3);margin:0;font-size:12px;line-height:18px}.dcp-empty{padding:25px 14px;text-align:center;color:var(--dsw-alias-label-tertiary,var(--pet-muted));font-size:12px;line-height:18px}
1187
1220
  .dcp-floating{position:fixed;z-index:2147483000;pointer-events:none}.dcp-pet-button{display:block!important;padding:0!important;background:transparent!important;touch-action:none;cursor:grab!important;pointer-events:auto;user-select:none;-webkit-user-select:none}.dcp-pet-button:active{cursor:grabbing!important}.dcp-sprite{background-repeat:no-repeat;pointer-events:none;flex-shrink:0}.dcp-bubble{position:absolute;bottom:calc(100% + 16px);right:0;min-width:160px;max-width:240px;width:max-content;padding:10px 16px!important;border:1px solid var(--pet-line)!important;border-radius:28px!important;background:var(--pet-card)!important;text-align:left;box-shadow:0 2px 12px #0002;pointer-events:auto}.dcp-bubble strong{display:block;max-width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:12px}.dcp-bubble span{display:block;font-size:12px;color:var(--pet-muted)}.dcp-menu{position:absolute;right:0;bottom:100%;width:160px;padding:6px;border:1px solid var(--pet-line);background:var(--pet-card);border-radius:10px;pointer-events:auto;box-shadow:0 8px 32px #0004}.dcp-menu button{display:block;width:100%;text-align:left;padding:8px;border-radius:5px}.dcp-menu hr{border:0;border-top:1px solid var(--pet-line);margin:5px}
1188
- .dcp-dialog{color:var(--pet-text);background:var(--dsw-alias-bg-layer-2,var(--pet-card));border:0;border-radius:var(--dsw-radius-panel,16px);width:min(480px,calc(100vw - 32px));padding:24px;box-shadow:var(--dsw-elevation-prominent,0 16px 48px #0004)}.dcp-dialog[open]{display:flex;flex-direction:column;gap:12px}.dcp-dialog-close{align-self:flex-start}.dcp-dialog::backdrop{background:var(--dsw-alias-bg-mask-1,#0008);backdrop-filter:var(--dsw-mask-blur,none)}.dcp-create-dialog h2{font-size:16px;line-height:24px;font-weight:500;margin:0 0 12px}.dcp textarea.dcp-textarea{display:block;resize:vertical;width:100%;min-height:120px;color:var(--pet-text);background:var(--dsw-alias-bg-layer-1,var(--pet-bg));border:0.5px solid var(--dsw-alias-border-l4,var(--pet-line));border-radius:var(--dsw-radius-md,12px);padding:8px 12px;margin:16px 0;font-size:14px;line-height:22px}.dcp textarea.dcp-textarea:focus{outline:none;border-color:var(--dsw-alias-state-business-primary,var(--pet-line))}.dcp-dialog footer{display:flex;justify-content:flex-end;gap:8px}.dcp-creation{border-top:0.5px solid var(--pet-line);padding-top:12px}
1221
+ .dcp-dialog{color:var(--pet-text);background:var(--dsw-alias-bg-layer-2,var(--pet-card));border:0;border-radius:var(--dsw-radius-panel,16px);width:min(480px,calc(100vw - 32px));padding:24px;box-shadow:var(--dsw-elevation-prominent,0 16px 48px #0004)}.dcp-dialog[open]{display:flex;flex-direction:column;gap:12px}.dcp-dialog-close{align-self:flex-start}.dcp-dialog::backdrop{background:var(--dsw-alias-bg-mask-1,#0008);backdrop-filter:var(--dsw-mask-blur,none)}.dcp-settings-modal{width:min(800px,100%)!important;max-height:calc(100vh - 48px);padding:0!important;gap:0!important;overflow:hidden}.dcp-settings-modal-body{box-sizing:border-box;display:flex;flex-direction:column;gap:12px;max-height:calc(100vh - 48px);overflow:auto;padding:24px}.dcp-create-dialog h2{font-size:16px;line-height:24px;font-weight:500;margin:0 0 12px}.dcp textarea.dcp-textarea{display:block;resize:vertical;width:100%;min-height:120px;color:var(--pet-text);background:var(--dsw-alias-bg-layer-1,var(--pet-bg));border:0.5px solid var(--dsw-alias-border-l4,var(--pet-line));border-radius:var(--dsw-radius-md,12px);padding:8px 12px;margin:16px 0;font-size:14px;line-height:22px}.dcp textarea.dcp-textarea:focus{outline:none;border-color:var(--dsw-alias-state-business-primary,var(--pet-line))}.dcp-dialog footer{display:flex;justify-content:flex-end;gap:8px}.dcp-creation{border-top:0.5px solid var(--pet-line);padding-top:12px}
1189
1222
  .dcp-size input{-webkit-appearance:none;appearance:none;background:var(--pet-line);height:2px}.dcp-size input::-webkit-slider-thumb{-webkit-appearance:none;width:20px;height:20px;border-radius:50%;background:var(--dsw-alias-brand-primary,var(--pet-text))}
1190
1223
  @container(max-width:520px){.dcp-page h1{font-size:22px}.dcp-head{flex-wrap:wrap;gap:10px}.dcp-row{min-height:68px;gap:8px}.dcp-preview{width:44px}.dcp-description{font-size:11px}.dcp-card{padding:0 12px}.dcp-folder{align-items:flex-start}.dcp-size{padding:12px}.dcp-size input{width:130px}}
1191
1224
  @media(prefers-reduced-motion:reduce){.dcp *{animation:none!important;transition:none!important}}
1192
1225
  `;
1193
1226
 
1227
+ // src/sprite-clock.ts
1228
+ function runSpriteClock(options) {
1229
+ const { durations, timer, hidden, onVisible, onFrame } = options;
1230
+ const count = durations.length;
1231
+ let frame = 0;
1232
+ let handle = null;
1233
+ let live = true;
1234
+ const stop = () => {
1235
+ if (handle === null) return;
1236
+ timer.clearTimeout(handle);
1237
+ handle = null;
1238
+ };
1239
+ const advance = () => {
1240
+ handle = timer.setTimeout(() => {
1241
+ handle = null;
1242
+ if (!live || hidden()) return;
1243
+ frame = (frame + 1) % count;
1244
+ onFrame(frame);
1245
+ advance();
1246
+ }, durations[frame] ?? 0);
1247
+ };
1248
+ const resume = () => {
1249
+ if (!live || !options.animate || hidden()) return;
1250
+ stop();
1251
+ advance();
1252
+ };
1253
+ const off = onVisible(resume);
1254
+ if (options.animate && count > 0 && !hidden()) advance();
1255
+ return () => {
1256
+ live = false;
1257
+ off();
1258
+ stop();
1259
+ };
1260
+ }
1261
+
1194
1262
  // src/ui.tsx
1195
1263
  var import_jsx_runtime3 = require("react/jsx-runtime");
1196
1264
  async function request(path, data) {
@@ -1206,16 +1274,16 @@ async function request(path, data) {
1206
1274
  }
1207
1275
  var libraryStore = createLibraryStore(request);
1208
1276
  function usePetController(locale) {
1209
- const language = (0, import_react5.useSyncExternalStore)(
1277
+ const language = (0, import_react6.useSyncExternalStore)(
1210
1278
  (listener) => locale ? locale.subscribe(listener) : () => {
1211
1279
  },
1212
1280
  () => locale?.getSnapshot().active ?? "zh"
1213
1281
  );
1214
- const { library, error } = (0, import_react5.useSyncExternalStore)(
1282
+ const { library, error } = (0, import_react6.useSyncExternalStore)(
1215
1283
  libraryStore.subscribe,
1216
1284
  libraryStore.getSnapshot
1217
1285
  );
1218
- const localizedLibrary = (0, import_react5.useMemo)(
1286
+ const localizedLibrary = (0, import_react6.useMemo)(
1219
1287
  () => library ? {
1220
1288
  ...library,
1221
1289
  pets: library.pets.map((pet) => localizePet(pet, language))
@@ -1238,12 +1306,12 @@ function Sprite({
1238
1306
  animate = false,
1239
1307
  look = null
1240
1308
  }) {
1241
- const element = (0, import_react5.useRef)(null);
1242
- (0, import_react5.useEffect)(() => {
1309
+ const element = (0, import_react6.useRef)(null);
1310
+ (0, import_react6.useEffect)(() => {
1243
1311
  const node = element.current;
1244
1312
  if (!node) return;
1245
1313
  const animation = ANIMATIONS[pose];
1246
- let frame = 0, last = null, id = 0;
1314
+ let frame = 0;
1247
1315
  const reduced = window.matchMedia("(prefers-reduced-motion: reduce)");
1248
1316
  const paint = () => {
1249
1317
  const row = pet.version === 2 && look ? look.row : animation.row;
@@ -1251,17 +1319,24 @@ function Sprite({
1251
1319
  node.style.backgroundPosition = `${-col * size}px ${-row * size * 208 / 192}px`;
1252
1320
  };
1253
1321
  paint();
1254
- const tick = (time) => {
1255
- if (last === null || document.hidden) last = time;
1256
- if (!document.hidden && time - last >= animation.durations[frame]) {
1257
- last = time;
1258
- frame = (frame + 1) % animation.durations.length;
1322
+ const stopClock = runSpriteClock({
1323
+ durations: animation.durations,
1324
+ animate: animate && !look && !reduced.matches,
1325
+ timer: {
1326
+ setTimeout: (callback, delay) => window.setTimeout(callback, delay),
1327
+ clearTimeout: (id) => window.clearTimeout(id)
1328
+ },
1329
+ hidden: () => document.hidden,
1330
+ onVisible: (resume) => {
1331
+ document.addEventListener("visibilitychange", resume);
1332
+ return () => document.removeEventListener("visibilitychange", resume);
1333
+ },
1334
+ onFrame: (next) => {
1335
+ frame = next;
1259
1336
  paint();
1260
1337
  }
1261
- id = requestAnimationFrame(tick);
1262
- };
1263
- if (animate && !look && !reduced.matches) id = requestAnimationFrame(tick);
1264
- return () => cancelAnimationFrame(id);
1338
+ });
1339
+ return stopClock;
1265
1340
  }, [pet.id, pet.version, size, pose, animate, look]);
1266
1341
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1267
1342
  "div",
@@ -1280,19 +1355,24 @@ function Sprite({
1280
1355
  function Settings({
1281
1356
  controller,
1282
1357
  create,
1283
- locale
1358
+ locale,
1359
+ draft
1284
1360
  }) {
1285
1361
  const t = translator(controller.language);
1286
1362
  const { library, error } = controller;
1287
- const [busy, setBusy] = (0, import_react5.useState)(false), [showCreate, setShowCreate] = (0, import_react5.useState)(false), [description, setDescription] = (0, import_react5.useState)("");
1288
- const [size, setSize] = (0, import_react5.useState)(library?.config.size ?? 120);
1289
- const dialog = (0, import_react5.useRef)(null);
1290
- const createTitleId = (0, import_react5.useId)();
1291
- const [creationError, setCreationError] = (0, import_react5.useState)("");
1292
- (0, import_react5.useEffect)(() => {
1363
+ const [busy, setBusy] = (0, import_react6.useState)(false), [showCreate, setShowCreate] = (0, import_react6.useState)(false), [description, setDescription] = (0, import_react6.useState)(draft?.current ?? "");
1364
+ const changeDescription = (value) => {
1365
+ if (draft) draft.current = value;
1366
+ setDescription(value);
1367
+ };
1368
+ const [size, setSize] = (0, import_react6.useState)(library?.config.size ?? 120);
1369
+ const dialog = (0, import_react6.useRef)(null);
1370
+ const createTitleId = (0, import_react6.useId)();
1371
+ const [creationError, setCreationError] = (0, import_react6.useState)("");
1372
+ (0, import_react6.useEffect)(() => {
1293
1373
  if (library) setSize(library.config.size);
1294
1374
  }, [library?.config.size]);
1295
- (0, import_react5.useEffect)(() => {
1375
+ (0, import_react6.useEffect)(() => {
1296
1376
  if (showCreate) dialog.current?.showModal();
1297
1377
  else dialog.current?.close();
1298
1378
  }, [showCreate]);
@@ -1315,7 +1395,7 @@ function Settings({
1315
1395
  ] }),
1316
1396
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dcp-actions", children: [
1317
1397
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1318
- import_dsh_client_ui_primitives.Button,
1398
+ import_dsh_client_ui_primitives2.Button,
1319
1399
  {
1320
1400
  type: "button",
1321
1401
  variant: "outline",
@@ -1329,7 +1409,7 @@ function Settings({
1329
1409
  }
1330
1410
  ),
1331
1411
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1332
- import_dsh_client_ui_primitives.Button,
1412
+ import_dsh_client_ui_primitives2.Button,
1333
1413
  {
1334
1414
  type: "button",
1335
1415
  variant: "outline",
@@ -1343,7 +1423,7 @@ function Settings({
1343
1423
  }
1344
1424
  ),
1345
1425
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1346
- import_dsh_client_ui_primitives.Button,
1426
+ import_dsh_client_ui_primitives2.Button,
1347
1427
  {
1348
1428
  type: "button",
1349
1429
  variant: "outline",
@@ -1367,7 +1447,7 @@ function Settings({
1367
1447
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dcp-description", children: pet.description })
1368
1448
  ] }),
1369
1449
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1370
- import_dsh_client_ui_primitives.Button,
1450
+ import_dsh_client_ui_primitives2.Button,
1371
1451
  {
1372
1452
  type: "button",
1373
1453
  variant: library.config.selected === pet.id ? "ghost" : "outline",
@@ -1387,7 +1467,7 @@ function Settings({
1387
1467
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dcp-path", children: library?.customPath ?? t("\u6B63\u5728\u8BFB\u53D6\u76EE\u5F55\u2026") })
1388
1468
  ] }),
1389
1469
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1390
- import_dsh_client_ui_primitives.Button,
1470
+ import_dsh_client_ui_primitives2.Button,
1391
1471
  {
1392
1472
  type: "button",
1393
1473
  variant: "outline",
@@ -1451,7 +1531,7 @@ function Settings({
1451
1531
  setCreationError("");
1452
1532
  void create(description).then(() => {
1453
1533
  setShowCreate(false);
1454
- setDescription("");
1534
+ changeDescription("");
1455
1535
  }).catch(
1456
1536
  (error2) => setCreationError(
1457
1537
  error2 instanceof Error ? error2.message : t("\u521B\u5EFA\u5931\u8D25")
@@ -1471,7 +1551,7 @@ function Settings({
1471
1551
  ),
1472
1552
  maxLength: 2e3,
1473
1553
  value: description,
1474
- onChange: (event) => setDescription(event.target.value),
1554
+ onChange: (event) => changeDescription(event.target.value),
1475
1555
  required: true
1476
1556
  }
1477
1557
  ),
@@ -1484,7 +1564,7 @@ function Settings({
1484
1564
  creationError && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { role: "alert", className: "dcp-error", children: t(creationError) }),
1485
1565
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("footer", { children: [
1486
1566
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1487
- import_dsh_client_ui_primitives.Button,
1567
+ import_dsh_client_ui_primitives2.Button,
1488
1568
  {
1489
1569
  type: "button",
1490
1570
  variant: "ghost",
@@ -1494,7 +1574,7 @@ function Settings({
1494
1574
  }
1495
1575
  ),
1496
1576
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1497
- import_dsh_client_ui_primitives.Button,
1577
+ import_dsh_client_ui_primitives2.Button,
1498
1578
  {
1499
1579
  type: "submit",
1500
1580
  variant: "primary",
@@ -1521,25 +1601,37 @@ function FloatingPet({
1521
1601
  tray
1522
1602
  }) {
1523
1603
  const t = translator(pet.displayLocale ?? "zh");
1524
- const root = (0, import_react5.useRef)(null);
1525
- const drag = (0, import_react5.useRef)(null);
1526
- const [position, setPosition] = (0, import_react5.useState)({ left: 0, top: 0 }), [action, setAction] = (0, import_react5.useState)(null), [look, setLook] = (0, import_react5.useState)(null), [menu, setMenu] = (0, import_react5.useState)(false);
1527
- const timer = (0, import_react5.useRef)(null);
1528
- const [menuError, setMenuError] = (0, import_react5.useState)("");
1604
+ const root = (0, import_react6.useRef)(null);
1605
+ const drag = (0, import_react6.useRef)(null);
1606
+ const [position, setPosition] = (0, import_react6.useState)({ left: 0, top: 0 }), [action, setAction] = (0, import_react6.useState)(null), [look, setLook] = (0, import_react6.useState)(null), [menu, setMenu] = (0, import_react6.useState)(false);
1607
+ const timer = (0, import_react6.useRef)(null);
1608
+ const [menuError, setMenuError] = (0, import_react6.useState)("");
1529
1609
  const petHeight = config.size * 208 / 192;
1530
- const place = (0, import_react5.useCallback)(() => {
1610
+ const place = (0, import_react6.useCallback)(() => {
1531
1611
  const width = Math.max(0, innerWidth - config.size - 16), height = Math.max(0, innerHeight - petHeight - 32);
1532
1612
  setPosition({
1533
1613
  left: config.position ? config.position.x * width : width,
1534
1614
  top: config.position ? config.position.y * height : height
1535
1615
  });
1536
1616
  }, [config.size, config.position, petHeight]);
1537
- (0, import_react5.useEffect)(() => {
1617
+ (0, import_react6.useEffect)(() => {
1538
1618
  place();
1539
1619
  window.addEventListener("resize", place);
1540
1620
  return () => window.removeEventListener("resize", place);
1541
1621
  }, [place]);
1542
- const perform = (0, import_react5.useCallback)((pose) => {
1622
+ const center = (0, import_react6.useRef)(null);
1623
+ const measuredAt = (0, import_react6.useRef)(0);
1624
+ const measure = (0, import_react6.useCallback)(() => {
1625
+ const box = root.current?.getBoundingClientRect();
1626
+ center.current = box ? { x: box.left + box.width / 2, y: box.top + box.height / 2 } : null;
1627
+ measuredAt.current = Date.now();
1628
+ }, []);
1629
+ (0, import_react6.useEffect)(() => {
1630
+ measure();
1631
+ window.addEventListener("resize", measure);
1632
+ return () => window.removeEventListener("resize", measure);
1633
+ }, [measure, position.left, position.top, config.size, petHeight]);
1634
+ const perform = (0, import_react6.useCallback)((pose) => {
1543
1635
  if (timer.current) clearTimeout(timer.current);
1544
1636
  setLook(null);
1545
1637
  setAction(pose);
@@ -1549,38 +1641,40 @@ function FloatingPet({
1549
1641
  anim.durations.reduce((sum, value) => sum + value, 0)
1550
1642
  );
1551
1643
  }, []);
1552
- (0, import_react5.useEffect)(
1644
+ (0, import_react6.useEffect)(
1553
1645
  () => () => {
1554
1646
  if (timer.current) clearTimeout(timer.current);
1555
1647
  },
1556
1648
  []
1557
1649
  );
1558
- (0, import_react5.useEffect)(() => {
1650
+ (0, import_react6.useEffect)(() => {
1559
1651
  const interval = setInterval(() => {
1560
1652
  if (activity.pose === "idle" && !action && !drag.current && !document.hidden && !window.matchMedia("(prefers-reduced-motion: reduce)").matches)
1561
1653
  perform(Math.random() < 0.7 ? "waving" : "jumping");
1562
1654
  }, 18e3);
1563
1655
  return () => clearInterval(interval);
1564
1656
  }, [activity.pose, action, perform]);
1565
- (0, import_react5.useEffect)(() => {
1657
+ (0, import_react6.useEffect)(() => {
1566
1658
  const track = (event) => {
1567
1659
  if (activity.pose !== "idle" || action || drag.current || pet.version !== 2) {
1568
1660
  setLook(null);
1569
1661
  return;
1570
1662
  }
1571
- const box = root.current?.getBoundingClientRect();
1572
- if (box)
1573
- setLook(
1574
- lookCell(
1575
- event.clientX - box.left - config.size / 2,
1576
- event.clientY - box.top - petHeight / 2
1577
- )
1578
- );
1663
+ if (Date.now() - measuredAt.current > 500) measure();
1664
+ const origin = center.current;
1665
+ if (!origin) return;
1666
+ const cell = lookCell(
1667
+ event.clientX - origin.x,
1668
+ event.clientY - origin.y
1669
+ );
1670
+ setLook(
1671
+ (current) => current === cell || current !== null && cell !== null && current.row === cell.row && current.col === cell.col ? current : cell
1672
+ );
1579
1673
  };
1580
1674
  window.addEventListener("mousemove", track);
1581
1675
  return () => window.removeEventListener("mousemove", track);
1582
- }, [activity.pose, action, pet.version, config.size, petHeight]);
1583
- (0, import_react5.useEffect)(() => {
1676
+ }, [activity.pose, action, pet.version, measure]);
1677
+ (0, import_react6.useEffect)(() => {
1584
1678
  if (!menu) return;
1585
1679
  const close = (event) => {
1586
1680
  if (!root.current?.contains(event.target)) setMenu(false);
@@ -1839,7 +1933,7 @@ function Companion({
1839
1933
  const selected = library?.pets.find(
1840
1934
  (item) => item.id === library.config.selected
1841
1935
  );
1842
- const pet = (0, import_react5.useMemo)(
1936
+ const pet = (0, import_react6.useMemo)(
1843
1937
  () => selected ? { ...selected, displayLocale: controller.language } : void 0,
1844
1938
  [selected, controller.language]
1845
1939
  );
@@ -1880,31 +1974,38 @@ function validateAnswers(questions, value) {
1880
1974
  }
1881
1975
  return value;
1882
1976
  }
1883
- function createNotifications(sessions, pending, notify, now = Date.now) {
1977
+ function createNotifications(sessions, pending, notify, now = Date.now, carried = /* @__PURE__ */ new Map()) {
1884
1978
  const records = /* @__PURE__ */ new Map();
1885
1979
  const bindings = /* @__PURE__ */ new Map();
1886
- const dismissed = /* @__PURE__ */ new Map();
1980
+ const dismissed = carried;
1887
1981
  const busy = /* @__PURE__ */ new Set();
1888
1982
  const answered = /* @__PURE__ */ new Set();
1889
1983
  let state = { items: [], activity: IDLE, hidden: 0 }, latestFirst = false;
1890
1984
  let publishing = false;
1891
1985
  let lastPublished = "";
1986
+ const HOT_GRACE_MS = 3e4;
1987
+ const hotUntil = /* @__PURE__ */ new Map();
1988
+ const releaseBinding = (id) => sessions.releaseBinding?.(id);
1892
1989
  const publish = () => {
1893
1990
  if (publishing) return;
1894
1991
  publishing = true;
1895
1992
  try {
1993
+ sessions.sweepBindings?.();
1896
1994
  const list = sessions.list.getSnapshot(), requests = pending.getSnapshot(), statuses = sessions.status?.getSnapshot();
1897
1995
  const current = selectedSessionId(list);
1996
+ const stamp = now();
1898
1997
  const ids = new Set(list.ids.filter((id) => list.byId[id] && list.byId[id].origin !== "subagent"));
1899
1998
  for (const id of records.keys()) if (!ids.has(id)) {
1900
1999
  records.delete(id);
1901
2000
  dismissed.delete(id);
2001
+ hotUntil.delete(id);
1902
2002
  }
1903
2003
  for (const [id, bound] of bindings) if (!ids.has(id)) {
1904
2004
  bound.off();
1905
2005
  bindings.delete(id);
1906
2006
  records.delete(id);
1907
2007
  dismissed.delete(id);
2008
+ hotUntil.delete(id);
1908
2009
  }
1909
2010
  const items = [];
1910
2011
  let hidden = 0;
@@ -1912,10 +2013,24 @@ function createNotifications(sessions, pending, notify, now = Date.now) {
1912
2013
  const row = list.byId[id];
1913
2014
  if (!row) continue;
1914
2015
  const status = statuses?.get(id);
1915
- const binding = sessions.binding(id);
2016
+ const request2 = requests.get(id);
2017
+ const active = !!status?.running || !!row.running || !!request2 || !!status?.pendingInteraction || !!status?.completionUnread || id === current;
2018
+ if (active) hotUntil.set(id, stamp + HOT_GRACE_MS);
2019
+ const hot = active || (hotUntil.get(id) ?? 0) > stamp;
2020
+ if (!hot) {
2021
+ hotUntil.delete(id);
2022
+ const previous2 = bindings.get(id);
2023
+ if (previous2) {
2024
+ previous2.off();
2025
+ bindings.delete(id);
2026
+ }
2027
+ releaseBinding(id);
2028
+ if (!records.has(id)) continue;
2029
+ }
2030
+ const binding = hot ? sessions.binding(id) : void 0;
1916
2031
  let record = records.get(id);
1917
2032
  if (!record) {
1918
- record = { round: 0, running: row.running, completion: !!status?.completionUnread, error: null, revision: binding?.eventSource?.getSnapshot().revision ?? -1, updatedAt: row.updatedAt ?? now(), lastPose: "" };
2033
+ record = { fresh: true, round: 0, running: row.running, completion: !!status?.completionUnread, error: null, revision: binding?.eventSource?.getSnapshot().revision ?? -1, updatedAt: row.updatedAt ?? now(), lastPose: "" };
1919
2034
  records.set(id, record);
1920
2035
  }
1921
2036
  const previous = bindings.get(id);
@@ -1931,6 +2046,7 @@ function createNotifications(sessions, pending, notify, now = Date.now) {
1931
2046
  const snapshot = binding?.session.getSnapshot();
1932
2047
  const running = status?.running ?? (id === current ? snapshot?.running ?? row.running : row.running);
1933
2048
  if (running && !record.running) {
2049
+ record.fresh = false;
1934
2050
  record.round++;
1935
2051
  record.awaitingStart = true;
1936
2052
  record.finished = void 0;
@@ -1945,6 +2061,7 @@ function createNotifications(sessions, pending, notify, now = Date.now) {
1945
2061
  if (events.change.kind === "append") for (const entry of events.change.entries) {
1946
2062
  if (entry.type !== "event") continue;
1947
2063
  if (entry.event.type === "turn/start") {
2064
+ record.fresh = false;
1948
2065
  if (!record.awaitingStart) record.round++;
1949
2066
  record.awaitingStart = false;
1950
2067
  record.finished = void 0;
@@ -1961,22 +2078,24 @@ function createNotifications(sessions, pending, notify, now = Date.now) {
1961
2078
  }
1962
2079
  const stopped = !running && record.running;
1963
2080
  record.running = running;
1964
- const agentError = snapshot?.lastAgentError ?? snapshot?.promptError?.error?.message ?? null;
1965
- if (agentError && agentError !== record.snapshotError) record.error = agentError;
1966
- record.snapshotError = agentError;
2081
+ if (snapshot !== void 0) {
2082
+ const agentError = snapshot.lastAgentError ?? snapshot.promptError?.error?.message ?? null;
2083
+ if (agentError && agentError !== record.snapshotError) record.error = agentError;
2084
+ record.snapshotError = agentError;
2085
+ }
1967
2086
  if (stopped && !record.suppressStopCompletion && !record.finished && !record.error) {
1968
2087
  record.completion = true;
1969
2088
  record.updatedAt = now();
1970
2089
  }
1971
2090
  if (status?.completionUnread && !running && (!record.finished || record.finished === "completed")) record.completion = true;
1972
- const request2 = requests.get(id);
1973
2091
  const activity = selectActivity([{ id, title: row.title ?? row.displayTitle, running, waiting: !!request2, error: running ? null : record.error, completed: !running && record.completion }]);
1974
2092
  if (activity.pose === "idle") continue;
1975
2093
  if (record.lastPose && record.lastPose !== activity.pose || record.requestKey !== request2?.key) record.updatedAt = now();
1976
2094
  record.lastPose = activity.pose;
1977
2095
  record.requestKey = request2?.key;
1978
2096
  const token = `${record.round}:${request2?.key ?? ""}`;
1979
- if (dismissed.get(id) === token) {
2097
+ const muted = dismissed.get(id);
2098
+ if (muted !== void 0 && muted.pose === activity.pose && muted.mark === (row.updatedAt ?? 0) && (muted.token === token || record.fresh === true)) {
1980
2099
  hidden++;
1981
2100
  continue;
1982
2101
  }
@@ -2013,14 +2132,14 @@ function createNotifications(sessions, pending, notify, now = Date.now) {
2013
2132
  const item = state.items.find((item2) => item2.id === command.id && item2.token === command.token);
2014
2133
  if (!item) throw new Error("\u8FD9\u6761\u901A\u77E5\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u4F7F\u7528\u6700\u65B0\u901A\u77E5");
2015
2134
  if (command.type === "dismiss") {
2016
- dismissed.set(item.id, item.token);
2135
+ dismissed.set(item.id, { mark: sessions.list.getSnapshot().byId[item.id]?.updatedAt ?? 0, token: item.token, pose: item.pose });
2017
2136
  publish();
2018
2137
  return;
2019
2138
  }
2020
2139
  if (command.type === "open") {
2021
2140
  if (!sessions.open) throw new Error("\u5BBF\u4E3B\u672A\u63D0\u4F9B\u6253\u5F00\u4F1A\u8BDD\u80FD\u529B");
2022
2141
  sessions.open(item.id);
2023
- if (item.pose === "review") dismissed.set(item.id, item.token);
2142
+ if (item.pose === "review") dismissed.set(item.id, { mark: sessions.list.getSnapshot().byId[item.id]?.updatedAt ?? 0, token: item.token, pose: item.pose });
2024
2143
  publish();
2025
2144
  return;
2026
2145
  }
@@ -2084,7 +2203,7 @@ async function createPetSession(sessions, description, directory, skill) {
2084
2203
  if (!result.ok) throw new Error(result.error?.message ?? "DSH \u672A\u63A5\u53D7\u5BA0\u7269\u521B\u5EFA\u8BF7\u6C42");
2085
2204
  };
2086
2205
  tryOpen(sessions, id);
2087
- const binding = sessions.binding(id);
2206
+ const binding = sessions.binding(id, "creation");
2088
2207
  if (binding?.session.prompt) {
2089
2208
  await send(binding.session);
2090
2209
  tryOpen(sessions, id);
@@ -2165,20 +2284,52 @@ function observePetSettingsIcon() {
2165
2284
  ensureNavIconStyle();
2166
2285
  let disposed = false;
2167
2286
  let frame;
2287
+ let timer;
2288
+ let lastRun = Number.NEGATIVE_INFINITY;
2289
+ const markedRows = /* @__PURE__ */ new Set();
2168
2290
  const hasSettingsSurface = () => document.querySelector(
2169
2291
  '.dcu-settings-page, .dcu-settings-link, [data-shortcut-modal="settings"]'
2170
2292
  ) !== null;
2293
+ let surfaceOpen = false;
2171
2294
  const sync = () => {
2172
2295
  frame = void 0;
2173
2296
  if (disposed) return;
2174
- if (!hasSettingsSurface() && document.querySelector(`[${PET_NAV_ICON_MARKER}]`) === null)
2175
- return;
2297
+ lastRun = performance.now();
2298
+ surfaceOpen = hasSettingsSurface();
2299
+ if (!surfaceOpen && markedRows.size === 0) return;
2176
2300
  for (const row of document.querySelectorAll(PET_NAV_ROW_SELECTOR)) {
2177
2301
  applyPetSettingsIcon(row);
2302
+ if (row.hasAttribute(PET_NAV_ICON_MARKER)) markedRows.add(row);
2303
+ else markedRows.delete(row);
2178
2304
  }
2305
+ for (const row of markedRows) if (!row.isConnected) markedRows.delete(row);
2179
2306
  };
2307
+ const MIN_INTERVAL = 150;
2180
2308
  const schedule = () => {
2181
- if (frame !== void 0 || disposed) return;
2309
+ if (disposed) return;
2310
+ const open = hasSettingsSurface();
2311
+ if (open && !surfaceOpen) {
2312
+ if (timer !== void 0) {
2313
+ window.clearTimeout(timer);
2314
+ timer = void 0;
2315
+ }
2316
+ if (frame !== void 0) {
2317
+ window.cancelAnimationFrame(frame);
2318
+ frame = void 0;
2319
+ }
2320
+ sync();
2321
+ return;
2322
+ }
2323
+ if (!open) surfaceOpen = false;
2324
+ if (frame !== void 0 || timer !== void 0) return;
2325
+ const wait = MIN_INTERVAL - (performance.now() - lastRun);
2326
+ if (wait > 0) {
2327
+ timer = window.setTimeout(() => {
2328
+ timer = void 0;
2329
+ schedule();
2330
+ }, wait);
2331
+ return;
2332
+ }
2182
2333
  frame = window.requestAnimationFrame(sync);
2183
2334
  };
2184
2335
  sync();
@@ -2192,6 +2343,7 @@ function observePetSettingsIcon() {
2192
2343
  disposed = true;
2193
2344
  observer.disconnect();
2194
2345
  if (frame !== void 0) window.cancelAnimationFrame(frame);
2346
+ if (timer !== void 0) window.clearTimeout(timer);
2195
2347
  for (const row of document.querySelectorAll(`[${PET_NAV_ICON_MARKER}]`)) {
2196
2348
  restorePetSettingsIcon(row);
2197
2349
  }
@@ -2200,11 +2352,11 @@ function observePetSettingsIcon() {
2200
2352
  }
2201
2353
 
2202
2354
  // src/global-overlay.tsx
2203
- var import_react6 = require("react");
2355
+ var import_react7 = require("react");
2204
2356
  var import_react_dom = require("react-dom");
2205
2357
  function GlobalOverlay({ children }) {
2206
- const [container, setContainer] = (0, import_react6.useState)(null);
2207
- (0, import_react6.useEffect)(() => {
2358
+ const [container, setContainer] = (0, import_react7.useState)(null);
2359
+ (0, import_react7.useEffect)(() => {
2208
2360
  const element = document.createElement("div");
2209
2361
  element.setAttribute("data-dsh-pet-overlay", "");
2210
2362
  element.style.cssText = "position:fixed;left:0;top:0;width:0;height:0;overflow:visible;z-index:2147483000;pointer-events:none";
@@ -2219,6 +2371,11 @@ function GlobalOverlay({ children }) {
2219
2371
  var import_jsx_runtime4 = require("react/jsx-runtime");
2220
2372
  var name = "michengai-codex-pet";
2221
2373
  var inject = ["slots", "sessions", "locale"];
2374
+ var EMPTY_NOTIFICATIONS = {
2375
+ items: [],
2376
+ activity: IDLE,
2377
+ hidden: 0
2378
+ };
2222
2379
  function openSettings() {
2223
2380
  const trigger = document.querySelector("[data-dcu-settings-trigger]");
2224
2381
  if (trigger)
@@ -2238,31 +2395,41 @@ function Overlay({
2238
2395
  }) {
2239
2396
  const controller = usePetController(locale);
2240
2397
  const t = translator(controller.language);
2241
- const settingsDialog = (0, import_react7.useRef)(null);
2242
- (0, import_react7.useEffect)(() => {
2243
- const show = () => {
2244
- if (!settingsDialog.current?.open) settingsDialog.current?.showModal();
2245
- };
2398
+ const [settingsOpen, setSettingsOpen] = (0, import_react8.useState)(false);
2399
+ (0, import_react8.useEffect)(() => {
2400
+ const show = () => setSettingsOpen(true);
2246
2401
  window.addEventListener("dcp-open-settings", show);
2247
2402
  return () => window.removeEventListener("dcp-open-settings", show);
2248
2403
  }, []);
2249
- const [state, setState] = (0, import_react7.useState)({
2250
- items: [],
2251
- activity: IDLE,
2252
- hidden: 0
2253
- });
2254
- const notifications = (0, import_react7.useRef)(
2404
+ const [state, setState] = (0, import_react8.useState)(EMPTY_NOTIFICATIONS);
2405
+ const notifications = (0, import_react8.useRef)(
2255
2406
  null
2256
2407
  );
2257
- (0, import_react7.useEffect)(() => {
2258
- const engine = createNotifications(sessions, pending, setState);
2408
+ const dismissed = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
2409
+ const createDraft = (0, import_react8.useRef)("");
2410
+ const petVisible = controller.library?.config.visible === true;
2411
+ (0, import_react8.useEffect)(() => {
2412
+ if (!petVisible) {
2413
+ setState(
2414
+ (current) => current.items.length === 0 && current.activity.pose === "idle" && current.hidden === 0 ? current : EMPTY_NOTIFICATIONS
2415
+ );
2416
+ return;
2417
+ }
2418
+ const engine = createNotifications(
2419
+ sessions,
2420
+ pending,
2421
+ setState,
2422
+ Date.now,
2423
+ dismissed.current
2424
+ );
2259
2425
  notifications.current = engine;
2260
2426
  return () => {
2261
2427
  notifications.current = null;
2262
2428
  engine.dispose();
2429
+ sessions.releaseBindings();
2263
2430
  };
2264
- }, [sessions, pending]);
2265
- (0, import_react7.useEffect)(observePetSettingsIcon, []);
2431
+ }, [sessions, pending, petVisible]);
2432
+ (0, import_react8.useEffect)(observePetSettingsIcon, []);
2266
2433
  const command = async (value) => {
2267
2434
  const engine = notifications.current;
2268
2435
  if (!engine) throw new Error("\u4F1A\u8BDD\u670D\u52A1\u5C1A\u672A\u5C31\u7EEA");
@@ -2272,17 +2439,17 @@ function Overlay({
2272
2439
  }
2273
2440
  await engine.command(value);
2274
2441
  };
2275
- const [externalDisplay, setExternalDisplay] = (0, import_react7.useState)(false);
2276
- const actions = (0, import_react7.useRef)({
2442
+ const [externalDisplay, setExternalDisplay] = (0, import_react8.useState)(false);
2443
+ const actions = (0, import_react8.useRef)({
2277
2444
  command,
2278
2445
  updateConfig: controller.update,
2279
2446
  openSettings
2280
2447
  });
2281
2448
  actions.current = { command, updateConfig: controller.update, openSettings };
2282
- const provider = (0, import_react7.useRef)(
2449
+ const provider = (0, import_react8.useRef)(
2283
2450
  null
2284
2451
  );
2285
- (0, import_react7.useEffect)(() => {
2452
+ (0, import_react8.useEffect)(() => {
2286
2453
  const value = createCompanionProvider({
2287
2454
  command: (command2) => actions.current.command(command2),
2288
2455
  updateConfig: (config) => actions.current.updateConfig(config),
@@ -2299,7 +2466,7 @@ function Overlay({
2299
2466
  window.dispatchEvent(new Event("dsh-pet-disposed"));
2300
2467
  };
2301
2468
  }, []);
2302
- (0, import_react7.useEffect)(() => {
2469
+ (0, import_react8.useEffect)(() => {
2303
2470
  const library = controller.library;
2304
2471
  provider.current?.publish(
2305
2472
  library ? {
@@ -2323,33 +2490,30 @@ function Overlay({
2323
2490
  settings: openSettings
2324
2491
  }
2325
2492
  ),
2326
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
2327
- "dialog",
2493
+ settingsOpen && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2494
+ import_dsh_client_ui_primitives3.Modal,
2328
2495
  {
2329
- ref: settingsDialog,
2330
- className: "dcp dcp-dialog",
2331
- "aria-label": t("\u5BA0\u7269\u8BBE\u7F6E"),
2332
- style: {
2333
- pointerEvents: "auto",
2334
- width: "min(800px, calc(100vw - 32px))",
2335
- maxHeight: "85vh",
2336
- overflow: "auto"
2337
- },
2338
- children: [
2496
+ open: true,
2497
+ headless: true,
2498
+ className: "dcp dcp-settings-modal",
2499
+ title: t("\u5BA0\u7269\u8BBE\u7F6E"),
2500
+ onClose: () => setSettingsOpen(false),
2501
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dcp-settings-modal-body", children: [
2339
2502
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2340
- import_dsh_client_ui_primitives2.Button,
2503
+ import_dsh_client_ui_primitives3.Button,
2341
2504
  {
2342
2505
  type: "button",
2343
2506
  variant: "ghost",
2344
2507
  size: "sm",
2345
2508
  className: "dcp-dialog-close",
2346
- onClick: () => settingsDialog.current?.close(),
2509
+ onClick: () => setSettingsOpen(false),
2347
2510
  children: t("\u5173\u95ED\u8BBE\u7F6E")
2348
2511
  }
2349
2512
  ),
2350
2513
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2351
2514
  Settings,
2352
2515
  {
2516
+ draft: createDraft,
2353
2517
  controller,
2354
2518
  locale,
2355
2519
  create: async (description) => {
@@ -2364,7 +2528,7 @@ function Overlay({
2364
2528
  }
2365
2529
  }
2366
2530
  )
2367
- ]
2531
+ ] })
2368
2532
  }
2369
2533
  )
2370
2534
  ] });