@lemoncat7/dsh-partner 0.1.0-alpha.13

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 (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +79 -0
  3. package/cordis.patch.yml +9 -0
  4. package/lib/agent-runtime.d.ts +42 -0
  5. package/lib/agent-runtime.d.ts.map +1 -0
  6. package/lib/agent-runtime.js +203 -0
  7. package/lib/agent-runtime.js.map +1 -0
  8. package/lib/api.d.ts +28 -0
  9. package/lib/api.d.ts.map +1 -0
  10. package/lib/api.js +196 -0
  11. package/lib/api.js.map +1 -0
  12. package/lib/channels/manager.d.ts +28 -0
  13. package/lib/channels/manager.d.ts.map +1 -0
  14. package/lib/channels/manager.js +205 -0
  15. package/lib/channels/manager.js.map +1 -0
  16. package/lib/channels/weixin/api.d.ts +15 -0
  17. package/lib/channels/weixin/api.d.ts.map +1 -0
  18. package/lib/channels/weixin/api.js +86 -0
  19. package/lib/channels/weixin/api.js.map +1 -0
  20. package/lib/channels/weixin/login.d.ts +24 -0
  21. package/lib/channels/weixin/login.d.ts.map +1 -0
  22. package/lib/channels/weixin/login.js +71 -0
  23. package/lib/channels/weixin/login.js.map +1 -0
  24. package/lib/channels/weixin/types.d.ts +40 -0
  25. package/lib/channels/weixin/types.d.ts.map +1 -0
  26. package/lib/channels/weixin/types.js +2 -0
  27. package/lib/channels/weixin/types.js.map +1 -0
  28. package/lib/client-api.d.ts +69 -0
  29. package/lib/client-api.d.ts.map +1 -0
  30. package/lib/client-api.js +20 -0
  31. package/lib/client-api.js.map +1 -0
  32. package/lib/client.d.ts +4 -0
  33. package/lib/client.d.ts.map +1 -0
  34. package/lib/client.js +1916 -0
  35. package/lib/client.js.map +7 -0
  36. package/lib/config.d.ts +11 -0
  37. package/lib/config.d.ts.map +1 -0
  38. package/lib/config.js +27 -0
  39. package/lib/config.js.map +1 -0
  40. package/lib/credentials.d.ts +14 -0
  41. package/lib/credentials.d.ts.map +1 -0
  42. package/lib/credentials.js +28 -0
  43. package/lib/credentials.js.map +1 -0
  44. package/lib/domain.d.ts +71 -0
  45. package/lib/domain.d.ts.map +1 -0
  46. package/lib/domain.js +57 -0
  47. package/lib/domain.js.map +1 -0
  48. package/lib/index.d.ts +9 -0
  49. package/lib/index.d.ts.map +1 -0
  50. package/lib/index.js +46 -0
  51. package/lib/index.js.map +1 -0
  52. package/lib/sidebar-anchor.d.ts +3 -0
  53. package/lib/sidebar-anchor.d.ts.map +1 -0
  54. package/lib/sidebar-anchor.js +38 -0
  55. package/lib/sidebar-anchor.js.map +1 -0
  56. package/lib/store.d.ts +12 -0
  57. package/lib/store.d.ts.map +1 -0
  58. package/lib/store.js +101 -0
  59. package/lib/store.js.map +1 -0
  60. package/package.json +111 -0
package/lib/client.js ADDED
@@ -0,0 +1,1916 @@
1
+ window.__ModuleLoader__.load({ id: "@lemoncat7/dsh-partner", factory: (require) => { var module = { exports: {} }; var exports = module.exports;
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/client.tsx
32
+ var client_exports = {};
33
+ __export(client_exports, {
34
+ apply: () => apply,
35
+ inject: () => inject
36
+ });
37
+ module.exports = __toCommonJS(client_exports);
38
+ var import_react4 = require("react");
39
+
40
+ // node_modules/@lemoncat7/dsh-plugin-ui/lib/index.js
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ var import_react = require("react");
43
+ var PLUGIN_WORKSPACE_ACTIVATE_EVENT = "@lemoncat7/dsh-plugin-ui/workspace-activate";
44
+ function activatePluginWorkspace(pluginId) {
45
+ window.dispatchEvent(new CustomEvent(PLUGIN_WORKSPACE_ACTIVATE_EVENT, {
46
+ detail: { pluginId }
47
+ }));
48
+ }
49
+ function observePluginWorkspace(pluginId, close) {
50
+ const onActivate = (event) => {
51
+ const detail = event.detail;
52
+ if (detail?.pluginId !== pluginId)
53
+ close();
54
+ };
55
+ window.addEventListener(PLUGIN_WORKSPACE_ACTIVATE_EVENT, onActivate);
56
+ return () => window.removeEventListener(PLUGIN_WORKSPACE_ACTIVATE_EVENT, onActivate);
57
+ }
58
+
59
+ // src/client.tsx
60
+ var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
61
+
62
+ // node_modules/qrcode.react/lib/esm/index.js
63
+ var import_react2 = __toESM(require("react"), 1);
64
+ var __defProp2 = Object.defineProperty;
65
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
66
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
67
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
68
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
69
+ var __spreadValues = (a, b) => {
70
+ for (var prop in b || (b = {}))
71
+ if (__hasOwnProp2.call(b, prop))
72
+ __defNormalProp(a, prop, b[prop]);
73
+ if (__getOwnPropSymbols)
74
+ for (var prop of __getOwnPropSymbols(b)) {
75
+ if (__propIsEnum.call(b, prop))
76
+ __defNormalProp(a, prop, b[prop]);
77
+ }
78
+ return a;
79
+ };
80
+ var __objRest = (source, exclude) => {
81
+ var target = {};
82
+ for (var prop in source)
83
+ if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0)
84
+ target[prop] = source[prop];
85
+ if (source != null && __getOwnPropSymbols)
86
+ for (var prop of __getOwnPropSymbols(source)) {
87
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
88
+ target[prop] = source[prop];
89
+ }
90
+ return target;
91
+ };
92
+ var qrcodegen;
93
+ ((qrcodegen2) => {
94
+ const _QrCode = class _QrCode2 {
95
+ /*-- Constructor (low level) and fields --*/
96
+ // Creates a new QR Code with the given version number,
97
+ // error correction level, data codeword bytes, and mask number.
98
+ // This is a low-level API that most users should not use directly.
99
+ // A mid-level API is the encodeSegments() function.
100
+ constructor(version, errorCorrectionLevel, dataCodewords, msk) {
101
+ this.version = version;
102
+ this.errorCorrectionLevel = errorCorrectionLevel;
103
+ this.modules = [];
104
+ this.isFunction = [];
105
+ if (version < _QrCode2.MIN_VERSION || version > _QrCode2.MAX_VERSION)
106
+ throw new RangeError("Version value out of range");
107
+ if (msk < -1 || msk > 7)
108
+ throw new RangeError("Mask value out of range");
109
+ this.size = version * 4 + 17;
110
+ let row = [];
111
+ for (let i = 0; i < this.size; i++)
112
+ row.push(false);
113
+ for (let i = 0; i < this.size; i++) {
114
+ this.modules.push(row.slice());
115
+ this.isFunction.push(row.slice());
116
+ }
117
+ this.drawFunctionPatterns();
118
+ const allCodewords = this.addEccAndInterleave(dataCodewords);
119
+ this.drawCodewords(allCodewords);
120
+ if (msk == -1) {
121
+ let minPenalty = 1e9;
122
+ for (let i = 0; i < 8; i++) {
123
+ this.applyMask(i);
124
+ this.drawFormatBits(i);
125
+ const penalty = this.getPenaltyScore();
126
+ if (penalty < minPenalty) {
127
+ msk = i;
128
+ minPenalty = penalty;
129
+ }
130
+ this.applyMask(i);
131
+ }
132
+ }
133
+ assert(0 <= msk && msk <= 7);
134
+ this.mask = msk;
135
+ this.applyMask(msk);
136
+ this.drawFormatBits(msk);
137
+ this.isFunction = [];
138
+ }
139
+ /*-- Static factory functions (high level) --*/
140
+ // Returns a QR Code representing the given Unicode text string at the given error correction level.
141
+ // As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
142
+ // Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
143
+ // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
144
+ // ecl argument if it can be done without increasing the version.
145
+ static encodeText(text, ecl) {
146
+ const segs = qrcodegen2.QrSegment.makeSegments(text);
147
+ return _QrCode2.encodeSegments(segs, ecl);
148
+ }
149
+ // Returns a QR Code representing the given binary data at the given error correction level.
150
+ // This function always encodes using the binary segment mode, not any text mode. The maximum number of
151
+ // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
152
+ // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
153
+ static encodeBinary(data, ecl) {
154
+ const seg = qrcodegen2.QrSegment.makeBytes(data);
155
+ return _QrCode2.encodeSegments([seg], ecl);
156
+ }
157
+ /*-- Static factory functions (mid level) --*/
158
+ // Returns a QR Code representing the given segments with the given encoding parameters.
159
+ // The smallest possible QR Code version within the given range is automatically
160
+ // chosen for the output. Iff boostEcl is true, then the ECC level of the result
161
+ // may be higher than the ecl argument if it can be done without increasing the
162
+ // version. The mask number is either between 0 to 7 (inclusive) to force that
163
+ // mask, or -1 to automatically choose an appropriate mask (which may be slow).
164
+ // This function allows the user to create a custom sequence of segments that switches
165
+ // between modes (such as alphanumeric and byte) to encode text in less space.
166
+ // This is a mid-level API; the high-level API is encodeText() and encodeBinary().
167
+ static encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = true) {
168
+ if (!(_QrCode2.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= _QrCode2.MAX_VERSION) || mask < -1 || mask > 7)
169
+ throw new RangeError("Invalid value");
170
+ let version;
171
+ let dataUsedBits;
172
+ for (version = minVersion; ; version++) {
173
+ const dataCapacityBits2 = _QrCode2.getNumDataCodewords(version, ecl) * 8;
174
+ const usedBits = QrSegment.getTotalBits(segs, version);
175
+ if (usedBits <= dataCapacityBits2) {
176
+ dataUsedBits = usedBits;
177
+ break;
178
+ }
179
+ if (version >= maxVersion)
180
+ throw new RangeError("Data too long");
181
+ }
182
+ for (const newEcl of [_QrCode2.Ecc.MEDIUM, _QrCode2.Ecc.QUARTILE, _QrCode2.Ecc.HIGH]) {
183
+ if (boostEcl && dataUsedBits <= _QrCode2.getNumDataCodewords(version, newEcl) * 8)
184
+ ecl = newEcl;
185
+ }
186
+ let bb = [];
187
+ for (const seg of segs) {
188
+ appendBits(seg.mode.modeBits, 4, bb);
189
+ appendBits(seg.numChars, seg.mode.numCharCountBits(version), bb);
190
+ for (const b of seg.getData())
191
+ bb.push(b);
192
+ }
193
+ assert(bb.length == dataUsedBits);
194
+ const dataCapacityBits = _QrCode2.getNumDataCodewords(version, ecl) * 8;
195
+ assert(bb.length <= dataCapacityBits);
196
+ appendBits(0, Math.min(4, dataCapacityBits - bb.length), bb);
197
+ appendBits(0, (8 - bb.length % 8) % 8, bb);
198
+ assert(bb.length % 8 == 0);
199
+ for (let padByte = 236; bb.length < dataCapacityBits; padByte ^= 236 ^ 17)
200
+ appendBits(padByte, 8, bb);
201
+ let dataCodewords = [];
202
+ while (dataCodewords.length * 8 < bb.length)
203
+ dataCodewords.push(0);
204
+ bb.forEach((b, i) => dataCodewords[i >>> 3] |= b << 7 - (i & 7));
205
+ return new _QrCode2(version, ecl, dataCodewords, mask);
206
+ }
207
+ /*-- Accessor methods --*/
208
+ // Returns the color of the module (pixel) at the given coordinates, which is false
209
+ // for light or true for dark. The top left corner has the coordinates (x=0, y=0).
210
+ // If the given coordinates are out of bounds, then false (light) is returned.
211
+ getModule(x, y) {
212
+ return 0 <= x && x < this.size && 0 <= y && y < this.size && this.modules[y][x];
213
+ }
214
+ // Modified to expose modules for easy access
215
+ getModules() {
216
+ return this.modules;
217
+ }
218
+ /*-- Private helper methods for constructor: Drawing function modules --*/
219
+ // Reads this object's version field, and draws and marks all function modules.
220
+ drawFunctionPatterns() {
221
+ for (let i = 0; i < this.size; i++) {
222
+ this.setFunctionModule(6, i, i % 2 == 0);
223
+ this.setFunctionModule(i, 6, i % 2 == 0);
224
+ }
225
+ this.drawFinderPattern(3, 3);
226
+ this.drawFinderPattern(this.size - 4, 3);
227
+ this.drawFinderPattern(3, this.size - 4);
228
+ const alignPatPos = this.getAlignmentPatternPositions();
229
+ const numAlign = alignPatPos.length;
230
+ for (let i = 0; i < numAlign; i++) {
231
+ for (let j = 0; j < numAlign; j++) {
232
+ if (!(i == 0 && j == 0 || i == 0 && j == numAlign - 1 || i == numAlign - 1 && j == 0))
233
+ this.drawAlignmentPattern(alignPatPos[i], alignPatPos[j]);
234
+ }
235
+ }
236
+ this.drawFormatBits(0);
237
+ this.drawVersion();
238
+ }
239
+ // Draws two copies of the format bits (with its own error correction code)
240
+ // based on the given mask and this object's error correction level field.
241
+ drawFormatBits(mask) {
242
+ const data = this.errorCorrectionLevel.formatBits << 3 | mask;
243
+ let rem = data;
244
+ for (let i = 0; i < 10; i++)
245
+ rem = rem << 1 ^ (rem >>> 9) * 1335;
246
+ const bits = (data << 10 | rem) ^ 21522;
247
+ assert(bits >>> 15 == 0);
248
+ for (let i = 0; i <= 5; i++)
249
+ this.setFunctionModule(8, i, getBit(bits, i));
250
+ this.setFunctionModule(8, 7, getBit(bits, 6));
251
+ this.setFunctionModule(8, 8, getBit(bits, 7));
252
+ this.setFunctionModule(7, 8, getBit(bits, 8));
253
+ for (let i = 9; i < 15; i++)
254
+ this.setFunctionModule(14 - i, 8, getBit(bits, i));
255
+ for (let i = 0; i < 8; i++)
256
+ this.setFunctionModule(this.size - 1 - i, 8, getBit(bits, i));
257
+ for (let i = 8; i < 15; i++)
258
+ this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i));
259
+ this.setFunctionModule(8, this.size - 8, true);
260
+ }
261
+ // Draws two copies of the version bits (with its own error correction code),
262
+ // based on this object's version field, iff 7 <= version <= 40.
263
+ drawVersion() {
264
+ if (this.version < 7)
265
+ return;
266
+ let rem = this.version;
267
+ for (let i = 0; i < 12; i++)
268
+ rem = rem << 1 ^ (rem >>> 11) * 7973;
269
+ const bits = this.version << 12 | rem;
270
+ assert(bits >>> 18 == 0);
271
+ for (let i = 0; i < 18; i++) {
272
+ const color = getBit(bits, i);
273
+ const a = this.size - 11 + i % 3;
274
+ const b = Math.floor(i / 3);
275
+ this.setFunctionModule(a, b, color);
276
+ this.setFunctionModule(b, a, color);
277
+ }
278
+ }
279
+ // Draws a 9*9 finder pattern including the border separator,
280
+ // with the center module at (x, y). Modules can be out of bounds.
281
+ drawFinderPattern(x, y) {
282
+ for (let dy = -4; dy <= 4; dy++) {
283
+ for (let dx = -4; dx <= 4; dx++) {
284
+ const dist = Math.max(Math.abs(dx), Math.abs(dy));
285
+ const xx = x + dx;
286
+ const yy = y + dy;
287
+ if (0 <= xx && xx < this.size && 0 <= yy && yy < this.size)
288
+ this.setFunctionModule(xx, yy, dist != 2 && dist != 4);
289
+ }
290
+ }
291
+ }
292
+ // Draws a 5*5 alignment pattern, with the center module
293
+ // at (x, y). All modules must be in bounds.
294
+ drawAlignmentPattern(x, y) {
295
+ for (let dy = -2; dy <= 2; dy++) {
296
+ for (let dx = -2; dx <= 2; dx++)
297
+ this.setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1);
298
+ }
299
+ }
300
+ // Sets the color of a module and marks it as a function module.
301
+ // Only used by the constructor. Coordinates must be in bounds.
302
+ setFunctionModule(x, y, isDark) {
303
+ this.modules[y][x] = isDark;
304
+ this.isFunction[y][x] = true;
305
+ }
306
+ /*-- Private helper methods for constructor: Codewords and masking --*/
307
+ // Returns a new byte string representing the given data with the appropriate error correction
308
+ // codewords appended to it, based on this object's version and error correction level.
309
+ addEccAndInterleave(data) {
310
+ const ver = this.version;
311
+ const ecl = this.errorCorrectionLevel;
312
+ if (data.length != _QrCode2.getNumDataCodewords(ver, ecl))
313
+ throw new RangeError("Invalid argument");
314
+ const numBlocks = _QrCode2.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
315
+ const blockEccLen = _QrCode2.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver];
316
+ const rawCodewords = Math.floor(_QrCode2.getNumRawDataModules(ver) / 8);
317
+ const numShortBlocks = numBlocks - rawCodewords % numBlocks;
318
+ const shortBlockLen = Math.floor(rawCodewords / numBlocks);
319
+ let blocks = [];
320
+ const rsDiv = _QrCode2.reedSolomonComputeDivisor(blockEccLen);
321
+ for (let i = 0, k = 0; i < numBlocks; i++) {
322
+ let dat = data.slice(k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1));
323
+ k += dat.length;
324
+ const ecc = _QrCode2.reedSolomonComputeRemainder(dat, rsDiv);
325
+ if (i < numShortBlocks)
326
+ dat.push(0);
327
+ blocks.push(dat.concat(ecc));
328
+ }
329
+ let result = [];
330
+ for (let i = 0; i < blocks[0].length; i++) {
331
+ blocks.forEach((block, j) => {
332
+ if (i != shortBlockLen - blockEccLen || j >= numShortBlocks)
333
+ result.push(block[i]);
334
+ });
335
+ }
336
+ assert(result.length == rawCodewords);
337
+ return result;
338
+ }
339
+ // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
340
+ // data area of this QR Code. Function modules need to be marked off before this is called.
341
+ drawCodewords(data) {
342
+ if (data.length != Math.floor(_QrCode2.getNumRawDataModules(this.version) / 8))
343
+ throw new RangeError("Invalid argument");
344
+ let i = 0;
345
+ for (let right = this.size - 1; right >= 1; right -= 2) {
346
+ if (right == 6)
347
+ right = 5;
348
+ for (let vert = 0; vert < this.size; vert++) {
349
+ for (let j = 0; j < 2; j++) {
350
+ const x = right - j;
351
+ const upward = (right + 1 & 2) == 0;
352
+ const y = upward ? this.size - 1 - vert : vert;
353
+ if (!this.isFunction[y][x] && i < data.length * 8) {
354
+ this.modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7));
355
+ i++;
356
+ }
357
+ }
358
+ }
359
+ }
360
+ assert(i == data.length * 8);
361
+ }
362
+ // XORs the codeword modules in this QR Code with the given mask pattern.
363
+ // The function modules must be marked and the codeword bits must be drawn
364
+ // before masking. Due to the arithmetic of XOR, calling applyMask() with
365
+ // the same mask value a second time will undo the mask. A final well-formed
366
+ // QR Code needs exactly one (not zero, two, etc.) mask applied.
367
+ applyMask(mask) {
368
+ if (mask < 0 || mask > 7)
369
+ throw new RangeError("Mask value out of range");
370
+ for (let y = 0; y < this.size; y++) {
371
+ for (let x = 0; x < this.size; x++) {
372
+ let invert;
373
+ switch (mask) {
374
+ case 0:
375
+ invert = (x + y) % 2 == 0;
376
+ break;
377
+ case 1:
378
+ invert = y % 2 == 0;
379
+ break;
380
+ case 2:
381
+ invert = x % 3 == 0;
382
+ break;
383
+ case 3:
384
+ invert = (x + y) % 3 == 0;
385
+ break;
386
+ case 4:
387
+ invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 == 0;
388
+ break;
389
+ case 5:
390
+ invert = x * y % 2 + x * y % 3 == 0;
391
+ break;
392
+ case 6:
393
+ invert = (x * y % 2 + x * y % 3) % 2 == 0;
394
+ break;
395
+ case 7:
396
+ invert = ((x + y) % 2 + x * y % 3) % 2 == 0;
397
+ break;
398
+ default:
399
+ throw new Error("Unreachable");
400
+ }
401
+ if (!this.isFunction[y][x] && invert)
402
+ this.modules[y][x] = !this.modules[y][x];
403
+ }
404
+ }
405
+ }
406
+ // Calculates and returns the penalty score based on state of this QR Code's current modules.
407
+ // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
408
+ getPenaltyScore() {
409
+ let result = 0;
410
+ for (let y = 0; y < this.size; y++) {
411
+ let runColor = false;
412
+ let runX = 0;
413
+ let runHistory = [0, 0, 0, 0, 0, 0, 0];
414
+ for (let x = 0; x < this.size; x++) {
415
+ if (this.modules[y][x] == runColor) {
416
+ runX++;
417
+ if (runX == 5)
418
+ result += _QrCode2.PENALTY_N1;
419
+ else if (runX > 5)
420
+ result++;
421
+ } else {
422
+ this.finderPenaltyAddHistory(runX, runHistory);
423
+ if (!runColor)
424
+ result += this.finderPenaltyCountPatterns(runHistory) * _QrCode2.PENALTY_N3;
425
+ runColor = this.modules[y][x];
426
+ runX = 1;
427
+ }
428
+ }
429
+ result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * _QrCode2.PENALTY_N3;
430
+ }
431
+ for (let x = 0; x < this.size; x++) {
432
+ let runColor = false;
433
+ let runY = 0;
434
+ let runHistory = [0, 0, 0, 0, 0, 0, 0];
435
+ for (let y = 0; y < this.size; y++) {
436
+ if (this.modules[y][x] == runColor) {
437
+ runY++;
438
+ if (runY == 5)
439
+ result += _QrCode2.PENALTY_N1;
440
+ else if (runY > 5)
441
+ result++;
442
+ } else {
443
+ this.finderPenaltyAddHistory(runY, runHistory);
444
+ if (!runColor)
445
+ result += this.finderPenaltyCountPatterns(runHistory) * _QrCode2.PENALTY_N3;
446
+ runColor = this.modules[y][x];
447
+ runY = 1;
448
+ }
449
+ }
450
+ result += this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) * _QrCode2.PENALTY_N3;
451
+ }
452
+ for (let y = 0; y < this.size - 1; y++) {
453
+ for (let x = 0; x < this.size - 1; x++) {
454
+ const color = this.modules[y][x];
455
+ if (color == this.modules[y][x + 1] && color == this.modules[y + 1][x] && color == this.modules[y + 1][x + 1])
456
+ result += _QrCode2.PENALTY_N2;
457
+ }
458
+ }
459
+ let dark = 0;
460
+ for (const row of this.modules)
461
+ dark = row.reduce((sum, color) => sum + (color ? 1 : 0), dark);
462
+ const total = this.size * this.size;
463
+ const k = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;
464
+ assert(0 <= k && k <= 9);
465
+ result += k * _QrCode2.PENALTY_N4;
466
+ assert(0 <= result && result <= 2568888);
467
+ return result;
468
+ }
469
+ /*-- Private helper functions --*/
470
+ // Returns an ascending list of positions of alignment patterns for this version number.
471
+ // Each position is in the range [0,177), and are used on both the x and y axes.
472
+ // This could be implemented as lookup table of 40 variable-length lists of integers.
473
+ getAlignmentPatternPositions() {
474
+ if (this.version == 1)
475
+ return [];
476
+ else {
477
+ const numAlign = Math.floor(this.version / 7) + 2;
478
+ const step = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2;
479
+ let result = [6];
480
+ for (let pos = this.size - 7; result.length < numAlign; pos -= step)
481
+ result.splice(1, 0, pos);
482
+ return result;
483
+ }
484
+ }
485
+ // Returns the number of data bits that can be stored in a QR Code of the given version number, after
486
+ // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
487
+ // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
488
+ static getNumRawDataModules(ver) {
489
+ if (ver < _QrCode2.MIN_VERSION || ver > _QrCode2.MAX_VERSION)
490
+ throw new RangeError("Version number out of range");
491
+ let result = (16 * ver + 128) * ver + 64;
492
+ if (ver >= 2) {
493
+ const numAlign = Math.floor(ver / 7) + 2;
494
+ result -= (25 * numAlign - 10) * numAlign - 55;
495
+ if (ver >= 7)
496
+ result -= 36;
497
+ }
498
+ assert(208 <= result && result <= 29648);
499
+ return result;
500
+ }
501
+ // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
502
+ // QR Code of the given version number and error correction level, with remainder bits discarded.
503
+ // This stateless pure function could be implemented as a (40*4)-cell lookup table.
504
+ static getNumDataCodewords(ver, ecl) {
505
+ return Math.floor(_QrCode2.getNumRawDataModules(ver) / 8) - _QrCode2.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * _QrCode2.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
506
+ }
507
+ // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
508
+ // implemented as a lookup table over all possible parameter values, instead of as an algorithm.
509
+ static reedSolomonComputeDivisor(degree) {
510
+ if (degree < 1 || degree > 255)
511
+ throw new RangeError("Degree out of range");
512
+ let result = [];
513
+ for (let i = 0; i < degree - 1; i++)
514
+ result.push(0);
515
+ result.push(1);
516
+ let root = 1;
517
+ for (let i = 0; i < degree; i++) {
518
+ for (let j = 0; j < result.length; j++) {
519
+ result[j] = _QrCode2.reedSolomonMultiply(result[j], root);
520
+ if (j + 1 < result.length)
521
+ result[j] ^= result[j + 1];
522
+ }
523
+ root = _QrCode2.reedSolomonMultiply(root, 2);
524
+ }
525
+ return result;
526
+ }
527
+ // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
528
+ static reedSolomonComputeRemainder(data, divisor) {
529
+ let result = divisor.map((_) => 0);
530
+ for (const b of data) {
531
+ const factor = b ^ result.shift();
532
+ result.push(0);
533
+ divisor.forEach((coef, i) => result[i] ^= _QrCode2.reedSolomonMultiply(coef, factor));
534
+ }
535
+ return result;
536
+ }
537
+ // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
538
+ // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
539
+ static reedSolomonMultiply(x, y) {
540
+ if (x >>> 8 != 0 || y >>> 8 != 0)
541
+ throw new RangeError("Byte out of range");
542
+ let z = 0;
543
+ for (let i = 7; i >= 0; i--) {
544
+ z = z << 1 ^ (z >>> 7) * 285;
545
+ z ^= (y >>> i & 1) * x;
546
+ }
547
+ assert(z >>> 8 == 0);
548
+ return z;
549
+ }
550
+ // Can only be called immediately after a light run is added, and
551
+ // returns either 0, 1, or 2. A helper function for getPenaltyScore().
552
+ finderPenaltyCountPatterns(runHistory) {
553
+ const n = runHistory[1];
554
+ assert(n <= this.size * 3);
555
+ const core = n > 0 && runHistory[2] == n && runHistory[3] == n * 3 && runHistory[4] == n && runHistory[5] == n;
556
+ return (core && runHistory[0] >= n * 4 && runHistory[6] >= n ? 1 : 0) + (core && runHistory[6] >= n * 4 && runHistory[0] >= n ? 1 : 0);
557
+ }
558
+ // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
559
+ finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) {
560
+ if (currentRunColor) {
561
+ this.finderPenaltyAddHistory(currentRunLength, runHistory);
562
+ currentRunLength = 0;
563
+ }
564
+ currentRunLength += this.size;
565
+ this.finderPenaltyAddHistory(currentRunLength, runHistory);
566
+ return this.finderPenaltyCountPatterns(runHistory);
567
+ }
568
+ // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
569
+ finderPenaltyAddHistory(currentRunLength, runHistory) {
570
+ if (runHistory[0] == 0)
571
+ currentRunLength += this.size;
572
+ runHistory.pop();
573
+ runHistory.unshift(currentRunLength);
574
+ }
575
+ };
576
+ _QrCode.MIN_VERSION = 1;
577
+ _QrCode.MAX_VERSION = 40;
578
+ _QrCode.PENALTY_N1 = 3;
579
+ _QrCode.PENALTY_N2 = 3;
580
+ _QrCode.PENALTY_N3 = 40;
581
+ _QrCode.PENALTY_N4 = 10;
582
+ _QrCode.ECC_CODEWORDS_PER_BLOCK = [
583
+ // Version: (note that index 0 is for padding, and is set to an illegal value)
584
+ //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
585
+ [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
586
+ // Low
587
+ [-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
588
+ // Medium
589
+ [-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
590
+ // Quartile
591
+ [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
592
+ // High
593
+ ];
594
+ _QrCode.NUM_ERROR_CORRECTION_BLOCKS = [
595
+ // Version: (note that index 0 is for padding, and is set to an illegal value)
596
+ //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
597
+ [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
598
+ // Low
599
+ [-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
600
+ // Medium
601
+ [-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
602
+ // Quartile
603
+ [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
604
+ // High
605
+ ];
606
+ let QrCode = _QrCode;
607
+ qrcodegen2.QrCode = _QrCode;
608
+ function appendBits(val, len, bb) {
609
+ if (len < 0 || len > 31 || val >>> len != 0)
610
+ throw new RangeError("Value out of range");
611
+ for (let i = len - 1; i >= 0; i--)
612
+ bb.push(val >>> i & 1);
613
+ }
614
+ function getBit(x, i) {
615
+ return (x >>> i & 1) != 0;
616
+ }
617
+ function assert(cond) {
618
+ if (!cond)
619
+ throw new Error("Assertion error");
620
+ }
621
+ const _QrSegment = class _QrSegment2 {
622
+ /*-- Constructor (low level) and fields --*/
623
+ // Creates a new QR Code segment with the given attributes and data.
624
+ // The character count (numChars) must agree with the mode and the bit buffer length,
625
+ // but the constraint isn't checked. The given bit buffer is cloned and stored.
626
+ constructor(mode, numChars, bitData) {
627
+ this.mode = mode;
628
+ this.numChars = numChars;
629
+ this.bitData = bitData;
630
+ if (numChars < 0)
631
+ throw new RangeError("Invalid argument");
632
+ this.bitData = bitData.slice();
633
+ }
634
+ /*-- Static factory functions (mid level) --*/
635
+ // Returns a segment representing the given binary data encoded in
636
+ // byte mode. All input byte arrays are acceptable. Any text string
637
+ // can be converted to UTF-8 bytes and encoded as a byte mode segment.
638
+ static makeBytes(data) {
639
+ let bb = [];
640
+ for (const b of data)
641
+ appendBits(b, 8, bb);
642
+ return new _QrSegment2(_QrSegment2.Mode.BYTE, data.length, bb);
643
+ }
644
+ // Returns a segment representing the given string of decimal digits encoded in numeric mode.
645
+ static makeNumeric(digits) {
646
+ if (!_QrSegment2.isNumeric(digits))
647
+ throw new RangeError("String contains non-numeric characters");
648
+ let bb = [];
649
+ for (let i = 0; i < digits.length; ) {
650
+ const n = Math.min(digits.length - i, 3);
651
+ appendBits(parseInt(digits.substring(i, i + n), 10), n * 3 + 1, bb);
652
+ i += n;
653
+ }
654
+ return new _QrSegment2(_QrSegment2.Mode.NUMERIC, digits.length, bb);
655
+ }
656
+ // Returns a segment representing the given text string encoded in alphanumeric mode.
657
+ // The characters allowed are: 0 to 9, A to Z (uppercase only), space,
658
+ // dollar, percent, asterisk, plus, hyphen, period, slash, colon.
659
+ static makeAlphanumeric(text) {
660
+ if (!_QrSegment2.isAlphanumeric(text))
661
+ throw new RangeError("String contains unencodable characters in alphanumeric mode");
662
+ let bb = [];
663
+ let i;
664
+ for (i = 0; i + 2 <= text.length; i += 2) {
665
+ let temp = _QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;
666
+ temp += _QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1));
667
+ appendBits(temp, 11, bb);
668
+ }
669
+ if (i < text.length)
670
+ appendBits(_QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb);
671
+ return new _QrSegment2(_QrSegment2.Mode.ALPHANUMERIC, text.length, bb);
672
+ }
673
+ // Returns a new mutable list of zero or more segments to represent the given Unicode text string.
674
+ // The result may use various segment modes and switch modes to optimize the length of the bit stream.
675
+ static makeSegments(text) {
676
+ if (text == "")
677
+ return [];
678
+ else if (_QrSegment2.isNumeric(text))
679
+ return [_QrSegment2.makeNumeric(text)];
680
+ else if (_QrSegment2.isAlphanumeric(text))
681
+ return [_QrSegment2.makeAlphanumeric(text)];
682
+ else
683
+ return [_QrSegment2.makeBytes(_QrSegment2.toUtf8ByteArray(text))];
684
+ }
685
+ // Returns a segment representing an Extended Channel Interpretation
686
+ // (ECI) designator with the given assignment value.
687
+ static makeEci(assignVal) {
688
+ let bb = [];
689
+ if (assignVal < 0)
690
+ throw new RangeError("ECI assignment value out of range");
691
+ else if (assignVal < 1 << 7)
692
+ appendBits(assignVal, 8, bb);
693
+ else if (assignVal < 1 << 14) {
694
+ appendBits(2, 2, bb);
695
+ appendBits(assignVal, 14, bb);
696
+ } else if (assignVal < 1e6) {
697
+ appendBits(6, 3, bb);
698
+ appendBits(assignVal, 21, bb);
699
+ } else
700
+ throw new RangeError("ECI assignment value out of range");
701
+ return new _QrSegment2(_QrSegment2.Mode.ECI, 0, bb);
702
+ }
703
+ // Tests whether the given string can be encoded as a segment in numeric mode.
704
+ // A string is encodable iff each character is in the range 0 to 9.
705
+ static isNumeric(text) {
706
+ return _QrSegment2.NUMERIC_REGEX.test(text);
707
+ }
708
+ // Tests whether the given string can be encoded as a segment in alphanumeric mode.
709
+ // A string is encodable iff each character is in the following set: 0 to 9, A to Z
710
+ // (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
711
+ static isAlphanumeric(text) {
712
+ return _QrSegment2.ALPHANUMERIC_REGEX.test(text);
713
+ }
714
+ /*-- Methods --*/
715
+ // Returns a new copy of the data bits of this segment.
716
+ getData() {
717
+ return this.bitData.slice();
718
+ }
719
+ // (Package-private) Calculates and returns the number of bits needed to encode the given segments at
720
+ // the given version. The result is infinity if a segment has too many characters to fit its length field.
721
+ static getTotalBits(segs, version) {
722
+ let result = 0;
723
+ for (const seg of segs) {
724
+ const ccbits = seg.mode.numCharCountBits(version);
725
+ if (seg.numChars >= 1 << ccbits)
726
+ return Infinity;
727
+ result += 4 + ccbits + seg.bitData.length;
728
+ }
729
+ return result;
730
+ }
731
+ // Returns a new array of bytes representing the given string encoded in UTF-8.
732
+ static toUtf8ByteArray(str) {
733
+ str = encodeURI(str);
734
+ let result = [];
735
+ for (let i = 0; i < str.length; i++) {
736
+ if (str.charAt(i) != "%")
737
+ result.push(str.charCodeAt(i));
738
+ else {
739
+ result.push(parseInt(str.substring(i + 1, i + 3), 16));
740
+ i += 2;
741
+ }
742
+ }
743
+ return result;
744
+ }
745
+ };
746
+ _QrSegment.NUMERIC_REGEX = /^[0-9]*$/;
747
+ _QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/;
748
+ _QrSegment.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
749
+ let QrSegment = _QrSegment;
750
+ qrcodegen2.QrSegment = _QrSegment;
751
+ })(qrcodegen || (qrcodegen = {}));
752
+ ((qrcodegen2) => {
753
+ let QrCode;
754
+ ((QrCode2) => {
755
+ const _Ecc = class _Ecc {
756
+ // The QR Code can tolerate about 30% erroneous codewords
757
+ /*-- Constructor and fields --*/
758
+ constructor(ordinal, formatBits) {
759
+ this.ordinal = ordinal;
760
+ this.formatBits = formatBits;
761
+ }
762
+ };
763
+ _Ecc.LOW = new _Ecc(0, 1);
764
+ _Ecc.MEDIUM = new _Ecc(1, 0);
765
+ _Ecc.QUARTILE = new _Ecc(2, 3);
766
+ _Ecc.HIGH = new _Ecc(3, 2);
767
+ let Ecc = _Ecc;
768
+ QrCode2.Ecc = _Ecc;
769
+ })(QrCode = qrcodegen2.QrCode || (qrcodegen2.QrCode = {}));
770
+ })(qrcodegen || (qrcodegen = {}));
771
+ ((qrcodegen2) => {
772
+ let QrSegment;
773
+ ((QrSegment2) => {
774
+ const _Mode = class _Mode {
775
+ /*-- Constructor and fields --*/
776
+ constructor(modeBits, numBitsCharCount) {
777
+ this.modeBits = modeBits;
778
+ this.numBitsCharCount = numBitsCharCount;
779
+ }
780
+ /*-- Method --*/
781
+ // (Package-private) Returns the bit width of the character count field for a segment in
782
+ // this mode in a QR Code at the given version number. The result is in the range [0, 16].
783
+ numCharCountBits(ver) {
784
+ return this.numBitsCharCount[Math.floor((ver + 7) / 17)];
785
+ }
786
+ };
787
+ _Mode.NUMERIC = new _Mode(1, [10, 12, 14]);
788
+ _Mode.ALPHANUMERIC = new _Mode(2, [9, 11, 13]);
789
+ _Mode.BYTE = new _Mode(4, [8, 16, 16]);
790
+ _Mode.KANJI = new _Mode(8, [8, 10, 12]);
791
+ _Mode.ECI = new _Mode(7, [0, 0, 0]);
792
+ let Mode = _Mode;
793
+ QrSegment2.Mode = _Mode;
794
+ })(QrSegment = qrcodegen2.QrSegment || (qrcodegen2.QrSegment = {}));
795
+ })(qrcodegen || (qrcodegen = {}));
796
+ var qrcodegen_default = qrcodegen;
797
+ var ERROR_LEVEL_MAP = {
798
+ L: qrcodegen_default.QrCode.Ecc.LOW,
799
+ M: qrcodegen_default.QrCode.Ecc.MEDIUM,
800
+ Q: qrcodegen_default.QrCode.Ecc.QUARTILE,
801
+ H: qrcodegen_default.QrCode.Ecc.HIGH
802
+ };
803
+ var DEFAULT_SIZE = 128;
804
+ var DEFAULT_LEVEL = "L";
805
+ var DEFAULT_BGCOLOR = "#FFFFFF";
806
+ var DEFAULT_FGCOLOR = "#000000";
807
+ var DEFAULT_INCLUDEMARGIN = false;
808
+ var DEFAULT_MINVERSION = 1;
809
+ var SPEC_MARGIN_SIZE = 4;
810
+ var DEFAULT_MARGIN_SIZE = 0;
811
+ var DEFAULT_IMG_SCALE = 0.1;
812
+ function generatePath(modules, margin = 0) {
813
+ const ops = [];
814
+ modules.forEach(function(row, y) {
815
+ let start = null;
816
+ row.forEach(function(cell, x) {
817
+ if (!cell && start !== null) {
818
+ ops.push(
819
+ `M${start + margin} ${y + margin}h${x - start}v1H${start + margin}z`
820
+ );
821
+ start = null;
822
+ return;
823
+ }
824
+ if (x === row.length - 1) {
825
+ if (!cell) {
826
+ return;
827
+ }
828
+ if (start === null) {
829
+ ops.push(`M${x + margin},${y + margin} h1v1H${x + margin}z`);
830
+ } else {
831
+ ops.push(
832
+ `M${start + margin},${y + margin} h${x + 1 - start}v1H${start + margin}z`
833
+ );
834
+ }
835
+ return;
836
+ }
837
+ if (cell && start === null) {
838
+ start = x;
839
+ }
840
+ });
841
+ });
842
+ return ops.join("");
843
+ }
844
+ function excavateModules(modules, excavation) {
845
+ return modules.slice().map((row, y) => {
846
+ if (y < excavation.y || y >= excavation.y + excavation.h) {
847
+ return row;
848
+ }
849
+ return row.map((cell, x) => {
850
+ if (x < excavation.x || x >= excavation.x + excavation.w) {
851
+ return cell;
852
+ }
853
+ return false;
854
+ });
855
+ });
856
+ }
857
+ function getImageSettings(cells, size, margin, imageSettings) {
858
+ if (imageSettings == null) {
859
+ return null;
860
+ }
861
+ const numCells = cells.length + margin * 2;
862
+ const defaultSize = Math.floor(size * DEFAULT_IMG_SCALE);
863
+ const scale = numCells / size;
864
+ const w = (imageSettings.width || defaultSize) * scale;
865
+ const h = (imageSettings.height || defaultSize) * scale;
866
+ const x = imageSettings.x == null ? cells.length / 2 - w / 2 : imageSettings.x * scale;
867
+ const y = imageSettings.y == null ? cells.length / 2 - h / 2 : imageSettings.y * scale;
868
+ const opacity = imageSettings.opacity == null ? 1 : imageSettings.opacity;
869
+ let excavation = null;
870
+ if (imageSettings.excavate) {
871
+ let floorX = Math.floor(x);
872
+ let floorY = Math.floor(y);
873
+ let ceilW = Math.ceil(w + x - floorX);
874
+ let ceilH = Math.ceil(h + y - floorY);
875
+ excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH };
876
+ }
877
+ const crossOrigin = imageSettings.crossOrigin;
878
+ return { x, y, h, w, excavation, opacity, crossOrigin };
879
+ }
880
+ function getMarginSize(includeMargin, marginSize) {
881
+ if (marginSize != null) {
882
+ return Math.max(Math.floor(marginSize), 0);
883
+ }
884
+ return includeMargin ? SPEC_MARGIN_SIZE : DEFAULT_MARGIN_SIZE;
885
+ }
886
+ function useQRCode({
887
+ value,
888
+ level,
889
+ minVersion,
890
+ includeMargin,
891
+ marginSize,
892
+ imageSettings,
893
+ size,
894
+ boostLevel
895
+ }) {
896
+ let qrcode = import_react2.default.useMemo(() => {
897
+ const values = Array.isArray(value) ? value : [value];
898
+ const segments = values.reduce((accum, v) => {
899
+ accum.push(...qrcodegen_default.QrSegment.makeSegments(v));
900
+ return accum;
901
+ }, []);
902
+ return qrcodegen_default.QrCode.encodeSegments(
903
+ segments,
904
+ ERROR_LEVEL_MAP[level],
905
+ minVersion,
906
+ void 0,
907
+ void 0,
908
+ boostLevel
909
+ );
910
+ }, [value, level, minVersion, boostLevel]);
911
+ const { cells, margin, numCells, calculatedImageSettings } = import_react2.default.useMemo(() => {
912
+ let cells2 = qrcode.getModules();
913
+ const margin2 = getMarginSize(includeMargin, marginSize);
914
+ const numCells2 = cells2.length + margin2 * 2;
915
+ const calculatedImageSettings2 = getImageSettings(
916
+ cells2,
917
+ size,
918
+ margin2,
919
+ imageSettings
920
+ );
921
+ return {
922
+ cells: cells2,
923
+ margin: margin2,
924
+ numCells: numCells2,
925
+ calculatedImageSettings: calculatedImageSettings2
926
+ };
927
+ }, [qrcode, size, imageSettings, includeMargin, marginSize]);
928
+ return {
929
+ qrcode,
930
+ margin,
931
+ cells,
932
+ numCells,
933
+ calculatedImageSettings
934
+ };
935
+ }
936
+ var SUPPORTS_PATH2D = (function() {
937
+ try {
938
+ new Path2D().addPath(new Path2D());
939
+ } catch (e) {
940
+ return false;
941
+ }
942
+ return true;
943
+ })();
944
+ var QRCodeCanvas = import_react2.default.forwardRef(
945
+ function QRCodeCanvas2(props, forwardedRef) {
946
+ const _a = props, {
947
+ value,
948
+ size = DEFAULT_SIZE,
949
+ level = DEFAULT_LEVEL,
950
+ bgColor = DEFAULT_BGCOLOR,
951
+ fgColor = DEFAULT_FGCOLOR,
952
+ includeMargin = DEFAULT_INCLUDEMARGIN,
953
+ minVersion = DEFAULT_MINVERSION,
954
+ boostLevel,
955
+ marginSize,
956
+ imageSettings
957
+ } = _a, extraProps = __objRest(_a, [
958
+ "value",
959
+ "size",
960
+ "level",
961
+ "bgColor",
962
+ "fgColor",
963
+ "includeMargin",
964
+ "minVersion",
965
+ "boostLevel",
966
+ "marginSize",
967
+ "imageSettings"
968
+ ]);
969
+ const _b = extraProps, { style } = _b, otherProps = __objRest(_b, ["style"]);
970
+ const imgSrc = imageSettings == null ? void 0 : imageSettings.src;
971
+ const _canvas = import_react2.default.useRef(null);
972
+ const _image = import_react2.default.useRef(null);
973
+ const setCanvasRef = import_react2.default.useCallback(
974
+ (node) => {
975
+ _canvas.current = node;
976
+ if (typeof forwardedRef === "function") {
977
+ forwardedRef(node);
978
+ } else if (forwardedRef) {
979
+ forwardedRef.current = node;
980
+ }
981
+ },
982
+ [forwardedRef]
983
+ );
984
+ const [isImgLoaded, setIsImageLoaded] = import_react2.default.useState(false);
985
+ const { margin, cells, numCells, calculatedImageSettings } = useQRCode({
986
+ value,
987
+ level,
988
+ minVersion,
989
+ boostLevel,
990
+ includeMargin,
991
+ marginSize,
992
+ imageSettings,
993
+ size
994
+ });
995
+ import_react2.default.useEffect(() => {
996
+ if (_canvas.current != null) {
997
+ const canvas = _canvas.current;
998
+ const ctx = canvas.getContext("2d");
999
+ if (!ctx) {
1000
+ return;
1001
+ }
1002
+ let cellsToDraw = cells;
1003
+ const image = _image.current;
1004
+ const haveImageToRender = calculatedImageSettings != null && image !== null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0;
1005
+ if (haveImageToRender) {
1006
+ if (calculatedImageSettings.excavation != null) {
1007
+ cellsToDraw = excavateModules(
1008
+ cells,
1009
+ calculatedImageSettings.excavation
1010
+ );
1011
+ }
1012
+ }
1013
+ const pixelRatio = window.devicePixelRatio || 1;
1014
+ canvas.height = canvas.width = size * pixelRatio;
1015
+ const scale = size / numCells * pixelRatio;
1016
+ ctx.scale(scale, scale);
1017
+ ctx.fillStyle = bgColor;
1018
+ ctx.fillRect(0, 0, numCells, numCells);
1019
+ ctx.fillStyle = fgColor;
1020
+ if (SUPPORTS_PATH2D) {
1021
+ ctx.fill(new Path2D(generatePath(cellsToDraw, margin)));
1022
+ } else {
1023
+ cells.forEach(function(row, rdx) {
1024
+ row.forEach(function(cell, cdx) {
1025
+ if (cell) {
1026
+ ctx.fillRect(cdx + margin, rdx + margin, 1, 1);
1027
+ }
1028
+ });
1029
+ });
1030
+ }
1031
+ if (calculatedImageSettings) {
1032
+ ctx.globalAlpha = calculatedImageSettings.opacity;
1033
+ }
1034
+ if (haveImageToRender) {
1035
+ ctx.drawImage(
1036
+ image,
1037
+ calculatedImageSettings.x + margin,
1038
+ calculatedImageSettings.y + margin,
1039
+ calculatedImageSettings.w,
1040
+ calculatedImageSettings.h
1041
+ );
1042
+ }
1043
+ }
1044
+ });
1045
+ import_react2.default.useEffect(() => {
1046
+ setIsImageLoaded(false);
1047
+ }, [imgSrc]);
1048
+ const canvasStyle = __spreadValues({ height: size, width: size }, style);
1049
+ let img = null;
1050
+ if (imgSrc != null) {
1051
+ img = /* @__PURE__ */ import_react2.default.createElement(
1052
+ "img",
1053
+ {
1054
+ src: imgSrc,
1055
+ key: imgSrc,
1056
+ style: { display: "none" },
1057
+ onLoad: () => {
1058
+ setIsImageLoaded(true);
1059
+ },
1060
+ ref: _image,
1061
+ crossOrigin: calculatedImageSettings == null ? void 0 : calculatedImageSettings.crossOrigin
1062
+ }
1063
+ );
1064
+ }
1065
+ return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(
1066
+ "canvas",
1067
+ __spreadValues({
1068
+ style: canvasStyle,
1069
+ height: size,
1070
+ width: size,
1071
+ ref: setCanvasRef,
1072
+ role: "img"
1073
+ }, otherProps)
1074
+ ), img);
1075
+ }
1076
+ );
1077
+ QRCodeCanvas.displayName = "QRCodeCanvas";
1078
+ var QRCodeSVG = import_react2.default.forwardRef(
1079
+ function QRCodeSVG2(props, forwardedRef) {
1080
+ const _a = props, {
1081
+ value,
1082
+ size = DEFAULT_SIZE,
1083
+ level = DEFAULT_LEVEL,
1084
+ bgColor = DEFAULT_BGCOLOR,
1085
+ fgColor = DEFAULT_FGCOLOR,
1086
+ includeMargin = DEFAULT_INCLUDEMARGIN,
1087
+ minVersion = DEFAULT_MINVERSION,
1088
+ boostLevel,
1089
+ title,
1090
+ marginSize,
1091
+ imageSettings
1092
+ } = _a, otherProps = __objRest(_a, [
1093
+ "value",
1094
+ "size",
1095
+ "level",
1096
+ "bgColor",
1097
+ "fgColor",
1098
+ "includeMargin",
1099
+ "minVersion",
1100
+ "boostLevel",
1101
+ "title",
1102
+ "marginSize",
1103
+ "imageSettings"
1104
+ ]);
1105
+ const { margin, cells, numCells, calculatedImageSettings } = useQRCode({
1106
+ value,
1107
+ level,
1108
+ minVersion,
1109
+ boostLevel,
1110
+ includeMargin,
1111
+ marginSize,
1112
+ imageSettings,
1113
+ size
1114
+ });
1115
+ let cellsToDraw = cells;
1116
+ let image = null;
1117
+ if (imageSettings != null && calculatedImageSettings != null) {
1118
+ if (calculatedImageSettings.excavation != null) {
1119
+ cellsToDraw = excavateModules(
1120
+ cells,
1121
+ calculatedImageSettings.excavation
1122
+ );
1123
+ }
1124
+ image = /* @__PURE__ */ import_react2.default.createElement(
1125
+ "image",
1126
+ {
1127
+ href: imageSettings.src,
1128
+ height: calculatedImageSettings.h,
1129
+ width: calculatedImageSettings.w,
1130
+ x: calculatedImageSettings.x + margin,
1131
+ y: calculatedImageSettings.y + margin,
1132
+ preserveAspectRatio: "none",
1133
+ opacity: calculatedImageSettings.opacity,
1134
+ crossOrigin: calculatedImageSettings.crossOrigin
1135
+ }
1136
+ );
1137
+ }
1138
+ const fgPath = generatePath(cellsToDraw, margin);
1139
+ return /* @__PURE__ */ import_react2.default.createElement(
1140
+ "svg",
1141
+ __spreadValues({
1142
+ height: size,
1143
+ width: size,
1144
+ viewBox: `0 0 ${numCells} ${numCells}`,
1145
+ ref: forwardedRef,
1146
+ role: "img"
1147
+ }, otherProps),
1148
+ !!title && /* @__PURE__ */ import_react2.default.createElement("title", null, title),
1149
+ /* @__PURE__ */ import_react2.default.createElement(
1150
+ "path",
1151
+ {
1152
+ fill: bgColor,
1153
+ d: `M0,0 h${numCells}v${numCells}H0z`,
1154
+ shapeRendering: "crispEdges"
1155
+ }
1156
+ ),
1157
+ /* @__PURE__ */ import_react2.default.createElement("path", { fill: fgColor, d: fgPath, shapeRendering: "crispEdges" }),
1158
+ image
1159
+ );
1160
+ }
1161
+ );
1162
+ QRCodeSVG.displayName = "QRCodeSVG";
1163
+
1164
+ // src/client.css
1165
+ var client_default = '.dsh-partner-sidebar,\n.dsh-partner-workspace {\n --partner-accent: #547d78;\n --partner-accent-strong: #3f6964;\n --partner-danger: #9a5752;\n --partner-border: color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent);\n --partner-surface: var(--xiaohei-plugin-pane-fill, transparent);\n --partner-pane: var(--xiaohei-plugin-pane-fill, var(--partner-surface));\n --partner-raised: var(--xiaohei-plugin-raised-fill, color-mix(in srgb, var(--dsw-alias-bg-layer-2, #fff) 76%, transparent));\n --partner-control: var(--xiaohei-plugin-control-fill, var(--partner-raised));\n color: var(--dsw-alias-label-primary);\n font-family: var(--ds-font-family);\n}\n\n.dsh-partner-sidebar { box-sizing: border-box; flex: none; margin: 0 8px 8px 2px; padding: 4px 0 7px; border-bottom: 1px solid color-mix(in srgb, var(--dsw-alias-border-l2) 62%, transparent); }\n.dsh-partner-sidebar.is-rail { width: 36px; margin: 0 0 8px; padding: 0; border: 0; }\n.dsh-partner-sidebar-heading { display: flex; align-items: center; justify-content: space-between; height: 32px; padding: 0 4px 0 5px; }\n.dsh-partner-sidebar-title { display: flex; min-width: 0; align-items: center; gap: 5px; height: 28px; padding: 0 5px; border: 0; border-radius: 7px; color: var(--dsw-alias-label-secondary); background: transparent; font: 600 12px/1 var(--ds-font-family); cursor: pointer; }\n.dsh-partner-sidebar-title > span { display: grid; place-items: center; transition: transform .16s ease; }\n.dsh-partner-sidebar-title > span[data-open="false"] { transform: rotate(-90deg); }\n.dsh-partner-sidebar-title:hover,\n.dsh-partner-sidebar-open:hover,\n.dsh-partner-rail:hover { color: var(--dsw-alias-label-primary); background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-partner-sidebar-open { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px; color: var(--dsw-alias-label-secondary); background: transparent; cursor: pointer; }\n.dsh-partner-sidebar-list { display: grid; gap: 2px; padding: 2px 1px 0; }\n.dsh-partner-sidebar-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) 7px; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 4px 7px; border: 1px solid transparent; border-radius: 9px; color: inherit; background: transparent; text-align: left; cursor: pointer; }\n.dsh-partner-sidebar-row:hover { background: color-mix(in srgb, var(--dsw-alias-interactive-bg-hover) 70%, transparent); }\n.dsh-partner-sidebar-row.is-active { border-color: color-mix(in srgb, var(--partner-accent) 10%, transparent); background: color-mix(in srgb, var(--partner-accent) 8%, transparent); }\n.dsh-partner-sidebar-row > span:nth-child(2) { display: grid; min-width: 0; gap: 2px; }\n.dsh-partner-sidebar-row strong,\n.dsh-partner-sidebar-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.dsh-partner-sidebar-row strong { font-size: 13px; font-weight: 520; }\n.dsh-partner-sidebar-row small { color: var(--dsw-alias-label-tertiary); font-size: 10px; }\n.dsh-partner-sidebar-row > i,\n.dsh-partner-roster-list button > i { width: 6px; height: 6px; border: 1px solid var(--dsw-alias-label-tertiary); border-radius: 50%; }\n.dsh-partner-sidebar-row > i.is-online,\n.dsh-partner-roster-list button > i.is-online { border-color: #5c9184; background: #5c9184; box-shadow: 0 0 0 2px color-mix(in srgb, #5c9184 12%, transparent); }\n.dsh-partner-sidebar-symbol { display: grid !important; place-items: center; width: 25px; height: 25px; border-radius: 8px; color: var(--partner-accent-strong); background: color-mix(in srgb, var(--partner-accent) 8%, transparent); }\n.dsh-partner-sidebar-empty { margin: 5px 9px; color: var(--dsw-alias-label-tertiary); font-size: 11px; }\n.dsh-partner-rail { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 10px; color: var(--dsw-alias-label-primary); background: transparent; cursor: pointer; }\n.dsh-partner-rail.is-active { background: var(--dsw-alias-interactive-bg-hover); }\n\n.dsh-partner-avatar { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border: 1px solid color-mix(in srgb, var(--partner-accent) 18%, var(--partner-border)); border-radius: 12px; color: var(--partner-accent-strong); background: color-mix(in srgb, var(--partner-accent) 9%, var(--partner-raised)); font-size: 13px; font-weight: 650; }\n.dsh-partner-avatar.is-small { width: 25px; height: 25px; border-radius: 8px; font-size: 10px; }\n\n.dsh-partner-workspace { position: relative; display: grid; grid-template-rows: 52px minmax(0, 1fr); width: 100%; height: 100%; min-width: 0; overflow: hidden; background: var(--partner-surface); }\n.dsh-partner-topbar { display: flex; align-items: center; justify-content: space-between; padding: 0 16px 0 18px; border-bottom: 1px solid var(--partner-border); background: var(--partner-pane, var(--partner-surface)); }\n.dsh-partner-topbar > div { display: flex; align-items: center; gap: 10px; }\n.dsh-partner-topbar > div > span:last-child { display: grid; gap: 2px; }\n.dsh-partner-topbar strong { font-size: 13px; font-weight: 620; }\n.dsh-partner-topbar small { color: var(--dsw-alias-label-tertiary); font-size: 10px; }\n.dsh-partner-topbar > button { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 9px; color: var(--dsw-alias-label-secondary); background: transparent; cursor: pointer; }\n.dsh-partner-topbar > button:hover { color: var(--dsw-alias-label-primary); background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-partner-grid { display: grid; grid-template-columns: 206px minmax(520px, 1fr); min-width: 0; min-height: 0; }\n\n.dsh-partner-roster { display: flex; min-width: 0; min-height: 0; flex-direction: column; padding: 20px 10px 14px; border-right: 1px solid var(--partner-border); background: color-mix(in srgb, var(--partner-raised) 94%, var(--partner-surface)); }\n.dsh-partner-roster-title { display: flex; align-items: flex-start; justify-content: space-between; padding: 0 5px 13px; }\n.dsh-partner-roster-title > span { display: grid; gap: 5px; }\n.dsh-partner-roster-title small,\n.dsh-partner-section > small,\n.dsh-partner-identity small,\n.dsh-partner-channel-card small,\n.dsh-partner-pairing-heading small,\n.dsh-partner-qr small { color: var(--partner-accent); font-size: 9px; font-weight: 700; letter-spacing: .12em; }\n.dsh-partner-roster-title strong { font-size: 14px; font-weight: 640; }\n.dsh-partner-roster-title button { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--partner-border); border-radius: 9px; color: var(--dsw-alias-label-secondary); background: var(--partner-control); cursor: pointer; }\n.dsh-partner-roster-title button:hover { color: var(--partner-accent-strong); border-color: color-mix(in srgb, var(--partner-accent) 28%, transparent); }\n.dsh-partner-roster-list { display: grid; gap: 3px; overflow: auto; }\n.dsh-partner-roster-list button { display: grid; grid-template-columns: 36px minmax(0, 1fr) 7px; align-items: center; gap: 9px; width: 100%; min-height: 58px; padding: 9px 8px; border: 1px solid transparent; border-radius: 12px; color: inherit; background: transparent; text-align: left; cursor: pointer; transition: transform .17s cubic-bezier(.2,.8,.2,1), background .15s ease, border-color .15s ease; }\n.dsh-partner-roster-list button:hover { background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-partner-roster-list button.is-active { transform: translateX(2px); border-color: color-mix(in srgb, var(--partner-accent) 13%, transparent); background: color-mix(in srgb, var(--partner-accent) 8%, transparent); }\n.dsh-partner-roster-list button > span:nth-child(2) { display: grid; min-width: 0; gap: 3px; }\n.dsh-partner-roster-list strong,\n.dsh-partner-roster-list small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.dsh-partner-roster-list strong { font-size: 13px; font-weight: 580; }\n.dsh-partner-roster-list small { color: var(--dsw-alias-label-tertiary); font-size: 10px; }\n.dsh-partner-roster-note { display: flex; align-items: flex-start; gap: 9px; margin-top: auto; padding: 12px 8px 2px; color: var(--dsw-alias-label-tertiary); }\n.dsh-partner-roster-note > svg { flex: none; margin-top: 1px; color: var(--partner-accent); }\n.dsh-partner-roster-note > span { display: grid; gap: 4px; }\n.dsh-partner-roster-note strong { color: var(--dsw-alias-label-secondary); font-size: 11px; font-weight: 580; }\n.dsh-partner-roster-note small { font-size: 10px; line-height: 1.5; }\n\n.dsh-partner-stage { position: relative; display: grid; grid-template-rows: auto auto minmax(0, 1fr); min-width: 0; min-height: 0; background: radial-gradient(circle at 92% 3%, color-mix(in srgb, var(--partner-accent) 4%, transparent), transparent 30%), var(--partner-surface); }\n.dsh-partner-identity { display: flex; align-items: center; gap: 12px; min-height: 86px; padding: 18px clamp(20px, 4vw, 46px) 13px; }\n.dsh-partner-identity > span:nth-child(2) { display: grid; min-width: 0; flex: 1; gap: 3px; }\n.dsh-partner-identity h1 { margin: 0; font-size: 21px; line-height: 1.15; font-weight: 650; letter-spacing: -.025em; }\n.dsh-partner-identity p { margin: 0; overflow: hidden; color: var(--dsw-alias-label-secondary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }\n.dsh-partner-status { display: inline-flex; align-items: center; flex: none; gap: 6px; padding: 5px 8px; border: 1px solid var(--partner-border); border-radius: 999px; color: var(--dsw-alias-label-secondary); background: color-mix(in srgb, var(--partner-raised) 76%, transparent); font-size: 10px; }\n.dsh-partner-status > i { width: 6px; height: 6px; border-radius: 50%; background: var(--dsw-alias-label-tertiary); }\n.dsh-partner-status.is-running > i { background: #5c9184; box-shadow: 0 0 0 2px color-mix(in srgb, #5c9184 13%, transparent); }\n.dsh-partner-status.is-starting > i { background: #9a8158; }\n.dsh-partner-status.is-error > i { background: var(--partner-danger); }\n.dsh-partner-tabs { display: flex; align-items: center; gap: 3px; margin: 0 clamp(20px, 4vw, 46px); border-bottom: 1px solid var(--partner-border); }\n.dsh-partner-tabs button { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 37px; padding: 0 10px; border: 0; color: var(--dsw-alias-label-tertiary); background: transparent; font-size: 12px; cursor: pointer; }\n.dsh-partner-tabs button::after { content: ""; position: absolute; right: 9px; bottom: -1px; left: 9px; height: 2px; border-radius: 99px; background: var(--partner-accent); opacity: 0; transform: scaleX(.5); transition: opacity .15s ease, transform .18s cubic-bezier(.2,.8,.2,1); }\n.dsh-partner-tabs button:hover { color: var(--dsw-alias-label-primary); }\n.dsh-partner-tabs button.is-active { color: var(--partner-accent-strong); }\n.dsh-partner-tabs button.is-active::after { opacity: 1; transform: scaleX(1); }\n.dsh-partner-stage-scroll { min-width: 0; min-height: 0; overflow: auto; padding: 26px clamp(22px, 4vw, 52px) 52px; }\n\n.dsh-partner-home { width: min(100%, 980px); margin: 0 auto; }\n.dsh-partner-home-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin: 0 2px 22px; }\n.dsh-partner-home-heading > span { display: grid; gap: 6px; }\n.dsh-partner-home-heading small { color: var(--partner-accent); font-size: 10px; font-weight: 700; letter-spacing: .08em; }\n.dsh-partner-home-heading h2 { margin: 0; font-size: clamp(22px, 2.2vw, 28px); line-height: 1.18; font-weight: 660; letter-spacing: -.035em; }\n.dsh-partner-home-heading p { max-width: 320px; margin: 0 0 2px; color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 1.55; text-align: right; }\n.dsh-partner-home-channel { position: relative; display: grid; grid-template-columns: minmax(230px, .8fr) minmax(330px, 1.2fr); align-items: center; min-height: 238px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--partner-accent) 13%, var(--partner-border)); border-radius: 20px; background: linear-gradient(110deg, color-mix(in srgb, var(--partner-accent) 7%, var(--partner-raised)) 0%, var(--partner-raised) 53%, color-mix(in srgb, var(--partner-raised) 96%, transparent) 100%); box-shadow: 0 18px 50px color-mix(in srgb, var(--partner-accent-strong) 5%, transparent); }\n.dsh-partner-home-channel::after { content: ""; position: absolute; right: -84px; bottom: -118px; width: 260px; height: 260px; border: 1px solid color-mix(in srgb, var(--partner-accent) 8%, transparent); border-radius: 50%; box-shadow: 0 0 0 34px color-mix(in srgb, var(--partner-accent) 2.5%, transparent), 0 0 0 78px color-mix(in srgb, var(--partner-accent) 1.5%, transparent); pointer-events: none; }\n.dsh-partner-home-route { position: relative; display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 28px; background: radial-gradient(circle at 42% 50%, color-mix(in srgb, var(--partner-accent) 9%, transparent), transparent 56%); }\n.dsh-partner-home-route > .dsh-partner-avatar { position: relative; z-index: 1; width: 58px; height: 58px; border-radius: 18px; background: var(--partner-raised); box-shadow: 0 9px 28px color-mix(in srgb, var(--partner-accent-strong) 10%, transparent); font-size: 19px; }\n.dsh-partner-route-line { position: relative; width: clamp(58px, 7vw, 94px); height: 1px; margin: 0 10px; overflow: hidden; background: repeating-linear-gradient(90deg, color-mix(in srgb, var(--partner-accent) 25%, transparent) 0 4px, transparent 4px 9px); }\n.dsh-partner-route-line > i { position: absolute; left: 0; top: -2px; width: 5px; height: 5px; border-radius: 50%; background: var(--partner-accent); opacity: 0; transform: translateX(0); }\n.dsh-partner-home-channel.is-online .dsh-partner-route-line > i { animation: dsh-partner-route-pulse 2.4s ease-in-out infinite; }\n.dsh-partner-route-weixin { position: relative; z-index: 1; display: grid; place-items: center; width: 58px; height: 58px; border: 1px solid color-mix(in srgb, #538b72 20%, var(--partner-border)); border-radius: 18px; color: #4f836b; background: var(--partner-raised); box-shadow: 0 9px 28px color-mix(in srgb, #46735f 9%, transparent); }\n.dsh-partner-home-channel-copy { position: relative; z-index: 1; display: grid; justify-items: start; gap: 8px; padding: 32px 36px 32px 12px; }\n.dsh-partner-home-kicker { display: inline-flex; align-items: center; gap: 7px; color: var(--partner-accent-strong); font-size: 10px; font-weight: 680; letter-spacing: .06em; }\n.dsh-partner-home-kicker > i { width: 6px; height: 6px; border-radius: 50%; background: var(--dsw-alias-label-tertiary); }\n.dsh-partner-home-channel.is-online .dsh-partner-home-kicker > i { background: #5c9184; box-shadow: 0 0 0 3px color-mix(in srgb, #5c9184 11%, transparent); }\n.dsh-partner-home-channel-copy h3 { margin: 1px 0 0; font-size: 19px; line-height: 1.28; font-weight: 650; letter-spacing: -.025em; }\n.dsh-partner-home-channel-copy p { max-width: 510px; margin: 0; color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 1.65; }\n.dsh-partner-home-channel-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 7px; }\n.dsh-partner-home-channel-actions button { min-height: 36px; padding: 0 15px; border: 1px solid var(--partner-accent-strong); border-radius: 10px; color: #fff; background: var(--partner-accent-strong); font: 600 12px/1 var(--ds-font-family); cursor: pointer; transition: transform .16s ease, background .16s ease; }\n.dsh-partner-home-channel-actions button:hover { background: color-mix(in srgb, var(--partner-accent-strong) 88%, #000); transform: translateY(-1px); }\n.dsh-partner-home-channel-actions button:active { transform: translateY(0) scale(.98); }\n.dsh-partner-home-channel-actions span { color: var(--dsw-alias-label-tertiary); font-size: 10px; }\n.dsh-partner-home-details { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(260px, .82fr); gap: 0 28px; margin-top: 20px; }\n.dsh-partner-home-details > section { min-width: 0; padding: 20px 2px; border-bottom: 1px solid var(--partner-border); }\n.dsh-partner-home-profile { grid-row: span 2; padding-right: 28px !important; border-right: 1px solid var(--partner-border); }\n.dsh-partner-home-details header { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; }\n.dsh-partner-home-details header > span { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; color: var(--partner-accent-strong); background: color-mix(in srgb, var(--partner-accent) 7%, transparent); }\n.dsh-partner-home-details header > div { display: grid; min-width: 0; gap: 3px; }\n.dsh-partner-home-details header small { color: var(--dsw-alias-label-tertiary); font-size: 10px; }\n.dsh-partner-home-details header strong { overflow: hidden; font-size: 13px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }\n.dsh-partner-home-details header button { padding: 5px 7px; border: 0; border-radius: 7px; color: var(--dsw-alias-label-tertiary); background: transparent; font: 560 10px/1 var(--ds-font-family); cursor: pointer; }\n.dsh-partner-home-details header button:hover { color: var(--partner-accent-strong); background: color-mix(in srgb, var(--partner-accent) 6%, transparent); }\n.dsh-partner-home-profile blockquote { display: -webkit-box; margin: 17px 2px 0 44px; overflow: hidden; color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 1.7; -webkit-box-orient: vertical; -webkit-line-clamp: 5; }\n.dsh-partner-home-capability-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0 44px; }\n.dsh-partner-home-capability-list em { padding: 5px 8px; border-radius: 7px; color: var(--partner-accent-strong); background: color-mix(in srgb, var(--partner-accent) 7%, transparent); font-size: 10px; font-style: normal; }\n.dsh-partner-home-capability-list small,\n.dsh-partner-home-continuity > p { margin: 13px 0 0 44px; color: var(--dsw-alias-label-tertiary); font-size: 10px; line-height: 1.55; }\n@keyframes dsh-partner-route-pulse { 0% { opacity: 0; transform: translateX(0); } 18% { opacity: .8; } 82% { opacity: .8; } 100% { opacity: 0; transform: translateX(clamp(58px, 7vw, 94px)); } }\n\n.dsh-partner-form { width: min(100%, 760px); margin: 0 auto; }\n.dsh-partner-section { margin-bottom: 23px; }\n.dsh-partner-section h2 { margin: 5px 0 6px; font-size: 19px; font-weight: 640; letter-spacing: -.02em; }\n.dsh-partner-section p { max-width: 640px; margin: 0; color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 1.65; }\n.dsh-partner-fields { display: grid; gap: 14px; }\n.dsh-partner-fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }\n.dsh-partner-field { display: grid; gap: 8px; margin-bottom: 16px; }\n.dsh-partner-field > span { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }\n.dsh-partner-field strong { font-size: 12px; font-weight: 610; }\n.dsh-partner-field small { color: var(--dsw-alias-label-tertiary); font-size: 10px; line-height: 1.35; text-align: right; }\n.dsh-partner-field input,\n.dsh-partner-field textarea,\n.dsh-partner-field select { box-sizing: border-box; width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--partner-border); border-radius: 10px; outline: none; color: var(--dsw-alias-label-primary); background: var(--partner-control); font: 13px/1.5 var(--ds-font-family); transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; }\n.dsh-partner-field textarea { resize: vertical; }\n.dsh-partner-field input:focus,\n.dsh-partner-field textarea:focus,\n.dsh-partner-field select:focus { border-color: color-mix(in srgb, var(--partner-accent) 54%, transparent); background: var(--partner-raised); box-shadow: 0 0 0 3px color-mix(in srgb, var(--partner-accent) 8%, transparent); }\n.dsh-partner-form-actions { display: flex; align-items: center; justify-content: space-between; min-height: 40px; padding-top: 5px; }\n.dsh-partner-form-actions > span { display: inline-flex; align-items: center; gap: 5px; color: var(--partner-accent-strong); font-size: 11px; }\n.dsh-partner-form-actions > button,\n.dsh-partner-state > button,\n.dsh-partner-weixin-connect > button { min-height: 34px; padding: 0 15px; border: 1px solid color-mix(in srgb, var(--partner-accent) 60%, transparent); border-radius: 10px; color: #fff; background: var(--partner-accent-strong); font: 600 12px/1 var(--ds-font-family); cursor: pointer; }\n.dsh-partner-form-actions > button:hover,\n.dsh-partner-state > button:hover,\n.dsh-partner-weixin-connect > button:hover { background: color-mix(in srgb, var(--partner-accent-strong) 88%, #000); }\n.dsh-partner-form-actions > button:disabled,\n.dsh-partner-weixin-connect > button:disabled { opacity: .55; cursor: default; }\n.dsh-partner-identity-danger { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 34px; padding-top: 17px; border-top: 1px solid var(--partner-border); }\n.dsh-partner-identity-danger > span { display: grid; gap: 4px; }\n.dsh-partner-identity-danger strong { font-size: 11px; font-weight: 600; }\n.dsh-partner-identity-danger small { color: var(--dsw-alias-label-tertiary); font-size: 9px; }\n.dsh-partner-identity-danger button { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 10px; border: 1px solid color-mix(in srgb, var(--partner-danger) 24%, transparent); border-radius: 8px; color: var(--partner-danger); background: transparent; font-size: 10px; cursor: pointer; }\n.dsh-partner-identity-danger button:disabled { opacity: .4; cursor: default; }\n.dsh-partner-inline-error,\n.dsh-partner-error { padding: 9px 11px; border: 1px solid color-mix(in srgb, var(--partner-danger) 20%, transparent); border-radius: 9px; color: var(--partner-danger); background: color-mix(in srgb, var(--partner-danger) 6%, transparent); font-size: 11px; }\n.dsh-partner-error { position: absolute; right: 18px; bottom: 14px; left: 18px; margin: 0; }\n\n.dsh-partner-capabilities { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 3px 0 20px; }\n.dsh-partner-capabilities button { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 3px 9px; min-height: 78px; padding: 13px; border: 1px solid var(--partner-border); border-radius: 12px; color: inherit; background: color-mix(in srgb, var(--partner-raised) 70%, transparent); text-align: left; cursor: pointer; }\n.dsh-partner-capabilities button:hover { border-color: color-mix(in srgb, var(--partner-accent) 24%, transparent); background: var(--partner-raised); }\n.dsh-partner-capabilities button.is-active { border-color: color-mix(in srgb, var(--partner-accent) 30%, transparent); background: color-mix(in srgb, var(--partner-accent) 7%, var(--partner-raised)); }\n.dsh-partner-capabilities button > span { display: grid; place-items: center; grid-row: 1 / span 2; width: 19px; height: 19px; margin-top: 1px; border: 1px solid var(--partner-border); border-radius: 6px; color: #fff; }\n.dsh-partner-capabilities button.is-active > span { border-color: var(--partner-accent); background: var(--partner-accent); }\n.dsh-partner-capabilities strong { font-size: 12px; font-weight: 610; }\n.dsh-partner-capabilities small { color: var(--dsw-alias-label-tertiary); font-size: 10px; line-height: 1.5; }\n\n.dsh-partner-weixin-connect { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; align-items: center; gap: 17px; padding: 19px; border: 1px solid var(--partner-border); border-radius: 15px; background: color-mix(in srgb, var(--partner-raised) 72%, transparent); }\n.dsh-partner-weixin-connect > span { display: grid; gap: 4px; }\n.dsh-partner-weixin-connect strong { font-size: 14px; }\n.dsh-partner-weixin-connect p { margin: 0; color: var(--dsw-alias-label-secondary); font-size: 11px; line-height: 1.55; }\n.dsh-partner-weixin-connect ul { display: flex; flex-wrap: wrap; gap: 6px 15px; margin: 7px 0 0; padding: 0; color: var(--dsw-alias-label-tertiary); font-size: 10px; list-style: none; }\n.dsh-partner-weixin-connect li::before { content: "\xB7"; margin-right: 4px; color: var(--partner-accent); }\n.dsh-partner-weixin-mark { display: grid; place-items: center; width: 52px; height: 52px; border: 1px solid color-mix(in srgb, #5a9176 18%, var(--partner-border)); border-radius: 16px; color: #568b72; background: color-mix(in srgb, #5a9176 7%, var(--partner-raised)); }\n.dsh-partner-weixin-glyph { position: relative; display: inline-block; width: 16px; height: 14px; }\n.dsh-partner-weixin-glyph::before,\n.dsh-partner-weixin-glyph::after { content: ""; position: absolute; border: 1.5px solid currentColor; border-radius: 48%; }\n.dsh-partner-weixin-glyph::before { left: 0; top: 0; width: 10px; height: 8px; }\n.dsh-partner-weixin-glyph::after { right: 0; bottom: 0; width: 9px; height: 7px; background: inherit; }\n.dsh-partner-weixin-glyph i,\n.dsh-partner-weixin-glyph b { position: absolute; z-index: 1; top: 4px; width: 1.5px; height: 1.5px; border-radius: 50%; background: currentColor; }\n.dsh-partner-weixin-glyph i { left: 3px; }\n.dsh-partner-weixin-glyph b { left: 7px; }\n.dsh-partner-weixin-glyph.is-large { transform: scale(1.55); }\n.dsh-partner-qr { display: grid; grid-template-columns: 206px minmax(0, 1fr); align-items: center; gap: 27px; padding: 22px; border: 1px solid var(--partner-border); border-radius: 16px; background: color-mix(in srgb, var(--partner-raised) 74%, transparent); }\n.dsh-partner-qr-code { display: grid; place-items: center; width: 196px; height: 196px; border-radius: 14px; background: #fff; box-shadow: 0 9px 28px color-mix(in srgb, #000 7%, transparent); }\n.dsh-partner-qr > span { display: grid; justify-items: start; gap: 7px; }\n.dsh-partner-qr strong { font-size: 17px; }\n.dsh-partner-qr p { max-width: 300px; margin: 0; color: var(--dsw-alias-label-secondary); font-size: 11px; line-height: 1.6; }\n.dsh-partner-qr button { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 11px; border: 1px solid var(--partner-border); border-radius: 9px; color: inherit; background: var(--partner-raised); cursor: pointer; }\n.dsh-partner-channel-card { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 15px; border: 1px solid var(--partner-border); border-radius: 14px; background: color-mix(in srgb, var(--partner-raised) 72%, transparent); }\n.dsh-partner-channel-card > span:nth-child(2) { display: grid; gap: 3px; }\n.dsh-partner-channel-card strong { font-size: 13px; }\n.dsh-partner-channel-card p { margin: 0; color: var(--dsw-alias-label-tertiary); font: 10px/1.4 ui-monospace, monospace; }\n.dsh-partner-switch { position: relative; width: 38px; height: 22px; padding: 0; border: 1px solid var(--partner-border); border-radius: 999px; background: color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent); cursor: pointer; transition: background .16s ease; }\n.dsh-partner-switch i { position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--partner-raised); box-shadow: 0 1px 3px color-mix(in srgb, #000 16%, transparent); transition: transform .18s cubic-bezier(.2,.8,.2,1); }\n.dsh-partner-switch[data-on="true"] { background: var(--partner-accent); }\n.dsh-partner-switch[data-on="true"] i { transform: translateX(16px); }\n.dsh-partner-pairing-heading { display: flex; align-items: end; justify-content: space-between; margin: 25px 1px 10px; }\n.dsh-partner-pairing-heading > span { display: grid; gap: 4px; }\n.dsh-partner-pairing-heading strong { font-size: 14px; }\n.dsh-partner-pairing-heading em { color: var(--dsw-alias-label-tertiary); font-size: 10px; font-style: normal; }\n.dsh-partner-pairings { display: grid; gap: 5px; }\n.dsh-partner-pairings article { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; align-items: center; gap: 9px; min-height: 52px; padding: 8px 9px; border-bottom: 1px solid var(--partner-border); }\n.dsh-partner-pairings article > span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: var(--dsw-alias-label-tertiary); background: var(--dsw-alias-interactive-bg-hover); }\n.dsh-partner-pairings article > span.is-approved { color: var(--partner-accent-strong); background: color-mix(in srgb, var(--partner-accent) 9%, transparent); }\n.dsh-partner-pairings article > div { display: grid; gap: 3px; }\n.dsh-partner-pairings strong { font-size: 12px; }\n.dsh-partner-pairings small { color: var(--dsw-alias-label-tertiary); font-size: 10px; }\n.dsh-partner-pairings button { min-height: 29px; padding: 0 10px; border: 1px solid var(--partner-border); border-radius: 8px; color: var(--dsw-alias-label-secondary); background: transparent; font-size: 10px; cursor: pointer; }\n.dsh-partner-pairings button.is-primary { color: #fff; border-color: var(--partner-accent); background: var(--partner-accent-strong); }\n\n.dsh-partner-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }\n.dsh-partner-metrics article { padding: 14px; border: 1px solid var(--partner-border); border-radius: 12px; background: color-mix(in srgb, var(--partner-raised) 66%, transparent); }\n.dsh-partner-metrics small { color: var(--dsw-alias-label-tertiary); font-size: 10px; }\n.dsh-partner-metrics strong { display: block; margin: 8px 0 4px; font-size: 17px; font-weight: 640; }\n.dsh-partner-metrics p { margin: 0; color: var(--dsw-alias-label-tertiary); font-size: 9px; }\n.dsh-partner-session-list { display: grid; gap: 4px; margin-top: 20px; }\n.dsh-partner-session-list article { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 7px 5px; border-bottom: 1px solid var(--partner-border); }\n.dsh-partner-session-list article > span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: var(--partner-accent); background: color-mix(in srgb, var(--partner-accent) 7%, transparent); }\n.dsh-partner-session-list article > div { display: grid; min-width: 0; flex: 1; gap: 3px; }\n.dsh-partner-session-list strong { font-size: 12px; }\n.dsh-partner-session-list small { overflow: hidden; color: var(--dsw-alias-label-tertiary); font: 9px/1.4 ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }\n.dsh-partner-session-list button { flex: none; min-height: 30px; padding: 0 10px; border: 1px solid var(--partner-border); border-radius: 8px; color: var(--dsw-alias-label-secondary); background: var(--partner-control); font: 560 10px/1 var(--ds-font-family); cursor: pointer; }\n.dsh-partner-session-list button:hover { color: var(--partner-accent-strong); border-color: color-mix(in srgb, var(--partner-accent) 24%, var(--partner-border)); }\n.dsh-partner-state { display: grid; place-items: center; align-content: center; min-height: 280px; padding: 30px; color: var(--dsw-alias-label-tertiary); text-align: center; }\n.dsh-partner-state > svg { margin-bottom: 10px; color: var(--partner-accent); }\n.dsh-partner-state strong { color: var(--dsw-alias-label-secondary); font-size: 13px; }\n.dsh-partner-state p { max-width: 330px; margin: 7px 0 14px; font-size: 11px; line-height: 1.55; }\n.dsh-partner-state.is-compact { min-height: 130px; }\n\n@media (max-width: 1080px) {\n .dsh-partner-grid { grid-template-columns: 190px minmax(400px, 1fr); }\n .dsh-partner-home-channel { grid-template-columns: minmax(190px, .7fr) minmax(300px, 1.3fr); }\n .dsh-partner-home-channel-copy { padding-right: 26px; }\n}\n@media (max-width: 760px) {\n .dsh-partner-grid { grid-template-columns: 1fr; }\n .dsh-partner-roster { display: none; }\n .dsh-partner-identity { padding-inline: 16px; }\n .dsh-partner-tabs { margin-inline: 12px; overflow-x: auto; }\n .dsh-partner-tabs button { flex: none; }\n .dsh-partner-stage-scroll { padding: 19px 16px 38px; }\n .dsh-partner-fields.two,\n .dsh-partner-capabilities,\n .dsh-partner-metrics { grid-template-columns: 1fr; }\n .dsh-partner-home-heading { display: grid; gap: 8px; }\n .dsh-partner-home-heading p { text-align: left; }\n .dsh-partner-home-channel { grid-template-columns: 1fr; }\n .dsh-partner-home-route { min-height: 128px; padding-bottom: 10px; }\n .dsh-partner-home-channel-copy { padding: 12px 22px 24px; }\n .dsh-partner-home-details { grid-template-columns: 1fr; }\n .dsh-partner-home-profile { grid-row: auto; padding-right: 2px !important; border-right: 0; }\n .dsh-partner-weixin-connect { grid-template-columns: 52px 1fr; }\n .dsh-partner-weixin-connect > button { grid-column: 1 / -1; }\n .dsh-partner-qr { grid-template-columns: 1fr; justify-items: center; text-align: center; }\n .dsh-partner-qr > span { justify-items: center; }\n .dsh-partner-channel-card { grid-template-columns: 45px minmax(0, 1fr) auto; }\n .dsh-partner-channel-card > .dsh-partner-status { display: none; }\n}\n@media (prefers-reduced-motion: reduce) {\n .dsh-partner-workspace *,\n .dsh-partner-sidebar * { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }\n}\n';
1166
+
1167
+ // src/client-api.ts
1168
+ var PARTNER_API = "/partner-local/v1";
1169
+ async function api(path = "", init = {}) {
1170
+ const method = init.method ?? "GET";
1171
+ const response = await fetch(`${PARTNER_API}${path}`, {
1172
+ ...init,
1173
+ headers: {
1174
+ Accept: "application/json",
1175
+ ...method === "GET" ? {} : { "Content-Type": "application/json", "X-DSH-Partner-Request": "1" },
1176
+ ...init.headers
1177
+ }
1178
+ });
1179
+ if (response.status === 204) return void 0;
1180
+ const body = await response.json().catch(() => ({}));
1181
+ if (!response.ok) throw new Error(typeof body.error === "string" ? body.error : `HTTP ${response.status}`);
1182
+ return body;
1183
+ }
1184
+ function loadPartner() {
1185
+ return api();
1186
+ }
1187
+
1188
+ // src/sidebar-anchor.ts
1189
+ var import_react3 = require("react");
1190
+ function useWorkspaceTopAnchor(ref) {
1191
+ (0, import_react3.useEffect)(() => {
1192
+ const element = ref.current;
1193
+ const originalParent = element?.parentElement;
1194
+ if (!element || !originalParent) return;
1195
+ let moved = false;
1196
+ let observer;
1197
+ const place = () => {
1198
+ let ancestor = element.parentElement;
1199
+ while (ancestor && ancestor !== document.body) {
1200
+ const candidate = ancestor.previousElementSibling;
1201
+ if (candidate instanceof HTMLElement) {
1202
+ const style = getComputedStyle(candidate);
1203
+ if (style.display === "flex" && style.flexDirection === "column" && Number.parseFloat(style.flexGrow) > 0) {
1204
+ candidate.insertBefore(element, candidate.firstChild);
1205
+ moved = true;
1206
+ return true;
1207
+ }
1208
+ }
1209
+ ancestor = ancestor.parentElement;
1210
+ }
1211
+ return false;
1212
+ };
1213
+ if (!place()) {
1214
+ observer = new MutationObserver(() => {
1215
+ if (place()) observer?.disconnect();
1216
+ });
1217
+ observer.observe(document.body, { childList: true, subtree: true });
1218
+ }
1219
+ return () => {
1220
+ observer?.disconnect();
1221
+ if (moved && originalParent.isConnected) originalParent.append(element);
1222
+ };
1223
+ }, [ref]);
1224
+ }
1225
+
1226
+ // src/client.tsx
1227
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1228
+ var PLUGIN_ID = "@lemoncat7/dsh-partner";
1229
+ var STYLE_ID = `${PLUGIN_ID}/client`;
1230
+ var inject = ["slots", "layout", "sessions"];
1231
+ function apply(ctx) {
1232
+ ctx.effect(installStyles, "dsh-partner: styles");
1233
+ const controller = createController(ctx);
1234
+ ctx.effect(() => observePluginWorkspace(PLUGIN_ID, controller.close), "dsh-partner: exclusive workspace");
1235
+ ctx.effect(() => () => controller.close(), "dsh-partner: workspace lifecycle");
1236
+ ctx.slots.inject("sidebar.footer.action", () => ctx.slots.register({
1237
+ name: "sidebar.footer.action",
1238
+ id: "partner",
1239
+ order: -120
1240
+ }, (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PartnerSidebar, { ...props, controller, collapse: () => ctx.layout.toggleSidebar() })));
1241
+ }
1242
+ function createController(ctx) {
1243
+ const listeners = /* @__PURE__ */ new Set();
1244
+ let selected;
1245
+ let dispose;
1246
+ const notify = () => {
1247
+ for (const listener of listeners) listener();
1248
+ };
1249
+ const controller = {
1250
+ open(companionId) {
1251
+ if (companionId !== void 0) selected = companionId;
1252
+ if (dispose === void 0) {
1253
+ activatePluginWorkspace(PLUGIN_ID);
1254
+ dispose = ctx.slots.register({ name: "conversation", priority: -3 }, (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PartnerWorkspace, { ...props, controller }));
1255
+ }
1256
+ notify();
1257
+ },
1258
+ close() {
1259
+ const current = dispose;
1260
+ dispose = void 0;
1261
+ current?.();
1262
+ notify();
1263
+ },
1264
+ toggle() {
1265
+ if (dispose === void 0) controller.open();
1266
+ else controller.close();
1267
+ },
1268
+ isOpen: () => dispose !== void 0,
1269
+ selected: () => selected,
1270
+ async openSession(routeId, sessionId) {
1271
+ const prepared = await api(`/sessions/${encodeURIComponent(routeId)}/prepare`, { method: "POST" });
1272
+ if (prepared.sessionId !== sessionId) throw new Error("\u4F19\u4F34\u4F1A\u8BDD\u6807\u8BC6\u4E0D\u4E00\u81F4");
1273
+ await waitForClientSession(ctx, sessionId);
1274
+ controller.close();
1275
+ clientSessions(ctx).open(sessionId);
1276
+ },
1277
+ subscribe(listener) {
1278
+ listeners.add(listener);
1279
+ return () => listeners.delete(listener);
1280
+ }
1281
+ };
1282
+ return controller;
1283
+ }
1284
+ function PartnerSidebar(props) {
1285
+ const ref = (0, import_react4.useRef)(null);
1286
+ useWorkspaceTopAnchor(ref);
1287
+ const [open, setOpen] = (0, import_react4.useState)(true);
1288
+ const [snapshot, setSnapshot] = (0, import_react4.useState)();
1289
+ const [, update] = (0, import_react4.useState)(0);
1290
+ (0, import_react4.useEffect)(() => props.controller.subscribe(() => update((value) => value + 1)), [props.controller]);
1291
+ (0, import_react4.useEffect)(() => {
1292
+ void loadPartner().then(setSnapshot).catch(() => {
1293
+ });
1294
+ }, [props.controller.isOpen()]);
1295
+ const launch = (id) => {
1296
+ props.controller.open(id);
1297
+ if (props.wide && window.matchMedia("(max-width: 820px)").matches) props.collapse();
1298
+ };
1299
+ if (!props.wide) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("section", { ref, className: "dsh-partner-sidebar is-rail", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: `dsh-partner-rail${props.controller.isOpen() ? " is-active" : ""}`, title: "\u4F19\u4F34", onClick: () => props.controller.toggle(), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconAgentPresetOutline16, { size: 18 }) }) });
1300
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { ref, className: "dsh-partner-sidebar", children: [
1301
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-sidebar-heading", children: [
1302
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", className: "dsh-partner-sidebar-title", "aria-expanded": open, onClick: () => setOpen((value) => !value), children: [
1303
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-open": open, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconChevronDownOutline14, { size: 14 }) }),
1304
+ "\u4F19\u4F34"
1305
+ ] }),
1306
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-partner-sidebar-open", onClick: () => launch(), "aria-label": "\u6253\u5F00\u4F19\u4F34\u9762\u677F", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconPlusOutline16, { size: 16 }) })
1307
+ ] }),
1308
+ open && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-partner-sidebar-list", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", className: `dsh-partner-sidebar-row${props.controller.isOpen() ? " is-active" : ""}`, onClick: () => launch(), children: [
1309
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-partner-sidebar-symbol", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconAgentPresetOutline16, { size: 16 }) }),
1310
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
1311
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "\u4F19\u4F34\u9762\u677F" }),
1312
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: snapshot ? `${snapshot.companions.length} \u4F4D\u4F19\u4F34 \xB7 ${snapshot.channels.filter((item) => item.runtimeStatus === "running").length} \u4E2A\u5FAE\u4FE1\u5728\u7EBF` : "\u8EAB\u4EFD\u3001\u80FD\u529B\u4E0E\u6E20\u9053" })
1313
+ ] }),
1314
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("i", { className: snapshot?.channels.some((item) => item.runtimeStatus === "running") ? "is-online" : "" })
1315
+ ] }) })
1316
+ ] });
1317
+ }
1318
+ function PartnerWorkspace({ controller }) {
1319
+ const [snapshot, setSnapshot] = (0, import_react4.useState)();
1320
+ const [selectedId, setSelectedId] = (0, import_react4.useState)(controller.selected());
1321
+ const [tab, setTab] = (0, import_react4.useState)("home");
1322
+ const [error, setError] = (0, import_react4.useState)();
1323
+ const [loading, setLoading] = (0, import_react4.useState)(true);
1324
+ const refresh = (0, import_react4.useCallback)(async () => {
1325
+ try {
1326
+ const next = await loadPartner();
1327
+ setSnapshot(next);
1328
+ setSelectedId((current) => next.companions.some((item) => item.id === current) ? current : next.companions[0]?.id);
1329
+ setError(void 0);
1330
+ } catch (reason) {
1331
+ setError(message(reason));
1332
+ } finally {
1333
+ setLoading(false);
1334
+ }
1335
+ }, []);
1336
+ (0, import_react4.useEffect)(() => {
1337
+ void refresh();
1338
+ }, [refresh]);
1339
+ (0, import_react4.useEffect)(() => controller.subscribe(() => {
1340
+ const next = controller.selected();
1341
+ if (next) setSelectedId(next);
1342
+ }), [controller]);
1343
+ const selected = snapshot?.companions.find((item) => item.id === selectedId);
1344
+ const create = async () => {
1345
+ try {
1346
+ const companion = await api("/companions", { method: "POST", body: JSON.stringify({ companion: {
1347
+ name: "\u65B0\u4F19\u4F34",
1348
+ role: "\u957F\u671F AI \u5DE5\u4F5C\u4F19\u4F34",
1349
+ description: "",
1350
+ instructions: "",
1351
+ capabilities: ["knowledge", "skills"]
1352
+ } }) });
1353
+ await refresh();
1354
+ setSelectedId(companion.id);
1355
+ setTab("identity");
1356
+ } catch (reason) {
1357
+ setError(message(reason));
1358
+ }
1359
+ };
1360
+ const openSession = async (routeId, sessionId) => {
1361
+ try {
1362
+ setError(void 0);
1363
+ await controller.openSession(routeId, sessionId);
1364
+ } catch (reason) {
1365
+ setError(message(reason));
1366
+ }
1367
+ };
1368
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("main", { className: "dsh-partner-workspace", "data-xiaohei-surface": "plugin-workspace", children: [
1369
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("header", { className: "dsh-partner-topbar", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
1370
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", "data-xiaohei-workspace-close": true, onClick: controller.close, "aria-label": "\u8FD4\u56DE\u4F1A\u8BDD", title: "\u8FD4\u56DE\u4F1A\u8BDD", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconChevronLeftOutline14, { size: 15 }) }),
1371
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconAgentPresetOutline16, { size: 18 }),
1372
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
1373
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "\u4F19\u4F34" }),
1374
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u957F\u671F\u8EAB\u4EFD\u4E0E\u5FAE\u4FE1\u6E20\u9053" })
1375
+ ] })
1376
+ ] }) }),
1377
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-grid", children: [
1378
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("aside", { className: "dsh-partner-roster", children: [
1379
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-roster-title", children: [
1380
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
1381
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "COMPANIONS" }),
1382
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "\u4F19\u4F34\u540D\u518C" })
1383
+ ] }),
1384
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => {
1385
+ void create();
1386
+ }, "aria-label": "\u65B0\u5EFA\u4F19\u4F34", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconPlusOutline16, { size: 16 }) })
1387
+ ] }),
1388
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-partner-roster-list", children: snapshot?.companions.map((companion) => {
1389
+ const channel = snapshot.channels.find((item) => item.companionId === companion.id);
1390
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", className: selectedId === companion.id ? "is-active" : "", onClick: () => {
1391
+ setSelectedId(companion.id);
1392
+ setTab("home");
1393
+ }, children: [
1394
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Avatar, { name: companion.name }),
1395
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
1396
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: companion.name }),
1397
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: companion.role })
1398
+ ] }),
1399
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("i", { className: channel?.runtimeStatus === "running" ? "is-online" : "", title: channel ? channel.runtimeStatus : "\u672A\u8FDE\u63A5\u6E20\u9053" })
1400
+ ] }, companion.id);
1401
+ }) }),
1402
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-roster-note", children: [
1403
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconLinkOutline16, { size: 16 }),
1404
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
1405
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "\u8EAB\u4EFD\u4E0E\u6E20\u9053\u5206\u79BB" }),
1406
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u5FAE\u4FE1\u53EA\u8D1F\u8D23\u6536\u53D1\uFF0C\u6743\u9650\u4ECD\u7531 DSH \u5DE5\u5177\u51B3\u5B9A\u3002" })
1407
+ ] })
1408
+ ] })
1409
+ ] }),
1410
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "dsh-partner-stage", children: [
1411
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(State, { title: "\u6B63\u5728\u8BFB\u53D6\u4F19\u4F34\u2026" }) : selected === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(State, { title: "\u521B\u5EFA\u7B2C\u4E00\u4E2A\u4F19\u4F34", detail: "\u4F19\u4F34\u4F1A\u4FDD\u5B58\u72EC\u7ACB\u8EAB\u4EFD\u3001\u80FD\u529B\u548C\u5FAE\u4FE1\u4F1A\u8BDD\u3002", action: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: () => {
1412
+ void create();
1413
+ }, children: "\u65B0\u5EFA\u4F19\u4F34" }) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
1414
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-identity", children: [
1415
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Avatar, { name: selected.name }),
1416
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
1417
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "ACTIVE COMPANION" }),
1418
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h1", { children: selected.name }),
1419
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: selected.description || selected.role })
1420
+ ] }),
1421
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Status, { channel: snapshot?.channels.find((item) => item.companionId === selected.id) })
1422
+ ] }),
1423
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("nav", { className: "dsh-partner-tabs", "aria-label": "\u4F19\u4F34\u914D\u7F6E", children: [
1424
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TabButton, { active: tab === "home", onClick: () => setTab("home"), icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconAgentPresetOutline16, { size: 16 }), children: "\u603B\u89C8" }),
1425
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TabButton, { active: tab === "identity", onClick: () => setTab("identity"), icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconEditOutline16, { size: 16 }), children: "\u8EAB\u4EFD" }),
1426
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TabButton, { active: tab === "capabilities", onClick: () => setTab("capabilities"), icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconAgentPresetOutline16, { size: 16 }), children: "\u80FD\u529B" }),
1427
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TabButton, { active: tab === "weixin", onClick: () => setTab("weixin"), icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(WeixinGlyph, {}), children: "\u5FAE\u4FE1" }),
1428
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TabButton, { active: tab === "memory", onClick: () => setTab("memory"), icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconDataOutline16, { size: 16 }), children: "\u8BB0\u5FC6" })
1429
+ ] }),
1430
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-stage-scroll", children: [
1431
+ tab === "home" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(HomePanel, { companion: selected, snapshot, navigate: setTab, openSession }),
1432
+ tab === "identity" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IdentityEditor, { companion: selected, count: snapshot?.companions.length ?? 1, onChanged: refresh }),
1433
+ tab === "capabilities" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CapabilityEditor, { companion: selected, presets: snapshot?.presets ?? [], onChanged: refresh }),
1434
+ tab === "weixin" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(WeixinPanel, { companion: selected, snapshot, onChanged: refresh }),
1435
+ tab === "memory" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MemoryPanel, { companion: selected, snapshot, openSession })
1436
+ ] })
1437
+ ] }),
1438
+ error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-partner-error", role: "alert", children: error })
1439
+ ] })
1440
+ ] })
1441
+ ] });
1442
+ }
1443
+ function HomePanel({ companion, snapshot, navigate, openSession }) {
1444
+ const channel = snapshot.channels.find((item) => item.companionId === companion.id);
1445
+ const sessions = snapshot.sessions.filter((item) => item.companionId === companion.id);
1446
+ const pending = channel ? snapshot.pairings.filter((item) => item.channelId === channel.id && item.status === "pending").length : 0;
1447
+ const approved = channel ? snapshot.pairings.filter((item) => item.channelId === channel.id && item.status === "approved").length : 0;
1448
+ const capabilities = companion.capabilities.map((item) => ({ knowledge: "\u77E5\u8BC6\u5E93", skills: "\u6280\u80FD", ssh: "SSH", git: "Git" })[item]);
1449
+ const online = channel?.runtimeStatus === "running";
1450
+ const latestSession = sessions.reduce((latest, item) => latest === void 0 || item.lastMessageAt > latest.lastMessageAt ? item : latest, void 0);
1451
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-home", children: [
1452
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { className: "dsh-partner-home-heading", children: [
1453
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
1454
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u5DE5\u4F5C\u53F0" }),
1455
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: online ? `${companion.name} \u6B63\u5728\u5FAE\u4FE1\u5F85\u547D` : `\u8FDE\u63A5 ${companion.name} \u7684\u7B2C\u4E00\u6761\u6E20\u9053` })
1456
+ ] }),
1457
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: online ? "\u6D88\u606F\u3001\u6388\u6743\u4E0E\u4E0A\u4E0B\u6587\u8FB9\u754C\u90FD\u5728\u8FD9\u91CC\u6C47\u603B\u3002" : "\u4F19\u4F34\u8EAB\u4EFD\u5DF2\u7ECF\u5C31\u7EEA\uFF0C\u8FDE\u63A5\u5FAE\u4FE1\u540E\u5373\u53EF\u5F00\u59CB\u6301\u7EED\u5DE5\u4F5C\u3002" })
1458
+ ] }),
1459
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: `dsh-partner-home-channel${online ? " is-online" : ""}`, children: [
1460
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-home-route", "aria-hidden": "true", children: [
1461
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Avatar, { name: companion.name }),
1462
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-partner-route-line", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("i", {}) }),
1463
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-partner-route-weixin", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(WeixinGlyph, { large: true }) })
1464
+ ] }),
1465
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-home-channel-copy", children: [
1466
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-partner-home-kicker", children: [
1467
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("i", {}),
1468
+ "\u4E3B\u8981\u6E20\u9053 \xB7 \u5FAE\u4FE1"
1469
+ ] }),
1470
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { children: !channel ? "\u7B49\u5F85\u626B\u7801\u8FDE\u63A5" : online ? "\u8FDE\u63A5\u6B63\u5E38\uFF0C\u6B63\u5728\u63A5\u6536\u6D88\u606F" : channel.runtimeStatus === "error" ? "\u6E20\u9053\u8FDE\u63A5\u9700\u8981\u5904\u7406" : "\u6E20\u9053\u5F53\u524D\u5DF2\u505C\u7528" }),
1471
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: !channel ? "\u901A\u8FC7\u5FAE\u4FE1 iLink Bot \u63A5\u5165\u3002\u51ED\u636E\u53EA\u8FDB\u5165 DSH \u51ED\u636E\u5E93\uFF0C\u8054\u7CFB\u4EBA\u9996\u6B21\u53D1\u6D88\u606F\u4ECD\u9700\u4F60\u7684\u6279\u51C6\u3002" : online ? "\u6BCF\u4F4D\u8054\u7CFB\u4EBA\u62E5\u6709\u72EC\u7ACB DSH \u4F1A\u8BDD\uFF0C\u4F19\u4F34\u8EAB\u4EFD\u4E00\u81F4\uFF0C\u4F46\u4E0A\u4E0B\u6587\u4E0D\u4F1A\u4E92\u76F8\u6DF7\u5408\u3002" : channel.lastError || "\u6E20\u9053\u914D\u7F6E\u4ECD\u7136\u4FDD\u7559\uFF0C\u53EF\u4EE5\u968F\u65F6\u91CD\u65B0\u542F\u7528\u3002" }),
1472
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-home-channel-actions", children: [
1473
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "is-primary", onClick: () => navigate("weixin"), children: !channel ? "\u8FDE\u63A5\u5FAE\u4FE1" : pending > 0 ? `\u5904\u7406 ${pending} \u4E2A\u8BF7\u6C42` : "\u7BA1\u7406\u6E20\u9053" }),
1474
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: !channel ? "\u626B\u7801\u5B8C\u6210\uFF0C\u65E0\u9700\u7C98\u8D34 Token" : `${approved} \u4F4D\u8054\u7CFB\u4EBA \xB7 ${sessions.length} \u4E2A\u72EC\u7ACB\u4F1A\u8BDD` })
1475
+ ] })
1476
+ ] })
1477
+ ] }),
1478
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-home-details", children: [
1479
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "dsh-partner-home-profile", children: [
1480
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { children: [
1481
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconUserOutline16, { size: 16 }) }),
1482
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
1483
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u4F19\u4F34\u5E95\u7A3F" }),
1484
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: companion.role })
1485
+ ] }),
1486
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => navigate("identity"), children: "\u7F16\u8F91" })
1487
+ ] }),
1488
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("blockquote", { children: companion.instructions || companion.description || "\u5C1A\u672A\u8BBE\u7F6E\u957F\u671F\u884C\u4E3A\u51C6\u5219\u3002" })
1489
+ ] }),
1490
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "dsh-partner-home-runtime", children: [
1491
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { children: [
1492
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconAgentPresetOutline16, { size: 16 }) }),
1493
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
1494
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u8FD0\u884C\u80FD\u529B" }),
1495
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: companion.presetId || "DSH \u9ED8\u8BA4 Preset" })
1496
+ ] }),
1497
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => navigate("capabilities"), children: "\u8C03\u6574" })
1498
+ ] }),
1499
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-partner-home-capability-list", children: capabilities.length ? capabilities.map((item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: item }, item)) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u5C1A\u672A\u58F0\u660E\u80FD\u529B\u8303\u56F4" }) })
1500
+ ] }),
1501
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "dsh-partner-home-continuity", children: [
1502
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { children: [
1503
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconDataOutline16, { size: 16 }) }),
1504
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
1505
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u4F1A\u8BDD\u8FDE\u7EED\u6027" }),
1506
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: sessions.length ? `${sessions.length} \u4E2A\u5171\u4EAB\u4F1A\u8BDD` : "\u7B49\u5F85\u7B2C\u4E00\u6761\u6D88\u606F" })
1507
+ ] }),
1508
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => latestSession === void 0 ? navigate("memory") : void openSession(latestSession.id, latestSession.sessionId), children: latestSession === void 0 ? "\u67E5\u770B" : "\u6253\u5F00\u4F1A\u8BDD" })
1509
+ ] }),
1510
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: sessions.length ? `\u6700\u8FD1\u6D3B\u52A8\u4E8E ${relativeTime(Math.max(...sessions.map((item) => item.lastMessageAt)))}` : "\u5FAE\u4FE1\u8054\u7CFB\u4EBA\u901A\u8FC7\u914D\u5BF9\u540E\uFF0C\u5C06\u5728\u8FD9\u91CC\u5EFA\u7ACB\u72EC\u7ACB\u4E0A\u4E0B\u6587\u3002" })
1511
+ ] })
1512
+ ] })
1513
+ ] });
1514
+ }
1515
+ function IdentityEditor({ companion, count, onChanged }) {
1516
+ const [form, setForm] = (0, import_react4.useState)(() => companionDraft(companion));
1517
+ const [saving, setSaving] = (0, import_react4.useState)(false);
1518
+ const [saved, setSaved] = (0, import_react4.useState)(false);
1519
+ const [error, setError] = (0, import_react4.useState)();
1520
+ (0, import_react4.useEffect)(() => {
1521
+ setForm(companionDraft(companion));
1522
+ setSaved(false);
1523
+ }, [companion.id, companion.updatedAt]);
1524
+ const submit = async (event) => {
1525
+ event.preventDefault();
1526
+ setSaving(true);
1527
+ setError(void 0);
1528
+ try {
1529
+ await api(`/companions/${companion.id}`, { method: "PUT", body: JSON.stringify({ companion: form }) });
1530
+ setSaved(true);
1531
+ await onChanged();
1532
+ } catch (reason) {
1533
+ setError(message(reason));
1534
+ } finally {
1535
+ setSaving(false);
1536
+ }
1537
+ };
1538
+ const remove = async () => {
1539
+ if (!window.confirm(`\u5220\u9664\u4F19\u4F34\u300C${companion.name}\u300D\uFF1F\u6B64\u64CD\u4F5C\u8981\u6C42\u5148\u79FB\u9664\u5DF2\u7ED1\u5B9A\u6E20\u9053\u3002`)) return;
1540
+ try {
1541
+ await api(`/companions/${companion.id}`, { method: "DELETE" });
1542
+ await onChanged();
1543
+ } catch (reason) {
1544
+ setError(message(reason));
1545
+ }
1546
+ };
1547
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("form", { className: "dsh-partner-form", onSubmit: (event) => {
1548
+ void submit(event);
1549
+ }, children: [
1550
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Section, { eyebrow: "IDENTITY", title: "\u5DE5\u4F5C\u8EAB\u4EFD", detail: "\u5B83\u4E0D\u662F\u4E00\u6B21\u5BF9\u8BDD\u7684\u63D0\u793A\u8BCD\uFF0C\u800C\u662F\u8FD9\u4E2A\u4F19\u4F34\u5728\u684C\u9762\u548C\u5FAE\u4FE1\u4E2D\u7684\u957F\u671F\u884C\u4E3A\u57FA\u7EBF\u3002" }),
1551
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-fields two", children: [
1552
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Field, { label: "\u540D\u5B57", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { required: true, maxLength: 60, value: form.name, onChange: (event) => setForm({ ...form, name: event.target.value }) }) }),
1553
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Field, { label: "\u89D2\u8272", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { required: true, maxLength: 120, value: form.role, onChange: (event) => setForm({ ...form, role: event.target.value }) }) })
1554
+ ] }),
1555
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Field, { label: "\u4E00\u53E5\u8BDD\u5B9A\u4F4D", hint: "\u7528\u4E8E\u540D\u518C\u8BC6\u522B\uFF0C\u4E0D\u4F1A\u66FF\u4EE3\u5B8C\u6574\u884C\u4E3A\u51C6\u5219\u3002", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("textarea", { rows: 2, maxLength: 500, value: form.description, onChange: (event) => setForm({ ...form, description: event.target.value }) }) }),
1556
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Field, { label: "\u957F\u671F\u884C\u4E3A\u51C6\u5219", hint: "\u5EFA\u8BAE\u5199\u804C\u8D23\u3001\u8868\u8FBE\u65B9\u5F0F\u4E0E\u8FB9\u754C\uFF1B\u6E20\u9053\u3001\u5DE5\u5177\u548C\u6388\u6743\u7531\u7CFB\u7EDF\u5355\u72EC\u63A7\u5236\u3002", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("textarea", { rows: 9, maxLength: 12e3, value: form.instructions, onChange: (event) => setForm({ ...form, instructions: event.target.value }) }) }),
1557
+ error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-partner-inline-error", children: error }),
1558
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-form-actions", children: [
1559
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: saved && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
1560
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconCheckOutline14, { size: 14 }),
1561
+ "\u5DF2\u4FDD\u5B58\uFF0C\u540E\u7EED\u5FAE\u4FE1\u6D88\u606F\u5C06\u4F7F\u7528\u65B0\u8EAB\u4EFD"
1562
+ ] }) }),
1563
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { disabled: saving, children: saving ? "\u6B63\u5728\u4FDD\u5B58\u2026" : "\u4FDD\u5B58\u8EAB\u4EFD" })
1564
+ ] }),
1565
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-identity-danger", children: [
1566
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
1567
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "\u5220\u9664\u4F19\u4F34" }),
1568
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u5FC5\u987B\u5148\u79FB\u9664\u5DF2\u7ED1\u5B9A\u5FAE\u4FE1\u6E20\u9053\uFF1B\u4E0D\u4F1A\u81EA\u52A8\u628A\u8054\u7CFB\u4EBA\u8F6C\u4EA4\u7ED9\u5176\u4ED6\u4F19\u4F34\u3002" })
1569
+ ] }),
1570
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", disabled: count <= 1, onClick: () => {
1571
+ void remove();
1572
+ }, children: [
1573
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconTrashOutline16, { size: 16 }),
1574
+ "\u5220\u9664"
1575
+ ] })
1576
+ ] })
1577
+ ] });
1578
+ }
1579
+ function CapabilityEditor({ companion, presets, onChanged }) {
1580
+ const [form, setForm] = (0, import_react4.useState)(() => companionDraft(companion));
1581
+ const [saving, setSaving] = (0, import_react4.useState)(false);
1582
+ const [error, setError] = (0, import_react4.useState)();
1583
+ (0, import_react4.useEffect)(() => setForm(companionDraft(companion)), [companion.id, companion.updatedAt]);
1584
+ const toggle = (capability) => setForm((current) => ({ ...current, capabilities: current.capabilities.includes(capability) ? current.capabilities.filter((item) => item !== capability) : [...current.capabilities, capability] }));
1585
+ const save = async () => {
1586
+ setSaving(true);
1587
+ setError(void 0);
1588
+ try {
1589
+ await api(`/companions/${companion.id}`, { method: "PUT", body: JSON.stringify({ companion: form }) });
1590
+ await onChanged();
1591
+ } catch (reason) {
1592
+ setError(message(reason));
1593
+ } finally {
1594
+ setSaving(false);
1595
+ }
1596
+ };
1597
+ const choices = [
1598
+ { id: "knowledge", title: "\u77E5\u8BC6\u5E93", detail: "\u5141\u8BB8\u4F19\u4F34\u5728\u5DF2\u6302\u8F7D\u8303\u56F4\u5185\u68C0\u7D22\u4E0E\u56DE\u5199\u77E5\u8BC6\u3002" },
1599
+ { id: "skills", title: "\u6280\u80FD", detail: "\u4F7F\u7528\u5F53\u524D Agent Preset \u63D0\u4F9B\u7684\u6280\u80FD\u4E0E\u5DE5\u4F5C\u6D41\u7A0B\u3002" },
1600
+ { id: "ssh", title: "SSH", detail: "\u901A\u8FC7 SSH \u63D2\u4EF6\u6388\u6743\u7684\u4E3B\u673A\u4E0E\u547D\u4EE4\u8FB9\u754C\u5DE5\u4F5C\u3002" },
1601
+ { id: "git", title: "Git", detail: "\u9884\u7559 Git \u5DE5\u5177\u80FD\u529B\uFF0C\u4ECD\u9700\u5BF9\u5E94\u63D2\u4EF6\u5B9E\u9645\u5B89\u88C5\u3002" }
1602
+ ];
1603
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-form", children: [
1604
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Section, { eyebrow: "COMPOSITION", title: "\u80FD\u529B\u7EC4\u5408", detail: "\u4F19\u4F34\u58F0\u660E\u610F\u56FE\u8303\u56F4\uFF1B\u771F\u6B63\u53EF\u8C03\u7528\u7684\u5DE5\u5177\u4ECD\u6765\u81EA\u6240\u9009 Agent Preset\uFF0C\u5E76\u7EE7\u7EED\u6267\u884C\u5404\u63D2\u4EF6\u6743\u9650\u3002" }),
1605
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Field, { label: "Agent Preset", hint: "\u51B3\u5B9A\u8FD9\u4E2A\u4F19\u4F34\u5B9E\u9645\u52A0\u8F7D\u54EA\u4E9B\u5DE5\u5177\u3001\u6280\u80FD\u548C\u7CFB\u7EDF\u63D0\u793A\u3002", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("select", { value: form.presetId, onChange: (event) => setForm({ ...form, presetId: event.target.value }), children: [
1606
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "\u8DDF\u968F DSH \u9ED8\u8BA4 Preset" }),
1607
+ presets.filter((item) => !item.broken).map((item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: item.id, children: item.name }, item.id))
1608
+ ] }) }),
1609
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-partner-capabilities", children: choices.map((choice) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", className: form.capabilities.includes(choice.id) ? "is-active" : "", onClick: () => toggle(choice.id), children: [
1610
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: form.capabilities.includes(choice.id) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconCheckOutline14, { size: 14 }) }),
1611
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: choice.title }),
1612
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: choice.detail })
1613
+ ] }, choice.id)) }),
1614
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-fields two", children: [
1615
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Field, { label: "\u6A21\u578B\u63D0\u4F9B\u65B9", hint: "\u7559\u7A7A\u4F7F\u7528 DSH \u9ED8\u8BA4\u8DEF\u7531", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { value: form.provider, onChange: (event) => setForm({ ...form, provider: event.target.value }), placeholder: "\u4F8B\u5982 openai" }) }),
1616
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Field, { label: "\u6A21\u578B", hint: "\u7559\u7A7A\u4F7F\u7528\u5F53\u524D\u9ED8\u8BA4\u6A21\u578B", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { value: form.model, onChange: (event) => setForm({ ...form, model: event.target.value }), placeholder: "\u4F8B\u5982 gpt-5" }) })
1617
+ ] }),
1618
+ error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-partner-inline-error", children: error }),
1619
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-form-actions", children: [
1620
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {}),
1621
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", disabled: saving, onClick: () => {
1622
+ void save();
1623
+ }, children: saving ? "\u6B63\u5728\u5E94\u7528\u2026" : "\u5E94\u7528\u80FD\u529B\u7EC4\u5408" })
1624
+ ] })
1625
+ ] });
1626
+ }
1627
+ function WeixinPanel({ companion, snapshot, onChanged }) {
1628
+ const channel = snapshot.channels.find((item) => item.companionId === companion.id);
1629
+ const [login, setLogin] = (0, import_react4.useState)();
1630
+ const [busy, setBusy] = (0, import_react4.useState)(false);
1631
+ const [error, setError] = (0, import_react4.useState)();
1632
+ (0, import_react4.useEffect)(() => {
1633
+ if (!login || login.phase === "confirmed" || login.phase === "expired" || login.phase === "error") return;
1634
+ const timer = window.setInterval(() => {
1635
+ void api(`/weixin/login/${login.id}`).then(async (result) => {
1636
+ setLogin(result.login);
1637
+ if (result.channel) {
1638
+ setLogin(void 0);
1639
+ await onChanged();
1640
+ }
1641
+ }).catch((reason) => setError(message(reason)));
1642
+ }, 2e3);
1643
+ return () => clearInterval(timer);
1644
+ }, [login?.id, login?.phase, onChanged]);
1645
+ const begin = async () => {
1646
+ setBusy(true);
1647
+ setError(void 0);
1648
+ try {
1649
+ setLogin(await api("/weixin/login", { method: "POST", body: JSON.stringify({ companionId: companion.id }) }));
1650
+ } catch (reason) {
1651
+ setError(message(reason));
1652
+ } finally {
1653
+ setBusy(false);
1654
+ }
1655
+ };
1656
+ const toggle = async () => {
1657
+ if (!channel) return;
1658
+ setBusy(true);
1659
+ setError(void 0);
1660
+ try {
1661
+ await api(`/channels/${channel.id}/enabled`, { method: "POST", body: JSON.stringify({ enabled: !channel.enabled }) });
1662
+ await onChanged();
1663
+ } catch (reason) {
1664
+ setError(message(reason));
1665
+ } finally {
1666
+ setBusy(false);
1667
+ }
1668
+ };
1669
+ const pairings = channel ? snapshot.pairings.filter((item) => item.channelId === channel.id) : [];
1670
+ const actPairing = async (id, status) => {
1671
+ try {
1672
+ await api(`/pairings/${id}/status`, { method: "POST", body: JSON.stringify({ status }) });
1673
+ await onChanged();
1674
+ } catch (reason) {
1675
+ setError(message(reason));
1676
+ }
1677
+ };
1678
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-form", children: [
1679
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Section, { eyebrow: "PRIMARY CHANNEL", title: "\u5FAE\u4FE1\u6E20\u9053", detail: "\u4F7F\u7528\u5FAE\u4FE1 iLink Bot \u626B\u7801\u63A5\u5165\u3002\u6BCF\u4E2A\u673A\u5668\u4EBA\u53EA\u7ED1\u5B9A\u4E00\u4E2A\u4F19\u4F34\uFF0C\u6BCF\u4F4D\u8054\u7CFB\u4EBA\u4FDD\u6301\u72EC\u7ACB DSH \u4F1A\u8BDD\u3002" }),
1680
+ !channel && !login && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-weixin-connect", children: [
1681
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-partner-weixin-mark", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(WeixinGlyph, { large: true }) }),
1682
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
1683
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("strong", { children: [
1684
+ "\u628A ",
1685
+ companion.name,
1686
+ " \u5E26\u5230\u5FAE\u4FE1"
1687
+ ] }),
1688
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "\u626B\u7801\u540E\uFF0C\u673A\u5668\u4EBA\u51ED\u636E\u76F4\u63A5\u4FDD\u5B58\u8FDB DSH \u51ED\u636E\u5E93\uFF0C\u4E0D\u4F1A\u663E\u793A\u5728\u6D4F\u89C8\u5668\u6216\u666E\u901A\u914D\u7F6E\u6587\u4EF6\u4E2D\u3002" }),
1689
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("ul", { children: [
1690
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { children: "\u79C1\u804A\u9996\u6B21\u8054\u7CFB\u5FC5\u987B\u5BA1\u6279" }),
1691
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { children: "\u8054\u7CFB\u4EBA\u4E4B\u95F4\u4E0A\u4E0B\u6587\u5B8C\u5168\u9694\u79BB" }),
1692
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { children: "\u5DE5\u5177\u6743\u9650\u4E0D\u4F1A\u56E0\u5FAE\u4FE1\u8EAB\u4EFD\u81EA\u52A8\u6269\u5927" })
1693
+ ] })
1694
+ ] }),
1695
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", disabled: busy, onClick: () => {
1696
+ void begin();
1697
+ }, children: busy ? "\u6B63\u5728\u7533\u8BF7\u4E8C\u7EF4\u7801\u2026" : "\u626B\u7801\u8FDE\u63A5\u5FAE\u4FE1" })
1698
+ ] }),
1699
+ login && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-qr", children: [
1700
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-partner-qr-code", children: login.qrContent && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(QRCodeSVG, { value: login.qrContent, size: 176, level: "M" }) }),
1701
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
1702
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "WECHAT ILINK BOT" }),
1703
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: login.phase === "scanned" ? "\u5DF2\u626B\u7801\uFF0C\u8BF7\u5728\u5FAE\u4FE1\u786E\u8BA4" : login.phase === "expired" ? "\u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F" : login.phase === "error" ? "\u8FDE\u63A5\u5931\u8D25" : "\u4F7F\u7528\u5FAE\u4FE1\u626B\u7801" }),
1704
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: login.error || (login.phase === "scanned" ? "\u786E\u8BA4\u540E\u4F1A\u81EA\u52A8\u542F\u52A8\u6E20\u9053\uFF0C\u4E0D\u9700\u8981\u590D\u5236 Token\u3002" : "\u4E8C\u7EF4\u7801\u7EA6 5 \u5206\u949F\u6709\u6548\u3002\u6B64\u9875\u9762\u53EF\u4EE5\u5B89\u5168\u5730\u4FDD\u6301\u6253\u5F00\u3002") }),
1705
+ (login.phase === "expired" || login.phase === "error") && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", onClick: () => {
1706
+ setLogin(void 0);
1707
+ void begin();
1708
+ }, children: [
1709
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconRefreshOutline16, { size: 16 }),
1710
+ "\u91CD\u65B0\u751F\u6210"
1711
+ ] })
1712
+ ] })
1713
+ ] }),
1714
+ channel && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
1715
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-channel-card", children: [
1716
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-partner-weixin-mark", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(WeixinGlyph, { large: true }) }),
1717
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
1718
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "WECHAT CHANNEL" }),
1719
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: channel.name }),
1720
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: channel.accountId })
1721
+ ] }),
1722
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Status, { channel }),
1723
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-partner-switch", "data-on": channel.enabled, disabled: busy, "aria-label": channel.enabled ? "\u505C\u7528\u5FAE\u4FE1\u6E20\u9053" : "\u542F\u7528\u5FAE\u4FE1\u6E20\u9053", onClick: () => {
1724
+ void toggle();
1725
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("i", {}) })
1726
+ ] }),
1727
+ channel.lastError && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-partner-inline-error", children: channel.lastError }),
1728
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-pairing-heading", children: [
1729
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
1730
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "ACCESS" }),
1731
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "\u79C1\u804A\u914D\u5BF9" })
1732
+ ] }),
1733
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("em", { children: [
1734
+ pairings.filter((item) => item.status === "pending").length,
1735
+ " \u4E2A\u5F85\u5904\u7406"
1736
+ ] })
1737
+ ] }),
1738
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-partner-pairings", children: pairings.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(State, { title: "\u8FD8\u6CA1\u6709\u8054\u7CFB\u4EBA", detail: "\u6709\u4EBA\u9996\u6B21\u5411\u673A\u5668\u4EBA\u53D1\u6D88\u606F\u540E\uFF0C\u914D\u5BF9\u8BF7\u6C42\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002", compact: true }) : pairings.map((pairing) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("article", { children: [
1739
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: `is-${pairing.status}`, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconUserOutline16, { size: 16 }) }),
1740
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
1741
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: pairing.displayName }),
1742
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("small", { children: [
1743
+ pairing.status === "pending" ? "\u7B49\u5F85\u5BA1\u6279" : pairing.status === "approved" ? "\u5DF2\u6388\u6743\u72EC\u7ACB\u4F1A\u8BDD" : "\u5DF2\u963B\u6B62",
1744
+ " \xB7 ",
1745
+ new Date(pairing.updatedAt).toLocaleString()
1746
+ ] })
1747
+ ] }),
1748
+ pairing.status === "pending" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
1749
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: () => {
1750
+ void actPairing(pairing.id, "blocked");
1751
+ }, children: "\u62D2\u7EDD" }),
1752
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "is-primary", onClick: () => {
1753
+ void actPairing(pairing.id, "approved");
1754
+ }, children: "\u6279\u51C6" })
1755
+ ] }),
1756
+ pairing.status === "approved" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: () => {
1757
+ void actPairing(pairing.id, "blocked");
1758
+ }, children: "\u64A4\u9500" }),
1759
+ pairing.status === "blocked" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: () => {
1760
+ void actPairing(pairing.id, "approved");
1761
+ }, children: "\u91CD\u65B0\u6279\u51C6" })
1762
+ ] }, pairing.id)) })
1763
+ ] }),
1764
+ error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsh-partner-inline-error", children: error })
1765
+ ] });
1766
+ }
1767
+ function MemoryPanel({ companion, snapshot, openSession }) {
1768
+ const sessions = snapshot.sessions.filter((item) => item.companionId === companion.id);
1769
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-form", children: [
1770
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Section, { eyebrow: "CONTINUITY", title: "\u4F1A\u8BDD\u8BB0\u5FC6", detail: "\u8FD9\u91CC\u5C55\u793A\u6E20\u9053\u4F1A\u8BDD\u8FB9\u754C\u3002\u77E5\u8BC6\u5E93\u4ECD\u7531\u77E5\u8BC6\u5E93\u63D2\u4EF6\u7BA1\u7406\uFF0C\u4F19\u4F34\u4E0D\u4F1A\u628A\u4E0D\u540C\u5FAE\u4FE1\u8054\u7CFB\u4EBA\u7684\u539F\u59CB\u4E0A\u4E0B\u6587\u6DF7\u5728\u4E00\u8D77\u3002" }),
1771
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-metrics", children: [
1772
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("article", { children: [
1773
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u6E20\u9053\u4F1A\u8BDD" }),
1774
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: sessions.length }),
1775
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "\u6BCF\u4F4D\u8054\u7CFB\u4EBA\u72EC\u7ACB" })
1776
+ ] }),
1777
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("article", { children: [
1778
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u77E5\u8BC6\u80FD\u529B" }),
1779
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: companion.capabilities.includes("knowledge") ? "\u5DF2\u58F0\u660E" : "\u672A\u542F\u7528" }),
1780
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "\u5B9E\u9645\u8303\u56F4\u7531\u4F1A\u8BDD\u6302\u8F7D\u51B3\u5B9A" })
1781
+ ] }),
1782
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("article", { children: [
1783
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u6700\u8FD1\u6D3B\u52A8" }),
1784
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: sessions.length ? relativeTime(Math.max(...sessions.map((item) => item.lastMessageAt))) : "\u6682\u65E0" }),
1785
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "\u4E0D\u4F1A\u8DE8\u6E20\u9053\u81EA\u52A8\u5408\u5E76" })
1786
+ ] })
1787
+ ] }),
1788
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-partner-session-list", children: [
1789
+ sessions.map((item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("article", { children: [
1790
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconDataOutline16, { size: 16 }) }),
1791
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
1792
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("strong", { children: [
1793
+ "\u5FAE\u4FE1\u8054\u7CFB\u4EBA \xB7 ",
1794
+ item.userId.slice(-6)
1795
+ ] }),
1796
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("small", { children: [
1797
+ item.sessionId,
1798
+ " \xB7 ",
1799
+ new Date(item.lastMessageAt).toLocaleString()
1800
+ ] })
1801
+ ] }),
1802
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => {
1803
+ void openSession(item.id, item.sessionId);
1804
+ }, children: "\u6253\u5F00\u4F1A\u8BDD" })
1805
+ ] }, item.id)),
1806
+ sessions.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(State, { title: "\u8FD8\u6CA1\u6709\u5171\u4EAB\u4F1A\u8BDD", detail: "\u8054\u7CFB\u4EBA\u5B8C\u6210\u914D\u5BF9\u5E76\u53D1\u6765\u7B2C\u4E00\u6761\u6D88\u606F\u540E\uFF0C\u4F19\u4F34\u4F1A\u521B\u5EFA\u7F51\u9875\u4E0E\u5FAE\u4FE1\u5171\u7528\u7684\u4F1A\u8BDD\u3002", compact: true })
1807
+ ] })
1808
+ ] });
1809
+ }
1810
+ function Status({ channel }) {
1811
+ const status = !channel ? "unbound" : channel.runtimeStatus;
1812
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: `dsh-partner-status is-${status}`, children: [
1813
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("i", {}),
1814
+ !channel ? "\u672A\u8FDE\u63A5" : statusLabel(channel.runtimeStatus)
1815
+ ] });
1816
+ }
1817
+ function statusLabel(status) {
1818
+ return status === "running" ? "\u5FAE\u4FE1\u5728\u7EBF" : status === "starting" ? "\u8FDE\u63A5\u4E2D" : status === "error" ? "\u8FDE\u63A5\u5F02\u5E38" : "\u5DF2\u505C\u7528";
1819
+ }
1820
+ function Avatar({ name, small = false }) {
1821
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: `dsh-partner-avatar${small ? " is-small" : ""}`, "aria-hidden": "true", children: [...name][0] ?? "\u4F34" });
1822
+ }
1823
+ function WeixinGlyph({ large = false }) {
1824
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: `dsh-partner-weixin-glyph${large ? " is-large" : ""}`, "aria-hidden": "true", children: [
1825
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("i", {}),
1826
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("b", {})
1827
+ ] });
1828
+ }
1829
+ function TabButton({ active, onClick, icon, children }) {
1830
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", className: active ? "is-active" : "", onClick, children: [
1831
+ icon,
1832
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children })
1833
+ ] });
1834
+ }
1835
+ function Field({ label, hint, children }) {
1836
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "dsh-partner-field", children: [
1837
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
1838
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: label }),
1839
+ hint && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: hint })
1840
+ ] }),
1841
+ children
1842
+ ] });
1843
+ }
1844
+ function Section({ eyebrow, title, detail }) {
1845
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { className: "dsh-partner-section", children: [
1846
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: eyebrow }),
1847
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: title }),
1848
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: detail })
1849
+ ] });
1850
+ }
1851
+ function State({ title, detail, action, compact = false }) {
1852
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `dsh-partner-state${compact ? " is-compact" : ""}`, children: [
1853
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconAgentPresetOutline16, { size: 20 }),
1854
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: title }),
1855
+ detail && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: detail }),
1856
+ action
1857
+ ] });
1858
+ }
1859
+ function companionDraft(companion) {
1860
+ return { name: companion.name, role: companion.role, description: companion.description, instructions: companion.instructions, presetId: companion.presetId ?? "", provider: companion.provider ?? "", model: companion.model ?? "", capabilities: [...companion.capabilities] };
1861
+ }
1862
+ function relativeTime(value) {
1863
+ const minutes = Math.floor((Date.now() - value) / 6e4);
1864
+ return minutes < 1 ? "\u521A\u521A" : minutes < 60 ? `${minutes} \u5206\u949F\u524D` : minutes < 1440 ? `${Math.floor(minutes / 60)} \u5C0F\u65F6\u524D` : `${Math.floor(minutes / 1440)} \u5929\u524D`;
1865
+ }
1866
+ function message(reason) {
1867
+ return reason instanceof Error ? reason.message : String(reason);
1868
+ }
1869
+ function waitForClientSession(ctx, sessionId) {
1870
+ const id = sessionId;
1871
+ const sessions = clientSessions(ctx);
1872
+ if (sessions.list.getSnapshot().byId[id] !== void 0) return Promise.resolve();
1873
+ return new Promise((resolve, reject) => {
1874
+ let stop = () => {
1875
+ };
1876
+ const timeout = window.setTimeout(() => {
1877
+ stop();
1878
+ reject(new Error("\u4F19\u4F34\u4F1A\u8BDD\u5C1A\u672A\u540C\u6B65\u5230\u7F51\u9875\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"));
1879
+ }, 5e3);
1880
+ stop = sessions.list.subscribe(() => {
1881
+ if (sessions.list.getSnapshot().byId[id] === void 0) return;
1882
+ window.clearTimeout(timeout);
1883
+ stop();
1884
+ resolve();
1885
+ });
1886
+ });
1887
+ }
1888
+ function clientSessions(ctx) {
1889
+ return ctx.sessions;
1890
+ }
1891
+ function installStyles() {
1892
+ let style = document.getElementById(STYLE_ID);
1893
+ if (!style) {
1894
+ style = document.createElement("style");
1895
+ style.id = STYLE_ID;
1896
+ style.textContent = client_default;
1897
+ document.head.append(style);
1898
+ }
1899
+ return () => style?.remove();
1900
+ }
1901
+ /*! Bundled license information:
1902
+
1903
+ qrcode.react/lib/esm/index.js:
1904
+ (**
1905
+ * @license QR Code generator library (TypeScript)
1906
+ * Copyright (c) Project Nayuki.
1907
+ * SPDX-License-Identifier: MIT
1908
+ *)
1909
+ (**
1910
+ * @license qrcode.react
1911
+ * Copyright (c) Paul O'Shannessy
1912
+ * SPDX-License-Identifier: ISC
1913
+ *)
1914
+ */
1915
+ return module.exports; } });
1916
+ //# sourceMappingURL=client.js.map