@eslaykey/dsh-breeze-tts 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.js ADDED
@@ -0,0 +1,1466 @@
1
+ window.__ModuleLoader__.load({
2
+ id: '@eslaykey/dsh-breeze-tts',
3
+ factory(require) {
4
+ const React = require('react')
5
+ const h = React.createElement
6
+ const NS = 'dsh-breeze-tts'
7
+ const ENDPOINT = '/breeze-tts'
8
+
9
+ const DICT = {
10
+ zh: {
11
+ meta: { title: 'Breeze 语音朗读', description: '用 Breeze Blue 把文字念出来。' },
12
+ section: { title: '语音朗读', subtitle: 'Breeze Blue · 文字转语音' },
13
+ err: {
14
+ auth: 'API key 无效或已失效,请重新填写',
15
+ rate: '请求太频繁,稍等几秒再试',
16
+ credits: '积分余额不足,请先充值或调低每日上限',
17
+ tooShort: '音色描述和试听台词至少要 3 个字',
18
+ daily: '已到今日字数上限,可在设置中调高',
19
+ },
20
+
21
+ label: {
22
+ voice: '音色', mood: '情绪', previewText: '试听文案', dailyLimit: '每日字数上限',
23
+ balance: '剩余额度', todayUsage: '今日已用', preview: '试听', save: '保存设置',
24
+ saving: '保存中…', synthesizing: '合成中…', refresh: '刷新', designed: '自捏',
25
+ readAloud: '朗读这条', replay: '重播上一条', replayEmpty: '还没有可重播的音频', saved: '已保存 ✓',
26
+ },
27
+ status: { ready: '就绪', missingKey: '缺少 API key', credits: 'credits', chars: '字' },
28
+ hint: { key: '把 Breeze API key 写进 ~/.dsh/breeze.json 的 apiKey 字段。', limit: '超过上限会拒绝合成,避免意外烧额度。' },
29
+ extra: {
30
+ autoSpeak: '自动朗读',
31
+ autoSpeakHint: '对字数不超过设定值的新回复自动朗读,默认关闭',
32
+ renameBlocked: '内置音色和公开音色不能重命名',
33
+ voiceManageHint: '只有你自己生成的音色可以在这里改名或删除',
34
+ cloneNotice: '本插件不提供音色克隆。需要克隆自己的声音,请到 Breeze 官网的音色库创建,克隆好的音色会自动出现在上面的列表里。',
35
+ renameVoice: '重命名',
36
+ renamePlaceholder: '新的音色名称',
37
+ saveName: '保存名称',
38
+ voiceRenamed: '已重命名 ✓',
39
+ voiceLoadedTag: '已加载',
40
+ voiceNamePlaceholder: '新音色名称',
41
+ addedTag: '已添加',
42
+ voiceAdded: '已加入音色库',
43
+ voiceRemoved: '已从音色库移除',
44
+ emotionMode: '语气模式',
45
+ emotionSaved: '语气模式已切换',
46
+ emotionFixed: '固定',
47
+ emotionInfer: '智能推断',
48
+ emotionMarker: '模型标注',
49
+ emotionFixedHint: '全程使用上面选中的语气朗读,不做任何切换',
50
+ emotionInferHint: '按标点自动切换:问号→好奇、感叹号→兴奋、省略号→失落;分段变多会拖慢生成',
51
+ emotionMarkerHint: '由模型在回复里插入标记,指定某一段的语气;分段变多会拖慢生成',
52
+ emotionMarkerNote: '模型标注为实验性功能:由模型自行标注语气,可能出现标记显形或判断偏差。',
53
+ publicVoices: '公开音色',
54
+ publicVoicesHint: '插件默认只显示你自建的音色,公共目录另外浏览',
55
+ openLibrary: '更多公开音色',
56
+ collapseLibrary: '收起音色库',
57
+ libraryTitle: '官方音色库',
58
+ librarySubtitle: '默认以自然语气试听',
59
+ librarySearch: '按名称或描述搜索',
60
+ libraryEmpty: '没有匹配的音色',
61
+ loadVoice: '加载',
62
+ voiceLoaded: '已切换音色',
63
+ newTone: '新建语气',
64
+ editTone: '编辑',
65
+ deleteTone: '删除',
66
+ saveTone: '保存语气',
67
+ cancel: '取消',
68
+ customTag: '自定义',
69
+ deleteVoice: '删除音色',
70
+ toneNamePlaceholder: '语气名称,例如:哄睡',
71
+ tonePlaceholder: '描述这个语气怎么说话,例如:语速很慢,声音放轻,句尾拖长,像在哄人睡觉。',
72
+ toneIncomplete: '名称和描述都要填',
73
+ toneSaved: '语气已保存 ✓',
74
+ toneDeleted: '语气已删除',
75
+ voiceDeleted: '音色已删除',
76
+ customMood: '自定义语气',
77
+ customMoodHint: '填写后优先于上面的预设;留空则使用选中语气',
78
+ customMoodPlaceholder: '例如:像在跟小孩子说话,句尾轻轻上扬',
79
+ backgroundPlay: '后台播放',
80
+ backgroundPlayHint: '关闭时只在 DSH 位于前台时朗读;开启后窗口切到后台也会继续播报',
81
+ autoMax: '自动朗读字数',
82
+ autoMaxWarning: '每条回复都会被完整合成;当前字数较多,生成会更慢、积分消耗也更多,建议先用较小值试几条。',
83
+ autoMaxHint: '可输入 0–99999,滑条范围 0–1000',
84
+ refreshed: '已刷新',
85
+ refreshFailed: '刷新失败',
86
+ autoMaxHard: '朗读超长文本会明显拖慢生成速度,积分消耗也难以预估,建议同时设好每日字数上限。',
87
+
88
+ autoOn: '自动朗读开',
89
+ designTitle: '音色设计',
90
+ designPlaceholder: '描述你想要的音色本身,不要写台词。建议覆盖年龄、性别、音色质地、语速和情绪基调。例如二十多岁的女性,声音清亮略带鼻音,说话轻快,句尾微微上扬,整体亲切有活力。',
91
+ designSample: '试听台词(可选)',
92
+ designCost: '每轮约 3–8 credits',
93
+ designHint: '生成按试听台词长度计费一次;保存后占用一个音色槽,免费档只有 5 个。',
94
+ generate: '生成',
95
+ generating: '生成中…',
96
+ candidate: '候选',
97
+ saveVoice: '保存为音色',
98
+ voiceSaved: '已保存为新音色',
99
+ newVoice: '我的音色',
100
+ designEmpty: '没有拿到候选,稍后再试',
101
+ },
102
+ },
103
+ en: {
104
+ meta: { title: 'Breeze Voice', description: 'Read text aloud with Breeze Blue.' },
105
+ section: { title: 'Voice', subtitle: 'Breeze Blue · text to speech' },
106
+ err: {
107
+ auth: 'The API key is invalid or expired. Please enter it again.',
108
+ rate: 'Too many requests. Wait a few seconds and retry.',
109
+ credits: 'Not enough credits. Top up or lower the daily limit.',
110
+ tooShort: 'Voice description and preview line need at least 3 characters.',
111
+ daily: 'Daily character limit reached. Raise it in settings.',
112
+ },
113
+
114
+ label: {
115
+ voice: 'Voice', mood: 'Mood', previewText: 'Preview line', dailyLimit: 'Daily character limit',
116
+ balance: 'Credits left', todayUsage: 'Used today', preview: 'Preview', save: 'Save settings',
117
+ saving: 'Saving…', synthesizing: 'Synthesizing…', refresh: 'Refresh', designed: 'Designed',
118
+ readAloud: 'Read aloud', replay: 'Replay', replayEmpty: 'Nothing to replay yet', saved: 'Saved ✓',
119
+ },
120
+ status: { ready: 'Ready', missingKey: 'Missing API key', credits: 'credits', chars: 'chars' },
121
+ hint: { key: 'Write the Breeze API key into apiKey of ~/.dsh/breeze.json.', limit: 'Synthesis is refused past the limit so credits cannot run away.' },
122
+ extra: {
123
+ autoSpeak: 'Auto speak',
124
+ autoSpeakHint: 'Automatically read new replies within the configured character limit. Off by default.',
125
+ renameBlocked: 'Built-in and public voices cannot be renamed',
126
+ voiceManageHint: 'Only voices you created can be renamed or deleted here',
127
+ cloneNotice: 'Voice cloning is not part of this plugin. Create a clone on the Breeze website and it will show up in the list above.',
128
+ renameVoice: 'Rename',
129
+ renamePlaceholder: 'New voice name',
130
+ saveName: 'Save name',
131
+ voiceRenamed: 'Renamed',
132
+ voiceLoadedTag: 'Loaded',
133
+ voiceNamePlaceholder: 'New voice name',
134
+ addedTag: 'added',
135
+ voiceAdded: 'Added to your voices',
136
+ voiceRemoved: 'Removed from your voices',
137
+ emotionMode: 'Tone mode',
138
+ emotionSaved: 'Tone mode switched',
139
+ emotionFixed: 'Fixed',
140
+ emotionInfer: 'Infer',
141
+ emotionMarker: 'Model tagged',
142
+ emotionFixedHint: 'Speak everything with the tone selected above, no switching',
143
+ emotionInferHint: 'Switch by punctuation: question → curious, exclamation → excited, ellipsis → sad; more segments means slower synthesis',
144
+ emotionMarkerHint: 'The model inserts markers to pick the tone per segment; more segments means slower synthesis',
145
+ emotionMarkerNote: 'Model tagging is experimental: the model tags its own tone. Markers may appear in the text or be misjudged.',
146
+ publicVoices: 'Public voices',
147
+ publicVoicesHint: 'Only your own voices are listed by default; the public catalog is browsed separately',
148
+ openLibrary: 'Browse public voices',
149
+ collapseLibrary: 'Collapse library',
150
+ libraryTitle: 'Public voice library',
151
+ librarySubtitle: 'Previews use the natural tone',
152
+ librarySearch: 'Search by name or description',
153
+ libraryEmpty: 'No matching voices',
154
+ loadVoice: 'Load',
155
+ voiceLoaded: 'Voice switched',
156
+ newTone: 'New tone',
157
+ editTone: 'Edit',
158
+ deleteTone: 'Delete',
159
+ saveTone: 'Save tone',
160
+ cancel: 'Cancel',
161
+ customTag: 'custom',
162
+ deleteVoice: 'Delete voice',
163
+ toneNamePlaceholder: 'Tone name, e.g. bedtime',
164
+ tonePlaceholder: 'Describe how it should sound, e.g. very slow and soft, with a trailing lilt.',
165
+ toneIncomplete: 'Both name and description are required',
166
+ toneSaved: 'Tone saved',
167
+ toneDeleted: 'Tone deleted',
168
+ voiceDeleted: 'Voice deleted',
169
+ customMood: 'Custom tone',
170
+ customMoodHint: 'Overrides the preset above when filled; leave empty to use the selected tone',
171
+ customMoodPlaceholder: 'e.g. speak to a small child, with a light upward lilt',
172
+ backgroundPlay: 'Play in background',
173
+ backgroundPlayHint: 'Off: only speak while DSH is in the foreground. On: keep speaking when the window is in the background.',
174
+ autoMax: 'Auto speak up to',
175
+ autoMaxWarning: 'Every reply is synthesized in full; with this many characters synthesis gets slower and costs more credits. Try a smaller value first.',
176
+ autoMaxHint: '0-99999 allowed, slider covers 0-1000',
177
+ refreshed: 'Refreshed',
178
+ refreshFailed: 'Refresh failed',
179
+ autoMaxHard: 'Very long replies slow synthesis down and make credit use unpredictable. Set a daily limit alongside it.',
180
+
181
+ autoOn: 'auto on',
182
+ designTitle: 'Voice design',
183
+ designPlaceholder: 'Describe the voice itself, not a script: age and gender, texture, pace, emotional baseline. Example: a woman in her twenties, bright voice with a light nasal tone, quick and upbeat.',
184
+ designSample: 'Preview line (optional)',
185
+ designCost: 'about 3-8 credits per run',
186
+ designHint: 'Generation is billed once by the preview line length; saving a voice uses one voice slot (the free plan has 5).',
187
+ generate: 'Generate',
188
+ generating: 'Generating…',
189
+ candidate: 'Candidate',
190
+ saveVoice: 'Save voice',
191
+ voiceSaved: 'Saved as a new voice',
192
+ newVoice: 'My voice',
193
+ designEmpty: 'No candidates came back, try again later',
194
+ },
195
+ },
196
+ }
197
+
198
+ function lookup(dict, key) {
199
+ let current = dict
200
+ for (const part of key.split('.')) {
201
+ if (current && typeof current === 'object' && part in current) current = current[part]
202
+ else return key
203
+ }
204
+ return typeof current === 'string' ? current : key
205
+ }
206
+
207
+ function flatten(dict, prefix, out) {
208
+ const target = out || {}
209
+ for (const key of Object.keys(dict)) {
210
+ const value = dict[key]
211
+ const next = prefix ? prefix + '.' + key : key
212
+ if (value && typeof value === 'object') flatten(value, next, target)
213
+ else target[next] = value
214
+ }
215
+ return target
216
+ }
217
+
218
+ const FLAT = { zh: flatten(DICT.zh), en: flatten(DICT.en) }
219
+
220
+ const COLOR = {
221
+ primary: 'var(--dsw-alias-label-primary)',
222
+ secondary: 'var(--dsw-alias-label-secondary)',
223
+ border: 'var(--dsw-alias-border-l1)',
224
+ borderStrong: 'var(--dsw-alias-border-l2)',
225
+ surface: 'var(--dsw-alias-bg-layer-1)',
226
+ nested: 'var(--dsw-alias-bg-layer-2)',
227
+ brand: 'var(--dsw-alias-brand-primary)',
228
+ error: 'var(--dsw-alias-state-error-primary)',
229
+ success: 'var(--dsw-alias-state-success-primary)',
230
+ idle: 'var(--dsw-alias-state-idle-primary)',
231
+ }
232
+
233
+ async function api(route, options) {
234
+ const response = await fetch(ENDPOINT + route, options)
235
+ const type = response.headers.get('content-type') || ''
236
+ if (type.includes('application/json')) {
237
+ const data = await response.json()
238
+ if (!response.ok) {
239
+ const failure = new Error(data.error || `HTTP ${response.status}`)
240
+ failure.code = data.code || ''
241
+ failure.status = data.status || response.status
242
+ throw failure
243
+ }
244
+ return data
245
+ }
246
+ if (!response.ok) throw new Error(`HTTP ${response.status}`)
247
+ return response.blob()
248
+ }
249
+
250
+ function humanError(t, error) {
251
+ const message = error instanceof Error ? error.message : String(error)
252
+ const code = error && error.code ? String(error.code) : ''
253
+ const status = error && error.status ? Number(error.status) : 0
254
+ if (status === 401 || code === 'AUTH_REQUIRED') return t('err.auth')
255
+ if (status === 429) return t('err.rate')
256
+ if (status === 402 || /credit/i.test(code) || /insufficient/i.test(message)) return t('err.credits')
257
+ if (/at least 3 characters/i.test(message)) return t('err.tooShort')
258
+ if (/daily limit/i.test(message)) return t('err.daily')
259
+ return message
260
+ }
261
+
262
+ let currentAudio = null
263
+
264
+ function playUrl(url) {
265
+ return new Promise((resolve, reject) => {
266
+ const audio = new Audio(url)
267
+ currentAudio = audio
268
+ audio.onerror = () => reject(new Error('audio element failed'))
269
+ const started = audio.play()
270
+ if (started && typeof started.then === 'function') started.then(() => resolve(true), reject)
271
+ else resolve(true)
272
+ })
273
+ }
274
+
275
+ async function speakRemotely(payload, options) {
276
+ const data = await api('/synth', {
277
+ method: 'POST',
278
+ headers: { 'content-type': 'application/json' },
279
+ body: JSON.stringify(payload),
280
+ })
281
+ const playOnHost = async () => {
282
+ await api('/play-file', {
283
+ method: 'POST',
284
+ headers: { 'content-type': 'application/json' },
285
+ body: JSON.stringify({ url: data.url }),
286
+ })
287
+ }
288
+ if (options && options.host) {
289
+ await playOnHost()
290
+ return data
291
+ }
292
+ try {
293
+ await playUrl(data.url)
294
+ } catch (error) {
295
+ console.error('[breeze-tts] html audio failed, using host playback', error)
296
+ await playOnHost()
297
+ }
298
+ return data
299
+ }
300
+
301
+ function PlayGlyph(size) {
302
+ const s = size || 11
303
+ return h("svg", {
304
+ width: s, height: s, viewBox: "0 0 12 12", "aria-hidden": true, style: { display: "block", shapeRendering: "geometricPrecision" },
305
+ }, h("path", { d: "M2.4 1.2 10.6 6 2.4 10.8z", fill: "currentColor" }))
306
+ }
307
+
308
+ function PlayTriangle(size) {
309
+ const s = size || 12
310
+ return h('svg', {
311
+ width: s, height: s, viewBox: '0 0 12 12', 'aria-hidden': true, style: { display: 'block', shapeRendering: 'geometricPrecision' },
312
+ }, h('path', { d: 'M3.4 2.1 9.6 6 3.4 9.9z', fill: 'currentColor' }))
313
+ }
314
+
315
+ async function playBlob(blob) {
316
+ const Ctx = window.AudioContext || window.webkitAudioContext
317
+ if (!Ctx) throw new Error('AudioContext unavailable')
318
+ const context = new Ctx()
319
+ try {
320
+ if (context.state === 'suspended') await context.resume()
321
+ } catch {
322
+ /* resume best effort */
323
+ }
324
+ const buffer = await context.decodeAudioData(await blob.arrayBuffer())
325
+ const source = context.createBufferSource()
326
+ source.buffer = buffer
327
+ source.connect(context.destination)
328
+ await new Promise((resolve, reject) => {
329
+ source.onended = () => {
330
+ context.close().catch(() => {})
331
+ resolve(true)
332
+ }
333
+ try {
334
+ source.start()
335
+ } catch (error) {
336
+ reject(error)
337
+ }
338
+ })
339
+ return true
340
+ }
341
+
342
+ function SpeakerIcon(size) {
343
+ const s = size || 14
344
+ return h('svg', {
345
+ width: s, height: s, viewBox: '0 0 16 16', fill: 'none',
346
+ stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round',
347
+ strokeLinejoin: 'round', 'aria-hidden': true, style: { display: 'block', shapeRendering: 'geometricPrecision' },
348
+ },
349
+ h('path', { d: 'M8 2.5 4.5 5.5H2v5h2.5L8 13.5z' }),
350
+ h('path', { d: 'M11 5.5a3.5 3.5 0 0 1 0 5' }),
351
+ h('path', { d: 'M13 3.5a6 6 0 0 1 0 9' }))
352
+ }
353
+
354
+ function Spinner(size) {
355
+ const s = size || 14
356
+ return h("svg", {
357
+ width: s, height: s, viewBox: "0 0 16 16", "aria-hidden": true, style: { display: "block", shapeRendering: "geometricPrecision" },
358
+ },
359
+ h("circle", {
360
+ cx: 8, cy: 8, r: 6, fill: "none", stroke: "currentColor",
361
+ strokeWidth: 1.7, strokeLinecap: "round", strokeDasharray: "9 29",
362
+ }, h("animateTransform", {
363
+ attributeName: "transform", type: "rotate", from: "0 8 8", to: "360 8 8",
364
+ dur: "0.9s", repeatCount: "indefinite",
365
+ })))
366
+ }
367
+
368
+ function StyleSheet() {
369
+ return h('style', null,
370
+ '@keyframes dsh-breeze-spin{to{transform:rotate(360deg)}}',
371
+ '.dsh-breeze-row{display:flex;align-items:center;gap:12px;padding:10px 0;border-top:1px solid ' + COLOR.border + '}',
372
+ '.dsh-breeze-row:first-of-type{border-top:0}',
373
+ '.dsh-breeze-key{flex:0 0 132px;font-size:13px;color:' + COLOR.secondary + '}',
374
+ '.dsh-breeze-value{flex:1;min-width:0;display:flex;align-items:center;gap:8px;flex-wrap:wrap}',
375
+ '.dsh-breeze-control{font:inherit;font-size:13px;height:30px;padding:0 10px;border-radius:8px;border:1px solid ' + COLOR.borderStrong + ';background:' + COLOR.nested + ';color:' + COLOR.primary + ';min-width:0}',
376
+ '.dsh-breeze-control:focus-visible{outline:2px solid ' + COLOR.brand + ';outline-offset:1px}',
377
+ '.dsh-breeze-chip{font:inherit;font-size:12px;height:26px;padding:0 10px;border-radius:999px;border:0;background:color-mix(in srgb,' + COLOR.primary + ' 9%,transparent);color:' + COLOR.secondary + ';cursor:pointer}',
378
+ '.dsh-breeze-chip:hover{background:color-mix(in srgb,' + COLOR.primary + ' 16%,transparent)}',
379
+ '.dsh-breeze-chip[data-on="true"]{color:' + COLOR.brand + ';background:color-mix(in srgb,' + COLOR.brand + ' 16%,' + COLOR.nested + ')}',
380
+ '.dsh-breeze-btn{display:inline-flex;align-items:center;gap:6px;font:inherit;font-size:13px;height:30px;padding:0 12px;border-radius:8px;cursor:pointer;border:0;background:color-mix(in srgb,' + COLOR.primary + ' 9%,transparent);color:' + COLOR.primary + ';background-clip:padding-box}',
381
+ '.dsh-breeze-btn:hover{background:color-mix(in srgb,' + COLOR.primary + ' 16%,transparent)}',
382
+ '.dsh-breeze-btn:active{background:color-mix(in srgb,' + COLOR.primary + ' 22%,transparent)}',
383
+ '.dsh-breeze-btn[data-primary="true"]{background:' + COLOR.brand + ';border-color:' + COLOR.brand + ';color:#fff}',
384
+ '.dsh-breeze-btn:disabled{opacity:.55;cursor:default}',
385
+ '.dsh-breeze-play{display:inline-flex;align-items:center;gap:9px;font:inherit;font-size:13px;font-weight:500;height:34px;padding:0 18px 0 15px;border-radius:10px;cursor:pointer;border:0;background:' + COLOR.primary + ';color:' + COLOR.surface + ';background-clip:padding-box}',
386
+ '.dsh-breeze-play:hover{background:color-mix(in srgb,' + COLOR.primary + ' 86%,' + COLOR.surface + ')}',
387
+ '.dsh-breeze-play:disabled{opacity:.6;cursor:default}',
388
+ '.dsh-breeze-switch{position:relative;width:40px;height:22px;border-radius:999px;border:0;background:color-mix(in srgb,' + COLOR.primary + ' 18%,transparent);cursor:pointer;padding:0;flex:0 0 auto}',
389
+ '.dsh-breeze-switch[data-on="true"]{background:' + COLOR.brand + '}',
390
+ '.dsh-breeze-knob{position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:999px;background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.25);transition:left .15s ease}',
391
+ '.dsh-breeze-switch[data-on="true"] .dsh-breeze-knob{left:20px}',
392
+ '.dsh-breeze-hint{margin:2px 0 0;font-size:12px;line-height:18px;color:' + COLOR.secondary + '}')
393
+ }
394
+
395
+ function useStatus() {
396
+ const [state, setState] = React.useState({ loading: true, data: null, error: null })
397
+ const load = React.useCallback(async (rethrow) => {
398
+ try {
399
+ const data = await api('/status')
400
+ setState({ loading: false, data, error: null })
401
+ return data
402
+ } catch (error) {
403
+ setState({ loading: false, data: null, error: error instanceof Error ? error.message : String(error) })
404
+ if (rethrow) throw error
405
+ return null
406
+ }
407
+ }, [])
408
+ React.useEffect(() => { load() }, [load])
409
+ return [state, load]
410
+ }
411
+
412
+ const SKIP_TYPES = ["reasoning", "thinking", "reasoning-delta", "thinking-delta", "redacted-thinking"]
413
+
414
+ function collectText(node, out, depth) {
415
+ if (!node || depth > 7) return out
416
+ if (typeof node !== "object") return out
417
+ if (Array.isArray(node)) {
418
+ for (const item of node) collectText(item, out, depth + 1)
419
+ return out
420
+ }
421
+ const type = typeof node.type === "string" ? node.type : (typeof node.kind === "string" ? node.kind : "")
422
+ if (SKIP_TYPES.includes(type)) return out
423
+ if (type === "text" && typeof node.text === "string" && node.text.trim()) {
424
+ out.push(node.text.trim())
425
+ return out
426
+ }
427
+ for (const key of ["content", "message", "blocks", "parts"]) {
428
+ if (node[key]) collectText(node[key], out, depth + 1)
429
+ }
430
+ return out
431
+ }
432
+
433
+ function collectAnyText(node, out, depth) {
434
+ if (!node || depth > 6 || typeof node !== "object") return out
435
+ if (Array.isArray(node)) {
436
+ for (const item of node) collectAnyText(item, out, depth + 1)
437
+ return out
438
+ }
439
+ const type = typeof node.type === "string" ? node.type : (typeof node.kind === "string" ? node.kind : "")
440
+ if (SKIP_TYPES.includes(type)) return out
441
+ if (typeof node.text === "string" && node.text.trim()) out.push(node.text.trim())
442
+ for (const key of ["content", "message", "blocks", "parts"]) {
443
+ if (node[key]) collectAnyText(node[key], out, depth + 1)
444
+ }
445
+ return out
446
+ }
447
+
448
+ function stripEmoji(text) {
449
+ let out = ''
450
+ for (const ch of String(text ?? '')) {
451
+ const cp = ch.codePointAt(0)
452
+ if (cp >= 0x1f000 && cp <= 0x1faff) continue
453
+ if (cp >= 0x2600 && cp <= 0x27bf) continue
454
+ if (cp === 0xfe0f || cp === 0x200d || cp === 0x2b50) continue
455
+ out += ch
456
+ }
457
+ return out
458
+ }
459
+
460
+ function cleanForSpeech(text) {
461
+ let value = String(text ?? '')
462
+ value = value.replace(/<!--[\s\S]*?-->/g, ' ')
463
+ value = value.replace(/!\[[^\]]*\]\([^)]*\)/g, ' ')
464
+ value = value.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1')
465
+ value = value.replace(/https?:\/\/[^\s)]+/g, ' ')
466
+ value = value.replace(/`{1,3}[^`]*`{1,3}/g, ' ')
467
+ value = value.replace(/[*_~#>|]+/g, ' ')
468
+ value = stripEmoji(value)
469
+ value = value.replace(/\s+([:,。!?;、)】」》])/g, '$1')
470
+ value = value.replace(/([(【「《])\s+/g, '$1')
471
+ value = value.replace(/\s+/g, ' ')
472
+ return value.trim()
473
+ }
474
+
475
+ function textBlocks(blocks, out) {
476
+ for (const block of Array.isArray(blocks) ? blocks : []) {
477
+ if (!block || typeof block !== "object") continue
478
+ const type = typeof block.type === "string" ? block.type : (typeof block.kind === "string" ? block.kind : "")
479
+ if (SKIP_TYPES.includes(type)) continue
480
+ if (type === "text" && typeof block.text === "string" && block.text.trim()) out.push(block.text.trim())
481
+ }
482
+ return out
483
+ }
484
+
485
+ function pickText(snapshot, messageId) {
486
+ const nodes = snapshot && Array.isArray(snapshot.nodes) ? snapshot.nodes : []
487
+ const target = nodes.find((node) => node && (
488
+ node.id === messageId
489
+ || node.messageId === messageId
490
+ || (node.message && node.message.id === messageId)
491
+ ))
492
+ if (!target) return ""
493
+ const message = target.message && typeof target.message === "object" ? target.message : target
494
+ const direct = textBlocks(message.content, [])
495
+ if (direct.length) return cleanForSpeech(direct.join(String.fromCharCode(10)))
496
+ const typed = collectText(message, [], 0).join(String.fromCharCode(10)).trim()
497
+ if (typed) return typed
498
+ return collectAnyText(message, [], 0).join(String.fromCharCode(10)).trim()
499
+ }
500
+
501
+ function SpeakButton(props) {
502
+ const [phase, setPhase] = React.useState('idle')
503
+ const [fail, setFail] = React.useState('')
504
+ const snapshot = typeof props.useChat === 'function'
505
+ ? props.useChat((state) => (state && typeof state === 'object' ? state.legacy : undefined))
506
+ : undefined
507
+ const text = React.useMemo(() => {
508
+ try {
509
+ return pickText(snapshot, props.messageId)
510
+ } catch {
511
+ return ''
512
+ }
513
+ }, [snapshot, props.messageId])
514
+ if (!text) return null
515
+ const speak = async () => {
516
+ setPhase('busy')
517
+ try {
518
+ const data = await speakRemotely({ text: text.slice(0, 600) })
519
+ setPhase('playing')
520
+ const wait = Math.max(1200, Number(data.chars || 0) * 260)
521
+ window.setTimeout(() => setPhase('idle'), wait)
522
+ } catch (error) {
523
+ setPhase('error')
524
+ setFail(error instanceof Error ? error.message : String(error))
525
+ console.error('[breeze-tts] play failed', error)
526
+ }
527
+ }
528
+ return h('button', {
529
+ type: 'button',
530
+ title: phase === 'error' && fail ? fail : props.t('label.readAloud'),
531
+ 'aria-label': props.t('label.readAloud'),
532
+ onClick: speak,
533
+ disabled: phase === 'busy',
534
+ style: {
535
+ display: 'inline-flex', alignItems: 'center', gap: 5, font: 'inherit', fontSize: 12,
536
+ height: 26, padding: '0 9px', borderRadius: 999, cursor: 'pointer',
537
+ border: 'none', background: 'color-mix(in srgb, ' + COLOR.primary + ' 9%, transparent)',
538
+ color: phase === 'error' ? COLOR.error : COLOR.secondary,
539
+ },
540
+ }, phase === 'busy' ? Spinner() : SpeakerIcon(13), h('span', null, props.t('label.readAloud')))
541
+ }
542
+
543
+ function AutoSpeakChip(props) {
544
+ const t = props.t
545
+ const [state] = useStatus()
546
+ const played = React.useRef(null)
547
+ if (!played.current) {
548
+ const key = 'breeze-tts:spoken:' + (props.sessionId || 'global')
549
+ let stored = null
550
+ try {
551
+ stored = JSON.parse(window.localStorage.getItem(key) || 'null')
552
+ } catch {
553
+ stored = null
554
+ }
555
+ played.current = {
556
+ key,
557
+ ids: new Set(Array.isArray(stored) ? stored : []),
558
+ texts: new Map(),
559
+ }
560
+ }
561
+ const markSpoken = (id, text) => {
562
+ played.current.ids.add(id)
563
+ if (text) played.current.texts.set(text.slice(0, 80), Date.now())
564
+ try {
565
+ const list = Array.from(played.current.ids).slice(-400)
566
+ window.localStorage.setItem(played.current.key, JSON.stringify(list))
567
+ } catch {
568
+ /* storage full or disabled */
569
+ }
570
+ }
571
+ const primed = React.useRef(false)
572
+ const debounce = React.useRef(null)
573
+ const focused = React.useRef(true)
574
+ const snapshot = typeof props.useChat === 'function'
575
+ ? props.useChat((value) => (value && typeof value === 'object' ? value.legacy : undefined))
576
+ : undefined
577
+
578
+ React.useEffect(() => {
579
+ const markFocused = () => {
580
+ focused.current = true
581
+ }
582
+ const markBlurred = () => {
583
+ focused.current = false
584
+ }
585
+ const onVisibility = () => {
586
+ if (document.visibilityState === 'hidden') markBlurred()
587
+ else markFocused()
588
+ }
589
+ window.addEventListener('focus', markFocused)
590
+ window.addEventListener('pointerdown', markFocused, true)
591
+ window.addEventListener('keydown', markFocused, true)
592
+ window.addEventListener('blur', markBlurred)
593
+ document.addEventListener('visibilitychange', onVisibility)
594
+ return () => {
595
+ window.removeEventListener('focus', markFocused)
596
+ window.removeEventListener('pointerdown', markFocused, true)
597
+ window.removeEventListener('keydown', markFocused, true)
598
+ window.removeEventListener('blur', markBlurred)
599
+ document.removeEventListener('visibilitychange', onVisibility)
600
+ }
601
+ }, [])
602
+
603
+ React.useEffect(() => {
604
+ const nodes = snapshot && Array.isArray(snapshot.nodes) ? snapshot.nodes : []
605
+ if (!snapshot) return
606
+
607
+ if (!primed.current) {
608
+ primed.current = true
609
+ for (const node of nodes) {
610
+ const id = node && (node.id || node.messageId || (node.message && node.message.id))
611
+ if (id) markSpoken(id, '')
612
+ }
613
+ return
614
+ }
615
+
616
+ if (debounce.current) window.clearTimeout(debounce.current)
617
+ debounce.current = window.setTimeout(evaluate, 600)
618
+ return
619
+
620
+ function evaluate() {
621
+ let text = ''
622
+ let id = ''
623
+ for (let index = nodes.length - 1; index >= 0; index -= 1) {
624
+ const node = nodes[index]
625
+ if (!node || typeof node !== 'object') continue
626
+ if (String(node.kind || '') !== 'assistant') continue
627
+ const candidateId = node.id || node.messageId || (node.message && node.message.id) || ''
628
+ if (!candidateId || played.current.ids.has(candidateId)) continue
629
+ let raw = ''
630
+ try {
631
+ raw = collectText(node, [], 0).join(' ')
632
+ if (!raw) raw = collectAnyText(node, [], 0).join(' ')
633
+ } catch {
634
+ raw = ''
635
+ }
636
+ const cleaned = cleanForSpeech(raw)
637
+ if (!cleaned) continue
638
+ const recent = played.current.texts.get(cleaned.slice(0, 80))
639
+ if (recent && Date.now() - recent < 60000) {
640
+ markSpoken(candidateId, '')
641
+ continue
642
+ }
643
+ text = cleaned
644
+ id = candidateId
645
+ break
646
+ }
647
+ if (!id) {
648
+ const last = nodes[nodes.length - 1]
649
+ const shape = last && typeof last === 'object' ? Object.keys(last).slice(0, 10).join(',') : 'none'
650
+ const kind = last && typeof last === 'object' ? String(last.kind || last.type || '?') : '?'
651
+ const blocks = last && Array.isArray(last.blocks) ? last.blocks : []
652
+ const probe = blocks[0] && typeof blocks[0] === 'object'
653
+ ? Object.keys(blocks[0]).slice(0, 8).join(',') + '|type=' + String(blocks[0].type || blocks[0].kind || '?')
654
+ : 'none'
655
+ return
656
+ }
657
+ markSpoken(id, text)
658
+
659
+ api('/status')
660
+ .then((data) => {
661
+ const limit = Number((data && data.autoSpeakMaxChars) || 0)
662
+ if (!data || !data.autoSpeak) return null
663
+ if (limit <= 0) return null
664
+ if (text.length > limit) return null
665
+ if (!data.backgroundPlay && !focused.current) return null
666
+ return speakRemotely({ text }, { host: true })
667
+ })
668
+ .catch(() => {})
669
+ }
670
+ }, [snapshot])
671
+
672
+ const data = state.data
673
+ if (!data) return null
674
+ const used = data.today ? data.today.chars : 0
675
+ const limit = data.today ? data.today.limit : 0
676
+ const tone = data.ok ? COLOR.success : COLOR.error
677
+ const enabled = Boolean(data.autoSpeak)
678
+ const label = data.ok
679
+ ? `${used} / ${limit} ${t('status.chars')}${enabled ? ' · ' + t('extra.autoOn') : ''}`
680
+ : t('status.missingKey')
681
+
682
+ return h('div', {
683
+ style: {
684
+ display: 'flex', alignItems: 'center', gap: 6, padding: '2px 2px 0',
685
+ fontSize: 11, lineHeight: '16px', color: COLOR.secondary,
686
+ },
687
+ },
688
+ h('span', { style: { width: 6, height: 6, borderRadius: 999, background: tone, flex: '0 0 auto' } }),
689
+ h('span', null, label))
690
+ }
691
+
692
+ function SettingsPage(props) {
693
+ const t = props.t
694
+ const [state, reload] = useStatus()
695
+ const [voices, setVoices] = React.useState([])
696
+ const [voiceId, setVoiceId] = React.useState('')
697
+ const [moodId, setMoodId] = React.useState('normal')
698
+ const [emotionMode, setEmotionMode] = React.useState('fixed')
699
+ const [tones, setTones] = React.useState([])
700
+ const [savedVoices, setSavedVoices] = React.useState([])
701
+ const [voiceRenameOpen, setVoiceRenameOpen] = React.useState(false)
702
+ const [voiceNameDraft, setVoiceNameDraft] = React.useState('')
703
+ const [designName, setDesignName] = React.useState('')
704
+ const [voiceNames, setVoiceNames] = React.useState({})
705
+ const [libraryOpen, setLibraryOpen] = React.useState(false)
706
+ const [libraryQuery, setLibraryQuery] = React.useState('')
707
+ const [toneEditor, setToneEditor] = React.useState(false)
708
+ const [toneEditId, setToneEditId] = React.useState('')
709
+ const [toneDraftName, setToneDraftName] = React.useState('')
710
+ const [toneDraftText, setToneDraftText] = React.useState('')
711
+ const [previewText, setPreviewText] = React.useState('')
712
+ const [dailyChars, setDailyChars] = React.useState(1500)
713
+ const [autoSpeak, setAutoSpeak] = React.useState(false)
714
+ const [autoMax, setAutoMax] = React.useState(120)
715
+ const [backgroundPlay, setBackgroundPlay] = React.useState(false)
716
+ const [customMood, setCustomMood] = React.useState('')
717
+ const [designDesc, setDesignDesc] = React.useState('')
718
+ const [designText, setDesignText] = React.useState('')
719
+ const [candidates, setCandidates] = React.useState([])
720
+ const [phase, setPhase] = React.useState('idle')
721
+ const [notice, setNotice] = React.useState('')
722
+ const [refreshNote, setRefreshNote] = React.useState({ text: '', tone: 'muted' })
723
+
724
+ React.useEffect(() => {
725
+ const data = state.data
726
+ if (!data) return
727
+ setVoiceId(data.voiceId || '')
728
+ setMoodId(data.moodId || 'normal')
729
+ setEmotionMode(data.emotionMode || 'fixed')
730
+ setTones(Array.isArray(data.tones) ? data.tones : [])
731
+ setSavedVoices(Array.isArray(data.savedVoices) ? data.savedVoices : [])
732
+ setPreviewText(data.previewText || '')
733
+ setDailyChars(data.today ? data.today.limit : 1500)
734
+ setAutoSpeak(Boolean(data.autoSpeak))
735
+ setAutoMax(Number(data.autoSpeakMaxChars || 120))
736
+ setBackgroundPlay(Boolean(data.backgroundPlay))
737
+ setCustomMood(String(data.customMood || ''))
738
+ }, [state.data])
739
+
740
+ React.useEffect(() => {
741
+ let alive = true
742
+ api('/voices')
743
+ .then((data) => { if (alive) setVoices(data.voices || []) })
744
+ .catch(() => { if (alive) setVoices([]) })
745
+ return () => { alive = false }
746
+ }, [])
747
+
748
+ const data = state.data
749
+ const presets = data && Array.isArray(data.voicePresets) ? data.voicePresets : []
750
+ const extra = voices.filter((voice) => !presets.some((preset) => preset.voiceId === voice.voiceId))
751
+ const balance = data && typeof data.balance === 'number' ? data.balance : null
752
+ const used = data && data.today ? data.today.chars : 0
753
+ const limit = data && data.today ? data.today.limit : dailyChars
754
+
755
+ const preview = async () => {
756
+ setPhase('preview')
757
+ setNotice('')
758
+ try {
759
+ const result = await speakRemotely({ text: previewText || '你好', toneId: moodId, voiceId })
760
+ setPhase('idle')
761
+ setNotice((result.chars || 0) + ' ' + t('status.chars') + ' · ' + (result.credits || 0) + ' ' + t('status.credits'))
762
+ } catch (error) {
763
+ setPhase('idle')
764
+ setNotice(humanError(t, error))
765
+ }
766
+ }
767
+
768
+ const save = async () => {
769
+ setPhase('save')
770
+ setNotice('')
771
+ try {
772
+ await api('/settings', {
773
+ method: 'POST',
774
+ headers: { 'content-type': 'application/json' },
775
+ body: JSON.stringify({
776
+ voiceId,
777
+ moodId,
778
+ emotionMode,
779
+ tones: tones.filter((tone) => !tone.builtin),
780
+ previewText,
781
+ dailyChars: Number(dailyChars),
782
+ autoSpeak,
783
+ autoSpeakMaxChars: Number(autoMax),
784
+ backgroundPlay,
785
+ customMood,
786
+ }),
787
+ })
788
+ setPhase('idle')
789
+ setNotice(t('label.saved'))
790
+ reload()
791
+ } catch (error) {
792
+ setPhase('idle')
793
+ setNotice(humanError(t, error))
794
+ }
795
+ }
796
+
797
+ const doRefresh = async () => {
798
+ setPhase('refresh')
799
+ setRefreshNote({ text: '', tone: 'muted' })
800
+ try {
801
+ const fresh = await reload(true)
802
+ setPhase('idle')
803
+ const credits = fresh && typeof fresh.balance === 'number' ? ' · ' + fresh.balance.toFixed(1) + ' ' + t('status.credits') : ''
804
+ setRefreshNote({ text: t('extra.refreshed') + credits, tone: 'ok' })
805
+ } catch (error) {
806
+ setPhase('idle')
807
+ setRefreshNote({ text: t('extra.refreshFailed') + ': ' + humanError(t, error), tone: 'error' })
808
+ }
809
+ }
810
+
811
+ const generate = async () => {
812
+ setPhase('design')
813
+ setNotice('')
814
+ setCandidates([])
815
+ try {
816
+ const result = await api('/design', {
817
+ method: 'POST',
818
+ headers: { 'content-type': 'application/json' },
819
+ body: JSON.stringify({ description: designDesc, text: designText || previewText || '你好' }),
820
+ })
821
+ setCandidates(result.candidates || [])
822
+ setPhase('idle')
823
+ if (!result.candidates || !result.candidates.length) setNotice(t('extra.designEmpty'))
824
+ } catch (error) {
825
+ setPhase('idle')
826
+ setNotice(humanError(t, error))
827
+ }
828
+ }
829
+
830
+ const saveCandidate = async (candidate) => {
831
+ setPhase('saveVoice')
832
+ setNotice('')
833
+ try {
834
+ const result = await api('/save-voice', {
835
+ method: 'POST',
836
+ headers: { 'content-type': 'application/json' },
837
+ body: JSON.stringify({
838
+ generatedVoiceId: candidate.generatedVoiceId,
839
+ name: designName.trim() || candidate.name || t('extra.newVoice'),
840
+ description: designDesc,
841
+ }),
842
+ })
843
+ setPhase('idle')
844
+ if (result.voiceId) {
845
+ setVoiceId(result.voiceId)
846
+ setNotice(t('extra.voiceSaved'))
847
+ reload()
848
+ const fresh = await api('/voices').catch(() => null)
849
+ if (fresh && Array.isArray(fresh.voices)) setVoices(fresh.voices)
850
+ }
851
+ } catch (error) {
852
+ setPhase('idle')
853
+ setNotice(humanError(t, error))
854
+ }
855
+ }
856
+
857
+ const publicVoices = voices.filter((voice) => {
858
+ if (voice.private) return false
859
+ if (presets.some((preset) => preset.voiceId === voice.voiceId)) return false
860
+ const query = libraryQuery.trim().toLowerCase()
861
+ if (!query) return true
862
+ return (voice.name || '').toLowerCase().includes(query)
863
+ || (voice.description || '').toLowerCase().includes(query)
864
+ })
865
+
866
+ const loadPublicVoice = async (voice) => {
867
+ const next = savedVoices.some((item) => item.voiceId === voice.voiceId)
868
+ ? savedVoices
869
+ : savedVoices.concat([{
870
+ voiceId: voice.voiceId,
871
+ name: voice.name,
872
+ language: voice.language || '',
873
+ description: voice.description || '',
874
+ }])
875
+ setSavedVoices(next)
876
+ setVoiceId(voice.voiceId)
877
+ setNotice(t('extra.voiceAdded'))
878
+ try {
879
+ await api('/settings', {
880
+ method: 'POST',
881
+ headers: { 'content-type': 'application/json' },
882
+ body: JSON.stringify({ savedVoices: next }),
883
+ })
884
+ } catch (error) {
885
+ setNotice(humanError(t, error))
886
+ }
887
+ }
888
+
889
+ const audioPreview = async (id) => {
890
+ setPhase('voicePreview')
891
+ setNotice('')
892
+ try {
893
+ await speakRemotely({ text: previewText || '你好', toneId: 'normal', voiceId: id })
894
+ setPhase('idle')
895
+ } catch (error) {
896
+ setPhase('idle')
897
+ setNotice(humanError(t, error))
898
+ }
899
+ }
900
+
901
+ const activeTone = tones.find((tone) => tone.id === moodId) || tones[0] || null
902
+ const activeVoice = voices.find((voice) => voice.voiceId === voiceId) || null
903
+ const savedVoice = savedVoices.find((item) => item.voiceId === voiceId) || null
904
+ const canDeleteVoice = Boolean(!presets.some((preset) => preset.voiceId === voiceId)
905
+ && (savedVoice || (activeVoice && activeVoice.private)))
906
+ const canRenameVoice = Boolean(voiceId)
907
+ && !presets.some((preset) => preset.voiceId === voiceId)
908
+ && !savedVoice
909
+
910
+ const startRenameVoice = () => {
911
+ if (!canRenameVoice) {
912
+ setNotice(t('extra.renameBlocked'))
913
+ return
914
+ }
915
+ setVoiceNameDraft((activeVoice && activeVoice.name) || '')
916
+ setVoiceRenameOpen(true)
917
+ }
918
+
919
+ const renameVoice = async () => {
920
+ const name = voiceNameDraft.trim()
921
+ if (!name) {
922
+ setNotice(t('extra.toneIncomplete'))
923
+ return
924
+ }
925
+ setPhase('renameVoice')
926
+ setNotice('')
927
+ try {
928
+ await api('/rename-voice', {
929
+ method: 'POST',
930
+ headers: { 'content-type': 'application/json' },
931
+ body: JSON.stringify({ voiceId, name }),
932
+ })
933
+ setVoiceNames((prev) => ({ ...prev, [voiceId]: name }))
934
+ setVoices((prev) => prev.map((voice) => (
935
+ voice.voiceId === voiceId ? { ...voice, name } : voice
936
+ )))
937
+ setPhase('idle')
938
+ setVoiceRenameOpen(false)
939
+ setNotice(t('extra.voiceRenamed') + ' ' + name)
940
+ const fresh = await api('/voices').catch(() => null)
941
+ if (fresh && Array.isArray(fresh.voices)) {
942
+ setVoices(fresh.voices.map((voice) => (
943
+ voice.voiceId === voiceId ? { ...voice, name } : voice
944
+ )))
945
+ }
946
+ } catch (error) {
947
+ setPhase('idle')
948
+ setNotice(humanError(t, error))
949
+ }
950
+ }
951
+
952
+ const startNewTone = () => {
953
+ setToneEditId('')
954
+ setToneDraftName('')
955
+ setToneDraftText('')
956
+ setToneEditor(true)
957
+ }
958
+
959
+ const startEditTone = () => {
960
+ if (!activeTone || activeTone.builtin) return
961
+ setToneEditId(activeTone.id)
962
+ setToneDraftName(activeTone.name)
963
+ setToneDraftText(activeTone.instructions)
964
+ setToneEditor(true)
965
+ }
966
+
967
+ const cancelTone = () => setToneEditor(false)
968
+
969
+ const saveTone = async () => {
970
+ const name = toneDraftName.trim()
971
+ const text = toneDraftText.trim()
972
+ if (!name || !text) {
973
+ setNotice(t('extra.toneIncomplete'))
974
+ return
975
+ }
976
+ setPhase('saveTone')
977
+ setNotice('')
978
+ const id = toneEditId || 'tone-' + Date.now().toString(36)
979
+ const next = tones
980
+ .filter((tone) => tone.builtin || tone.id !== id)
981
+ .concat([{ id, name, instructions: text, builtin: false }])
982
+ try {
983
+ await api('/settings', {
984
+ method: 'POST',
985
+ headers: { 'content-type': 'application/json' },
986
+ body: JSON.stringify({ moodId: id, tones: next.filter((tone) => !tone.builtin) }),
987
+ })
988
+ setTones(next)
989
+ setMoodId(id)
990
+ setToneEditor(false)
991
+ setPhase('idle')
992
+ setNotice(t('extra.toneSaved'))
993
+ } catch (error) {
994
+ setPhase('idle')
995
+ setNotice(humanError(t, error))
996
+ }
997
+ }
998
+
999
+ const removeTone = async () => {
1000
+ if (!activeTone || activeTone.builtin) return
1001
+ setPhase('deleteTone')
1002
+ setNotice('')
1003
+ const next = tones.filter((tone) => tone.id !== activeTone.id)
1004
+ try {
1005
+ await api('/settings', {
1006
+ method: 'POST',
1007
+ headers: { 'content-type': 'application/json' },
1008
+ body: JSON.stringify({ moodId: 'normal', tones: next.filter((tone) => !tone.builtin) }),
1009
+ })
1010
+ setTones(next)
1011
+ setMoodId('normal')
1012
+ setPhase('idle')
1013
+ setNotice(t('extra.toneDeleted'))
1014
+ } catch (error) {
1015
+ setPhase('idle')
1016
+ setNotice(humanError(t, error))
1017
+ }
1018
+ }
1019
+
1020
+ const removeVoice = async () => {
1021
+ if (!canDeleteVoice) return
1022
+ setPhase('deleteVoice')
1023
+ setNotice('')
1024
+ try {
1025
+ await api('/delete-voice', {
1026
+ method: 'POST',
1027
+ headers: { 'content-type': 'application/json' },
1028
+ body: JSON.stringify({ voiceId }),
1029
+ })
1030
+ setPhase('idle')
1031
+ setNotice(savedVoice ? t('extra.voiceRemoved') : t('extra.voiceDeleted'))
1032
+ if (savedVoice) setSavedVoices(savedVoices.filter((item) => item.voiceId !== voiceId))
1033
+ setVoiceId(presets.length ? presets[0].voiceId : '')
1034
+ const fresh = await api('/voices').catch(() => null)
1035
+ if (fresh && Array.isArray(fresh.voices)) setVoices(fresh.voices)
1036
+ } catch (error) {
1037
+ setPhase('idle')
1038
+ setNotice(humanError(t, error))
1039
+ }
1040
+ }
1041
+
1042
+ const row = (key, ...children) => h('div', { className: 'dsh-breeze-row', key },
1043
+ h('div', { className: 'dsh-breeze-key' }, key),
1044
+ h('div', { className: 'dsh-breeze-value' }, children))
1045
+
1046
+ const sectionTitle = (key) => h('div', {
1047
+ key,
1048
+ style: { marginTop: 18, marginBottom: 4, fontSize: 13, fontWeight: 600, color: COLOR.primary },
1049
+ }, key)
1050
+
1051
+ const optionLabel = (voice) => {
1052
+ const isPreset = presets.some((preset) => preset.voiceId === voice.voiceId)
1053
+ const label = (voiceNames[voice.voiceId] || voice.name)
1054
+ if (isPreset) return label + ' · ' + (voice.tag || '')
1055
+ return (voice.designed ? '★ ' : '') + label
1056
+ }
1057
+
1058
+ return h('div', { style: { padding: '4px 0 12px' } },
1059
+ h(StyleSheet),
1060
+ h('div', { style: { display: 'flex', alignItems: 'baseline', gap: 8, marginBottom: 6 } },
1061
+ h('div', { style: { fontSize: 14, fontWeight: 600, color: COLOR.primary } }, t('section.title')),
1062
+ h('div', { style: { fontSize: 12, color: COLOR.secondary } }, t('section.subtitle'))),
1063
+ state.error ? h('p', { className: 'dsh-breeze-hint', style: { color: COLOR.error } }, state.error) : null,
1064
+
1065
+ h('div', { style: { display: 'flex', flexDirection: 'column' } },
1066
+ row(t('label.voice'),
1067
+ h('select', {
1068
+ className: 'dsh-breeze-control',
1069
+ style: { maxWidth: 340 },
1070
+ value: voiceId,
1071
+ onChange: (event) => setVoiceId(event.target.value),
1072
+ },
1073
+ presets.map((preset) => h('option', { key: preset.voiceId, value: preset.voiceId }, optionLabel(preset))),
1074
+ extra.filter((voice) => voice.private).map((voice) => h('option', { key: voice.voiceId, value: voice.voiceId }, optionLabel(voice))),
1075
+ savedVoices
1076
+ .filter((item) => !presets.some((preset) => preset.voiceId === item.voiceId))
1077
+ .map((item) => h('option', { key: item.voiceId, value: item.voiceId }, item.name)),
1078
+ voiceId && !presets.some((p) => p.voiceId === voiceId) && !extra.some((v) => v.voiceId === voiceId)
1079
+ ? h('option', { key: voiceId, value: voiceId }, voiceId)
1080
+ : null),
1081
+ h('button', {
1082
+ type: 'button',
1083
+ className: 'dsh-breeze-btn',
1084
+ onClick: startRenameVoice,
1085
+ disabled: !canRenameVoice || phase === 'renameVoice',
1086
+ }, t('extra.renameVoice')),
1087
+ h('button', {
1088
+ type: 'button',
1089
+ className: 'dsh-breeze-btn',
1090
+ onClick: removeVoice,
1091
+ disabled: !canDeleteVoice || phase === 'deleteVoice',
1092
+ }, phase === 'deleteVoice' ? Spinner(12) : t('extra.deleteVoice'))),
1093
+
1094
+ voiceRenameOpen
1095
+ ? h('div', { style: { display: 'flex', gap: 8, margin: '2px 0 8px 144px' } },
1096
+ h('input', {
1097
+ className: 'dsh-breeze-control',
1098
+ style: { maxWidth: 260 },
1099
+ placeholder: t('extra.renamePlaceholder'),
1100
+ value: voiceNameDraft,
1101
+ onChange: (event) => setVoiceNameDraft(event.target.value),
1102
+ }),
1103
+ h('button', {
1104
+ type: 'button', className: 'dsh-breeze-btn', 'data-primary': 'true',
1105
+ onClick: renameVoice, disabled: phase === 'renameVoice',
1106
+ }, phase === 'renameVoice' ? Spinner(12) : t('extra.saveName')),
1107
+ h('button', { type: 'button', className: 'dsh-breeze-btn', onClick: () => setVoiceRenameOpen(false) }, t('extra.cancel')))
1108
+ : null,
1109
+
1110
+ row(t('extra.publicVoices'),
1111
+ h('button', {
1112
+ type: 'button',
1113
+ className: 'dsh-breeze-btn',
1114
+ onClick: () => setLibraryOpen(!libraryOpen),
1115
+ }, libraryOpen ? t('extra.collapseLibrary') : t('extra.openLibrary')),
1116
+ h('span', { style: { fontSize: 12, color: COLOR.secondary } }, t('extra.publicVoicesHint'))),
1117
+
1118
+ libraryOpen
1119
+ ? h('div', {
1120
+ style: {
1121
+ border: '1px solid ' + COLOR.border, borderRadius: 10, background: COLOR.surface,
1122
+ padding: 12, margin: '2px 0 10px',
1123
+ },
1124
+ },
1125
+ h('div', { style: { display: 'flex', alignItems: 'baseline', gap: 8, marginBottom: 8 } },
1126
+ h('div', { style: { fontSize: 13, fontWeight: 600, color: COLOR.primary } }, t('extra.libraryTitle')),
1127
+ h('div', { style: { fontSize: 12, color: COLOR.secondary } }, t('extra.librarySubtitle'))),
1128
+ h('input', {
1129
+ className: 'dsh-breeze-control',
1130
+ style: { width: '100%', marginBottom: 8 },
1131
+ placeholder: t('extra.librarySearch'),
1132
+ value: libraryQuery,
1133
+ onChange: (event) => setLibraryQuery(event.target.value),
1134
+ }),
1135
+ h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6, maxHeight: 260, overflowY: 'auto' } },
1136
+ publicVoices.map((voice) => h('div', {
1137
+ key: voice.voiceId,
1138
+ style: {
1139
+ display: 'flex', alignItems: 'center', gap: 10, padding: '6px 0',
1140
+ borderTop: '1px solid ' + COLOR.border,
1141
+ },
1142
+ },
1143
+ h('div', { style: { flex: 1, minWidth: 0 } },
1144
+ h('div', { style: { fontSize: 13, color: COLOR.primary } }, voice.name + ' · ' + (voice.language || '')),
1145
+ h('div', {
1146
+ style: {
1147
+ fontSize: 12, color: COLOR.secondary, lineHeight: '17px',
1148
+ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
1149
+ },
1150
+ }, voice.description || '')),
1151
+ h('button', {
1152
+ type: 'button', className: 'dsh-breeze-btn',
1153
+ onClick: () => audioPreview(voice.voiceId),
1154
+ }, t('label.preview')),
1155
+ h('button', {
1156
+ type: 'button',
1157
+ className: 'dsh-breeze-btn',
1158
+ 'data-primary': savedVoices.some((item) => item.voiceId === voice.voiceId) ? 'false' : 'true',
1159
+ disabled: savedVoices.some((item) => item.voiceId === voice.voiceId),
1160
+ onClick: () => loadPublicVoice(voice),
1161
+ }, savedVoices.some((item) => item.voiceId === voice.voiceId) ? t('extra.voiceLoadedTag') : t('extra.loadVoice'))))),
1162
+ publicVoices.length ? null : h('div', { style: { fontSize: 12, color: COLOR.secondary } }, t('extra.libraryEmpty')))
1163
+ : null,
1164
+
1165
+ row(t('label.mood'),
1166
+ h('select', {
1167
+ className: 'dsh-breeze-control',
1168
+ style: { maxWidth: 240 },
1169
+ value: moodId,
1170
+ onChange: (event) => setMoodId(event.target.value),
1171
+ },
1172
+ tones.map((tone) => h('option', { key: tone.id, value: tone.id },
1173
+ tone.name + (tone.builtin ? '' : ' · ' + t('extra.customTag'))))),
1174
+ h('button', { type: 'button', className: 'dsh-breeze-btn', onClick: startNewTone }, t('extra.newTone')),
1175
+ activeTone && !activeTone.builtin
1176
+ ? h('button', { type: 'button', className: 'dsh-breeze-btn', onClick: startEditTone }, t('extra.editTone'))
1177
+ : null,
1178
+ activeTone && !activeTone.builtin
1179
+ ? h('button', { type: 'button', className: 'dsh-breeze-btn', onClick: removeTone, disabled: phase === 'deleteTone' }, t('extra.deleteTone'))
1180
+ : null),
1181
+
1182
+ activeTone
1183
+ ? h('div', {
1184
+ style: {
1185
+ marginTop: -4, marginBottom: 6, fontSize: 12, lineHeight: '18px',
1186
+ color: COLOR.secondary, paddingLeft: 144,
1187
+ },
1188
+ }, activeTone.instructions)
1189
+ : null,
1190
+
1191
+ toneEditor
1192
+ ? h('div', { style: { display: 'flex', flexDirection: 'column', gap: 8, margin: '4px 0 10px 144px' } },
1193
+ h('input', {
1194
+ className: 'dsh-breeze-control',
1195
+ style: { maxWidth: 300 },
1196
+ placeholder: t('extra.toneNamePlaceholder'),
1197
+ value: toneDraftName,
1198
+ onChange: (event) => setToneDraftName(event.target.value),
1199
+ }),
1200
+ h('textarea', {
1201
+ className: 'dsh-breeze-control',
1202
+ style: { minHeight: 62, padding: '8px 10px', resize: 'vertical', lineHeight: '20px' },
1203
+ placeholder: t('extra.tonePlaceholder'),
1204
+ maxLength: 500,
1205
+ value: toneDraftText,
1206
+ onChange: (event) => setToneDraftText(event.target.value),
1207
+ }),
1208
+ h('div', { style: { display: 'flex', gap: 8 } },
1209
+ h('button', {
1210
+ type: 'button', className: 'dsh-breeze-btn', 'data-primary': 'true',
1211
+ onClick: saveTone, disabled: phase === 'saveTone',
1212
+ }, phase === 'saveTone' ? Spinner(12) : t('extra.saveTone')),
1213
+ h('button', { type: 'button', className: 'dsh-breeze-btn', onClick: cancelTone }, t('extra.cancel'))))
1214
+ : null,
1215
+
1216
+ row(t('extra.emotionMode'),
1217
+ h('select', {
1218
+ className: 'dsh-breeze-control',
1219
+ style: { maxWidth: 200 },
1220
+ value: emotionMode,
1221
+ onChange: async (event) => {
1222
+ const next = event.target.value
1223
+ setEmotionMode(next)
1224
+ try {
1225
+ await api('/settings', {
1226
+ method: 'POST',
1227
+ headers: { 'content-type': 'application/json' },
1228
+ body: JSON.stringify({ emotionMode: next }),
1229
+ })
1230
+ setNotice(t('extra.emotionSaved'))
1231
+ } catch (error) {
1232
+ setNotice(humanError(t, error))
1233
+ }
1234
+ },
1235
+ },
1236
+ h('option', { value: 'fixed' }, t('extra.emotionFixed')),
1237
+ h('option', { value: 'infer' }, t('extra.emotionInfer')),
1238
+ h('option', { value: 'marker' }, t('extra.emotionMarker'))),
1239
+ h('span', { style: { fontSize: 12, color: COLOR.secondary } },
1240
+ emotionMode === 'infer'
1241
+ ? t('extra.emotionInferHint')
1242
+ : emotionMode === 'marker'
1243
+ ? t('extra.emotionMarkerHint')
1244
+ : t('extra.emotionFixedHint')),
1245
+ emotionMode === 'marker'
1246
+ ? h('div', { style: { flexBasis: '100%', fontSize: 12, color: COLOR.error, lineHeight: '18px' } }, t('extra.emotionMarkerNote'))
1247
+ : null),
1248
+
1249
+ row(t('label.previewText'),
1250
+ h('input', {
1251
+ className: 'dsh-breeze-control',
1252
+ style: { flex: 1, minWidth: 220, maxWidth: 420 },
1253
+ value: previewText,
1254
+ onChange: (event) => setPreviewText(event.target.value),
1255
+ }),
1256
+ h('button', {
1257
+ type: 'button',
1258
+ className: 'dsh-breeze-play',
1259
+ onClick: preview,
1260
+ disabled: phase === 'preview',
1261
+ }, phase === 'preview' ? Spinner(11) : PlayGlyph(11), h('span', null, t('label.preview')))),
1262
+
1263
+ row(t('extra.autoSpeak'),
1264
+ h('button', {
1265
+ type: 'button',
1266
+ role: 'switch',
1267
+ 'aria-checked': autoSpeak ? 'true' : 'false',
1268
+ className: 'dsh-breeze-switch',
1269
+ 'data-on': autoSpeak ? 'true' : 'false',
1270
+ onClick: () => setAutoSpeak(!autoSpeak),
1271
+ }, h('span', { className: 'dsh-breeze-knob' })),
1272
+ h('span', { style: { fontSize: 12, color: COLOR.secondary } }, t('extra.autoSpeakHint'))),
1273
+
1274
+ row(t('extra.backgroundPlay'),
1275
+ h('button', {
1276
+ type: 'button',
1277
+ role: 'switch',
1278
+ 'aria-checked': backgroundPlay ? 'true' : 'false',
1279
+ className: 'dsh-breeze-switch',
1280
+ 'data-on': backgroundPlay ? 'true' : 'false',
1281
+ onClick: () => setBackgroundPlay(!backgroundPlay),
1282
+ }, h('span', { className: 'dsh-breeze-knob' })),
1283
+ h('span', { style: { fontSize: 12, color: COLOR.secondary } }, t('extra.backgroundPlayHint'))),
1284
+
1285
+ row(t('extra.autoMax'),
1286
+ h('input', {
1287
+ type: 'range', min: 0, max: 1000, step: 10,
1288
+ value: Math.min(1000, Math.max(0, Number(autoMax) || 0)),
1289
+ onChange: (event) => setAutoMax(Number(event.target.value)),
1290
+ style: { flex: 1, minWidth: 160, maxWidth: 320, accentColor: COLOR.brand },
1291
+ }),
1292
+ h('input', {
1293
+ className: 'dsh-breeze-control',
1294
+ style: { width: 96 },
1295
+ type: 'number', min: 0, max: 99999, step: 1,
1296
+ value: autoMax,
1297
+ onChange: (event) => setAutoMax(Math.max(0, Math.min(99999, Number(event.target.value) || 0))),
1298
+ }),
1299
+ h('span', { style: { fontSize: 12, color: COLOR.secondary } }, t('status.chars')),
1300
+ h('span', { style: { fontSize: 12, color: COLOR.secondary } }, t('extra.autoMaxHint')),
1301
+ autoMax > 1000
1302
+ ? h('div', { style: { flexBasis: '100%', fontSize: 12, fontWeight: 600, color: COLOR.error, lineHeight: '18px' } }, t('extra.autoMaxHard'))
1303
+ : autoMax > 300
1304
+ ? h('div', { style: { flexBasis: '100%', fontSize: 12, color: COLOR.error, lineHeight: '18px' } }, t('extra.autoMaxWarning'))
1305
+ : null),
1306
+
1307
+ row(t('label.dailyLimit'),
1308
+ h('input', {
1309
+ className: 'dsh-breeze-control',
1310
+ style: { width: 110 },
1311
+ type: 'number', min: 100, step: 100,
1312
+ value: dailyChars,
1313
+ onChange: (event) => setDailyChars(event.target.value),
1314
+ }),
1315
+ h('span', { style: { fontSize: 12, color: COLOR.secondary } }, t('hint.limit'))),
1316
+
1317
+ row(t('label.todayUsage'),
1318
+ h('span', { style: { fontSize: 13, color: COLOR.primary } }, used + ' / ' + limit + ' ' + t('status.chars')),
1319
+ h('span', {
1320
+ style: {
1321
+ flex: '1 1 120px', maxWidth: 220, height: 5, borderRadius: 999,
1322
+ background: COLOR.border, overflow: 'hidden', display: 'block',
1323
+ },
1324
+ }, h('span', {
1325
+ style: {
1326
+ display: 'block', height: '100%', borderRadius: 999,
1327
+ width: Math.min(100, limit ? Math.round((used / limit) * 100) : 0) + '%',
1328
+ background: COLOR.brand,
1329
+ },
1330
+ }))),
1331
+
1332
+ row(t('label.balance'),
1333
+ h('span', { style: { fontSize: 13, color: COLOR.primary } }, balance === null ? '-' : balance.toFixed(1)),
1334
+ h('span', { style: { fontSize: 12, color: COLOR.secondary } }, t('status.credits')),
1335
+ h('button', {
1336
+ type: 'button',
1337
+ className: 'dsh-breeze-btn',
1338
+ onClick: doRefresh,
1339
+ disabled: phase === 'refresh',
1340
+ }, phase === 'refresh' ? Spinner(12) : t('label.refresh')),
1341
+ refreshNote.text
1342
+ ? h('span', {
1343
+ style: {
1344
+ fontSize: 12,
1345
+ color: refreshNote.tone === 'error' ? COLOR.error : refreshNote.tone === 'ok' ? COLOR.success : COLOR.secondary,
1346
+ },
1347
+ }, refreshNote.text)
1348
+ : null)),
1349
+
1350
+ h('div', {
1351
+ style: { marginTop: 14, fontSize: 12, lineHeight: '18px', color: COLOR.secondary },
1352
+ }, t('extra.cloneNotice')),
1353
+
1354
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, marginTop: 8 } },
1355
+ h('button', {
1356
+ type: 'button', className: 'dsh-breeze-btn', 'data-primary': 'true',
1357
+ onClick: save, disabled: phase === 'save',
1358
+ }, phase === 'save' ? t('label.saving') : t('label.save')),
1359
+ notice ? h('span', { style: { fontSize: 12, color: COLOR.secondary } }, notice) : null),
1360
+ data && data.ok === false ? h('p', { className: 'dsh-breeze-hint' }, t('hint.key')) : null,
1361
+
1362
+ sectionTitle(t('extra.designTitle')),
1363
+ h('div', { style: { display: 'flex', flexDirection: 'column', gap: 10, marginTop: 4 } },
1364
+ h('textarea', {
1365
+ className: 'dsh-breeze-control',
1366
+ style: { minHeight: 88, padding: '8px 10px', resize: 'vertical', lineHeight: '20px' },
1367
+ placeholder: t('extra.designPlaceholder'),
1368
+ maxLength: 500,
1369
+ value: designDesc,
1370
+ onChange: (event) => setDesignDesc(event.target.value),
1371
+ }),
1372
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' } },
1373
+ h('input', {
1374
+ className: 'dsh-breeze-control',
1375
+ style: { flex: 1, minWidth: 200, maxWidth: 420 },
1376
+ placeholder: t('extra.designSample'),
1377
+ maxLength: 500,
1378
+ value: designText,
1379
+ onChange: (event) => setDesignText(event.target.value),
1380
+ }),
1381
+ h('input', {
1382
+ className: 'dsh-breeze-control',
1383
+ style: { width: 160 },
1384
+ placeholder: t('extra.voiceNamePlaceholder'),
1385
+ value: designName,
1386
+ onChange: (event) => setDesignName(event.target.value),
1387
+ }),
1388
+ h('button', {
1389
+ type: 'button', className: 'dsh-breeze-btn', 'data-primary': 'true',
1390
+ onClick: generate, disabled: phase === 'design' || designDesc.trim().length < 3,
1391
+ }, phase === 'design' ? t('extra.generating') : t('extra.generate')),
1392
+ h('span', { style: { fontSize: 12, color: COLOR.secondary } }, t('extra.designCost'))),
1393
+ h('p', { className: 'dsh-breeze-hint', style: { margin: 0 } }, t('extra.designHint')),
1394
+ candidates.length
1395
+ ? h('div', { style: { display: 'flex', gap: 10, flexWrap: 'wrap', marginTop: 2 } },
1396
+ candidates.map((candidate, index) => h('div', {
1397
+ key: candidate.generatedVoiceId,
1398
+ style: {
1399
+ border: '1px solid ' + COLOR.border, borderRadius: 10, padding: 10,
1400
+ background: COLOR.nested, minWidth: 150, display: 'flex',
1401
+ flexDirection: 'column', gap: 8,
1402
+ },
1403
+ },
1404
+ h('div', { style: { fontSize: 12, color: COLOR.secondary } }, t('extra.candidate') + ' ' + (index + 1)),
1405
+ h('div', { style: { display: 'flex', gap: 8 } },
1406
+ h('button', {
1407
+ type: 'button', className: 'dsh-breeze-btn',
1408
+ onClick: () => playUrl(candidate.url).catch(() => {}),
1409
+ }, PlayGlyph(10), t('label.preview')),
1410
+ h('button', {
1411
+ type: 'button', className: 'dsh-breeze-btn', 'data-primary': 'true',
1412
+ onClick: () => saveCandidate(candidate),
1413
+ disabled: phase === 'saveVoice',
1414
+ }, t('extra.saveVoice'))))))
1415
+ : null))
1416
+ }
1417
+
1418
+ return {
1419
+ inject: ['slots', 'locale'],
1420
+ apply(ctx) {
1421
+ let t = (key) => lookup(DICT.zh, key)
1422
+ try {
1423
+ ctx.effect(() => ctx.locale.register(NS, FLAT), 'dsh-breeze-tts: dictionaries')
1424
+ const bound = ctx.locale.bind(NS)
1425
+ if (typeof bound === 'function') {
1426
+ t = (key) => {
1427
+ let value
1428
+ try {
1429
+ value = bound(key)
1430
+ } catch {
1431
+ value = undefined
1432
+ }
1433
+ if (typeof value === 'string' && value && value !== key) return value
1434
+ const flat = FLAT.zh[key]
1435
+ return typeof flat === 'string' ? flat : lookup(DICT.zh, key)
1436
+ }
1437
+ }
1438
+ } catch {
1439
+ t = (key) => lookup(DICT.zh, key)
1440
+ }
1441
+
1442
+ ctx.slots.inject('settings.section', () => ctx.slots.register({
1443
+ name: 'settings.section',
1444
+ id: 'breeze-tts',
1445
+ order: 60,
1446
+ locale: NS,
1447
+ label: () => t('section.title'),
1448
+ }, (props) => h(SettingsPage, Object.assign({}, props, { t }))))
1449
+
1450
+ ctx.slots.inject('conversation.chat.assistant-actions', () => ctx.slots.register({
1451
+ name: 'conversation.chat.assistant-actions',
1452
+ id: 'breeze-tts-speak',
1453
+ order: 30,
1454
+ locale: NS,
1455
+ }, (props) => h(SpeakButton, Object.assign({}, props, { t }))))
1456
+
1457
+ ctx.slots.inject('conversation.composer.dock', () => ctx.slots.register({
1458
+ name: 'conversation.composer.dock',
1459
+ id: 'breeze-tts-status',
1460
+ order: 30,
1461
+ locale: NS,
1462
+ }, (props) => h(AutoSpeakChip, Object.assign({}, props, { t }))))
1463
+ },
1464
+ }
1465
+ },
1466
+ })