@jayyuen66/dsh-zvec-grep 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.js CHANGED
@@ -88,10 +88,15 @@ const REMOTE_EMBEDDING_CATALOG = Object.freeze([
88
88
  dimension: 1024
89
89
  }
90
90
  ].map((entry) => Object.freeze(entry)));
91
- // node_modules/@jayyuen66/dsh-plugin-shared/dist/card-ui-yf56_khz.js
91
+ // node_modules/@jayyuen66/dsh-plugin-shared/dist/card-ui-ikodobgI.js
92
92
  const c = `
93
93
  .dsu-form{display:flex;flex-direction:column}
94
+ .dsu-form,.dsu-form *,.dsu-form *::before,.dsu-form *::after{box-sizing:border-box}
94
95
  .dsu-section{margin-top:24px;padding-top:24px;border-top:.5px solid var(--dsw-alias-border-l1)}
96
+ .dsu-form .dsu-section>*+*{margin-top:10px}
97
+ .dsu-form .dsu-section>.dsu-sectionHint{margin-top:4px}
98
+ .dsu-form .dsu-section>*+.dsu-field{margin-top:0}
99
+ .dsu-form .dsu-section>.dsu-savebar{margin-top:24px}
95
100
  .dsu-form>.dsu-section:first-child{margin-top:0;padding-top:0;border-top:0}
96
101
  .dsu-sectionTitle{margin:0;font-size:15px;font-weight:600;line-height:1.4;color:var(--dsw-alias-label-primary)}
97
102
  .dsu-sectionHint{margin:4px 0 0;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
@@ -142,8 +147,8 @@ const c = `
142
147
  .dsu-optionGroup{padding:6px 10px 2px;font-size:11px;font-weight:600;color:var(--dsw-alias-label-tertiary)}
143
148
  .dsu-check{opacity:0;flex:none}
144
149
  .dsu-option[aria-selected="true"] .dsu-check{opacity:1}
145
- .dsu-savebar{display:flex;align-items:center;gap:8px;padding:12px 0;margin-top:24px;border-top:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base)}
146
- .dsu-savebar[data-dirty="true"]{position:sticky;bottom:0;z-index:2;box-shadow:0 -12px 24px rgb(0 0 0 / 35%)}
150
+ .dsu-savebar{display:flex;align-items:center;gap:8px;padding:12px 0;margin-top:24px;border-top:.5px solid var(--dsw-alias-border-l2)}
151
+ .dsu-savebar[data-dirty="true"]{position:sticky;bottom:0;z-index:2;background:var(--dsw-alias-bg-base);box-shadow:0 -12px 24px rgb(0 0 0 / 35%)}
147
152
  .dsu-btn{appearance:none;border:.5px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:1.5;border-radius:var(--dsw-radius-md);padding:5px 14px;cursor:pointer;transition:background-color .12s,border-color .12s,color .12s,filter .12s}
148
153
  .dsu-btn:hover:not(:disabled){background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-border-l3)}
149
154
  .dsu-btn:active:not(:disabled){background:var(--dsw-alias-bg-layer-1)}
@@ -168,61 +173,126 @@ const c = `
168
173
  .dsu-switch,.dsu-knob,.dsu-chevron,.dsu-btn{transition:none}
169
174
  }
170
175
  `;
171
- function l(e, t = 30) {
176
+ const l = `dsh-card-ui-css`;
177
+ const u = Symbol.for(`@jayyuen66/dsh-plugin-shared/card-ui-css/refs`);
178
+ function d() {}
179
+ function f(e) {
180
+ if (typeof e != `object` || !e) return !1;
181
+ let t = Reflect.get(e, `head`);
182
+ return typeof Reflect.get(e, `querySelector`) == `function` && typeof Reflect.get(e, `createElement`) == `function` && typeof t == `object` && !!t && typeof Reflect.get(t, `append`) == `function`;
183
+ }
184
+ function p(e) {
185
+ if (e !== void 0) return f(e) ? e : void 0;
186
+ let t = typeof document > `u` ? void 0 : document;
187
+ return f(t) ? t : void 0;
188
+ }
189
+ function m(e) {
190
+ return typeof Reflect.get(e, `remove`) == `function`;
191
+ }
192
+ function h(e) {
193
+ let t = Reflect.get(e, u);
194
+ return typeof t == `number` && t > 0 ? t : 0;
195
+ }
196
+ function g(e) {
197
+ let t = e.createElement(`style`);
198
+ return t.id = l, t.textContent = c, e.head.append(t), t;
199
+ }
200
+ function _(e) {
201
+ let t = !1;
202
+ return () => {
203
+ if (t) return;
204
+ t = !0;
205
+ let n = h(e);
206
+ n <= 1 ? (Reflect.deleteProperty(e, u), e.remove()) : Reflect.set(e, u, n - 1);
207
+ };
208
+ }
209
+ function v(e) {
210
+ let t = p(e);
211
+ if (t === void 0) return d;
212
+ let n = t.querySelector(`#${l}`);
213
+ if (n != null) {
214
+ if (typeof n != `object` || !m(n)) return d;
215
+ let e = h(n);
216
+ return e === 0 ? d : (Reflect.set(n, u, e + 1), _(n));
217
+ }
218
+ let r = g(t);
219
+ return Reflect.set(r, u, 1), _(r);
220
+ }
221
+ function y(e, t = 30) {
172
222
  return e.length <= t ? { hint: e } : { detail: e };
173
223
  }
174
- function u(t) {
224
+ function b(e, t, n) {
225
+ if (e.has(t) === n) return e;
226
+ let r = new Set(e);
227
+ return n ? r.add(t) : r.delete(t), r;
228
+ }
229
+ function x() {
230
+ let [e, n] = (0, react.useState)(() => /* @__PURE__ */ new Set()), [r, i] = (0, react.useState)(0), a = (0, react.useCallback)((e, t) => {
231
+ n((n) => b(n, e, t));
232
+ }, []), o = (0, react.useCallback)(() => {
233
+ n(/* @__PURE__ */ new Set()), i((e) => e + 1);
234
+ }, []);
235
+ return {
236
+ blocked: e.size > 0,
237
+ fields: e,
238
+ count: e.size,
239
+ resetToken: r,
240
+ reportInvalid: a,
241
+ clear: o
242
+ };
243
+ }
244
+ function S(t) {
175
245
  return (0, react.createElement)(`div`, { className: `dsu-form` }, t.children);
176
246
  }
177
- function d(t) {
247
+ function C(t) {
178
248
  return (0, react.createElement)(`section`, { className: `dsu-section` }, (0, react.createElement)(`h2`, { className: `dsu-sectionTitle` }, t.title), t.hint === void 0 ? null : (0, react.createElement)(`p`, { className: `dsu-sectionHint` }, t.hint), t.children);
179
249
  }
180
- function m() {
250
+ function E() {
181
251
  return `happyDOM` in globalThis ? !1 : typeof CSS < `u` && typeof CSS.supports == `function` && CSS.supports(`position-area: block-end`);
182
252
  }
183
- function h(e, t) {
253
+ function D(e, t) {
184
254
  let n = Math.abs(t.left - e.left) <= 2, r = Math.abs(t.right - e.right) <= 2;
185
255
  if (!n && !r) return !0;
186
256
  let i = t.top >= e.bottom - 2, a = t.bottom <= e.top + 2;
187
257
  return !i && !a;
188
258
  }
189
- function g(a) {
190
- let c = (0, react.useId)(), l = `--dsu-tip-${c.replaceAll(/[^a-zA-Z0-9]/gu, ``)}`, [u, d] = (0, react.useState)(!1), f = (0, react.useRef)(!1), p = (0, react.useRef)(!1), g = (0, react.useRef)(!1), _ = (0, react.useRef)(null), v = (0, react.useRef)(null), y = (0, react.useRef)(null), b = (0, react.useRef)(null), x = (0, react.useCallback)(() => {
191
- b.current !== null && (clearTimeout(b.current), b.current = null);
192
- }, []), S = (0, react.useCallback)(() => {
193
- let e = v.current, t = y.current;
259
+ function O(a) {
260
+ let c = (0, react.useId)(), l = `--dsu-tip-${c.replaceAll(/[^a-zA-Z0-9]/gu, ``)}`, [u, d] = (0, react.useState)(!1), f = (0, react.useRef)(!1), p = (0, react.useRef)(!1), m = (0, react.useRef)(!1), h = (0, react.useRef)(null), g = (0, react.useRef)(null), _ = (0, react.useRef)(null), v = (0, react.useRef)(null), y = (0, react.useCallback)(() => {
261
+ v.current !== null && (clearTimeout(v.current), v.current = null);
262
+ }, []), b = (0, react.useCallback)(() => {
263
+ let e = g.current, t = _.current;
194
264
  /* v8 ignore next 3 -- place 只在 open 的 layout effect 与挂载期监听器里调用;refs 为空只可能是卸载竞态 */
195
265
  if (e === null || t === null) return;
196
- let n = m() && t.style.positionArea !== `none`, r = e.getBoundingClientRect();
197
- if (n && !h(r, t.getBoundingClientRect())) return;
266
+ let n = E() && t.style.positionArea !== `none`, r = e.getBoundingClientRect();
267
+ if (n && !D(r, t.getBoundingClientRect())) return;
198
268
  n && (t.style.positionArea = `none`), t.style.marginTop = `0px`;
199
269
  let i = t.offsetWidth, a = t.offsetHeight, { left: o } = r, s = r.bottom + 8;
200
270
  s + a > window.innerHeight - 8 && (s = r.top - a - 8), o + i > window.innerWidth - 8 && (o = window.innerWidth - i - 8);
201
271
  let c = Math.max(8, window.innerWidth - i - 8), l = Math.max(8, window.innerHeight - a - 8);
202
272
  t.style.left = `${Math.min(Math.max(8, o), c)}px`, t.style.top = `${Math.min(Math.max(8, s), l)}px`;
203
- }, []), C = (0, react.useCallback)(() => {
204
- x(), g.current = !1, d(!1);
205
- }, [x]), w = (0, react.useCallback)(() => {
206
- x(), d(!0);
207
- }, [x]), T = (0, react.useCallback)(() => {
208
- x(), f.current || p.current || g.current || (b.current = setTimeout(() => {
273
+ }, []), x = (0, react.useCallback)(() => {
274
+ y(), m.current = !1, d(!1);
275
+ }, [y]), S = (0, react.useCallback)(() => {
276
+ y(), d(!0);
277
+ }, [y]), C = (0, react.useCallback)(() => {
278
+ y(), f.current || p.current || m.current || (v.current = setTimeout(() => {
209
279
  /* v8 ignore next 3 -- 任何重新进入/钉住都会 cancelHide;这次复查只防未来的异步路径 */
210
- b.current = null, f.current || p.current || g.current || d(!1);
280
+ v.current = null, f.current || p.current || m.current || d(!1);
211
281
  }, 120));
212
- }, [x]), E = (0, react.useCallback)((e) => {
213
- g.current = e;
282
+ }, [y]), w = (0, react.useCallback)((e) => {
283
+ m.current = e;
214
284
  }, []);
215
285
  (0, react.useLayoutEffect)(() => {
216
286
  if (!u) return () => {};
217
- S();
287
+ b();
218
288
  let e = (e) => {
219
289
  let { target: t } = e;
220
- t instanceof Node && y.current?.contains(t) === !0 || (g.current ? S() : C());
290
+ t instanceof Node && _.current?.contains(t) === !0 || (m.current ? b() : x());
221
291
  }, t = () => {
222
- S();
292
+ b();
223
293
  }, n = (e) => {
224
294
  let t = e.target;
225
- _.current?.contains(t) !== !0 && C();
295
+ h.current?.contains(t) !== !0 && x();
226
296
  };
227
297
  return document.addEventListener(`pointerdown`, n, !0), window.addEventListener(`scroll`, e, !0), window.addEventListener(`resize`, t), () => {
228
298
  document.removeEventListener(`pointerdown`, n, !0), window.removeEventListener(`scroll`, e, !0), window.removeEventListener(`resize`, t);
@@ -230,19 +300,19 @@ function g(a) {
230
300
  }, [
231
301
  u,
232
302
  a.detail,
233
- S,
234
- C
303
+ b,
304
+ x
235
305
  ]), (0, react.useEffect)(() => {
236
306
  if (!u) return () => {};
237
307
  let e = (e) => {
238
- e.key === `Escape` && C();
308
+ e.key === `Escape` && x();
239
309
  };
240
310
  return document.addEventListener(`keydown`, e), () => {
241
311
  document.removeEventListener(`keydown`, e);
242
312
  };
243
- }, [u, C]), (0, react.useEffect)(() => x, [x]);
244
- let D = (0, react.createElement)(`button`, {
245
- ref: v,
313
+ }, [u, x]), (0, react.useEffect)(() => y, [y]);
314
+ let T = (0, react.createElement)(`button`, {
315
+ ref: g,
246
316
  type: `button`,
247
317
  className: `dsu-helpBtn`,
248
318
  style: { anchorName: l },
@@ -250,7 +320,7 @@ function g(a) {
250
320
  "aria-expanded": u,
251
321
  "aria-controls": c,
252
322
  onClick: () => {
253
- g.current ? C() : (E(!0), w());
323
+ m.current ? x() : (w(!0), S());
254
324
  }
255
325
  }, (0, react.createElement)(`svg`, {
256
326
  width: 12,
@@ -275,7 +345,7 @@ function g(a) {
275
345
  r: .8,
276
346
  fill: `currentColor`
277
347
  }))), O = (0, react.createElement)(`div`, {
278
- ref: y,
348
+ ref: _,
279
349
  id: c,
280
350
  role: `tooltip`,
281
351
  className: `dsu-tip`,
@@ -286,37 +356,37 @@ function g(a) {
286
356
  hidden: !u
287
357
  }, a.detail), k = a.showLabel === !1 ? null : (0, react.createElement)(`span`, { className: `dsu-label${a.compact === !0 ? ` dsu-labelMono` : ``}` }, a.label);
288
358
  return (0, react.createElement)(`span`, {
289
- ref: _,
359
+ ref: h,
290
360
  className: `dsu-help`,
291
361
  onMouseEnter: () => {
292
- f.current = !0, w();
362
+ f.current = !0, S();
293
363
  },
294
364
  onMouseLeave: () => {
295
- f.current = !1, T();
365
+ f.current = !1, C();
296
366
  },
297
367
  onFocus: () => {
298
- p.current = !0, w();
368
+ p.current = !0, S();
299
369
  },
300
370
  onBlur: (e) => {
301
371
  let t = e.relatedTarget;
302
- t instanceof Node && e.currentTarget.contains(t) || (p.current = !1, T());
372
+ t instanceof Node && e.currentTarget.contains(t) || (p.current = !1, C());
303
373
  }
304
- }, k, D, O);
374
+ }, k, T, O);
305
375
  }
306
- function _(t) {
376
+ function k(t) {
307
377
  let n = `dsu-label${t.compact === !0 ? ` dsu-labelMono` : ``}`, r = t.controlId === void 0 ? (0, react.createElement)(`span`, { className: n }, t.label) : (0, react.createElement)(`label`, {
308
378
  className: n,
309
379
  htmlFor: t.controlId
310
380
  }, t.label);
311
- return (0, react.createElement)(`div`, { className: `dsu-labelRow` }, r, t.detail === void 0 ? null : (0, react.createElement)(g, {
381
+ return (0, react.createElement)(`div`, { className: `dsu-labelRow` }, r, t.detail === void 0 ? null : (0, react.createElement)(O, {
312
382
  label: t.label,
313
383
  detail: t.detail,
314
384
  showLabel: !1
315
385
  }));
316
386
  }
317
- function v(t) {
387
+ function A(t) {
318
388
  let n = t.controlId === void 0 ? void 0 : `${t.controlId}-hint`;
319
- return (0, react.createElement)(`div`, { className: `dsu-field${t.wide === !0 ? ` dsu-fieldWide` : ``}` }, (0, react.createElement)(`div`, { className: `dsu-fieldMeta` }, (0, react.createElement)(_, {
389
+ return (0, react.createElement)(`div`, { className: `dsu-field${t.wide === !0 ? ` dsu-fieldWide` : ``}` }, (0, react.createElement)(`div`, { className: `dsu-fieldMeta` }, (0, react.createElement)(k, {
320
390
  label: t.label,
321
391
  detail: t.detail,
322
392
  compact: t.compact,
@@ -326,9 +396,9 @@ function v(t) {
326
396
  id: n
327
397
  }, t.hint)), (0, react.createElement)(`div`, { className: `dsu-control` }, t.children));
328
398
  }
329
- function y(t) {
399
+ function j(t) {
330
400
  let n = (0, react.useId)(), i = t.hint === void 0 ? void 0 : `${n}-hint`;
331
- return (0, react.createElement)(v, {
401
+ return (0, react.createElement)(A, {
332
402
  ...t,
333
403
  controlId: n
334
404
  }, (0, react.createElement)(`button`, {
@@ -345,57 +415,67 @@ function y(t) {
345
415
  }
346
416
  }, (0, react.createElement)(`span`, { className: `dsu-knob` })));
347
417
  }
348
- function b(t) {
349
- let i = typeof t.value == `number` && Number.isFinite(t.value) ? String(t.value) : ``, [a, c] = (0, react.useState)(i), [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(!1), p = (0, react.useRef)(void 0), m = (0, react.useId)(), h = (0, react.useId)(), g = t.hint === void 0 ? void 0 : `${m}-hint`, _ = l && d, y = [g, _ ? h : void 0].filter((e) => e !== void 0), b = y.length === 0 ? void 0 : y.join(` `);
418
+ function M(t) {
419
+ let i = typeof t.value == `number` && Number.isFinite(t.value) ? String(t.value) : ``, [a, c] = (0, react.useState)(i), [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(!1), p = (0, react.useRef)(void 0), m = (0, react.useRef)(t.resetToken), h = (0, react.useRef)(t.onInvalidChange), g = (0, react.useId)(), _ = (0, react.useId)(), v = t.hint === void 0 ? void 0 : `${g}-hint`, y = l && d, b = [v, y ? _ : void 0].filter((e) => e !== void 0), x = b.length === 0 ? void 0 : b.join(` `);
350
420
  (0, react.useEffect)(() => {
421
+ h.current = t.onInvalidChange;
422
+ }, [t.onInvalidChange]), (0, react.useEffect)(() => {
423
+ h.current?.(l);
424
+ }, [l]), (0, react.useEffect)(() => {
425
+ m.current !== t.resetToken && (m.current = t.resetToken, p.current = t.value, c(i), u(!1), f(!1));
426
+ }, [
427
+ t.resetToken,
428
+ t.value,
429
+ i
430
+ ]), (0, react.useEffect)(() => {
351
431
  t.value !== p.current && (p.current = t.value, c(i), u(!1), f(!1));
352
432
  }, [t.value, i]);
353
- let x = (e) => {
433
+ let S = (e) => {
354
434
  let n = t.min ?? -1 / 0, r = t.max ?? 1 / 0;
355
435
  if (!Number.isFinite(e) || e < n || e > r) return !1;
356
436
  let { step: i } = t;
357
437
  if (i === void 0 || i <= 0) return !0;
358
438
  let a = (e - (t.min ?? 0)) / i;
359
439
  return Math.abs(a - Math.round(a)) < 1e-9;
360
- }, S = (e) => {
440
+ }, C = (e) => {
361
441
  if (f(!1), c(e), e === ``) {
362
442
  u(!1), p.current = void 0, t.onChange(void 0);
363
443
  return;
364
444
  }
365
445
  let n = Number(e);
366
- x(n) ? (u(!1), p.current = n, t.onChange(n)) : u(!0);
367
- }, C = () => {
368
- a === `` || l || c(String(Number(a)));
446
+ S(n) ? (u(!1), p.current = n, t.onChange(n)) : u(!0);
369
447
  }, w = () => {
370
- f(l), C();
448
+ a === `` || l || c(String(Number(a)));
449
+ }, T = () => {
450
+ f(l), w();
371
451
  };
372
- return (0, react.createElement)(v, {
452
+ return (0, react.createElement)(A, {
373
453
  ...t,
374
- controlId: m
454
+ controlId: g
375
455
  }, (0, react.createElement)(`div`, { className: `dsu-numberWrap` }, (0, react.createElement)(`div`, { className: `dsu-number` }, (0, react.createElement)(`input`, {
376
456
  className: `dsu-input`,
377
457
  type: `number`,
378
458
  inputMode: `numeric`,
379
- id: m,
459
+ id: g,
380
460
  value: a,
381
461
  min: t.min,
382
462
  max: t.max,
383
463
  step: t.step,
384
464
  placeholder: t.placeholder,
385
- "aria-invalid": _ || void 0,
386
- "aria-describedby": b,
465
+ "aria-invalid": y || void 0,
466
+ "aria-describedby": x,
387
467
  "data-field": t.field,
388
468
  disabled: t.disabled === !0,
389
469
  onChange: (e) => {
390
- S(e.target.value);
470
+ C(e.target.value);
391
471
  },
392
- onBlur: w
393
- }), t.unit === void 0 ? null : (0, react.createElement)(`span`, { className: `dsu-unit` }, t.unit)), _ ? (0, react.createElement)(`p`, {
472
+ onBlur: T
473
+ }), t.unit === void 0 ? null : (0, react.createElement)(`span`, { className: `dsu-unit` }, t.unit)), y ? (0, react.createElement)(`p`, {
394
474
  className: `dsu-error`,
395
- id: h
475
+ id: _
396
476
  }, t.invalidHint) : null));
397
477
  }
398
- function x(t) {
478
+ function N(t) {
399
479
  let [i, a] = (0, react.useState)(t.value), [o, c] = (0, react.useState)(!1), l = (0, react.useId)(), u = t.hint === void 0 ? void 0 : `${l}-hint`;
400
480
  (0, react.useEffect)(() => {
401
481
  o || a(t.value);
@@ -418,23 +498,23 @@ function x(t) {
418
498
  a(e.target.value), t.onChange(e.target.value);
419
499
  }
420
500
  };
421
- return (0, react.createElement)(v, {
501
+ return (0, react.createElement)(A, {
422
502
  ...t,
423
503
  controlId: l
424
504
  }, t.multiline === !0 ? (0, react.createElement)(`textarea`, d) : (0, react.createElement)(`input`, d));
425
505
  }
426
- function C(c) {
427
- let [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(0), p = (0, react.useRef)(null), g = (0, react.useRef)(null), _ = (0, react.useId)(), y = (0, react.useId)(), b = `--dsu-${y.replaceAll(/[^a-zA-Z0-9]/gu, ``)}`, x = c.hint === void 0 ? void 0 : `${y}-hint`, { disabled: S, value: C, options: w, onChange: T } = c, E = (0, react.useMemo)(() => w.map((e, t) => ({
506
+ function F(c) {
507
+ let [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(0), p = (0, react.useRef)(null), m = (0, react.useRef)(null), h = (0, react.useId)(), g = (0, react.useId)(), _ = `--dsu-${g.replaceAll(/[^a-zA-Z0-9]/gu, ``)}`, v = c.hint === void 0 ? void 0 : `${g}-hint`, { disabled: y, value: b, options: x, onChange: S } = c, C = (0, react.useMemo)(() => x.map((e, t) => ({
428
508
  option: e,
429
509
  index: t
430
- })).filter((e) => e.option.disabled !== !0), [w]), D = w.find((e) => e.value === C)?.label ?? C, O = w[d], k = O !== void 0 && O.disabled !== !0, A = (0, react.useCallback)(() => {
431
- let e = p.current, t = g.current;
510
+ })).filter((e) => e.option.disabled !== !0), [x]), w = x.find((e) => e.value === b)?.label ?? b, T = x[d], O = T !== void 0 && T.disabled !== !0, k = (0, react.useCallback)(() => {
511
+ let e = p.current, t = m.current;
432
512
  /* v8 ignore next 3 -- place 只在 open 的 layout effect 里调用;refs 为空只可能是卸载竞态 */
433
513
  if (e === null || t === null) return;
434
514
  let n = e.getBoundingClientRect(), r = Math.min(n.width, window.innerWidth - 16);
435
515
  t.style.width = `${r}px`;
436
- let i = m() && t.style.positionArea !== `none`;
437
- if (i && !h(n, t.getBoundingClientRect())) return;
516
+ let i = E() && t.style.positionArea !== `none`;
517
+ if (i && !D(n, t.getBoundingClientRect())) return;
438
518
  i && (t.style.positionArea = `none`), t.style.marginTop = `0px`;
439
519
  let { left: a } = n;
440
520
  a + r > window.innerWidth - 8 && (a = window.innerWidth - r - 8);
@@ -445,43 +525,43 @@ function C(c) {
445
525
  }, []), j = (0, react.useCallback)(() => {
446
526
  u(!1);
447
527
  }, []), M = (0, react.useCallback)(() => {
448
- if (S === !0) return;
449
- let e = E.find((e) => e.option.value === C) ?? E.at(0);
528
+ if (y === !0) return;
529
+ let e = C.find((e) => e.option.value === b) ?? C.at(0);
450
530
  e !== void 0 && (f(e.index), u(!0));
451
531
  }, [
452
- S,
453
- C,
454
- E
532
+ y,
533
+ b,
534
+ C
455
535
  ]), N = (0, react.useCallback)((e) => {
456
536
  /* v8 ignore next 3 -- 浮层只能经由 openMenu 打开;组件禁用时打不开 */
457
- if (S === !0) return;
458
- let t = w[e];
537
+ if (y === !0) return;
538
+ let t = x[e];
459
539
  /* v8 ignore next 3 -- disabled 选项在浏览器里不派发 click;越界下标由调用方保证 */
460
- t !== void 0 && t.disabled !== !0 && (T(t.value), j(), p.current?.focus());
540
+ t !== void 0 && t.disabled !== !0 && (S(t.value), j(), p.current?.focus());
461
541
  }, [
542
+ y,
543
+ x,
462
544
  S,
463
- w,
464
- T,
465
545
  j
466
546
  ]), P = (0, react.useCallback)((e) => {
467
- let t = E.findIndex((e) => e.index === d);
547
+ let t = C.findIndex((e) => e.index === d);
468
548
  /* v8 ignore next 5 -- open 时归一 effect 已保证 enabled 非空且 active 落在可用项上 */
469
- if (t === -1 || E.length === 0) return;
470
- let n = (t + e + E.length) % E.length, r = E[n];
549
+ if (t === -1 || C.length === 0) return;
550
+ let n = (t + e + C.length) % C.length, r = C[n];
471
551
  /* v8 ignore next 3 -- next 由取模保证在界内 */
472
552
  r !== void 0 && f(r.index);
473
- }, [d, E]);
553
+ }, [d, C]);
474
554
  (0, react.useLayoutEffect)(() => {
475
555
  if (!l) return () => {};
476
- A();
556
+ k();
477
557
  let e = (e) => {
478
558
  let t = e.target;
479
- g.current?.contains(t) !== !0 && p.current?.contains(t) !== !0 && j();
559
+ m.current?.contains(t) !== !0 && p.current?.contains(t) !== !0 && j();
480
560
  }, t = (e) => {
481
561
  let { target: t } = e;
482
- t instanceof Node && g.current?.contains(t) === !0 || j();
562
+ t instanceof Node && m.current?.contains(t) === !0 || j();
483
563
  }, n = () => {
484
- A();
564
+ k();
485
565
  };
486
566
  return document.addEventListener(`pointerdown`, e, !0), window.addEventListener(`scroll`, t, !0), window.addEventListener(`resize`, n), () => {
487
567
  document.removeEventListener(`pointerdown`, e, !0), window.removeEventListener(`scroll`, t, !0), window.removeEventListener(`resize`, n);
@@ -489,29 +569,29 @@ function C(c) {
489
569
  }, [
490
570
  l,
491
571
  c.options,
492
- A,
572
+ k,
493
573
  j
494
574
  ]), (0, react.useEffect)(() => {
495
575
  if (!l) return;
496
- if (S === !0 || E.length === 0) {
576
+ if (y === !0 || C.length === 0) {
497
577
  j();
498
578
  return;
499
579
  }
500
- if (E.some((e) => e.index === d)) return;
501
- let e = E.find((e) => e.option.value === C) ?? E.at(0);
580
+ if (C.some((e) => e.index === d)) return;
581
+ let e = C.find((e) => e.option.value === b) ?? C.at(0);
502
582
  /* v8 ignore next 3 -- enabled 非空在上一分支已保证 */
503
583
  e !== void 0 && f(e.index);
504
584
  }, [
505
585
  l,
506
- S,
507
- C,
508
- w,
586
+ y,
587
+ b,
588
+ x,
509
589
  d,
510
590
  j,
511
- E
591
+ C
512
592
  ]), (0, react.useLayoutEffect)(() => {
513
593
  if (!l) return;
514
- let e = g.current;
594
+ let e = m.current;
515
595
  /* v8 ignore next 2 -- 同上,menu 在 open 的 commit 之后必然已挂上 */
516
596
  if (e === null) return;
517
597
  let t = e.querySelector(`[data-active="true"]`);
@@ -520,7 +600,7 @@ function C(c) {
520
600
  }, [
521
601
  l,
522
602
  d,
523
- w
603
+ x
524
604
  ]);
525
605
  let F = (e) => {
526
606
  if (e.key === `ArrowDown` || e.key === `ArrowUp`) {
@@ -530,8 +610,8 @@ function C(c) {
530
610
  }
531
611
  P(e.key === `ArrowDown` ? 1 : -1);
532
612
  } else if (e.key === `Home` || e.key === `End`) {
533
- if (e.preventDefault(), l || M(), E.length === 0) return;
534
- let t = e.key === `Home` ? E.at(0) : E.at(-1);
613
+ if (e.preventDefault(), l || M(), C.length === 0) return;
614
+ let t = e.key === `Home` ? C.at(0) : C.at(-1);
535
615
  /* v8 ignore next 3 -- enabled 为空已在上一条返回 */
536
616
  if (t === void 0) return;
537
617
  f(t.index);
@@ -543,7 +623,7 @@ function C(c) {
543
623
  N(d);
544
624
  } else (e.key === `Tab` || e.key === `Escape`) && j();
545
625
  }, I = [], L;
546
- for (let [t, n] of w.entries()) n.group !== L && (n.group !== void 0 && I.push((0, react.createElement)(`div`, {
626
+ for (let [t, n] of x.entries()) n.group !== L && (n.group !== void 0 && I.push((0, react.createElement)(`div`, {
547
627
  key: `group-${t}-${n.group}`,
548
628
  className: `dsu-optionGroup`,
549
629
  role: `presentation`
@@ -551,7 +631,7 @@ function C(c) {
551
631
  key: `option-${n.value}`,
552
632
  type: `button`,
553
633
  role: `option`,
554
- id: `${_}-${t}`,
634
+ id: `${h}-${t}`,
555
635
  className: `dsu-option`,
556
636
  tabIndex: -1,
557
637
  "aria-selected": n.value === c.value,
@@ -581,9 +661,9 @@ function C(c) {
581
661
  strokeLinecap: `round`,
582
662
  strokeLinejoin: `round`
583
663
  }))));
584
- return (0, react.createElement)(v, {
664
+ return (0, react.createElement)(A, {
585
665
  ...c,
586
- controlId: y
666
+ controlId: g
587
667
  }, (0, react.createElement)(`div`, {
588
668
  className: `dsu-selectWrap`,
589
669
  onBlur: (e) => {
@@ -593,22 +673,22 @@ function C(c) {
593
673
  }, (0, react.createElement)(`button`, {
594
674
  ref: p,
595
675
  type: `button`,
596
- id: y,
597
- style: { anchorName: b },
676
+ id: g,
677
+ style: { anchorName: _ },
598
678
  className: `dsu-select dsu-input`,
599
679
  role: `combobox`,
600
680
  "aria-haspopup": `listbox`,
601
681
  "aria-expanded": l,
602
- "aria-controls": `${_}-list`,
603
- "aria-activedescendant": l && k ? `${_}-${d}` : void 0,
604
- "aria-describedby": x,
682
+ "aria-controls": `${h}-list`,
683
+ "aria-activedescendant": l && O ? `${h}-${d}` : void 0,
684
+ "aria-describedby": v,
605
685
  "data-field": c.field,
606
- disabled: S === !0 || w.length === 0,
686
+ disabled: y === !0 || x.length === 0,
607
687
  onClick: () => {
608
688
  l ? j() : M();
609
689
  },
610
690
  onKeyDown: F
611
- }, (0, react.createElement)(`span`, { className: `dsu-selectValue` }, D), (0, react.createElement)(`svg`, {
691
+ }, (0, react.createElement)(`span`, { className: `dsu-selectValue` }, w), (0, react.createElement)(`svg`, {
612
692
  className: `dsu-chevron`,
613
693
  width: 14,
614
694
  height: 14,
@@ -622,39 +702,39 @@ function C(c) {
622
702
  strokeLinecap: `round`,
623
703
  strokeLinejoin: `round`
624
704
  }))), (0, react.createElement)(`div`, {
625
- ref: g,
626
- id: `${_}-list`,
705
+ ref: m,
706
+ id: `${h}-list`,
627
707
  role: `listbox`,
628
708
  className: `dsu-menu`,
629
709
  style: {
630
- positionAnchor: b,
710
+ positionAnchor: _,
631
711
  positionTryFallbacks: `flip-block, flip-inline`
632
712
  },
633
713
  "aria-label": c.label,
634
714
  hidden: !l
635
715
  }, ...I)));
636
716
  }
637
- function w(t) {
638
- let n = !t.writable || t.busy || !t.dirty, r;
639
- return r = t.error === null ? t.writable ? t.dirty ? t.dirtyLabel : t.cleanLabel : t.readOnlyLabel : t.error, (0, react.createElement)(`div`, {
717
+ function I(t) {
718
+ let n = t.blocked === !0, r = !t.writable || t.busy, i = r || !t.dirty || n, a = r || !t.dirty && !n, o;
719
+ return o = t.error === null ? t.writable ? t.dirty ? t.dirtyLabel : t.cleanLabel : t.readOnlyLabel : t.error, (0, react.createElement)(`div`, {
640
720
  className: `dsu-savebar`,
641
- "data-dirty": t.dirty
721
+ "data-dirty": t.dirty || n
642
722
  }, (0, react.createElement)(`button`, {
643
723
  type: `button`,
644
724
  className: `dsu-btn dsu-btnPrimary`,
645
725
  "data-field": `save`,
646
- disabled: n,
726
+ disabled: i,
647
727
  onClick: t.onSave
648
728
  }, t.busy ? t.savingLabel : t.saveLabel), (0, react.createElement)(`button`, {
649
729
  type: `button`,
650
730
  className: `dsu-btn`,
651
731
  "data-field": `discard`,
652
- disabled: n,
732
+ disabled: a,
653
733
  onClick: t.onDiscard
654
734
  }, t.revertLabel), (0, react.createElement)(`span`, {
655
735
  role: `status`,
656
736
  className: t.error === null ? `dsu-status` : `dsu-status dsu-statusError`
657
- }, r));
737
+ }, o));
658
738
  }
659
739
  // node_modules/@jayyuen66/dsh-plugin-shared/dist/card-diff.js
660
740
  function e$1(t, n, r) {
@@ -1008,6 +1088,7 @@ const UI_MESSAGES = {
1008
1088
  saving: "保存中…",
1009
1089
  revert: "撤销",
1010
1090
  saveFailed: "保存失败:{reason}",
1091
+ invalidFields: "有字段超出范围,先修正或撤销后再保存。",
1011
1092
  saveRejected: "保存被宿主拒绝(配置校验未通过或写入被跳过),修改未生效",
1012
1093
  modelSection: "检索模型",
1013
1094
  indexSection: "网络与索引",
@@ -1067,6 +1148,7 @@ const UI_MESSAGES = {
1067
1148
  saving: "Saving…",
1068
1149
  revert: "Revert",
1069
1150
  saveFailed: "save failed: {reason}",
1151
+ invalidFields: "Some fields are out of range; fix them or revert before saving.",
1070
1152
  saveRejected: "save rejected by host (validation failed or write skipped) — changes not applied",
1071
1153
  modelSection: "Retrieval model",
1072
1154
  indexSection: "Network and index",
@@ -1225,9 +1307,9 @@ function numberDisplay(display, schema) {
1225
1307
  /** 检索模型小节:embedding 下拉(按本地后端分组)+ 每组结果数。 */
1226
1308
  function buildModelSection(deps) {
1227
1309
  const { editable, fields, setField, t } = deps;
1228
- const embedding = (0, react.createElement)(C, {
1310
+ const embedding = (0, react.createElement)(F, {
1229
1311
  label: t("embeddingLabel"),
1230
- ...l(t("embeddingHint")),
1312
+ ...y(t("embeddingHint")),
1231
1313
  field: "defaultEmbedding",
1232
1314
  value: fields.embedding,
1233
1315
  options: embeddingOptions(t),
@@ -1236,7 +1318,7 @@ function buildModelSection(deps) {
1236
1318
  setField("defaultEmbedding", next);
1237
1319
  }
1238
1320
  });
1239
- const limit = (0, react.createElement)(b, {
1321
+ const limit = (0, react.createElement)(M, {
1240
1322
  label: t("limitLabel"),
1241
1323
  hint: t("limitInvalid", {
1242
1324
  min: 1,
@@ -1250,11 +1332,15 @@ function buildModelSection(deps) {
1250
1332
  unit: t("unitResults"),
1251
1333
  invalidHint: t("outOfRange"),
1252
1334
  disabled: !editable,
1335
+ resetToken: deps.resetToken,
1336
+ onInvalidChange: (invalid) => {
1337
+ deps.reportInvalid("defaultLimit", invalid);
1338
+ },
1253
1339
  onChange: (next) => {
1254
1340
  setField("defaultLimit", next);
1255
1341
  }
1256
1342
  });
1257
- return (0, react.createElement)(d, { title: t("modelSection") }, embedding, limit);
1343
+ return (0, react.createElement)(C, { title: t("modelSection") }, embedding, limit);
1258
1344
  }
1259
1345
  /** 重建行:root 输入(白名单候选进 <datalist>)+ 触发按钮(在跑时禁用)。 */
1260
1346
  function buildRebuildField(deps) {
@@ -1280,9 +1366,9 @@ function buildRebuildField(deps) {
1280
1366
  disabled: rebuild.phase === "running",
1281
1367
  onClick: deps.onRebuild
1282
1368
  }, rebuild.phase === "running" ? t("rebuildRunning") : t("rebuildButton"));
1283
- return (0, react.createElement)(v, {
1369
+ return (0, react.createElement)(A, {
1284
1370
  label: t("rebuildLabel"),
1285
- ...l(rebuildHintText(t, fields.embedding, roots.length > 0)),
1371
+ ...y(rebuildHintText(t, fields.embedding, roots.length > 0)),
1286
1372
  wide: true
1287
1373
  }, rootDatalist, rebuildInput, rebuildButton);
1288
1374
  }
@@ -1313,9 +1399,9 @@ function buildRebuildStatusRow(deps) {
1313
1399
  /** 网络与索引小节:传输三档、镜像地址、search-first 开关、配额与时效、工作区重建与守护进程状态。 */
1314
1400
  function buildIndexSection(deps) {
1315
1401
  const { editable, fields, setField, t } = deps;
1316
- const transport = (0, react.createElement)(C, {
1402
+ const transport = (0, react.createElement)(F, {
1317
1403
  label: t("transportLabel"),
1318
- ...l(t("transportHint")),
1404
+ ...y(t("transportHint")),
1319
1405
  field: "transport",
1320
1406
  value: fields.transport,
1321
1407
  options: transportOptions(t),
@@ -1324,9 +1410,9 @@ function buildIndexSection(deps) {
1324
1410
  setField("transport", next);
1325
1411
  }
1326
1412
  });
1327
- const endpoint = (0, react.createElement)(x, {
1413
+ const endpoint = (0, react.createElement)(N, {
1328
1414
  label: t("endpointLabel"),
1329
- ...l(t("endpointHint")),
1415
+ ...y(t("endpointHint")),
1330
1416
  field: "hfEndpoint",
1331
1417
  value: fields.hfEndpoint,
1332
1418
  placeholder: EMBEDDING_MIRROR_URL,
@@ -1336,9 +1422,9 @@ function buildIndexSection(deps) {
1336
1422
  setField("hfEndpoint", next.trim() === "" ? void 0 : next.trim());
1337
1423
  }
1338
1424
  });
1339
- const enforce = (0, react.createElement)(y, {
1425
+ const enforce = (0, react.createElement)(j, {
1340
1426
  label: t("enforceLabel"),
1341
- ...l(t("enforceHint")),
1427
+ ...y(t("enforceHint")),
1342
1428
  field: "enforceSearchFirst",
1343
1429
  checked: fields.enforceSearchFirst,
1344
1430
  disabled: !editable,
@@ -1346,9 +1432,9 @@ function buildIndexSection(deps) {
1346
1432
  setField("enforceSearchFirst", next);
1347
1433
  }
1348
1434
  });
1349
- const budget = (0, react.createElement)(b, {
1435
+ const budget = (0, react.createElement)(M, {
1350
1436
  label: t("budgetLabel"),
1351
- ...l(t("budgetHint", { default: 3 })),
1437
+ ...y(t("budgetHint", { default: 3 })),
1352
1438
  field: "grepBudgetPerSearch",
1353
1439
  value: numberDisplay(fields.grepBudget, BUDGET_SCHEMA),
1354
1440
  min: BUDGET_SCHEMA.minValue ?? 1,
@@ -1357,13 +1443,17 @@ function buildIndexSection(deps) {
1357
1443
  unit: t("unitTimes"),
1358
1444
  invalidHint: t("outOfRange"),
1359
1445
  disabled: !editable,
1446
+ resetToken: deps.resetToken,
1447
+ onInvalidChange: (invalid) => {
1448
+ deps.reportInvalid("grepBudgetPerSearch", invalid);
1449
+ },
1360
1450
  onChange: (next) => {
1361
1451
  setField("grepBudgetPerSearch", next);
1362
1452
  }
1363
1453
  });
1364
- const window = (0, react.createElement)(b, {
1454
+ const window = (0, react.createElement)(M, {
1365
1455
  label: t("windowLabel"),
1366
- ...l(t("windowHint", { default: 10 })),
1456
+ ...y(t("windowHint", { default: 10 })),
1367
1457
  field: "unlockWindowMin",
1368
1458
  value: numberDisplay(fields.unlockWindow, WINDOW_SCHEMA),
1369
1459
  min: WINDOW_SCHEMA.minValue ?? 1,
@@ -1372,20 +1462,25 @@ function buildIndexSection(deps) {
1372
1462
  unit: t("unitMinutes"),
1373
1463
  invalidHint: t("outOfRange"),
1374
1464
  disabled: !editable,
1465
+ resetToken: deps.resetToken,
1466
+ onInvalidChange: (invalid) => {
1467
+ deps.reportInvalid("unlockWindowMin", invalid);
1468
+ },
1375
1469
  onChange: (next) => {
1376
1470
  setField("unlockWindowMin", next);
1377
1471
  }
1378
1472
  });
1379
- return (0, react.createElement)(d, { title: t("indexSection") }, transport, endpoint, enforce, budget, window, buildDaemonNote(deps), buildRebuildField(deps), buildRebuildStatusRow(deps));
1473
+ return (0, react.createElement)(C, { title: t("indexSection") }, transport, endpoint, enforce, budget, window, buildDaemonNote(deps), buildRebuildField(deps), buildRebuildStatusRow(deps));
1380
1474
  }
1381
1475
  /** 卡片主体:检索模型 / 网络与索引两节 + 保存条。 */
1382
1476
  function buildCardBody(deps) {
1383
1477
  const { t } = deps;
1384
- const saveBar = (0, react.createElement)(w, {
1478
+ const saveBar = (0, react.createElement)(I, {
1385
1479
  dirty: deps.dirty,
1480
+ blocked: deps.blocked,
1386
1481
  busy: deps.busy,
1387
1482
  writable: deps.writable,
1388
- error: deps.saveError,
1483
+ error: deps.saveError ?? (deps.blocked ? t("invalidFields") : null),
1389
1484
  saveLabel: t("save"),
1390
1485
  savingLabel: t("saving"),
1391
1486
  revertLabel: t("revert"),
@@ -1395,7 +1490,7 @@ function buildCardBody(deps) {
1395
1490
  onSave: deps.onSave,
1396
1491
  onDiscard: deps.onDiscard
1397
1492
  });
1398
- return (0, react.createElement)(u, null, buildModelSection(deps), buildIndexSection(deps), saveBar);
1493
+ return (0, react.createElement)(S, null, buildModelSection(deps), buildIndexSection(deps), saveBar);
1399
1494
  }
1400
1495
  /** 显式字段写入(schema-coverage 门禁按 set('字段名') 字面量识别绑定)。 */
1401
1496
  function pushFieldWrite(ops, key, draft, set) {
@@ -1546,8 +1641,10 @@ function ZgCard(props) {
1546
1641
  const [saveError, setSaveError] = (0, react.useState)(null);
1547
1642
  const rebuildView = useRebuild(t, props.rebuildRemote);
1548
1643
  const fields = draftFields(touched, value);
1549
- const dirtyCount = t$1(touched, value).length;
1550
- const dirty = dirtyCount > 0;
1644
+ const invalid = x();
1645
+ const { blocked, fields: invalidFields, resetToken, reportInvalid } = invalid;
1646
+ const dirtyCount = (/* @__PURE__ */ new Set([...t$1(touched, value), ...invalidFields])).size;
1647
+ const dirty = dirtyCount > 0 || blocked;
1551
1648
  const setField = (field, draft) => {
1552
1649
  setTouched((prev) => ({
1553
1650
  ...prev,
@@ -1556,7 +1653,7 @@ function ZgCard(props) {
1556
1653
  };
1557
1654
  const save = async () => {
1558
1655
  const keys = t$1(touched, value);
1559
- if (keys.length === 0) return;
1656
+ if (keys.length === 0 || blocked) return;
1560
1657
  setBusy(true);
1561
1658
  setSaveError(null);
1562
1659
  const ops = [];
@@ -1580,10 +1677,12 @@ function ZgCard(props) {
1580
1677
  const next = Object.fromEntries(Object.entries(touched).filter(([entryKey]) => !savedKeys.has(entryKey)));
1581
1678
  setBusy(false);
1582
1679
  setTouched(next);
1680
+ invalid.clear();
1583
1681
  };
1584
1682
  const discard = () => {
1585
1683
  setTouched({});
1586
1684
  setSaveError(null);
1685
+ invalid.clear();
1587
1686
  };
1588
1687
  return buildCardBody({
1589
1688
  t,
@@ -1595,6 +1694,9 @@ function ZgCard(props) {
1595
1694
  root: rebuildView.root,
1596
1695
  rebuild: rebuildView.state,
1597
1696
  dirty,
1697
+ blocked,
1698
+ resetToken,
1699
+ reportInvalid,
1598
1700
  dirtyCount,
1599
1701
  busy,
1600
1702
  saveError,
@@ -1616,12 +1718,14 @@ const inject = [
1616
1718
  ];
1617
1719
  function apply(ctx) {
1618
1720
  ctx.effect(() => {
1721
+ const disposeShared = v();
1619
1722
  const tag = document.createElement("style");
1620
1723
  tag.id = "zvec-grep-card-css";
1621
- tag.textContent = `${CARD_CSS}\n${c}`;
1724
+ tag.textContent = CARD_CSS;
1622
1725
  document.head.append(tag);
1623
1726
  return () => {
1624
1727
  tag.remove();
1728
+ disposeShared();
1625
1729
  };
1626
1730
  }, "zvec-grep-card: styles");
1627
1731
  const scope = ctx.configForms.get(NS);