luo-image-annotator 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,59 +1,59 @@
1
1
  var Jt = Object.defineProperty;
2
- var jt = (v, t, i) => t in v ? Jt(v, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : v[t] = i;
3
- var k = (v, t, i) => jt(v, typeof t != "symbol" ? t + "" : t, i);
4
- import { defineComponent as K, ref as S, watchEffect as Yt, openBlock as f, createElementBlock as p, normalizeClass as V, computed as U, onMounted as Xt, watch as Y, createElementVNode as g, toDisplayString as T, Fragment as R, renderList as F, normalizeStyle as O, createCommentVNode as $, createVNode as H, withModifiers as qt, createTextVNode as X, withDirectives as lt, vModelText as rt, createBlock as ft, nextTick as Gt } from "vue";
5
- const ct = (v, t) => Math.sqrt(Math.pow(v.x - t.x, 2) + Math.pow(v.y - t.y, 2)), Kt = (v, t) => {
2
+ var jt = (f, t, i) => t in f ? Jt(f, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : f[t] = i;
3
+ var S = (f, t, i) => jt(f, typeof t != "symbol" ? t + "" : t, i);
4
+ import { defineComponent as tt, ref as M, watchEffect as Yt, openBlock as y, createElementBlock as x, normalizeClass as J, computed as D, onMounted as Xt, watch as Y, createElementVNode as g, toDisplayString as P, Fragment as B, renderList as F, normalizeStyle as V, createCommentVNode as T, createVNode as L, withModifiers as qt, createTextVNode as K, withDirectives as lt, vModelText as rt, createBlock as yt, nextTick as Gt } from "vue";
5
+ const ct = (f, t) => Math.sqrt(Math.pow(f.x - t.x, 2) + Math.pow(f.y - t.y, 2)), Kt = (f, t) => {
6
6
  let i = !1;
7
- for (let e = 0, a = t.length - 1; e < t.length; a = e++) {
8
- const r = t[e].x, c = t[e].y, o = t[a].x, h = t[a].y;
9
- c > v.y != h > v.y && v.x < (o - r) * (v.y - c) / (h - c) + r && (i = !i);
7
+ for (let e = 0, o = t.length - 1; e < t.length; o = e++) {
8
+ const c = t[e].x, r = t[e].y, a = t[o].x, d = t[o].y;
9
+ r > f.y != d > f.y && f.x < (a - c) * (f.y - r) / (d - r) + c && (i = !i);
10
10
  }
11
11
  return i;
12
- }, yt = (v, t, i) => {
13
- const e = i * (Math.PI / 180), a = Math.cos(e), r = Math.sin(e), c = v.x - t.x, o = v.y - t.y;
12
+ }, pt = (f, t, i) => {
13
+ const e = i * (Math.PI / 180), o = Math.cos(e), c = Math.sin(e), r = f.x - t.x, a = f.y - t.y;
14
14
  return {
15
- x: t.x + (c * a - o * r),
16
- y: t.y + (c * r + o * a)
15
+ x: t.x + (r * o - a * c),
16
+ y: t.y + (r * c + a * o)
17
17
  };
18
18
  };
19
19
  class Zt {
20
20
  constructor(t) {
21
- k(this, "canvas");
22
- k(this, "ctx");
23
- k(this, "img");
24
- k(this, "annotations", []);
21
+ S(this, "canvas");
22
+ S(this, "ctx");
23
+ S(this, "img");
24
+ S(this, "annotations", []);
25
25
  // 状态
26
- k(this, "currentTool", null);
27
- k(this, "interactionMode", "none");
28
- k(this, "activeAnnotation", null);
29
- k(this, "hoverAnnotation", null);
30
- k(this, "isDrawing", !1);
31
- k(this, "isDragging", !1);
32
- k(this, "isPanning", !1);
26
+ S(this, "currentTool", null);
27
+ S(this, "interactionMode", "none");
28
+ S(this, "activeAnnotation", null);
29
+ S(this, "hoverAnnotation", null);
30
+ S(this, "isDrawing", !1);
31
+ S(this, "isDragging", !1);
32
+ S(this, "isPanning", !1);
33
33
  // 平移模式
34
- k(this, "panStartPoint", null);
34
+ S(this, "panStartPoint", null);
35
35
  // 平移起点
36
- k(this, "dragStartPoint", null);
37
- k(this, "dragStartAnnotation", null);
36
+ S(this, "dragStartPoint", null);
37
+ S(this, "dragStartAnnotation", null);
38
38
  // 快照用于撤销/diff
39
- k(this, "lastMouseMovePoint", null);
39
+ S(this, "lastMouseMovePoint", null);
40
40
  // 用于绘制辅助线
41
- k(this, "isHoveringStartPoint", !1);
41
+ S(this, "isHoveringStartPoint", !1);
42
42
  // 多边形闭合吸附状态
43
43
  // 设置
44
- k(this, "currentLabelColor", "#FF4081");
44
+ S(this, "currentLabelColor", "#FF4081");
45
45
  // 当前选中标签颜色
46
- k(this, "visibleLabels", /* @__PURE__ */ new Set());
46
+ S(this, "visibleLabels", /* @__PURE__ */ new Set());
47
47
  // 可见标签集合 (如果为空则全部可见,或者由外部控制渲染列表)
48
48
  // 交互
49
- k(this, "selectedHandleIndex", -1);
49
+ S(this, "selectedHandleIndex", -1);
50
50
  // -1: 主体, >=0: 顶点索引, -2: 旋转手柄
51
- k(this, "hoverHandleIndex", -1);
51
+ S(this, "hoverHandleIndex", -1);
52
52
  // 视口
53
- k(this, "scale", 1);
54
- k(this, "offset", { x: 0, y: 0 });
55
- k(this, "listeners", {});
56
- k(this, "imageUrl", "");
53
+ S(this, "scale", 1);
54
+ S(this, "offset", { x: 0, y: 0 });
55
+ S(this, "listeners", {});
56
+ S(this, "imageUrl", "");
57
57
  this.canvas = t;
58
58
  const i = t.getContext("2d");
59
59
  if (!i) throw new Error("Could not get 2d context");
@@ -89,8 +89,8 @@ class Zt {
89
89
  zoom(t) {
90
90
  const e = t > 0 ? this.scale * 1.1 : this.scale / 1.1;
91
91
  if (e < 0.1 || e > 10) return;
92
- const a = this.canvas.width / 2, r = this.canvas.height / 2, c = this.toImageCoords(a, r);
93
- this.scale = e, this.offset.x = a - c.x * this.scale, this.offset.y = r - c.y * this.scale, this.clampViewportOffset(), this.render();
92
+ const o = this.canvas.width / 2, c = this.canvas.height / 2, r = this.toImageCoords(o, c);
93
+ this.scale = e, this.offset.x = o - r.x * this.scale, this.offset.y = c - r.y * this.scale, this.clampViewportOffset(), this.render();
94
94
  }
95
95
  resize() {
96
96
  this.fitImageToCanvas(), this.render();
@@ -122,14 +122,14 @@ class Zt {
122
122
  if (t <= this.canvas.width)
123
123
  this.offset.x = (this.canvas.width - t) / 2;
124
124
  else {
125
- const e = this.canvas.width - t, a = 0;
126
- this.offset.x = Math.min(a, Math.max(e, this.offset.x));
125
+ const e = this.canvas.width - t, o = 0;
126
+ this.offset.x = Math.min(o, Math.max(e, this.offset.x));
127
127
  }
128
128
  if (i <= this.canvas.height)
129
129
  this.offset.y = (this.canvas.height - i) / 2;
130
130
  else {
131
- const e = this.canvas.height - i, a = 0;
132
- this.offset.y = Math.min(a, Math.max(e, this.offset.y));
131
+ const e = this.canvas.height - i, o = 0;
132
+ this.offset.y = Math.min(o, Math.max(e, this.offset.y));
133
133
  }
134
134
  }
135
135
  // --- 事件处理 ---
@@ -151,28 +151,28 @@ class Zt {
151
151
  }
152
152
  }
153
153
  handleMouseDown(t) {
154
- const i = this.canvas.getBoundingClientRect(), e = t.clientX - i.left, a = t.clientY - i.top, r = this.toImageCoords(e, a);
154
+ const i = this.canvas.getBoundingClientRect(), e = t.clientX - i.left, o = t.clientY - i.top, c = this.toImageCoords(e, o);
155
155
  if (this.canvas.style.cursor === "grab" || this.canvas.style.cursor === "grabbing") {
156
- this.isPanning = !0, this.panStartPoint = { x: e, y: a }, this.canvas.style.cursor = "grabbing";
156
+ this.isPanning = !0, this.panStartPoint = { x: e, y: o }, this.canvas.style.cursor = "grabbing";
157
157
  return;
158
158
  }
159
159
  if (this.interactionMode === "select" && this.activeAnnotation) {
160
- const h = this.getHitHandle(e, a, this.activeAnnotation);
161
- if (h !== -100) {
162
- this.isDragging = !0, this.dragStartPoint = r, this.selectedHandleIndex = h, this.dragStartAnnotation = JSON.parse(JSON.stringify(this.activeAnnotation));
160
+ const d = this.getHitHandle(e, o, this.activeAnnotation);
161
+ if (d !== -100) {
162
+ this.isDragging = !0, this.dragStartPoint = c, this.selectedHandleIndex = d, this.dragStartAnnotation = JSON.parse(JSON.stringify(this.activeAnnotation));
163
163
  return;
164
164
  }
165
165
  }
166
- const c = this.interactionMode === "select" ? this.getHitCategory(e, a) : null;
167
- if (c) {
168
- this.activeAnnotation = c, this.isDragging = !1, this.selectedHandleIndex = -1, this.emit("annotationChange", { action: "select", changedItem: c, imageUrl: this.imageUrl }), this.render();
166
+ const r = this.interactionMode === "select" ? this.getHitCategory(e, o) : null;
167
+ if (r) {
168
+ this.activeAnnotation = r, this.isDragging = !1, this.selectedHandleIndex = -1, this.emit("annotationChange", { action: "select", changedItem: r, imageUrl: this.imageUrl }), this.render();
169
169
  return;
170
170
  }
171
- const o = this.getHitAnnotation(r);
171
+ const a = this.getHitAnnotation(c);
172
172
  if (this.interactionMode === "select") {
173
- if (o) {
174
- if (!(this.visibleLabels.size > 0 && !this.visibleLabels.has(o.label))) {
175
- this.activeAnnotation = o, this.isDragging = !0, this.dragStartPoint = r, this.selectedHandleIndex = -1, this.dragStartAnnotation = JSON.parse(JSON.stringify(o)), this.emit("annotationChange", { action: "select", changedItem: o, imageUrl: this.imageUrl }), this.render();
173
+ if (a) {
174
+ if (!(this.visibleLabels.size > 0 && !this.visibleLabels.has(a.label))) {
175
+ this.activeAnnotation = a, this.isDragging = !0, this.dragStartPoint = c, this.selectedHandleIndex = -1, this.dragStartAnnotation = JSON.parse(JSON.stringify(a)), this.emit("annotationChange", { action: "select", changedItem: a, imageUrl: this.imageUrl }), this.render();
176
176
  return;
177
177
  }
178
178
  } else
@@ -181,43 +181,43 @@ class Zt {
181
181
  }
182
182
  if (this.interactionMode === "draw") {
183
183
  if (this.isDrawing && this.currentTool === "polygon" && this.activeAnnotation) {
184
- const h = this.activeAnnotation.coordinates;
185
- if (h.points.length > 2 && ct(r, h.points[0]) < 20 / this.scale) {
184
+ const d = this.activeAnnotation.coordinates;
185
+ if (d.points.length > 2 && ct(c, d.points[0]) < 20 / this.scale) {
186
186
  this.finishDrawing();
187
187
  return;
188
188
  }
189
- this.startDrawing(r);
189
+ this.startDrawing(c);
190
190
  return;
191
191
  }
192
192
  if (this.currentTool) {
193
193
  if (this.currentTool === "polygon" && !this.isDrawing) {
194
- this.startDrawing(r);
194
+ this.startDrawing(c);
195
195
  return;
196
196
  }
197
- this.startDrawing(r);
197
+ this.startDrawing(c);
198
198
  }
199
199
  return;
200
200
  }
201
201
  this.activeAnnotation = null, this.render();
202
202
  }
203
203
  handleMouseMove(t) {
204
- const i = this.canvas.getBoundingClientRect(), e = t.clientX - i.left, a = t.clientY - i.top, r = this.toImageCoords(e, a);
204
+ const i = this.canvas.getBoundingClientRect(), e = t.clientX - i.left, o = t.clientY - i.top, c = this.toImageCoords(e, o);
205
205
  if (this.isPanning && this.panStartPoint) {
206
- const c = e - this.panStartPoint.x, o = a - this.panStartPoint.y;
207
- this.offset.x += c, this.offset.y += o, this.clampViewportOffset(), this.panStartPoint = { x: e, y: a }, this.render();
206
+ const r = e - this.panStartPoint.x, a = o - this.panStartPoint.y;
207
+ this.offset.x += r, this.offset.y += a, this.clampViewportOffset(), this.panStartPoint = { x: e, y: o }, this.render();
208
208
  return;
209
209
  }
210
- if (this.lastMouseMovePoint = r, this.isDrawing) {
210
+ if (this.lastMouseMovePoint = c, this.isDrawing) {
211
211
  if (this.currentTool === "polygon" && this.activeAnnotation) {
212
- const c = this.activeAnnotation.coordinates;
213
- if (c.points.length > 2) {
214
- const o = c.points[0], h = ct(r, o);
215
- this.isHoveringStartPoint = h < 20 / this.scale;
212
+ const r = this.activeAnnotation.coordinates;
213
+ if (r.points.length > 2) {
214
+ const a = r.points[0], d = ct(c, a);
215
+ this.isHoveringStartPoint = d < 20 / this.scale;
216
216
  } else
217
217
  this.isHoveringStartPoint = !1;
218
218
  }
219
- this.updateDrawing(r);
220
- } else this.isDragging && this.activeAnnotation && this.dragStartPoint ? this.updateDragging(r) : this.checkHover(e, a, r);
219
+ this.updateDrawing(c);
220
+ } else this.isDragging && this.activeAnnotation && this.dragStartPoint ? this.updateDragging(c) : this.checkHover(e, o, c);
221
221
  this.render();
222
222
  }
223
223
  handleMouseUp(t) {
@@ -242,8 +242,8 @@ class Zt {
242
242
  // 辅助函数:将 hex 转换为 rgba
243
243
  hexToRgba(t, i) {
244
244
  if (!t.startsWith("#")) return t;
245
- const e = parseInt(t.slice(1, 3), 16), a = parseInt(t.slice(3, 5), 16), r = parseInt(t.slice(5, 7), 16);
246
- return `rgba(${e}, ${a}, ${r}, ${i})`;
245
+ const e = parseInt(t.slice(1, 3), 16), o = parseInt(t.slice(3, 5), 16), c = parseInt(t.slice(5, 7), 16);
246
+ return `rgba(${e}, ${o}, ${c}, ${i})`;
247
247
  }
248
248
  startDrawing(t) {
249
249
  if (!this.currentTool) return;
@@ -299,8 +299,8 @@ class Zt {
299
299
  const i = this.activeAnnotation.coordinates;
300
300
  i.x2 = t.x, i.y2 = t.y;
301
301
  } else if (this.activeAnnotation.type === "rotatedRect" && this.dragStartPoint) {
302
- const i = this.activeAnnotation.coordinates, e = Math.abs(t.x - this.dragStartPoint.x), a = Math.abs(t.y - this.dragStartPoint.y);
303
- i.width = e * 2, i.height = a * 2;
302
+ const i = this.activeAnnotation.coordinates, e = Math.abs(t.x - this.dragStartPoint.x), o = Math.abs(t.y - this.dragStartPoint.y);
303
+ i.width = e * 2, i.height = o * 2;
304
304
  } else this.activeAnnotation.type;
305
305
  }
306
306
  finishDrawing() {
@@ -311,8 +311,8 @@ class Zt {
311
311
  this.activeAnnotation = null, this.isDrawing = !1;
312
312
  return;
313
313
  }
314
- const i = Math.min(t.x1, t.x2), e = Math.max(t.x1, t.x2), a = Math.min(t.y1, t.y2), r = Math.max(t.y1, t.y2);
315
- t.x1 = i, t.x2 = e, t.y1 = a, t.y2 = r, this.annotations.push(this.activeAnnotation), this.emit("annotationChange", { action: "add", changedItem: this.activeAnnotation, imageUrl: this.imageUrl });
314
+ const i = Math.min(t.x1, t.x2), e = Math.max(t.x1, t.x2), o = Math.min(t.y1, t.y2), c = Math.max(t.y1, t.y2);
315
+ t.x1 = i, t.x2 = e, t.y1 = o, t.y2 = c, this.annotations.push(this.activeAnnotation), this.emit("annotationChange", { action: "add", changedItem: this.activeAnnotation, imageUrl: this.imageUrl });
316
316
  } else if (this.activeAnnotation.type === "polygon") {
317
317
  if (this.activeAnnotation.coordinates.points.length < 3) {
318
318
  this.activeAnnotation = null, this.isDrawing = !1;
@@ -336,40 +336,40 @@ class Zt {
336
336
  const i = t.x - this.dragStartPoint.x, e = t.y - this.dragStartPoint.y;
337
337
  this.selectedHandleIndex === -1 ? this.moveAnnotation(this.activeAnnotation, this.dragStartAnnotation, i, e) : this.resizeAnnotation(this.activeAnnotation, this.dragStartAnnotation, this.selectedHandleIndex, t);
338
338
  }
339
- moveAnnotation(t, i, e, a) {
339
+ moveAnnotation(t, i, e, o) {
340
340
  if (t.type === "rectangle") {
341
- const r = i.coordinates, c = t.coordinates;
342
- c.x1 = r.x1 + e, c.x2 = r.x2 + e, c.y1 = r.y1 + a, c.y2 = r.y2 + a;
341
+ const c = i.coordinates, r = t.coordinates;
342
+ r.x1 = c.x1 + e, r.x2 = c.x2 + e, r.y1 = c.y1 + o, r.y2 = c.y2 + o;
343
343
  } else if (t.type === "point") {
344
- const r = i.coordinates, c = t.coordinates;
345
- c.points = r.points.map((o) => ({ x: o.x + e, y: o.y + a }));
344
+ const c = i.coordinates, r = t.coordinates;
345
+ r.points = c.points.map((a) => ({ x: a.x + e, y: a.y + o }));
346
346
  } else if (t.type === "rotatedRect") {
347
- const r = i.coordinates, c = t.coordinates;
348
- c.x = r.x + e, c.y = r.y + a;
347
+ const c = i.coordinates, r = t.coordinates;
348
+ r.x = c.x + e, r.y = c.y + o;
349
349
  } else if (t.type === "polygon") {
350
- const r = i.coordinates, c = t.coordinates;
351
- c.points = r.points.map((o) => ({ x: o.x + e, y: o.y + a }));
350
+ const c = i.coordinates, r = t.coordinates;
351
+ r.points = c.points.map((a) => ({ x: a.x + e, y: a.y + o }));
352
352
  }
353
353
  }
354
- resizeAnnotation(t, i, e, a) {
354
+ resizeAnnotation(t, i, e, o) {
355
355
  if (t.type === "rectangle") {
356
- const r = t.coordinates;
357
- e === 0 && (r.x1 = a.x, r.y1 = a.y), e === 1 && (r.x2 = a.x, r.y1 = a.y), e === 2 && (r.x2 = a.x, r.y2 = a.y), e === 3 && (r.x1 = a.x, r.y2 = a.y);
356
+ const c = t.coordinates;
357
+ e === 0 && (c.x1 = o.x, c.y1 = o.y), e === 1 && (c.x2 = o.x, c.y1 = o.y), e === 2 && (c.x2 = o.x, c.y2 = o.y), e === 3 && (c.x1 = o.x, c.y2 = o.y);
358
358
  } else if (t.type === "polygon") {
359
- const r = t.coordinates;
360
- e >= 0 && e < r.points.length && (r.points[e] = a);
359
+ const c = t.coordinates;
360
+ e >= 0 && e < c.points.length && (c.points[e] = o);
361
361
  } else if (t.type === "point") {
362
- const r = t.coordinates;
363
- e >= 0 && e < r.points.length && (r.points[e] = a);
362
+ const c = t.coordinates;
363
+ e >= 0 && e < c.points.length && (c.points[e] = o);
364
364
  } else if (t.type === "rotatedRect") {
365
- const r = t.coordinates;
365
+ const c = t.coordinates;
366
366
  if (e === -2) {
367
- const c = r.x, o = r.y, h = a.x - c, u = a.y - o;
368
- let A = Math.atan2(u, h) * 180 / Math.PI;
369
- A += 90, r.angle = A;
367
+ const r = c.x, a = c.y, d = o.x - r, u = o.y - a;
368
+ let w = Math.atan2(u, d) * 180 / Math.PI;
369
+ w += 90, c.angle = w;
370
370
  } else {
371
- const c = r.angle * Math.PI / 180, o = Math.cos(-c), h = Math.sin(-c), u = a.x - r.x, A = a.y - r.y, y = u * o - A * h, w = u * h + A * o;
372
- (e === 0 || e === 3) && (r.width / 2, r.width = Math.abs(y) * 2), (e === 1 || e === 2) && (r.width = Math.abs(y) * 2), (e === 0 || e === 1) && (r.height = Math.abs(w) * 2), (e === 2 || e === 3) && (r.height = Math.abs(w) * 2);
371
+ const r = c.angle * Math.PI / 180, a = Math.cos(-r), d = Math.sin(-r), u = o.x - c.x, w = o.y - c.y, m = u * a - w * d, _ = u * d + w * a;
372
+ (e === 0 || e === 3) && (c.width / 2, c.width = Math.abs(m) * 2), (e === 1 || e === 2) && (c.width = Math.abs(m) * 2), (e === 0 || e === 1) && (c.height = Math.abs(_) * 2), (e === 2 || e === 3) && (c.height = Math.abs(_) * 2);
373
373
  }
374
374
  }
375
375
  }
@@ -390,18 +390,18 @@ class Zt {
390
390
  const e = i.coordinates;
391
391
  return Kt(t, e.points);
392
392
  } else if (i.type === "rotatedRect") {
393
- const e = i.coordinates, a = yt(t, { x: e.x, y: e.y }, -e.angle), r = e.width / 2, c = e.height / 2;
394
- return a.x >= e.x - r && a.x <= e.x + r && a.y >= e.y - c && a.y <= e.y + c;
393
+ const e = i.coordinates, o = pt(t, { x: e.x, y: e.y }, -e.angle), c = e.width / 2, r = e.height / 2;
394
+ return o.x >= e.x - c && o.x <= e.x + c && o.y >= e.y - r && o.y <= e.y + r;
395
395
  } else if (i.type === "point")
396
- return i.coordinates.points.some((a) => ct(t, a) < 10 / this.scale);
396
+ return i.coordinates.points.some((o) => ct(t, o) < 10 / this.scale);
397
397
  return !1;
398
398
  }
399
399
  getHitHandle(t, i, e) {
400
- const a = this.getAnnotationHandles(e), r = 6;
401
- for (let c = 0; c < a.length; c++) {
402
- const o = a[c], h = this.toScreenCoords(o.x, o.y);
403
- if (Math.abs(t - h.x) < r && Math.abs(i - h.y) < r)
404
- return e.type === "rotatedRect" && c === 4 ? -2 : c;
400
+ const o = this.getAnnotationHandles(e), c = 6;
401
+ for (let r = 0; r < o.length; r++) {
402
+ const a = o[r], d = this.toScreenCoords(a.x, a.y);
403
+ if (Math.abs(t - d.x) < c && Math.abs(i - d.y) < c)
404
+ return e.type === "rotatedRect" && r === 4 ? -2 : r;
405
405
  }
406
406
  return -100;
407
407
  }
@@ -424,24 +424,24 @@ class Zt {
424
424
  if (t.type === "point")
425
425
  return t.coordinates.points;
426
426
  if (t.type === "rotatedRect") {
427
- const i = t.coordinates, e = { x: i.x, y: i.y }, a = i.width / 2, r = i.height / 2, c = { x: i.x - a, y: i.y - r }, o = { x: i.x + a, y: i.y - r }, h = { x: i.x + a, y: i.y + r }, u = { x: i.x - a, y: i.y + r }, A = { x: i.x, y: i.y - r - 20 / this.scale };
428
- return [c, o, h, u, A].map((y) => yt(y, e, i.angle));
427
+ const i = t.coordinates, e = { x: i.x, y: i.y }, o = i.width / 2, c = i.height / 2, r = { x: i.x - o, y: i.y - c }, a = { x: i.x + o, y: i.y - c }, d = { x: i.x + o, y: i.y + c }, u = { x: i.x - o, y: i.y + c }, w = { x: i.x, y: i.y - c - 20 / this.scale };
428
+ return [r, a, d, u, w].map((m) => pt(m, e, i.angle));
429
429
  }
430
430
  }
431
431
  return [];
432
432
  }
433
433
  checkHover(t, i, e) {
434
- const a = this.getHitCategory(t, i);
435
- if (a) {
436
- this.canvas.style.cursor = "pointer", this.hoverAnnotation = a;
434
+ const o = this.getHitCategory(t, i);
435
+ if (o) {
436
+ this.canvas.style.cursor = "pointer", this.hoverAnnotation = o;
437
437
  return;
438
438
  }
439
439
  if (this.activeAnnotation && this.getHitHandle(t, i, this.activeAnnotation) !== -100) {
440
440
  this.canvas.style.cursor = "pointer";
441
441
  return;
442
442
  }
443
- const r = this.getHitAnnotation(e);
444
- r ? (this.canvas.style.cursor = "move", this.hoverAnnotation = r) : (this.canvas.style.cursor = "default", this.hoverAnnotation = null);
443
+ const c = this.getHitAnnotation(e);
444
+ c ? (this.canvas.style.cursor = "move", this.hoverAnnotation = c) : (this.canvas.style.cursor = "default", this.hoverAnnotation = null);
445
445
  }
446
446
  render() {
447
447
  this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.img.complete && this.img.width > 0 && this.ctx.drawImage(this.img, this.offset.x, this.offset.y, this.img.width * this.scale, this.img.height * this.scale), this.annotations.forEach((t) => {
@@ -449,76 +449,76 @@ class Zt {
449
449
  }), this.activeAnnotation && this.drawItem(this.activeAnnotation, !0), this.renderCategories();
450
450
  }
451
451
  renderCategories() {
452
- const t = this.annotations.filter((h) => h.type === "category");
452
+ const t = this.annotations.filter((d) => d.type === "category");
453
453
  if (t.length === 0) return;
454
454
  this.ctx.save(), this.ctx.font = "14px sans-serif", this.ctx.textBaseline = "top";
455
455
  let i = 10;
456
- const e = 10, a = 8, r = 4, c = 24, o = 8;
457
- t.forEach((h) => {
458
- const u = h.label || "Unlabeled", A = this.ctx.measureText(u).width + a * 2, y = this.activeAnnotation === h, w = this.hoverAnnotation === h;
459
- this.ctx.fillStyle = y ? "#E3F2FD" : w ? "#F5F5F5" : "rgba(255, 255, 255, 0.9)", this.ctx.strokeStyle = y ? "#2196F3" : "#666", this.ctx.lineWidth = y ? 2 : 1, this.ctx.beginPath(), this.ctx.rect(i, e, A, c), this.ctx.fill(), this.ctx.stroke(), this.ctx.fillStyle = y ? "#1976D2" : "#333", this.ctx.fillText(u, i + a, e + r), i += A + o;
456
+ const e = 10, o = 8, c = 4, r = 24, a = 8;
457
+ t.forEach((d) => {
458
+ const u = d.label || "Unlabeled", w = this.ctx.measureText(u).width + o * 2, m = this.activeAnnotation === d, _ = this.hoverAnnotation === d;
459
+ this.ctx.fillStyle = m ? "#E3F2FD" : _ ? "#F5F5F5" : "rgba(255, 255, 255, 0.9)", this.ctx.strokeStyle = m ? "#2196F3" : "#666", this.ctx.lineWidth = m ? 2 : 1, this.ctx.beginPath(), this.ctx.rect(i, e, w, r), this.ctx.fill(), this.ctx.stroke(), this.ctx.fillStyle = m ? "#1976D2" : "#333", this.ctx.fillText(u, i + o, e + c), i += w + a;
460
460
  }), this.ctx.restore();
461
461
  }
462
462
  getHitCategory(t, i) {
463
- const e = this.annotations.filter((A) => A.type === "category");
463
+ const e = this.annotations.filter((w) => w.type === "category");
464
464
  if (e.length === 0) return null;
465
465
  this.ctx.save(), this.ctx.font = "14px sans-serif";
466
- let a = 10;
467
- const r = 10, c = 8, o = 24, h = 8;
466
+ let o = 10;
467
+ const c = 10, r = 8, a = 24, d = 8;
468
468
  let u = null;
469
- for (const A of e) {
470
- const y = A.label || "Unlabeled", w = this.ctx.measureText(y).width + c * 2;
471
- if (t >= a && t <= a + w && i >= r && i <= r + o) {
472
- u = A;
469
+ for (const w of e) {
470
+ const m = w.label || "Unlabeled", _ = this.ctx.measureText(m).width + r * 2;
471
+ if (t >= o && t <= o + _ && i >= c && i <= c + a) {
472
+ u = w;
473
473
  break;
474
474
  }
475
- a += w + h;
475
+ o += _ + d;
476
476
  }
477
477
  return this.ctx.restore(), u;
478
478
  }
479
479
  drawItem(t, i) {
480
- var r;
480
+ var c;
481
481
  if (this.visibleLabels.size > 0 && !this.visibleLabels.has(t.label) && !i)
482
482
  return;
483
483
  this.ctx.save();
484
- const e = ((r = t.style) == null ? void 0 : r.strokeColor) || "#FF4081", a = i ? "#00E5FF" : e;
485
- if (this.ctx.strokeStyle = a, this.ctx.lineWidth = 2, i ? this.ctx.fillStyle = "rgba(0, 229, 255, 0.2)" : this.ctx.fillStyle = this.hexToRgba(e, 0.2), t.type === "rectangle") {
486
- const c = t.coordinates, o = this.toScreenCoords(c.x1, c.y1), h = this.toScreenCoords(c.x2, c.y2), u = Math.min(o.x, h.x), A = Math.min(o.y, h.y), y = Math.abs(o.x - h.x), w = Math.abs(o.y - h.y);
487
- this.ctx.strokeRect(u, A, y, w), this.ctx.fillStyle = i ? "rgba(0, 229, 255, 0.2)" : "rgba(255, 64, 129, 0.2)", this.ctx.fillRect(u, A, y, w), i && this.drawHandles(this.getAnnotationHandles(t));
484
+ const e = ((c = t.style) == null ? void 0 : c.strokeColor) || "#FF4081", o = i ? "#00E5FF" : e;
485
+ if (this.ctx.strokeStyle = o, this.ctx.lineWidth = 2, i ? this.ctx.fillStyle = "rgba(0, 229, 255, 0.2)" : this.ctx.fillStyle = this.hexToRgba(e, 0.2), t.type === "rectangle") {
486
+ const r = t.coordinates, a = this.toScreenCoords(r.x1, r.y1), d = this.toScreenCoords(r.x2, r.y2), u = Math.min(a.x, d.x), w = Math.min(a.y, d.y), m = Math.abs(a.x - d.x), _ = Math.abs(a.y - d.y);
487
+ this.ctx.strokeRect(u, w, m, _), this.ctx.fillStyle = i ? "rgba(0, 229, 255, 0.2)" : "rgba(255, 64, 129, 0.2)", this.ctx.fillRect(u, w, m, _), i && this.drawHandles(this.getAnnotationHandles(t));
488
488
  } else if (t.type === "polygon") {
489
- const c = t.coordinates;
490
- if (c.points.length === 0) {
489
+ const r = t.coordinates;
490
+ if (r.points.length === 0) {
491
491
  this.ctx.restore();
492
492
  return;
493
493
  }
494
494
  this.ctx.beginPath();
495
- const o = this.toScreenCoords(c.points[0].x, c.points[0].y);
496
- this.ctx.moveTo(o.x, o.y);
497
- for (let h = 1; h < c.points.length; h++) {
498
- const u = this.toScreenCoords(c.points[h].x, c.points[h].y);
495
+ const a = this.toScreenCoords(r.points[0].x, r.points[0].y);
496
+ this.ctx.moveTo(a.x, a.y);
497
+ for (let d = 1; d < r.points.length; d++) {
498
+ const u = this.toScreenCoords(r.points[d].x, r.points[d].y);
499
499
  this.ctx.lineTo(u.x, u.y);
500
500
  }
501
501
  if (!this.isDrawing || t !== this.activeAnnotation)
502
502
  this.ctx.closePath();
503
503
  else if (this.lastMouseMovePoint) {
504
- let h = this.lastMouseMovePoint;
505
- if (this.isHoveringStartPoint && c.points.length > 0) {
506
- h = c.points[0];
507
- const A = this.toScreenCoords(c.points[0].x, c.points[0].y);
508
- this.ctx.save(), this.ctx.beginPath(), this.ctx.arc(A.x, A.y, 10, 0, Math.PI * 2), this.ctx.fillStyle = "rgba(255, 215, 0, 0.6)", this.ctx.strokeStyle = "#FFFFFF", this.ctx.lineWidth = 2, this.ctx.fill(), this.ctx.stroke(), this.ctx.restore();
504
+ let d = this.lastMouseMovePoint;
505
+ if (this.isHoveringStartPoint && r.points.length > 0) {
506
+ d = r.points[0];
507
+ const w = this.toScreenCoords(r.points[0].x, r.points[0].y);
508
+ this.ctx.save(), this.ctx.beginPath(), this.ctx.arc(w.x, w.y, 10, 0, Math.PI * 2), this.ctx.fillStyle = "rgba(255, 215, 0, 0.6)", this.ctx.strokeStyle = "#FFFFFF", this.ctx.lineWidth = 2, this.ctx.fill(), this.ctx.stroke(), this.ctx.restore();
509
509
  }
510
- const u = this.toScreenCoords(h.x, h.y);
510
+ const u = this.toScreenCoords(d.x, d.y);
511
511
  this.ctx.lineTo(u.x, u.y);
512
512
  }
513
513
  this.ctx.stroke(), this.ctx.fillStyle = i ? "rgba(0, 229, 255, 0.2)" : "rgba(255, 64, 129, 0.2)", this.ctx.fill(), i && this.drawHandles(this.getAnnotationHandles(t));
514
514
  } else if (t.type === "rotatedRect") {
515
- const c = t.coordinates;
516
- this.ctx.translate(this.toScreenCoords(c.x, c.y).x, this.toScreenCoords(c.x, c.y).y), this.ctx.rotate(c.angle * Math.PI / 180);
517
- const o = c.width * this.scale, h = c.height * this.scale;
518
- this.ctx.strokeRect(-o / 2, -h / 2, o, h), this.ctx.fillStyle = i ? "rgba(0, 229, 255, 0.2)" : "rgba(255, 64, 129, 0.2)", this.ctx.fillRect(-o / 2, -h / 2, o, h), this.ctx.rotate(-c.angle * Math.PI / 180), this.ctx.translate(-this.toScreenCoords(c.x, c.y).x, -this.toScreenCoords(c.x, c.y).y), i && this.drawHandles(this.getAnnotationHandles(t));
519
- } else t.type === "point" && t.coordinates.points.forEach((o) => {
520
- const h = this.toScreenCoords(o.x, o.y);
521
- this.ctx.beginPath(), this.ctx.arc(h.x, h.y, 5, 0, Math.PI * 2), this.ctx.fillStyle = i ? "#00E5FF" : e, this.ctx.fill(), this.ctx.stroke();
515
+ const r = t.coordinates;
516
+ this.ctx.translate(this.toScreenCoords(r.x, r.y).x, this.toScreenCoords(r.x, r.y).y), this.ctx.rotate(r.angle * Math.PI / 180);
517
+ const a = r.width * this.scale, d = r.height * this.scale;
518
+ this.ctx.strokeRect(-a / 2, -d / 2, a, d), this.ctx.fillStyle = i ? "rgba(0, 229, 255, 0.2)" : "rgba(255, 64, 129, 0.2)", this.ctx.fillRect(-a / 2, -d / 2, a, d), this.ctx.rotate(-r.angle * Math.PI / 180), this.ctx.translate(-this.toScreenCoords(r.x, r.y).x, -this.toScreenCoords(r.x, r.y).y), i && this.drawHandles(this.getAnnotationHandles(t));
519
+ } else t.type === "point" && t.coordinates.points.forEach((a) => {
520
+ const d = this.toScreenCoords(a.x, a.y);
521
+ this.ctx.beginPath(), this.ctx.arc(d.x, d.y, 5, 0, Math.PI * 2), this.ctx.fillStyle = i ? "#00E5FF" : e, this.ctx.fill(), this.ctx.stroke();
522
522
  });
523
523
  this.ctx.restore();
524
524
  }
@@ -561,28 +561,28 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
561
561
  <path d="M637.12 693.376l182.208 182.208a32 32 0 1 1-45.248 45.248L591.872 738.624a352 352 0 1 1 45.248-45.248z m-45.248-45.248A288 288 0 1 0 183.872 240.128a288 288 0 0 0 408 408zM416 448h96a32 32 0 0 1 0 64h-96v96a32 32 0 0 1-64 0v-96h-96a32 32 0 0 1 0-64h96v-96a32 32 0 0 1 64 0v96z" fill="currentColor"/>\r
562
562
  </svg>`, ve = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" width="1em" height="1em">\r
563
563
  <path d="M637.12 693.376l182.208 182.208a32 32 0 1 1-45.248 45.248L591.872 738.624a352 352 0 1 1 45.248-45.248z m-45.248-45.248A288 288 0 1 0 183.872 240.128a288 288 0 0 0 408 408zM256 448h320a32 32 0 1 1 0 64H256a32 32 0 1 1 0-64z" fill="currentColor"/>\r
564
- </svg>`, me = ["innerHTML"], fe = /* @__PURE__ */ K({
564
+ </svg>`, me = ["innerHTML"], fe = /* @__PURE__ */ tt({
565
565
  __name: "SvgIcon",
566
566
  props: {
567
567
  name: {},
568
568
  size: {}
569
569
  },
570
- setup(v) {
571
- const t = v, i = S(""), e = /* @__PURE__ */ Object.assign({ "../assets/svg/aim.svg": Qt, "../assets/svg/back.svg": te, "../assets/svg/connection.svg": ee, "../assets/svg/crop.svg": ne, "../assets/svg/delete.svg": se, "../assets/svg/download.svg": ie, "../assets/svg/edit.svg": oe, "../assets/svg/hide.svg": ae, "../assets/svg/pointer.svg": le, "../assets/svg/price-tag.svg": re, "../assets/svg/rank.svg": ce, "../assets/svg/refresh-right.svg": he, "../assets/svg/right.svg": de, "../assets/svg/view.svg": ge, "../assets/svg/zoom-in.svg": ue, "../assets/svg/zoom-out.svg": ve });
570
+ setup(f) {
571
+ const t = f, i = M(""), e = /* @__PURE__ */ Object.assign({ "../assets/svg/aim.svg": Qt, "../assets/svg/back.svg": te, "../assets/svg/connection.svg": ee, "../assets/svg/crop.svg": ne, "../assets/svg/delete.svg": se, "../assets/svg/download.svg": ie, "../assets/svg/edit.svg": oe, "../assets/svg/hide.svg": ae, "../assets/svg/pointer.svg": le, "../assets/svg/price-tag.svg": re, "../assets/svg/rank.svg": ce, "../assets/svg/refresh-right.svg": he, "../assets/svg/right.svg": de, "../assets/svg/view.svg": ge, "../assets/svg/zoom-in.svg": ue, "../assets/svg/zoom-out.svg": ve });
572
572
  return Yt(() => {
573
- const a = `../assets/svg/${t.name}.svg`, r = e[a];
574
- r ? i.value = r : (console.warn(`Icon ${t.name} not found at path ${a}`), i.value = "");
575
- }), (a, r) => (f(), p("i", {
576
- class: V(["svg-icon", [v.size ? `size-${v.size}` : ""]]),
573
+ const o = `../assets/svg/${t.name}.svg`, c = e[o];
574
+ c ? i.value = c : (console.warn(`Icon ${t.name} not found at path ${o}`), i.value = "");
575
+ }), (o, c) => (y(), x("i", {
576
+ class: J(["svg-icon", [f.size ? `size-${f.size}` : ""]]),
577
577
  innerHTML: i.value
578
578
  }, null, 10, me));
579
579
  }
580
- }), Z = (v, t) => {
581
- const i = v.__vccOpts || v;
582
- for (const [e, a] of t)
583
- i[e] = a;
580
+ }), et = (f, t) => {
581
+ const i = f.__vccOpts || f;
582
+ for (const [e, o] of t)
583
+ i[e] = o;
584
584
  return i;
585
- }, P = /* @__PURE__ */ Z(fe, [["__scopeId", "data-v-3928607b"]]), ye = {
585
+ }, H = /* @__PURE__ */ et(fe, [["__scopeId", "data-v-3928607b"]]), ye = {
586
586
  key: 0,
587
587
  class: "image-list-sidebar"
588
588
  }, pe = { class: "image-list-title" }, xe = { class: "image-list-scroll" }, be = ["onClick"], we = { class: "image-list-stage" }, Ce = ["src", "alt"], Ae = {
@@ -608,10 +608,10 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
608
608
  }, Be = ["disabled"], De = ["disabled"], Ue = {
609
609
  key: 2,
610
610
  class: "right-sidebar"
611
- }, Fe = { class: "label-list" }, Ee = { class: "label-row" }, Oe = ["onUpdate:modelValue", "onChange"], Ve = ["title"], Ne = ["onClick"], We = { class: "action-icon more-actions" }, Je = ["onClick"], je = {
611
+ }, Fe = { class: "label-list" }, Oe = { class: "label-row" }, Ee = ["onUpdate:modelValue", "onChange"], Ve = ["title"], Ne = ["onClick"], We = { class: "action-icon more-actions" }, Je = ["onClick"], je = {
612
612
  key: 3,
613
613
  class: "modal-overlay"
614
- }, Ye = { class: "modal-content" }, Xe = { class: "form-group" }, qe = { class: "form-group" }, Ge = { class: "color-input-wrapper" }, Ke = /* @__PURE__ */ K({
614
+ }, Ye = { class: "modal-content" }, Xe = { class: "form-group" }, qe = { class: "form-group" }, Ge = { class: "color-input-wrapper" }, Ke = /* @__PURE__ */ tt({
615
615
  __name: "ImageAnnotator",
616
616
  props: {
617
617
  annotationTypes: { default: () => ["rectangle", "polygon", "point", "rotatedRect"] },
@@ -628,44 +628,44 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
628
628
  maxZoom: {}
629
629
  },
630
630
  emits: ["annotationChange", "batchChange", "labelChange", "ready", "error", "tool:change", "viewport:change", "annotation:add", "annotation:update", "annotation:delete", "annotation:select", "prediction:loaded", "prediction:apply", "prediction:reject"],
631
- setup(v, { expose: t, emit: i }) {
632
- const e = v, a = i, r = S(null), c = S(null), o = S(null), h = S(null), u = S(0), A = S(""), y = S([]), w = S(""), I = S(!1), C = S({ name: "", color: "#FF0000" }), B = S("none"), D = S([]), L = S({}), Q = U(() => h.value === "select" && !!A.value), J = (n) => {
633
- if (!n || L.value[n]) return;
631
+ setup(f, { expose: t, emit: i }) {
632
+ const e = f, o = i, c = M(null), r = M(null), a = M(null), d = M(null), u = M(0), w = M(""), m = M([]), _ = M(""), U = M(!1), k = M({ name: "", color: "#FF0000" }), I = M("none"), C = M([]), R = M({}), N = D(() => d.value === "select" && !!w.value), j = (n) => {
633
+ if (!n || R.value[n]) return;
634
634
  const s = new Image();
635
635
  s.onload = () => {
636
- const l = s.naturalWidth || 1, d = s.naturalHeight || 1;
637
- L.value = {
638
- ...L.value,
639
- [n]: { width: l, height: d }
636
+ const l = s.naturalWidth || 1, h = s.naturalHeight || 1;
637
+ R.value = {
638
+ ...R.value,
639
+ [n]: { width: l, height: h }
640
640
  };
641
641
  }, s.src = n;
642
- }, tt = () => {
642
+ }, X = () => {
643
643
  e.batchImages.forEach((n) => {
644
- J(n.imageUrl);
644
+ j(n.imageUrl);
645
645
  });
646
- }, E = () => {
647
- var l, d, m, _;
646
+ }, O = () => {
647
+ var l, h, v, A;
648
648
  const n = e.batchImages[u.value], s = (n == null ? void 0 : n.imageUrl) || ((l = e.image) == null ? void 0 : l.url);
649
649
  return {
650
650
  eventId: `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`,
651
651
  timestamp: Date.now(),
652
652
  requestId: e.requestId,
653
- taskId: (d = e.session) == null ? void 0 : d.taskId,
654
- imageId: ((m = e.image) == null ? void 0 : m.id) || s,
655
- operator: (_ = e.session) == null ? void 0 : _.userId
653
+ taskId: (h = e.session) == null ? void 0 : h.taskId,
654
+ imageId: ((v = e.image) == null ? void 0 : v.id) || s,
655
+ operator: (A = e.session) == null ? void 0 : A.userId
656
656
  };
657
- }, et = (n) => {
658
- var d;
657
+ }, ht = (n) => {
658
+ var h;
659
659
  const s = n == null ? void 0 : n.action;
660
660
  if (!s) return;
661
661
  const l = {
662
- meta: E(),
662
+ meta: O(),
663
663
  action: s,
664
664
  current: n == null ? void 0 : n.changedItem,
665
- source: (d = n == null ? void 0 : n.changedItem) != null && d.predictionId ? "prediction" : "manual"
665
+ source: (h = n == null ? void 0 : n.changedItem) != null && h.predictionId ? "prediction" : "manual"
666
666
  };
667
- s === "add" && a("annotation:add", l), s === "update" && a("annotation:update", l), s === "delete" && a("annotation:delete", l), s === "select" && a("annotation:select", l);
668
- }, nt = U(() => e.annotationTypes.filter((n) => n !== "category")), st = (n) => ({
667
+ s === "add" && o("annotation:add", l), s === "update" && o("annotation:update", l), s === "delete" && o("annotation:delete", l), s === "select" && o("annotation:select", l);
668
+ }, nt = D(() => e.annotationTypes.filter((n) => n !== "category")), st = (n) => ({
669
669
  rectangle: "crop",
670
670
  polygon: "connection",
671
671
  point: "aim",
@@ -679,253 +679,253 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
679
679
  category: "分类标签"
680
680
  })[n] || n;
681
681
  Xt(() => {
682
- if (tt(), r.value) {
683
- o.value = new Zt(r.value), o.value.on("annotationChange", (s) => {
684
- var l, d;
682
+ if (X(), c.value) {
683
+ a.value = new Zt(c.value), a.value.on("annotationChange", (s) => {
684
+ var l, h;
685
685
  if (s.action === "add" && s.changedItem) {
686
- const m = y.value.find((_) => _.id === w.value);
687
- m && (s.changedItem.label = m.name, s.changedItem.labelId = m.id);
686
+ const v = m.value.find((A) => A.id === _.value);
687
+ v && (s.changedItem.label = v.name, s.changedItem.labelId = v.id);
688
688
  }
689
- s.action === "select" ? A.value = ((l = s.changedItem) == null ? void 0 : l.id) || "" : s.action === "delete" && ((d = s.changedItem) == null ? void 0 : d.id) === A.value && (A.value = ""), a("annotationChange", s), et(s);
690
- }), x(), N();
689
+ s.action === "select" ? w.value = ((l = s.changedItem) == null ? void 0 : l.id) || "" : s.action === "delete" && ((h = s.changedItem) == null ? void 0 : h.id) === w.value && (w.value = ""), o("annotationChange", s), ht(s);
690
+ }), W(), E();
691
691
  const n = new ResizeObserver(() => {
692
692
  var s;
693
- (s = o.value) == null || s.resize();
693
+ (s = a.value) == null || s.resize();
694
694
  });
695
- c.value && n.observe(c.value), e.defaultActiveType && b(e.defaultActiveType), a("ready", { meta: E() });
695
+ r.value && n.observe(r.value), e.defaultActiveType && p(e.defaultActiveType), o("ready", { meta: O() });
696
696
  }
697
697
  });
698
- const N = () => {
699
- if (!o.value) return;
700
- const n = y.value.find((l) => l.id === w.value);
701
- n && o.value.setLabelStyle(n.color);
702
- const s = y.value.filter((l) => l.visible).map((l) => l.name);
703
- o.value.setVisibleLabels(s);
704
- }, x = () => {
698
+ const E = () => {
699
+ if (!a.value) return;
700
+ const n = m.value.find((l) => l.id === _.value);
701
+ n && a.value.setLabelStyle(n.color);
702
+ const s = m.value.filter((l) => l.visible).map((l) => l.name);
703
+ a.value.setVisibleLabels(s);
704
+ }, W = () => {
705
705
  var n;
706
- if (o.value)
707
- if (A.value = "", requestAnimationFrame(() => {
706
+ if (a.value)
707
+ if (w.value = "", requestAnimationFrame(() => {
708
708
  var s;
709
- (s = o.value) == null || s.resize();
709
+ (s = a.value) == null || s.resize();
710
710
  }), e.batchImages.length > 0) {
711
711
  const s = e.batchImages[u.value];
712
- o.value.loadImage(s.imageUrl), s.annotations ? o.value.setAnnotations(s.annotations) : o.value.setAnnotations([]);
713
- } else (n = e.image) != null && n.url && o.value.loadImage(e.image.url);
714
- }, b = (n) => {
712
+ a.value.loadImage(s.imageUrl), s.annotations ? a.value.setAnnotations(s.annotations) : a.value.setAnnotations([]);
713
+ } else (n = e.image) != null && n.url && a.value.loadImage(e.image.url);
714
+ }, p = (n) => {
715
715
  var s, l;
716
- if (h.value = n, A.value = "", n !== "pan" && n !== "select" && y.value.length === 0) {
716
+ if (d.value = n, w.value = "", n !== "pan" && n !== "select" && m.value.length === 0) {
717
717
  alert("请先创建标签!");
718
718
  return;
719
719
  }
720
- n === "pan" || n === "select" ? (s = o.value) == null || s.setTool(n) : (l = o.value) == null || l.setTool(n), a("tool:change", { meta: E(), tool: n });
721
- }, M = () => {
720
+ n === "pan" || n === "select" ? (s = a.value) == null || s.setTool(n) : (l = a.value) == null || l.setTool(n), o("tool:change", { meta: O(), tool: n });
721
+ }, b = () => {
722
722
  var n;
723
- (n = o.value) != null && n.activeAnnotation && o.value.deleteAnnotation(o.value.activeAnnotation.id);
724
- }, W = () => {
725
- o.value && a("viewport:change", {
726
- meta: E(),
727
- scale: o.value.scale,
728
- offset: { ...o.value.offset }
723
+ (n = a.value) != null && n.activeAnnotation && a.value.deleteAnnotation(a.value.activeAnnotation.id);
724
+ }, z = () => {
725
+ a.value && o("viewport:change", {
726
+ meta: O(),
727
+ scale: a.value.scale,
728
+ offset: { ...a.value.offset }
729
729
  });
730
- }, ht = () => {
730
+ }, q = () => {
731
731
  var n;
732
- (n = o.value) == null || n.zoom(1), W();
733
- }, pt = () => {
732
+ (n = a.value) == null || n.zoom(1), z();
733
+ }, dt = () => {
734
734
  var n;
735
- (n = o.value) == null || n.zoom(-1), W();
735
+ (n = a.value) == null || n.zoom(-1), z();
736
736
  }, xt = () => {
737
- C.value = { name: "", color: "#2196F3" }, I.value = !0;
738
- }, dt = () => {
739
- I.value = !1;
737
+ k.value = { name: "", color: "#2196F3" }, U.value = !0;
738
+ }, gt = () => {
739
+ U.value = !1;
740
740
  }, bt = () => {
741
- if (!C.value.name.trim()) {
741
+ if (!k.value.name.trim()) {
742
742
  alert("请输入标签名称");
743
743
  return;
744
744
  }
745
745
  const s = {
746
746
  id: Date.now().toString(),
747
- name: C.value.name,
748
- color: C.value.color,
747
+ name: k.value.name,
748
+ color: k.value.color,
749
749
  visible: !0
750
750
  };
751
- y.value.push(s), a("labelChange", y.value), y.value.length === 1 && j(s), dt();
752
- }, j = (n) => {
751
+ m.value.push(s), o("labelChange", m.value), E(), m.value.length === 1 && G(s), gt();
752
+ }, G = (n) => {
753
753
  var s;
754
- w.value = n.id, (s = o.value) == null || s.setLabelStyle(n.color);
754
+ _.value = n.id, (s = a.value) == null || s.setLabelStyle(n.color);
755
755
  }, wt = (n, s) => {
756
756
  if (!n.startsWith("#")) return n;
757
- let l = 0, d = 0, m = 0;
758
- return n.length === 4 ? (l = parseInt(n[1] + n[1], 16), d = parseInt(n[2] + n[2], 16), m = parseInt(n[3] + n[3], 16)) : n.length === 7 && (l = parseInt(n.slice(1, 3), 16), d = parseInt(n.slice(3, 5), 16), m = parseInt(n.slice(5, 7), 16)), `rgba(${l}, ${d}, ${m}, ${s})`;
757
+ let l = 0, h = 0, v = 0;
758
+ return n.length === 4 ? (l = parseInt(n[1] + n[1], 16), h = parseInt(n[2] + n[2], 16), v = parseInt(n[3] + n[3], 16)) : n.length === 7 && (l = parseInt(n.slice(1, 3), 16), h = parseInt(n.slice(3, 5), 16), v = parseInt(n.slice(5, 7), 16)), `rgba(${l}, ${h}, ${v}, ${s})`;
759
759
  }, Ct = (n) => {
760
760
  var s;
761
- if (n.id === w.value && ((s = o.value) == null || s.setLabelStyle(n.color)), o.value) {
762
- const l = o.value.getAnnotations();
763
- let d = !1;
764
- l.forEach((m) => {
765
- m.label === n.name && (m.style || (m.style = {}), m.style.strokeColor = n.color, m.style.fillColor = wt(n.color, 0.2), d = !0);
766
- }), d && o.value.render();
761
+ if (n.id === _.value && ((s = a.value) == null || s.setLabelStyle(n.color)), a.value) {
762
+ const l = a.value.getAnnotations();
763
+ let h = !1;
764
+ l.forEach((v) => {
765
+ v.label === n.name && (v.style || (v.style = {}), v.style.strokeColor = n.color, v.style.fillColor = wt(n.color, 0.2), h = !0);
766
+ }), h && a.value.render();
767
767
  }
768
- a("labelChange", y.value);
768
+ o("labelChange", m.value), E();
769
769
  }, At = (n) => {
770
- n.visible = !n.visible, N();
770
+ n.visible = !n.visible, E();
771
771
  }, _t = (n) => {
772
- const s = y.value.findIndex((l) => l.id === n);
773
- s > -1 && (y.value.splice(s, 1), a("labelChange", y.value), w.value === n && (w.value = y.value.length > 0 ? y.value[0].id : "", w.value && j(y.value[0])), N());
772
+ const s = m.value.findIndex((l) => l.id === n);
773
+ s > -1 && (m.value.splice(s, 1), o("labelChange", m.value), _.value === n && (_.value = m.value.length > 0 ? m.value[0].id : "", _.value && G(m.value[0])), E());
774
774
  };
775
775
  Y(() => e.labels, (n) => {
776
776
  const s = JSON.parse(JSON.stringify(n || []));
777
- if (y.value = s, y.value.length > 0)
778
- if (!w.value || !y.value.find((l) => l.id === w.value))
779
- j(y.value[0]);
777
+ if (m.value = s, m.value.length > 0)
778
+ if (!_.value || !m.value.find((l) => l.id === _.value))
779
+ G(m.value[0]);
780
780
  else {
781
- const l = y.value.find((d) => d.id === w.value);
782
- l && j(l);
781
+ const l = m.value.find((h) => h.id === _.value);
782
+ l && G(l);
783
783
  }
784
784
  else
785
- w.value = "";
786
- N();
785
+ _.value = "";
786
+ E();
787
787
  }, { immediate: !0, deep: !0 });
788
788
  const It = () => {
789
- u.value > 0 && (ot(), u.value--, x(), at());
789
+ u.value > 0 && (ot(), u.value--, W(), at());
790
790
  }, kt = () => {
791
- u.value < e.batchImages.length - 1 && (ot(), u.value++, x(), at());
791
+ u.value < e.batchImages.length - 1 && (ot(), u.value++, W(), at());
792
792
  }, ot = () => {
793
- if (o.value) {
794
- const n = o.value.getAnnotations();
793
+ if (a.value) {
794
+ const n = a.value.getAnnotations();
795
795
  e.batchImages[u.value].annotations = n;
796
796
  }
797
797
  }, at = () => {
798
798
  const n = e.batchImages[u.value];
799
- a("batchChange", {
799
+ o("batchChange", {
800
800
  currentIndex: u.value,
801
801
  total: e.batchImages.length,
802
802
  currentImageUrl: n.imageUrl,
803
803
  currentAnnotations: n.annotations || []
804
804
  });
805
- }, gt = (n = []) => {
806
- var m;
807
- if (!o.value) return;
808
- if (D.value = JSON.parse(JSON.stringify(n)), D.value.length === 0) {
809
- B.value = "none";
805
+ }, ut = (n = []) => {
806
+ var v;
807
+ if (!a.value) return;
808
+ if (C.value = JSON.parse(JSON.stringify(n)), C.value.length === 0) {
809
+ I.value = "none";
810
810
  return;
811
811
  }
812
- B.value = "loaded";
813
- const l = (o.value.getAnnotations() || []).filter((_) => !_.predictionId), d = D.value.map((_) => {
814
- const z = JSON.parse(JSON.stringify(_.annotation));
815
- return z.id = z.id || `pred-${_.id}`, z.predictionId = _.id, z.modelRunId = _.modelRunId || z.modelRunId, z.confidence = _.confidence ?? z.confidence, z.reviewStatus = z.reviewStatus || "draft", z;
812
+ I.value = "loaded";
813
+ const l = (a.value.getAnnotations() || []).filter((A) => !A.predictionId), h = C.value.map((A) => {
814
+ const $ = JSON.parse(JSON.stringify(A.annotation));
815
+ return $.id = $.id || `pred-${A.id}`, $.predictionId = A.id, $.modelRunId = A.modelRunId || $.modelRunId, $.confidence = A.confidence ?? $.confidence, $.reviewStatus = $.reviewStatus || "draft", $;
816
816
  });
817
- o.value.setAnnotations([...l, ...d]), a("prediction:loaded", {
818
- meta: E(),
819
- modelRunId: (m = D.value[0]) == null ? void 0 : m.modelRunId,
820
- candidates: D.value
817
+ a.value.setAnnotations([...l, ...h]), o("prediction:loaded", {
818
+ meta: O(),
819
+ modelRunId: (v = C.value[0]) == null ? void 0 : v.modelRunId,
820
+ candidates: C.value
821
821
  });
822
822
  }, St = (n, s) => {
823
- var m;
824
- if (!o.value) return [];
825
- B.value = "applying";
826
- const d = (o.value.getAnnotations() || []).filter((_) => _.predictionId && n.includes(_.predictionId));
827
- return d.forEach((_) => {
828
- _.reviewStatus = "accepted";
829
- }), B.value = "applied", a("prediction:apply", {
830
- meta: E(),
831
- modelRunId: (m = d[0]) == null ? void 0 : m.modelRunId,
823
+ var v;
824
+ if (!a.value) return [];
825
+ I.value = "applying";
826
+ const h = (a.value.getAnnotations() || []).filter((A) => A.predictionId && n.includes(A.predictionId));
827
+ return h.forEach((A) => {
828
+ A.reviewStatus = "accepted";
829
+ }), I.value = "applied", o("prediction:apply", {
830
+ meta: O(),
831
+ modelRunId: (v = h[0]) == null ? void 0 : v.modelRunId,
832
832
  candidateIds: n,
833
833
  threshold: s,
834
- acceptedAnnotations: d
835
- }), o.value.render(), d;
834
+ acceptedAnnotations: h
835
+ }), a.value.render(), h;
836
836
  }, Mt = (n, s) => {
837
- var m;
838
- if (!o.value) return;
839
- const l = o.value.getAnnotations() || [], d = l.filter((_) => !(_.predictionId && n.includes(_.predictionId)));
840
- o.value.setAnnotations(d), a("prediction:reject", {
841
- meta: E(),
842
- modelRunId: (m = l.find((_) => _.predictionId && n.includes(_.predictionId))) == null ? void 0 : m.modelRunId,
837
+ var v;
838
+ if (!a.value) return;
839
+ const l = a.value.getAnnotations() || [], h = l.filter((A) => !(A.predictionId && n.includes(A.predictionId)));
840
+ a.value.setAnnotations(h), o("prediction:reject", {
841
+ meta: O(),
842
+ modelRunId: (v = l.find((A) => A.predictionId && n.includes(A.predictionId))) == null ? void 0 : v.modelRunId,
843
843
  candidateIds: n,
844
844
  reason: s
845
845
  });
846
846
  }, zt = (n, s = []) => {
847
- o.value && (o.value.loadImage(n.url), o.value.setAnnotations(s));
847
+ a.value && (a.value.loadImage(n.url), a.value.setAnnotations(s));
848
848
  }, $t = (n) => {
849
849
  var s;
850
- (s = o.value) == null || s.setAnnotations(n);
851
- }, ut = () => {
850
+ (s = a.value) == null || s.setAnnotations(n);
851
+ }, vt = () => {
852
852
  var n;
853
- return ((n = o.value) == null ? void 0 : n.getAnnotations()) || [];
853
+ return ((n = a.value) == null ? void 0 : n.getAnnotations()) || [];
854
854
  }, Tt = (n = "json") => {
855
- var l, d;
856
- const s = ut();
855
+ var l, h;
856
+ const s = vt();
857
857
  return {
858
858
  format: n,
859
- image: ((l = e.batchImages[u.value]) == null ? void 0 : l.imageUrl) || ((d = e.image) == null ? void 0 : d.url) || "",
859
+ image: ((l = e.batchImages[u.value]) == null ? void 0 : l.imageUrl) || ((h = e.image) == null ? void 0 : h.url) || "",
860
860
  annotations: s
861
861
  };
862
- }, vt = (n) => {
863
- n >= 0 && n < e.batchImages.length && (ot(), u.value = n, x(), at());
862
+ }, mt = (n) => {
863
+ n >= 0 && n < e.batchImages.length && (ot(), u.value = n, W(), at());
864
864
  }, Pt = (n) => {
865
865
  var s;
866
- return n === u.value && o.value ? o.value.getAnnotations() || [] : ((s = e.batchImages[n]) == null ? void 0 : s.annotations) || [];
867
- }, Ht = (n) => n.type === "rectangle", Lt = (n) => n.type === "polygon", Rt = (n) => n.type === "point", Bt = (n) => n.type === "rotatedRect", q = (n) => {
868
- var l, d;
869
- const s = (l = y.value.find((m) => m.name === n.label)) == null ? void 0 : l.color;
870
- return ((d = n.style) == null ? void 0 : d.strokeColor) || s || "#409eff";
871
- }, mt = (n) => {
866
+ return n === u.value && a.value ? a.value.getAnnotations() || [] : ((s = e.batchImages[n]) == null ? void 0 : s.annotations) || [];
867
+ }, Ht = (n) => n.type === "rectangle", Lt = (n) => n.type === "polygon", Rt = (n) => n.type === "point", Bt = (n) => n.type === "rotatedRect", Z = (n) => {
868
+ var l, h;
869
+ const s = (l = m.value.find((v) => v.name === n.label)) == null ? void 0 : l.color;
870
+ return ((h = n.style) == null ? void 0 : h.strokeColor) || s || "#409eff";
871
+ }, ft = (n) => {
872
872
  const s = n.coordinates;
873
873
  return (s == null ? void 0 : s.points) || [];
874
- }, G = (n) => {
874
+ }, Q = (n) => {
875
875
  const s = e.batchImages[n];
876
876
  if (s != null && s.width && (s != null && s.height))
877
877
  return { width: s.width, height: s.height };
878
- const l = s != null && s.imageUrl ? L.value[s.imageUrl] : void 0;
879
- return l || (s != null && s.imageUrl && J(s.imageUrl), { width: 1, height: 1 });
878
+ const l = s != null && s.imageUrl ? R.value[s.imageUrl] : void 0;
879
+ return l || (s != null && s.imageUrl && j(s.imageUrl), { width: 1, height: 1 });
880
880
  }, Dt = (n) => {
881
881
  const s = e.batchImages[n];
882
- return s != null && s.width && (s != null && s.height) ? !0 : s != null && s.imageUrl ? !!L.value[s.imageUrl] : !1;
882
+ return s != null && s.width && (s != null && s.height) ? !0 : s != null && s.imageUrl ? !!R.value[s.imageUrl] : !1;
883
883
  }, Ut = (n, s) => {
884
- const l = s.coordinates, d = G(n), m = q(s), _ = Math.min(l.x1, l.x2), z = Math.min(l.y1, l.y2), Nt = Math.max(l.x1, l.x2), Wt = Math.max(l.y1, l.y2);
884
+ const l = s.coordinates, h = Q(n), v = Z(s), A = Math.min(l.x1, l.x2), $ = Math.min(l.y1, l.y2), Nt = Math.max(l.x1, l.x2), Wt = Math.max(l.y1, l.y2);
885
885
  return {
886
- left: `${_ / d.width * 100}%`,
887
- top: `${z / d.height * 100}%`,
888
- width: `${(Nt - _) / d.width * 100}%`,
889
- height: `${(Wt - z) / d.height * 100}%`,
890
- borderColor: m,
891
- backgroundColor: `${m}22`
886
+ left: `${A / h.width * 100}%`,
887
+ top: `${$ / h.height * 100}%`,
888
+ width: `${(Nt - A) / h.width * 100}%`,
889
+ height: `${(Wt - $) / h.height * 100}%`,
890
+ borderColor: v,
891
+ backgroundColor: `${v}22`
892
892
  };
893
893
  }, Ft = (n, s) => {
894
- const l = G(n);
895
- return mt(s).map((d) => `${d.x / l.width * 100},${d.y / l.height * 100}`).join(" ");
896
- }, Et = (n) => {
897
- const s = q(n);
894
+ const l = Q(n);
895
+ return ft(s).map((h) => `${h.x / l.width * 100},${h.y / l.height * 100}`).join(" ");
896
+ }, Ot = (n) => {
897
+ const s = Z(n);
898
898
  return {
899
899
  fill: `${s}33`,
900
900
  stroke: s,
901
901
  strokeWidth: "1.4"
902
902
  };
903
- }, Ot = (n, s, l) => {
904
- const d = G(n), m = q(l);
903
+ }, Et = (n, s, l) => {
904
+ const h = Q(n), v = Z(l);
905
905
  return {
906
- left: `${s.x / d.width * 100}%`,
907
- top: `${s.y / d.height * 100}%`,
908
- backgroundColor: m
906
+ left: `${s.x / h.width * 100}%`,
907
+ top: `${s.y / h.height * 100}%`,
908
+ backgroundColor: v
909
909
  };
910
910
  }, Vt = (n, s) => {
911
- const l = s.coordinates, d = G(n), m = q(s), _ = Math.abs(l.width), z = Math.abs(l.height);
911
+ const l = s.coordinates, h = Q(n), v = Z(s), A = Math.abs(l.width), $ = Math.abs(l.height);
912
912
  return {
913
- left: `${(l.x - _ / 2) / d.width * 100}%`,
914
- top: `${(l.y - z / 2) / d.height * 100}%`,
915
- width: `${_ / d.width * 100}%`,
916
- height: `${z / d.height * 100}%`,
913
+ left: `${(l.x - A / 2) / h.width * 100}%`,
914
+ top: `${(l.y - $ / 2) / h.height * 100}%`,
915
+ width: `${A / h.width * 100}%`,
916
+ height: `${$ / h.height * 100}%`,
917
917
  transform: `rotate(${l.angle || 0}deg)`,
918
- borderColor: m,
919
- backgroundColor: `${m}22`
918
+ borderColor: v,
919
+ backgroundColor: `${v}22`
920
920
  };
921
921
  };
922
922
  return t({
923
- jumpTo: vt,
923
+ jumpTo: mt,
924
924
  setImage: zt,
925
925
  setAnnotations: $t,
926
- getAnnotations: ut,
927
- selectTool: b,
928
- loadPredictionCandidates: gt,
926
+ getAnnotations: vt,
927
+ selectTool: p,
928
+ loadPredictionCandidates: ut,
929
929
  applyPredictions: St,
930
930
  rejectPredictions: Mt,
931
931
  exportAnnotations: Tt,
@@ -933,14 +933,14 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
933
933
  var n, s;
934
934
  return e.batchImages.length > 0 ? e.batchImages : [{
935
935
  imageUrl: ((n = e.image) == null ? void 0 : n.url) || "",
936
- annotations: ((s = o.value) == null ? void 0 : s.getAnnotations()) || []
936
+ annotations: ((s = a.value) == null ? void 0 : s.getAnnotations()) || []
937
937
  }];
938
938
  },
939
939
  getCurrentAnnotation: () => {
940
940
  var n, s, l;
941
941
  return {
942
942
  imageUrl: ((n = e.batchImages[u.value]) == null ? void 0 : n.imageUrl) || ((s = e.image) == null ? void 0 : s.url) || "",
943
- annotations: ((l = o.value) == null ? void 0 : l.getAnnotations()) || []
943
+ annotations: ((l = a.value) == null ? void 0 : l.getAnnotations()) || []
944
944
  };
945
945
  }
946
946
  }), Y(() => {
@@ -948,158 +948,158 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
948
948
  return (n = e.image) == null ? void 0 : n.url;
949
949
  }, () => {
950
950
  var n;
951
- e.batchImages.length === 0 && ((n = e.image) != null && n.url) && x();
951
+ e.batchImages.length === 0 && ((n = e.image) != null && n.url) && W();
952
952
  }), Y(() => e.predictionCandidates, (n) => {
953
- n && gt(n);
953
+ n && ut(n);
954
954
  }, { immediate: !0, deep: !0 }), Y(
955
955
  () => e.batchImages.map((n) => `${n.imageUrl}:${n.width || ""}x${n.height || ""}`),
956
956
  () => {
957
- tt();
957
+ X();
958
958
  },
959
959
  { immediate: !0 }
960
- ), (n, s) => (f(), p("div", {
961
- class: V(["annotation-container", v.theme])
960
+ ), (n, s) => (y(), x("div", {
961
+ class: J(["annotation-container", f.theme])
962
962
  }, [
963
- v.batchImages && v.batchImages.length > 0 ? (f(), p("div", ye, [
964
- g("div", pe, "批量图片(" + T(v.batchImages.length) + ")", 1),
963
+ f.batchImages && f.batchImages.length > 0 ? (y(), x("div", ye, [
964
+ g("div", pe, "批量图片(" + P(f.batchImages.length) + ")", 1),
965
965
  g("div", xe, [
966
- (f(!0), p(R, null, F(v.batchImages, (l, d) => (f(), p("button", {
967
- key: `${l.imageUrl}-${d}`,
968
- class: V(["image-list-item", { active: d === u.value }]),
969
- onClick: (m) => vt(d)
966
+ (y(!0), x(B, null, F(f.batchImages, (l, h) => (y(), x("button", {
967
+ key: `${l.imageUrl}-${h}`,
968
+ class: J(["image-list-item", { active: h === u.value }]),
969
+ onClick: (v) => mt(h)
970
970
  }, [
971
971
  g("div", we, [
972
972
  g("img", {
973
973
  src: l.imageUrl,
974
- alt: `第${d + 1}张`,
974
+ alt: `第${h + 1}张`,
975
975
  class: "image-list-thumb"
976
976
  }, null, 8, Ce),
977
- Dt(d) ? (f(), p("div", Ae, [
978
- (f(!0), p(R, null, F(Pt(d), (m) => (f(), p(R, {
979
- key: m.id
977
+ Dt(h) ? (y(), x("div", Ae, [
978
+ (y(!0), x(B, null, F(Pt(h), (v) => (y(), x(B, {
979
+ key: v.id
980
980
  }, [
981
- Ht(m) ? (f(), p("div", {
981
+ Ht(v) ? (y(), x("div", {
982
982
  key: 0,
983
983
  class: "thumb-overlay-rect",
984
- style: O(Ut(d, m))
985
- }, null, 4)) : Lt(m) ? (f(), p("svg", _e, [
984
+ style: V(Ut(h, v))
985
+ }, null, 4)) : Lt(v) ? (y(), x("svg", _e, [
986
986
  g("polygon", {
987
- points: Ft(d, m),
988
- style: O(Et(m))
987
+ points: Ft(h, v),
988
+ style: V(Ot(v))
989
989
  }, null, 12, Ie)
990
- ])) : Rt(m) ? (f(!0), p(R, { key: 2 }, F(mt(m), (_, z) => (f(), p("div", {
991
- key: `${m.id}-${z}`,
990
+ ])) : Rt(v) ? (y(!0), x(B, { key: 2 }, F(ft(v), (A, $) => (y(), x("div", {
991
+ key: `${v.id}-${$}`,
992
992
  class: "thumb-overlay-point",
993
- style: O(Ot(d, _, m))
994
- }, null, 4))), 128)) : Bt(m) ? (f(), p("div", {
993
+ style: V(Et(h, A, v))
994
+ }, null, 4))), 128)) : Bt(v) ? (y(), x("div", {
995
995
  key: 3,
996
996
  class: "thumb-overlay-rotated",
997
- style: O(Vt(d, m))
998
- }, null, 4)) : $("", !0)
997
+ style: V(Vt(h, v))
998
+ }, null, 4)) : T("", !0)
999
999
  ], 64))), 128))
1000
- ])) : $("", !0)
1000
+ ])) : T("", !0)
1001
1001
  ]),
1002
- g("span", ke, "第 " + T(d + 1) + " 张", 1)
1002
+ g("span", ke, "第 " + P(h + 1) + " 张", 1)
1003
1003
  ], 10, be))), 128))
1004
1004
  ])
1005
- ])) : $("", !0),
1006
- v.readOnly ? $("", !0) : (f(), p("div", Se, [
1005
+ ])) : T("", !0),
1006
+ f.readOnly ? T("", !0) : (y(), x("div", Se, [
1007
1007
  g("div", {
1008
- class: V(["tool-btn", { active: h.value === "pan" }]),
1009
- onClick: s[0] || (s[0] = (l) => b("pan")),
1008
+ class: J(["tool-btn", { active: d.value === "pan" }]),
1009
+ onClick: s[0] || (s[0] = (l) => p("pan")),
1010
1010
  title: "拖动"
1011
1011
  }, [
1012
- H(P, { name: "rank" })
1012
+ L(H, { name: "rank" })
1013
1013
  ], 2),
1014
1014
  g("div", {
1015
- class: V(["tool-btn", { active: h.value === "select" }]),
1016
- onClick: s[1] || (s[1] = (l) => b("select")),
1015
+ class: J(["tool-btn", { active: d.value === "select" }]),
1016
+ onClick: s[1] || (s[1] = (l) => p("select")),
1017
1017
  title: "选择"
1018
1018
  }, [
1019
- H(P, { name: "pointer" })
1019
+ L(H, { name: "pointer" })
1020
1020
  ], 2),
1021
1021
  s[5] || (s[5] = g("div", { class: "divider" }, null, -1)),
1022
- (f(!0), p(R, null, F(nt.value, (l) => (f(), p("div", {
1022
+ (y(!0), x(B, null, F(nt.value, (l) => (y(), x("div", {
1023
1023
  key: l,
1024
- class: V(["tool-btn", { active: h.value === l }]),
1025
- onClick: (d) => b(l),
1024
+ class: J(["tool-btn", { active: d.value === l }]),
1025
+ onClick: (h) => p(l),
1026
1026
  title: it(l)
1027
1027
  }, [
1028
- H(P, {
1028
+ L(H, {
1029
1029
  name: st(l)
1030
1030
  }, null, 8, ["name"])
1031
1031
  ], 10, Me))), 128)),
1032
1032
  s[6] || (s[6] = g("div", { class: "divider" }, null, -1)),
1033
1033
  g("div", {
1034
1034
  class: "tool-btn",
1035
- onClick: ht,
1035
+ onClick: q,
1036
1036
  title: "放大"
1037
1037
  }, [
1038
- H(P, { name: "zoom-in" })
1038
+ L(H, { name: "zoom-in" })
1039
1039
  ]),
1040
1040
  g("div", {
1041
1041
  class: "tool-btn",
1042
- onClick: pt,
1042
+ onClick: dt,
1043
1043
  title: "缩小"
1044
1044
  }, [
1045
- H(P, { name: "zoom-out" })
1045
+ L(H, { name: "zoom-out" })
1046
1046
  ]),
1047
1047
  s[7] || (s[7] = g("div", { class: "divider" }, null, -1)),
1048
- Q.value ? (f(), p("div", {
1048
+ N.value ? (y(), x("div", {
1049
1049
  key: 0,
1050
1050
  class: "tool-btn",
1051
- onClick: M,
1051
+ onClick: b,
1052
1052
  title: "删除选中"
1053
1053
  }, [
1054
- H(P, { name: "delete" })
1055
- ])) : $("", !0)
1054
+ L(H, { name: "delete" })
1055
+ ])) : T("", !0)
1056
1056
  ])),
1057
1057
  g("div", ze, [
1058
- v.readOnly ? $("", !0) : (f(), p("div", $e, [
1058
+ f.readOnly ? T("", !0) : (y(), x("div", $e, [
1059
1059
  g("div", Te, [
1060
1060
  s[8] || (s[8] = g("span", { class: "label-text" }, "当前标签:", -1)),
1061
1061
  g("div", Pe, [
1062
- (f(!0), p(R, null, F(y.value, (l) => (f(), p("div", {
1062
+ (y(!0), x(B, null, F(m.value, (l) => (y(), x("div", {
1063
1063
  key: l.id,
1064
- class: V(["tag-chip", { active: w.value === l.id }]),
1065
- style: O({ backgroundColor: l.color, borderColor: l.color }),
1066
- onClick: (d) => j(l)
1067
- }, T(l.name), 15, He))), 128)),
1068
- y.value.length === 0 ? (f(), p("div", Le, "请在右侧创建标签")) : $("", !0)
1064
+ class: J(["tag-chip", { active: _.value === l.id }]),
1065
+ style: V({ backgroundColor: l.color, borderColor: l.color }),
1066
+ onClick: (h) => G(l)
1067
+ }, P(l.name), 15, He))), 128)),
1068
+ m.value.length === 0 ? (y(), x("div", Le, "请在右侧创建标签")) : T("", !0)
1069
1069
  ])
1070
1070
  ])
1071
1071
  ])),
1072
1072
  g("div", {
1073
1073
  class: "canvas-wrapper",
1074
1074
  ref_key: "canvasWrapper",
1075
- ref: c,
1075
+ ref: r,
1076
1076
  onWheel: s[2] || (s[2] = qt(() => {
1077
1077
  }, ["prevent"]))
1078
1078
  }, [
1079
1079
  g("canvas", {
1080
1080
  ref_key: "canvasRef",
1081
- ref: r
1081
+ ref: c
1082
1082
  }, null, 512)
1083
1083
  ], 544),
1084
- v.batchImages && v.batchImages.length > 0 ? (f(), p("div", Re, [
1084
+ f.batchImages && f.batchImages.length > 0 ? (y(), x("div", Re, [
1085
1085
  g("button", {
1086
1086
  onClick: It,
1087
1087
  disabled: u.value <= 0
1088
1088
  }, [
1089
- H(P, { name: "back" }),
1090
- s[9] || (s[9] = X(" 上一张 ", -1))
1089
+ L(H, { name: "back" }),
1090
+ s[9] || (s[9] = K(" 上一张 ", -1))
1091
1091
  ], 8, Be),
1092
- g("span", null, T(u.value + 1) + " / " + T(v.batchImages.length), 1),
1092
+ g("span", null, P(u.value + 1) + " / " + P(f.batchImages.length), 1),
1093
1093
  g("button", {
1094
1094
  onClick: kt,
1095
- disabled: u.value >= v.batchImages.length - 1
1095
+ disabled: u.value >= f.batchImages.length - 1
1096
1096
  }, [
1097
- s[10] || (s[10] = X(" 下一张 ", -1)),
1098
- H(P, { name: "right" })
1097
+ s[10] || (s[10] = K(" 下一张 ", -1)),
1098
+ L(H, { name: "right" })
1099
1099
  ], 8, De)
1100
- ])) : $("", !0)
1100
+ ])) : T("", !0)
1101
1101
  ]),
1102
- v.readOnly ? $("", !0) : (f(), p("div", Ue, [
1102
+ f.readOnly ? T("", !0) : (y(), x("div", Ue, [
1103
1103
  g("div", { class: "sidebar-header" }, [
1104
1104
  s[11] || (s[11] = g("h3", null, "标签管理", -1)),
1105
1105
  g("button", {
@@ -1108,36 +1108,36 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1108
1108
  }, "添加标签")
1109
1109
  ]),
1110
1110
  g("div", Fe, [
1111
- (f(!0), p(R, null, F(y.value, (l) => (f(), p("div", {
1111
+ (y(!0), x(B, null, F(m.value, (l) => (y(), x("div", {
1112
1112
  key: l.id,
1113
1113
  class: "label-item"
1114
1114
  }, [
1115
- g("div", Ee, [
1115
+ g("div", Oe, [
1116
1116
  g("label", {
1117
1117
  class: "color-wrapper",
1118
- style: O({ backgroundColor: l.color })
1118
+ style: V({ backgroundColor: l.color })
1119
1119
  }, [
1120
1120
  lt(g("input", {
1121
1121
  type: "color",
1122
- "onUpdate:modelValue": (d) => l.color = d,
1123
- onChange: (d) => Ct(l),
1122
+ "onUpdate:modelValue": (h) => l.color = h,
1123
+ onChange: (h) => Ct(l),
1124
1124
  style: { visibility: "hidden", width: "0", height: "0" }
1125
- }, null, 40, Oe), [
1125
+ }, null, 40, Ee), [
1126
1126
  [rt, l.color]
1127
1127
  ])
1128
1128
  ], 4),
1129
1129
  g("span", {
1130
1130
  class: "label-name",
1131
1131
  title: l.name
1132
- }, T(l.name), 9, Ve),
1132
+ }, P(l.name), 9, Ve),
1133
1133
  g("span", {
1134
1134
  class: "action-icon eye",
1135
- onClick: (d) => At(l)
1135
+ onClick: (h) => At(l)
1136
1136
  }, [
1137
- l.visible ? (f(), ft(P, {
1137
+ l.visible ? (y(), yt(H, {
1138
1138
  key: 0,
1139
1139
  name: "view"
1140
- })) : (f(), ft(P, {
1140
+ })) : (y(), yt(H, {
1141
1141
  key: 1,
1142
1142
  name: "hide"
1143
1143
  }))
@@ -1146,27 +1146,27 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1146
1146
  s[12] || (s[12] = g("span", { class: "dots" }, "•••", -1)),
1147
1147
  g("span", {
1148
1148
  class: "delete-btn",
1149
- onClick: (d) => _t(l.id),
1149
+ onClick: (h) => _t(l.id),
1150
1150
  title: "删除"
1151
1151
  }, [
1152
- H(P, { name: "delete" })
1152
+ L(H, { name: "delete" })
1153
1153
  ], 8, Je)
1154
1154
  ])
1155
1155
  ])
1156
1156
  ]))), 128))
1157
1157
  ])
1158
1158
  ])),
1159
- I.value ? (f(), p("div", je, [
1159
+ U.value ? (y(), x("div", je, [
1160
1160
  g("div", Ye, [
1161
1161
  s[15] || (s[15] = g("h3", null, "新增标签", -1)),
1162
1162
  g("div", Xe, [
1163
1163
  s[13] || (s[13] = g("label", null, "名称", -1)),
1164
1164
  lt(g("input", {
1165
- "onUpdate:modelValue": s[3] || (s[3] = (l) => C.value.name = l),
1165
+ "onUpdate:modelValue": s[3] || (s[3] = (l) => k.value.name = l),
1166
1166
  placeholder: "请输入标签名称",
1167
1167
  class: "modal-input"
1168
1168
  }, null, 512), [
1169
- [rt, C.value.name]
1169
+ [rt, k.value.name]
1170
1170
  ])
1171
1171
  ]),
1172
1172
  g("div", qe, [
@@ -1174,17 +1174,17 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1174
1174
  g("div", Ge, [
1175
1175
  lt(g("input", {
1176
1176
  type: "color",
1177
- "onUpdate:modelValue": s[4] || (s[4] = (l) => C.value.color = l),
1177
+ "onUpdate:modelValue": s[4] || (s[4] = (l) => k.value.color = l),
1178
1178
  class: "modal-color-picker"
1179
1179
  }, null, 512), [
1180
- [rt, C.value.color]
1180
+ [rt, k.value.color]
1181
1181
  ]),
1182
- g("span", null, T(C.value.color), 1)
1182
+ g("span", null, P(k.value.color), 1)
1183
1183
  ])
1184
1184
  ]),
1185
1185
  g("div", { class: "modal-actions" }, [
1186
1186
  g("button", {
1187
- onClick: dt,
1187
+ onClick: gt,
1188
1188
  class: "cancel-btn"
1189
1189
  }, "取消"),
1190
1190
  g("button", {
@@ -1193,98 +1193,100 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1193
1193
  }, "确认")
1194
1194
  ])
1195
1195
  ])
1196
- ])) : $("", !0)
1196
+ ])) : T("", !0)
1197
1197
  ], 2));
1198
1198
  }
1199
- }), Ze = /* @__PURE__ */ Z(Ke, [["__scopeId", "data-v-79777e6e"]]), Qe = {
1199
+ }), Ze = /* @__PURE__ */ et(Ke, [["__scopeId", "data-v-ccc538f3"]]), Qe = {
1200
1200
  class: "thumbnail-wrapper",
1201
1201
  ref: "wrapper"
1202
- }, tn = ["src", "alt"], en = ["viewBox", "preserveAspectRatio"], nn = ["x", "y", "width", "height", "stroke"], sn = ["points", "stroke"], on = ["x", "y", "fill"], an = {
1202
+ }, tn = ["src", "alt"], en = ["viewBox", "preserveAspectRatio"], nn = ["x", "y", "width", "height", "stroke", "stroke-width"], sn = ["points", "stroke", "stroke-width"], on = ["x", "y", "fill", "font-size"], an = {
1203
1203
  key: 1,
1204
1204
  class: "loading-placeholder"
1205
- }, ln = /* @__PURE__ */ K({
1205
+ }, ln = /* @__PURE__ */ tt({
1206
1206
  __name: "AnnotationThumbnail",
1207
1207
  props: {
1208
1208
  src: {},
1209
1209
  annotations: {},
1210
1210
  alt: {},
1211
1211
  labels: {},
1212
- fit: {}
1212
+ fit: {},
1213
+ strokeWidth: {},
1214
+ fontSize: {}
1213
1215
  },
1214
- setup(v) {
1215
- const t = v, i = S(null), e = S(!1), a = S(0), r = S(0), c = () => {
1216
- i.value && (a.value = i.value.naturalWidth, r.value = i.value.naturalHeight, e.value = !0);
1217
- }, o = U(() => t.fit === "contain" ? "xMidYMid meet" : "xMidYMid slice"), h = (w) => {
1216
+ setup(f) {
1217
+ const t = f, i = M(null), e = M(!1), o = M(0), c = M(0), r = () => {
1218
+ i.value && (o.value = i.value.naturalWidth, c.value = i.value.naturalHeight, e.value = !0);
1219
+ }, a = D(() => t.fit === "contain" ? "xMidYMid meet" : "xMidYMid slice"), d = D(() => t.strokeWidth ?? 10), u = D(() => t.fontSize ?? 30), w = (k) => {
1218
1220
  var I;
1219
- if ((I = w.style) != null && I.strokeColor) return w.style.strokeColor;
1221
+ if ((I = k.style) != null && I.strokeColor) return k.style.strokeColor;
1220
1222
  if (t.labels) {
1221
- const C = t.labels.find((B) => B.name === w.label);
1223
+ const C = t.labels.find((R) => R.name === k.label);
1222
1224
  if (C) return C.color;
1223
1225
  }
1224
1226
  return "#FF0000";
1225
- }, u = (w) => {
1226
- const I = w.coordinates, C = Math.min(I.x1, I.x2), B = Math.min(I.y1, I.y2), D = Math.abs(I.x1 - I.x2), L = Math.abs(I.y1 - I.y2);
1227
- return { x: C, y: B, width: D, height: L };
1228
- }, A = (w) => w.coordinates.points.map((C) => `${C.x},${C.y}`).join(" "), y = (w) => {
1229
- if (w.type === "rectangle") {
1230
- const I = u(w);
1227
+ }, m = (k) => {
1228
+ const I = k.coordinates, C = Math.min(I.x1, I.x2), R = Math.min(I.y1, I.y2), N = Math.abs(I.x1 - I.x2), j = Math.abs(I.y1 - I.y2);
1229
+ return { x: C, y: R, width: N, height: j };
1230
+ }, _ = (k) => k.coordinates.points.map((C) => `${C.x},${C.y}`).join(" "), U = (k) => {
1231
+ if (k.type === "rectangle") {
1232
+ const I = m(k);
1231
1233
  return { x: I.x, y: I.y - 5 };
1232
- } else if (w.type === "polygon") {
1233
- const I = w.coordinates.points;
1234
+ } else if (k.type === "polygon") {
1235
+ const I = k.coordinates.points;
1234
1236
  if (I.length > 0) return { x: I[0].x, y: I[0].y - 5 };
1235
1237
  }
1236
1238
  return { x: 0, y: 0 };
1237
1239
  };
1238
- return (w, I) => (f(), p("div", Qe, [
1240
+ return (k, I) => (y(), x("div", Qe, [
1239
1241
  g("img", {
1240
1242
  ref_key: "img",
1241
1243
  ref: i,
1242
- src: v.src,
1244
+ src: f.src,
1243
1245
  class: "thumbnail-image",
1244
- style: O({ objectFit: v.fit }),
1245
- onLoad: c,
1246
- alt: v.alt
1246
+ style: V({ objectFit: f.fit }),
1247
+ onLoad: r,
1248
+ alt: f.alt
1247
1249
  }, null, 44, tn),
1248
- e.value ? (f(), p("svg", {
1250
+ e.value ? (y(), x("svg", {
1249
1251
  key: 0,
1250
1252
  class: "annotation-overlay",
1251
- viewBox: `0 0 ${a.value} ${r.value}`,
1252
- preserveAspectRatio: o.value
1253
+ viewBox: `0 0 ${o.value} ${c.value}`,
1254
+ preserveAspectRatio: a.value
1253
1255
  }, [
1254
- (f(!0), p(R, null, F(v.annotations, (C) => (f(), p(R, {
1256
+ (y(!0), x(B, null, F(f.annotations, (C) => (y(), x(B, {
1255
1257
  key: C.id
1256
1258
  }, [
1257
- C.type === "rectangle" ? (f(), p("rect", {
1259
+ C.type === "rectangle" ? (y(), x("rect", {
1258
1260
  key: 0,
1259
- x: u(C).x,
1260
- y: u(C).y,
1261
- width: u(C).width,
1262
- height: u(C).height,
1263
- stroke: h(C),
1264
- "stroke-width": "2",
1261
+ x: m(C).x,
1262
+ y: m(C).y,
1263
+ width: m(C).width,
1264
+ height: m(C).height,
1265
+ stroke: w(C),
1266
+ "stroke-width": d.value,
1265
1267
  fill: "transparent"
1266
- }, null, 8, nn)) : $("", !0),
1267
- C.type === "polygon" ? (f(), p("polygon", {
1268
+ }, null, 8, nn)) : T("", !0),
1269
+ C.type === "polygon" ? (y(), x("polygon", {
1268
1270
  key: 1,
1269
- points: A(C),
1270
- stroke: h(C),
1271
- "stroke-width": "2",
1271
+ points: _(C),
1272
+ stroke: w(C),
1273
+ "stroke-width": d.value,
1272
1274
  fill: "transparent"
1273
- }, null, 8, sn)) : $("", !0),
1274
- C.label ? (f(), p("text", {
1275
+ }, null, 8, sn)) : T("", !0),
1276
+ C.label ? (y(), x("text", {
1275
1277
  key: 2,
1276
- x: y(C).x,
1277
- y: y(C).y,
1278
- fill: h(C),
1279
- "font-size": "14",
1278
+ x: U(C).x,
1279
+ y: U(C).y,
1280
+ fill: w(C),
1281
+ "font-size": u.value,
1280
1282
  "font-weight": "bold",
1281
1283
  class: "anno-label"
1282
- }, T(C.label), 9, on)) : $("", !0)
1284
+ }, P(C.label), 9, on)) : T("", !0)
1283
1285
  ], 64))), 128))
1284
- ], 8, en)) : (f(), p("div", an, "Loading..."))
1286
+ ], 8, en)) : (y(), x("div", an, "Loading..."))
1285
1287
  ], 512));
1286
1288
  }
1287
- }), rn = /* @__PURE__ */ Z(ln, [["__scopeId", "data-v-c77b0958"]]), cn = {
1289
+ }), rn = /* @__PURE__ */ et(ln, [["__scopeId", "data-v-d2fd08ec"]]), cn = {
1288
1290
  key: 0,
1289
1291
  class: "gallery-view"
1290
1292
  }, hn = { class: "gallery-header" }, dn = { class: "label-summary" }, gn = ["onClick"], un = { class: "thumbnail-wrapper" }, vn = { class: "img-meta" }, mn = { class: "img-index" }, fn = { class: "anno-count" }, yn = {
@@ -1293,163 +1295,174 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1293
1295
  }, pn = {
1294
1296
  key: 1,
1295
1297
  class: "editor-view"
1296
- }, xn = { class: "editor-header" }, bn = { class: "header-left" }, wn = { class: "editor-title" }, Cn = { class: "editor-content" }, An = /* @__PURE__ */ K({
1298
+ }, xn = { class: "editor-header" }, bn = { class: "header-left" }, wn = { class: "editor-title" }, Cn = { class: "editor-content" }, An = /* @__PURE__ */ tt({
1297
1299
  __name: "BatchAnnotator",
1298
1300
  props: {
1299
1301
  images: {},
1300
1302
  labels: {},
1301
1303
  actionBar: {},
1302
- clickToEnterEditor: { type: Boolean }
1304
+ clickToEnterEditor: { type: Boolean },
1305
+ thumbStrokeWidth: {},
1306
+ thumbFontSize: {}
1303
1307
  },
1304
- emits: ["export", "update:images", "imageClick"],
1305
- setup(v, { expose: t, emit: i }) {
1306
- const e = v, a = i, r = S("gallery"), c = S([]), o = S(0), h = S(null), u = S(null), A = S(null), y = U(() => {
1307
- var x, b;
1308
- return ((b = (x = e.actionBar) == null ? void 0 : x.annotateButton) == null ? void 0 : b.show) === !0;
1309
- }), w = U(() => {
1310
- var x, b;
1311
- return ((b = (x = e.actionBar) == null ? void 0 : x.exportButton) == null ? void 0 : b.show) === !0;
1312
- }), I = U(() => y.value || w.value), C = U(() => {
1313
- var x, b;
1314
- return ((b = (x = e.actionBar) == null ? void 0 : x.annotateButton) == null ? void 0 : b.text) || "手动标注";
1315
- }), B = U(() => {
1316
- var x, b;
1317
- return ((b = (x = e.actionBar) == null ? void 0 : x.exportButton) == null ? void 0 : b.text) || "导出";
1318
- }), D = U(() => e.clickToEnterEditor !== !1);
1319
- Y(() => e.images, (x) => {
1320
- c.value = JSON.parse(JSON.stringify(x));
1308
+ emits: ["export", "update:images", "imageClick", "update:labels"],
1309
+ setup(f, { expose: t, emit: i }) {
1310
+ const e = f, o = i, c = M("gallery"), r = M([]), a = M([]), d = M(0), u = M(null), w = M(null), m = M(null), _ = D(() => {
1311
+ var p, b;
1312
+ return ((b = (p = e.actionBar) == null ? void 0 : p.annotateButton) == null ? void 0 : b.show) === !0;
1313
+ }), U = D(() => {
1314
+ var p, b;
1315
+ return ((b = (p = e.actionBar) == null ? void 0 : p.exportButton) == null ? void 0 : b.show) === !0;
1316
+ }), k = D(() => _.value || U.value), I = D(() => {
1317
+ var p, b;
1318
+ return ((b = (p = e.actionBar) == null ? void 0 : p.annotateButton) == null ? void 0 : b.text) || "手动标注";
1319
+ }), C = D(() => {
1320
+ var p, b;
1321
+ return ((b = (p = e.actionBar) == null ? void 0 : p.exportButton) == null ? void 0 : b.text) || "导出";
1322
+ }), R = D(() => e.clickToEnterEditor !== !1);
1323
+ Y(() => e.images, (p) => {
1324
+ r.value = JSON.parse(JSON.stringify(p));
1325
+ }, { immediate: !0, deep: !0 }), Y(() => e.labels, (p) => {
1326
+ a.value = JSON.parse(JSON.stringify(p || []));
1321
1327
  }, { immediate: !0, deep: !0 });
1322
- const L = (x) => {
1323
- o.value = x, r.value = "editor", A.value && (A.value.scrollTop = 0), Gt(() => {
1324
- u.value && (u.value.scrollTop = 0), window.scrollTo(0, 0), requestAnimationFrame(() => {
1325
- var b, M;
1326
- (M = (b = h.value) == null ? void 0 : b.jumpTo) == null || M.call(b, x);
1328
+ const N = (p) => {
1329
+ d.value = p, c.value = "editor", m.value && (m.value.scrollTop = 0), Gt(() => {
1330
+ w.value && (w.value.scrollTop = 0), window.scrollTo(0, 0), requestAnimationFrame(() => {
1331
+ var b, z;
1332
+ (z = (b = u.value) == null ? void 0 : b.jumpTo) == null || z.call(b, p);
1327
1333
  });
1328
1334
  });
1329
- }, Q = (x, b) => {
1330
- if (D.value) {
1331
- L(x);
1335
+ }, j = (p, b) => {
1336
+ if (R.value) {
1337
+ N(p);
1332
1338
  return;
1333
1339
  }
1334
- a("imageClick", { index: x, imageId: b.id, image: b });
1335
- }, J = (x) => c.value.findIndex((b) => b.id === x);
1340
+ o("imageClick", { index: p, imageId: b.id, image: b });
1341
+ }, X = (p) => r.value.findIndex((b) => b.id === p);
1336
1342
  t({
1337
- openImageById: (x) => {
1338
- const b = J(x);
1339
- return b < 0 ? !1 : (L(b), !0);
1343
+ openImageById: (p) => {
1344
+ const b = X(p);
1345
+ return b < 0 ? !1 : (N(b), !0);
1340
1346
  },
1341
- triggerImageClickById: (x) => {
1342
- const b = J(x);
1347
+ triggerImageClickById: (p) => {
1348
+ const b = X(p);
1343
1349
  if (b < 0)
1344
1350
  return !1;
1345
- const M = c.value[b];
1346
- return M ? (a("imageClick", { index: b, imageId: M.id, image: M }), !0) : !1;
1347
- }
1351
+ const z = r.value[b];
1352
+ return z ? (o("imageClick", { index: b, imageId: z.id, image: z }), !0) : !1;
1353
+ },
1354
+ getFinalData: () => ({
1355
+ images: JSON.parse(JSON.stringify(r.value)),
1356
+ labels: JSON.parse(JSON.stringify(a.value))
1357
+ })
1348
1358
  });
1349
- const et = () => {
1350
- if (h.value && h.value.getCurrentAnnotation) {
1351
- const x = h.value.getCurrentAnnotation();
1352
- c.value[o.value] && (c.value[o.value].annotations = x.annotations);
1359
+ const nt = () => {
1360
+ if (u.value && u.value.getCurrentAnnotation) {
1361
+ const p = u.value.getCurrentAnnotation();
1362
+ r.value[d.value] && (r.value[d.value].annotations = p.annotations);
1353
1363
  }
1354
- r.value = "gallery";
1355
- }, nt = () => {
1356
- a("export", c.value);
1357
- }, st = (x) => {
1358
- o.value = x.currentIndex, c.value[x.currentIndex] && (c.value[x.currentIndex].annotations = x.currentAnnotations);
1359
- }, it = (x) => {
1360
- if (h.value && h.value.getCurrentAnnotation) {
1361
- const b = h.value.getCurrentAnnotation();
1362
- c.value[o.value] && (c.value[o.value].annotations = b.annotations, a("update:images", c.value));
1364
+ c.value = "gallery";
1365
+ }, st = () => {
1366
+ o("export", r.value);
1367
+ }, it = (p) => {
1368
+ d.value = p.currentIndex, r.value[p.currentIndex] && (r.value[p.currentIndex].annotations = p.currentAnnotations);
1369
+ }, E = (p) => {
1370
+ if (u.value && u.value.getCurrentAnnotation) {
1371
+ const b = u.value.getCurrentAnnotation();
1372
+ r.value[d.value] && (r.value[d.value].annotations = b.annotations, o("update:images", r.value));
1363
1373
  }
1364
- }, N = (x) => {
1374
+ }, W = (p) => {
1375
+ a.value = JSON.parse(JSON.stringify(p || [])), o("update:labels", a.value);
1365
1376
  };
1366
- return (x, b) => (f(), p("div", {
1377
+ return (p, b) => (y(), x("div", {
1367
1378
  ref_key: "batchRootRef",
1368
- ref: u,
1379
+ ref: w,
1369
1380
  class: "batch-annotator"
1370
1381
  }, [
1371
- r.value === "gallery" ? (f(), p("div", cn, [
1382
+ c.value === "gallery" ? (y(), x("div", cn, [
1372
1383
  g("div", hn, [
1373
- g("h3", null, "批量查看与标注 (" + T(c.value.length) + " 张)", 1),
1384
+ g("h3", null, "批量查看与标注 (" + P(r.value.length) + " 张)", 1),
1374
1385
  g("div", dn, [
1375
- (f(!0), p(R, null, F(v.labels, (M) => (f(), p("span", {
1376
- key: M.id,
1386
+ (y(!0), x(B, null, F(a.value, (z) => (y(), x("span", {
1387
+ key: z.id,
1377
1388
  class: "label-badge",
1378
- style: O({ backgroundColor: M.color })
1379
- }, T(M.name), 5))), 128))
1389
+ style: V({ backgroundColor: z.color })
1390
+ }, P(z.name), 5))), 128))
1380
1391
  ])
1381
1392
  ]),
1382
1393
  g("div", {
1383
1394
  ref_key: "galleryGridRef",
1384
- ref: A,
1395
+ ref: m,
1385
1396
  class: "gallery-grid"
1386
1397
  }, [
1387
- (f(!0), p(R, null, F(c.value, (M, W) => (f(), p("div", {
1388
- key: W,
1398
+ (y(!0), x(B, null, F(r.value, (z, q) => (y(), x("div", {
1399
+ key: q,
1389
1400
  class: "gallery-item",
1390
- onClick: (ht) => Q(W, M)
1401
+ onClick: (dt) => j(q, z)
1391
1402
  }, [
1392
1403
  g("div", un, [
1393
- H(rn, {
1394
- src: M.imageUrl,
1395
- annotations: M.annotations || [],
1396
- labels: v.labels,
1397
- fit: "cover"
1398
- }, null, 8, ["src", "annotations", "labels"])
1404
+ L(rn, {
1405
+ src: z.imageUrl,
1406
+ annotations: z.annotations || [],
1407
+ labels: a.value,
1408
+ fit: "cover",
1409
+ strokeWidth: e.thumbStrokeWidth,
1410
+ fontSize: e.thumbFontSize
1411
+ }, null, 8, ["src", "annotations", "labels", "strokeWidth", "fontSize"])
1399
1412
  ]),
1400
1413
  g("div", vn, [
1401
- g("span", mn, "#" + T(W + 1), 1),
1402
- g("span", fn, T((M.annotations || []).length) + " 标注", 1)
1414
+ g("span", mn, "#" + P(q + 1), 1),
1415
+ g("span", fn, P((z.annotations || []).length) + " 标注", 1)
1403
1416
  ])
1404
1417
  ], 8, gn))), 128))
1405
1418
  ], 512),
1406
- I.value ? (f(), p("div", yn, [
1407
- y.value ? (f(), p("button", {
1419
+ k.value ? (y(), x("div", yn, [
1420
+ _.value ? (y(), x("button", {
1408
1421
  key: 0,
1409
1422
  class: "action-btn primary",
1410
- onClick: b[0] || (b[0] = (M) => L(0))
1423
+ onClick: b[0] || (b[0] = (z) => N(0))
1411
1424
  }, [
1412
- H(P, { name: "edit" }),
1413
- X(" " + T(C.value), 1)
1414
- ])) : $("", !0),
1415
- w.value ? (f(), p("button", {
1425
+ L(H, { name: "edit" }),
1426
+ K(" " + P(I.value), 1)
1427
+ ])) : T("", !0),
1428
+ U.value ? (y(), x("button", {
1416
1429
  key: 1,
1417
1430
  class: "action-btn success",
1418
- onClick: nt
1431
+ onClick: st
1419
1432
  }, [
1420
- H(P, { name: "download" }),
1421
- X(" " + T(B.value), 1)
1422
- ])) : $("", !0)
1423
- ])) : $("", !0)
1424
- ])) : (f(), p("div", pn, [
1433
+ L(H, { name: "download" }),
1434
+ K(" " + P(C.value), 1)
1435
+ ])) : T("", !0)
1436
+ ])) : T("", !0)
1437
+ ])) : (y(), x("div", pn, [
1425
1438
  g("div", xn, [
1426
1439
  g("div", bn, [
1427
1440
  g("button", {
1428
1441
  class: "back-btn",
1429
- onClick: et
1442
+ onClick: nt
1430
1443
  }, [
1431
- H(P, { name: "back" }),
1432
- b[1] || (b[1] = X(" 返回列表 ", -1))
1444
+ L(H, { name: "back" }),
1445
+ b[1] || (b[1] = K(" 返回列表 ", -1))
1433
1446
  ]),
1434
- g("span", wn, "正在标注: " + T(o.value + 1) + " / " + T(c.value.length), 1)
1447
+ g("span", wn, "正在标注: " + P(d.value + 1) + " / " + P(r.value.length), 1)
1435
1448
  ])
1436
1449
  ]),
1437
1450
  g("div", Cn, [
1438
- H(Ze, {
1451
+ L(Ze, {
1439
1452
  ref_key: "annotatorRef",
1440
- ref: h,
1441
- batchImages: c.value,
1442
- labels: v.labels,
1453
+ ref: u,
1454
+ batchImages: r.value,
1455
+ labels: a.value,
1443
1456
  annotationTypes: ["rectangle", "polygon", "point", "rotatedRect"],
1444
- onBatchChange: st,
1445
- onAnnotationChange: it,
1446
- onLabelChange: N
1457
+ onBatchChange: it,
1458
+ onAnnotationChange: E,
1459
+ onLabelChange: W
1447
1460
  }, null, 8, ["batchImages", "labels"])
1448
1461
  ])
1449
1462
  ]))
1450
1463
  ], 512));
1451
1464
  }
1452
- }), kn = /* @__PURE__ */ Z(An, [["__scopeId", "data-v-16638a5c"]]);
1465
+ }), kn = /* @__PURE__ */ et(An, [["__scopeId", "data-v-0ae1040a"]]);
1453
1466
  export {
1454
1467
  kn as BatchAnnotator,
1455
1468
  Ze as ImageAnnotator,