dsh-her 0.0.1 → 0.1.0-beta.1

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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +113 -0
  3. package/cordis.patch.yml +5 -0
  4. package/examples/workshop/README.md +20 -0
  5. package/lib/client.js +1546 -0
  6. package/lib/core/character.js +50 -0
  7. package/lib/core/cues.js +62 -0
  8. package/lib/core/echo.js +27 -0
  9. package/lib/core/index.js +10 -0
  10. package/lib/core/paths.js +14 -0
  11. package/lib/core/prompt.js +63 -0
  12. package/lib/core/sentences.js +115 -0
  13. package/lib/core/speakable.js +26 -0
  14. package/lib/core/voices.js +43 -0
  15. package/lib/core/wav.js +71 -0
  16. package/lib/core/workshop.js +268 -0
  17. package/lib/dsh/api.js +156 -0
  18. package/lib/dsh/body-install.js +137 -0
  19. package/lib/dsh/body-launcher.js +48 -0
  20. package/lib/dsh/config.js +27 -0
  21. package/lib/dsh/her-session.js +282 -0
  22. package/lib/dsh/import-status.js +6 -0
  23. package/lib/dsh/plugin.js +1010 -0
  24. package/lib/dsh/workshop.js +212 -0
  25. package/lib/index.js +11 -0
  26. package/lib/memory/digest.js +119 -0
  27. package/lib/memory/search.js +52 -0
  28. package/lib/memory/store.js +267 -0
  29. package/lib/protocol/index.js +39 -0
  30. package/lib/server/brain-server.js +219 -0
  31. package/lib/types/core/character.d.ts +32 -0
  32. package/lib/types/core/cues.d.ts +20 -0
  33. package/lib/types/core/echo.d.ts +10 -0
  34. package/lib/types/core/index.d.ts +10 -0
  35. package/lib/types/core/paths.d.ts +11 -0
  36. package/lib/types/core/prompt.d.ts +39 -0
  37. package/lib/types/core/sentences.d.ts +40 -0
  38. package/lib/types/core/speakable.d.ts +6 -0
  39. package/lib/types/core/voices.d.ts +23 -0
  40. package/lib/types/core/wav.d.ts +9 -0
  41. package/lib/types/core/workshop.d.ts +130 -0
  42. package/lib/types/dsh/api.d.ts +163 -0
  43. package/lib/types/dsh/body-install.d.ts +58 -0
  44. package/lib/types/dsh/body-launcher.d.ts +28 -0
  45. package/lib/types/dsh/config.d.ts +34 -0
  46. package/lib/types/dsh/her-session.d.ts +215 -0
  47. package/lib/types/dsh/import-status.d.ts +17 -0
  48. package/lib/types/dsh/plugin.d.ts +34 -0
  49. package/lib/types/dsh/workshop.d.ts +92 -0
  50. package/lib/types/index.d.ts +11 -0
  51. package/lib/types/memory/digest.d.ts +33 -0
  52. package/lib/types/memory/search.d.ts +17 -0
  53. package/lib/types/memory/store.d.ts +132 -0
  54. package/lib/types/protocol/index.d.ts +434 -0
  55. package/lib/types/server/brain-server.d.ts +71 -0
  56. package/lib/types/voice/cloud-key.d.ts +10 -0
  57. package/lib/types/voice/cosyvoice.d.ts +47 -0
  58. package/lib/types/voice/edge.d.ts +52 -0
  59. package/lib/types/voice/engine.d.ts +30 -0
  60. package/lib/types/voice/models.d.ts +21 -0
  61. package/lib/types/voice/speech-queue.d.ts +55 -0
  62. package/lib/types/voice/voice.d.ts +75 -0
  63. package/lib/types/voice/worker.d.ts +37 -0
  64. package/lib/voice/cloud-key.js +23 -0
  65. package/lib/voice/cosyvoice.js +194 -0
  66. package/lib/voice/edge.js +199 -0
  67. package/lib/voice/engine.js +101 -0
  68. package/lib/voice/models.js +69 -0
  69. package/lib/voice/speech-queue.js +118 -0
  70. package/lib/voice/voice.js +171 -0
  71. package/lib/voice/worker.js +47 -0
  72. package/package.json +61 -4
package/lib/client.js ADDED
@@ -0,0 +1,1546 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "dsh-her",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ "use strict";
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+
25
+ // src/client/index.tsx
26
+ var index_exports = {};
27
+ __export(index_exports, {
28
+ PACKAGE_NAME: () => PACKAGE_NAME,
29
+ PANEL_ID: () => PANEL_ID,
30
+ apply: () => apply,
31
+ inject: () => inject
32
+ });
33
+ module.exports = __toCommonJS(index_exports);
34
+
35
+ // src/client/Page.tsx
36
+ var import_react3 = require("react");
37
+
38
+ // src/client/api.ts
39
+ async function post(path, body = {}) {
40
+ try {
41
+ const res = await fetch(new URL(`/api/dsh-her${path}`, document.baseURI), {
42
+ method: "POST",
43
+ credentials: "same-origin",
44
+ headers: { "content-type": "application/json" },
45
+ body: JSON.stringify(body)
46
+ });
47
+ const value = await res.json().catch(() => null);
48
+ if (value === null) return { ok: false, message: `HTTP ${res.status}` };
49
+ return value;
50
+ } catch (error) {
51
+ return { ok: false, message: error instanceof Error ? error.message : String(error) };
52
+ }
53
+ }
54
+ var herApi = {
55
+ state: () => post("/state"),
56
+ saveCharacter: (patch) => post("/character", patch),
57
+ expandPersona: (input) => post("/persona/expand", input),
58
+ tryPersona: (input) => post("/persona/try", input),
59
+ previewVoice: (voice, speed, text) => post("/voice/preview", { voice, speed, ...text === void 0 ? {} : { text } }),
60
+ startBody: () => post("/body/start"),
61
+ installBody: () => post("/body/install"),
62
+ restartBody: () => post("/body/restart"),
63
+ setMode: (mode) => post("/body/mode", { mode }),
64
+ pickPack: () => post("/pack/pick"),
65
+ usePack: (packId) => post("/pack/use", { packId }),
66
+ workshopList: () => post("/workshop/list"),
67
+ workshopNew: (name) => post("/workshop/new", { name }),
68
+ workshopSave: (project) => post("/workshop/save", { project }),
69
+ workshopExport: (id, media) => post("/workshop/export", { id, media }),
70
+ workshopImportProject: () => post("/workshop/import-project"),
71
+ workshopExamples: () => post("/workshop/examples"),
72
+ workshopOpen: (id) => post("/workshop/open", { id }),
73
+ workshopFrame: (id, scene) => post("/workshop/frame", { id, scene }),
74
+ workshopImport: (id) => post("/workshop/import", { id }),
75
+ setLook: (change) => post("/look/set", change),
76
+ memoryRemove: (ids) => post("/memory/remove", { ids }),
77
+ memoryConfirm: (ids) => post("/memory/confirm", { ids }),
78
+ digest: () => post("/memory/digest"),
79
+ exportMemory: () => post("/memory/export")
80
+ };
81
+ async function modelCatalog() {
82
+ try {
83
+ const res = await fetch(new URL("/api/session/modelCatalog", document.baseURI), {
84
+ method: "POST",
85
+ credentials: "same-origin",
86
+ headers: { "content-type": "application/json" },
87
+ body: JSON.stringify({ type: "client-request", rpcId: crypto.randomUUID(), method: "session/modelCatalog", payload: { args: {} } })
88
+ });
89
+ const reply = await res.json();
90
+ const value = reply.result?.value;
91
+ if (reply.result?.ok !== true || value === void 0) return { ok: false, message: reply.result?.error?.message ?? `HTTP ${res.status}` };
92
+ const routable = value.routableProviders;
93
+ const groups = (value.groups ?? []).filter((g) => routable === void 0 || routable.includes(g.id));
94
+ return { ok: true, groups, ...value.default === void 0 ? {} : { default: value.default } };
95
+ } catch (error) {
96
+ return { ok: false, message: error instanceof Error ? error.message : String(error) };
97
+ }
98
+ }
99
+ function playAudio(base64, format) {
100
+ void new Audio(`data:audio/${format === "mp3" ? "mpeg" : "wav"};base64,${base64}`).play();
101
+ }
102
+
103
+ // src/core/voices.ts
104
+ var VOICES = [
105
+ { id: "zh-CN-XiaoxiaoNeural", name: "\u6653\u6653", desc: "\u6E29\u6696\uFF0C\u81EA\u7136", service: "edge" },
106
+ { id: "zh-CN-XiaoyiNeural", name: "\u6653\u4F0A", desc: "\u6D3B\u6CFC\uFF0C\u53EF\u7231", service: "edge" },
107
+ { id: "zh-TW-HsiaoChenNeural", name: "\u66C9\u81FB", desc: "\u6E29\u67D4\uFF0C\u53F0\u6E7E\u8154", service: "edge" },
108
+ { id: "zh-TW-HsiaoYuNeural", name: "\u66C9\u96E8", desc: "\u6E05\u4EAE\uFF0C\u53F0\u6E7E\u8154", service: "edge" },
109
+ { id: "zh-CN-liaoning-XiaobeiNeural", name: "\u6653\u5317", desc: "\u723D\u6717\uFF0C\u4E1C\u5317\u8BDD", service: "edge" },
110
+ { id: "zh-CN-shaanxi-XiaoniNeural", name: "\u6653\u59AE", desc: "\u9655\u897F\u8BDD", service: "edge" },
111
+ { id: "zh-HK-HiuMaanNeural", name: "\u66C9\u66FC", desc: "\u7CA4\u8BED", service: "edge" },
112
+ { id: "longanrou_v3", name: "\u9F99\u5B89\u67D4", desc: "\u6E29\u67D4\uFF0C\u50CF\u95FA\u871C", service: "cosyvoice" },
113
+ { id: "longxing_v3", name: "\u9F99\u661F", desc: "\u6E29\u5A49\uFF0C\u90BB\u5BB6\u5973\u5B69", service: "cosyvoice" },
114
+ { id: "longanhuan_v3", name: "\u9F99\u5B89\u6B22", desc: "\u6B22\u8131\u5143\u6C14", service: "cosyvoice" },
115
+ { id: "longanqin_v3", name: "\u9F99\u5B89\u4EB2", desc: "\u4EB2\u548C\uFF0C\u5F00\u6717", service: "cosyvoice" },
116
+ { id: "longanling_v3", name: "\u9F99\u5B89\u7075", desc: "\u673A\u7075\uFF0C\u6D3B\u6CFC", service: "cosyvoice" },
117
+ { id: "longhua_v3", name: "\u9F99\u534E", desc: "\u5143\u6C14\uFF0C\u751C\u7F8E", service: "cosyvoice" },
118
+ { id: "longfeifei_v3", name: "\u9F99\u83F2\u83F2", desc: "\u751C\u7F8E\uFF0C\u7231\u6492\u5A07", service: "cosyvoice" },
119
+ { id: "longantai_v3", name: "\u9F99\u5B89\u53F0", desc: "\u55F2\u751C\uFF0C\u53F0\u6E7E\u8154", service: "cosyvoice" },
120
+ { id: "longwan_v3", name: "\u9F99\u5A49", desc: "\u7EC6\u817B\uFF0C\u67D4\u58F0", service: "cosyvoice" },
121
+ { id: "longyingling_v3", name: "\u9F99\u5E94\u8046", desc: "\u6E29\u548C\uFF0C\u4F1A\u5171\u60C5", service: "cosyvoice" },
122
+ { id: "longanwen_v3", name: "\u9F99\u5B89\u6E29", desc: "\u4F18\u96C5\uFF0C\u77E5\u6027", service: "cosyvoice" },
123
+ { id: "longxiaochun_v3", name: "\u9F99\u5C0F\u6DF3", desc: "\u77E5\u6027\uFF0C\u79EF\u6781", service: "cosyvoice" }
124
+ ];
125
+ function voiceName(id) {
126
+ return VOICES.find((v2) => v2.id === id)?.name ?? id;
127
+ }
128
+ var SERVICE_NAMES = {
129
+ edge: "\u5FAE\u8F6F Edge\uFF08\u514D\u8D39\uFF0C\u8981\u8054\u7F51\uFF09",
130
+ cosyvoice: "\u963F\u91CC\u4E91\u767E\u70BC CosyVoice\uFF08\u8981 key\uFF0C\u6309\u5B57\u6570\u4ED8\u8D39\uFF09"
131
+ };
132
+
133
+ // src/client/Workshop.tsx
134
+ var import_react = require("react");
135
+
136
+ // src/core/workshop.ts
137
+ var DESK_DIR = "\u684C\u5BA0";
138
+ var sceneDir = (scene) => `\u573A\u666F-${safeName(scene.name)}`;
139
+ function safeName(text) {
140
+ return text.trim().replace(/[\\/:*?"<>|]+/g, "-").replace(/^\.+/, "") || "\u672A\u547D\u540D";
141
+ }
142
+ var CARD_CHOICES = {
143
+ gender: ["\u5973", "\u7537"],
144
+ age: ["\u4E8C\u5341\u51FA\u5934", "\u4E8C\u5341\u591A\u5C81", "\u4E09\u5341\u5C81\u5DE6\u53F3", "\u4E09\u5341\u591A\u5C81"],
145
+ skin: ["\u767D\u7699", "\u81EA\u7136\u80A4\u8272", "\u5C0F\u9EA6\u8272", "\u6DF1\u8272"],
146
+ hairStyle: ["\u957F\u76F4\u53D1", "\u957F\u5377\u53D1", "\u4E2D\u957F\u53D1", "\u77ED\u53D1", "\u9A6C\u5C3E", "\u4E38\u5B50\u5934"],
147
+ hairColor: ["\u9ED1\u8272", "\u6DF1\u68D5\u8272", "\u6817\u8272", "\u91D1\u8272", "\u94F6\u767D\u8272"],
148
+ build: ["\u7EA4\u7EC6", "\u5300\u79F0", "\u5065\u7F8E", "\u4E30\u6EE1"],
149
+ outfit: ["\u5BB6\u5C45\u670D", "\u886C\u886B\u8FDE\u8863\u88D9", "\u536B\u8863\u548C\u725B\u4ED4\u88E4", "\u540A\u5E26\u548C\u77ED\u88D9", "\u897F\u88C5\u5957\u88C5", "\u9488\u7EC7\u886B\u548C\u957F\u88D9", "\u6C49\u670D"],
150
+ accessories: ["\u65E0", "\u7EC6\u6846\u773C\u955C", "\u53D1\u5361", "\u8033\u73AF", "\u9879\u94FE"],
151
+ style: ["\u5199\u5B9E\u7167\u7247", "\u65E5\u7CFB\u52A8\u6F2B", "3D \u5361\u901A"]
152
+ };
153
+ var CARD_LABELS = {
154
+ gender: "\u6027\u522B",
155
+ age: "\u5E74\u9F84",
156
+ skin: "\u80A4\u8272",
157
+ hairStyle: "\u53D1\u578B",
158
+ hairColor: "\u53D1\u8272",
159
+ build: "\u8EAB\u6750",
160
+ outfit: "\u8863\u670D",
161
+ accessories: "\u914D\u9970",
162
+ style: "\u753B\u98CE",
163
+ extra: "\u5176\u4ED6\u7279\u5F81",
164
+ sentence: "\u89D2\u8272\u63CF\u8FF0"
165
+ };
166
+ var subject = (card) => card.gender === "\u7537" ? "\u6210\u5E74\u7537\u6027" : card.gender === "\u5973" ? "\u6210\u5E74\u5973\u6027" : `\u6210\u5E74\u4EBA\uFF08${card.gender}\uFF09`;
167
+ function describe(card) {
168
+ if (card.sentence.trim() !== "") return card.sentence.trim();
169
+ const parts = [
170
+ `${card.age}\u7684${subject(card)}`,
171
+ `${card.skin}\u76AE\u80A4`,
172
+ `${card.hairColor}${card.hairStyle}`,
173
+ ...card.accessories === "\u65E0" || card.accessories.trim() === "" ? [] : [`\u6234${card.accessories}`],
174
+ `\u7A7F${card.outfit}`,
175
+ `\u8EAB\u6750${card.build}`,
176
+ ...card.extra.trim() === "" ? [] : [card.extra.trim()]
177
+ ];
178
+ return parts.join("\uFF0C");
179
+ }
180
+ var styleWords = (card) => card.style === "\u5199\u5B9E\u7167\u7247" ? "\u5199\u5B9E\u6444\u5F71\u98CE\u683C\uFF0C\u771F\u5B9E\u76AE\u80A4\u8D28\u611F\uFF0C\u81EA\u7136\u5149" : card.style === "\u65E5\u7CFB\u52A8\u6F2B" ? "\u65E5\u7CFB\u52A8\u6F2B\u753B\u98CE\uFF0C\u5E72\u51C0\u7EBF\u6761" : card.style === "3D \u5361\u901A" ? "3D \u5361\u901A\u6E32\u67D3\u98CE\u683C" : card.style;
181
+ function screenColor(card) {
182
+ return /绿/.test(`${card.outfit}${card.extra}${card.sentence}`) ? { name: "\u7EAF\u7070\u8272", hex: "#808080" } : { name: "\u7EAF\u7EFF\u8272", hex: "#00B140" };
183
+ }
184
+ var POSE_WORDS = { stand: "\u7AD9\u7740", sit: "\u5750\u7740", lie: "\u8EBA\u7740" };
185
+ var PRESETS = [
186
+ { role: "idle", n: 1, required: true, action: "\u5B89\u9759\u5730{pose}\uFF0C\u81EA\u7136\u547C\u5438\uFF0C\u5076\u5C14\u7728\u773C\uFF0C\u5934\u6781\u8F7B\u5FAE\u5730\u6643\u52A8\uFF0C\u5634\u5DF4\u95ED\u5408\uFF0C\u6D45\u6D45\u5730\u7B11" },
187
+ { role: "talk", n: 1, required: true, action: "\u770B\u7740\u955C\u5934\u6E29\u67D4\u5730\u8BF4\u8BDD\uFF0C\u5634\u5DF4\u81EA\u7136\u6301\u7EED\u5F00\u5408\uFF0C\u8F7B\u8F7B\u70B9\u5934\uFF0C\u624B\u6709\u5F88\u5C0F\u7684\u52A8\u4F5C\u3002\u6700\u540E\u4E00\u79D2\u95ED\u5634\u56DE\u5230\u539F\u59FF\u52BF" },
188
+ { role: "talk", n: 2, required: true, action: "\u770B\u7740\u955C\u5934\u8BF4\u8BDD\uFF0C\u6362\u4E00\u79CD\u8282\u594F\uFF0C\u7565\u5E26\u7B11\u610F\uFF0C\u5634\u5DF4\u81EA\u7136\u6301\u7EED\u5F00\u5408\uFF0C\u4E00\u53EA\u624B\u8F7B\u8F7B\u62AC\u8D77\u53C8\u653E\u4E0B\u3002\u6700\u540E\u4E00\u79D2\u95ED\u5634\u56DE\u5230\u539F\u59FF\u52BF" },
189
+ { role: "idle", n: 2, action: "\u5B89\u9759\u5730{pose}\uFF0C\u8F7B\u8F7B\u628A\u4E00\u7F15\u5934\u53D1\u62E8\u5230\u8033\u540E\uFF0C\u7136\u540E\u6062\u590D\u539F\u59FF\u52BF" },
190
+ { role: "listen", n: 1, action: "\u8BA4\u771F\u5730\u542C\uFF0C\u5634\u5DF4\u95ED\u7740\uFF0C\u8F7B\u8F7B\u70B9\u5934\u4E24\u6B21\uFF0C\u773C\u795E\u4E13\u6CE8\u770B\u7740\u955C\u5934" },
191
+ { role: "think", n: 1, action: "\u773C\u775B\u770B\u5411\u53F3\u4E0A\u65B9\u50CF\u5728\u601D\u8003\uFF0C\u98DF\u6307\u8F7B\u78B0\u4E0B\u5DF4\uFF0C\u7136\u540E\u653E\u4E0B\u624B\uFF0C\u89C6\u7EBF\u56DE\u5230\u955C\u5934" },
192
+ { role: "happy", n: 1, action: "\u5F00\u5FC3\u5730\u7B11\u51FA\u6765\uFF0C\u773C\u775B\u5F2F\u8D77\uFF0C\u80A9\u8180\u8F7B\u5FAE\u8038\u52A8\uFF0C\u7136\u540E\u6062\u590D\u6D45\u7B11" },
193
+ { role: "shy", n: 1, action: "\u5BB3\u7F9E\u5730\u4F4E\u5934\uFF0C\u624B\u6307\u5377\u4E00\u4E0B\u53D1\u68A2\uFF0C\u518D\u62AC\u773C\u770B\u955C\u5934\uFF0C\u6062\u590D\u539F\u59FF\u52BF" },
194
+ { role: "wave", n: 1, action: "\u770B\u5230\u4F60\u5F88\u5F00\u5FC3\uFF0C\u62AC\u8D77\u53F3\u624B\u671D\u955C\u5934\u6325\u624B\uFF0C\u7136\u540E\u653E\u4E0B\u624B\u6062\u590D\u539F\u59FF\u52BF" },
195
+ { role: "touched", n: 1, action: "\u50CF\u88AB\u8F7B\u8F7B\u6233\u4E86\u4E00\u4E0B\uFF0C\u5FAE\u5FAE\u4E00\u60CA\uFF0C\u7136\u540E\u770B\u7740\u955C\u5934\u7B11\uFF0C\u6062\u590D\u539F\u59FF\u52BF" },
196
+ { role: "sleepy", n: 1, action: "\u6253\u4E00\u4E2A\u5C0F\u54C8\u6B20\uFF0C\u7528\u624B\u80CC\u8F7B\u63C9\u773C\u775B\uFF0C\u7136\u540E\u5BF9\u955C\u5934\u7B11\u4E00\u4E0B\uFF0C\u6062\u590D\u539F\u59FF\u52BF" }
197
+ ];
198
+ function presetClips(pose) {
199
+ return PRESETS.map((p) => ({
200
+ file: `${pose}_${p.role}_${String(p.n).padStart(2, "0")}`,
201
+ action: p.action.replaceAll("{pose}", POSE_WORDS[pose]),
202
+ ...p.required === true ? { required: true } : { off: true }
203
+ }));
204
+ }
205
+ function customClip(pose, existing, action) {
206
+ let n = 1;
207
+ while (existing.some((c) => c.file === `${pose}_act${n}_01`)) n++;
208
+ return { file: `${pose}_act${n}_01`, action: action.trim() };
209
+ }
210
+ function newScene(id, name, pose = "stand") {
211
+ return { id, name, place: "", pose, clips: presetClips(pose) };
212
+ }
213
+ function rules(project, kind, scene) {
214
+ const common = [
215
+ "\u56FA\u5B9A\u673A\u4F4D\uFF0C\u5355\u4E00\u8FDE\u7EED\u955C\u5934\uFF0C\u4E0D\u63A8\u62C9\u6447\u79FB\uFF0C\u4E0D\u53D8\u7126\uFF0C\u4E0D\u5207\u955C",
216
+ "\u8138\u3001\u4E94\u5B98\u3001\u53D1\u578B\u3001\u5986\u5BB9\u3001\u670D\u88C5\u3001\u8EAB\u6750\u6BD4\u4F8B\u5168\u7A0B\u5B8C\u5168\u4E0D\u53D8",
217
+ "\u52A8\u4F5C\u81EA\u7136\u3001\u514B\u5236\u3001\u5E45\u5EA6\u5C0F\uFF0C\u771F\u5B9E\u7684\u547C\u5438\u548C\u7728\u773C",
218
+ "\u753B\u9762\u4E2D\u4E0D\u51FA\u73B0\u4EFB\u4F55\u6587\u5B57\u3001\u5B57\u5E55\u3001\u6C34\u5370\u3001Logo\uFF0C\u65E0\u80CC\u666F\u97F3\u4E50",
219
+ "\u89C6\u9891\u5F00\u59CB\u548C\u7ED3\u675F\u65F6\uFF0C\u4EBA\u7269\u59FF\u52BF\u4E0E\u53C2\u8003\u56FE\u5B8C\u5168\u4E00\u81F4"
220
+ ];
221
+ if (kind === "desk") {
222
+ const color = screenColor(project.card);
223
+ return [
224
+ `\u53C2\u8003\u56FE\u4E2D\u7684\u540C\u4E00\u4F4D${subject(project.card)}\uFF0C\u5168\u8EAB\u7AD9\u7ACB\uFF0C${color.name}\u80CC\u666F`,
225
+ ...common,
226
+ `\u80CC\u666F\u59CB\u7EC8\u662F\u5747\u5300\u7684${color.name}\uFF08${color.hex}\uFF09\uFF0C\u65E0\u5730\u9762\u3001\u65E0\u9634\u5F71\u3001\u65E0\u6E10\u53D8\u3001\u65E0\u4EFB\u4F55\u7269\u4F53\uFF0C\u5149\u7167\u4E0D\u53D8`,
227
+ "\u53CC\u811A\u59CB\u7EC8\u7AD9\u5728\u539F\u5730\uFF0C\u8EAB\u4F53\u59CB\u7EC8\u5B8C\u6574\u5730\u5728\u753B\u9762\u5185\uFF08\u5934\u9876\u548C\u811A\u90FD\u4E0D\u51FA\u753B\uFF09"
228
+ ].join("\u3002") + "\u3002";
229
+ }
230
+ return [
231
+ `\u53C2\u8003\u56FE\u4E2D\u7684\u540C\u4E00\u4F4D${subject(project.card)}\uFF0C\u5728${scene?.name ?? "\u573A\u666F"}\u91CC${POSE_WORDS[scene?.pose ?? "stand"]}`,
232
+ ...common,
233
+ "\u80CC\u666F\u4E0E\u53C2\u8003\u56FE\u5B8C\u5168\u4E00\u81F4\u4E14\u9759\u6B62\uFF0C\u5149\u7167\u4E0D\u53D8",
234
+ "\u4EBA\u7269\u4E0D\u79BB\u5F00\u539F\u4F4D\uFF0C\u8EAB\u4F53\u59CB\u7EC8\u5728\u753B\u9762\u5185"
235
+ ].join("\u3002") + "\u3002";
236
+ }
237
+ function clipPrompt(project, kind, clip, scene) {
238
+ return `${rules(project, kind, scene)}\u5979\u662F\uFF1A${describe(project.card)}\u3002${clip.action}\u3002`;
239
+ }
240
+ function referencePrompt(project) {
241
+ const color = screenColor(project.card);
242
+ return [
243
+ `${describe(project.card)}`,
244
+ "\u5168\u8EAB\u6B63\u9762\u7AD9\u7ACB\uFF0C\u53CC\u624B\u81EA\u7136\u5782\u5728\u8EAB\u4FA7\uFF0C\u8868\u60C5\u6E29\u548C\uFF0C\u770B\u7740\u955C\u5934",
245
+ `${color.name}\u80CC\u666F\uFF08${color.hex}\uFF09\uFF0C\u80CC\u666F\u5B8C\u5168\u5747\u5300\uFF0C\u65E0\u5730\u9762\u3001\u65E0\u9634\u5F71\u3001\u65E0\u6E10\u53D8\u3001\u65E0\u4EFB\u4F55\u7269\u4F53`,
246
+ "\u4EBA\u7269\u5C45\u4E2D\uFF0C\u5934\u9876\u548C\u811A\u4E0B\u5404\u7559\u4E00\u70B9\u7A7A\uFF0C\u7AD6\u7248 9:16\uFF0C1080\xD71920",
247
+ styleWords(project.card)
248
+ ].join("\u3002") + "\u3002";
249
+ }
250
+ function scenePhotoPrompt(project, scene, screen) {
251
+ const size = screen === void 0 ? "\u6A2A\u7248 16:10\uFF0C2560 \u5BBD\u4EE5\u4E0A" : `\u6A2A\u7248\uFF0C\u548C\u5C4F\u5E55\u4E00\u6837\u7684\u6BD4\u4F8B\uFF0C${screen.width}\xD7${screen.height}`;
252
+ return [
253
+ `${scene.place.trim() === "" ? scene.name : scene.place.trim()}`,
254
+ `\u753B\u9762\u91CC\u6709\u4E00\u4F4D${describe(project.card)}\uFF0C${POSE_WORDS[scene.pose]}\uFF0C\u770B\u7740\u955C\u5934`,
255
+ "\u7528\u53C2\u8003\u56FE\u4FDD\u6301\u4EBA\u7269\u5B8C\u5168\u4E00\u81F4\uFF08\u540C\u4E00\u5F20\u8138\u3001\u540C\u6837\u7684\u53D1\u578B\u548C\u8863\u670D\uFF09",
256
+ "\u4EBA\u7269\u5B8C\u6574\u5730\u5728\u753B\u9762\u4E2D\u95F4\u504F\u4E00\u4FA7\uFF0C\u5934\u9876\u548C\u811A\u4E0B\u7559\u51FA\u7A7A\u95F4\uFF0C\u4EBA\u7269\u9AD8\u5EA6\u7EA6\u5360\u753B\u9762\u7684\u516D\u6210",
257
+ size,
258
+ styleWords(project.card)
259
+ ].join("\u3002") + "\u3002";
260
+ }
261
+ var EXAMPLE_SLOTS = {
262
+ look: [{ file: "look.png", label: "\u505A\u597D\u7684\u5979\uFF08\u89D2\u8272\u5361\u8FD9\u6837\u586B\u51FA\u6765\u7684\u6837\u5B50\uFF09" }],
263
+ reference: [{ file: "reference.png", label: "\u53C2\u8003\u56FE\uFF1A\u7EAF\u8272\u80CC\u666F\u3001\u5168\u8EAB\u3001\u6B63\u9762\u7AD9\u7ACB" }],
264
+ desk: [{ file: "desk.mp4", label: "\u684C\u5BA0\u7247\u6BB5\uFF08\u7EFF\u5E55\u539F\u7247\uFF09" }, { file: "desk-keyed.png", label: "\u62A0\u597D\u540E\u6D6E\u5728\u684C\u9762\u4E0A" }],
265
+ scene: [
266
+ { file: "scene-plate.png", label: "\u573A\u666F\u7684\u5168\u5C4F\u7167\u7247" },
267
+ { file: "scene-crop.png", label: "\u6846\u597D\u7684\u4EBA\u7269\u533A\uFF08crop.png\uFF09" },
268
+ { file: "scene.mp4", label: "\u573A\u666F\u7247\u6BB5" }
269
+ ],
270
+ import: [{ file: "result.png", label: "\u5BFC\u5165\u540E\u684C\u9762\u4E0A\u7684\u6837\u5B50" }]
271
+ };
272
+ var EXAMPLE_FILES = new Set(Object.values(EXAMPLE_SLOTS).flatMap((slots) => slots.map((s) => s.file)));
273
+
274
+ // src/client/Workshop.tsx
275
+ var import_jsx_runtime = require("react/jsx-runtime");
276
+ var OWN = "__own__";
277
+ var copy = (text) => void navigator.clipboard?.writeText(text);
278
+ function Workshop({ state, apply: apply2 }) {
279
+ const [items, setItems] = (0, import_react.useState)([]);
280
+ const [open, setOpen] = (0, import_react.useState)();
281
+ const [draft, setDraft] = (0, import_react.useState)();
282
+ const [dirty, setDirty] = (0, import_react.useState)(false);
283
+ const [newName, setNewName] = (0, import_react.useState)("");
284
+ const [note, setNote] = (0, import_react.useState)();
285
+ const reload = (0, import_react.useCallback)(async () => {
286
+ const result = await herApi.workshopList();
287
+ if (result.ok) setItems(result.projects);
288
+ }, []);
289
+ (0, import_react.useEffect)(() => {
290
+ void reload();
291
+ const timer = setInterval(() => void reload(), 4e3);
292
+ return () => clearInterval(timer);
293
+ }, [reload]);
294
+ const status = items.find((i) => i.project.id === open)?.status;
295
+ const choose = (item) => {
296
+ setOpen(item.project.id);
297
+ setDraft(structuredClone(item.project));
298
+ setDirty(false);
299
+ setNote(void 0);
300
+ };
301
+ const edit = (change) => {
302
+ setDraft((current) => {
303
+ if (current === void 0) return current;
304
+ const next = structuredClone(current);
305
+ change(next);
306
+ return next;
307
+ });
308
+ setDirty(true);
309
+ };
310
+ const report = (result, done) => {
311
+ setNote(result.ok ? { kind: "ok", text: done } : { kind: "error", text: result.message });
312
+ return result.ok;
313
+ };
314
+ const create = async () => {
315
+ const result = await herApi.workshopNew(newName.trim());
316
+ if (report(result, "\u5EFA\u597D\u4E86\uFF0C\u6587\u4EF6\u5939\u5728\u300C\u6587\u7A3F / dsh-her \u7D20\u6750\u300D\u91CC") && result.ok) {
317
+ setNewName("");
318
+ await reload();
319
+ choose(result);
320
+ }
321
+ };
322
+ const save = async () => {
323
+ if (draft === void 0) return false;
324
+ const result = await herApi.workshopSave(draft);
325
+ if (!report(result, "\u5DF2\u4FDD\u5B58\uFF1A\u63D0\u793A\u8BCD\u90FD\u5199\u8FDB\u6587\u4EF6\u5939\u4E86")) return false;
326
+ setDirty(false);
327
+ await reload();
328
+ return true;
329
+ };
330
+ const frame = async (scene) => {
331
+ if (dirty && !await save()) return;
332
+ report(await herApi.workshopFrame(draft.id, scene.id), '\u5DF2\u5728\u684C\u9762\u4E0A\u6253\u5F00"\u505A\u573A\u666F"\u7A97\u53E3\uFF1A\u6846\u597D\u5979\u7684\u6D3B\u52A8\u8303\u56F4\uFF0C\u70B9\u4FDD\u5B58');
333
+ };
334
+ const importLook = async () => {
335
+ if (dirty && !await save()) return;
336
+ if (await apply2(herApi.workshopImport(draft.id))) setNote({ kind: "ok", text: "\u5F00\u59CB\u5BFC\u5165\uFF0C\u8FDB\u5EA6\u5728\u4E0B\u9762" });
337
+ };
338
+ const [unfolded, setUnfolded] = (0, import_react.useState)(() => loadFolds());
339
+ const toggle = (card, on = !unfolded[card]) => setUnfolded((current) => {
340
+ const next = { ...current, [card]: on };
341
+ storeFolds(next);
342
+ return next;
343
+ });
344
+ const saveStep = async (card) => {
345
+ if (dirty && !await save()) return;
346
+ const at = CARDS.indexOf(card);
347
+ setUnfolded((current) => {
348
+ const next = { ...current, [card]: false, ...at + 1 < CARDS.length ? { [CARDS[at + 1]]: true } : {} };
349
+ storeFolds(next);
350
+ return next;
351
+ });
352
+ if (!dirty) setNote({ kind: "ok", text: "\u8FD9\u4E00\u6B65\u5DF2\u7ECF\u4FDD\u5B58\u8FC7\u4E86" });
353
+ };
354
+ const [examples, setExamples] = (0, import_react.useState)([]);
355
+ (0, import_react.useEffect)(() => {
356
+ void herApi.workshopExamples().then((r) => {
357
+ if (r.ok) setExamples(r.examples);
358
+ });
359
+ }, []);
360
+ const [withMedia, setWithMedia] = (0, import_react.useState)(false);
361
+ const exportProject = async () => {
362
+ if (dirty && !await save()) return;
363
+ setNote({ kind: "ok", text: "\u5728\u684C\u9762\u4E0A\u5F39\u51FA\u7684\u7A97\u53E3\u91CC\u9009\u4E00\u4E2A\u6587\u4EF6\u5939\u2026" });
364
+ const result = await herApi.workshopExport(draft.id, withMedia);
365
+ if (!result.ok) report(result, "");
366
+ else if ("cancelled" in result) setNote(void 0);
367
+ else setNote({ kind: "ok", text: `\u5DF2\u5BFC\u51FA ${result.files} \u4E2A\u6587\u4EF6\u5230 ${result.dir}` });
368
+ };
369
+ const importProject = async () => {
370
+ setNote({ kind: "ok", text: "\u5728\u684C\u9762\u4E0A\u5F39\u51FA\u7684\u7A97\u53E3\u91CC\u9009\u4E00\u4E2A\u5F62\u8C61\u9879\u76EE\u7684\u6587\u4EF6\u5939\uFF08\u6216\u91CC\u9762\u7684 \u5F62\u8C61.json\uFF09\u2026" });
371
+ const result = await herApi.workshopImportProject();
372
+ if (!result.ok) report(result, "");
373
+ else if ("cancelled" in result) setNote(void 0);
374
+ else {
375
+ await reload();
376
+ choose(result);
377
+ setNote({ kind: "ok", text: `\u5DF2\u5BFC\u5165\u300C${result.project.name}\u300D\uFF0C\u653E\u5728 ${result.status.dir}` });
378
+ }
379
+ };
380
+ const screen = state.body.screens?.[0];
381
+ const screenPx = screen === void 0 ? void 0 : { width: Math.round(screen.w * screen.scale), height: Math.round(screen.h * screen.scale) };
382
+ const desk = status?.parts.find((p) => p.folder === DESK_DIR);
383
+ const fold = (card, title, summary, done, body, saveLabel = "\u4FDD\u5B58\u8FD9\u4E00\u6B65") => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Fold, { card, title, summary, done, open: unfolded[card], onToggle: () => toggle(card), children: [
384
+ body,
385
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExampleStrip, { examples: examples.filter((e) => e.card === card) }),
386
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-row", children: [
387
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "her-btn primary", onClick: () => void saveStep(card), children: saveLabel }),
388
+ dirty && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "her-warn", children: "\u6709\u6539\u52A8\u8FD8\u6CA1\u4FDD\u5B58" })
389
+ ] })
390
+ ] });
391
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
392
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-card", children: [
393
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "\u5F62\u8C61\u5DE5\u574A" }),
394
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "her-muted", children: "\u505A\u4E00\u4E2A\u4F60\u81EA\u5DF1\u7684\u5979\uFF1A\u9009\u597D\u5979\u7684\u6837\u5B50\u3001\u5979\u4F4F\u5728\u54EA\u4E9B\u573A\u666F\u91CC\uFF0C\u8FD9\u91CC\u4F1A\u628A\u6BCF\u4E00\u5F20\u56FE\u3001\u6BCF\u4E00\u6BB5\u89C6\u9891\u7684\u63D0\u793A\u8BCD\u90FD\u5199\u597D\uFF0C\u653E\u8FDB\u300C\u6587\u7A3F / dsh-her \u7D20\u6750\u300D\u91CC\u7684\u4E00\u4E2A\u6587\u4EF6\u5939\u3002\u4F60\u7528\u8C46\u5305\u3001\u5373\u68A6\u3001MiniMax \u8FD9\u4E9B\u5DE5\u5177\u751F\u6210\uFF0C\u653E\u56DE\u6587\u4EF6\u5939\uFF0C\u518D\u4E00\u952E\u5BFC\u5165\u3002" }),
395
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "her-grid", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { className: `her-choice ${item.project.id === open ? "on" : ""}`, onClick: () => choose(item), children: [
396
+ item.project.name,
397
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: progressText(item.status) })
398
+ ] }, item.project.id)) }),
399
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-row", children: [
400
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "her-input", style: { flex: 1, minWidth: 160 }, value: newName, placeholder: "\u65B0\u5F62\u8C61\u7684\u540D\u5B57\uFF0C\u6BD4\u5982\uFF1A\u5C45\u5BB6\u773C\u955C", onChange: (e) => setNewName(e.target.value) }),
401
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "her-btn", disabled: newName.trim() === "", onClick: () => void create(), children: "\u65B0\u5EFA" }),
402
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "her-btn", onClick: () => void importProject(), children: "\u5BFC\u5165\u5DF2\u6709\u9879\u76EE\u2026" })
403
+ ] }),
404
+ draft !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-row", children: [
405
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { className: "her-btn", onClick: () => void exportProject(), children: [
406
+ "\u628A\u300C",
407
+ draft.name,
408
+ "\u300D\u5BFC\u51FA\u5230\u6587\u4EF6\u5939\u2026"
409
+ ] }),
410
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
411
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: withMedia, onChange: (e) => setWithMedia(e.target.checked) }),
412
+ " \u8FDE\u540C\u56FE\u7247\u548C\u89C6\u9891"
413
+ ] }),
414
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "her-muted", children: '\u4E0D\u52FE\u53EA\u5BFC\u51FA\u8BBE\u7F6E\uFF08\u5F62\u8C61.json \u548C\u6240\u6709\u63D0\u793A\u8BCD\uFF09\uFF0C\u5F88\u5C0F\uFF1B\u5BFC\u51FA\u7684\u6587\u4EF6\u5939\u5728\u522B\u7684\u7535\u8111\u4E0A\u7528"\u5BFC\u5165\u5DF2\u6709\u9879\u76EE"\u6253\u5F00\u3002' })
415
+ ] }),
416
+ draft === void 0 && note !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: note.kind === "error" ? "her-danger" : "her-ok", children: note.text })
417
+ ] }),
418
+ draft !== void 0 && status !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
419
+ fold("look", "1. \u5979\u957F\u4EC0\u4E48\u6837", describe(draft.card), true, /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
420
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-row", children: [
421
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { flex: 1, minWidth: 160 }, children: [
422
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "her-label", children: "\u5F62\u8C61\u540D\u5B57" }),
423
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "her-input", value: draft.name, onChange: (e) => edit((p) => {
424
+ p.name = e.target.value;
425
+ }) })
426
+ ] }),
427
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { flex: 1, minWidth: 160 }, children: [
428
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "her-label", children: "\u7528\u4EC0\u4E48\u751F\u6210\u89C6\u9891" }),
429
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { className: "her-select", value: draft.generator, onChange: (e) => edit((p) => {
430
+ p.generator = e.target.value;
431
+ }), children: [
432
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "minimax", children: "MiniMax Code\uFF08\u7ED9\u5B83\u4EFB\u52A1\u6587\u4EF6\uFF0C\u81EA\u52A8\u751F\u6210\u4E0B\u8F7D\uFF09" }),
433
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "manual", children: "\u5373\u68A6\u3001\u53EF\u7075\u7B49\uFF08\u81EA\u5DF1\u4E00\u6BB5\u6BB5\u590D\u5236\u63D0\u793A\u8BCD\uFF09" })
434
+ ] })
435
+ ] })
436
+ ] }),
437
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CardEditor, { card: draft.card, onChange: (card) => edit((p) => {
438
+ p.card = card;
439
+ }) }),
440
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "her-label", children: "\u89D2\u8272\u63CF\u8FF0\uFF08\u6BCF\u5F20\u56FE\u3001\u6BCF\u6BB5\u89C6\u9891\u90FD\u7528\u8FD9\u4E00\u53E5\uFF0C\u5979\u624D\u662F\u540C\u4E00\u4E2A\u4EBA\uFF1B\u53EF\u4EE5\u76F4\u63A5\u6539\uFF09" }),
441
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { className: "her-textarea", style: { minHeight: 60 }, value: draft.card.sentence, placeholder: describe({ ...draft.card, sentence: "" }), onChange: (e) => edit((p) => {
442
+ p.card.sentence = e.target.value;
443
+ }) })
444
+ ] })),
445
+ fold("reference", '2. \u53C2\u8003\u56FE\uFF08\u5979\u7684"\u8EAB\u4EFD\u8BC1"\uFF09', status.reference ? "\u2713 \u5DF2\u6709 \u53C2\u8003\u56FE.png" : "\u8FD8\u6CA1\u6709 \u53C2\u8003\u56FE.png", status.reference, /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
446
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
447
+ status.reference ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "her-ok", children: "\u2713 \u5DF2\u6709 \u53C2\u8003\u56FE.png" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "her-warn", children: "\u8FD8\u6CA1\u6709 \u53C2\u8003\u56FE.png" }),
448
+ "\uFF1A\u7EAF\u8272\u80CC\u666F\u3001\u5168\u8EAB\u3001\u6B63\u9762\u7AD9\u7ACB\u3002\u7528\u6587\u751F\u56FE\u5DE5\u5177\u6309\u4E0B\u9762\u7684\u63D0\u793A\u8BCD\u751F\u6210\uFF0C\u5B58\u6210\u300C\u53C2\u8003\u56FE.png\u300D\u653E\u8FDB\u9879\u76EE\u6587\u4EF6\u5939\u3002\u4E4B\u540E\u6BCF\u4E2A\u573A\u666F\u7684\u7167\u7247\u90FD\u8981\u7528\u5B83\u5F53\u53C2\u8003\u56FE\u3002"
449
+ ] }),
450
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PromptBox, { text: referencePrompt(draft) })
451
+ ] })),
452
+ fold("desk", "3. \u684C\u5BA0\uFF08\u6D6E\u5728\u6700\u4E0A\u5C42\u65F6\u7684\u5979\uFF09", !draft.desk.on ? "\u4E0D\u8981\u684C\u5BA0" : desk === void 0 ? "\u8FD8\u6CA1\u4FDD\u5B58" : `${desk.made}/${desk.planned} \u6BB5${desk.enough ? "\uFF0C\u591F\u7528\u4E86" : ""}`, !draft.desk.on || desk?.enough === true, /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
453
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
454
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: draft.desk.on, onChange: (e) => edit((p) => {
455
+ p.desk.on = e.target.checked;
456
+ }) }),
457
+ " \u8981\u684C\u5BA0\uFF1A\u7EFF\u5E55\u5168\u8EAB\u89C6\u9891\uFF0C\u5BFC\u5165\u65F6\u62A0\u6389\u80CC\u666F\uFF0C\u5979\u6D6E\u5728\u6240\u6709\u7A97\u53E3\u4E0A\u9762"
458
+ ] }),
459
+ draft.desk.on && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
460
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PartStatusLine, { status: desk }),
461
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "her-muted", children: "\u9996\u5E27\u7528\u300C\u53C2\u8003\u56FE.png\u300D\uFF0C\u751F\u6210\u7AD6\u7248 9:16\u30011080P\u30015\u20136 \u79D2\u3002" }),
462
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClipList, { project: draft, kind: "desk", clips: draft.desk.clips, pose: "stand", onChange: (clips) => edit((p) => {
463
+ p.desk.clips = clips;
464
+ }) })
465
+ ] })
466
+ ] })),
467
+ fold("scene", "4. \u573A\u666F\uFF08\u4F4F\u5728\u58C1\u7EB8\u91CC\u3001\u666E\u901A\u7A97\u53E3\u65F6\u7684\u5979\uFF09", draft.scenes.length === 0 ? "\u8FD8\u6CA1\u6709\u573A\u666F" : draft.scenes.map((sc) => {
468
+ const part = status.parts.find((p) => p.folder === sceneDir(sc));
469
+ return `${sc.name} ${part === void 0 ? "\u672A\u4FDD\u5B58" : `${part.made}/${part.planned}${part.framed === true ? "" : part.photo === true ? "\xB7\u672A\u6846" : "\xB7\u7F3A\u7167\u7247"}`}`;
470
+ }).join(" \xB7 "), draft.scenes.length > 0 && draft.scenes.every((sc) => {
471
+ const part = status.parts.find((p) => p.folder === sceneDir(sc));
472
+ return part?.enough === true && part.framed === true;
473
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
474
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "her-muted", children: [
475
+ '\u6BCF\u4E2A\u573A\u666F\u662F\u4E00\u5F20\u5168\u5C4F\u7167\u7247\uFF0C\u5979\u5728\u7167\u7247\u91CC\u7684\u4E00\u5757\u5730\u65B9\u52A8\u3002\u81EA\u52A8\u6362\u573A\u666F\u6309\u4E0B\u9762\u7684\u65F6\u95F4\u548C"\u4F60\u5728\u4E0D\u5728"\u6765\u9009\u3002',
476
+ screenPx === void 0 ? "" : `\u4F60\u7684\u5C4F\u5E55\u662F ${screenPx.width}\xD7${screenPx.height}\uFF0C\u7167\u7247\u5C31\u505A\u8FD9\u4E48\u5927\u3002`
477
+ ] }),
478
+ draft.scenes.map((scene, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
479
+ SceneEditor,
480
+ {
481
+ project: draft,
482
+ scene,
483
+ isDefault: (draft.default ?? draft.scenes[0]?.id) === scene.id,
484
+ status: status.parts.find((p) => p.folder === sceneDir(scene)),
485
+ screen: screenPx,
486
+ onChange: (change) => edit((p) => {
487
+ change(p.scenes[i]);
488
+ }),
489
+ onDefault: () => edit((p) => {
490
+ p.default = scene.id;
491
+ }),
492
+ onRemove: () => edit((p) => {
493
+ p.scenes.splice(i, 1);
494
+ }),
495
+ onFrame: () => void frame(scene)
496
+ },
497
+ scene.id
498
+ )),
499
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "her-btn", onClick: () => edit((p) => {
500
+ p.scenes.push(newScene(`s${Date.now().toString(36)}`, `\u573A\u666F${p.scenes.length + 1}`));
501
+ }), children: "\u52A0\u4E00\u4E2A\u573A\u666F" })
502
+ ] })),
503
+ fold("import", "5. \u751F\u6210\u3001\u5BFC\u5165", status.importable ? "\u53EF\u4EE5\u5BFC\u5165\u4E86" : "\u7247\u6BB5\u8FD8\u4E0D\u591F", false, /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
504
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ol", { className: "her-muted", style: { margin: "4px 0", paddingLeft: 18 }, children: [
505
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
506
+ '\u6BCF\u4E00\u6B65\u586B\u5B8C\u70B9"\u4FDD\u5B58\u8FD9\u4E00\u6B65"\uFF1A\u63D0\u793A\u8BCD\u5199\u8FDB\u9879\u76EE\u6587\u4EF6\u5939',
507
+ draft.generator === "minimax" ? "\uFF0C\u8FD8\u6709\u7ED9 MiniMax Code \u7684\u300CMiniMax\u751F\u6210\u4EFB\u52A1.md\u300D" : "",
508
+ "\u3002"
509
+ ] }),
510
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: draft.generator === "minimax" ? '\u5728 MiniMax Code \u91CC\u8BF4\uFF1A"\u6309 <\u9879\u76EE\u6587\u4EF6\u5939>/MiniMax\u751F\u6210\u4EFB\u52A1.md \u751F\u6210"\u3002' : "\u5728\u5373\u68A6\u3001\u53EF\u7075\u91CC\u4E00\u6BB5\u6BB5\u751F\u6210\uFF0C\u6309\u63D0\u793A\u8BCD\u91CC\u7684\u6587\u4EF6\u540D\u5B58\u8FDB\u5BF9\u5E94\u7684\u6587\u4EF6\u5939\u3002" }),
511
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: '\u573A\u666F\u7684\u7167\u7247\u653E\u597D\u540E\u70B9"\u6846\u4EBA\u7269\u533A"\uFF1B\u7247\u6BB5\u9F50\u4E86\u5C31"\u5BFC\u5165\u8FD9\u4E2A\u5F62\u8C61"\u3002\u6BCF\u90E8\u5206\u81F3\u5C11\u8981 3 \u6BB5\uFF08\u5F85\u673A\u3001\u8BF4\u8BDD \xD72\uFF09\uFF0C\u5176\u4ED6\u7684\u4EE5\u540E\u8865\uFF0C\u518D\u5BFC\u5165\u4E00\u6B21\u5C31\u4F1A\u66F4\u65B0\u3002' })
512
+ ] }),
513
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-row", children: [
514
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "her-btn", onClick: () => void herApi.workshopOpen(draft.id).then((r) => report(r, "\u5DF2\u6253\u5F00\u6587\u4EF6\u5939")), children: "\u6253\u5F00\u6587\u4EF6\u5939" }),
515
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "her-btn", disabled: !status.importable || state.import.state === "running", onClick: () => void importLook(), children: "\u5BFC\u5165\u8FD9\u4E2A\u5F62\u8C61" })
516
+ ] }),
517
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ImportProgress, { state })
518
+ ] }), "\u4FDD\u5B58"),
519
+ note !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: note.kind === "error" ? "her-danger" : "her-ok", children: note.text })
520
+ ] })
521
+ ] });
522
+ }
523
+ var CARDS = ["look", "reference", "desk", "scene", "import"];
524
+ var FOLDS_KEY = "dsh-her.workshop.open";
525
+ function loadFolds() {
526
+ const all = Object.fromEntries(CARDS.map((c) => [c, true]));
527
+ try {
528
+ return { ...all, ...JSON.parse(localStorage.getItem(FOLDS_KEY) ?? "{}") };
529
+ } catch {
530
+ return all;
531
+ }
532
+ }
533
+ function storeFolds(folds) {
534
+ try {
535
+ localStorage.setItem(FOLDS_KEY, JSON.stringify(folds));
536
+ } catch {
537
+ }
538
+ }
539
+ function Fold({ title, summary, done, open, onToggle, children }) {
540
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-card", children: [
541
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { className: "her-fold", onClick: onToggle, "aria-expanded": open, children: [
542
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "her-fold-arrow", children: open ? "\u25BE" : "\u25B8" }),
543
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: title }),
544
+ !open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `her-fold-sum ${done ? "her-ok" : "her-muted"}`, children: summary })
545
+ ] }),
546
+ open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children })
547
+ ] });
548
+ }
549
+ function ExampleStrip({ examples }) {
550
+ if (examples.length === 0) return null;
551
+ const src = (file) => new URL(`/api/dsh-her/example?f=${encodeURIComponent(file)}`, document.baseURI).href;
552
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-examples", children: [
553
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "her-label", children: "\u793A\u4F8B" }),
554
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "her-example-row", children: examples.map((e) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("figure", { className: "her-example", children: [
555
+ !e.ready ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-example-empty", children: [
556
+ "\u793A\u4F8B\u5F85\u653E",
557
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
558
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("code", { children: [
559
+ "examples/workshop/",
560
+ e.file
561
+ ] })
562
+ ] }) : e.file.endsWith(".mp4") ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("video", { src: src(e.file), muted: true, loop: true, playsInline: true, onMouseEnter: (ev) => void ev.currentTarget.play(), onMouseLeave: (ev) => ev.currentTarget.pause() }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: src(e.file), alt: e.label }),
563
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("figcaption", { children: e.label })
564
+ ] }, e.file)) })
565
+ ] });
566
+ }
567
+ function progressText(status) {
568
+ if (status.parts.length === 0) return "\u8FD8\u6CA1\u5F00\u59CB";
569
+ return status.parts.map((p) => `${p.name} ${p.made}/${p.planned}${p.framed === false ? p.photo === true ? "\xB7\u672A\u6846" : "\xB7\u7F3A\u7167\u7247" : ""}`).join(" \xB7 ");
570
+ }
571
+ function PartStatusLine({ status }) {
572
+ if (status === void 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "her-muted", children: "\u4FDD\u5B58\u540E\u4F1A\u5EFA\u597D\u8FD9\u90E8\u5206\u7684\u6587\u4EF6\u5939\u3002" });
573
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
574
+ "\u5DF2\u6709 ",
575
+ status.made,
576
+ "/",
577
+ status.planned,
578
+ " \u6BB5",
579
+ status.enough ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "her-ok", children: "\uFF0C\u591F\u7528\u4E86" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "her-warn", children: "\uFF0C\u6700\u5C11\u8981\u5F85\u673A\u3001\u8BF4\u8BDD \xD72 \u8FD9 3 \u6BB5" }),
580
+ status.photo === false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "her-warn", children: "\uFF1B\u8FD8\u6CA1\u6709\u7167\u7247 plate.png" }),
581
+ status.photo === true && status.framed === false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "her-warn", children: "\uFF1B\u7167\u7247\u6709\u4E86\uFF0C\u8FD8\u6CA1\u6846\u4EBA\u7269\u533A" }),
582
+ status.framed === true && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "her-ok", children: "\uFF1B\u4EBA\u7269\u533A\u5DF2\u6846\u597D" })
583
+ ] });
584
+ }
585
+ function PromptBox({ text }) {
586
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-row", style: { alignItems: "flex-start" }, children: [
587
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "her-chat", style: { flex: 1, margin: 0, whiteSpace: "pre-wrap" }, children: text }),
588
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "her-btn small", onClick: () => copy(text), children: "\u590D\u5236" })
589
+ ] });
590
+ }
591
+ function CardEditor({ card, onChange }) {
592
+ const fields = Object.keys(CARD_CHOICES);
593
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-grid", children: [
594
+ fields.map((field) => {
595
+ const choices = CARD_CHOICES[field];
596
+ const own = !choices.includes(card[field]);
597
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
598
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "her-label", children: CARD_LABELS[field] }),
599
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { className: "her-select", value: own ? OWN : card[field], onChange: (e) => onChange({ ...card, [field]: e.target.value === OWN ? "" : e.target.value }), children: [
600
+ choices.map((c) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: c, children: c }, c)),
601
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: OWN, children: "\u81EA\u5DF1\u5199\u2026" })
602
+ ] }),
603
+ own && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "her-input", style: { marginTop: 4 }, value: card[field], placeholder: field === "age" ? "\u8981\u5199\u6210\u5E74\u7684\uFF0C\u6BD4\u5982 26 \u5C81" : "\u5199\u4F60\u60F3\u8981\u7684", onChange: (e) => onChange({ ...card, [field]: e.target.value }) })
604
+ ] }, field);
605
+ }),
606
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { gridColumn: "1 / -1" }, children: [
607
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "her-label", children: [
608
+ CARD_LABELS.extra,
609
+ "\uFF08\u53EF\u4E0D\u586B\uFF09"
610
+ ] }),
611
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "her-input", value: card.extra, placeholder: "\u6BD4\u5982\uFF1A\u5DE6\u773C\u4E0B\u6709\u9897\u5C0F\u75E3\uFF0C\u7B11\u8D77\u6765\u6709\u9152\u7A9D", onChange: (e) => onChange({ ...card, extra: e.target.value }) })
612
+ ] })
613
+ ] });
614
+ }
615
+ function SceneEditor({ project, scene, isDefault, status, screen, onChange, onDefault, onRemove, onFrame }) {
616
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-scenes", children: [
617
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-row", children: [
618
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "her-input", style: { width: 140 }, value: scene.name, onChange: (e) => onChange((s) => {
619
+ s.name = e.target.value;
620
+ }) }),
621
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { className: "her-select", style: { width: 90 }, value: scene.pose, onChange: (e) => onChange((s) => {
622
+ const pose = e.target.value;
623
+ s.clips = s.clips.map((c) => ({ ...c, file: c.file.replace(/^(stand|sit|lie)_/, `${pose}_`), action: c.action.replace(POSE_WORDS[s.pose], POSE_WORDS[pose]) }));
624
+ s.pose = pose;
625
+ }), children: Object.keys(POSE_WORDS).map((p) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: p, children: POSE_WORDS[p] }, p)) }),
626
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
627
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "radio", checked: isDefault, onChange: onDefault }),
628
+ " \u9ED8\u8BA4\u573A\u666F"
629
+ ] }),
630
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "her-btn small", onClick: onRemove, children: "\u5220\u6389\u8FD9\u4E2A\u573A\u666F" })
631
+ ] }),
632
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "her-label", children: "\u8FD9\u4E2A\u5730\u65B9\u4EC0\u4E48\u6837\uFF08\u5199\u8FDB\u7167\u7247\u7684\u63D0\u793A\u8BCD\uFF09" }),
633
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "her-input", value: scene.place, placeholder: "\u6BD4\u5982\uFF1A\u6E29\u99A8\u7684\u5367\u5BA4\uFF0C\u6728\u8D28\u5E8A\u5934\u67DC\u548C\u53F0\u706F\uFF0C\u6696\u8272\u706F\u5149\uFF0C\u7A97\u5E18\u534A\u62C9", onChange: (e) => onChange((s) => {
634
+ s.place = e.target.value;
635
+ }) }),
636
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-row", children: [
637
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "her-muted", children: "\u4EC0\u4E48\u65F6\u5019\u5728\u8FD9\uFF1A" }),
638
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "her-input", style: { width: 90 }, value: scene.hours ?? "", placeholder: "21-24", onChange: (e) => onChange((s) => {
639
+ if (e.target.value.trim() === "") delete s.hours;
640
+ else s.hours = e.target.value.trim();
641
+ }) }),
642
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "her-muted", children: "\u70B9\uFF0C" }),
643
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { className: "her-select", style: { width: 150 }, value: scene.user ?? "", onChange: (e) => onChange((s) => {
644
+ if (e.target.value === "") delete s.user;
645
+ else s.user = e.target.value;
646
+ }), children: [
647
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", children: "\u4E0D\u7BA1\u4F60\u5728\u4E0D\u5728" }),
648
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "active", children: "\u4F60\u5728\u7528\u7535\u8111\u65F6" }),
649
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "idle", children: "\u4F60\u5F88\u4E45\u6CA1\u52A8\u65F6" })
650
+ ] })
651
+ ] }),
652
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "her-muted", children: [
653
+ "\u7167\u7247\uFF1A\u7528\u53C2\u8003\u56FE\u751F\u6210\uFF08",
654
+ screen === void 0 ? "\u6A2A\u7248\uFF0C\u548C\u5C4F\u5E55\u4E00\u6837\u7684\u6BD4\u4F8B" : `${screen.width}\xD7${screen.height}`,
655
+ "\uFF09\uFF0C\u5B58\u6210 plate.png \u653E\u8FDB\u300C",
656
+ sceneDir(scene),
657
+ "\u300D\u6587\u4EF6\u5939\u3002"
658
+ ] }),
659
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PromptBox, { text: scenePhotoPrompt(project, scene, screen) }),
660
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PartStatusLine, { status }),
661
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-row", children: [
662
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "her-btn", disabled: status?.photo !== true, onClick: onFrame, children: "\u6846\u4EBA\u7269\u533A" }),
663
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "her-muted", children: '\u5728\u684C\u9762\u4E0A\u6253\u5F00"\u505A\u573A\u666F"\uFF0C\u6846\u51FA\u5979\u6D3B\u52A8\u7684\u90A3\u4E00\u5757\uFF1B\u4E4B\u540E\u7528 crop.png \u5F53\u9996\u5E27\u751F\u6210\u89C6\u9891\u3002' })
664
+ ] }),
665
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClipList, { project, kind: "scene", scene, clips: scene.clips, pose: scene.pose, onChange: (clips) => onChange((s) => {
666
+ s.clips = clips;
667
+ }) })
668
+ ] });
669
+ }
670
+ function ClipList({ project, kind, scene, clips, pose, onChange }) {
671
+ const [own, setOwn] = (0, import_react.useState)("");
672
+ const set = (i, change) => onChange(clips.map((c, j) => j === i ? { ...c, ...change } : c));
673
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
674
+ clips.map((clip, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-row", style: { margin: "3px 0" }, children: [
675
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { style: { width: 150 }, children: [
676
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: clip.off !== true, disabled: clip.required === true, onChange: (e) => set(i, { off: !e.target.checked }) }),
677
+ " ",
678
+ clip.file
679
+ ] }),
680
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "her-input", style: { flex: 1, minWidth: 200 }, value: clip.action, disabled: clip.off === true, onChange: (e) => set(i, { action: e.target.value }) }),
681
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "her-btn small", disabled: clip.off === true, onClick: () => copy(clipPrompt(project, kind, clip, scene)), children: "\u590D\u5236\u63D0\u793A\u8BCD" })
682
+ ] }, clip.file)),
683
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "her-row", children: [
684
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "her-input", style: { flex: 1 }, value: own, placeholder: "\u52A0\u4E00\u6BB5\u81EA\u5DF1\u7684\u52A8\u4F5C\uFF0C\u6BD4\u5982\uFF1A\u7AEF\u8D77\u5496\u5561\u559D\u4E00\u53E3\uFF0C\u518D\u653E\u4E0B", onChange: (e) => setOwn(e.target.value) }),
685
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "her-btn small", disabled: own.trim() === "", onClick: () => {
686
+ onChange([...clips, customClip(pose, clips, own)]);
687
+ setOwn("");
688
+ }, children: "\u52A0\u4E0A" })
689
+ ] })
690
+ ] });
691
+ }
692
+ function ImportProgress({ state }) {
693
+ const imp = state.import;
694
+ if (imp.state === "running") {
695
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
696
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "her-progress", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { width: `${imp.total === 0 ? 0 : Math.round(imp.done / imp.total * 100)}%` } }) }),
697
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "her-muted", children: imp.step })
698
+ ] });
699
+ }
700
+ if (imp.state !== "done" && imp.state !== "failed") return null;
701
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "her-report", children: imp.lines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: line.level === "error" ? "her-danger" : line.level === "warn" ? "her-warn" : "", children: [
702
+ line.level === "ok" ? "\u2705" : line.level === "warn" ? "\u26A0\uFE0F" : "\u274C",
703
+ " ",
704
+ line.text
705
+ ] }, i)) });
706
+ }
707
+
708
+ // src/client/parts.tsx
709
+ var import_react2 = require("react");
710
+ var import_jsx_runtime2 = require("react/jsx-runtime");
711
+ var MODE_TEXT = {
712
+ overlay: { title: "\u6D6E\u5728\u6700\u4E0A\u5C42", desc: "\u50CF\u684C\u5BA0\u4E00\u6837\u5728\u6240\u6709\u7A97\u53E3\u4E0A\u9762\uFF0C\u53EF\u4EE5\u62D6\u52A8\u3001\u70B9\u5979" },
713
+ wallpaper: { title: "\u4F4F\u5728\u58C1\u7EB8\u91CC", desc: "\u5728\u684C\u9762\u56FE\u6807\u548C\u6240\u6709\u7A97\u53E3\u4E0B\u9762\uFF0C\u53EA\u770B\u4E0D\u70B9\uFF1B\u6309\u5FEB\u6377\u952E\u53EB\u5979\u51FA\u6765" },
714
+ window: { title: "\u666E\u901A\u7A97\u53E3", desc: "\u4E00\u4E2A\u53EF\u4EE5\u5173\u6389\u7684\u7A97\u53E3" }
715
+ };
716
+ function Dot({ tone }) {
717
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: `her-dot ${tone === "off" ? "" : tone}` });
718
+ }
719
+ function BodyStatus({ state, apply: apply2 }) {
720
+ const [message, setMessage] = (0, import_react2.useState)();
721
+ const body = state.body;
722
+ const install = body.install;
723
+ const start = async () => {
724
+ const result = await herApi.startBody();
725
+ if (result.ok) setMessage(result.message);
726
+ await apply2(Promise.resolve(result));
727
+ };
728
+ const busy = install.state === "checking" || install.state === "downloading" || install.state === "installing";
729
+ const progress = busy && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
730
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "her-progress", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { width: `${install.total ? Math.round((install.done ?? 0) / install.total * 100) : 0}%` } }) }),
731
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-muted", children: install.state === "checking" ? "\u6B63\u5728\u770B\u6709\u6CA1\u6709\u65B0\u7248\u672C\u2026" : install.state === "installing" ? "\u6B63\u5728\u5B89\u88C5\u2026" : `\u6B63\u5728\u4E0B\u8F7D\u8EAB\u4F53\u7A0B\u5E8F ${install.latest ?? ""}\uFF08${mb(install.done)} / ${mb(install.total)} MB\uFF09` })
732
+ ] });
733
+ const failed = install.state === "failed" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "her-danger", children: [
734
+ "\u4E0B\u8F7D\u5B89\u88C5\u6CA1\u6210\u529F\uFF1A",
735
+ install.error
736
+ ] });
737
+ if (body.connected) {
738
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
739
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { children: [
740
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Dot, { tone: "ok" }),
741
+ "\u8EAB\u4F53\u5DF2\u8FDE\u4E0A\uFF08",
742
+ body.info?.os,
743
+ "\uFF0C\u7248\u672C ",
744
+ body.info?.version,
745
+ "\uFF09",
746
+ body.pack === void 0 ? "" : `\uFF0C\u5916\u5F62\uFF1A${body.pack.name}`,
747
+ !install.dev && !busy && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn link", onClick: () => void apply2(herApi.installBody()), children: "\u68C0\u67E5\u66F4\u65B0" }),
748
+ !install.dev && !busy && install.latest !== void 0 && install.restart !== true && install.state === "idle" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "her-muted", children: [
749
+ "\uFF08\u5DF2\u662F\u6700\u65B0\uFF1A",
750
+ install.latest,
751
+ "\uFF09"
752
+ ] })
753
+ ] }),
754
+ install.restart === true && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-row", children: [
755
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
756
+ "\u65B0\u7248\u672C ",
757
+ install.installed,
758
+ " \u5DF2\u7ECF\u88C5\u597D\uFF0C\u91CD\u542F\u4E00\u4E0B\u8EAB\u4F53\u5C31\u7528\u4E0A\u4E86\u3002"
759
+ ] }),
760
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn primary", onClick: () => void apply2(herApi.restartBody()), children: "\u91CD\u542F\u8EAB\u4F53" })
761
+ ] }),
762
+ progress,
763
+ failed
764
+ ] });
765
+ }
766
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
767
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { children: [
768
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Dot, { tone: body.running ? "warn" : "bad" }),
769
+ body.running ? "\u8EAB\u4F53\u5728\u8FD0\u884C\uFF0C\u6B63\u5728\u8FDE\u63A5\u2026" : "\u8EAB\u4F53\u8FD8\u6CA1\u8FD0\u884C"
770
+ ] }),
771
+ !body.running && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "her-row", children: body.canStart ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn primary", onClick: () => void start(), children: "\u542F\u52A8\u8EAB\u4F53" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
772
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn primary", disabled: busy, onClick: () => void apply2(herApi.installBody()), children: "\u4E0B\u8F7D\u5B89\u88C5\u8EAB\u4F53" }),
773
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "her-muted", children: "\u5979\u5728\u684C\u9762\u4E0A\u7684\u6837\u5B50\u662F\u4E00\u4E2A\u5355\u72EC\u7684\u5C0F\u7A0B\u5E8F\uFF08\u7EA6 150 MB\uFF09\uFF0C\u88C5\u5728 dsh-her \u81EA\u5DF1\u7684\u6587\u4EF6\u5939\u91CC\uFF0C\u88C5\u597D\u5C31\u81EA\u52A8\u542F\u52A8\u3002" })
774
+ ] }) }),
775
+ progress,
776
+ failed,
777
+ message !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-muted", children: message })
778
+ ] });
779
+ }
780
+ var mb = (bytes) => ((bytes ?? 0) / 1e6).toFixed(0);
781
+ function PackPicker({ state, apply: apply2 }) {
782
+ const body = state.body;
783
+ const imp = state.import;
784
+ if (!body.connected) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-muted", children: "\u8EAB\u4F53\u8FDE\u4E0A\u4E4B\u540E\u624D\u80FD\u9009\u5916\u5F62\u3002" });
785
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
786
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-grid", children: [
787
+ body.packs.map((pack) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: `her-choice ${pack.packId === body.activePack ? "on" : ""}`, onClick: () => void apply2(herApi.usePack(pack.packId)), children: [
788
+ pack.name,
789
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("small", { children: [
790
+ pack.packId.startsWith("look:") ? "\u591A\u573A\u666F\u5F62\u8C61" : pack.layer === "scene" ? "\u58C1\u7EB8\u573A\u666F" : "\u684C\u5BA0",
791
+ " \xB7 ",
792
+ pack.actions.filter((a) => !a.id.startsWith("scene_")).length,
793
+ " \u4E2A\u52A8\u4F5C",
794
+ pack.emotions.length > 0 ? ` \xB7 ${pack.emotions.length} \u79CD\u60C5\u7EEA` : ""
795
+ ] })
796
+ ] }, pack.packId)),
797
+ body.packs.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-muted", children: "\u8FD8\u6CA1\u6709\u5BFC\u5165\u8FC7\u5916\u5F62\u5305\u3002" })
798
+ ] }),
799
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-row", children: [
800
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn", disabled: imp.state === "picking" || imp.state === "running", onClick: () => void apply2(herApi.pickPack()), children: "\u5BFC\u5165\u6211\u7684\u7D20\u6750\u2026" }),
801
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "her-muted", children: "\u4F1A\u5728\u8EAB\u4F53\u90A3\u53F0\u7535\u8111\u4E0A\u5F39\u51FA\u9009\u62E9\u6587\u4EF6\u5939\u7684\u7A97\u53E3\u3002\u7D20\u6750\u600E\u4E48\u505A\u3001\u600E\u4E48\u547D\u540D\uFF0C\u89C1 docs/\u7D20\u6750\u751F\u6210\u63D0\u793A\u8BCD.md\u3002" })
802
+ ] }),
803
+ imp.state === "picking" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-muted", children: "\u8BF7\u5728\u684C\u9762\u4E0A\u5F39\u51FA\u7684\u7A97\u53E3\u91CC\u9009\u62E9\u7D20\u6750\u6587\u4EF6\u5939\u2026" }),
804
+ imp.state === "running" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
805
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "her-progress", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { width: `${imp.total === 0 ? 0 : Math.round(imp.done / imp.total * 100)}%` } }) }),
806
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "her-muted", children: [
807
+ imp.step,
808
+ "\uFF08",
809
+ imp.done,
810
+ "/",
811
+ imp.total,
812
+ "\uFF09"
813
+ ] })
814
+ ] }),
815
+ (imp.state === "done" || imp.state === "failed") && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { className: "her-report", children: imp.lines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("li", { className: line.level === "error" ? "her-danger" : line.level === "warn" ? "her-warn" : "", children: [
816
+ line.level === "ok" ? "\u2705" : line.level === "warn" ? "\u26A0\uFE0F" : "\u274C",
817
+ " ",
818
+ line.text
819
+ ] }, i)) })
820
+ ] });
821
+ }
822
+ function PersonaEditor({ state, apply: apply2, onSaved, saveLabel = "\u4FDD\u5B58" }) {
823
+ const c = state.character;
824
+ const [name, setName] = (0, import_react2.useState)(c.name);
825
+ const [callYou, setCallYou] = (0, import_react2.useState)(c.callYou);
826
+ const [pronoun, setPronoun] = (0, import_react2.useState)(c.pronoun);
827
+ const [persona, setPersona] = (0, import_react2.useState)(c.persona);
828
+ const [idea, setIdea] = (0, import_react2.useState)("");
829
+ const [busy, setBusy] = (0, import_react2.useState)();
830
+ const [error, setError] = (0, import_react2.useState)();
831
+ const [chat, setChat] = (0, import_react2.useState)([]);
832
+ const [line, setLine] = (0, import_react2.useState)("");
833
+ const expand = async () => {
834
+ setBusy("expand");
835
+ setError(void 0);
836
+ const result = await herApi.expandPersona({ name, idea, callYou, pronoun });
837
+ setBusy(void 0);
838
+ if (result.ok) setPersona(result.persona);
839
+ else setError(result.message);
840
+ };
841
+ const tryOne = async () => {
842
+ const message = line.trim();
843
+ if (message === "") return;
844
+ setBusy("try");
845
+ setLine("");
846
+ const history = [...chat, { who: "you", text: message }];
847
+ setChat(history);
848
+ const result = await herApi.tryPersona({ name, persona, callYou, pronoun, history: chat, message });
849
+ setBusy(void 0);
850
+ setChat(result.ok ? [...history, { who: "her", text: result.reply }] : history);
851
+ if (!result.ok) setError(result.message);
852
+ };
853
+ const save = async () => {
854
+ setBusy("save");
855
+ const ok = await apply2(herApi.saveCharacter({ name, persona, callYou, pronoun }));
856
+ setBusy(void 0);
857
+ if (ok) onSaved?.();
858
+ };
859
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
860
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-row", children: [
861
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { flex: 1, minWidth: 140 }, children: [
862
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { className: "her-label", children: "\u5979\u7684\u540D\u5B57" }),
863
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { className: "her-input", value: name, onChange: (e) => setName(e.target.value) })
864
+ ] }),
865
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { flex: 1, minWidth: 140 }, children: [
866
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { className: "her-label", children: "\u5979\u600E\u4E48\u79F0\u547C\u4F60" }),
867
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { className: "her-input", value: callYou, placeholder: "\u6BD4\u5982\uFF1A\u963F\u6587", onChange: (e) => setCallYou(e.target.value) })
868
+ ] }),
869
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { width: 120 }, children: [
870
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { className: "her-label", children: "\u63D0\u5230\u4F60\u65F6\u7528" }),
871
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("select", { className: "her-select", value: pronoun, onChange: (e) => setPronoun(e.target.value), children: [
872
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "\u4ED6", children: "\u4ED6" }),
873
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "\u5979", children: "\u5979" }),
874
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "TA", children: "TA" })
875
+ ] })
876
+ ] })
877
+ ] }),
878
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { className: "her-label", children: "\u4E00\u53E5\u8BDD\u63CF\u8FF0\u5979\uFF08\u53EF\u9009\uFF09\uFF0C\u8BA9\u6A21\u578B\u5E2E\u4F60\u5199\u6210\u5B8C\u6574\u4EBA\u8BBE" }),
879
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-row", children: [
880
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { className: "her-input", style: { flex: 1 }, value: idea, placeholder: "\u6BD4\u5982\uFF1A\u4E8C\u5341\u4E94\u5C81\u7684\u7F16\u5267\uFF0C\u7231\u5410\u69FD\uFF0C\u559C\u6B22\u732B\u548C\u706B\u9505", onChange: (e) => setIdea(e.target.value) }),
881
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn", disabled: busy !== void 0 || idea.trim() === "", onClick: () => void expand(), children: busy === "expand" ? "\u6B63\u5728\u5199\u2026" : "\u5E2E\u6211\u5199" })
882
+ ] }),
883
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { className: "her-label", children: "\u4EBA\u8BBE\uFF08\u53EF\u4EE5\u76F4\u63A5\u6539\uFF09" }),
884
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("textarea", { className: "her-textarea", value: persona, onChange: (e) => setPersona(e.target.value) }),
885
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { className: "her-label", children: "\u5148\u8BD5\u804A\u51E0\u53E5\uFF08\u4E0D\u4F1A\u8FDB\u5979\u7684\u8BB0\u5FC6\uFF09" }),
886
+ chat.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "her-chat", children: chat.map((m, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: m.who, children: [
887
+ m.who === "you" ? "\u4F60\uFF1A" : `${name}\uFF1A`,
888
+ m.text
889
+ ] }, i)) }),
890
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-row", children: [
891
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { className: "her-input", style: { flex: 1 }, value: line, placeholder: "\u8BF4\u4E00\u53E5\u8BD5\u8BD5", onChange: (e) => setLine(e.target.value), onKeyDown: (e) => {
892
+ if (e.key === "Enter") void tryOne();
893
+ } }),
894
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn", disabled: busy !== void 0 || persona.trim() === "", onClick: () => void tryOne(), children: busy === "try" ? "\u2026" : "\u53D1\u9001" })
895
+ ] }),
896
+ error !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-error", children: error }),
897
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "her-row", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn primary", disabled: busy !== void 0, onClick: () => void save(), children: saveLabel }) })
898
+ ] });
899
+ }
900
+ function KeyHelp({ state }) {
901
+ if (state.voice.speaking.status === "no-quota") {
902
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-warn", children: [
903
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "\u767E\u70BC\u8D26\u53F7\u7684\u989D\u5EA6\u7528\u5B8C\u4E86\uFF0C\u5979\u73B0\u5728\u53EA\u7528\u6587\u5B57\u56DE\u7B54\u3002" }),
904
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: '\u5230\u963F\u91CC\u4E91\u767E\u70BC\u63A7\u5236\u53F0\u5F00\u901A\u6309\u91CF\u4ED8\u8D39\uFF1B\u5982\u679C\u5DF2\u7ECF\u5F00\u901A\uFF0C\u628A"\u4EC5\u4F7F\u7528\u514D\u8D39\u989D\u5EA6"\u5173\u6389\u3002\u5F04\u597D\u540E\u6700\u591A\u534A\u5206\u949F\u5979\u5C31\u80FD\u8BF4\u8BDD\uFF0C\u4E0D\u7528\u91CD\u542F\u3002' }),
905
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-faint", children: state.voice.speaking.error })
906
+ ] });
907
+ }
908
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-warn", children: [
909
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "\u5979\u7684\u58F0\u97F3\u7528\u963F\u91CC\u4E91\u767E\u70BC\uFF08CosyVoice\uFF09\uFF0C\u8FD8\u6CA1\u6709\u627E\u5230 API key\uFF0C\u73B0\u5728\u53EA\u7528\u6587\u5B57\u56DE\u7B54\u3002" }),
910
+ state.platform === "darwin" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { children: [
911
+ "\u5728\u7EC8\u7AEF\u8FD0\u884C\u4E0B\u9762\u8FD9\u6761\u547D\u4EE4\uFF0C\u6309\u63D0\u793A\u7C98\u8D34 key\uFF08\u4E24\u6B21\uFF0C\u5C4F\u5E55\u4E0A\u4E0D\u663E\u793A\uFF09\uFF0C\u4E0D\u7528\u91CD\u542F\uFF1A",
912
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("br", {}),
913
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { children: "security add-generic-password -a dsh-her -s dsh-her-dashscope -w" })
914
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { children: [
915
+ "\u628A key \u8BBE\u6210\u73AF\u5883\u53D8\u91CF ",
916
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { children: "DASHSCOPE_API_KEY" }),
917
+ "\uFF0C\u7136\u540E\u91CD\u542F dsh\u3002"
918
+ ] }),
919
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-faint", children: "key \u4E0D\u4F1A\u5B58\u8FDB\u4EFB\u4F55\u6587\u4EF6\uFF0C\u4E5F\u4E0D\u8981\u8D34\u5230\u804A\u5929\u91CC\u3002" })
920
+ ] });
921
+ }
922
+ function VoicePicker({ state, apply: apply2, onSaved, saveLabel = "\u7528\u8FD9\u4E2A\u58F0\u97F3" }) {
923
+ const [voice, setVoice] = (0, import_react2.useState)(state.character.voice.id);
924
+ const [speed, setSpeed] = (0, import_react2.useState)(state.character.voice.speed);
925
+ const [error, setError] = (0, import_react2.useState)();
926
+ const [playing, setPlaying] = (0, import_react2.useState)();
927
+ const { status: speaking, error: speakingError } = state.voice.speaking;
928
+ const listen = async (which) => {
929
+ setVoice(which);
930
+ setPlaying(which);
931
+ setError(void 0);
932
+ const result = await herApi.previewVoice(which, speed, `\u4F60\u597D\u5440\uFF0C\u6211\u662F${state.character.name}\uFF0C\u6211\u5728\u4F60\u684C\u9762\u4E0A\u7B49\u4F60\u597D\u4E45\u5566\u3002\u4ECA\u5929\u8FC7\u5F97\u600E\u4E48\u6837\uFF1F`);
933
+ setPlaying(void 0);
934
+ if (result.ok) playAudio(result.audio, result.format);
935
+ else setError(result.message);
936
+ };
937
+ const save = async () => {
938
+ if (await apply2(herApi.saveCharacter({ voice, speed }))) onSaved?.();
939
+ };
940
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
941
+ (speaking === "no-key" || speaking === "no-quota") && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(KeyHelp, { state }),
942
+ speaking === "off" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-warn", children: "\u5979\u7684\u58F0\u97F3\u5DF2\u5173\u95ED\uFF08\u63D2\u4EF6\u8BBE\u7F6E\u91CC voice.enabled \u662F false\uFF09\uFF0C\u53EA\u7528\u6587\u5B57\u56DE\u7B54\u3002" }),
943
+ speaking === "installing" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-muted", children: "\u7B2C\u4E00\u6B21\u7528\uFF0C\u6B63\u5728\u51C6\u5907 Edge \u8BED\u97F3\u7EC4\u4EF6\uFF08\u4E00\u4E24\u5206\u949F\uFF09\u2026" }),
944
+ speaking === "failed" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "her-warn", children: [
945
+ "\u5979\u7684\u58F0\u97F3\u521A\u624D\u51FA\u9519\u4E86\uFF1A",
946
+ speakingError ?? "\u672A\u77E5\u539F\u56E0",
947
+ "\u3002\u4F1A\u81EA\u52A8\u91CD\u8BD5\u3002"
948
+ ] }),
949
+ ["edge", "cosyvoice"].map((service) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
950
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { className: "her-label", children: SERVICE_NAMES[service] }),
951
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "her-grid", children: VOICES.filter((v2) => v2.service === service).map((v2) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: `her-choice ${v2.id === voice ? "on" : ""}`, disabled: speaking === "off", onClick: () => void listen(v2.id), children: [
952
+ v2.name,
953
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: playing === v2.id ? "\u6B63\u5728\u5408\u6210\u2026" : `${v2.desc} \xB7 \u70B9\u4E00\u4E0B\u8BD5\u542C` })
954
+ ] }, v2.id)) })
955
+ ] }, service)),
956
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-row", children: [
957
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "her-muted", children: [
958
+ "\u8BED\u901F ",
959
+ speed.toFixed(1)
960
+ ] }),
961
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "range", min: 0.7, max: 1.4, step: 0.1, value: speed, onChange: (e) => setSpeed(Number(e.target.value)) }),
962
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn", disabled: speaking === "off", onClick: () => void listen(voice), children: "\u7528\u8FD9\u4E2A\u8BED\u901F\u8BD5\u542C" })
963
+ ] }),
964
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-faint", children: "Edge \u7684\u58F0\u97F3\u514D\u8D39\uFF0C\u4F46\u4E0D\u662F\u5FAE\u8F6F\u516C\u5F00\u7684\u6B63\u5F0F\u63A5\u53E3\uFF0C\u53EF\u80FD\u54EA\u5929\u5931\u6548\uFF1B\u767E\u70BC\u7684\u58F0\u97F3\u66F4\u7A33\uFF0C\u8981 key \u548C\u4ED8\u8D39\u989D\u5EA6\u3002\u7528\u4F60\u81EA\u5DF1\u5F55\u7684\u58F0\u97F3\u514B\u9686\uFF0C\u4E4B\u540E\u4F1A\u52A0\u5728\u8FD9\u91CC\u3002" }),
965
+ error !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-error", children: error }),
966
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "her-row", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn primary", onClick: () => void save(), children: saveLabel }) })
967
+ ] });
968
+ }
969
+ var DEFAULT_CHOICE = "";
970
+ function ModelPicker({ state, apply: apply2 }) {
971
+ const chosen = state.character.model;
972
+ const [groups, setGroups] = (0, import_react2.useState)();
973
+ const [loadError, setLoadError] = (0, import_react2.useState)();
974
+ const [choice, setChoice] = (0, import_react2.useState)(chosen === void 0 ? DEFAULT_CHOICE : `${chosen.provider}/${chosen.model}`);
975
+ const [effort, setEffort] = (0, import_react2.useState)(chosen?.effort ?? "");
976
+ const [saved, setSaved] = (0, import_react2.useState)(false);
977
+ (0, import_react2.useEffect)(() => {
978
+ void modelCatalog().then((result) => {
979
+ if (result.ok) setGroups(result.groups);
980
+ else setLoadError(result.message);
981
+ });
982
+ }, []);
983
+ const [provider, model] = choice === DEFAULT_CHOICE ? [void 0, void 0] : [choice.slice(0, choice.indexOf("/")), choice.slice(choice.indexOf("/") + 1)];
984
+ const efforts = groups?.find((g) => g.id === provider)?.models.find((m) => m.id === model)?.reasoning?.efforts ?? [];
985
+ const nameOf = (p, m) => {
986
+ const group = groups?.find((g) => g.id === p);
987
+ return `${group?.name ?? p} \xB7 ${group?.models.find((x) => x.id === m)?.name ?? m}`;
988
+ };
989
+ const save = async () => {
990
+ setSaved(false);
991
+ const value = provider === void 0 ? null : { provider, model, ...effort === "" ? {} : { effort } };
992
+ if (await apply2(herApi.saveCharacter({ model: value }))) setSaved(true);
993
+ };
994
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
995
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "her-muted", children: [
996
+ "\u73B0\u5728\u7528\u7684\uFF1A",
997
+ state.model === null ? "\u6CA1\u6709\u53EF\u7528\u7684\u6A21\u578B" : `${nameOf(state.model.provider, state.model.model)}${state.model.effort ? `\uFF08\u601D\u8003\uFF1A${state.model.effort}\uFF09` : ""}`,
998
+ state.model !== null && !state.model.chosen && "\uFF08dsh \u7684\u9ED8\u8BA4\u6A21\u578B\uFF09"
999
+ ] }),
1000
+ loadError !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "her-error", children: [
1001
+ "\u62FF\u4E0D\u5230 dsh \u7684\u6A21\u578B\u5217\u8868\uFF1A",
1002
+ loadError
1003
+ ] }),
1004
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-row", children: [
1005
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("select", { className: "her-select", style: { flex: 1, minWidth: 220 }, value: choice, disabled: groups === void 0, onChange: (e) => {
1006
+ setChoice(e.target.value);
1007
+ setEffort("");
1008
+ }, children: [
1009
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: DEFAULT_CHOICE, children: "\u8DDF\u968F dsh \u7684\u9ED8\u8BA4\u6A21\u578B" }),
1010
+ groups?.map((g) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("optgroup", { label: g.name, children: g.models.map((m) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: `${g.id}/${m.id}`, children: m.name }, m.id)) }, g.id))
1011
+ ] }),
1012
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("select", { className: "her-select", style: { width: 150 }, value: effort, disabled: efforts.length === 0, onChange: (e) => setEffort(e.target.value), children: [
1013
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "\u601D\u8003\uFF1A\u9ED8\u8BA4" }),
1014
+ efforts.map((x) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("option", { value: x.id, children: [
1015
+ "\u601D\u8003\uFF1A",
1016
+ x.name
1017
+ ] }, x.id))
1018
+ ] }),
1019
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn primary", disabled: groups === void 0, onClick: () => void save(), children: "\u7528\u8FD9\u4E2A\u6A21\u578B" })
1020
+ ] }),
1021
+ saved && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-ok", children: "\u5DF2\u6362\u597D\uFF0C\u4ECE\u5979\u7684\u4E0B\u4E00\u53E5\u8BDD\u5F00\u59CB\u751F\u6548\uFF1B\u4E4B\u524D\u804A\u8FC7\u7684\u90FD\u8FD8\u5728\u3002" }),
1022
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-faint", children: "\u804A\u5929\u8981\u7684\u662F\u5FEB\uFF1A\u9009 Flash \u4E00\u7C7B\u7684\u5FEB\u6A21\u578B\u3001\u601D\u8003\u9009 Low\uFF08\u6216 Off\uFF09\uFF0C\u5979\u5F00\u53E3\u4F1A\u5FEB\u5F88\u591A\u3002\u6A21\u578B\u7684\u8D26\u53F7\u548C\u4EF7\u683C\u5728 dsh \u7684\u8BBE\u7F6E\u91CC\u7BA1\u3002" })
1023
+ ] });
1024
+ }
1025
+ function MicCheck({ state }) {
1026
+ const shortcut = state.platform === "darwin" ? "\u2303\u2325\u7A7A\u683C" : "Ctrl+Alt+\u7A7A\u683C";
1027
+ const fresh = state.heard !== void 0 && Date.now() - state.heard.at < 12e4;
1028
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
1029
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { children: [
1030
+ "\u6309 ",
1031
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("b", { children: shortcut }),
1032
+ '\uFF0C\u5BF9\u7740\u9EA6\u514B\u98CE\u8BF4\u4E00\u53E5\u8BDD\uFF08\u6BD4\u5982"\u4F60\u597D\u5440"\uFF09\u3002\u7B2C\u4E00\u6B21\u4F1A\u5F39\u51FA\u9EA6\u514B\u98CE\u6743\u9650\u8BF7\u6C42\uFF0C\u8BF7\u5141\u8BB8\u3002'
1033
+ ] }),
1034
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "\u5979\u811A\u4E0B\u7684\u5C0F\u5706\u70B9\u4EAE\u8D77\u8868\u793A\u5728\u542C\uFF0C\u53D8\u7EFF\u8868\u793A\u542C\u5230\u4E86\u58F0\u97F3\u3002" }),
1035
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: fresh ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
1036
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Dot, { tone: "ok" }),
1037
+ "\u6211\u542C\u5230\u4E86\uFF1A\u300C",
1038
+ state.heard.text,
1039
+ "\u300D"
1040
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "her-muted", children: "\u8FD8\u6CA1\u542C\u5230\u2026\u2026" }) }),
1041
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-faint", children: "\u542C\u4E0D\u6E05\u65F6\uFF1A\u6362\u4E2A\u5B89\u9759\u7684\u5730\u65B9\uFF0C\u6216\u8005\u68C0\u67E5\u7CFB\u7EDF\u8BBE\u7F6E\u91CC\u9009\u7684\u9EA6\u514B\u98CE\u3002\u5916\u653E\u65F6\u5979\u7684\u58F0\u97F3\u53EF\u80FD\u88AB\u5F53\u6210\u4F60\u5728\u8BF4\u8BDD\uFF0C\u6234\u8033\u673A\u6548\u679C\u6700\u597D\u3002" })
1042
+ ] });
1043
+ }
1044
+ function ScenePicker({ state, apply: apply2 }) {
1045
+ const look = state.body.look;
1046
+ if (look === void 0) return null;
1047
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-scenes", children: [
1048
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { children: [
1049
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("b", { children: look.name }),
1050
+ " \u7684\u573A\u666F",
1051
+ look.desk ? '\uFF08"\u6D6E\u5728\u6700\u4E0A\u5C42"\u65F6\u663E\u793A\u684C\u5BA0\uFF0C\u6362\u573A\u666F\u5728\u5176\u4ED6\u4E24\u79CD\u6A21\u5F0F\u4E0B\u770B\u5F97\u5230\uFF09' : ""
1052
+ ] }),
1053
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-row", children: [
1054
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
1055
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "checkbox", checked: look.auto, onChange: (e) => void apply2(herApi.setLook({ auto: e.target.checked })) }),
1056
+ " \u81EA\u52A8\u6362\u573A\u666F"
1057
+ ] }),
1058
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
1059
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "checkbox", checked: look.locked, onChange: (e) => void apply2(herApi.setLook({ locked: e.target.checked })) }),
1060
+ " \u5F85\u5728\u73B0\u5728\u8FD9\u91CC\u4E0D\u52A8"
1061
+ ] })
1062
+ ] }),
1063
+ look.scenes.map((scene) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-row her-scene", children: [
1064
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
1065
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "checkbox", checked: scene.on, disabled: scene.id === look.current, onChange: (e) => void apply2(herApi.setLook({ on: { [scene.id]: e.target.checked } })) }),
1066
+ " ",
1067
+ scene.name
1068
+ ] }),
1069
+ scene.id === look.current && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "her-tag ok", children: "\u73B0\u5728\u5728\u8FD9" }),
1070
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "her-muted", children: scene.when }),
1071
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn", disabled: scene.id === look.current || !scene.on, onClick: () => void apply2(herApi.setLook({ go: scene.id })), children: "\u73B0\u5728\u53BB\u8FD9\u91CC" })
1072
+ ] }, scene.id)),
1073
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-muted", children: '\u81EA\u52A8\u6362\u573A\u666F\u65F6\uFF0C\u6BCF\u4E2A\u573A\u666F\u81F3\u5C11\u5F85 20 \u5206\u949F\uFF0C\u4F60\u4EEC\u8BF4\u8BDD\u7684\u65F6\u5019\u4E0D\u6362\u3002\u8DDF\u5979\u8BF4"\u53BB\u5367\u5BA4\u5427""\u5C31\u5F85\u5728\u8FD9"\u4E5F\u884C\u3002' })
1074
+ ] });
1075
+ }
1076
+ function ModePicker({ state, apply: apply2 }) {
1077
+ const current = state.body.mode;
1078
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "her-grid", children: ["overlay", "wallpaper", "window"].map((mode) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: `her-choice ${current === mode ? "on" : ""}`, disabled: !state.body.connected, onClick: () => void apply2(herApi.setMode(mode)), children: [
1079
+ MODE_TEXT[mode].title,
1080
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: MODE_TEXT[mode].desc })
1081
+ ] }, mode)) });
1082
+ }
1083
+ function MemoryView({ state, apply: apply2 }) {
1084
+ const [report, setReport] = (0, import_react2.useState)();
1085
+ const { diary, lastDigestDay } = state.memory;
1086
+ const facts = [...state.memory.facts].reverse();
1087
+ const episodes = [...state.memory.episodes].reverse();
1088
+ const today = (/* @__PURE__ */ new Date()).toDateString();
1089
+ const isNew = (at) => new Date(at).toDateString() === today;
1090
+ const digest = async () => {
1091
+ setReport("\u6B63\u5728\u6574\u7406\u2026");
1092
+ const result = await herApi.digest();
1093
+ setReport(result.ok ? result.report : result.message);
1094
+ if (result.ok) await apply2(Promise.resolve(result));
1095
+ };
1096
+ const download = async () => {
1097
+ const result = await herApi.exportMemory();
1098
+ if (!result.ok) return;
1099
+ const link = document.createElement("a");
1100
+ link.href = URL.createObjectURL(new Blob([result.markdown], { type: "text/markdown" }));
1101
+ link.download = `\u5979\u8BB0\u5F97\u7684\u4E8B-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.md`;
1102
+ link.click();
1103
+ URL.revokeObjectURL(link.href);
1104
+ };
1105
+ const forget = (id, text) => {
1106
+ if (window.confirm(`\u8BA9\u5979\u5FD8\u6389\u8FD9\u6761\uFF1F
1107
+
1108
+ ${text}`)) void apply2(herApi.memoryRemove([id]));
1109
+ };
1110
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
1111
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-card", children: [
1112
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("h2", { children: [
1113
+ "\u5173\u4E8E\u4F60\uFF08",
1114
+ facts.length,
1115
+ "\uFF09"
1116
+ ] }),
1117
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-muted", children: '\u5979\u804A\u5929\u65F6\u81EA\u5DF1\u8BB0\u4E0B\u7684\u76F4\u63A5\u751F\u6548\uFF1B\u804A\u5B8C\u4E00\u5206\u949F\u540E\u5979\u4F1A\u628A\u521A\u624D\u7684\u8BDD\u8FC7\u4E00\u904D\uFF0C\u6311\u51FA\u6765\u7684\u5148"\u5F85\u786E\u8BA4"\uFF0C7 \u5929\u540E\u81EA\u52A8\u786E\u8BA4\uFF0C\u654F\u611F\u7684\u8981\u4F60\u70B9\u786E\u8BA4\u3002' }),
1118
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("ul", { className: "her-list", children: [
1119
+ facts.map((f) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("li", { children: [
1120
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "grow", children: f.text }),
1121
+ isNew(f.createdAt) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "her-tag ok", children: "\u4ECA\u5929" }),
1122
+ f.status === "candidate" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "her-tag warn", children: "\u5F85\u786E\u8BA4" }),
1123
+ f.sensitive && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "her-tag bad", children: "\u654F\u611F" }),
1124
+ f.status === "candidate" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn small", onClick: () => void apply2(herApi.memoryConfirm([f.id])), children: "\u786E\u8BA4" }),
1125
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn small", onClick: () => forget(f.id, f.text), children: "\u5FD8\u6389" })
1126
+ ] }, f.id)),
1127
+ facts.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { className: "her-muted", children: "\u8FD8\u6CA1\u6709" })
1128
+ ] })
1129
+ ] }),
1130
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-card", children: [
1131
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("h2", { children: [
1132
+ "\u4E8B\u4EF6\uFF08",
1133
+ episodes.length,
1134
+ "\uFF09"
1135
+ ] }),
1136
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-muted", children: "\u6709\u65E5\u671F\u7684\u4E8B\uFF0C\u5728\u5F53\u5929\u548C\u524D\u4E00\u5929\u5979\u4F1A\u81EA\u7136\u5730\u63D0\u8D77\u3002" }),
1137
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("ul", { className: "her-list", children: [
1138
+ episodes.map((e) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("li", { children: [
1139
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "her-faint", children: e.at.slice(0, 10) }),
1140
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "grow", children: e.text }),
1141
+ isNew(e.at) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "her-tag ok", children: "\u4ECA\u5929" }),
1142
+ e.due !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "her-tag", children: e.due }),
1143
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn small", onClick: () => forget(e.id, e.text), children: "\u5FD8\u6389" })
1144
+ ] }, e.id)),
1145
+ episodes.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { className: "her-muted", children: "\u8FD8\u6CA1\u6709" })
1146
+ ] })
1147
+ ] }),
1148
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-card", children: [
1149
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("h2", { children: [
1150
+ "\u5979\u7684\u65E5\u8BB0\uFF08",
1151
+ diary.length,
1152
+ " \u5929\uFF09"
1153
+ ] }),
1154
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "her-muted", children: [
1155
+ "\u65E5\u8BB0\u6BCF\u5929\u5199\u4E00\u7BC7\uFF1A\u4F60\u6700\u540E\u4E00\u6B21\u548C\u5979\u8BF4\u8BDD 30 \u5206\u949F\u540E\uFF08\u6216 23:30 \u4EE5\u540E\uFF09\u3002\u4E0A\u6B21\u5199\u5230\uFF1A",
1156
+ lastDigestDay ?? "\u8FD8\u6CA1\u6709"
1157
+ ] }),
1158
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: diary.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "her-muted", children: "\u8FD8\u6CA1\u6709" }) : diary.join("\u3001") }),
1159
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "her-row", children: [
1160
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn", onClick: () => void digest(), children: "\u73B0\u5728\u6574\u7406\u4ECA\u5929" }),
1161
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "her-btn", onClick: () => void download(), children: "\u5BFC\u51FA\u5168\u90E8\uFF08Markdown\uFF09" })
1162
+ ] }),
1163
+ report !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "her-muted", children: report })
1164
+ ] })
1165
+ ] });
1166
+ }
1167
+
1168
+ // src/client/Page.tsx
1169
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1170
+ var POLL_MS = 2e3;
1171
+ function HerPage() {
1172
+ const [state, setState] = (0, import_react3.useState)();
1173
+ const [error, setError] = (0, import_react3.useState)();
1174
+ const [wizard, setWizard] = (0, import_react3.useState)();
1175
+ const refresh = (0, import_react3.useCallback)(async () => {
1176
+ const result = await herApi.state();
1177
+ if (result.ok) {
1178
+ setState(result.state);
1179
+ setError(void 0);
1180
+ } else setError(result.message);
1181
+ }, []);
1182
+ (0, import_react3.useEffect)(() => {
1183
+ void refresh();
1184
+ const timer = setInterval(() => void refresh(), POLL_MS);
1185
+ return () => clearInterval(timer);
1186
+ }, [refresh]);
1187
+ const apply2 = (0, import_react3.useCallback)(async (call) => {
1188
+ const result = await call;
1189
+ if (result.ok) {
1190
+ setState(result.state);
1191
+ setError(void 0);
1192
+ return true;
1193
+ }
1194
+ setError(result.message);
1195
+ return false;
1196
+ }, []);
1197
+ if (state === void 0) {
1198
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "her-page", children: error === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "her-muted", children: "\u6B63\u5728\u8FDE\u63A5\u5979\u7684\u5927\u8111\u2026" }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "her-error", children: [
1199
+ "\u8FDE\u4E0D\u4E0A\uFF1A",
1200
+ error
1201
+ ] }) });
1202
+ }
1203
+ const showWizard = wizard ?? !state.character.onboarded;
1204
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-page", children: [
1205
+ showWizard ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Wizard, { state, apply: apply2, onDone: () => setWizard(false) }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Manage, { state, apply: apply2, onWizard: () => setWizard(true) }),
1206
+ error !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "her-error", children: error })
1207
+ ] });
1208
+ }
1209
+ var STEPS = ["\u68C0\u67E5", "\u8EAB\u4F53", "\u5916\u5F62", "\u4EBA\u8BBE", "\u58F0\u97F3", "\u9EA6\u514B\u98CE", "\u653E\u5230\u684C\u9762"];
1210
+ function Wizard({ state, apply: apply2, onDone }) {
1211
+ const [step, setStep] = (0, import_react3.useState)(0);
1212
+ const next = () => setStep((s) => Math.min(s + 1, STEPS.length - 1));
1213
+ const finish = async () => {
1214
+ if (await apply2(herApi.saveCharacter({ onboarded: true }))) onDone();
1215
+ };
1216
+ const body = state.body;
1217
+ const nav = (canNext, hint) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-row", children: [
1218
+ step > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "her-btn", onClick: () => setStep(step - 1), children: "\u4E0A\u4E00\u6B65" }),
1219
+ step < STEPS.length - 1 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "her-btn primary", disabled: !canNext, onClick: next, children: "\u4E0B\u4E00\u6B65" }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "her-btn primary", onClick: () => void finish(), children: "\u5B8C\u6210" }),
1220
+ hint !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "her-muted", children: hint })
1221
+ ] });
1222
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1223
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-head", children: [
1224
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { children: "\u8BA9\u5979\u4F4F\u5230\u4F60\u7684\u684C\u9762\u4E0A" }),
1225
+ state.character.onboarded && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "her-btn link", onClick: onDone, children: "\u56DE\u5230\u7BA1\u7406\u9875" })
1226
+ ] }),
1227
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "her-steps", children: STEPS.map((name, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("button", { className: `her-step ${i === step ? "on" : i < step ? "done" : ""}`, onClick: () => setStep(i), children: [
1228
+ i + 1,
1229
+ ". ",
1230
+ name
1231
+ ] }, name)) }),
1232
+ step === 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-card", children: [
1233
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "\u5148\u770B\u770B\u51C6\u5907\u597D\u4E86\u6CA1\u6709" }),
1234
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: state.model === null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1235
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Dot, { tone: "bad" }),
1236
+ "dsh \u8FD8\u6CA1\u6709\u53EF\u7528\u7684\u6A21\u578B\u3002\u8BF7\u5148\u5728 dsh \u8BBE\u7F6E\u91CC\u914D\u597D\u4E00\u4E2A\u6A21\u578B\uFF08\u6BD4\u5982 DeepSeek\uFF09\uFF0C\u518D\u56DE\u6765\u3002"
1237
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1238
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Dot, { tone: "ok" }),
1239
+ "\u5927\u8111\u7528\u7684\u6A21\u578B\uFF1A",
1240
+ state.model.provider,
1241
+ " / ",
1242
+ state.model.model
1243
+ ] }) }),
1244
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
1245
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Dot, { tone: toneOf(state.voice.speaking.status) }),
1246
+ "\u5979\u7684\u58F0\u97F3\uFF1A",
1247
+ speakingText(state.voice.speaking.status, state.voice.speaking.service)
1248
+ ] }),
1249
+ (state.voice.speaking.status === "no-key" || state.voice.speaking.status === "no-quota") && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(KeyHelp, { state }),
1250
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
1251
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Dot, { tone: toneOf(state.voice.status) }),
1252
+ "\u542C\u4F60\u8BF4\u8BDD\uFF1A",
1253
+ listeningText(state.voice.status)
1254
+ ] }),
1255
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
1256
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Dot, { tone: "ok" }),
1257
+ "\u7CFB\u7EDF\uFF1A",
1258
+ platformText(state.platform)
1259
+ ] }),
1260
+ nav(state.model !== null, state.model === null ? "\u6CA1\u6709\u6A21\u578B\u5979\u6CA1\u6CD5\u8BF4\u8BDD" : void 0)
1261
+ ] }),
1262
+ step === 1 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-card", children: [
1263
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "\u5979\u7684\u8EAB\u4F53" }),
1264
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "her-muted", children: '\u5979\u7684\u6837\u5B50\u548C\u58F0\u97F3\u5728\u4E00\u4E2A\u5355\u72EC\u7684\u684C\u9762\u7A0B\u5E8F\u91CC\uFF08"\u8EAB\u4F53"\uFF09\uFF0C\u8FD9\u91CC\u7684 dsh \u662F\u5979\u7684\u5927\u8111\u3002\u4E24\u8FB9\u8FDE\u4E0A\u5979\u624D\u80FD\u51FA\u73B0\u5728\u684C\u9762\u4E0A\u3002' }),
1265
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(BodyStatus, { state, apply: apply2 }),
1266
+ nav(body.connected, body.connected ? void 0 : "\u4E5F\u53EF\u4EE5\u5148\u8DF3\u8FC7\uFF0C\u4E4B\u540E\u5728\u7BA1\u7406\u9875\u518D\u8FDE"),
1267
+ !body.connected && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "her-row", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "her-btn link", onClick: next, children: "\u5148\u8DF3\u8FC7" }) })
1268
+ ] }),
1269
+ step === 2 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-card", children: [
1270
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "\u9009\u4E00\u4E2A\u5916\u5F62" }),
1271
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "her-muted", children: "\u5916\u5F62\u5305\u662F\u4E00\u7EC4\u77ED\u89C6\u9891\uFF1A\u5F85\u673A\u3001\u8BF4\u8BDD\u3001\u51E0\u4E2A\u52A8\u4F5C\u3002\u70B9\u4E00\u4E0B\u5C31\u6362\u4E0A\uFF1B\u4E5F\u53EF\u4EE5\u5BFC\u5165\u4F60\u81EA\u5DF1\u751F\u6210\u7684\u7D20\u6750\u3002" }),
1272
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PackPicker, { state, apply: apply2 }),
1273
+ nav(true)
1274
+ ] }),
1275
+ step === 3 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-card", children: [
1276
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "\u5979\u662F\u8C01" }),
1277
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PersonaEditor, { state, apply: apply2, onSaved: next, saveLabel: "\u4FDD\u5B58\uFF0C\u4E0B\u4E00\u6B65" }),
1278
+ nav(true)
1279
+ ] }),
1280
+ step === 4 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-card", children: [
1281
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "\u5979\u7684\u58F0\u97F3" }),
1282
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(VoicePicker, { state, apply: apply2, onSaved: next, saveLabel: "\u7528\u8FD9\u4E2A\u58F0\u97F3\uFF0C\u4E0B\u4E00\u6B65" }),
1283
+ nav(true)
1284
+ ] }),
1285
+ step === 5 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-card", children: [
1286
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "\u8BD5\u8BD5\u548C\u5979\u8BF4\u8BDD" }),
1287
+ body.connected ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MicCheck, { state }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "her-muted", children: "\u8EAB\u4F53\u8FDE\u4E0A\u4E4B\u540E\u624D\u80FD\u7528\u9EA6\u514B\u98CE\u3002" }),
1288
+ nav(true)
1289
+ ] }),
1290
+ step === 6 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-card", children: [
1291
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "\u628A\u5979\u653E\u5230\u684C\u9762\u4E0A" }),
1292
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "her-muted", children: "\u968F\u65F6\u53EF\u4EE5\u5728\u7BA1\u7406\u9875\u6539\u3002" }),
1293
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ModePicker, { state, apply: apply2 }),
1294
+ !body.connected && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "her-muted", children: "\u8EAB\u4F53\u8FDE\u4E0A\u4E4B\u540E\u624D\u80FD\u5207\u6362\u3002" }),
1295
+ nav(true)
1296
+ ] })
1297
+ ] });
1298
+ }
1299
+ var TABS = [["overview", "\u6982\u51B5"], ["settings", "\u8BBE\u7F6E"], ["memory", "\u5979\u8BB0\u5F97\u7684\u4E8B"], ["workshop", "\u5F62\u8C61\u5DE5\u574A"]];
1300
+ function Manage({ state, apply: apply2, onWizard }) {
1301
+ const [tab, setTab] = (0, import_react3.useState)("overview");
1302
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1303
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-head", children: [
1304
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { children: state.character.name }),
1305
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "her-btn link", onClick: onWizard, children: "\u91CD\u65B0\u8D70\u4E00\u904D\u5411\u5BFC" })
1306
+ ] }),
1307
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "her-tabs", children: TABS.map(([id, label]) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: `her-tab ${tab === id ? "on" : ""}`, onClick: () => setTab(id), children: label }, id)) }),
1308
+ tab === "overview" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1309
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-card", children: [
1310
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "\u8EAB\u4F53" }),
1311
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(BodyStatus, { state, apply: apply2 })
1312
+ ] }),
1313
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-card", children: [
1314
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "\u5927\u8111" }),
1315
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: state.model === null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1316
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Dot, { tone: "bad" }),
1317
+ "\u6CA1\u6709\u53EF\u7528\u7684\u6A21\u578B"
1318
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1319
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Dot, { tone: "ok" }),
1320
+ state.model.provider,
1321
+ " / ",
1322
+ state.model.model,
1323
+ state.model.chosen ? "" : "\uFF08dsh \u9ED8\u8BA4\uFF09"
1324
+ ] }) }),
1325
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
1326
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Dot, { tone: toneOf(state.voice.speaking.status) }),
1327
+ "\u5979\u7684\u58F0\u97F3\uFF1A",
1328
+ speakingText(state.voice.speaking.status, state.voice.speaking.service),
1329
+ "\uFF08",
1330
+ voiceName(state.character.voice.id),
1331
+ "\uFF09"
1332
+ ] }),
1333
+ (state.voice.speaking.status === "no-key" || state.voice.speaking.status === "no-quota") && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(KeyHelp, { state }),
1334
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
1335
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Dot, { tone: toneOf(state.voice.status) }),
1336
+ "\u542C\u4F60\u8BF4\u8BDD\uFF1A",
1337
+ listeningText(state.voice.status)
1338
+ ] }),
1339
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "her-muted", children: [
1340
+ "\u8BB0\u5F97 ",
1341
+ state.memory.facts.length,
1342
+ " \u4EF6\u5173\u4E8E\u4F60\u7684\u4E8B\u3001",
1343
+ state.memory.episodes.length,
1344
+ " \u4E2A\u4E8B\u4EF6\uFF0C\u5199\u4E86 ",
1345
+ state.memory.diary.length,
1346
+ " \u5929\u65E5\u8BB0\u3002"
1347
+ ] }),
1348
+ state.heard !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "her-faint", children: [
1349
+ "\u6700\u8FD1\u542C\u5230\uFF1A\u300C",
1350
+ state.heard.text,
1351
+ "\u300D"
1352
+ ] })
1353
+ ] }),
1354
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "her-muted", children: '\u6539\u4EBA\u8BBE\u3001\u6362\u58F0\u97F3\u3001\u5916\u5F62\u3001\u6A21\u578B\uFF0C\u90FD\u5728"\u8BBE\u7F6E"\u91CC\uFF1B\u5979\u8BB0\u4F4F\u4E86\u4EC0\u4E48\uFF0C\u5728"\u5979\u8BB0\u5F97\u7684\u4E8B"\u91CC\u3002' })
1355
+ ] }),
1356
+ tab === "settings" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Settings, { state, apply: apply2 }),
1357
+ tab === "memory" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MemoryView, { state, apply: apply2 }),
1358
+ tab === "workshop" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Workshop, { state, apply: apply2 })
1359
+ ] });
1360
+ }
1361
+ var SECTIONS = [["persona", "\u4EBA\u8BBE"], ["voice", "\u58F0\u97F3"], ["look", "\u5916\u5F62"], ["model", "\u6A21\u578B"], ["place", "\u653E\u5728\u54EA\u91CC"]];
1362
+ function Settings({ state, apply: apply2 }) {
1363
+ const jump = (id) => document.getElementById(`her-set-${id}`)?.scrollIntoView({ behavior: "smooth", block: "start" });
1364
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1365
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "her-steps", children: SECTIONS.map(([id, label]) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "her-step", onClick: () => jump(id), children: label }, id)) }),
1366
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-card", id: "her-set-persona", children: [
1367
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "\u4EBA\u8BBE" }),
1368
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PersonaEditor, { state, apply: apply2 })
1369
+ ] }),
1370
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-card", id: "her-set-voice", children: [
1371
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "\u58F0\u97F3" }),
1372
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(VoicePicker, { state, apply: apply2, saveLabel: "\u7528\u8FD9\u4E2A\u58F0\u97F3" })
1373
+ ] }),
1374
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-card", id: "her-set-look", children: [
1375
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "\u5916\u5F62" }),
1376
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PackPicker, { state, apply: apply2 }),
1377
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ScenePicker, { state, apply: apply2 })
1378
+ ] }),
1379
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-card", id: "her-set-model", children: [
1380
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "\u6A21\u578B" }),
1381
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ModelPicker, { state, apply: apply2 })
1382
+ ] }),
1383
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "her-card", id: "her-set-place", children: [
1384
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "\u653E\u5728\u54EA\u91CC" }),
1385
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ModePicker, { state, apply: apply2 })
1386
+ ] })
1387
+ ] });
1388
+ }
1389
+ function toneOf(status) {
1390
+ if (status === "ready") return "ok";
1391
+ if (status === "off") return "off";
1392
+ if (status === "no-key" || status === "no-quota" || status === "failed") return "bad";
1393
+ return "warn";
1394
+ }
1395
+ function speakingText(status, service) {
1396
+ const name = service === "edge" ? "\u5FAE\u8F6F Edge" : "\u963F\u91CC\u4E91\u767E\u70BC";
1397
+ switch (status) {
1398
+ case "ready":
1399
+ return `\u5DF2\u5C31\u7EEA\uFF08${name}\uFF09`;
1400
+ case "checking":
1401
+ return `\u6B63\u5728\u8FDE\u63A5${name}`;
1402
+ case "installing":
1403
+ return "\u6B63\u5728\u51C6\u5907 Edge \u8BED\u97F3\u7EC4\u4EF6\uFF08\u7B2C\u4E00\u6B21\u7528\uFF0C\u4E00\u4E24\u5206\u949F\uFF09";
1404
+ case "no-key":
1405
+ return "\u8FD8\u6CA1\u6709\u767E\u70BC\u7684 API key\uFF0C\u73B0\u5728\u53EA\u7528\u6587\u5B57\u56DE\u7B54";
1406
+ case "no-quota":
1407
+ return "\u767E\u70BC\u7684\u989D\u5EA6\u7528\u5B8C\u4E86\uFF0C\u73B0\u5728\u53EA\u7528\u6587\u5B57\u56DE\u7B54";
1408
+ case "failed":
1409
+ return `${name}\u7684\u8BED\u97F3\u51FA\u9519\u4E86\uFF0C\u6682\u65F6\u53EA\u7528\u6587\u5B57\uFF08\u4F1A\u81EA\u52A8\u91CD\u8BD5\uFF09`;
1410
+ case "off":
1411
+ return "\u5DF2\u5173\u95ED\uFF0C\u53EA\u7528\u6587\u5B57";
1412
+ default:
1413
+ return status;
1414
+ }
1415
+ }
1416
+ function listeningText(status) {
1417
+ switch (status) {
1418
+ case "ready":
1419
+ return "\u5DF2\u5C31\u7EEA\uFF08\u672C\u5730\u8BC6\u522B\uFF09";
1420
+ case "downloading":
1421
+ return "\u6B63\u5728\u4E0B\u8F7D\u8BC6\u522B\u6A21\u578B\uFF08\u7EA6 170 MB\uFF0C\u53EA\u4E0B\u4E00\u6B21\uFF09";
1422
+ case "loading":
1423
+ return "\u6B63\u5728\u52A0\u8F7D";
1424
+ case "failed":
1425
+ return "\u51FA\u9519\u4E86\uFF0C\u6682\u65F6\u53EA\u80FD\u6253\u5B57";
1426
+ default:
1427
+ return status;
1428
+ }
1429
+ }
1430
+ function platformText(platform) {
1431
+ if (platform === "darwin") return "macOS";
1432
+ if (platform === "win32") return "Windows";
1433
+ return platform;
1434
+ }
1435
+
1436
+ // src/client/styles.ts
1437
+ var v = (name, fallback) => `var(--dsw-alias-${name}, ${fallback})`;
1438
+ var TEXT = v("label-primary", "CanvasText");
1439
+ var MUTED = v("label-secondary", "GrayText");
1440
+ var FAINT = v("label-tertiary", "GrayText");
1441
+ var LINE = v("border-l2", "rgba(127,127,127,.22)");
1442
+ var LAYER1 = v("bg-layer-1", "rgba(127,127,127,.06)");
1443
+ var LAYER2 = v("bg-layer-2", "rgba(127,127,127,.10)");
1444
+ var HOVER = v("interactive-bg-hover", "rgba(127,127,127,.12)");
1445
+ var DANGER = v("state-error-primary", "#d14343");
1446
+ var WARN = v("state-warn-primary", "#b7791f");
1447
+ var OK = v("state-success-primary", "#2f855a");
1448
+ var ACCENT = v("button-primary-fill", "#4d6bfe");
1449
+ var ON_ACCENT = v("label-primary-foreground", "#fff");
1450
+ var STYLES = `
1451
+ .her-page{box-sizing:border-box;height:100%;overflow:auto;padding:20px 24px 40px;color:${TEXT};font-size:13px;line-height:1.55}
1452
+ .her-page *{box-sizing:border-box}
1453
+ .her-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:14px}
1454
+ .her-head h1{font-size:18px;font-weight:600;margin:0}
1455
+ .her-muted{color:${MUTED}}.her-faint{color:${FAINT}}
1456
+ .her-ok{color:${OK}}.her-warn{color:${WARN}}.her-danger{color:${DANGER}}
1457
+ .her-card{background:${LAYER1};border-radius:12px;padding:14px 16px;margin-bottom:12px;max-width:760px}
1458
+ .her-card h2{font-size:15px;font-weight:600;margin:0 0 6px}
1459
+ .her-card p{margin:4px 0}
1460
+ .her-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:8px 0}
1461
+ .her-fold{display:flex;align-items:baseline;gap:8px;width:100%;border:none;background:none;padding:0;color:${TEXT};font:inherit;cursor:pointer;text-align:left}
1462
+ .her-fold h2{margin:0}
1463
+ .her-fold-arrow{color:${MUTED};width:14px;font-size:15px;line-height:1}
1464
+ .her-fold-sum{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px}
1465
+ .her-examples{margin-top:12px}
1466
+ .her-example-row{display:flex;gap:10px;flex-wrap:wrap}
1467
+ .her-example{margin:0;width:150px}
1468
+ .her-example img,.her-example video,.her-example-empty{width:150px;height:110px;object-fit:cover;border-radius:8px;background:${LAYER2};display:block}
1469
+ .her-example-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;border:1px dashed ${LINE};color:${FAINT};font-size:11px;text-align:center;padding:6px}
1470
+ .her-example-empty code{font-size:10px;word-break:break-all}
1471
+ .her-example figcaption{font-size:11px;color:${MUTED};margin-top:3px}
1472
+ .her-scenes{margin-top:14px;border-top:1px solid ${LINE};padding-top:10px}
1473
+ .her-scene{margin:4px 0}.her-scene label{min-width:7em}.her-scene .her-muted{flex:1}
1474
+ .her-btn{border:1px solid ${LINE};background:${LAYER2};color:${TEXT};border-radius:8px;padding:6px 12px;font:inherit;cursor:pointer}
1475
+ .her-btn:hover{background:${HOVER}}
1476
+ .her-btn:disabled{opacity:.5;cursor:default}
1477
+ .her-btn.primary{background:${ACCENT};border-color:${ACCENT};color:${ON_ACCENT}}
1478
+ .her-btn.small{padding:2px 8px;font-size:12px}
1479
+ .her-btn.link{border:none;background:none;color:${ACCENT};padding:2px 4px}
1480
+ .her-input,.her-textarea,.her-select{width:100%;border:1px solid ${LINE};background:${LAYER2};color:${TEXT};border-radius:8px;padding:7px 10px;font:inherit}
1481
+ .her-textarea{min-height:120px;resize:vertical}
1482
+ .her-label{display:block;font-size:12px;color:${MUTED};margin:10px 0 4px}
1483
+ .her-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px;margin:8px 0}
1484
+ .her-choice{border:1px solid ${LINE};background:${LAYER2};border-radius:10px;padding:10px;cursor:pointer;text-align:left;color:${TEXT};font:inherit}
1485
+ .her-choice:hover{background:${HOVER}}
1486
+ .her-choice.on{border-color:${ACCENT};box-shadow:0 0 0 1px ${ACCENT}}
1487
+ .her-choice small{display:block;color:${MUTED};margin-top:2px}
1488
+ .her-steps{display:flex;gap:6px;flex-wrap:wrap;margin:0 0 14px;max-width:760px}
1489
+ .her-step{font-size:12px;padding:3px 10px;border-radius:999px;background:${LAYER1};color:${MUTED};border:none;cursor:pointer;font-family:inherit}
1490
+ .her-step.on{background:${ACCENT};color:${ON_ACCENT}}
1491
+ .her-step.done{color:${OK}}
1492
+ .her-tabs{display:flex;gap:4px;margin-bottom:12px;flex-wrap:wrap}
1493
+ .her-tab{border:none;background:none;color:${MUTED};padding:6px 10px;border-radius:8px;cursor:pointer;font:inherit}
1494
+ .her-tab.on{background:${LAYER2};color:${TEXT};font-weight:600}
1495
+ .her-dot{display:inline-block;width:8px;height:8px;border-radius:50%;margin-right:6px;background:${FAINT};vertical-align:0}
1496
+ .her-dot.ok{background:${OK}}.her-dot.warn{background:${WARN}}.her-dot.bad{background:${DANGER}}
1497
+ .her-list{list-style:none;margin:6px 0;padding:0}
1498
+ .her-list li{display:flex;gap:8px;align-items:baseline;padding:6px 0;border-bottom:1px solid ${LINE}}
1499
+ .her-list li:last-child{border-bottom:none}
1500
+ .her-list li .grow{flex:1;min-width:0;word-break:break-word}
1501
+ .her-tag{font-size:11px;padding:0 6px;border-radius:999px;background:${LAYER2};color:${MUTED};white-space:nowrap}
1502
+ .her-tag.warn{color:${WARN}}.her-tag.bad{color:${DANGER}}.her-tag.ok{color:${OK}}
1503
+ .her-chat{background:${LAYER2};border-radius:10px;padding:8px 10px;margin:8px 0;max-height:220px;overflow:auto}
1504
+ .her-chat div{margin:3px 0}
1505
+ .her-chat .you{color:${MUTED}}
1506
+ .her-report{margin:6px 0;padding-left:0;list-style:none}
1507
+ .her-report li{margin:2px 0}
1508
+ .her-progress{height:6px;background:${LAYER2};border-radius:3px;overflow:hidden;margin:6px 0}
1509
+ .her-progress div{height:100%;background:${ACCENT};transition:width .3s}
1510
+ .her-error{color:${DANGER};margin:6px 0}
1511
+ `;
1512
+
1513
+ // src/client/index.tsx
1514
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1515
+ var PACKAGE_NAME = "dsh-her";
1516
+ var inject = ["slots", "locale"];
1517
+ var PANEL_ID = "dsh-her";
1518
+ var NS = "dsh-her";
1519
+ function HerIcon({ size }) {
1520
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10z" }) });
1521
+ }
1522
+ function apply(ctx) {
1523
+ ctx.effect(() => ctx.locale.register(NS, { zh: { panel: "\u5979" }, en: { panel: "Her" } }), "dsh-her: dictionaries");
1524
+ ctx.effect(() => {
1525
+ const style = document.createElement("style");
1526
+ style.dataset.dshPlugin = PACKAGE_NAME;
1527
+ style.textContent = STYLES;
1528
+ document.head.append(style);
1529
+ return () => {
1530
+ style.remove();
1531
+ };
1532
+ }, "dsh-her: styles");
1533
+ const t = ctx.locale.bind(NS);
1534
+ ctx.slots.inject("main", () => ctx.slots.register({ name: "main", key: PANEL_ID, locale: NS }, HerPage));
1535
+ ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
1536
+ name: "sidebar.panellist",
1537
+ id: PANEL_ID,
1538
+ order: 31,
1539
+ locale: NS,
1540
+ label: () => t("panel")
1541
+ }, HerIcon));
1542
+ }
1543
+
1544
+ return module.exports;
1545
+ }
1546
+ });