@opentiny/tiny-robot 0.3.0-alpha.9 → 0.3.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,730 @@
1
+ import { defineComponent as A, ref as S, computed as y, createElementBlock as r, openBlock as o, normalizeClass as K, createElementVNode as e, createBlock as x, createCommentVNode as k, toDisplayString as U, renderSlot as j, Fragment as M, unref as u, createVNode as g, withCtx as w, Transition as Y, withDirectives as I, renderList as H, vShow as ge, useModel as G, vModelText as O, watch as Q, onUnmounted as ve, mergeModels as X, normalizeStyle as fe, createTextVNode as he } from "vue";
2
+ import { TinyPopconfirm as ye, TinySwitch as ee, TinyRadioGroup as ie, TinyTabs as ke, TinyTabItem as te, TinyInput as le, TinySelect as be, TinyOption as Te } from "@opentiny/vue";
3
+ import { IconArrowRight as Ce, IconArrowDown as Pe, IconDelete as $e, IconClose as re, IconEmptySearch as xe, IconPlus as we, IconSearch as oe } from "@opentiny/tiny-robot-svgs";
4
+ import { _ as E } from "../_plugin-vue_export-helper.js";
5
+ import { _ as Se } from "../no-data.js";
6
+ import { d as De, o as Ve } from "../index2.js";
7
+ const Ue = { class: "plugin-card__main" }, Be = ["src"], Fe = { class: "plugin-card__content" }, Ie = { class: "plugin-card__info" }, Me = { class: "plugin-card__name" }, Ae = {
8
+ key: 0,
9
+ class: "plugin-card__count"
10
+ }, Ee = ["title"], Le = { class: "plugin-card__actions" }, Oe = { class: "plugin-card__operations" }, Re = { title: "移除插件" }, Ne = {
11
+ key: 1,
12
+ class: "plugin-card__add"
13
+ }, ze = { key: 0 }, qe = { key: 1 }, je = { key: 2 }, He = { class: "plugin-card__tools" }, Qe = { class: "plugin-card__tool" }, Je = { class: "plugin-card__content" }, Ge = { class: "plugin-card__info" }, We = { class: "plugin-card__name" }, Ke = ["title"], Xe = { class: "plugin-card__actions plugin-card__actions--tool" }, Ye = {
14
+ key: 0,
15
+ class: "plugin-card__divider"
16
+ }, Ze = /* @__PURE__ */ A({
17
+ __name: "PluginCard",
18
+ props: {
19
+ plugin: {},
20
+ mode: { default: "installed" },
21
+ showToolCount: { type: Boolean, default: !0 }
22
+ },
23
+ emits: ["toggle-plugin", "toggle-tool", "add-plugin", "delete-plugin"],
24
+ setup(_, { emit: p }) {
25
+ const t = _, d = p, c = S(t.plugin.expanded || !1), T = y(() => {
26
+ var s;
27
+ return ((s = t.plugin.tools) == null ? void 0 : s.length) || 0;
28
+ }), v = y(() => T.value > 0), C = y(() => ({
29
+ "plugin-card--expandable": v.value,
30
+ "plugin-card--expanded": c.value,
31
+ [`plugin-card--${t.mode}`]: !0
32
+ })), D = () => {
33
+ v.value && (c.value = !c.value);
34
+ }, a = y(() => {
35
+ if (!v.value)
36
+ return { checked: t.plugin.enabled || !1, indeterminate: !1 };
37
+ const s = t.plugin.tools.filter(($) => $.enabled), b = t.plugin.tools.length;
38
+ return s.length === 0 ? { checked: !1, indeterminate: !1 } : s.length === b ? { checked: !0, indeterminate: !1 } : { checked: !0, indeterminate: !0 };
39
+ }), h = (s) => {
40
+ v.value && t.plugin.tools.forEach((b) => {
41
+ b.enabled !== s && (b.enabled = s, d("toggle-tool", b.id, s));
42
+ }), d("toggle-plugin", s);
43
+ }, R = (s, b) => {
44
+ d("toggle-tool", s, b);
45
+ }, m = () => {
46
+ d("delete-plugin");
47
+ }, P = y(() => t.plugin.addState || "idle"), N = (s) => {
48
+ P.value === "idle" && d("add-plugin", s);
49
+ }, z = (s) => s ? "关闭插件" : "打开插件";
50
+ return (s, b) => (o(), r("div", {
51
+ class: K(["plugin-card", C.value])
52
+ }, [
53
+ e("div", Ue, [
54
+ e("img", {
55
+ src: s.plugin.icon,
56
+ class: "plugin-card__icon"
57
+ }, null, 8, Be),
58
+ e("div", Fe, [
59
+ e("div", Ie, [
60
+ e("span", Me, U(s.plugin.name), 1),
61
+ s.showToolCount && T.value ? (o(), r("span", Ae, U(T.value) + " 个工具 ", 1)) : k("", !0)
62
+ ]),
63
+ e("div", {
64
+ class: "plugin-card__desc",
65
+ title: s.plugin.description
66
+ }, U(s.plugin.description), 9, Ee)
67
+ ]),
68
+ e("div", Le, [
69
+ j(s.$slots, "actions", {
70
+ plugin: s.plugin,
71
+ expanded: c.value,
72
+ mode: s.mode
73
+ }, () => [
74
+ s.mode === "installed" ? (o(), r(M, { key: 0 }, [
75
+ v.value ? (o(), r("div", {
76
+ key: 0,
77
+ class: "plugin-card__expand",
78
+ onClick: D
79
+ }, [
80
+ j(s.$slots, "expand-icon", { expanded: c.value }, () => [
81
+ c.value ? (o(), x(u(Pe), {
82
+ key: 1,
83
+ class: "common-icon"
84
+ })) : (o(), x(u(Ce), {
85
+ key: 0,
86
+ class: "common-icon"
87
+ }))
88
+ ], !0)
89
+ ])) : k("", !0),
90
+ e("div", Oe, [
91
+ g(u(ye), {
92
+ title: "确定移除该插件吗?",
93
+ style: { height: "16px" },
94
+ type: "info",
95
+ onConfirm: m,
96
+ trigger: "click"
97
+ }, {
98
+ reference: w(() => [
99
+ j(s.$slots, "delete-icon", {}, () => [
100
+ e("span", Re, [
101
+ g(u($e), { class: "common-icon" })
102
+ ])
103
+ ], !0)
104
+ ]),
105
+ _: 3
106
+ }),
107
+ g(u(ee), {
108
+ title: z(a.value.checked),
109
+ "model-value": a.value.checked,
110
+ indeterminate: a.value.indeterminate,
111
+ "onUpdate:modelValue": h
112
+ }, null, 8, ["title", "model-value", "indeterminate"])
113
+ ])
114
+ ], 64)) : s.mode === "market" ? (o(), r("div", Ne, [
115
+ j(s.$slots, "add-button", {}, () => [
116
+ e("div", {
117
+ class: K(["plugin-card__add-button", {
118
+ "plugin-card__add-button--loading": P.value === "loading",
119
+ "plugin-card__add-button--added": P.value === "added"
120
+ }]),
121
+ onClick: b[0] || (b[0] = ($) => N(s.plugin))
122
+ }, [
123
+ P.value === "idle" ? (o(), r("span", ze, "添加")) : P.value === "loading" ? (o(), r("span", qe, "添加中")) : (o(), r("span", je, "已添加"))
124
+ ], 2)
125
+ ], !0)
126
+ ])) : k("", !0)
127
+ ], !0)
128
+ ])
129
+ ]),
130
+ v.value ? (o(), x(Y, {
131
+ key: 0,
132
+ name: "plugin-card-slide"
133
+ }, {
134
+ default: w(() => [
135
+ I(e("div", He, [
136
+ b[2] || (b[2] = e("div", { class: "plugin-card__divider" }, null, -1)),
137
+ (o(!0), r(M, null, H(s.plugin.tools, ($, F) => {
138
+ var q;
139
+ return o(), r("div", {
140
+ key: $.id,
141
+ class: "plugin-card__tool-item"
142
+ }, [
143
+ e("div", Qe, [
144
+ b[1] || (b[1] = e("div", { class: "plugin-card__icon plugin-card__icon--placeholder" }, null, -1)),
145
+ e("div", Je, [
146
+ e("div", Ge, [
147
+ e("span", We, U($.name), 1)
148
+ ]),
149
+ e("div", {
150
+ class: "plugin-card__desc",
151
+ title: $.description
152
+ }, U($.description), 9, Ke)
153
+ ]),
154
+ e("div", Xe, [
155
+ g(u(ee), {
156
+ title: z($.enabled),
157
+ "model-value": $.enabled,
158
+ "onUpdate:modelValue": (W) => R($.id, W)
159
+ }, null, 8, ["title", "model-value", "onUpdate:modelValue"])
160
+ ])
161
+ ]),
162
+ F < (((q = s.plugin.tools) == null ? void 0 : q.length) || 0) - 1 ? (o(), r("div", Ye)) : k("", !0)
163
+ ]);
164
+ }), 128))
165
+ ], 512), [
166
+ [ge, c.value]
167
+ ])
168
+ ]),
169
+ _: 1
170
+ })) : k("", !0)
171
+ ], 2));
172
+ }
173
+ }), ae = /* @__PURE__ */ E(Ze, [["__scopeId", "data-v-1bbe4f4e"]]), et = { class: "code-editor__container" }, tt = { class: "code-editor__section" }, lt = { class: "code-editor__area" }, ot = /* @__PURE__ */ A({
174
+ __name: "CodeEditor",
175
+ props: {
176
+ codeData: { required: !0 },
177
+ codeDataModifiers: {}
178
+ },
179
+ emits: ["update:codeData"],
180
+ setup(_) {
181
+ const p = G(_, "codeData");
182
+ return (t, d) => (o(), r("div", et, [
183
+ e("div", tt, [
184
+ d[1] || (d[1] = e("div", { class: "code-editor__header" }, [
185
+ e("span", { class: "code-editor__title" }, "ai_plugin(填写json)")
186
+ ], -1)),
187
+ e("div", lt, [
188
+ I(e("textarea", {
189
+ "onUpdate:modelValue": d[0] || (d[0] = (c) => p.value = c),
190
+ class: "code-editor__textarea",
191
+ placeholder: "请输入 JSON 配置..."
192
+ }, null, 512), [
193
+ [O, p.value]
194
+ ])
195
+ ])
196
+ ])
197
+ ]));
198
+ }
199
+ }), at = /* @__PURE__ */ E(ot, [["__scopeId", "data-v-87ddff5d"]]), nt = { class: "form-editor__container" }, st = { class: "form-editor__item" }, it = { class: "form-editor__item" }, rt = { class: "form-editor__item" }, dt = { class: "form-editor__item" }, ut = { class: "form-editor__item" }, ct = { class: "form-editor__item" }, pt = ["src"], ne = "https://res.hc-cdn.com/tinyui-design/1.1.0.20250526191525/home/images/tiny-ng.svg", _t = /* @__PURE__ */ A({
200
+ __name: "FormEditor",
201
+ props: {
202
+ formData: { required: !0 },
203
+ formDataModifiers: {}
204
+ },
205
+ emits: ["update:formData"],
206
+ setup(_) {
207
+ const p = S(""), t = G(_, "formData"), d = [
208
+ { label: "sse", text: "服务器发送事件(SSE)" },
209
+ { label: "streamableHttp", text: "流式HTTP(Streamable HTTP)" }
210
+ ], { open: c, files: T } = De({
211
+ accept: "image/*",
212
+ // 只接受图片文件
213
+ multiple: !1
214
+ // 只允许选择单个文件
215
+ }), v = () => {
216
+ p.value && p.value !== ne && (URL.revokeObjectURL(p.value), p.value = "");
217
+ };
218
+ Q(T, (D) => {
219
+ if (D && D.length > 0) {
220
+ const a = D[0];
221
+ if (!a.type.startsWith("image/"))
222
+ return;
223
+ const h = 5 * 1024 * 1024;
224
+ if (a.size > h)
225
+ return;
226
+ v(), p.value = URL.createObjectURL(a), t.value.thumbnail = a;
227
+ }
228
+ });
229
+ const C = () => {
230
+ c();
231
+ };
232
+ return ve(() => {
233
+ v();
234
+ }), (D, a) => (o(), r("form", nt, [
235
+ e("div", st, [
236
+ a[5] || (a[5] = e("label", { class: "form-editor__label" }, "名称", -1)),
237
+ I(e("input", {
238
+ "onUpdate:modelValue": a[0] || (a[0] = (h) => t.value.name = h),
239
+ class: "form-editor__input",
240
+ type: "text",
241
+ placeholder: "请输入插件名称"
242
+ }, null, 512), [
243
+ [O, t.value.name]
244
+ ])
245
+ ]),
246
+ e("div", it, [
247
+ a[6] || (a[6] = e("label", { class: "form-editor__label" }, "描述", -1)),
248
+ I(e("textarea", {
249
+ "onUpdate:modelValue": a[1] || (a[1] = (h) => t.value.description = h),
250
+ class: "form-editor__textarea",
251
+ placeholder: "请输入插件描述"
252
+ }, null, 512), [
253
+ [O, t.value.description]
254
+ ])
255
+ ]),
256
+ e("div", rt, [
257
+ a[7] || (a[7] = e("label", { class: "form-editor__label" }, "类型", -1)),
258
+ g(u(ie), {
259
+ modelValue: t.value.type,
260
+ "onUpdate:modelValue": a[2] || (a[2] = (h) => t.value.type = h),
261
+ options: d,
262
+ class: "form-editor__radio-group"
263
+ }, null, 8, ["modelValue"])
264
+ ]),
265
+ e("div", dt, [
266
+ a[8] || (a[8] = e("label", { class: "form-editor__label" }, "URL", -1)),
267
+ I(e("input", {
268
+ "onUpdate:modelValue": a[3] || (a[3] = (h) => t.value.url = h),
269
+ class: "form-editor__input",
270
+ type: "url",
271
+ placeholder: "请输入插件URL"
272
+ }, null, 512), [
273
+ [O, t.value.url]
274
+ ])
275
+ ]),
276
+ e("div", ut, [
277
+ a[9] || (a[9] = e("label", { class: "form-editor__label" }, "请求头", -1)),
278
+ I(e("textarea", {
279
+ "onUpdate:modelValue": a[4] || (a[4] = (h) => t.value.headers = h),
280
+ class: "form-editor__textarea",
281
+ placeholder: "请输入请求头,格式为JSON"
282
+ }, null, 512), [
283
+ [O, t.value.headers]
284
+ ])
285
+ ]),
286
+ e("div", ct, [
287
+ a[11] || (a[11] = e("label", { class: "form-editor__label" }, "缩略图", -1)),
288
+ e("div", {
289
+ class: "form-editor__file-upload",
290
+ onClick: C
291
+ }, [
292
+ e("img", {
293
+ src: p.value || ne,
294
+ alt: "缩略图预览",
295
+ class: "form-editor__file-preview-image"
296
+ }, null, 8, pt),
297
+ a[10] || (a[10] = e("div", { class: "form-editor__file-overlay" }, [
298
+ e("div", { class: "form-editor__file-icon" })
299
+ ], -1))
300
+ ])
301
+ ])
302
+ ]));
303
+ }
304
+ }), mt = /* @__PURE__ */ E(_t, [["__scopeId", "data-v-7cd7ea10"]]), gt = {
305
+ key: 0,
306
+ class: "plugin-editor__backdrop"
307
+ }, vt = { class: "plugin-editor__header" }, ft = { class: "plugin-editor__content" }, ht = { class: "plugin-editor__add-type" }, yt = {
308
+ key: 0,
309
+ class: "plugin-editor__form-editor"
310
+ }, kt = {
311
+ key: 1,
312
+ class: "plugin-editor__code-editor"
313
+ }, bt = /* @__PURE__ */ A({
314
+ __name: "PluginModal",
315
+ props: {
316
+ visible: { type: Boolean, required: !0 },
317
+ visibleModifiers: {}
318
+ },
319
+ emits: /* @__PURE__ */ X(["update:visible", "confirm"], ["update:visible"]),
320
+ setup(_, { emit: p }) {
321
+ const t = p, d = G(_, "visible"), c = S(null), T = S({
322
+ name: "",
323
+ description: "",
324
+ type: "sse",
325
+ url: "",
326
+ headers: "",
327
+ thumbnail: null
328
+ }), v = S(""), C = S("form"), D = [
329
+ { label: "form", text: "表单添加" },
330
+ { label: "code", text: "代码添加" }
331
+ ], a = () => {
332
+ d.value = !1;
333
+ };
334
+ Ve(c, () => {
335
+ d.value && a();
336
+ });
337
+ const h = () => {
338
+ C.value === "form" ? t("confirm", "form", T.value) : t("confirm", "code", v.value), a();
339
+ };
340
+ return (R, m) => (o(), r(M, null, [
341
+ d.value ? (o(), r("div", gt)) : k("", !0),
342
+ g(Y, { name: "plugin-editor" }, {
343
+ default: w(() => [
344
+ d.value ? (o(), r("div", {
345
+ key: 0,
346
+ class: "plugin-editor",
347
+ ref_key: "dialogRef",
348
+ ref: c
349
+ }, [
350
+ e("div", vt, [
351
+ m[3] || (m[3] = e("h3", { class: "plugin-editor__title" }, "添加插件", -1)),
352
+ g(u(re), {
353
+ class: "plugin-editor__close",
354
+ onClick: a
355
+ })
356
+ ]),
357
+ e("div", ft, [
358
+ e("div", ht, [
359
+ m[4] || (m[4] = e("span", { class: "plugin-editor__add-type-label" }, "添加方式", -1)),
360
+ g(u(ie), {
361
+ modelValue: C.value,
362
+ "onUpdate:modelValue": m[0] || (m[0] = (P) => C.value = P),
363
+ type: "button",
364
+ options: D
365
+ }, null, 8, ["modelValue"])
366
+ ]),
367
+ C.value === "form" ? (o(), r("div", yt, [
368
+ g(mt, {
369
+ "form-data": T.value,
370
+ "onUpdate:formData": m[1] || (m[1] = (P) => T.value = P)
371
+ }, null, 8, ["form-data"])
372
+ ])) : k("", !0),
373
+ C.value === "code" ? (o(), r("div", kt, [
374
+ g(at, {
375
+ "code-data": v.value,
376
+ "onUpdate:codeData": m[2] || (m[2] = (P) => v.value = P)
377
+ }, null, 8, ["code-data"])
378
+ ])) : k("", !0)
379
+ ]),
380
+ e("div", { class: "plugin-editor__footer" }, [
381
+ e("div", {
382
+ class: "button cancel",
383
+ onClick: a
384
+ }, [...m[5] || (m[5] = [
385
+ e("span", null, "取消", -1)
386
+ ])]),
387
+ e("div", {
388
+ class: "button confirm",
389
+ onClick: h
390
+ }, [...m[6] || (m[6] = [
391
+ e("span", null, "确定", -1)
392
+ ])])
393
+ ])
394
+ ], 512)) : k("", !0)
395
+ ]),
396
+ _: 1
397
+ })
398
+ ], 64));
399
+ }
400
+ }), Tt = /* @__PURE__ */ E(bt, [["__scopeId", "data-v-192c66c9"]]), Ct = {
401
+ class: "empty-state",
402
+ role: "status",
403
+ "aria-live": "polite"
404
+ }, Pt = {
405
+ key: 1,
406
+ src: Se,
407
+ class: "empty-state__illustration"
408
+ }, $t = { class: "empty-state__message" }, xt = /* @__PURE__ */ A({
409
+ __name: "NoData",
410
+ props: {
411
+ searchQuery: { default: "" }
412
+ },
413
+ setup(_) {
414
+ const p = _, t = y(() => {
415
+ var c;
416
+ return !!((c = p.searchQuery) != null && c.trim());
417
+ }), d = y(() => t.value ? "暂无搜索结果" : "暂无数据");
418
+ return (c, T) => (o(), r("section", Ct, [
419
+ t.value ? (o(), x(u(xe), {
420
+ key: 0,
421
+ class: "empty-state__illustration"
422
+ })) : (o(), r("img", Pt)),
423
+ e("p", $t, U(d.value), 1)
424
+ ]));
425
+ }
426
+ }), se = /* @__PURE__ */ E(xt, [["__scopeId", "data-v-839781e5"]]), wt = { class: "mcp-server-picker__header" }, St = { class: "mcp-server-picker__header-left" }, Dt = { class: "mcp-server-picker__header-right" }, Vt = { class: "mcp-server-picker__content" }, Ut = {
427
+ key: 0,
428
+ class: "mcp-server-picker__content-installed-search"
429
+ }, Bt = {
430
+ key: 1,
431
+ class: "mcp-server-picker__content-list"
432
+ }, Ft = {
433
+ key: 0,
434
+ class: "mcp-server-picker__loading"
435
+ }, It = {
436
+ key: 0,
437
+ class: "mcp-server-picker__content-market-header"
438
+ }, Mt = {
439
+ key: 0,
440
+ style: { width: "168px" }
441
+ }, At = {
442
+ key: 1,
443
+ style: { width: "264px", "flex-shrink": "0" }
444
+ }, Et = {
445
+ key: 1,
446
+ class: "mcp-server-picker__content-list"
447
+ }, Lt = {
448
+ key: 0,
449
+ class: "mcp-server-picker__loading"
450
+ }, Ot = /* @__PURE__ */ A({
451
+ __name: "index",
452
+ props: /* @__PURE__ */ X({
453
+ installedPlugins: { default: () => [] },
454
+ marketPlugins: { default: () => [] },
455
+ searchPlaceholder: { default: "搜索插件" },
456
+ enableSearch: { type: Boolean, default: !0 },
457
+ installedSearchFn: { type: Function, default: (_, p) => _ ? p.name.toLowerCase().includes(_.toLowerCase()) : !0 },
458
+ marketSearchFn: { type: Function, default: (_, p) => _ ? p.name.toLowerCase().includes(_.toLowerCase()) : !0 },
459
+ marketCategoryOptions: { default: () => [] },
460
+ marketCategoryPlaceholder: { default: "按照分类筛选" },
461
+ enableMarketCategoryFilter: { type: Boolean, default: !0 },
462
+ defaultActiveTab: { default: "installed" },
463
+ showInstalledTab: { type: Boolean, default: !0 },
464
+ showMarketTab: { type: Boolean, default: !0 },
465
+ visible: { type: Boolean },
466
+ popupConfig: { default: () => ({
467
+ type: "fixed",
468
+ position: {},
469
+ drawer: { direction: "right" }
470
+ }) },
471
+ activeCount: {},
472
+ installedTabTitle: { default: "已添加插件" },
473
+ marketTabTitle: { default: "市场" },
474
+ title: { default: "插件" },
475
+ showCustomAddButton: { type: Boolean, default: !0 },
476
+ customAddButtonText: { default: "自定义添加" },
477
+ allowPluginToggle: { type: Boolean, default: !0 },
478
+ allowToolToggle: { type: Boolean, default: !0 },
479
+ allowPluginDelete: { type: Boolean, default: !0 },
480
+ allowPluginAdd: { type: Boolean, default: !0 },
481
+ loading: { type: Boolean, default: !1 },
482
+ marketLoading: { type: Boolean, default: !1 }
483
+ }, {
484
+ visible: { type: Boolean, required: !0 },
485
+ visibleModifiers: {}
486
+ }),
487
+ emits: /* @__PURE__ */ X(["market-category-change", "tab-change", "plugin-toggle", "plugin-delete", "plugin-add", "plugin-create", "tool-toggle", "refresh", "update:activeCount", "update:visible"], ["update:visible"]),
488
+ setup(_, { emit: p }) {
489
+ const t = _, d = p, c = S(t.defaultActiveTab), T = S(""), v = S(""), C = S(""), D = y(
490
+ () => c.value === "installed" ? t.searchPlaceholder : "搜索市场插件"
491
+ ), a = y(() => t.installedPlugins), h = y(() => t.marketPlugins), R = y(() => !a.value || a.value.length === 0 ? 0 : a.value.filter((l) => l.enabled).length);
492
+ Q(
493
+ R,
494
+ (l) => {
495
+ d("update:activeCount", l);
496
+ },
497
+ { immediate: !0 }
498
+ ), Q(c, (l, i) => {
499
+ l !== i && d("tab-change", l);
500
+ });
501
+ const m = y(() => a.value.filter((l) => t.installedSearchFn(T.value, l))), P = y(() => {
502
+ const { category: l, search: i } = {
503
+ category: C.value,
504
+ search: v.value
505
+ }, f = (n) => {
506
+ const V = !l || n.category === l, B = !i || t.marketSearchFn(i, n);
507
+ return V && B;
508
+ };
509
+ return h.value.filter(f);
510
+ }), N = y(() => c.value === "installed" ? m.value.length > 0 : P.value.length > 0);
511
+ Q(C, (l) => {
512
+ d("market-category-change", l);
513
+ });
514
+ const z = (l, i) => {
515
+ var f;
516
+ t.allowPluginToggle && (d("plugin-toggle", l, i), (f = l.tools) != null && f.length && (i ? l.tools.filter((V) => V.enabled).length === 0 && l.tools.forEach((V) => {
517
+ d("tool-toggle", l, V.id, !0);
518
+ }) : l.tools.forEach((n) => {
519
+ n.enabled && d("tool-toggle", l, n.id, !1);
520
+ })));
521
+ }, s = (l, i, f) => {
522
+ var n;
523
+ if (t.allowToolToggle && (d("tool-toggle", l, i, f), (n = l.tools) != null && n.length)) {
524
+ const V = l.tools.filter((L) => L.id !== i).some((L) => L.enabled), B = f || V;
525
+ l.enabled !== B && d("plugin-toggle", l, B);
526
+ }
527
+ }, b = (l) => {
528
+ t.allowPluginDelete && d("plugin-delete", l);
529
+ }, $ = (l) => {
530
+ t.allowPluginAdd && d("plugin-add", l);
531
+ }, F = S(!1), q = () => {
532
+ F.value = !0;
533
+ }, W = (l, i) => {
534
+ d("plugin-create", l, i), F.value = !1;
535
+ }, de = G(_, "visible"), ue = () => {
536
+ d("update:visible", !1);
537
+ }, ce = y(() => {
538
+ const { type: l, position: i, drawer: f } = t.popupConfig || {}, n = {
539
+ "z-index": "1000",
540
+ position: "fixed"
541
+ };
542
+ return l === "fixed" ? {
543
+ ...n,
544
+ ...pe(i)
545
+ } : l === "drawer" ? {
546
+ ...n,
547
+ ..._e(f)
548
+ } : n;
549
+ }), pe = (l = {}) => {
550
+ const i = {};
551
+ return Object.entries(l).forEach(([f, n]) => {
552
+ n !== void 0 && (i[f] = typeof n == "number" ? `${n}px` : n);
553
+ }), Object.keys(i).length === 0 ? {
554
+ top: "50%",
555
+ left: "50%",
556
+ transform: "translate(-50%, -50%)"
557
+ } : i;
558
+ }, _e = (l = { direction: "right" }) => {
559
+ const { direction: i } = l, f = {
560
+ top: "0",
561
+ bottom: "0",
562
+ height: "100%"
563
+ };
564
+ return i === "left" ? {
565
+ ...f,
566
+ left: "0",
567
+ "border-right": "1px solid rgb(219, 219, 219)"
568
+ } : {
569
+ ...f,
570
+ right: "0",
571
+ "border-left": "1px solid rgb(219, 219, 219)"
572
+ };
573
+ }, Z = y(() => {
574
+ const { type: l, drawer: i } = t.popupConfig || {};
575
+ return l !== "drawer" ? "" : `drawer-${(i == null ? void 0 : i.direction) || "right"}`;
576
+ }), me = y(() => {
577
+ const { type: l } = t.popupConfig || {};
578
+ return l === "drawer" ? Z.value : "fade";
579
+ });
580
+ return (l, i) => (o(), x(Y, { name: me.value }, {
581
+ default: w(() => {
582
+ var f;
583
+ return [
584
+ de.value ? (o(), r("div", {
585
+ key: 0,
586
+ class: K(["mcp-server-picker", [`popup-type-${((f = t.popupConfig) == null ? void 0 : f.type) || "fixed"}`, Z.value]]),
587
+ style: fe(ce.value)
588
+ }, [
589
+ e("div", wt, [
590
+ e("div", St, U(t.title), 1),
591
+ e("div", Dt, [
592
+ t.showCustomAddButton ? (o(), r("div", {
593
+ key: 0,
594
+ class: "mcp-server-picker__header-right-item",
595
+ onClick: q
596
+ }, [
597
+ g(u(we), { style: { "font-size": "16px", cursor: "pointer" } }),
598
+ e("span", null, U(t.customAddButtonText), 1)
599
+ ])) : k("", !0),
600
+ g(u(re), {
601
+ class: "mcp-server-picker__header-right-close",
602
+ onClick: ue
603
+ })
604
+ ])
605
+ ]),
606
+ e("div", Vt, [
607
+ g(u(ke), {
608
+ modelValue: c.value,
609
+ "onUpdate:modelValue": i[3] || (i[3] = (n) => c.value = n)
610
+ }, {
611
+ default: w(() => [
612
+ t.showInstalledTab ? (o(), x(u(te), {
613
+ key: 0,
614
+ title: t.installedTabTitle,
615
+ name: "installed"
616
+ }, {
617
+ default: w(() => [
618
+ t.enableSearch ? (o(), r("div", Ut, [
619
+ g(u(le), {
620
+ modelValue: T.value,
621
+ "onUpdate:modelValue": i[0] || (i[0] = (n) => T.value = n),
622
+ placeholder: t.searchPlaceholder
623
+ }, {
624
+ suffix: w(() => [
625
+ g(u(oe), { style: { "font-size": "16px", cursor: "pointer" } })
626
+ ]),
627
+ _: 1
628
+ }, 8, ["modelValue", "placeholder"])
629
+ ])) : k("", !0),
630
+ N.value ? (o(), r("div", Bt, [
631
+ t.loading ? (o(), r("div", Ft, "加载中...")) : (o(!0), r(M, { key: 1 }, H(m.value, (n) => {
632
+ var V;
633
+ return o(), x(u(ae), {
634
+ key: n.id,
635
+ plugin: n,
636
+ mode: "installed",
637
+ expandable: !!((V = n.tools) != null && V.length),
638
+ onTogglePlugin: (B) => z(n, B),
639
+ onToggleTool: (B, L) => s(n, B, L),
640
+ onDeletePlugin: () => b(n)
641
+ }, null, 8, ["plugin", "expandable", "onTogglePlugin", "onToggleTool", "onDeletePlugin"]);
642
+ }), 128))
643
+ ])) : (o(), x(u(se), {
644
+ key: 2,
645
+ "search-query": T.value
646
+ }, null, 8, ["search-query"]))
647
+ ]),
648
+ _: 1
649
+ }, 8, ["title"])) : k("", !0),
650
+ t.showMarketTab ? (o(), x(u(te), {
651
+ key: 1,
652
+ title: t.marketTabTitle,
653
+ name: "market"
654
+ }, {
655
+ default: w(() => [
656
+ t.enableSearch || t.enableMarketCategoryFilter ? (o(), r("div", It, [
657
+ t.enableMarketCategoryFilter ? (o(), r("div", Mt, [
658
+ g(u(be), {
659
+ modelValue: C.value,
660
+ "onUpdate:modelValue": i[1] || (i[1] = (n) => C.value = n),
661
+ placeholder: t.marketCategoryPlaceholder
662
+ }, {
663
+ default: w(() => [
664
+ (o(!0), r(M, null, H(t.marketCategoryOptions, (n) => (o(), x(u(Te), {
665
+ key: n.value,
666
+ label: n.label,
667
+ value: n.value
668
+ }, {
669
+ default: w(() => [
670
+ he(U(n.label), 1)
671
+ ]),
672
+ _: 2
673
+ }, 1032, ["label", "value"]))), 128))
674
+ ]),
675
+ _: 1
676
+ }, 8, ["modelValue", "placeholder"])
677
+ ])) : k("", !0),
678
+ t.enableSearch ? (o(), r("div", At, [
679
+ g(u(le), {
680
+ modelValue: v.value,
681
+ "onUpdate:modelValue": i[2] || (i[2] = (n) => v.value = n),
682
+ placeholder: D.value
683
+ }, {
684
+ suffix: w(() => [
685
+ g(u(oe), { style: { "font-size": "16px", cursor: "pointer" } })
686
+ ]),
687
+ _: 1
688
+ }, 8, ["modelValue", "placeholder"])
689
+ ])) : k("", !0)
690
+ ])) : k("", !0),
691
+ N.value ? (o(), r("div", Et, [
692
+ t.marketLoading ? (o(), r("div", Lt, "加载中...")) : (o(!0), r(M, { key: 1 }, H(P.value, (n) => (o(), x(u(ae), {
693
+ key: n.id,
694
+ plugin: n,
695
+ mode: "market",
696
+ expandable: !1,
697
+ "show-tool-count": !1,
698
+ onAddPlugin: $
699
+ }, null, 8, ["plugin"]))), 128))
700
+ ])) : (o(), x(u(se), {
701
+ key: 2,
702
+ "search-query": v.value || C.value
703
+ }, null, 8, ["search-query"]))
704
+ ]),
705
+ _: 1
706
+ }, 8, ["title"])) : k("", !0)
707
+ ]),
708
+ _: 1
709
+ }, 8, ["modelValue"])
710
+ ]),
711
+ g(u(Tt), {
712
+ visible: F.value,
713
+ "onUpdate:visible": i[4] || (i[4] = (n) => F.value = n),
714
+ onConfirm: W
715
+ }, null, 8, ["visible"])
716
+ ], 6)) : k("", !0)
717
+ ];
718
+ }),
719
+ _: 1
720
+ }, 8, ["name"]));
721
+ }
722
+ }), J = /* @__PURE__ */ E(Ot, [["__scopeId", "data-v-51b705ed"]]);
723
+ J.name = "McpServerPicker";
724
+ const Rt = function(_) {
725
+ _.component(J.name, J);
726
+ };
727
+ J.install = Rt;
728
+ export {
729
+ J as default
730
+ };