yc-component 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/image-selector/api/images.d.ts +6 -0
  2. package/dist/image-selector/api/images.d.ts.map +1 -0
  3. package/dist/image-selector/components/YcImageSelectorDialog.d.ts +28 -0
  4. package/dist/image-selector/components/YcImageSelectorDialog.d.ts.map +1 -0
  5. package/dist/image-selector/components/YcImageSelectorProvider.d.ts +42 -0
  6. package/dist/image-selector/components/YcImageSelectorProvider.d.ts.map +1 -0
  7. package/dist/image-selector/composables/useImageSelector.d.ts +10 -0
  8. package/dist/image-selector/composables/useImageSelector.d.ts.map +1 -0
  9. package/dist/image-selector/config.d.ts +12 -0
  10. package/dist/image-selector/config.d.ts.map +1 -0
  11. package/dist/image-selector/context.d.ts +60 -0
  12. package/dist/image-selector/context.d.ts.map +1 -0
  13. package/dist/image-selector/dialog-state.d.ts +39 -0
  14. package/dist/image-selector/dialog-state.d.ts.map +1 -0
  15. package/dist/image-selector/index.d.ts +15 -0
  16. package/dist/image-selector/index.d.ts.map +1 -0
  17. package/dist/image-selector/inject.d.ts +59 -0
  18. package/dist/image-selector/inject.d.ts.map +1 -0
  19. package/dist/image-selector/types/index.d.ts +84 -0
  20. package/dist/image-selector/types/index.d.ts.map +1 -0
  21. package/dist/index.css +1 -0
  22. package/dist/index.d.ts +2 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/plugin.d.ts +2 -0
  25. package/dist/plugin.d.ts.map +1 -1
  26. package/dist/yc-component.cjs.full.js +50 -0
  27. package/dist/yc-component.cjs.js +5 -0
  28. package/dist/yc-component.esm.full.js +12216 -0
  29. package/dist/yc-component.esm.js +1931 -0
  30. package/dist/yc-component.umd.full.js +112 -0
  31. package/dist/yc-component.umd.full.min.js +1 -0
  32. package/dist/yc-component.umd.js +6 -0
  33. package/dist/yc-component.umd.min.js +1 -0
  34. package/package.json +32 -6
  35. package/dist/_virtual/_plugin-vue_export-helper.js +0 -9
  36. package/dist/ai-task/api/http.js +0 -47
  37. package/dist/ai-task/api/prompt.js +0 -9
  38. package/dist/ai-task/api/workflow.js +0 -15
  39. package/dist/ai-task/components/AiTaskPanel.css +0 -1
  40. package/dist/ai-task/components/AiTaskPanel.vue.js +0 -7
  41. package/dist/ai-task/components/AiTaskPanel.vue2.js +0 -248
  42. package/dist/ai-task/components/AiTaskProvider.vue.js +0 -69
  43. package/dist/ai-task/components/AiTaskProvider.vue2.js +0 -4
  44. package/dist/ai-task/components/AiUseDialog.css +0 -1
  45. package/dist/ai-task/components/AiUseDialog.vue.js +0 -7
  46. package/dist/ai-task/components/AiUseDialog.vue2.js +0 -248
  47. package/dist/ai-task/composables/useAiTask.js +0 -11
  48. package/dist/ai-task/config.js +0 -23
  49. package/dist/ai-task/context.js +0 -42
  50. package/dist/ai-task/dialog-state.js +0 -28
  51. package/dist/ai-task/index.js +0 -24
  52. package/dist/ai-task/inject.js +0 -10
  53. package/dist/ai-task/services/taskRunner.js +0 -60
  54. package/dist/ai-task/store/useAiTaskStore.js +0 -230
  55. package/dist/ai-task/style.css +0 -3
  56. package/dist/ai-task/useScopedStore.js +0 -10
  57. package/dist/ai-task/utils/runClientScript.js +0 -26
  58. package/dist/ai-task/utils/storage.js +0 -45
  59. package/dist/index.js +0 -31
  60. package/dist/page-window/YcPageWindow.css +0 -1
  61. package/dist/page-window/YcPageWindow.vue.js +0 -7
  62. package/dist/page-window/YcPageWindow.vue2.js +0 -230
  63. package/dist/page-window/index.js +0 -5
  64. package/dist/page-window/style.css +0 -1
  65. package/dist/plugin.js +0 -19
@@ -0,0 +1,1931 @@
1
+ import Ze from "axios";
2
+ import { defineComponent as ce, ref as k, computed as D, watch as ne, onBeforeUnmount as At, resolveComponent as V, resolveDirective as et, openBlock as c, createBlock as E, Transition as tt, withCtx as p, withDirectives as _e, createElementVNode as _, normalizeStyle as He, createVNode as f, unref as h, toDisplayString as B, createElementBlock as A, createCommentVNode as P, createTextVNode as q, renderSlot as Ce, Fragment as le, vShow as Ee, reactive as nt, inject as Oe, onMounted as Ue, onUnmounted as Re, renderList as ve, Teleport as Mt, normalizeClass as ue, provide as $e, normalizeProps as Et, mergeProps as ot, withKeys as $t, withModifiers as Pt, nextTick as Je, isRef as Lt } from "vue";
3
+ import { ArrowLeft as Dt, ArrowUpBold as Bt, ArrowDownBold as Vt, Switch as Ot, Close as at, Check as lt, Refresh as Xe, ArrowDown as Ut, CircleCheck as Rt, CircleClose as Ft, Remove as Kt, Search as Nt, Upload as zt } from "@element-plus/icons-vue";
4
+ import { storeToRefs as Yt, defineStore as Wt } from "pinia";
5
+ import { ElMessage as ee } from "element-plus";
6
+ const Fe = {
7
+ projectId: "default-project",
8
+ storageKey: "yc-ai-task-queue-v1"
9
+ };
10
+ let he = { ...Fe };
11
+ function jt(e) {
12
+ he = { ...he, ...e };
13
+ }
14
+ function it() {
15
+ return he;
16
+ }
17
+ function Gt() {
18
+ return he.projectId ?? Fe.projectId;
19
+ }
20
+ function st() {
21
+ return he.storageKey ?? Fe.storageKey;
22
+ }
23
+ let ie = null;
24
+ function qt() {
25
+ ie = null;
26
+ }
27
+ function de() {
28
+ if (ie) return ie;
29
+ const { baseURL: e, getToken: n, onUnauthorized: t } = it();
30
+ return ie = Ze.create({
31
+ baseURL: e ?? "",
32
+ timeout: 6e4,
33
+ headers: { "Content-Type": "application/json" }
34
+ }), ie.interceptors.request.use((o) => {
35
+ const l = n == null ? void 0 : n();
36
+ return l && (o.headers.Authorization = `Bearer ${l}`), o;
37
+ }), ie.interceptors.response.use(
38
+ (o) => {
39
+ const l = o.data;
40
+ return (l == null ? void 0 : l.code) != null && l.code !== 200 ? Promise.reject(new Error(l.message || "请求失败")) : (o.data = (l == null ? void 0 : l.data) ?? l, o);
41
+ },
42
+ (o) => {
43
+ var g, w, S;
44
+ ((g = o.response) == null ? void 0 : g.status) === 401 && (t == null || t());
45
+ const l = (S = (w = o.response) == null ? void 0 : w.data) == null ? void 0 : S.message;
46
+ return Promise.reject(new Error(l || o.message || "请求失败"));
47
+ }
48
+ ), ie;
49
+ }
50
+ async function Ht(e, n) {
51
+ const o = (await de().get(
52
+ `/yc-ai/workflows/runs/${e}/artifacts/${n}`,
53
+ { transformResponse: [(l) => l] }
54
+ )).data;
55
+ if (typeof o == "string")
56
+ try {
57
+ return JSON.parse(o);
58
+ } catch {
59
+ return o;
60
+ }
61
+ return o;
62
+ }
63
+ let Pe = {};
64
+ function Jt(e) {
65
+ Pe = { ...Pe, ...e };
66
+ }
67
+ function Ke() {
68
+ return Pe;
69
+ }
70
+ const Xt = { class: "yc-page-window__header" }, Qt = { class: "yc-page-window__title" }, Zt = {
71
+ key: 0,
72
+ class: "yc-page-window__nav"
73
+ }, en = { class: "yc-page-window__opera" }, tn = { class: "yc-page-window__content" }, nn = /* @__PURE__ */ ce({
74
+ __name: "YcPageWindow",
75
+ props: {
76
+ visible: { type: Boolean },
77
+ title: { default: "" },
78
+ type: { default: "" },
79
+ showButtons: { type: Boolean, default: !0 },
80
+ showConfirm: { type: Boolean, default: !0 },
81
+ contentMinHeight: { default: "calc(100vh - 175px)" },
82
+ cancelText: { default: "取消" },
83
+ confirmText: { default: "保存" },
84
+ disabled: { type: Boolean, default: !1 },
85
+ loading: { type: Boolean, default: !1 },
86
+ zIndex: { default: 9 },
87
+ list: { default: () => [] },
88
+ row: { default: null },
89
+ rowKey: { default: "id" }
90
+ },
91
+ emits: ["update:visible", "update:type", "confirm", "close", "opened", "changeType", "prev", "next", "checkRow"],
92
+ setup(e, { expose: n, emit: t }) {
93
+ const o = e, l = t, g = k(!1), w = D(() => o.loading || g.value), S = D(() => o.type === "detail" ? "详情" : o.type === "edit" ? "编辑" : o.type === "add" ? "新增" : ""), m = D(
94
+ () => o.list.length > 0 && o.row != null
95
+ ), r = D(
96
+ () => ["detail", "edit"].includes(o.type)
97
+ ), O = D(() => o.type !== "detail");
98
+ function R() {
99
+ if (!o.row) return -1;
100
+ const C = o.rowKey, U = o.row[C];
101
+ return o.list.findIndex((Y) => Y[C] === U);
102
+ }
103
+ function M(C) {
104
+ const U = R();
105
+ return U < 0 ? !0 : C === "prev" ? U <= 0 : U >= o.list.length - 1;
106
+ }
107
+ function L() {
108
+ const C = R();
109
+ if (C <= 0) return;
110
+ const U = o.list[C - 1];
111
+ l("checkRow", U), l("prev", U);
112
+ }
113
+ function N() {
114
+ const C = R();
115
+ if (C < 0 || C >= o.list.length - 1) return;
116
+ const U = o.list[C + 1];
117
+ l("checkRow", U), l("next", U);
118
+ }
119
+ function y() {
120
+ const C = o.type === "detail" ? "edit" : "detail";
121
+ l("update:type", C), l("changeType");
122
+ }
123
+ function $() {
124
+ l("update:visible", !1), l("close");
125
+ }
126
+ function z() {
127
+ g.value = !0, l("confirm", (C) => {
128
+ g.value = !1, C && $();
129
+ });
130
+ }
131
+ return ne(
132
+ () => o.visible,
133
+ (C) => {
134
+ C && l("opened");
135
+ }
136
+ ), At(() => {
137
+ o.visible && $();
138
+ }), n({ closeWindow: $ }), (C, U) => {
139
+ const Y = V("el-icon"), v = V("el-button"), T = V("el-tooltip"), W = V("el-scrollbar"), H = et("loading");
140
+ return c(), E(tt, {
141
+ name: "yc-page-window-fade",
142
+ mode: "out-in"
143
+ }, {
144
+ default: p(() => [
145
+ _e(_("div", {
146
+ class: "yc-page-window",
147
+ style: He({ zIndex: e.zIndex })
148
+ }, [
149
+ _("div", Xt, [
150
+ _("div", Qt, [
151
+ f(Y, {
152
+ class: "yc-page-window__back",
153
+ onClick: $
154
+ }, {
155
+ default: p(() => [
156
+ f(h(Dt))
157
+ ]),
158
+ _: 1
159
+ }),
160
+ _("span", null, B(e.title) + B(S.value), 1),
161
+ m.value ? (c(), A("div", Zt, [
162
+ f(T, {
163
+ content: "上一条",
164
+ placement: "top"
165
+ }, {
166
+ default: p(() => [
167
+ f(v, {
168
+ round: "",
169
+ text: "",
170
+ disabled: M("prev"),
171
+ onClick: L
172
+ }, {
173
+ default: p(() => [
174
+ f(Y, null, {
175
+ default: p(() => [
176
+ f(h(Bt))
177
+ ]),
178
+ _: 1
179
+ })
180
+ ]),
181
+ _: 1
182
+ }, 8, ["disabled"])
183
+ ]),
184
+ _: 1
185
+ }),
186
+ f(T, {
187
+ content: "下一条",
188
+ placement: "top"
189
+ }, {
190
+ default: p(() => [
191
+ f(v, {
192
+ round: "",
193
+ text: "",
194
+ disabled: M("next"),
195
+ onClick: N
196
+ }, {
197
+ default: p(() => [
198
+ f(Y, null, {
199
+ default: p(() => [
200
+ f(h(Vt))
201
+ ]),
202
+ _: 1
203
+ })
204
+ ]),
205
+ _: 1
206
+ }, 8, ["disabled"])
207
+ ]),
208
+ _: 1
209
+ })
210
+ ])) : P("", !0),
211
+ r.value ? (c(), E(v, {
212
+ key: 1,
213
+ text: "",
214
+ class: "yc-page-window__type-switch",
215
+ type: e.type === "detail" ? "primary" : "success",
216
+ onClick: y
217
+ }, {
218
+ default: p(() => [
219
+ f(Y, { class: "m-r-4" }, {
220
+ default: p(() => [
221
+ f(h(Ot))
222
+ ]),
223
+ _: 1
224
+ }),
225
+ q(" " + B(e.type === "detail" ? "切换编辑" : "切换详情"), 1)
226
+ ]),
227
+ _: 1
228
+ }, 8, ["type"])) : P("", !0)
229
+ ]),
230
+ _("div", en, [
231
+ Ce(C.$slots, "opera", {}, void 0, !0),
232
+ e.showButtons && O.value ? (c(), A(le, { key: 0 }, [
233
+ f(v, {
234
+ text: "",
235
+ disabled: w.value,
236
+ onClick: $
237
+ }, {
238
+ default: p(() => [
239
+ f(Y, { class: "m-r-4" }, {
240
+ default: p(() => [
241
+ f(h(at))
242
+ ]),
243
+ _: 1
244
+ }),
245
+ q(" " + B(e.cancelText), 1)
246
+ ]),
247
+ _: 1
248
+ }, 8, ["disabled"]),
249
+ e.showConfirm ? (c(), E(v, {
250
+ key: 0,
251
+ type: "primary",
252
+ loading: w.value,
253
+ disabled: e.disabled,
254
+ onClick: z
255
+ }, {
256
+ default: p(() => [
257
+ f(Y, { class: "m-r-4" }, {
258
+ default: p(() => [
259
+ f(h(lt))
260
+ ]),
261
+ _: 1
262
+ }),
263
+ q(" " + B(e.confirmText), 1)
264
+ ]),
265
+ _: 1
266
+ }, 8, ["loading", "disabled"])) : P("", !0)
267
+ ], 64)) : P("", !0)
268
+ ])
269
+ ]),
270
+ _e((c(), A("div", tn, [
271
+ f(W, { class: "yc-page-window__scroll" }, {
272
+ default: p(() => [
273
+ e.visible ? (c(), A("div", {
274
+ key: 0,
275
+ class: "yc-page-window__body",
276
+ style: He({ minHeight: e.contentMinHeight })
277
+ }, [
278
+ Ce(C.$slots, "default", {}, void 0, !0)
279
+ ], 4)) : P("", !0)
280
+ ]),
281
+ _: 3
282
+ })
283
+ ])), [
284
+ [H, w.value]
285
+ ])
286
+ ], 4), [
287
+ [Ee, e.visible]
288
+ ])
289
+ ]),
290
+ _: 3
291
+ });
292
+ };
293
+ }
294
+ }), Se = (e, n) => {
295
+ const t = e.__vccOpts || e;
296
+ for (const [o, l] of n)
297
+ t[o] = l;
298
+ return t;
299
+ }, Qe = /* @__PURE__ */ Se(nn, [["__scopeId", "data-v-b3e784c3"]]);
300
+ function on(e) {
301
+ e != null && e.aiTask && (jt(e.aiTask), qt()), e != null && e.imageSelector && Jt(e.imageSelector);
302
+ }
303
+ function an(e, n) {
304
+ (n == null ? void 0 : n.registerPageWindow) !== !1 && (e.component("YcPageWindow", Qe), e.component("SkyPageWindow", Qe));
305
+ }
306
+ const Lo = {
307
+ install(e, n) {
308
+ on(n), an(e, n);
309
+ }
310
+ }, Ae = "__YC_COMPONENT_AI_DIALOG__", Le = "yc-component:ai-dialog-open";
311
+ function ln() {
312
+ const e = globalThis;
313
+ return e[Ae] || (e[Ae] = nt({
314
+ visible: !1,
315
+ options: {}
316
+ })), e[Ae];
317
+ }
318
+ const te = ln();
319
+ function Ne(e = {}) {
320
+ te.options = { ...e }, te.visible = !0, globalThis.dispatchEvent(
321
+ new CustomEvent(Le, { detail: { ...e } })
322
+ );
323
+ }
324
+ function rt() {
325
+ te.visible = !1;
326
+ }
327
+ function Do(e = {}) {
328
+ Ne(e);
329
+ }
330
+ function ut(e) {
331
+ const {
332
+ tasks: n,
333
+ panelVisible: t,
334
+ panelMinimized: o,
335
+ dialogVisible: l,
336
+ runningCount: g,
337
+ activeCount: w,
338
+ panelTitle: S,
339
+ panelSubtitle: m
340
+ } = Yt(e);
341
+ return {
342
+ tasks: n,
343
+ panelVisible: t,
344
+ panelMinimized: o,
345
+ dialogVisible: l,
346
+ runningCount: g,
347
+ activeCount: w,
348
+ panelTitle: S,
349
+ panelSubtitle: m,
350
+ openUseDialog: (r) => {
351
+ Ne(r ?? {}), e.openDialog(r ?? {});
352
+ },
353
+ closeUseDialog: () => e.closeDialog(),
354
+ openTaskPanel: () => e.showPanel(),
355
+ hideTaskPanel: () => e.hidePanel(),
356
+ togglePanelMinimize: () => e.toggleMinimize(),
357
+ submitTask: (r) => e.enqueue(r),
358
+ cancelTask: (r) => e.cancelTask(r),
359
+ cancelAll: () => e.cancelAll(),
360
+ clearFinished: () => e.clearFinished(),
361
+ removeTask: (r) => e.removeTask(r),
362
+ loadTaskResult: (r) => e.loadTaskResult(r),
363
+ refreshTasks: () => e.refreshActiveTasks(),
364
+ onTaskFinish: (r) => e.onTaskFinish(r)
365
+ };
366
+ }
367
+ const sn = "__YC_AI_TASK_CTX_KEY__", rn = "__YC_AI_TASK_STORE_KEY__";
368
+ function ct(e) {
369
+ const n = globalThis;
370
+ return n[e] || (n[e] = Symbol(e)), n[e];
371
+ }
372
+ const dt = ct(sn), ft = ct(rn), un = async (e) => (await de().post(
373
+ "/yc-ai/workflows/runs",
374
+ e
375
+ )).data, pt = async (e) => (await de().get(`/yc-ai/workflows/runs/${e}`)).data, cn = (e) => de().post(`/yc-ai/workflows/runs/${e}/cancel`), dn = (e, n) => de().post(`/yc-ai/workflows/runs/${e}/client-continue`, n);
376
+ async function De(e, n) {
377
+ return Ht(e, n);
378
+ }
379
+ function fn(e, n) {
380
+ const t = e.trim();
381
+ if (!t)
382
+ return n;
383
+ let o;
384
+ try {
385
+ t.includes("function") ? o = new Function(
386
+ "result",
387
+ `
388
+ ${t}
389
+ if (typeof handler === 'function') return handler(result);
390
+ throw new Error('请定义 function handler(result) { ... }');
391
+ `
392
+ ) : o = new Function("result", `return (${t})(result);`);
393
+ } catch (l) {
394
+ throw new Error(`自定义脚本语法错误: ${l instanceof Error ? l.message : String(l)}`);
395
+ }
396
+ try {
397
+ return o(n);
398
+ } catch (l) {
399
+ throw new Error(`自定义脚本执行失败: ${l instanceof Error ? l.message : String(l)}`);
400
+ }
401
+ }
402
+ async function pn(e) {
403
+ return (await un({
404
+ projectId: Gt(),
405
+ freeText: e.freeText,
406
+ promptId: e.promptId,
407
+ autoMatch: e.autoMatch
408
+ })).runId;
409
+ }
410
+ async function mn(e, n) {
411
+ var o, l, g, w;
412
+ const t = await pt(e);
413
+ if (t.status === "WAITING_CLIENT" && t.waitingStepKey && t.waitingClientScript) {
414
+ (o = n == null ? void 0 : n.onProgress) == null || o.call(n, 60, `执行脚本:${t.waitingStepKey}`);
415
+ let S = {};
416
+ t.waitingArtifactId && (S = await De(e, t.waitingArtifactId));
417
+ const m = fn(t.waitingClientScript, S);
418
+ return await dn(e, {
419
+ stepKey: t.waitingStepKey,
420
+ output: m ?? {}
421
+ }), null;
422
+ }
423
+ if (t.status === "SUCCEEDED") {
424
+ if (t.finalArtifactId) {
425
+ (l = n == null ? void 0 : n.onProgress) == null || l.call(n, 95, "加载结果…");
426
+ const S = await De(e, t.finalArtifactId);
427
+ return (g = n == null ? void 0 : n.onProgress) == null || g.call(n, 100, "已完成"), { phase: "SUCCEEDED", runId: e, result: S };
428
+ }
429
+ return { phase: "SUCCEEDED", runId: e, result: {} };
430
+ }
431
+ return t.status === "FAILED" ? { phase: "FAILED", runId: e, errorMessage: t.errorMessage || "工作流失败" } : t.status === "CANCELLED" ? { phase: "FAILED", runId: e, errorMessage: "已取消" } : ((w = n == null ? void 0 : n.onProgress) == null || w.call(n, _n(t), hn(t)), null);
432
+ }
433
+ async function gn(e) {
434
+ const n = await pt(e);
435
+ return n.status !== "SUCCEEDED" || !n.finalArtifactId ? null : await De(e, n.finalArtifactId);
436
+ }
437
+ async function vn(e) {
438
+ await cn(e);
439
+ }
440
+ function _n(e) {
441
+ if (e.status === "PENDING") return 8;
442
+ const n = e.steps ?? [];
443
+ if (!n.length) return 35;
444
+ const t = n.filter((o) => o.status === "SUCCEEDED" || o.status === "SKIPPED").length;
445
+ return Math.min(90, Math.round(20 + t / n.length * 70));
446
+ }
447
+ function hn(e) {
448
+ var t;
449
+ if (e.status === "PENDING") return "排队中…";
450
+ const n = (t = e.steps) == null ? void 0 : t.find((o) => o.status === "RUNNING");
451
+ return n ? `执行中:${n.stepKey}` : "后端处理中…";
452
+ }
453
+ const mt = 80;
454
+ function yn() {
455
+ try {
456
+ const e = localStorage.getItem(st());
457
+ if (!e) return [];
458
+ const n = JSON.parse(e);
459
+ return Array.isArray(n) ? n.filter((t) => t && t.id && t.createdAt).sort((t, o) => o.createdAt - t.createdAt).slice(0, mt) : [];
460
+ } catch {
461
+ return [];
462
+ }
463
+ }
464
+ function wn(e) {
465
+ const n = e.slice(0, mt).map((t) => ({
466
+ id: t.id,
467
+ title: t.title,
468
+ freeText: t.freeText,
469
+ promptId: t.promptId,
470
+ autoMatch: t.autoMatch,
471
+ status: t.status,
472
+ progress: t.progress,
473
+ summary: t.summary,
474
+ runId: t.runId,
475
+ errorMessage: t.errorMessage,
476
+ createdAt: t.createdAt,
477
+ finishedAt: t.finishedAt
478
+ }));
479
+ localStorage.setItem(st(), JSON.stringify(n));
480
+ }
481
+ function Tn(e) {
482
+ return {
483
+ ...e,
484
+ logs: e.runId ? [`ℹ 已从本地恢复,runId=${e.runId}`] : [],
485
+ result: void 0
486
+ };
487
+ }
488
+ function ae(e) {
489
+ return e === "pending" || e === "running";
490
+ }
491
+ let Be = 0, ge = null;
492
+ const In = 5e3;
493
+ function Cn() {
494
+ return Be += 1, `ai_task_${Date.now()}_${Be}`;
495
+ }
496
+ function Sn(e, n = 28) {
497
+ const t = e.trim();
498
+ return t.length <= n ? t : `${t.slice(0, n)}…`;
499
+ }
500
+ const gt = Wt("ycAiTask", () => {
501
+ const e = k([]), n = k(!1), t = k(!1), o = k(!1), l = k({}), g = k(!1), w = /* @__PURE__ */ new Set(), S = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Set();
502
+ function r(a, d) {
503
+ return {
504
+ taskId: a.id,
505
+ runId: a.runId,
506
+ title: a.title,
507
+ freeText: a.freeText,
508
+ promptId: a.promptId,
509
+ result: d,
510
+ finishedAt: a.finishedAt ?? Date.now()
511
+ };
512
+ }
513
+ function O(a, d) {
514
+ var re;
515
+ const u = e.value.find((pe) => pe.id === a);
516
+ if (!(u != null && u.runId)) return;
517
+ const K = r(u, d);
518
+ (re = S.get(a)) == null || re(K), S.delete(a), m.forEach((pe) => pe(K));
519
+ }
520
+ function R(a) {
521
+ return m.add(a), () => m.delete(a);
522
+ }
523
+ const M = D(
524
+ () => e.value.filter((a) => ae(a.status)).length
525
+ ), L = D(() => e.value.filter((a) => a.status === "running").length), N = D(() => M.value > 0 ? "AI 处理中" : e.value.some((a) => a.status === "failed") ? "部分任务失败" : "AI 任务"), y = D(() => {
526
+ const a = e.value.length, d = M.value;
527
+ return a === 0 ? "暂无任务" : d > 0 ? `${d}/${a} 项任务进行中` : `${a} 项任务已完成`;
528
+ });
529
+ function $() {
530
+ wn(e.value);
531
+ }
532
+ function z(a, d) {
533
+ const u = e.value.findIndex((K) => K.id === a);
534
+ u >= 0 && (e.value[u] = { ...e.value[u], ...d }, $());
535
+ }
536
+ function C(a, d) {
537
+ const u = e.value.find((K) => K.id === a);
538
+ u && (u.logs.unshift(d), u.logs.length > 20 && u.logs.pop());
539
+ }
540
+ function U() {
541
+ n.value = !0, t.value = !1;
542
+ }
543
+ function Y() {
544
+ n.value = !1;
545
+ }
546
+ function v() {
547
+ t.value = !t.value;
548
+ }
549
+ function T(a = {}) {
550
+ l.value = { ...a }, o.value = !0, Ne(a);
551
+ }
552
+ function W() {
553
+ o.value = !1, rt();
554
+ }
555
+ function H() {
556
+ ge || (ge = setInterval(() => {
557
+ J();
558
+ }, In));
559
+ }
560
+ function x() {
561
+ M.value > 0 || ge && (clearInterval(ge), ge = null);
562
+ }
563
+ async function J() {
564
+ const a = e.value.filter((d) => d.runId && ae(d.status));
565
+ if (!a.length) {
566
+ x();
567
+ return;
568
+ }
569
+ await Promise.all(a.map((d) => X(d.id)));
570
+ }
571
+ async function X(a) {
572
+ if (w.has(a)) return;
573
+ const d = e.value.find((u) => u.id === a);
574
+ if (!(!(d != null && d.runId) || !ae(d.status))) {
575
+ w.add(a);
576
+ try {
577
+ const u = await mn(d.runId, {
578
+ onProgress: (K, re) => z(a, { progress: K, summary: re, status: "running" })
579
+ });
580
+ if (!u) return;
581
+ if (u.phase === "SUCCEEDED") {
582
+ const K = u.result ?? {};
583
+ z(a, {
584
+ status: "succeeded",
585
+ progress: 100,
586
+ summary: "已完成",
587
+ result: K,
588
+ runId: u.runId,
589
+ finishedAt: Date.now()
590
+ }), O(a, K);
591
+ } else
592
+ z(a, {
593
+ status: u.errorMessage === "已取消" ? "cancelled" : "failed",
594
+ progress: 100,
595
+ summary: u.errorMessage || "失败",
596
+ errorMessage: u.errorMessage,
597
+ runId: u.runId,
598
+ finishedAt: Date.now()
599
+ });
600
+ x();
601
+ } catch (u) {
602
+ const K = u instanceof Error ? u.message : "同步失败";
603
+ C(a, `✗ ${K}`);
604
+ } finally {
605
+ w.delete(a);
606
+ }
607
+ }
608
+ }
609
+ async function oe() {
610
+ if (g.value) return;
611
+ g.value = !0;
612
+ const a = yn();
613
+ a.length && (e.value = a.map(Tn), Be = a.length);
614
+ const d = e.value.filter((u) => u.runId && ae(u.status));
615
+ d.length && (await Promise.all(d.map((u) => X(u.id))), H());
616
+ for (const u of e.value)
617
+ u.status === "pending" && !u.runId && z(u.id, { status: "failed", summary: "页面刷新前未提交成功", finishedAt: Date.now() });
618
+ }
619
+ function F(a) {
620
+ const d = Cn(), u = {
621
+ id: d,
622
+ title: a.title ?? Sn(a.freeText),
623
+ freeText: a.freeText.trim(),
624
+ promptId: a.promptId,
625
+ autoMatch: a.autoMatch,
626
+ status: "pending",
627
+ progress: 0,
628
+ summary: "正在提交…",
629
+ createdAt: Date.now(),
630
+ logs: []
631
+ };
632
+ return e.value.unshift(u), $(), a.onFinish && S.set(d, a.onFinish), a.showPanel !== !1 && U(), se(d), d;
633
+ }
634
+ async function se(a) {
635
+ const d = e.value.find((u) => u.id === a);
636
+ if (d)
637
+ try {
638
+ const u = await pn({
639
+ freeText: d.freeText,
640
+ promptId: d.promptId,
641
+ autoMatch: d.autoMatch
642
+ });
643
+ z(a, {
644
+ runId: u,
645
+ status: "running",
646
+ progress: 10,
647
+ summary: "后端异步处理中…"
648
+ }), C(a, `▶ 已提交 runId=${u}`), H(), X(a);
649
+ } catch (u) {
650
+ const K = u instanceof Error ? u.message : "提交失败";
651
+ z(a, {
652
+ status: "failed",
653
+ progress: 100,
654
+ summary: K,
655
+ errorMessage: K,
656
+ finishedAt: Date.now()
657
+ });
658
+ }
659
+ }
660
+ async function j(a) {
661
+ const d = e.value.find((K) => K.id === a);
662
+ if (!(d != null && d.runId)) return null;
663
+ if (d.result) return d.result;
664
+ const u = await gn(d.runId);
665
+ return u && z(a, { result: u }), u;
666
+ }
667
+ async function fe(a) {
668
+ const d = e.value.find((u) => u.id === a);
669
+ if (d != null && d.runId && ae(d.status))
670
+ try {
671
+ await vn(d.runId);
672
+ } catch {
673
+ }
674
+ d && ae(d.status) && z(a, { status: "cancelled", summary: "已取消", finishedAt: Date.now() }), S.delete(a), x();
675
+ }
676
+ function ye() {
677
+ for (const a of e.value)
678
+ ae(a.status) && fe(a.id);
679
+ }
680
+ function ke() {
681
+ e.value = e.value.filter((a) => ae(a.status)), $();
682
+ }
683
+ function Q(a) {
684
+ fe(a), S.delete(a), e.value = e.value.filter((d) => d.id !== a), $();
685
+ }
686
+ return {
687
+ tasks: e,
688
+ panelVisible: n,
689
+ panelMinimized: t,
690
+ dialogVisible: o,
691
+ dialogOptions: l,
692
+ hydrated: g,
693
+ runningCount: M,
694
+ activeCount: L,
695
+ panelTitle: N,
696
+ panelSubtitle: y,
697
+ hydrate: oe,
698
+ showPanel: U,
699
+ hidePanel: Y,
700
+ toggleMinimize: v,
701
+ openDialog: T,
702
+ closeDialog: W,
703
+ enqueue: F,
704
+ onTaskFinish: R,
705
+ refreshActiveTasks: J,
706
+ loadTaskResult: j,
707
+ cancelTask: fe,
708
+ cancelAll: ye,
709
+ clearFinished: ke,
710
+ removeTask: Q
711
+ };
712
+ });
713
+ async function kn(e) {
714
+ return (await de().get("/yc-ai/ai/prompts", {
715
+ params: e ? { category: e } : {}
716
+ })).data;
717
+ }
718
+ function ze() {
719
+ const e = Oe(ft, null);
720
+ return e || gt();
721
+ }
722
+ const xn = { class: "ai-use-dialog__footer" }, bn = { class: "ai-use-dialog__footer-actions" }, An = /* @__PURE__ */ ce({
723
+ __name: "AiUseDialog",
724
+ props: {
725
+ title: { default: "AI 生成" },
726
+ freeText: { default: "" },
727
+ promptId: {},
728
+ autoMatch: { type: Boolean, default: !1 },
729
+ prompts: {},
730
+ showAutoMatch: { type: Boolean, default: !1 },
731
+ showPromptSelect: { type: Boolean, default: !1 },
732
+ autoMatchLabel: { default: "自动匹配提示词" },
733
+ promptLabel: { default: "提示词" },
734
+ freeTextLabel: { default: "需求描述" },
735
+ freeTextPlaceholder: { default: "描述要生成的页面或项目 JSON" },
736
+ submitText: { default: "发送" },
737
+ showTaskListButton: { type: Boolean, default: !0 },
738
+ taskListButtonText: { default: "查看 AI 任务" },
739
+ width: { default: "520px" },
740
+ modelValue: { type: Boolean },
741
+ showDialog: { type: Boolean }
742
+ },
743
+ emits: ["update:modelValue", "submitted"],
744
+ setup(e, { emit: n }) {
745
+ const t = e, o = n, l = ze(), g = D(() => t.modelValue !== void 0), w = k(!1);
746
+ ne(
747
+ () => t.modelValue,
748
+ (v) => {
749
+ g.value && (w.value = !!v);
750
+ },
751
+ { immediate: !0 }
752
+ ), ne(w, (v) => {
753
+ if (g.value) {
754
+ o("update:modelValue", v);
755
+ return;
756
+ }
757
+ te.visible = v, v || rt();
758
+ }), ne(
759
+ () => te.visible,
760
+ (v) => {
761
+ g.value || (w.value = v);
762
+ },
763
+ { immediate: !0 }
764
+ );
765
+ function S(v) {
766
+ if (g.value) return;
767
+ const T = v.detail ?? {};
768
+ N(T), w.value = !0;
769
+ }
770
+ Ue(() => {
771
+ globalThis.addEventListener(Le, S), g.value || (w.value = te.visible);
772
+ }), Re(() => {
773
+ globalThis.removeEventListener(Le, S);
774
+ });
775
+ const m = D(
776
+ () => (g.value ? void 0 : te.options.title) ?? t.title ?? "AI 生成"
777
+ ), r = k({
778
+ freeText: t.freeText,
779
+ promptId: t.promptId,
780
+ autoMatch: t.autoMatch
781
+ }), O = k(t.prompts ? [...t.prompts] : []), R = k(!1), M = k(!1), L = k();
782
+ function N(v) {
783
+ var T, W;
784
+ r.value.freeText = v.freeText ?? t.freeText ?? "", r.value.promptId = v.promptId ?? t.promptId, r.value.autoMatch = v.autoMatch ?? t.autoMatch ?? !1, L.value = v.onFinish, (T = v.prompts) != null && T.length ? O.value = [...v.prompts] : (W = t.prompts) != null && W.length && (O.value = [...t.prompts]);
785
+ }
786
+ async function y() {
787
+ if (!(O.value.length > 0)) {
788
+ R.value = !0;
789
+ try {
790
+ const v = it().listPrompts;
791
+ O.value = v ? await v() : await kn();
792
+ } catch {
793
+ ee.warning("加载提示词失败");
794
+ } finally {
795
+ R.value = !1;
796
+ }
797
+ }
798
+ }
799
+ function $() {
800
+ g.value ? N({}) : N(te.options), t.showPromptSelect && y();
801
+ }
802
+ ne(
803
+ () => t.prompts,
804
+ (v) => {
805
+ v != null && v.length && (O.value = [...v]);
806
+ },
807
+ { deep: !0 }
808
+ ), ne(
809
+ () => [t.freeText, t.promptId, t.autoMatch],
810
+ ([v, T, W]) => {
811
+ w.value || (r.value.freeText = v ?? "", r.value.promptId = T, r.value.autoMatch = W ?? !1);
812
+ }
813
+ );
814
+ function z() {
815
+ r.value.autoMatch && (r.value.promptId = void 0);
816
+ }
817
+ function C() {
818
+ M.value = !1;
819
+ }
820
+ function U() {
821
+ l.showPanel();
822
+ }
823
+ async function Y() {
824
+ var x, J;
825
+ if (!r.value.freeText.trim()) {
826
+ ee.warning("请填写需求描述");
827
+ return;
828
+ }
829
+ const v = r.value.autoMatch, T = v ? void 0 : r.value.promptId;
830
+ if (!v && T == null) {
831
+ const X = t.showPromptSelect || t.showAutoMatch ? "请选择提示词或开启自动匹配" : "请通过 promptId 传入提示词,或设置 autoMatch 为 true";
832
+ ee.warning(X);
833
+ return;
834
+ }
835
+ M.value = !0;
836
+ const W = g.value ? L.value : te.options.onFinish, H = l.enqueue({
837
+ freeText: r.value.freeText.trim(),
838
+ promptId: T,
839
+ autoMatch: v && T == null ? !0 : void 0,
840
+ showPanel: !0,
841
+ onFinish: W
842
+ });
843
+ g.value ? o("submitted", H) : (J = (x = te.options).onSubmitted) == null || J.call(x, H), w.value = !1, M.value = !1, ee.success("已加入任务队列,可在任务面板查看进度");
844
+ }
845
+ return (v, T) => {
846
+ const W = V("el-switch"), H = V("el-form-item"), x = V("el-option"), J = V("el-select"), X = V("el-input"), oe = V("el-form"), F = V("el-button"), se = V("el-dialog");
847
+ return c(), E(se, {
848
+ modelValue: w.value,
849
+ "onUpdate:modelValue": T[4] || (T[4] = (j) => w.value = j),
850
+ title: m.value,
851
+ width: e.width,
852
+ "append-to-body": "",
853
+ class: "ai-use-dialog",
854
+ onClosed: C,
855
+ onOpen: $
856
+ }, {
857
+ footer: p(() => [
858
+ _("div", xn, [
859
+ e.showTaskListButton ? (c(), E(F, {
860
+ key: 0,
861
+ link: "",
862
+ type: "primary",
863
+ onClick: U
864
+ }, {
865
+ default: p(() => [
866
+ q(B(e.taskListButtonText), 1)
867
+ ]),
868
+ _: 1
869
+ })) : P("", !0),
870
+ _("div", bn, [
871
+ f(F, {
872
+ onClick: T[3] || (T[3] = (j) => w.value = !1)
873
+ }, {
874
+ default: p(() => [...T[5] || (T[5] = [
875
+ q("取消", -1)
876
+ ])]),
877
+ _: 1
878
+ }),
879
+ f(F, {
880
+ type: "primary",
881
+ loading: M.value,
882
+ onClick: Y
883
+ }, {
884
+ default: p(() => [
885
+ q(B(e.submitText), 1)
886
+ ]),
887
+ _: 1
888
+ }, 8, ["loading"])
889
+ ])
890
+ ])
891
+ ]),
892
+ default: p(() => [
893
+ f(oe, { "label-position": "top" }, {
894
+ default: p(() => [
895
+ e.showAutoMatch ? (c(), E(H, {
896
+ key: 0,
897
+ label: e.autoMatchLabel
898
+ }, {
899
+ default: p(() => [
900
+ f(W, {
901
+ modelValue: r.value.autoMatch,
902
+ "onUpdate:modelValue": T[0] || (T[0] = (j) => r.value.autoMatch = j),
903
+ "active-text": "按需求自动选",
904
+ "inactive-text": "手动指定",
905
+ onChange: z
906
+ }, null, 8, ["modelValue"])
907
+ ]),
908
+ _: 1
909
+ }, 8, ["label"])) : P("", !0),
910
+ e.showPromptSelect ? (c(), E(H, {
911
+ key: 1,
912
+ label: e.promptLabel,
913
+ required: !r.value.autoMatch
914
+ }, {
915
+ default: p(() => [
916
+ f(J, {
917
+ modelValue: r.value.promptId,
918
+ "onUpdate:modelValue": T[1] || (T[1] = (j) => r.value.promptId = j),
919
+ filterable: "",
920
+ clearable: "",
921
+ placeholder: r.value.autoMatch ? "留空则自动匹配" : "请选择提示词",
922
+ style: { width: "100%" },
923
+ loading: R.value
924
+ }, {
925
+ default: p(() => [
926
+ (c(!0), A(le, null, ve(O.value, (j) => (c(), E(x, {
927
+ key: j.id,
928
+ label: j.name,
929
+ value: j.id
930
+ }, null, 8, ["label", "value"]))), 128))
931
+ ]),
932
+ _: 1
933
+ }, 8, ["modelValue", "placeholder", "loading"])
934
+ ]),
935
+ _: 1
936
+ }, 8, ["label", "required"])) : P("", !0),
937
+ f(H, {
938
+ label: e.freeTextLabel,
939
+ required: ""
940
+ }, {
941
+ default: p(() => [
942
+ f(X, {
943
+ modelValue: r.value.freeText,
944
+ "onUpdate:modelValue": T[2] || (T[2] = (j) => r.value.freeText = j),
945
+ type: "textarea",
946
+ rows: 4,
947
+ placeholder: e.freeTextPlaceholder
948
+ }, null, 8, ["modelValue", "placeholder"])
949
+ ]),
950
+ _: 1
951
+ }, 8, ["label"])
952
+ ]),
953
+ _: 1
954
+ })
955
+ ]),
956
+ _: 1
957
+ }, 8, ["modelValue", "title", "width"]);
958
+ };
959
+ }
960
+ }), Mn = /* @__PURE__ */ Se(An, [["__scopeId", "data-v-9aa82e83"]]), En = { class: "ai-task-panel" }, $n = { class: "ai-task-panel__header" }, Pn = { class: "ai-task-panel__header-left" }, Ln = { class: "ai-task-panel__titles" }, Dn = { class: "ai-task-panel__subtitle" }, Bn = { class: "ai-task-panel__title" }, Vn = { class: "ai-task-panel__header-actions" }, On = { class: "ai-task-panel__body" }, Un = {
961
+ key: 1,
962
+ class: "ai-task-list"
963
+ }, Rn = { class: "ai-task-row__icon" }, Fn = { class: "ai-task-row__main" }, Kn = { class: "ai-task-row__title" }, Nn = { class: "ai-task-row__meta" }, zn = { key: 0 }, Yn = {
964
+ key: 0,
965
+ class: "ai-task-row__summary"
966
+ }, Wn = { class: "ai-task-row__ops" }, jn = {
967
+ key: 0,
968
+ class: "ai-task-panel__footer"
969
+ }, Gn = /* @__PURE__ */ ce({
970
+ __name: "AiTaskPanel",
971
+ emits: ["use"],
972
+ setup(e, { emit: n }) {
973
+ const t = n, o = ze(), l = k(null), g = {
974
+ pending: "等待中",
975
+ running: "执行中",
976
+ succeeded: "已完成",
977
+ failed: "失败",
978
+ cancelled: "已取消"
979
+ };
980
+ function w(m) {
981
+ return g[m] ?? m;
982
+ }
983
+ async function S(m) {
984
+ l.value = m.id;
985
+ try {
986
+ const r = m.result ?? await o.loadTaskResult(m.id);
987
+ if (!r) return;
988
+ t("use", {
989
+ taskId: m.id,
990
+ runId: m.runId,
991
+ title: m.title,
992
+ freeText: m.freeText,
993
+ promptId: m.promptId,
994
+ result: r,
995
+ finishedAt: m.finishedAt ?? Date.now()
996
+ });
997
+ } finally {
998
+ l.value = null;
999
+ }
1000
+ }
1001
+ return (m, r) => {
1002
+ const O = V("el-icon"), R = V("el-button"), M = V("el-empty"), L = V("el-progress"), N = V("el-badge");
1003
+ return c(), E(Mt, { to: "body" }, [
1004
+ f(tt, { name: "ai-panel-slide" }, {
1005
+ default: p(() => [
1006
+ _e(_("div", En, [
1007
+ _("div", $n, [
1008
+ _("div", Pn, [
1009
+ _("div", {
1010
+ class: ue(["ai-task-panel__icon", { spinning: h(o).activeCount > 0 }])
1011
+ }, [
1012
+ f(O, null, {
1013
+ default: p(() => [
1014
+ f(h(Xe))
1015
+ ]),
1016
+ _: 1
1017
+ })
1018
+ ], 2),
1019
+ _("div", Ln, [
1020
+ _("div", Dn, B(h(o).panelSubtitle), 1),
1021
+ _("div", Bn, B(h(o).panelTitle), 1)
1022
+ ])
1023
+ ]),
1024
+ _("div", Vn, [
1025
+ h(o).runningCount > 0 ? (c(), E(R, {
1026
+ key: 0,
1027
+ link: "",
1028
+ type: "primary",
1029
+ onClick: r[0] || (r[0] = (y) => h(o).cancelAll())
1030
+ }, {
1031
+ default: p(() => [...r[5] || (r[5] = [
1032
+ q(" 取消全部 ", -1)
1033
+ ])]),
1034
+ _: 1
1035
+ })) : P("", !0),
1036
+ f(R, {
1037
+ link: "",
1038
+ onClick: r[1] || (r[1] = (y) => h(o).toggleMinimize())
1039
+ }, {
1040
+ default: p(() => [
1041
+ f(O, null, {
1042
+ default: p(() => [
1043
+ f(h(Ut))
1044
+ ]),
1045
+ _: 1
1046
+ })
1047
+ ]),
1048
+ _: 1
1049
+ }),
1050
+ f(R, {
1051
+ link: "",
1052
+ onClick: r[2] || (r[2] = (y) => h(o).hidePanel())
1053
+ }, {
1054
+ default: p(() => [
1055
+ f(O, null, {
1056
+ default: p(() => [
1057
+ f(h(at))
1058
+ ]),
1059
+ _: 1
1060
+ })
1061
+ ]),
1062
+ _: 1
1063
+ })
1064
+ ])
1065
+ ]),
1066
+ _("div", On, [
1067
+ h(o).tasks.length ? (c(), A("div", Un, [
1068
+ (c(!0), A(le, null, ve(h(o).tasks, (y) => (c(), A("div", {
1069
+ key: y.id,
1070
+ class: "ai-task-row"
1071
+ }, [
1072
+ _("div", Rn, [
1073
+ y.status === "succeeded" ? (c(), E(O, {
1074
+ key: 0,
1075
+ class: "ok"
1076
+ }, {
1077
+ default: p(() => [
1078
+ f(h(Rt))
1079
+ ]),
1080
+ _: 1
1081
+ })) : y.status === "failed" ? (c(), E(O, {
1082
+ key: 1,
1083
+ class: "err"
1084
+ }, {
1085
+ default: p(() => [
1086
+ f(h(Ft))
1087
+ ]),
1088
+ _: 1
1089
+ })) : y.status === "running" || y.status === "pending" ? (c(), E(L, {
1090
+ key: 2,
1091
+ type: "circle",
1092
+ percentage: y.progress,
1093
+ width: 36,
1094
+ "stroke-width": 3
1095
+ }, null, 8, ["percentage"])) : (c(), E(O, {
1096
+ key: 3,
1097
+ class: "muted"
1098
+ }, {
1099
+ default: p(() => [
1100
+ f(h(Kt))
1101
+ ]),
1102
+ _: 1
1103
+ }))
1104
+ ]),
1105
+ _("div", Fn, [
1106
+ _("div", Kn, B(y.title), 1),
1107
+ _("div", Nn, [
1108
+ _("span", null, B(w(y.status)), 1),
1109
+ y.runId ? (c(), A("span", zn, " · #" + B(y.runId), 1)) : P("", !0)
1110
+ ]),
1111
+ y.summary ? (c(), A("div", Yn, B(y.summary), 1)) : P("", !0)
1112
+ ]),
1113
+ _("div", Wn, [
1114
+ y.status === "running" || y.status === "pending" ? (c(), E(R, {
1115
+ key: 0,
1116
+ link: "",
1117
+ type: "danger",
1118
+ size: "small",
1119
+ onClick: ($) => h(o).cancelTask(y.id)
1120
+ }, {
1121
+ default: p(() => [...r[6] || (r[6] = [
1122
+ q(" 取消 ", -1)
1123
+ ])]),
1124
+ _: 1
1125
+ }, 8, ["onClick"])) : P("", !0),
1126
+ y.status === "succeeded" && y.runId ? (c(), E(R, {
1127
+ key: 1,
1128
+ link: "",
1129
+ type: "primary",
1130
+ size: "small",
1131
+ loading: l.value === y.id,
1132
+ onClick: ($) => S(y)
1133
+ }, {
1134
+ default: p(() => [...r[7] || (r[7] = [
1135
+ q(" 使用 ", -1)
1136
+ ])]),
1137
+ _: 1
1138
+ }, 8, ["loading", "onClick"])) : P("", !0),
1139
+ y.status !== "running" && y.status !== "pending" ? (c(), E(R, {
1140
+ key: 2,
1141
+ link: "",
1142
+ size: "small",
1143
+ onClick: ($) => h(o).removeTask(y.id)
1144
+ }, {
1145
+ default: p(() => [...r[8] || (r[8] = [
1146
+ q(" 移除 ", -1)
1147
+ ])]),
1148
+ _: 1
1149
+ }, 8, ["onClick"])) : P("", !0)
1150
+ ])
1151
+ ]))), 128))
1152
+ ])) : (c(), E(M, {
1153
+ key: 0,
1154
+ description: "暂无 AI 任务",
1155
+ "image-size": 64
1156
+ }))
1157
+ ]),
1158
+ h(o).tasks.some((y) => y.status !== "running" && y.status !== "pending") ? (c(), A("div", jn, [
1159
+ f(R, {
1160
+ link: "",
1161
+ type: "info",
1162
+ onClick: r[3] || (r[3] = (y) => h(o).clearFinished())
1163
+ }, {
1164
+ default: p(() => [...r[9] || (r[9] = [
1165
+ q("清除已完成", -1)
1166
+ ])]),
1167
+ _: 1
1168
+ })
1169
+ ])) : P("", !0)
1170
+ ], 512), [
1171
+ [Ee, h(o).panelVisible && !h(o).panelMinimized]
1172
+ ])
1173
+ ]),
1174
+ _: 1
1175
+ }),
1176
+ _e(_("div", {
1177
+ class: "ai-task-panel-mini",
1178
+ onClick: r[4] || (r[4] = (y) => h(o).toggleMinimize())
1179
+ }, [
1180
+ h(o).activeCount > 0 ? (c(), E(O, {
1181
+ key: 0,
1182
+ class: "spinning"
1183
+ }, {
1184
+ default: p(() => [
1185
+ f(h(Xe))
1186
+ ]),
1187
+ _: 1
1188
+ })) : P("", !0),
1189
+ _("span", null, B(h(o).panelSubtitle), 1),
1190
+ h(o).runningCount > 0 ? (c(), E(N, {
1191
+ key: 1,
1192
+ value: h(o).runningCount,
1193
+ class: "m-l-8"
1194
+ }, null, 8, ["value"])) : P("", !0)
1195
+ ], 512), [
1196
+ [Ee, h(o).panelVisible && h(o).panelMinimized]
1197
+ ])
1198
+ ]);
1199
+ };
1200
+ }
1201
+ }), qn = /* @__PURE__ */ Se(Gn, [["__scopeId", "data-v-812b3127"]]), Bo = /* @__PURE__ */ ce({
1202
+ __name: "AiTaskProvider",
1203
+ props: {
1204
+ title: {},
1205
+ freeText: {},
1206
+ promptId: {},
1207
+ autoMatch: { type: Boolean },
1208
+ prompts: {},
1209
+ showAutoMatch: { type: Boolean },
1210
+ showPromptSelect: { type: Boolean },
1211
+ autoMatchLabel: {},
1212
+ promptLabel: {},
1213
+ freeTextLabel: {},
1214
+ freeTextPlaceholder: {},
1215
+ submitText: {},
1216
+ showTaskListButton: { type: Boolean },
1217
+ taskListButtonText: {},
1218
+ width: {},
1219
+ modelValue: { type: Boolean },
1220
+ showDialog: { type: Boolean, default: !0 }
1221
+ },
1222
+ emits: ["finish", "use"],
1223
+ setup(e, { emit: n }) {
1224
+ const t = e, o = n, l = gt();
1225
+ $e(ft, l), $e(dt, ut(l));
1226
+ const g = D(() => {
1227
+ const m = {
1228
+ title: t.title,
1229
+ freeText: t.freeText,
1230
+ promptId: t.promptId,
1231
+ autoMatch: t.autoMatch,
1232
+ prompts: t.prompts,
1233
+ showAutoMatch: t.showAutoMatch,
1234
+ showPromptSelect: t.showPromptSelect,
1235
+ autoMatchLabel: t.autoMatchLabel,
1236
+ promptLabel: t.promptLabel,
1237
+ freeTextLabel: t.freeTextLabel,
1238
+ freeTextPlaceholder: t.freeTextPlaceholder,
1239
+ submitText: t.submitText,
1240
+ showTaskListButton: t.showTaskListButton,
1241
+ taskListButtonText: t.taskListButtonText,
1242
+ width: t.width
1243
+ };
1244
+ return t.modelValue !== void 0 && (m.modelValue = t.modelValue), m;
1245
+ });
1246
+ let w;
1247
+ function S(m) {
1248
+ o("use", m);
1249
+ }
1250
+ return Ue(() => {
1251
+ l.hydrate(), w = l.onTaskFinish((m) => o("finish", m));
1252
+ }), Re(() => {
1253
+ w == null || w();
1254
+ }), (m, r) => (c(), A(le, null, [
1255
+ e.showDialog !== !1 ? (c(), E(Mn, Et(ot({ key: 0 }, g.value)), null, 16)) : P("", !0),
1256
+ f(qn, { onUse: S }),
1257
+ Ce(m.$slots, "default")
1258
+ ], 64));
1259
+ }
1260
+ });
1261
+ function Vo() {
1262
+ const e = Oe(dt, null);
1263
+ return e || ut(ze());
1264
+ }
1265
+ const Me = "__YC_COMPONENT_IMAGE_SELECTOR__", Ve = "yc-component:image-selector-open";
1266
+ function Hn() {
1267
+ const e = globalThis;
1268
+ return e[Me] || (e[Me] = nt({
1269
+ visible: !1,
1270
+ options: {}
1271
+ })), e[Me];
1272
+ }
1273
+ const G = Hn();
1274
+ function Jn(e = {}) {
1275
+ G.options = { ...e }, G.visible = !0, globalThis.dispatchEvent(
1276
+ new CustomEvent(Ve, { detail: { ...e } })
1277
+ );
1278
+ }
1279
+ function Xn() {
1280
+ G.visible = !1;
1281
+ }
1282
+ function Qn(e = {}) {
1283
+ Jn(e);
1284
+ }
1285
+ const Zn = { class: "yc-image-selector" }, eo = { class: "yc-image-selector__toolbar" }, to = { class: "yc-image-selector__body" }, no = {
1286
+ key: 0,
1287
+ class: "yc-image-selector__aside"
1288
+ }, oo = ["onClick"], ao = {
1289
+ key: 0,
1290
+ class: "yc-image-selector__category-count"
1291
+ }, lo = { class: "yc-image-selector__main" }, io = {
1292
+ key: 1,
1293
+ class: "yc-image-selector__grid"
1294
+ }, so = ["onClick"], ro = { class: "yc-image-selector__thumb" }, uo = ["src", "alt", "onLoad"], co = {
1295
+ key: 0,
1296
+ class: "yc-image-selector__order"
1297
+ }, fo = ["title"], po = {
1298
+ key: 0,
1299
+ class: "yc-image-selector__selected-bar"
1300
+ }, mo = { class: "yc-image-selector__selected-bar-label" }, go = { class: "yc-image-selector__selected-bar-list" }, vo = ["onClick"], _o = ["src", "alt"], ho = {
1301
+ key: 1,
1302
+ class: "yc-image-selector__pagination"
1303
+ }, yo = {
1304
+ key: 0,
1305
+ class: "yc-image-selector__footer"
1306
+ }, wo = { class: "yc-image-selector__selected-tip" }, To = { class: "yc-image-selector__footer-actions" }, Io = {
1307
+ key: 1,
1308
+ class: "yc-image-selector__footer yc-image-selector__footer--quick"
1309
+ }, Co = { class: "yc-image-selector__selected-tip" }, So = /* @__PURE__ */ ce({
1310
+ __name: "YcImageSelectorDialog",
1311
+ props: {
1312
+ modelValue: { type: Boolean },
1313
+ title: { default: "选择图片" },
1314
+ multiple: { type: Boolean, default: !1 },
1315
+ maxCount: { default: 9 },
1316
+ selected: {},
1317
+ width: { default: "860px" },
1318
+ pageSize: { default: 8 },
1319
+ showUpload: { type: Boolean, default: !0 },
1320
+ accept: { default: "image/*" },
1321
+ showCategories: { type: Boolean, default: !1 },
1322
+ categories: {},
1323
+ categoryAllLabel: { default: "全部" },
1324
+ showModeSwitch: { type: Boolean, default: !1 },
1325
+ confirmOnSelect: { type: Boolean, default: !1 },
1326
+ confirmText: { default: "确定" },
1327
+ cancelText: { default: "取消" },
1328
+ emptyText: { default: "暂无图片资源" },
1329
+ getImages: {},
1330
+ upload: {}
1331
+ },
1332
+ emits: ["update:modelValue", "confirm", "cancel"],
1333
+ setup(e, { emit: n }) {
1334
+ const t = e, o = n, l = D(() => t.modelValue !== void 0), g = k(!1);
1335
+ ne(
1336
+ () => t.modelValue,
1337
+ (s) => {
1338
+ l.value && (g.value = !!s);
1339
+ },
1340
+ { immediate: !0 }
1341
+ ), ne(g, (s) => {
1342
+ if (l.value) {
1343
+ o("update:modelValue", s);
1344
+ return;
1345
+ }
1346
+ G.visible = s, s || Xn();
1347
+ }), ne(
1348
+ () => G.visible,
1349
+ (s) => {
1350
+ l.value || (g.value = s);
1351
+ },
1352
+ { immediate: !0 }
1353
+ );
1354
+ const w = D(
1355
+ () => (l.value ? void 0 : G.options.title) ?? t.title ?? "选择图片"
1356
+ ), S = D(
1357
+ () => (l.value ? void 0 : G.options.multiple) ?? t.multiple
1358
+ ), m = D(
1359
+ () => (l.value ? void 0 : G.options.maxCount) ?? t.maxCount
1360
+ ), r = D(
1361
+ () => (l.value ? void 0 : G.options.showModeSwitch) ?? t.showModeSwitch
1362
+ ), O = D(
1363
+ () => (l.value ? void 0 : G.options.showCategories) ?? t.showCategories
1364
+ ), R = D(() => {
1365
+ var s, i;
1366
+ if ((s = t.categories) != null && s.length) return t.categories;
1367
+ if (!l.value && ((i = G.options.categories) != null && i.length))
1368
+ return G.options.categories;
1369
+ }), M = D(() => O.value ? R.value ?? H.value : []), L = D(() => !!t.confirmOnSelect), N = k("single"), y = [
1370
+ { label: "单选", value: "single" },
1371
+ { label: "多选", value: "multiple" }
1372
+ ], $ = D(
1373
+ () => r.value ? N.value === "multiple" : S.value
1374
+ ), z = k(""), C = k(""), U = k(1), Y = k(0), v = k(!1), T = k(!1), W = k([]), H = k([]), x = k(/* @__PURE__ */ new Map()), J = k(/* @__PURE__ */ new Map()), X = k(), oe = k(), F = D(() => [...x.value.values()]), se = D(() => {
1375
+ var i, b;
1376
+ const s = F.value.length;
1377
+ return L.value ? s ? `已选:${((i = F.value[0]) == null ? void 0 : i.name) || "1 张图片"}` : "单击图片即可完成选择" : s ? $.value ? `已选 ${s} / ${m.value} 张` : `已选:${((b = F.value[0]) == null ? void 0 : b.name) || "1 张图片"}` : $.value ? `多选模式:最多 ${m.value} 张` : "单选模式:请选择一张图片";
1378
+ });
1379
+ function j(s) {
1380
+ const i = F.value.findIndex((b) => Q(b) === Q(s));
1381
+ return i >= 0 ? i + 1 : "";
1382
+ }
1383
+ function fe(s) {
1384
+ if (s === "single" && F.value.length > 1) {
1385
+ const i = F.value[0];
1386
+ x.value = /* @__PURE__ */ new Map([[Q(i), i]]), ee.info("已切换为单选,仅保留第一张");
1387
+ }
1388
+ }
1389
+ function ye() {
1390
+ N.value = S.value ? "multiple" : "single";
1391
+ }
1392
+ function ke() {
1393
+ x.value = /* @__PURE__ */ new Map();
1394
+ }
1395
+ function Q(s) {
1396
+ return s.id ?? s.url;
1397
+ }
1398
+ function a(s) {
1399
+ return x.value.has(Q(s));
1400
+ }
1401
+ function d(s, i) {
1402
+ return s < i ? "portrait" : s > i ? "landscape" : "square";
1403
+ }
1404
+ function u(s, i) {
1405
+ const b = Q(s);
1406
+ J.value.get(b) !== i && (J.value.set(b, i), J.value = new Map(J.value));
1407
+ }
1408
+ function K(s) {
1409
+ const i = J.value.get(Q(s));
1410
+ return i ? `yc-image-selector__img--${i}` : "";
1411
+ }
1412
+ function re(s, i) {
1413
+ const b = s.target;
1414
+ !(b != null && b.naturalWidth) || !(b != null && b.naturalHeight) || u(i, d(b.naturalWidth, b.naturalHeight));
1415
+ }
1416
+ function pe(s) {
1417
+ s.width && s.height && u(s, d(s.width, s.height));
1418
+ }
1419
+ function Ye(s) {
1420
+ const i = /* @__PURE__ */ new Map();
1421
+ if (!(s != null && s.length)) {
1422
+ x.value = i;
1423
+ return;
1424
+ }
1425
+ if (typeof s[0] == "string")
1426
+ for (const Z of s)
1427
+ i.set(Z, { id: Z, url: Z, name: Z.split("/").pop() });
1428
+ else
1429
+ for (const Z of s)
1430
+ i.set(Q(Z), Z);
1431
+ x.value = i;
1432
+ }
1433
+ function xe(s) {
1434
+ X.value = s.onConfirm, oe.value = s.onCancel, Ye(s.selected ?? t.selected);
1435
+ }
1436
+ function We(s) {
1437
+ if (l.value) return;
1438
+ const i = s.detail ?? {};
1439
+ xe(i), g.value = !0;
1440
+ }
1441
+ Ue(() => {
1442
+ globalThis.addEventListener(Ve, We), l.value || (g.value = G.visible);
1443
+ }), Re(() => {
1444
+ globalThis.removeEventListener(Ve, We);
1445
+ });
1446
+ async function be() {
1447
+ var s;
1448
+ if (!t.getImages) {
1449
+ ee.error("请通过 props.getImages 传入图片列表请求方法");
1450
+ return;
1451
+ }
1452
+ v.value = !0;
1453
+ try {
1454
+ const i = await t.getImages({
1455
+ keyword: z.value.trim() || void 0,
1456
+ category: C.value || void 0,
1457
+ page: U.value,
1458
+ pageSize: t.pageSize
1459
+ });
1460
+ W.value = i.list, Y.value = i.total;
1461
+ for (const b of i.list)
1462
+ pe(b);
1463
+ !R.value && ((s = i.categories) != null && s.length) && (H.value = i.categories);
1464
+ } catch (i) {
1465
+ ee.error(i instanceof Error ? i.message : "加载图片失败");
1466
+ } finally {
1467
+ v.value = !1;
1468
+ }
1469
+ }
1470
+ function we() {
1471
+ U.value = 1, be();
1472
+ }
1473
+ function je(s) {
1474
+ C.value !== s && (C.value = s, we());
1475
+ }
1476
+ function Ge(s) {
1477
+ const i = Q(s);
1478
+ if ($.value) {
1479
+ if (x.value.has(i)) {
1480
+ x.value.delete(i), x.value = new Map(x.value);
1481
+ return;
1482
+ }
1483
+ if (F.value.length >= m.value) {
1484
+ ee.warning(`最多选择 ${m.value} 张图片`);
1485
+ return;
1486
+ }
1487
+ x.value.set(i, s), x.value = new Map(x.value);
1488
+ return;
1489
+ }
1490
+ if (x.value.has(i)) {
1491
+ if (L.value) {
1492
+ Je(() => Te());
1493
+ return;
1494
+ }
1495
+ x.value = /* @__PURE__ */ new Map();
1496
+ return;
1497
+ }
1498
+ x.value = /* @__PURE__ */ new Map([[i, s]]), L.value && Je(() => Te());
1499
+ }
1500
+ async function yt(s) {
1501
+ if (!t.upload) {
1502
+ ee.error("请通过 props.upload 传入图片上传方法");
1503
+ return;
1504
+ }
1505
+ T.value = !0;
1506
+ try {
1507
+ const { resource: i } = await t.upload(s.file);
1508
+ if (ee.success("上传成功"), $.value)
1509
+ F.value.length < m.value && (x.value.set(Q(i), i), x.value = new Map(x.value));
1510
+ else if (x.value = /* @__PURE__ */ new Map([[Q(i), i]]), L.value) {
1511
+ Te();
1512
+ return;
1513
+ }
1514
+ we();
1515
+ } catch (i) {
1516
+ ee.error(i instanceof Error ? i.message : "上传失败");
1517
+ } finally {
1518
+ T.value = !1;
1519
+ }
1520
+ }
1521
+ function wt() {
1522
+ z.value = "", C.value = "", U.value = 1, J.value = /* @__PURE__ */ new Map(), ye(), l.value ? xe({}) : xe(G.options), ye(), be();
1523
+ }
1524
+ function Tt() {
1525
+ T.value = !1;
1526
+ }
1527
+ function qe() {
1528
+ var s, i, b;
1529
+ (s = oe.value) == null || s.call(oe), l.value || (b = (i = G.options).onCancel) == null || b.call(i), o("cancel"), g.value = !1;
1530
+ }
1531
+ function Te() {
1532
+ var i, b, Z;
1533
+ if (!F.value.length) {
1534
+ ee.warning("请选择图片");
1535
+ return;
1536
+ }
1537
+ const s = [...F.value];
1538
+ if (l.value) {
1539
+ o("confirm", s), g.value = !1;
1540
+ return;
1541
+ }
1542
+ (i = X.value) == null || i.call(X, s), (Z = (b = G.options).onConfirm) == null || Z.call(b, s), o("confirm", s), g.value = !1;
1543
+ }
1544
+ return ne(
1545
+ () => t.selected,
1546
+ (s) => {
1547
+ g.value || Ye(s);
1548
+ },
1549
+ { deep: !0 }
1550
+ ), (s, i) => {
1551
+ const b = V("el-icon"), Z = V("el-input"), It = V("el-segmented"), me = V("el-button"), Ct = V("el-upload"), St = V("el-empty"), kt = V("el-pagination"), xt = V("el-dialog"), bt = et("loading");
1552
+ return c(), E(xt, {
1553
+ modelValue: g.value,
1554
+ "onUpdate:modelValue": i[4] || (i[4] = (I) => g.value = I),
1555
+ title: w.value,
1556
+ width: e.width,
1557
+ "append-to-body": "",
1558
+ "destroy-on-close": "",
1559
+ class: "yc-image-selector-dialog",
1560
+ onClosed: Tt,
1561
+ onOpen: wt
1562
+ }, {
1563
+ footer: p(() => [
1564
+ L.value ? (c(), A("div", Io, [
1565
+ _("span", Co, B(se.value), 1),
1566
+ f(me, {
1567
+ link: "",
1568
+ type: "primary",
1569
+ onClick: qe
1570
+ }, {
1571
+ default: p(() => [
1572
+ q(B(e.cancelText), 1)
1573
+ ]),
1574
+ _: 1
1575
+ })
1576
+ ])) : (c(), A("div", yo, [
1577
+ _("span", wo, B(se.value), 1),
1578
+ _("div", To, [
1579
+ f(me, { onClick: qe }, {
1580
+ default: p(() => [
1581
+ q(B(e.cancelText), 1)
1582
+ ]),
1583
+ _: 1
1584
+ }),
1585
+ f(me, {
1586
+ type: "primary",
1587
+ disabled: !F.value.length,
1588
+ onClick: Te
1589
+ }, {
1590
+ default: p(() => [
1591
+ q(B(e.confirmText), 1)
1592
+ ]),
1593
+ _: 1
1594
+ }, 8, ["disabled"])
1595
+ ])
1596
+ ]))
1597
+ ]),
1598
+ default: p(() => [
1599
+ _("div", Zn, [
1600
+ _("div", eo, [
1601
+ f(Z, {
1602
+ modelValue: z.value,
1603
+ "onUpdate:modelValue": i[0] || (i[0] = (I) => z.value = I),
1604
+ clearable: "",
1605
+ placeholder: "搜索图片名称",
1606
+ class: "yc-image-selector__search",
1607
+ onKeyup: $t(we, ["enter"]),
1608
+ onClear: we
1609
+ }, {
1610
+ prefix: p(() => [
1611
+ f(b, null, {
1612
+ default: p(() => [
1613
+ f(h(Nt))
1614
+ ]),
1615
+ _: 1
1616
+ })
1617
+ ]),
1618
+ _: 1
1619
+ }, 8, ["modelValue"]),
1620
+ r.value ? (c(), E(It, {
1621
+ key: 0,
1622
+ modelValue: N.value,
1623
+ "onUpdate:modelValue": i[1] || (i[1] = (I) => N.value = I),
1624
+ options: y,
1625
+ class: "yc-image-selector__mode",
1626
+ onChange: fe
1627
+ }, null, 8, ["modelValue"])) : P("", !0),
1628
+ e.showUpload && e.upload ? (c(), E(Ct, {
1629
+ key: 1,
1630
+ "show-file-list": !1,
1631
+ accept: e.accept,
1632
+ "http-request": yt,
1633
+ disabled: T.value
1634
+ }, {
1635
+ default: p(() => [
1636
+ f(me, {
1637
+ type: "primary",
1638
+ plain: "",
1639
+ loading: T.value
1640
+ }, {
1641
+ default: p(() => [
1642
+ f(b, { class: "m-r-4" }, {
1643
+ default: p(() => [
1644
+ f(h(zt))
1645
+ ]),
1646
+ _: 1
1647
+ }),
1648
+ i[5] || (i[5] = q(" 上传图片 ", -1))
1649
+ ]),
1650
+ _: 1
1651
+ }, 8, ["loading"])
1652
+ ]),
1653
+ _: 1
1654
+ }, 8, ["accept", "disabled"])) : P("", !0)
1655
+ ]),
1656
+ _("div", to, [
1657
+ O.value && M.value.length ? (c(), A("aside", no, [
1658
+ _("div", {
1659
+ class: ue(["yc-image-selector__category", { "is-active": C.value === "" }]),
1660
+ onClick: i[2] || (i[2] = (I) => je(""))
1661
+ }, B(e.categoryAllLabel), 3),
1662
+ (c(!0), A(le, null, ve(M.value, (I) => (c(), A("div", {
1663
+ key: I.id,
1664
+ class: ue(["yc-image-selector__category", { "is-active": C.value === I.id }]),
1665
+ onClick: (Ie) => je(I.id)
1666
+ }, [
1667
+ _("span", null, B(I.name), 1),
1668
+ I.count != null ? (c(), A("span", ao, B(I.count), 1)) : P("", !0)
1669
+ ], 10, oo))), 128))
1670
+ ])) : P("", !0),
1671
+ _e((c(), A("div", lo, [
1672
+ !v.value && !W.value.length ? (c(), E(St, {
1673
+ key: 0,
1674
+ description: e.emptyText
1675
+ }, null, 8, ["description"])) : (c(), A("div", io, [
1676
+ (c(!0), A(le, null, ve(W.value, (I) => (c(), A("div", {
1677
+ key: String(I.id),
1678
+ class: ue(["yc-image-selector__item", {
1679
+ "is-selected": a(I),
1680
+ "is-single-mode": !$.value,
1681
+ "is-multi-mode": $.value
1682
+ }]),
1683
+ onClick: (Ie) => Ge(I)
1684
+ }, [
1685
+ _("div", ro, [
1686
+ _("img", {
1687
+ src: I.url,
1688
+ alt: I.name || "image",
1689
+ loading: "lazy",
1690
+ class: ue(K(I)),
1691
+ onLoad: (Ie) => re(Ie, I)
1692
+ }, null, 42, uo),
1693
+ _("div", {
1694
+ class: ue(["yc-image-selector__indicator", {
1695
+ "is-checked": a(I),
1696
+ "is-radio": !$.value,
1697
+ "is-checkbox": $.value
1698
+ }])
1699
+ }, [
1700
+ a(I) && $.value ? (c(), A("span", co, B(j(I)), 1)) : a(I) ? (c(), E(b, { key: 1 }, {
1701
+ default: p(() => [
1702
+ f(h(lt))
1703
+ ]),
1704
+ _: 1
1705
+ })) : P("", !0)
1706
+ ], 2)
1707
+ ]),
1708
+ _("div", {
1709
+ class: "yc-image-selector__meta",
1710
+ title: I.name
1711
+ }, B(I.name || "未命名"), 9, fo)
1712
+ ], 10, so))), 128))
1713
+ ]))
1714
+ ])), [
1715
+ [bt, v.value]
1716
+ ])
1717
+ ]),
1718
+ $.value && F.value.length ? (c(), A("div", po, [
1719
+ _("span", mo, "已选 " + B(F.value.length) + " 张", 1),
1720
+ _("div", go, [
1721
+ (c(!0), A(le, null, ve(F.value, (I) => (c(), A("div", {
1722
+ key: String(I.id),
1723
+ class: "yc-image-selector__selected-chip",
1724
+ onClick: Pt((Ie) => Ge(I), ["stop"])
1725
+ }, [
1726
+ _("img", {
1727
+ src: I.url,
1728
+ alt: I.name
1729
+ }, null, 8, _o),
1730
+ i[6] || (i[6] = _("span", { class: "yc-image-selector__selected-chip-remove" }, "×", -1))
1731
+ ], 8, vo))), 128))
1732
+ ]),
1733
+ f(me, {
1734
+ link: "",
1735
+ type: "primary",
1736
+ onClick: ke
1737
+ }, {
1738
+ default: p(() => [...i[7] || (i[7] = [
1739
+ q("清空", -1)
1740
+ ])]),
1741
+ _: 1
1742
+ })
1743
+ ])) : P("", !0),
1744
+ Y.value > 0 ? (c(), A("div", ho, [
1745
+ f(kt, {
1746
+ "current-page": U.value,
1747
+ "onUpdate:currentPage": i[3] || (i[3] = (I) => U.value = I),
1748
+ background: "",
1749
+ layout: "total, prev, pager, next, jumper",
1750
+ "page-size": e.pageSize,
1751
+ total: Y.value,
1752
+ onCurrentChange: be
1753
+ }, null, 8, ["current-page", "page-size", "total"])
1754
+ ])) : P("", !0)
1755
+ ])
1756
+ ]),
1757
+ _: 1
1758
+ }, 8, ["modelValue", "title", "width"]);
1759
+ };
1760
+ }
1761
+ }), ko = /* @__PURE__ */ Se(So, [["__scopeId", "data-v-f75b2f69"]]);
1762
+ function vt() {
1763
+ const e = k(!1), n = k({});
1764
+ function t(l = {}) {
1765
+ n.value = { ...l }, e.value = !0;
1766
+ }
1767
+ function o() {
1768
+ e.value = !1;
1769
+ }
1770
+ return {
1771
+ dialogVisible: e,
1772
+ dialogOptions: n,
1773
+ openImageSelector: t,
1774
+ closeImageSelector: o
1775
+ };
1776
+ }
1777
+ const xo = "__YC_IMAGE_SELECTOR_CTX_KEY__";
1778
+ function bo(e) {
1779
+ const n = globalThis;
1780
+ return n[e] || (n[e] = Symbol(e)), n[e];
1781
+ }
1782
+ const _t = bo(xo), Oo = /* @__PURE__ */ ce({
1783
+ __name: "YcImageSelectorProvider",
1784
+ props: {
1785
+ modelValue: { type: Boolean },
1786
+ title: { default: "选择图片" },
1787
+ multiple: { type: Boolean, default: !1 },
1788
+ maxCount: { default: 9 },
1789
+ selected: {},
1790
+ width: { default: "860px" },
1791
+ pageSize: { default: 8 },
1792
+ showUpload: { type: Boolean, default: !0 },
1793
+ accept: { default: "image/*" },
1794
+ showCategories: { type: Boolean, default: !1 },
1795
+ categories: {},
1796
+ categoryAllLabel: { default: "全部" },
1797
+ showModeSwitch: { type: Boolean, default: !1 },
1798
+ confirmOnSelect: { type: Boolean, default: !1 },
1799
+ confirmText: { default: "确定" },
1800
+ cancelText: { default: "取消" },
1801
+ emptyText: { default: "暂无图片资源" },
1802
+ getImages: {},
1803
+ upload: {},
1804
+ showDialog: { type: Boolean, default: !0 }
1805
+ },
1806
+ setup(e, { expose: n }) {
1807
+ const t = e, o = vt(), { dialogVisible: l, dialogOptions: g, openImageSelector: w, closeImageSelector: S } = o;
1808
+ $e(_t, o);
1809
+ function m(M, L) {
1810
+ return M in g.value ? g.value[M] : L;
1811
+ }
1812
+ const r = D(() => ({
1813
+ title: m("title", t.title),
1814
+ multiple: m("multiple", t.multiple),
1815
+ maxCount: m("maxCount", t.maxCount),
1816
+ selected: m("selected", t.selected),
1817
+ width: t.width,
1818
+ pageSize: t.pageSize,
1819
+ showUpload: t.showUpload,
1820
+ accept: t.accept,
1821
+ showCategories: m("showCategories", t.showCategories),
1822
+ categories: m("categories", t.categories),
1823
+ categoryAllLabel: m("categoryAllLabel", t.categoryAllLabel),
1824
+ showModeSwitch: m("showModeSwitch", t.showModeSwitch),
1825
+ confirmOnSelect: m("confirmOnSelect", t.confirmOnSelect),
1826
+ confirmText: t.confirmText,
1827
+ cancelText: t.cancelText,
1828
+ emptyText: t.emptyText,
1829
+ getImages: t.getImages,
1830
+ upload: t.upload
1831
+ }));
1832
+ function O(M) {
1833
+ var L, N;
1834
+ (N = (L = g.value).onConfirm) == null || N.call(L, M), S();
1835
+ }
1836
+ function R() {
1837
+ var M, L;
1838
+ (L = (M = g.value).onCancel) == null || L.call(M), S();
1839
+ }
1840
+ return n({ openImageSelector: w, closeImageSelector: S }), (M, L) => (c(), A(le, null, [
1841
+ e.showDialog !== !1 ? (c(), E(ko, ot({
1842
+ key: 0,
1843
+ modelValue: h(l),
1844
+ "onUpdate:modelValue": L[0] || (L[0] = (N) => Lt(l) ? l.value = N : null)
1845
+ }, r.value, {
1846
+ onConfirm: O,
1847
+ onCancel: R
1848
+ }), null, 16, ["modelValue"])) : P("", !0),
1849
+ Ce(M.$slots, "default")
1850
+ ], 64));
1851
+ }
1852
+ });
1853
+ function Uo() {
1854
+ const e = Oe(_t, null);
1855
+ if (e)
1856
+ return {
1857
+ openImageSelector: (t = {}) => e.openImageSelector(t),
1858
+ closeImageSelector: () => e.closeImageSelector()
1859
+ };
1860
+ const n = vt();
1861
+ return {
1862
+ openImageSelector: (t = {}) => {
1863
+ Qn(t), n.openImageSelector(t);
1864
+ },
1865
+ closeImageSelector: () => n.closeImageSelector()
1866
+ };
1867
+ }
1868
+ function ht() {
1869
+ const { baseURL: e = "" } = Ke();
1870
+ return Ze.create({ baseURL: e, timeout: 3e4 });
1871
+ }
1872
+ async function Ro(e) {
1873
+ const n = Ke().fetchImages;
1874
+ if (n) return n(e);
1875
+ const t = ht(), { data: o } = await t.get(
1876
+ "/yc-media/images",
1877
+ { params: e }
1878
+ );
1879
+ if (o.code !== 200)
1880
+ throw new Error("加载图片资源失败");
1881
+ return o.data;
1882
+ }
1883
+ async function Fo(e) {
1884
+ const n = Ke().uploadImage;
1885
+ if (n) return n(e);
1886
+ const t = ht(), o = new FormData();
1887
+ o.append("file", e);
1888
+ const { data: l } = await t.post(
1889
+ "/yc-media/images/upload",
1890
+ o,
1891
+ { headers: { "Content-Type": "multipart/form-data" } }
1892
+ );
1893
+ if (l.code !== 200)
1894
+ throw new Error("上传图片失败");
1895
+ return l.data;
1896
+ }
1897
+ export {
1898
+ qn as AiTaskPanel,
1899
+ Bo as AiTaskProvider,
1900
+ Mn as AiUseDialog,
1901
+ _t as IMAGE_SELECTOR_INJECT_KEY,
1902
+ ko as ImageSelectorDialog,
1903
+ Oo as ImageSelectorProvider,
1904
+ Qe as SkyPageWindow,
1905
+ qn as YcAiTaskPanel,
1906
+ Bo as YcAiTaskProvider,
1907
+ Mn as YcAiUseDialog,
1908
+ Lo as YcComponent,
1909
+ ko as YcImageSelectorDialog,
1910
+ Oo as YcImageSelectorProvider,
1911
+ Qe as YcPageWindow,
1912
+ vt as createImageSelectorApi,
1913
+ Lo as default,
1914
+ Ro as fetchImages,
1915
+ it as getAiTaskConfig,
1916
+ Ke as getImageSelectorConfig,
1917
+ rt as hideAiDialog,
1918
+ Xn as hideImageSelectorDialog,
1919
+ on as installYcComponent,
1920
+ kn as listPrompts,
1921
+ Do as openAiUseDialog,
1922
+ Qn as openImageSelector,
1923
+ jt as setAiTaskConfig,
1924
+ Jt as setImageSelectorConfig,
1925
+ Ne as showAiDialog,
1926
+ Jn as showImageSelectorDialog,
1927
+ Fo as uploadImage,
1928
+ Vo as useAiTask,
1929
+ gt as useAiTaskStore,
1930
+ Uo as useImageSelector
1931
+ };