@jayyuen66/dsh-zvec-grep 0.1.14 → 0.1.16

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,7 +88,7 @@ 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-C1lrHILm.js
91
+ // node_modules/@jayyuen66/dsh-plugin-shared/dist/card-ui-yf56_khz.js
92
92
  const c = `
93
93
  .dsu-form{display:flex;flex-direction:column}
94
94
  .dsu-section{margin-top:24px;padding-top:24px;border-top:.5px solid var(--dsw-alias-border-l1)}
@@ -109,11 +109,11 @@ const c = `
109
109
  .dsu-helpBtn{appearance:none;border:0;background:transparent;padding:0;width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center;color:var(--dsw-alias-label-tertiary);cursor:help;border-radius:50%;flex:none}
110
110
  .dsu-help:hover .dsu-helpBtn,.dsu-helpBtn:focus-visible{color:var(--dsw-alias-label-primary)}
111
111
  .dsu-helpBtn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
112
- .dsu-tip{position:fixed;z-index:60;box-sizing:border-box;max-width:min(340px,calc(100vw - 16px));max-height:calc(100vh - 16px);overflow:auto;overflow-wrap:anywhere;padding:10px 12px;border-radius:10px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);box-shadow:0 12px 32px rgb(0 0 0 / 45%);font-size:12px;line-height:1.6;font-weight:400;color:var(--dsw-alias-label-secondary)}
112
+ .dsu-tip{width:max-content;position:fixed;position-area:block-end span-inline-end;justify-self:start;margin-top:8px;z-index:60;box-sizing:border-box;max-width:min(340px,calc(100vw - 16px));max-height:calc(100vh - 16px);overflow:auto;overflow-wrap:anywhere;padding:10px 12px;border-radius:10px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);box-shadow:0 12px 32px rgb(0 0 0 / 45%);font-size:12px;line-height:1.6;font-weight:400;color:var(--dsw-alias-label-secondary)}
113
113
  .dsu-input{width:100%;height:34px;padding:0 12px;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px}
114
114
  .dsu-input:focus-visible{outline:none;border-color:var(--dsw-alias-state-business-primary)}
115
115
  .dsu-input[aria-invalid="true"]{border-color:var(--dsw-alias-state-error-primary)}
116
- .dsu-input:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}
116
+ .dsu-input:disabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}
117
117
  .dsu-input::placeholder{color:var(--dsw-alias-label-tertiary)}
118
118
  .dsu-textarea{height:auto;min-height:96px;padding:8px 12px;line-height:1.6;resize:vertical}
119
119
  .dsu-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
@@ -134,7 +134,7 @@ const c = `
134
134
  .dsu-selectValue{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
135
135
  .dsu-chevron{flex:none;color:var(--dsw-alias-label-tertiary);transition:transform .16s}
136
136
  .dsu-select[aria-expanded="true"] .dsu-chevron{transform:rotate(180deg)}
137
- .dsu-menu{position:fixed;z-index:70;padding:4px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);border-radius:12px;box-shadow:0 12px 32px rgb(0 0 0 / 50%);max-height:280px;overflow:auto}
137
+ .dsu-menu{position:fixed;position-area:block-end span-inline-end;justify-self:start;margin-top:6px;z-index:70;padding:4px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);border-radius:12px;box-shadow:0 12px 32px rgb(0 0 0 / 50%);max-height:280px;overflow:auto}
138
138
  .dsu-option{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:1.4;width:100%;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 10px;border-radius:8px;cursor:pointer;text-align:left}
139
139
  .dsu-option:hover,.dsu-option[data-active="true"]{background:var(--dsw-alias-bg-layer-3)}
140
140
  .dsu-option:disabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}
@@ -177,64 +177,80 @@ function u(t) {
177
177
  function d(t) {
178
178
  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
179
  }
180
- function m(a) {
181
- let c = (0, react.useId)(), [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(!1), p = (0, react.useRef)(!1), m = (0, react.useRef)(!1), h = (0, react.useRef)(!1), g = (0, react.useRef)(null), _ = (0, react.useRef)(null), v = (0, react.useRef)(null), y = (0, react.useCallback)(() => {
182
- v.current !== null && (clearTimeout(v.current), v.current = null);
183
- }, []), b = (0, react.useCallback)(() => {
184
- let e = g.current, t = _.current;
180
+ function m() {
181
+ return `happyDOM` in globalThis ? !1 : typeof CSS < `u` && typeof CSS.supports == `function` && CSS.supports(`position-area: block-end`);
182
+ }
183
+ function h(e, t) {
184
+ let n = Math.abs(t.left - e.left) <= 2, r = Math.abs(t.right - e.right) <= 2;
185
+ if (!n && !r) return !0;
186
+ let i = t.top >= e.bottom - 2, a = t.bottom <= e.top + 2;
187
+ return !i && !a;
188
+ }
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;
185
194
  /* v8 ignore next 3 -- place 只在 open 的 layout effect 与挂载期监听器里调用;refs 为空只可能是卸载竞态 */
186
195
  if (e === null || t === null) return;
187
- let n = e.getBoundingClientRect(), r = t.offsetWidth, i = t.offsetHeight, { left: a } = n, o = n.bottom + 8;
188
- o + i > window.innerHeight - 8 && (o = n.top - i - 8), a + r > window.innerWidth - 8 && (a = window.innerWidth - r - 8);
189
- let s = Math.max(8, window.innerWidth - r - 8), c = Math.max(8, window.innerHeight - i - 8);
190
- t.style.left = `${Math.min(Math.max(8, a), s)}px`, t.style.top = `${Math.min(Math.max(8, o), c)}px`;
191
- }, []), x = (0, react.useCallback)(() => {
192
- y(), h.current = !1, f(!1), u(!1);
193
- }, [y]), S = (0, react.useCallback)(() => {
194
- y(), u(!0);
195
- }, [y]), C = (0, react.useCallback)(() => {
196
- y(), p.current || m.current || h.current || (v.current = setTimeout(() => {
196
+ let n = m() && t.style.positionArea !== `none`, r = e.getBoundingClientRect();
197
+ if (n && !h(r, t.getBoundingClientRect())) return;
198
+ n && (t.style.positionArea = `none`), t.style.marginTop = `0px`;
199
+ let i = t.offsetWidth, a = t.offsetHeight, { left: o } = r, s = r.bottom + 8;
200
+ s + a > window.innerHeight - 8 && (s = r.top - a - 8), o + i > window.innerWidth - 8 && (o = window.innerWidth - i - 8);
201
+ let c = Math.max(8, window.innerWidth - i - 8), l = Math.max(8, window.innerHeight - a - 8);
202
+ 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(() => {
197
209
  /* v8 ignore next 3 -- 任何重新进入/钉住都会 cancelHide;这次复查只防未来的异步路径 */
198
- v.current = null, p.current || m.current || h.current || u(!1);
210
+ b.current = null, f.current || p.current || g.current || d(!1);
199
211
  }, 120));
200
- }, [y]), w = (0, react.useCallback)((e) => {
201
- h.current = e, f(e);
212
+ }, [x]), E = (0, react.useCallback)((e) => {
213
+ g.current = e;
202
214
  }, []);
203
215
  (0, react.useLayoutEffect)(() => {
204
- if (!l) return () => {};
205
- b();
216
+ if (!u) return () => {};
217
+ S();
206
218
  let e = (e) => {
207
219
  let { target: t } = e;
208
- t instanceof Node && _.current?.contains(t) === !0 || (h.current ? b() : x());
220
+ t instanceof Node && y.current?.contains(t) === !0 || (g.current ? S() : C());
209
221
  }, t = () => {
210
- b();
222
+ S();
223
+ }, n = (e) => {
224
+ let t = e.target;
225
+ _.current?.contains(t) !== !0 && C();
211
226
  };
212
- return window.addEventListener(`scroll`, e, !0), window.addEventListener(`resize`, t), () => {
213
- window.removeEventListener(`scroll`, e, !0), window.removeEventListener(`resize`, t);
227
+ return document.addEventListener(`pointerdown`, n, !0), window.addEventListener(`scroll`, e, !0), window.addEventListener(`resize`, t), () => {
228
+ document.removeEventListener(`pointerdown`, n, !0), window.removeEventListener(`scroll`, e, !0), window.removeEventListener(`resize`, t);
214
229
  };
215
230
  }, [
216
- l,
231
+ u,
217
232
  a.detail,
218
- b,
219
- x
233
+ S,
234
+ C
220
235
  ]), (0, react.useEffect)(() => {
221
- if (!l) return () => {};
236
+ if (!u) return () => {};
222
237
  let e = (e) => {
223
- e.key === `Escape` && x();
238
+ e.key === `Escape` && C();
224
239
  };
225
240
  return document.addEventListener(`keydown`, e), () => {
226
241
  document.removeEventListener(`keydown`, e);
227
242
  };
228
- }, [l, x]), (0, react.useEffect)(() => y, [y]);
229
- let T = (0, react.createElement)(`button`, {
230
- ref: g,
243
+ }, [u, C]), (0, react.useEffect)(() => x, [x]);
244
+ let D = (0, react.createElement)(`button`, {
245
+ ref: v,
231
246
  type: `button`,
232
247
  className: `dsu-helpBtn`,
248
+ style: { anchorName: l },
233
249
  "aria-label": `${a.label} 说明`,
234
- "aria-describedby": c,
235
- "aria-pressed": d,
250
+ "aria-expanded": u,
251
+ "aria-controls": c,
236
252
  onClick: () => {
237
- h.current ? x() : (w(!0), S());
253
+ g.current ? C() : (E(!0), w());
238
254
  }
239
255
  }, (0, react.createElement)(`svg`, {
240
256
  width: 12,
@@ -258,44 +274,49 @@ function m(a) {
258
274
  cy: 4.3,
259
275
  r: .8,
260
276
  fill: `currentColor`
261
- }))), E = (0, react.createElement)(`div`, {
262
- ref: _,
277
+ }))), O = (0, react.createElement)(`div`, {
278
+ ref: y,
263
279
  id: c,
264
280
  role: `tooltip`,
265
281
  className: `dsu-tip`,
266
- hidden: !l
267
- }, a.detail), D = a.showLabel === !1 ? null : (0, react.createElement)(`span`, { className: `dsu-label${a.compact === !0 ? ` dsu-labelMono` : ``}` }, a.label);
282
+ style: {
283
+ positionAnchor: l,
284
+ positionTryFallbacks: `flip-block, flip-inline`
285
+ },
286
+ hidden: !u
287
+ }, a.detail), k = a.showLabel === !1 ? null : (0, react.createElement)(`span`, { className: `dsu-label${a.compact === !0 ? ` dsu-labelMono` : ``}` }, a.label);
268
288
  return (0, react.createElement)(`span`, {
289
+ ref: _,
269
290
  className: `dsu-help`,
270
291
  onMouseEnter: () => {
271
- p.current = !0, S();
292
+ f.current = !0, w();
272
293
  },
273
294
  onMouseLeave: () => {
274
- p.current = !1, C();
295
+ f.current = !1, T();
275
296
  },
276
297
  onFocus: () => {
277
- m.current = !0, S();
298
+ p.current = !0, w();
278
299
  },
279
300
  onBlur: (e) => {
280
301
  let t = e.relatedTarget;
281
- t instanceof Node && e.currentTarget.contains(t) || (m.current = !1, C());
302
+ t instanceof Node && e.currentTarget.contains(t) || (p.current = !1, T());
282
303
  }
283
- }, D, T, E);
304
+ }, k, D, O);
284
305
  }
285
- function h(t) {
306
+ function _(t) {
286
307
  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`, {
287
308
  className: n,
288
309
  htmlFor: t.controlId
289
310
  }, t.label);
290
- return (0, react.createElement)(`div`, { className: `dsu-labelRow` }, r, t.detail === void 0 ? null : (0, react.createElement)(m, {
311
+ return (0, react.createElement)(`div`, { className: `dsu-labelRow` }, r, t.detail === void 0 ? null : (0, react.createElement)(g, {
291
312
  label: t.label,
292
313
  detail: t.detail,
293
314
  showLabel: !1
294
315
  }));
295
316
  }
296
- function g(t) {
317
+ function v(t) {
297
318
  let n = t.controlId === void 0 ? void 0 : `${t.controlId}-hint`;
298
- return (0, react.createElement)(`div`, { className: `dsu-field${t.wide === !0 ? ` dsu-fieldWide` : ``}` }, (0, react.createElement)(`div`, { className: `dsu-fieldMeta` }, (0, react.createElement)(h, {
319
+ return (0, react.createElement)(`div`, { className: `dsu-field${t.wide === !0 ? ` dsu-fieldWide` : ``}` }, (0, react.createElement)(`div`, { className: `dsu-fieldMeta` }, (0, react.createElement)(_, {
299
320
  label: t.label,
300
321
  detail: t.detail,
301
322
  compact: t.compact,
@@ -305,9 +326,9 @@ function g(t) {
305
326
  id: n
306
327
  }, t.hint)), (0, react.createElement)(`div`, { className: `dsu-control` }, t.children));
307
328
  }
308
- function _(t) {
329
+ function y(t) {
309
330
  let n = (0, react.useId)(), i = t.hint === void 0 ? void 0 : `${n}-hint`;
310
- return (0, react.createElement)(g, {
331
+ return (0, react.createElement)(v, {
311
332
  ...t,
312
333
  controlId: n
313
334
  }, (0, react.createElement)(`button`, {
@@ -324,55 +345,57 @@ function _(t) {
324
345
  }
325
346
  }, (0, react.createElement)(`span`, { className: `dsu-knob` })));
326
347
  }
327
- function v(t) {
328
- 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 = (0, react.useRef)(void 0), f = (0, react.useId)(), p = (0, react.useId)(), m = [t.hint === void 0 ? void 0 : `${f}-hint`, l ? p : void 0].filter((e) => e !== void 0), h = m.length === 0 ? void 0 : m.join(` `);
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(` `);
329
350
  (0, react.useEffect)(() => {
330
- t.value !== d.current && (d.current = t.value, c(i), u(!1));
351
+ t.value !== p.current && (p.current = t.value, c(i), u(!1), f(!1));
331
352
  }, [t.value, i]);
332
- let _ = (e) => {
353
+ let x = (e) => {
333
354
  let n = t.min ?? -1 / 0, r = t.max ?? 1 / 0;
334
355
  if (!Number.isFinite(e) || e < n || e > r) return !1;
335
356
  let { step: i } = t;
336
357
  if (i === void 0 || i <= 0) return !0;
337
358
  let a = (e - (t.min ?? 0)) / i;
338
359
  return Math.abs(a - Math.round(a)) < 1e-9;
339
- }, v = (e) => {
340
- if (c(e), e === ``) {
341
- u(!1), d.current = void 0, t.onChange(void 0);
360
+ }, S = (e) => {
361
+ if (f(!1), c(e), e === ``) {
362
+ u(!1), p.current = void 0, t.onChange(void 0);
342
363
  return;
343
364
  }
344
365
  let n = Number(e);
345
- _(n) ? (u(!1), d.current = n, t.onChange(n)) : u(!0);
346
- }, y = () => {
366
+ x(n) ? (u(!1), p.current = n, t.onChange(n)) : u(!0);
367
+ }, C = () => {
347
368
  a === `` || l || c(String(Number(a)));
369
+ }, w = () => {
370
+ f(l), C();
348
371
  };
349
- return (0, react.createElement)(g, {
372
+ return (0, react.createElement)(v, {
350
373
  ...t,
351
- controlId: f
374
+ controlId: m
352
375
  }, (0, react.createElement)(`div`, { className: `dsu-numberWrap` }, (0, react.createElement)(`div`, { className: `dsu-number` }, (0, react.createElement)(`input`, {
353
376
  className: `dsu-input`,
354
377
  type: `number`,
355
378
  inputMode: `numeric`,
356
- id: f,
379
+ id: m,
357
380
  value: a,
358
381
  min: t.min,
359
382
  max: t.max,
360
383
  step: t.step,
361
384
  placeholder: t.placeholder,
362
- "aria-invalid": l || void 0,
363
- "aria-describedby": h,
385
+ "aria-invalid": _ || void 0,
386
+ "aria-describedby": b,
364
387
  "data-field": t.field,
365
388
  disabled: t.disabled === !0,
366
389
  onChange: (e) => {
367
- v(e.target.value);
390
+ S(e.target.value);
368
391
  },
369
- onBlur: y
370
- }), t.unit === void 0 ? null : (0, react.createElement)(`span`, { className: `dsu-unit` }, t.unit)), l ? (0, react.createElement)(`p`, {
392
+ onBlur: w
393
+ }), t.unit === void 0 ? null : (0, react.createElement)(`span`, { className: `dsu-unit` }, t.unit)), _ ? (0, react.createElement)(`p`, {
371
394
  className: `dsu-error`,
372
- id: p
395
+ id: h
373
396
  }, t.invalidHint) : null));
374
397
  }
375
- function y(t) {
398
+ function x(t) {
376
399
  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`;
377
400
  (0, react.useEffect)(() => {
378
401
  o || a(t.value);
@@ -395,65 +418,70 @@ function y(t) {
395
418
  a(e.target.value), t.onChange(e.target.value);
396
419
  }
397
420
  };
398
- return (0, react.createElement)(g, {
421
+ return (0, react.createElement)(v, {
399
422
  ...t,
400
423
  controlId: l
401
424
  }, t.multiline === !0 ? (0, react.createElement)(`textarea`, d) : (0, react.createElement)(`input`, d));
402
425
  }
403
- function x(c) {
404
- 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)(), _ = (0, react.useId)(), v = c.hint === void 0 ? void 0 : `${_}-hint`, { disabled: y, value: b, options: x, onChange: S } = c, C = (0, react.useMemo)(() => x.map((e, t) => ({
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) => ({
405
428
  option: e,
406
429
  index: t
407
- })).filter((e) => e.option.disabled !== !0), [x]), w = x.find((e) => e.value === b)?.label ?? b, T = x[d], E = T !== void 0 && T.disabled !== !0, D = (0, react.useCallback)(() => {
408
- let e = p.current, t = m.current;
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;
409
432
  /* v8 ignore next 3 -- place 只在 open 的 layout effect 里调用;refs 为空只可能是卸载竞态 */
410
433
  if (e === null || t === null) return;
411
- let n = e.getBoundingClientRect(), r = Math.min(n.width, window.innerWidth - 16), { left: i } = n;
412
- i + r > window.innerWidth - 8 && (i = window.innerWidth - r - 8);
413
- let a = t.offsetHeight, o = n.bottom + 6;
414
- o + a > window.innerHeight - 8 && (o = n.top - a - 6);
415
- let s = Math.max(8, window.innerWidth - r - 8), c = Math.max(8, window.innerHeight - a - 8);
416
- t.style.width = `${r}px`, t.style.left = `${Math.min(Math.max(8, i), s)}px`, t.style.top = `${Math.min(Math.max(8, o), c)}px`;
417
- }, []), O = (0, react.useCallback)(() => {
434
+ let n = e.getBoundingClientRect(), r = Math.min(n.width, window.innerWidth - 16);
435
+ t.style.width = `${r}px`;
436
+ let i = m() && t.style.positionArea !== `none`;
437
+ if (i && !h(n, t.getBoundingClientRect())) return;
438
+ i && (t.style.positionArea = `none`), t.style.marginTop = `0px`;
439
+ let { left: a } = n;
440
+ a + r > window.innerWidth - 8 && (a = window.innerWidth - r - 8);
441
+ let o = t.offsetHeight, s = n.bottom + 6;
442
+ s + o > window.innerHeight - 8 && (s = n.top - o - 6);
443
+ let c = Math.max(8, window.innerWidth - r - 8), l = Math.max(8, window.innerHeight - o - 8);
444
+ t.style.left = `${Math.min(Math.max(8, a), c)}px`, t.style.top = `${Math.min(Math.max(8, s), l)}px`;
445
+ }, []), j = (0, react.useCallback)(() => {
418
446
  u(!1);
419
- }, []), k = (0, react.useCallback)(() => {
420
- if (y === !0) return;
421
- let e = C.find((e) => e.option.value === b) ?? C.at(0);
447
+ }, []), M = (0, react.useCallback)(() => {
448
+ if (S === !0) return;
449
+ let e = E.find((e) => e.option.value === C) ?? E.at(0);
422
450
  e !== void 0 && (f(e.index), u(!0));
423
451
  }, [
424
- y,
425
- b,
426
- C
427
- ]), A = (0, react.useCallback)((e) => {
452
+ S,
453
+ C,
454
+ E
455
+ ]), N = (0, react.useCallback)((e) => {
428
456
  /* v8 ignore next 3 -- 浮层只能经由 openMenu 打开;组件禁用时打不开 */
429
- if (y === !0) return;
430
- let t = x[e];
431
- /* v8 ignore next 3 -- disabled 选项在浏览器里不派发 click;越界下标由调用面保证 */
432
- t !== void 0 && t.disabled !== !0 && (S(t.value), O(), p.current?.focus());
457
+ if (S === !0) return;
458
+ let t = w[e];
459
+ /* v8 ignore next 3 -- disabled 选项在浏览器里不派发 click;越界下标由调用方保证 */
460
+ t !== void 0 && t.disabled !== !0 && (T(t.value), j(), p.current?.focus());
433
461
  }, [
434
- y,
435
- x,
436
462
  S,
437
- O
438
- ]), j = (0, react.useCallback)((e) => {
439
- let t = C.findIndex((e) => e.index === d);
463
+ w,
464
+ T,
465
+ j
466
+ ]), P = (0, react.useCallback)((e) => {
467
+ let t = E.findIndex((e) => e.index === d);
440
468
  /* v8 ignore next 5 -- open 时归一 effect 已保证 enabled 非空且 active 落在可用项上 */
441
- if (t === -1 || C.length === 0) return;
442
- let n = (t + e + C.length) % C.length, r = C[n];
469
+ if (t === -1 || E.length === 0) return;
470
+ let n = (t + e + E.length) % E.length, r = E[n];
443
471
  /* v8 ignore next 3 -- next 由取模保证在界内 */
444
472
  r !== void 0 && f(r.index);
445
- }, [d, C]);
473
+ }, [d, E]);
446
474
  (0, react.useLayoutEffect)(() => {
447
475
  if (!l) return () => {};
448
- D();
476
+ A();
449
477
  let e = (e) => {
450
478
  let t = e.target;
451
- m.current?.contains(t) !== !0 && p.current?.contains(t) !== !0 && O();
479
+ g.current?.contains(t) !== !0 && p.current?.contains(t) !== !0 && j();
452
480
  }, t = (e) => {
453
481
  let { target: t } = e;
454
- t instanceof Node && m.current?.contains(t) === !0 || O();
482
+ t instanceof Node && g.current?.contains(t) === !0 || j();
455
483
  }, n = () => {
456
- D();
484
+ A();
457
485
  };
458
486
  return document.addEventListener(`pointerdown`, e, !0), window.addEventListener(`scroll`, t, !0), window.addEventListener(`resize`, n), () => {
459
487
  document.removeEventListener(`pointerdown`, e, !0), window.removeEventListener(`scroll`, t, !0), window.removeEventListener(`resize`, n);
@@ -461,29 +489,29 @@ function x(c) {
461
489
  }, [
462
490
  l,
463
491
  c.options,
464
- D,
465
- O
492
+ A,
493
+ j
466
494
  ]), (0, react.useEffect)(() => {
467
495
  if (!l) return;
468
- if (y === !0 || C.length === 0) {
469
- O();
496
+ if (S === !0 || E.length === 0) {
497
+ j();
470
498
  return;
471
499
  }
472
- if (C.some((e) => e.index === d)) return;
473
- let e = C.find((e) => e.option.value === b) ?? C.at(0);
500
+ if (E.some((e) => e.index === d)) return;
501
+ let e = E.find((e) => e.option.value === C) ?? E.at(0);
474
502
  /* v8 ignore next 3 -- enabled 非空在上一分支已保证 */
475
503
  e !== void 0 && f(e.index);
476
504
  }, [
477
505
  l,
478
- y,
479
- b,
480
- x,
506
+ S,
507
+ C,
508
+ w,
481
509
  d,
482
- O,
483
- C
510
+ j,
511
+ E
484
512
  ]), (0, react.useLayoutEffect)(() => {
485
513
  if (!l) return;
486
- let e = m.current;
514
+ let e = g.current;
487
515
  /* v8 ignore next 2 -- 同上,menu 在 open 的 commit 之后必然已挂上 */
488
516
  if (e === null) return;
489
517
  let t = e.querySelector(`[data-active="true"]`);
@@ -492,38 +520,38 @@ function x(c) {
492
520
  }, [
493
521
  l,
494
522
  d,
495
- x
523
+ w
496
524
  ]);
497
- let M = (e) => {
525
+ let F = (e) => {
498
526
  if (e.key === `ArrowDown` || e.key === `ArrowUp`) {
499
527
  if (e.preventDefault(), !l) {
500
- k();
528
+ M();
501
529
  return;
502
530
  }
503
- j(e.key === `ArrowDown` ? 1 : -1);
531
+ P(e.key === `ArrowDown` ? 1 : -1);
504
532
  } else if (e.key === `Home` || e.key === `End`) {
505
- if (e.preventDefault(), l || k(), C.length === 0) return;
506
- let t = e.key === `Home` ? C.at(0) : C.at(-1);
533
+ if (e.preventDefault(), l || M(), E.length === 0) return;
534
+ let t = e.key === `Home` ? E.at(0) : E.at(-1);
507
535
  /* v8 ignore next 3 -- enabled 为空已在上一条返回 */
508
536
  if (t === void 0) return;
509
537
  f(t.index);
510
538
  } else if (e.key === `Enter` || e.key === ` `) {
511
539
  if (e.preventDefault(), !l) {
512
- k();
540
+ M();
513
541
  return;
514
542
  }
515
- A(d);
516
- } else (e.key === `Tab` || e.key === `Escape`) && O();
517
- }, N = [], P;
518
- for (let [t, n] of x.entries()) n.group !== P && (n.group !== void 0 && N.push((0, react.createElement)(`div`, {
543
+ N(d);
544
+ } else (e.key === `Tab` || e.key === `Escape`) && j();
545
+ }, I = [], L;
546
+ for (let [t, n] of w.entries()) n.group !== L && (n.group !== void 0 && I.push((0, react.createElement)(`div`, {
519
547
  key: `group-${t}-${n.group}`,
520
548
  className: `dsu-optionGroup`,
521
549
  role: `presentation`
522
- }, n.group)), P = n.group), N.push((0, react.createElement)(`button`, {
550
+ }, n.group)), L = n.group), I.push((0, react.createElement)(`button`, {
523
551
  key: `option-${n.value}`,
524
552
  type: `button`,
525
553
  role: `option`,
526
- id: `${h}-${t}`,
554
+ id: `${_}-${t}`,
527
555
  className: `dsu-option`,
528
556
  tabIndex: -1,
529
557
  "aria-selected": n.value === c.value,
@@ -533,7 +561,7 @@ function x(c) {
533
561
  e.preventDefault();
534
562
  },
535
563
  onClick: () => {
536
- A(t);
564
+ N(t);
537
565
  },
538
566
  onMouseEnter: () => {
539
567
  /* v8 ignore next -- happy-dom 对 disabled 元素不派发 mouse 事件;浏览器实现各有差异,保留禁用检查 */
@@ -553,33 +581,34 @@ function x(c) {
553
581
  strokeLinecap: `round`,
554
582
  strokeLinejoin: `round`
555
583
  }))));
556
- return (0, react.createElement)(g, {
584
+ return (0, react.createElement)(v, {
557
585
  ...c,
558
- controlId: _
586
+ controlId: y
559
587
  }, (0, react.createElement)(`div`, {
560
588
  className: `dsu-selectWrap`,
561
589
  onBlur: (e) => {
562
590
  let t = e.relatedTarget;
563
- t instanceof Node && e.currentTarget.contains(t) || O();
591
+ t instanceof Node && e.currentTarget.contains(t) || j();
564
592
  }
565
593
  }, (0, react.createElement)(`button`, {
566
594
  ref: p,
567
595
  type: `button`,
568
- id: _,
596
+ id: y,
597
+ style: { anchorName: b },
569
598
  className: `dsu-select dsu-input`,
570
599
  role: `combobox`,
571
600
  "aria-haspopup": `listbox`,
572
601
  "aria-expanded": l,
573
- "aria-controls": `${h}-list`,
574
- "aria-activedescendant": l && E ? `${h}-${d}` : void 0,
575
- "aria-describedby": v,
602
+ "aria-controls": `${_}-list`,
603
+ "aria-activedescendant": l && k ? `${_}-${d}` : void 0,
604
+ "aria-describedby": x,
576
605
  "data-field": c.field,
577
- disabled: y === !0 || x.length === 0,
606
+ disabled: S === !0 || w.length === 0,
578
607
  onClick: () => {
579
- l ? O() : k();
608
+ l ? j() : M();
580
609
  },
581
- onKeyDown: M
582
- }, (0, react.createElement)(`span`, { className: `dsu-selectValue` }, w), (0, react.createElement)(`svg`, {
610
+ onKeyDown: F
611
+ }, (0, react.createElement)(`span`, { className: `dsu-selectValue` }, D), (0, react.createElement)(`svg`, {
583
612
  className: `dsu-chevron`,
584
613
  width: 14,
585
614
  height: 14,
@@ -593,15 +622,19 @@ function x(c) {
593
622
  strokeLinecap: `round`,
594
623
  strokeLinejoin: `round`
595
624
  }))), (0, react.createElement)(`div`, {
596
- ref: m,
597
- id: `${h}-list`,
625
+ ref: g,
626
+ id: `${_}-list`,
598
627
  role: `listbox`,
599
628
  className: `dsu-menu`,
629
+ style: {
630
+ positionAnchor: b,
631
+ positionTryFallbacks: `flip-block, flip-inline`
632
+ },
600
633
  "aria-label": c.label,
601
634
  hidden: !l
602
- }, ...N)));
635
+ }, ...I)));
603
636
  }
604
- function S(t) {
637
+ function w(t) {
605
638
  let n = !t.writable || t.busy || !t.dirty, r;
606
639
  return r = t.error === null ? t.writable ? t.dirty ? t.dirtyLabel : t.cleanLabel : t.readOnlyLabel : t.error, (0, react.createElement)(`div`, {
607
640
  className: `dsu-savebar`,
@@ -618,7 +651,10 @@ function S(t) {
618
651
  "data-field": `discard`,
619
652
  disabled: n,
620
653
  onClick: t.onDiscard
621
- }, t.revertLabel), (0, react.createElement)(`span`, { className: t.error === null ? `dsu-status` : `dsu-status dsu-statusError` }, r));
654
+ }, t.revertLabel), (0, react.createElement)(`span`, {
655
+ role: `status`,
656
+ className: t.error === null ? `dsu-status` : `dsu-status dsu-statusError`
657
+ }, r));
622
658
  }
623
659
  // node_modules/@jayyuen66/dsh-plugin-shared/dist/card-diff.js
624
660
  function e$1(t, n, r) {
@@ -1189,7 +1225,7 @@ function numberDisplay(display, schema) {
1189
1225
  /** 检索模型小节:embedding 下拉(按本地后端分组)+ 每组结果数。 */
1190
1226
  function buildModelSection(deps) {
1191
1227
  const { editable, fields, setField, t } = deps;
1192
- const embedding = (0, react.createElement)(x, {
1228
+ const embedding = (0, react.createElement)(C, {
1193
1229
  label: t("embeddingLabel"),
1194
1230
  ...l(t("embeddingHint")),
1195
1231
  field: "defaultEmbedding",
@@ -1200,7 +1236,7 @@ function buildModelSection(deps) {
1200
1236
  setField("defaultEmbedding", next);
1201
1237
  }
1202
1238
  });
1203
- const limit = (0, react.createElement)(v, {
1239
+ const limit = (0, react.createElement)(b, {
1204
1240
  label: t("limitLabel"),
1205
1241
  hint: t("limitInvalid", {
1206
1242
  min: 1,
@@ -1244,7 +1280,7 @@ function buildRebuildField(deps) {
1244
1280
  disabled: rebuild.phase === "running",
1245
1281
  onClick: deps.onRebuild
1246
1282
  }, rebuild.phase === "running" ? t("rebuildRunning") : t("rebuildButton"));
1247
- return (0, react.createElement)(g, {
1283
+ return (0, react.createElement)(v, {
1248
1284
  label: t("rebuildLabel"),
1249
1285
  ...l(rebuildHintText(t, fields.embedding, roots.length > 0)),
1250
1286
  wide: true
@@ -1277,7 +1313,7 @@ function buildRebuildStatusRow(deps) {
1277
1313
  /** 网络与索引小节:传输三档、镜像地址、search-first 开关、配额与时效、工作区重建与守护进程状态。 */
1278
1314
  function buildIndexSection(deps) {
1279
1315
  const { editable, fields, setField, t } = deps;
1280
- const transport = (0, react.createElement)(x, {
1316
+ const transport = (0, react.createElement)(C, {
1281
1317
  label: t("transportLabel"),
1282
1318
  ...l(t("transportHint")),
1283
1319
  field: "transport",
@@ -1288,7 +1324,7 @@ function buildIndexSection(deps) {
1288
1324
  setField("transport", next);
1289
1325
  }
1290
1326
  });
1291
- const endpoint = (0, react.createElement)(y, {
1327
+ const endpoint = (0, react.createElement)(x, {
1292
1328
  label: t("endpointLabel"),
1293
1329
  ...l(t("endpointHint")),
1294
1330
  field: "hfEndpoint",
@@ -1300,7 +1336,7 @@ function buildIndexSection(deps) {
1300
1336
  setField("hfEndpoint", next.trim() === "" ? void 0 : next.trim());
1301
1337
  }
1302
1338
  });
1303
- const enforce = (0, react.createElement)(_, {
1339
+ const enforce = (0, react.createElement)(y, {
1304
1340
  label: t("enforceLabel"),
1305
1341
  ...l(t("enforceHint")),
1306
1342
  field: "enforceSearchFirst",
@@ -1310,7 +1346,7 @@ function buildIndexSection(deps) {
1310
1346
  setField("enforceSearchFirst", next);
1311
1347
  }
1312
1348
  });
1313
- const budget = (0, react.createElement)(v, {
1349
+ const budget = (0, react.createElement)(b, {
1314
1350
  label: t("budgetLabel"),
1315
1351
  ...l(t("budgetHint", { default: 3 })),
1316
1352
  field: "grepBudgetPerSearch",
@@ -1325,7 +1361,7 @@ function buildIndexSection(deps) {
1325
1361
  setField("grepBudgetPerSearch", next);
1326
1362
  }
1327
1363
  });
1328
- const window = (0, react.createElement)(v, {
1364
+ const window = (0, react.createElement)(b, {
1329
1365
  label: t("windowLabel"),
1330
1366
  ...l(t("windowHint", { default: 10 })),
1331
1367
  field: "unlockWindowMin",
@@ -1345,7 +1381,7 @@ function buildIndexSection(deps) {
1345
1381
  /** 卡片主体:检索模型 / 网络与索引两节 + 保存条。 */
1346
1382
  function buildCardBody(deps) {
1347
1383
  const { t } = deps;
1348
- const saveBar = (0, react.createElement)(S, {
1384
+ const saveBar = (0, react.createElement)(w, {
1349
1385
  dirty: deps.dirty,
1350
1386
  busy: deps.busy,
1351
1387
  writable: deps.writable,