@frigate-nvr/image-annotator 1.0.0

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 (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -0
  3. package/dist/_commonjsHelpers-DjF3Plf2.js +27 -0
  4. package/dist/_commonjsHelpers-DjF3Plf2.js.map +1 -0
  5. package/dist/assets/Button.css +1 -0
  6. package/dist/assets/FormElement.css +1 -0
  7. package/dist/assets/FormElementBox.css +1 -0
  8. package/dist/components/BoundingBox.js +2553 -0
  9. package/dist/components/BoundingBox.js.map +1 -0
  10. package/dist/components/Button.js +45 -0
  11. package/dist/components/Button.js.map +1 -0
  12. package/dist/components/Crosshairs.js +58 -0
  13. package/dist/components/Crosshairs.js.map +1 -0
  14. package/dist/components/FormElement.js +13 -0
  15. package/dist/components/FormElement.js.map +1 -0
  16. package/dist/components/FormElementBox.js +18 -0
  17. package/dist/components/FormElementBox.js.map +1 -0
  18. package/dist/components/ImageAnnotator.js +642 -0
  19. package/dist/components/ImageAnnotator.js.map +1 -0
  20. package/dist/components/InfoDialog.js +25 -0
  21. package/dist/components/InfoDialog.js.map +1 -0
  22. package/dist/components/LabelDialog.js +27 -0
  23. package/dist/components/LabelDialog.js.map +1 -0
  24. package/dist/components/VerifyDialog.js +34 -0
  25. package/dist/components/VerifyDialog.js.map +1 -0
  26. package/dist/components/index.js +22 -0
  27. package/dist/components/index.js.map +1 -0
  28. package/dist/dialog-DrJOKYL3.js +1128 -0
  29. package/dist/dialog-DrJOKYL3.js.map +1 -0
  30. package/dist/index-sN46tOW-.js +43 -0
  31. package/dist/index-sN46tOW-.js.map +1 -0
  32. package/dist/index.d.ts +176 -0
  33. package/dist/index.esm-FeyXGhGs.js +916 -0
  34. package/dist/index.esm-FeyXGhGs.js.map +1 -0
  35. package/dist/index.js +22 -0
  36. package/dist/index.js.map +1 -0
  37. package/package.json +70 -0
@@ -0,0 +1,642 @@
1
+ import { jsxs as D, Fragment as oe, jsx as i } from "react/jsx-runtime";
2
+ import { useRef as B, useEffect as te, useMemo as ce, useState as O, Fragment as ae } from "react";
3
+ import { Button as v } from "./Button.js";
4
+ import { Crosshairs as se } from "./Crosshairs.js";
5
+ import { InfoDialog as de } from "./InfoDialog.js";
6
+ import { LabelDialog as ue } from "./LabelDialog.js";
7
+ import { VerifyDialog as Z } from "./VerifyDialog.js";
8
+ import { FormElement as he } from "./FormElement.js";
9
+ import { FormElementBox as fe } from "./FormElementBox.js";
10
+ import { BoundingBox as ee, BoundingBoxType as q } from "./BoundingBox.js";
11
+ import { T as me, a as we } from "../index.esm-FeyXGhGs.js";
12
+ function ge(a, y, d) {
13
+ var f = this, g = B(null), L = B(0), e = B(null), o = B([]), p = B(), b = B(), M = B(a), k = B(!0);
14
+ M.current = a;
15
+ var A = typeof window < "u", T = !y && y !== 0 && A;
16
+ if (typeof a != "function") throw new TypeError("Expected a function");
17
+ y = +y || 0;
18
+ var I = !!(d = d || {}).leading, X = !("trailing" in d) || !!d.trailing, N = "maxWait" in d, j = "debounceOnServer" in d && !!d.debounceOnServer, W = N ? Math.max(+d.maxWait || 0, y) : null;
19
+ te(function() {
20
+ return k.current = !0, function() {
21
+ k.current = !1;
22
+ };
23
+ }, []);
24
+ var V = ce(function() {
25
+ var F = function(u) {
26
+ var m = o.current, R = p.current;
27
+ return o.current = p.current = null, L.current = u, b.current = M.current.apply(R, m);
28
+ }, S = function(u, m) {
29
+ T && cancelAnimationFrame(e.current), e.current = T ? requestAnimationFrame(u) : setTimeout(u, m);
30
+ }, _ = function(u) {
31
+ if (!k.current) return !1;
32
+ var m = u - g.current;
33
+ return !g.current || m >= y || m < 0 || N && u - L.current >= W;
34
+ }, U = function(u) {
35
+ return e.current = null, X && o.current ? F(u) : (o.current = p.current = null, b.current);
36
+ }, P = function u() {
37
+ var m = Date.now();
38
+ if (_(m)) return U(m);
39
+ if (k.current) {
40
+ var R = y - (m - g.current), C = N ? Math.min(R, W - (m - L.current)) : R;
41
+ S(u, C);
42
+ }
43
+ }, z = function() {
44
+ if (A || j) {
45
+ var u = Date.now(), m = _(u);
46
+ if (o.current = [].slice.call(arguments), p.current = f, g.current = u, m) {
47
+ if (!e.current && k.current) return L.current = g.current, S(P, y), I ? F(g.current) : b.current;
48
+ if (N) return S(P, y), F(g.current);
49
+ }
50
+ return e.current || S(P, y), b.current;
51
+ }
52
+ };
53
+ return z.cancel = function() {
54
+ e.current && (T ? cancelAnimationFrame(e.current) : clearTimeout(e.current)), L.current = 0, o.current = g.current = p.current = e.current = null;
55
+ }, z.isPending = function() {
56
+ return !!e.current;
57
+ }, z.flush = function() {
58
+ return e.current ? U(Date.now()) : b.current;
59
+ }, z;
60
+ }, [I, N, y, W, X, T, A, j]);
61
+ return V;
62
+ }
63
+ const ke = (a) => {
64
+ var G;
65
+ const y = [
66
+ { codes: ["?"], action: "Shortcut help" },
67
+ { codes: ["w"], action: "Add Box" },
68
+ { codes: ["d"], action: "Mark Difficult" },
69
+ { codes: ["s"], action: "Cycle Label" },
70
+ { codes: ["Tab"], action: "Select Next Box" },
71
+ { codes: ["Del"], action: "Delete Box" },
72
+ { codes: ["Esc"], action: "Deselect/Cancel" },
73
+ { codes: ["← ↑ → ↓"], action: "Move Box" },
74
+ { codes: ["Shift", "← ↑ → ↓"], action: "Resize Box" },
75
+ { codes: ["f"], action: "Toggle Unselected Boxes" },
76
+ { codes: ["Spacebar"], action: "Verify and Save" }
77
+ ], [d, f] = O([]), [g, L] = O([]), [e, o] = O({
78
+ createMode: !1,
79
+ drawingMode: !1,
80
+ showBoxes: !0,
81
+ showLabeler: !1,
82
+ showHelp: !1,
83
+ showVerify: !1,
84
+ showDelete: !1,
85
+ showConfirmDeleteFalsePositive: !1,
86
+ showTutorial: a.userAnnotationCount === 0,
87
+ drawStartX: 0,
88
+ drawStartY: 0,
89
+ selectedLabel: a.labels[0],
90
+ difficult: !1,
91
+ width: 1,
92
+ height: 1
93
+ }), p = B(null), b = B(null), M = B(null), k = () => {
94
+ var w, x, H, K;
95
+ let t = 4;
96
+ const r = ((w = p.current) == null ? void 0 : w.naturalHeight) ?? 0, n = ((x = p.current) == null ? void 0 : x.naturalWidth) ?? 0, c = Math.round(r * t), l = ((H = b.current) == null ? void 0 : H.getBoundingClientRect().height) ?? 0;
97
+ c > l - 10 && (t = (l - 10) / r);
98
+ const h = Math.round(n * t), s = ((K = b.current) == null ? void 0 : K.getBoundingClientRect().width) ?? 0;
99
+ h > s - 10 && (t = (s - 10) / n), o({
100
+ ...e,
101
+ width: Math.round(n * t),
102
+ height: Math.round(r * t)
103
+ });
104
+ }, A = ge(() => {
105
+ k();
106
+ }, 200);
107
+ te(() => {
108
+ var t, r;
109
+ return window.addEventListener("resize", A), (r = (t = b.current) == null ? void 0 : t.parentElement) == null || r.focus(), () => {
110
+ window.removeEventListener("resize", A);
111
+ };
112
+ }, [A]);
113
+ const T = (t, r, n) => {
114
+ f(
115
+ (c) => c.map((l) => l.id === n ? {
116
+ ...l,
117
+ x: r.x / e.width,
118
+ y: r.y / e.height,
119
+ w: t.offsetWidth / e.width,
120
+ h: t.offsetHeight / e.height
121
+ } : l)
122
+ );
123
+ }, I = (t, r) => {
124
+ f(
125
+ (n) => n.map((c) => c.id === r ? {
126
+ ...c,
127
+ x: t.x / e.width,
128
+ y: t.y / e.height
129
+ } : c)
130
+ );
131
+ }, X = (t) => {
132
+ var r, n;
133
+ if (e.createMode) {
134
+ const c = ((r = M.current) == null ? void 0 : r.instance.transformState.scale) ?? 1, l = (n = p.current) == null ? void 0 : n.getBoundingClientRect(), h = (t.clientX - ((l == null ? void 0 : l.left) ?? 0)) / c / e.width, s = (t.clientY - ((l == null ? void 0 : l.top) ?? 0)) / c / e.height;
135
+ o({
136
+ ...e,
137
+ drawingMode: !0,
138
+ drawStartX: h,
139
+ drawStartY: s,
140
+ selectedBox: "draft"
141
+ }), f((w) => [
142
+ ...w,
143
+ {
144
+ id: "draft",
145
+ x: h,
146
+ y: s,
147
+ w: 0,
148
+ h: 0
149
+ }
150
+ ]);
151
+ } else
152
+ o({ ...e, selectedBox: void 0 });
153
+ }, N = (t) => {
154
+ if (e.drawingMode) {
155
+ const r = Date.now().toString();
156
+ o({
157
+ ...e,
158
+ drawingMode: !1,
159
+ createMode: !1,
160
+ selectedBox: r
161
+ }), f(
162
+ (n) => n.reduce((c, l) => {
163
+ var h, s;
164
+ if (l.id === "draft") {
165
+ const w = ((h = M.current) == null ? void 0 : h.instance.transformState.scale) ?? 1, x = (s = p.current) == null ? void 0 : s.getBoundingClientRect(), H = (t.clientX - ((x == null ? void 0 : x.left) ?? 0)) / w / e.width, K = (t.clientY - ((x == null ? void 0 : x.top) ?? 0)) / w / e.height;
166
+ if (Math.min(
167
+ Math.abs(e.drawStartX - H),
168
+ Math.abs(e.drawStartY - K)
169
+ ) > 1e-3) {
170
+ let Y = Math.min(e.drawStartX, H), E = Math.min(e.drawStartY, K), J = Math.abs(e.drawStartX - H), Q = Math.abs(e.drawStartY - K);
171
+ Y < 0 && (J -= Math.abs(Y), Y = 0), E < 0 && (Q -= Math.abs(E), E = 0), c.push({
172
+ ...l,
173
+ id: r,
174
+ label: e.selectedLabel,
175
+ difficult: !1,
176
+ x: Y,
177
+ y: E,
178
+ w: Math.min(1 - Y, J),
179
+ h: Math.min(1 - E, Q)
180
+ });
181
+ }
182
+ } else
183
+ c.push(l);
184
+ return c;
185
+ }, [])
186
+ );
187
+ }
188
+ }, j = (t) => {
189
+ e.drawingMode && f(
190
+ (r) => r.map((n) => {
191
+ var c, l;
192
+ if (n.id === "draft") {
193
+ const h = ((c = M.current) == null ? void 0 : c.instance.transformState.scale) ?? 1, s = (l = p.current) == null ? void 0 : l.getBoundingClientRect(), w = (t.pageX - ((s == null ? void 0 : s.left) ?? 0)) / h / e.width, x = (t.pageY - ((s == null ? void 0 : s.top) ?? 0)) / h / e.height;
194
+ return {
195
+ ...n,
196
+ x: Math.min(e.drawStartX, w),
197
+ y: Math.min(e.drawStartY, x),
198
+ w: Math.abs(e.drawStartX - w),
199
+ h: Math.abs(e.drawStartY - x)
200
+ };
201
+ }
202
+ return n;
203
+ })
204
+ );
205
+ }, W = () => {
206
+ o({ ...e, createMode: !e.createMode });
207
+ }, V = (t) => {
208
+ const r = d.find((n) => n.id === t);
209
+ o({
210
+ ...e,
211
+ selectedBox: t,
212
+ selectedLabel: (r == null ? void 0 : r.label) ?? e.selectedLabel,
213
+ difficult: (r == null ? void 0 : r.difficult) ?? e.difficult
214
+ });
215
+ }, F = (t, r, n) => {
216
+ f(
217
+ (c) => c.map((l) => l.id === t ? {
218
+ ...l,
219
+ x: Math.min(
220
+ 1 - l.w,
221
+ Math.max(0, l.x + n / e.width)
222
+ ),
223
+ y: Math.min(
224
+ 1 - l.h,
225
+ Math.max(0, l.y + r / e.height)
226
+ )
227
+ } : l)
228
+ );
229
+ }, S = (t, r, n) => {
230
+ f(
231
+ (c) => c.map((l) => l.id === t ? {
232
+ ...l,
233
+ w: Math.min(1 - l.x, l.w + n / e.width),
234
+ h: Math.min(1 - l.y, l.h + r / e.height)
235
+ } : l)
236
+ );
237
+ }, _ = (t) => {
238
+ f(
239
+ (r) => r.map((n) => n.id === t ? {
240
+ ...n,
241
+ difficult: !n.difficult
242
+ } : n)
243
+ );
244
+ }, U = (t, r = !1) => {
245
+ const n = a.labels.findIndex(
246
+ (s) => e.selectedLabel === s
247
+ ), c = a.labels.length - 1;
248
+ let l = 0;
249
+ r ? l = n === 0 ? c : n - 1 : l = n === c ? 0 : n + 1;
250
+ const h = a.labels[l];
251
+ f(
252
+ (s) => s.map((w) => w.id === t ? {
253
+ ...w,
254
+ label: h
255
+ } : w)
256
+ ), o({ ...e, selectedLabel: h });
257
+ }, P = (t) => {
258
+ f((r) => r.filter((n) => n.id !== t));
259
+ }, z = (t) => {
260
+ L((r) => r.filter((n) => n.id !== t));
261
+ }, u = (t) => {
262
+ var r;
263
+ return (r = g.find((n) => n.id === t)) == null ? void 0 : r.label;
264
+ }, m = (t) => d.find((r) => r.id === t), R = (t) => {
265
+ if (!t)
266
+ return d[0].id;
267
+ const r = d.findIndex((n) => n.id === t);
268
+ return r === d.length - 1 ? d[0].id : d[r + 1].id;
269
+ }, C = 5 / (((G = M.current) == null ? void 0 : G.instance.transformState.scale) ?? 1), ne = (t) => {
270
+ if (t.code === "Escape" && (e.createMode ? o({ ...e, createMode: !1 }) : o({ ...e, selectedBox: void 0 })), t.code === "KeyW" && (e.createMode ? o({ ...e, createMode: !1 }) : o({ ...e, createMode: !0, selectedBox: void 0 })), t.code === "KeyF" && o({ ...e, showBoxes: !e.showBoxes }), t.code === "KeyD" && e.selectedBox && _(e.selectedBox), t.code === "KeyS" && e.selectedBox && U(e.selectedBox, t.shiftKey), t.code === "Delete" && e.selectedBox && (P(e.selectedBox), o({ ...e, selectedBox: void 0 })), t.code === "Tab") {
271
+ const r = R(e.selectedBox), n = m(r);
272
+ o({
273
+ ...e,
274
+ selectedBox: r,
275
+ selectedLabel: (n == null ? void 0 : n.label) ?? e.selectedLabel
276
+ }), t.preventDefault();
277
+ }
278
+ t.code === "Space" && a.save(d, g.length === 0, a.labels), t.code === "Slash" && t.shiftKey && o({ ...e, showHelp: !0 }), e.selectedBox && (t.code === "ArrowLeft" && (t.shiftKey ? S(e.selectedBox, 0, -C) : F(e.selectedBox, 0, -C)), t.code === "ArrowRight" && (t.shiftKey ? S(e.selectedBox, 0, C) : F(e.selectedBox, 0, C)), t.code === "ArrowUp" && (t.shiftKey ? S(e.selectedBox, -C, 0) : F(e.selectedBox, -C, 0)), t.code === "ArrowDown" && (t.shiftKey ? S(e.selectedBox, C, 0) : F(e.selectedBox, C, 0)));
279
+ }, re = (t) => {
280
+ k(), f(
281
+ a.annotations.concat(a.suggestions).sort((r, n) => n.w * n.h - r.w * r.h)
282
+ ), L(a.falsePositives.sort((r, n) => n.w * n.h - r.w * r.h));
283
+ }, ie = () => {
284
+ o({ ...e, showLabeler: !1 }), f(
285
+ (t) => t.map((r) => r.id === e.selectedBox ? {
286
+ ...r,
287
+ label: e.selectedLabel,
288
+ difficult: e.difficult
289
+ } : r)
290
+ );
291
+ }, le = () => {
292
+ o({ ...e, showLabeler: !1 }), f((t) => t.filter((r) => r.label));
293
+ }, $ = e.showBoxes ? 0 : -1;
294
+ return /* @__PURE__ */ D(oe, { children: [
295
+ /* @__PURE__ */ i(me, { ref: M, disabled: e.createMode || e.drawingMode, children: ({ zoomIn: t, zoomOut: r }) => /* @__PURE__ */ D(
296
+ "div",
297
+ {
298
+ className: "flex h-screen min-w-[600px] flex-col overflow-hidden bg-slate-900",
299
+ onKeyDown: ne,
300
+ tabIndex: 0,
301
+ children: [
302
+ /* @__PURE__ */ D("div", { className: "flex flex-initial bg-slate-300 p-1", children: [
303
+ /* @__PURE__ */ i("div", { className: "flex-initial", children: /* @__PURE__ */ i("button", { type: "button", onClick: a.back, children: /* @__PURE__ */ i(v, { secondary: !0, sm: !0, children: "Back" }) }) }),
304
+ /* @__PURE__ */ D("div", { className: "flex flex-auto justify-center", children: [
305
+ /* @__PURE__ */ i(
306
+ "button",
307
+ {
308
+ type: "button",
309
+ onClick: () => {
310
+ r();
311
+ },
312
+ children: /* @__PURE__ */ i(v, { children: /* @__PURE__ */ i(
313
+ "svg",
314
+ {
315
+ xmlns: "http://www.w3.org/2000/svg",
316
+ className: "h-6 w-6",
317
+ fill: "none",
318
+ viewBox: "0 0 24 24",
319
+ stroke: "currentColor",
320
+ children: /* @__PURE__ */ i(
321
+ "path",
322
+ {
323
+ strokeLinecap: "round",
324
+ strokeLinejoin: "round",
325
+ strokeWidth: "2",
326
+ d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM13 10H7"
327
+ }
328
+ )
329
+ }
330
+ ) })
331
+ }
332
+ ),
333
+ /* @__PURE__ */ i(
334
+ "button",
335
+ {
336
+ type: "button",
337
+ onClick: () => {
338
+ t();
339
+ },
340
+ children: /* @__PURE__ */ i(v, { children: /* @__PURE__ */ i(
341
+ "svg",
342
+ {
343
+ xmlns: "http://www.w3.org/2000/svg",
344
+ className: "h-6 w-6",
345
+ fill: "none",
346
+ viewBox: "0 0 24 24",
347
+ stroke: "currentColor",
348
+ children: /* @__PURE__ */ i(
349
+ "path",
350
+ {
351
+ strokeLinecap: "round",
352
+ strokeLinejoin: "round",
353
+ strokeWidth: "2",
354
+ d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"
355
+ }
356
+ )
357
+ }
358
+ ) })
359
+ }
360
+ ),
361
+ /* @__PURE__ */ i("button", { type: "button", onClick: W, children: /* @__PURE__ */ i(v, { secondary: !0, sm: !0, children: "Add (w)" }) })
362
+ ] }),
363
+ /* @__PURE__ */ D("div", { className: "flex-initial", children: [
364
+ /* @__PURE__ */ i(
365
+ "button",
366
+ {
367
+ onClick: () => {
368
+ o({ ...e, showVerify: !0 });
369
+ },
370
+ children: /* @__PURE__ */ i(v, { sm: !0, children: "Verify & Save" })
371
+ }
372
+ ),
373
+ /* @__PURE__ */ i(
374
+ "button",
375
+ {
376
+ onClick: () => {
377
+ a.save(d, g.length === 0, []);
378
+ },
379
+ children: /* @__PURE__ */ i(v, { green: !0, sm: !0, children: "Save" })
380
+ }
381
+ ),
382
+ /* @__PURE__ */ i(
383
+ "button",
384
+ {
385
+ onClick: () => {
386
+ o({ ...e, showDelete: !0 });
387
+ },
388
+ children: /* @__PURE__ */ i(v, { red: !0, sm: !0, children: "Delete" })
389
+ }
390
+ ),
391
+ /* @__PURE__ */ i(
392
+ "button",
393
+ {
394
+ onClick: () => {
395
+ o({ ...e, showHelp: !0 });
396
+ },
397
+ children: /* @__PURE__ */ i(v, { sm: !0, secondary: !0, children: "?" })
398
+ }
399
+ )
400
+ ] })
401
+ ] }),
402
+ /* @__PURE__ */ i(
403
+ "div",
404
+ {
405
+ ref: b,
406
+ className: "grid flex-auto place-content-center",
407
+ children: /* @__PURE__ */ i(we, { children: /* @__PURE__ */ D(
408
+ "div",
409
+ {
410
+ className: "grid place-content-center",
411
+ onMouseDown: X,
412
+ onMouseUp: N,
413
+ onMouseMove: j,
414
+ children: [
415
+ /* @__PURE__ */ i(
416
+ "img",
417
+ {
418
+ ref: p,
419
+ className: "col-start-1 row-start-1 h-full w-full",
420
+ alt: "annotate",
421
+ src: a.imageUrl,
422
+ onLoad: re,
423
+ style: {
424
+ width: e.width,
425
+ height: e.height
426
+ }
427
+ }
428
+ ),
429
+ g.map((n) => {
430
+ var c;
431
+ return /* @__PURE__ */ i(
432
+ ee,
433
+ {
434
+ type: q.falsePositive,
435
+ label: n.label ?? "",
436
+ zIndex: n.id === e.selectedBox ? 1 : $,
437
+ x: n.x * e.width,
438
+ y: n.y * e.height,
439
+ w: n.w * e.width,
440
+ h: n.h * e.height,
441
+ initialScale: (c = M.current) == null ? void 0 : c.instance.transformState.scale,
442
+ selected: n.id === e.selectedBox,
443
+ onMouseDown: (l) => {
444
+ e.createMode || (V(n.id), l.stopPropagation());
445
+ },
446
+ onClickDelete: () => {
447
+ o({
448
+ ...e,
449
+ showConfirmDeleteFalsePositive: !0
450
+ });
451
+ }
452
+ },
453
+ n.id
454
+ );
455
+ }),
456
+ d.map((n) => {
457
+ var c;
458
+ return /* @__PURE__ */ i(
459
+ ee,
460
+ {
461
+ type: n.suggestion ? q.suggestion : q.truePositive,
462
+ label: n.label ?? "",
463
+ difficult: n.difficult,
464
+ zIndex: n.id === e.selectedBox ? 1 : $,
465
+ x: n.x * e.width,
466
+ y: n.y * e.height,
467
+ w: n.w * e.width,
468
+ h: n.h * e.height,
469
+ initialScale: (c = M.current) == null ? void 0 : c.instance.transformState.scale,
470
+ selected: n.id === e.selectedBox,
471
+ onMouseDown: (l) => {
472
+ e.createMode || (V(n.id), l.stopPropagation());
473
+ },
474
+ onDragStop: (l, h) => {
475
+ I(h, n.id);
476
+ },
477
+ onResizeStop: (l, h, s, w, x) => {
478
+ T(s, x, n.id);
479
+ },
480
+ onClickDelete: () => {
481
+ P(n.id);
482
+ },
483
+ onClickEdit: () => {
484
+ o({ ...e, showLabeler: !0 });
485
+ }
486
+ },
487
+ n.id
488
+ );
489
+ }),
490
+ /* @__PURE__ */ i(
491
+ se,
492
+ {
493
+ className: "col-start-1 row-start-1",
494
+ show: e.createMode && !e.drawingMode
495
+ }
496
+ )
497
+ ]
498
+ }
499
+ ) })
500
+ }
501
+ )
502
+ ]
503
+ }
504
+ ) }),
505
+ /* @__PURE__ */ i(
506
+ ue,
507
+ {
508
+ title: "Annotate",
509
+ show: e.showLabeler,
510
+ cancelText: "Cancel",
511
+ button: /* @__PURE__ */ i("button", { type: "button", onClick: ie, children: /* @__PURE__ */ i(v, { sm: !0, green: !0, children: "Save" }) }),
512
+ handleCancel: le,
513
+ children: /* @__PURE__ */ D("div", { className: "my-2 grid grid-cols-1 gap-y-2", children: [
514
+ /* @__PURE__ */ i(he, { children: /* @__PURE__ */ i(
515
+ "select",
516
+ {
517
+ value: e.selectedLabel,
518
+ onChange: (t) => {
519
+ o({ ...e, selectedLabel: t.target.value });
520
+ },
521
+ children: a.labels.map((t) => /* @__PURE__ */ i("option", { value: t, children: t }, t))
522
+ }
523
+ ) }),
524
+ /* @__PURE__ */ i(fe, { htmlFor: "difficult", text: "Difficult?", children: /* @__PURE__ */ i(
525
+ "input",
526
+ {
527
+ id: "difficult",
528
+ type: "checkbox",
529
+ checked: e.difficult,
530
+ onChange: (t) => {
531
+ o({ ...e, difficult: t.target.checked });
532
+ }
533
+ }
534
+ ) })
535
+ ] })
536
+ }
537
+ ),
538
+ /* @__PURE__ */ i(
539
+ de,
540
+ {
541
+ title: "Keyboard shortcuts",
542
+ show: e.showHelp,
543
+ handleClose: () => {
544
+ o({ ...e, showHelp: !1 });
545
+ },
546
+ children: /* @__PURE__ */ i("div", { className: "grid w-full grid-cols-2 place-content-center gap-2 p-5", children: y.map((t) => /* @__PURE__ */ D(ae, { children: [
547
+ /* @__PURE__ */ i("div", { children: t.action }),
548
+ /* @__PURE__ */ i("div", { className: "justify-self-end", children: t.codes.map((r) => /* @__PURE__ */ i(
549
+ "span",
550
+ {
551
+ className: "rounded-md bg-slate-100 p-1 font-mono text-xs shadow-inner",
552
+ children: r
553
+ },
554
+ r
555
+ )).reduce((r, n) => [r, " + ", n]) })
556
+ ] }, t.action)) })
557
+ }
558
+ ),
559
+ /* @__PURE__ */ i(
560
+ Z,
561
+ {
562
+ title: "Are all objects in this image labeled?",
563
+ description: " ",
564
+ handleCancel: () => {
565
+ o({ ...e, showVerify: !1 });
566
+ },
567
+ show: e.showVerify,
568
+ cancelText: "Cancel",
569
+ button: /* @__PURE__ */ i(
570
+ "button",
571
+ {
572
+ type: "button",
573
+ onClick: () => {
574
+ a.save(d, g.length === 0, a.labels), o({ ...e, showVerify: !1 });
575
+ },
576
+ children: /* @__PURE__ */ i(v, { sm: !0, green: !0, children: "Yes, all objects are labeled" })
577
+ }
578
+ ),
579
+ children: /* @__PURE__ */ i("ul", { className: "list-inside list-disc", children: a.labels.map((t) => /* @__PURE__ */ i("li", { children: t }, t)) })
580
+ }
581
+ ),
582
+ /* @__PURE__ */ i(
583
+ Z,
584
+ {
585
+ title: "Are you sure you want to delete this image?",
586
+ description: "",
587
+ handleCancel: () => {
588
+ o({ ...e, showDelete: !1 });
589
+ },
590
+ show: e.showDelete,
591
+ cancelText: "Cancel",
592
+ button: /* @__PURE__ */ i(
593
+ "button",
594
+ {
595
+ type: "button",
596
+ onClick: () => {
597
+ a.delete(), o({ ...e, showDelete: !1 });
598
+ },
599
+ children: /* @__PURE__ */ i(v, { sm: !0, red: !0, children: "Yes, permanently delete" })
600
+ }
601
+ ),
602
+ children: "This cannot be undone."
603
+ }
604
+ ),
605
+ /* @__PURE__ */ i(
606
+ Z,
607
+ {
608
+ title: "Are you sure you want to delete this reported false positive?",
609
+ description: " ",
610
+ maxWidthClass: "max-w-xl",
611
+ handleCancel: () => {
612
+ o({ ...e, showConfirmDeleteFalsePositive: !1 });
613
+ },
614
+ show: e.showConfirmDeleteFalsePositive,
615
+ cancelText: "Cancel",
616
+ button: /* @__PURE__ */ i(
617
+ "button",
618
+ {
619
+ type: "button",
620
+ onClick: () => {
621
+ e.selectedBox && z(e.selectedBox), o({
622
+ ...e,
623
+ showConfirmDeleteFalsePositive: !1,
624
+ selectedBox: void 0
625
+ });
626
+ },
627
+ children: /* @__PURE__ */ D(v, { sm: !0, red: !0, children: [
628
+ "Do not teach my model that this is not a",
629
+ " ",
630
+ e.selectedBox ? u(e.selectedBox) : " "
631
+ ] })
632
+ }
633
+ ),
634
+ children: /* @__PURE__ */ i("p", { children: "False positives submitted from Frigate are used to improve your model and should not be deleted unless you submitted them accidentally." })
635
+ }
636
+ )
637
+ ] });
638
+ };
639
+ export {
640
+ ke as ImageAnnotator
641
+ };
642
+ //# sourceMappingURL=ImageAnnotator.js.map