@tbib-image-viewer/react 0.1.6 → 0.2.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.
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  // src/components/ImageViewer.tsx
2
- import { useState as useState4, useRef as useRef5, useEffect as useEffect3, useCallback as useCallback3, useMemo as useMemo2 } from "react";
3
- import { FontAwesomeIcon as FontAwesomeIcon3 } from "@fortawesome/react-fontawesome";
2
+ import { useState as useState4, useRef as useRef3, useEffect, useCallback as useCallback3, useMemo as useMemo2, Suspense, lazy } from "react";
3
+ import { FontAwesomeIcon as FontAwesomeIcon2 } from "@fortawesome/react-fontawesome";
4
4
  import {
5
- faSpinner as faSpinner2,
5
+ faSpinner,
6
6
  faRotateRight as faRotateRight2
7
7
  } from "@fortawesome/free-solid-svg-icons";
8
8
  import { faExclamationTriangle } from "@fortawesome/free-solid-svg-icons/faExclamationTriangle";
@@ -14,13 +14,13 @@ import {
14
14
  } from "@tbib-image-viewer/core";
15
15
 
16
16
  // src/components/ImageToolbar.tsx
17
- import React2 from "react";
18
- import { FontAwesomeIcon as FontAwesomeIcon2 } from "@fortawesome/react-fontawesome";
17
+ import { useState } from "react";
18
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
19
19
  import {
20
20
  faHand,
21
21
  faPen,
22
22
  faHighlighter,
23
- faCrosshairs,
23
+ faWandMagicSparkles,
24
24
  faEraser,
25
25
  faRotateLeft,
26
26
  faRotateRight,
@@ -30,190 +30,16 @@ import {
30
30
  faExpand,
31
31
  faRotate,
32
32
  faXmark,
33
- faExpandAlt,
34
- faCompressAlt,
35
- faEyeDropper
36
- } from "@fortawesome/free-solid-svg-icons";
37
-
38
- // src/components/DownloadMenu.tsx
39
- import { useState, useRef, useEffect } from "react";
40
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
41
- import {
33
+ faUpRightAndDownLeftFromCenter,
34
+ faDownLeftAndUpRightToCenter,
35
+ faEyeDropper,
42
36
  faDownload,
43
37
  faImage,
44
- faPaintBrush,
45
- faSpinner,
46
- faChevronDown
38
+ faFileCode,
39
+ faPenToSquare
47
40
  } from "@fortawesome/free-solid-svg-icons";
41
+ import { InkToolbar } from "@tbib-ink/react";
48
42
  import { jsx, jsxs } from "react/jsx-runtime";
49
- var DownloadMenu = ({
50
- onDownloadAnnotated,
51
- onDownloadClean,
52
- onExportJson
53
- }) => {
54
- const [isOpen, setIsOpen] = useState(false);
55
- const [isExporting, setIsExporting] = useState(false);
56
- const [popoverPos, setPopoverPos] = useState({ top: 0, right: 0 });
57
- const containerRef = useRef(null);
58
- useEffect(() => {
59
- if (isOpen && containerRef.current) {
60
- const rect = containerRef.current.getBoundingClientRect();
61
- setPopoverPos({
62
- top: rect.bottom + 8,
63
- right: Math.max(12, window.innerWidth - rect.right)
64
- });
65
- }
66
- }, [isOpen]);
67
- useEffect(() => {
68
- const handleOutsideClick = (e) => {
69
- if (containerRef.current && !containerRef.current.contains(e.target)) {
70
- setIsOpen(false);
71
- }
72
- };
73
- if (isOpen) {
74
- document.addEventListener("mousedown", handleOutsideClick);
75
- document.addEventListener("touchstart", handleOutsideClick);
76
- }
77
- return () => {
78
- document.removeEventListener("mousedown", handleOutsideClick);
79
- document.removeEventListener("touchstart", handleOutsideClick);
80
- };
81
- }, [isOpen]);
82
- const handleAnnotated = async () => {
83
- if (isExporting) return;
84
- setIsExporting(true);
85
- try {
86
- await onDownloadAnnotated();
87
- } finally {
88
- setIsExporting(false);
89
- setIsOpen(false);
90
- }
91
- };
92
- const handleClean = async () => {
93
- if (isExporting) return;
94
- setIsExporting(true);
95
- try {
96
- await onDownloadClean();
97
- } finally {
98
- setIsExporting(false);
99
- setIsOpen(false);
100
- }
101
- };
102
- return /* @__PURE__ */ jsxs(
103
- "div",
104
- {
105
- ref: containerRef,
106
- style: {
107
- position: "relative",
108
- display: "inline-flex",
109
- alignItems: "center"
110
- },
111
- children: [
112
- /* @__PURE__ */ jsx(
113
- "button",
114
- {
115
- type: "button",
116
- className: "tbib-iv-btn",
117
- title: "Download Annotated Image (1-Click PNG)",
118
- "aria-label": "Download Image",
119
- disabled: isExporting,
120
- onClick: handleAnnotated,
121
- style: {
122
- borderTopRightRadius: 0,
123
- borderBottomRightRadius: 0,
124
- paddingRight: "6px"
125
- },
126
- children: /* @__PURE__ */ jsx(
127
- FontAwesomeIcon,
128
- {
129
- icon: isExporting ? faSpinner : faDownload,
130
- className: isExporting ? "fa-spin" : "",
131
- style: { fontSize: "14px" }
132
- }
133
- )
134
- }
135
- ),
136
- /* @__PURE__ */ jsx(
137
- "button",
138
- {
139
- type: "button",
140
- className: "tbib-iv-btn",
141
- title: "More Download Options",
142
- "aria-label": "More Download Options",
143
- disabled: isExporting,
144
- onClick: () => setIsOpen((prev) => !prev),
145
- style: {
146
- borderTopLeftRadius: 0,
147
- borderBottomLeftRadius: 0,
148
- paddingLeft: "4px",
149
- paddingRight: "6px",
150
- minWidth: "20px",
151
- borderLeft: "1px solid var(--tbib-iv-border)"
152
- },
153
- children: /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: faChevronDown, style: { fontSize: "10px", opacity: 0.8 } })
154
- }
155
- ),
156
- isOpen && /* @__PURE__ */ jsxs(
157
- "div",
158
- {
159
- className: "tbib-iv-popover",
160
- style: {
161
- position: "fixed",
162
- top: `${popoverPos.top}px`,
163
- right: `${popoverPos.right}px`,
164
- flexDirection: "column",
165
- minWidth: "210px",
166
- zIndex: 9999
167
- },
168
- children: [
169
- /* @__PURE__ */ jsxs(
170
- "button",
171
- {
172
- type: "button",
173
- className: "tbib-iv-btn",
174
- style: {
175
- width: "100%",
176
- justifyContent: "flex-start",
177
- gap: "10px",
178
- padding: "8px 10px",
179
- fontSize: "12px"
180
- },
181
- onClick: handleAnnotated,
182
- children: [
183
- /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: faPaintBrush, style: { fontSize: "13px", color: "var(--tbib-iv-accent)" } }),
184
- /* @__PURE__ */ jsx("span", { children: "Annotated Image (PNG)" })
185
- ]
186
- }
187
- ),
188
- /* @__PURE__ */ jsxs(
189
- "button",
190
- {
191
- type: "button",
192
- className: "tbib-iv-btn",
193
- style: {
194
- width: "100%",
195
- justifyContent: "flex-start",
196
- gap: "10px",
197
- padding: "8px 10px",
198
- fontSize: "12px"
199
- },
200
- onClick: handleClean,
201
- children: [
202
- /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: faImage, style: { fontSize: "13px" } }),
203
- /* @__PURE__ */ jsx("span", { children: "Clean Image (Original)" })
204
- ]
205
- }
206
- )
207
- ]
208
- }
209
- )
210
- ]
211
- }
212
- );
213
- };
214
-
215
- // src/components/ImageToolbar.tsx
216
- import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
217
43
  var PRESET_COLORS = [
218
44
  "#ef4444",
219
45
  // Red
@@ -233,11 +59,46 @@ var PRESET_COLORS = [
233
59
  // Black
234
60
  ];
235
61
  var THICKNESS_OPTIONS = [
236
- { label: "Fine", value: 2 },
237
- { label: "Medium", value: 4 },
238
- { label: "Bold", value: 7 },
239
- { label: "Heavy", value: 12 }
62
+ { label: "Fin", value: 2 },
63
+ { label: "Moyen", value: 4 },
64
+ { label: "\xC9pais", value: 7 },
65
+ { label: "Gras", value: 12 }
240
66
  ];
67
+ var TOOLS = [
68
+ { id: "hand", label: "Main", icon: faHand, shortcut: "H" },
69
+ { id: "pen", label: "Stylo", icon: faPen, shortcut: "P", hasOptions: true },
70
+ { id: "highlighter", label: "Surligneur", icon: faHighlighter, shortcut: "S", hasOptions: true },
71
+ { id: "eraser", label: "Gomme", icon: faEraser, shortcut: "E" },
72
+ { id: "laser", label: "Laser", icon: faWandMagicSparkles, shortcut: "L", hasOptions: true }
73
+ ];
74
+ var panelStyle = {
75
+ display: "flex",
76
+ flexDirection: "column",
77
+ gap: 10,
78
+ padding: 12,
79
+ width: "min(296px, calc(100vw - 24px))",
80
+ background: "var(--tbi-surface)",
81
+ border: "1px solid var(--tbi-border)",
82
+ borderRadius: 16,
83
+ boxShadow: "var(--tbi-shadow)",
84
+ color: "var(--tbi-fg)"
85
+ };
86
+ var chipStyle = (active) => ({
87
+ display: "inline-flex",
88
+ alignItems: "center",
89
+ justifyContent: "center",
90
+ gap: 6,
91
+ padding: "7px 0",
92
+ flex: 1,
93
+ borderRadius: 10,
94
+ border: `1px solid ${active ? "color-mix(in oklch, var(--tbi-primary) 40%, transparent)" : "var(--tbi-border)"}`,
95
+ background: active ? "color-mix(in oklch, var(--tbi-primary) 15%, transparent)" : "var(--tbi-surface-2)",
96
+ color: active ? "var(--tbi-primary)" : "var(--tbi-fg)",
97
+ font: "inherit",
98
+ fontSize: 11,
99
+ fontWeight: 700,
100
+ cursor: "pointer"
101
+ });
241
102
  var ImageToolbar = ({
242
103
  activeTool,
243
104
  onToolChange,
@@ -262,320 +123,211 @@ var ImageToolbar = ({
262
123
  isFullscreen,
263
124
  onToggleFullscreen,
264
125
  currentIndex,
265
- totalImages
126
+ totalImages,
127
+ theme = "dark"
266
128
  }) => {
267
- const showSubtoolbar = activeTool === "pen" || activeTool === "highlighter" || activeTool === "laser";
268
- const toolbarScrollRef = React2.useRef(null);
269
- const subtoolbarScrollRef = React2.useRef(null);
270
- const toolbarTouchState = React2.useRef({ isDown: false, startX: 0, scrollLeft: 0 });
271
- const subtoolbarTouchState = React2.useRef({ isDown: false, startX: 0, scrollLeft: 0 });
272
- const handleToolbarTouchStart = (e) => {
273
- if (!toolbarScrollRef.current) return;
274
- toolbarTouchState.current = {
275
- isDown: true,
276
- startX: e.touches[0].clientX,
277
- scrollLeft: toolbarScrollRef.current.scrollLeft
278
- };
279
- };
280
- const handleToolbarTouchMove = (e) => {
281
- if (!toolbarTouchState.current.isDown || !toolbarScrollRef.current) return;
282
- const dx = e.touches[0].clientX - toolbarTouchState.current.startX;
283
- toolbarScrollRef.current.scrollLeft = toolbarTouchState.current.scrollLeft - dx;
284
- };
285
- const handleToolbarTouchEnd = () => {
286
- toolbarTouchState.current.isDown = false;
287
- };
288
- const handleSubtoolbarTouchStart = (e) => {
289
- if (!subtoolbarScrollRef.current) return;
290
- subtoolbarTouchState.current = {
291
- isDown: true,
292
- startX: e.touches[0].clientX,
293
- scrollLeft: subtoolbarScrollRef.current.scrollLeft
294
- };
295
- };
296
- const handleSubtoolbarTouchMove = (e) => {
297
- if (!subtoolbarTouchState.current.isDown || !subtoolbarScrollRef.current) return;
298
- const dx = e.touches[0].clientX - subtoolbarTouchState.current.startX;
299
- subtoolbarScrollRef.current.scrollLeft = subtoolbarTouchState.current.scrollLeft - dx;
300
- };
301
- const handleSubtoolbarTouchEnd = () => {
302
- subtoolbarTouchState.current.isDown = false;
129
+ const [downloadOpen, setDownloadOpen] = useState(false);
130
+ const [downloading, setDownloading] = useState(false);
131
+ const runDownload = async (fn) => {
132
+ setDownloadOpen(false);
133
+ setDownloading(true);
134
+ try {
135
+ await fn();
136
+ } finally {
137
+ setDownloading(false);
138
+ }
303
139
  };
304
- return /* @__PURE__ */ jsxs2("div", { className: "tbib-iv-toolbar-wrapper", children: [
305
- /* @__PURE__ */ jsx2("header", { className: "tbib-iv-toolbar", role: "toolbar", "aria-label": "Image tools", children: /* @__PURE__ */ jsxs2(
306
- "div",
307
- {
308
- ref: toolbarScrollRef,
309
- className: "tbib-iv-toolbar-scroll",
310
- onTouchStart: handleToolbarTouchStart,
311
- onTouchMove: handleToolbarTouchMove,
312
- onTouchEnd: handleToolbarTouchEnd,
313
- children: [
314
- currentIndex !== void 0 && totalImages !== void 0 && totalImages > 1 && /* @__PURE__ */ jsxs2(Fragment, { children: [
315
- /* @__PURE__ */ jsxs2("span", { className: "tbib-iv-tabular", title: "Current Image", children: [
316
- currentIndex + 1,
317
- " / ",
318
- totalImages
319
- ] }),
320
- /* @__PURE__ */ jsx2("div", { className: "tbib-iv-divider" })
321
- ] }),
322
- /* @__PURE__ */ jsx2(
323
- "button",
324
- {
325
- type: "button",
326
- className: `tbib-iv-btn ${activeTool === "hand" ? "tbib-iv-btn-active" : ""}`,
327
- onClick: () => onToolChange("hand"),
328
- title: "Pan & Move (1-finger / drag)",
329
- "aria-label": "Hand Pan Tool",
330
- children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faHand })
331
- }
332
- ),
333
- /* @__PURE__ */ jsx2(
334
- "button",
335
- {
336
- type: "button",
337
- className: `tbib-iv-btn ${activeTool === "pen" ? "tbib-iv-btn-active" : ""}`,
338
- onClick: () => onToolChange("pen"),
339
- title: "Draw Pen",
340
- "aria-label": "Pen Tool",
341
- children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faPen })
342
- }
343
- ),
344
- /* @__PURE__ */ jsx2(
345
- "button",
346
- {
347
- type: "button",
348
- className: `tbib-iv-btn ${activeTool === "highlighter" ? "tbib-iv-btn-active" : ""}`,
349
- onClick: () => onToolChange("highlighter"),
350
- title: "Highlighter (Semi-transparent)",
351
- "aria-label": "Highlighter Tool",
352
- children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faHighlighter })
353
- }
354
- ),
355
- /* @__PURE__ */ jsx2(
356
- "button",
357
- {
358
- type: "button",
359
- className: `tbib-iv-btn ${activeTool === "laser" ? "tbib-iv-btn-active" : ""}`,
360
- onClick: () => onToolChange("laser"),
361
- title: "Laser Pointer (Glowing WebGL trail)",
362
- "aria-label": "Laser Pointer",
363
- children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faCrosshairs })
364
- }
365
- ),
366
- /* @__PURE__ */ jsx2(
367
- "button",
368
- {
369
- type: "button",
370
- className: `tbib-iv-btn ${activeTool === "eraser" ? "tbib-iv-btn-active" : ""}`,
371
- onClick: () => onToolChange("eraser"),
372
- title: "Eraser (Erase strokes on tap)",
373
- "aria-label": "Eraser Tool",
374
- children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faEraser })
375
- }
376
- ),
377
- /* @__PURE__ */ jsx2("div", { className: "tbib-iv-divider" }),
378
- /* @__PURE__ */ jsx2(
379
- "button",
380
- {
381
- type: "button",
382
- className: "tbib-iv-btn",
383
- disabled: !canUndo,
384
- onClick: onUndo,
385
- title: "Undo (Ctrl+Z)",
386
- "aria-label": "Undo",
387
- children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faRotateLeft })
388
- }
389
- ),
390
- /* @__PURE__ */ jsx2(
391
- "button",
392
- {
393
- type: "button",
394
- className: "tbib-iv-btn",
395
- disabled: !canRedo,
396
- onClick: onRedo,
397
- title: "Redo (Ctrl+Y)",
398
- "aria-label": "Redo",
399
- children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faRotateRight })
400
- }
401
- ),
402
- /* @__PURE__ */ jsx2(
403
- "button",
404
- {
405
- type: "button",
406
- className: "tbib-iv-btn",
407
- onClick: onClear,
408
- title: "Clear Slide Annotations",
409
- "aria-label": "Clear All",
410
- children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faTrashCan })
411
- }
412
- ),
413
- /* @__PURE__ */ jsx2("div", { className: "tbib-iv-divider" }),
414
- /* @__PURE__ */ jsx2(
415
- "button",
416
- {
417
- type: "button",
418
- className: "tbib-iv-btn",
419
- onClick: onZoomOut,
420
- title: "Zoom Out (-)",
421
- "aria-label": "Zoom Out",
422
- children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faMagnifyingGlassMinus })
423
- }
424
- ),
425
- /* @__PURE__ */ jsxs2("span", { className: "tbib-iv-tabular", title: "Current Zoom Scale", children: [
426
- Math.round(zoomScale * 100),
427
- "%"
428
- ] }),
429
- /* @__PURE__ */ jsx2(
430
- "button",
431
- {
432
- type: "button",
433
- className: "tbib-iv-btn",
434
- onClick: onZoomIn,
435
- title: "Zoom In (+)",
436
- "aria-label": "Zoom In",
437
- children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faMagnifyingGlassPlus })
438
- }
439
- ),
440
- /* @__PURE__ */ jsx2(
441
- "button",
442
- {
443
- type: "button",
444
- className: "tbib-iv-btn",
445
- onClick: onZoomReset,
446
- title: "Reset Fit to Screen (0)",
447
- "aria-label": "Reset Zoom",
448
- children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faExpand })
449
- }
450
- ),
451
- /* @__PURE__ */ jsx2(
452
- "button",
453
- {
454
- type: "button",
455
- className: "tbib-iv-btn",
456
- onClick: onRotate,
457
- title: "Rotate 90\xB0 Clockwise",
458
- "aria-label": "Rotate Image",
459
- children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faRotate })
460
- }
461
- ),
462
- /* @__PURE__ */ jsx2("div", { className: "tbib-iv-divider" }),
463
- /* @__PURE__ */ jsx2(
464
- DownloadMenu,
465
- {
466
- onDownloadAnnotated,
467
- onDownloadClean,
468
- onExportJson
469
- }
470
- ),
471
- onToggleFullscreen && /* @__PURE__ */ jsx2(
472
- "button",
473
- {
474
- type: "button",
475
- className: "tbib-iv-btn",
476
- onClick: onToggleFullscreen,
477
- title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
478
- "aria-label": "Toggle Fullscreen",
479
- children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: isFullscreen ? faCompressAlt : faExpandAlt })
480
- }
481
- ),
482
- onClose && /* @__PURE__ */ jsxs2(Fragment, { children: [
483
- /* @__PURE__ */ jsx2("div", { className: "tbib-iv-divider" }),
484
- /* @__PURE__ */ jsx2(
485
- "button",
140
+ const zoomPct = Math.round(zoomScale * 100);
141
+ const actions = [
142
+ { id: "undo", label: "Annuler", icon: faRotateLeft, disabled: !canUndo, onSelect: onUndo },
143
+ { id: "redo", label: "R\xE9tablir", icon: faRotateRight, disabled: !canRedo, onSelect: onRedo },
144
+ { id: "clear", label: "Tout effacer", icon: faTrashCan, placement: "sheet", onSelect: onClear },
145
+ { id: "zoom-out", label: "Zoom arri\xE8re", icon: faMagnifyingGlassMinus, onSelect: onZoomOut },
146
+ { id: "zoom-in", label: "Zoom avant", icon: faMagnifyingGlassPlus, onSelect: onZoomIn },
147
+ { id: "zoom-reset", label: `Ajuster (${zoomPct}%)`, icon: faExpand, onSelect: onZoomReset },
148
+ { id: "rotate", label: "Pivoter", icon: faRotate, onSelect: onRotate },
149
+ {
150
+ id: "download",
151
+ label: "T\xE9l\xE9charger",
152
+ icon: faDownload,
153
+ primary: true,
154
+ busy: downloading,
155
+ active: downloadOpen,
156
+ onSelect: () => setDownloadOpen((v) => !v)
157
+ }
158
+ ];
159
+ if (onToggleFullscreen) {
160
+ actions.push({
161
+ id: "fullscreen",
162
+ label: isFullscreen ? "Quitter le plein \xE9cran" : "Plein \xE9cran",
163
+ icon: isFullscreen ? faDownLeftAndUpRightToCenter : faUpRightAndDownLeftFromCenter,
164
+ active: isFullscreen,
165
+ onSelect: onToggleFullscreen
166
+ });
167
+ }
168
+ if (onClose) {
169
+ actions.push({ id: "close", label: "Fermer", icon: faXmark, placement: "bar", onSelect: onClose });
170
+ }
171
+ const renderToolOptions = (toolId) => {
172
+ const showThickness = toolId === "pen" || toolId === "highlighter";
173
+ return /* @__PURE__ */ jsxs("div", { style: panelStyle, role: "group", "aria-label": "Options de l'outil", children: [
174
+ showThickness && /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: 6 }, children: THICKNESS_OPTIONS.map((opt) => /* @__PURE__ */ jsxs(
175
+ "button",
176
+ {
177
+ type: "button",
178
+ "aria-pressed": strokeWidth === opt.value,
179
+ style: chipStyle(strokeWidth === opt.value),
180
+ onClick: () => onStrokeWidthChange(opt.value),
181
+ title: `${opt.label} (${opt.value}px)`,
182
+ children: [
183
+ /* @__PURE__ */ jsx(
184
+ "span",
486
185
  {
487
- type: "button",
488
- className: "tbib-iv-btn",
489
- onClick: onClose,
490
- title: "Close Viewer (Esc)",
491
- "aria-label": "Close",
492
- style: { color: "#ef4444" },
493
- children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faXmark, style: { fontSize: "16px" } })
186
+ "aria-hidden": "true",
187
+ style: {
188
+ width: Math.min(opt.value * 1.4, 11),
189
+ height: Math.min(opt.value * 1.4, 11),
190
+ borderRadius: 999,
191
+ background: "currentColor"
192
+ }
494
193
  }
495
- )
496
- ] })
497
- ]
498
- }
499
- ) }),
500
- showSubtoolbar && /* @__PURE__ */ jsx2("div", { className: "tbib-iv-subtoolbar", role: "region", "aria-label": "Tool customization", children: /* @__PURE__ */ jsxs2(
501
- "div",
502
- {
503
- ref: subtoolbarScrollRef,
504
- className: "tbib-iv-subtoolbar-scroll",
505
- onTouchStart: handleSubtoolbarTouchStart,
506
- onTouchMove: handleSubtoolbarTouchMove,
507
- onTouchEnd: handleSubtoolbarTouchEnd,
508
- children: [
509
- activeTool !== "laser" && /* @__PURE__ */ jsx2("div", { className: "tbib-iv-thickness-group", children: THICKNESS_OPTIONS.map((opt) => /* @__PURE__ */ jsxs2(
194
+ ),
195
+ opt.label
196
+ ]
197
+ },
198
+ opt.value
199
+ )) }),
200
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" }, children: [
201
+ PRESET_COLORS.map((c) => {
202
+ const selected = color.toLowerCase() === c.toLowerCase();
203
+ return /* @__PURE__ */ jsx(
510
204
  "button",
511
205
  {
512
206
  type: "button",
513
- className: `tbib-iv-thickness-btn ${strokeWidth === opt.value ? "tbib-iv-thickness-active" : ""}`,
514
- onClick: () => onStrokeWidthChange(opt.value),
515
- title: `${opt.label} stroke (${opt.value}px)`,
516
- children: [
517
- /* @__PURE__ */ jsx2(
518
- "span",
519
- {
520
- style: {
521
- display: "inline-block",
522
- width: `${Math.min(opt.value * 1.5, 12)}px`,
523
- height: `${Math.min(opt.value * 1.5, 12)}px`,
524
- borderRadius: "50%",
525
- backgroundColor: "currentColor"
526
- }
527
- }
528
- ),
529
- /* @__PURE__ */ jsx2("span", { children: opt.label })
530
- ]
207
+ "aria-label": `Couleur ${c}`,
208
+ "aria-pressed": selected,
209
+ onClick: () => onColorChange(c),
210
+ style: {
211
+ width: 24,
212
+ height: 24,
213
+ borderRadius: 999,
214
+ background: c,
215
+ cursor: "pointer",
216
+ border: "1px solid var(--tbi-border)",
217
+ boxShadow: selected ? "0 0 0 2px var(--tbi-surface), 0 0 0 4px var(--tbi-primary)" : "none"
218
+ }
531
219
  },
532
- opt.value
533
- )) }),
534
- activeTool === "laser" && /* @__PURE__ */ jsx2("span", { style: { fontSize: "11px", color: "var(--tbib-iv-text-muted)", fontStyle: "italic", paddingRight: "4px" }, children: "Laser Beam Color:" }),
535
- /* @__PURE__ */ jsx2("div", { className: "tbib-iv-divider", style: { height: "16px", margin: "0 2px" } }),
536
- /* @__PURE__ */ jsxs2("div", { style: { display: "inline-flex", alignItems: "center", gap: "6px" }, children: [
537
- PRESET_COLORS.map((c) => {
538
- const isSelected = color.toLowerCase() === c.toLowerCase();
539
- return /* @__PURE__ */ jsx2(
540
- "button",
541
- {
542
- type: "button",
543
- className: `tbib-iv-swatch-btn ${isSelected ? "tbib-iv-swatch-active" : ""}`,
544
- style: { backgroundColor: c },
545
- onClick: () => onColorChange(c),
546
- title: `Select color: ${c}`,
547
- "aria-label": `Color ${c}`
548
- },
549
- c
550
- );
551
- }),
552
- /* @__PURE__ */ jsxs2("label", { className: "tbib-iv-custom-color-btn", title: "Custom Color Picker", children: [
553
- /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faEyeDropper, style: { fontSize: "10px", opacity: 0.8 } }),
554
- /* @__PURE__ */ jsx2(
220
+ c
221
+ );
222
+ }),
223
+ /* @__PURE__ */ jsxs(
224
+ "label",
225
+ {
226
+ title: "Couleur personnalis\xE9e",
227
+ style: {
228
+ position: "relative",
229
+ width: 24,
230
+ height: 24,
231
+ borderRadius: 999,
232
+ display: "inline-flex",
233
+ alignItems: "center",
234
+ justifyContent: "center",
235
+ border: "1px dashed var(--tbi-border)",
236
+ color: "var(--tbi-muted)",
237
+ cursor: "pointer",
238
+ overflow: "hidden"
239
+ },
240
+ children: [
241
+ /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: faEyeDropper, style: { width: 11, height: 11 } }),
242
+ /* @__PURE__ */ jsx(
555
243
  "input",
556
244
  {
557
245
  type: "color",
558
246
  value: color,
559
247
  onChange: (e) => onColorChange(e.target.value),
560
- className: "tbib-iv-custom-color-input",
561
- "aria-label": "Custom color picker"
248
+ "aria-label": "Couleur personnalis\xE9e",
249
+ style: { position: "absolute", inset: 0, opacity: 0, cursor: "pointer" }
562
250
  }
563
251
  )
564
- ] })
565
- ] })
252
+ ]
253
+ }
254
+ )
255
+ ] })
256
+ ] });
257
+ };
258
+ const downloadPanel = downloadOpen ? /* @__PURE__ */ jsx("div", { style: { ...panelStyle, width: "min(260px, calc(100vw - 24px))", gap: 6 }, role: "menu", "aria-label": "T\xE9l\xE9charger", children: [
259
+ { id: "annotated", label: "Image annot\xE9e (PNG)", icon: faPenToSquare, run: onDownloadAnnotated },
260
+ { id: "clean", label: "Image originale", icon: faImage, run: onDownloadClean },
261
+ ...onExportJson ? [{ id: "json", label: "Annotations (JSON)", icon: faFileCode, run: onExportJson }] : []
262
+ ].map((o) => /* @__PURE__ */ jsxs(
263
+ "button",
264
+ {
265
+ type: "button",
266
+ role: "menuitem",
267
+ onClick: () => void runDownload(o.run),
268
+ style: { ...chipStyle(false), justifyContent: "flex-start", padding: "10px 12px", fontSize: 12, gap: 10 },
269
+ children: [
270
+ /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: o.icon, style: { width: 13, height: 13 } }),
271
+ o.label
272
+ ]
273
+ },
274
+ o.id
275
+ )) }) : null;
276
+ return /* @__PURE__ */ jsxs("div", { className: "tbib-iv-toolbar-wrapper", children: [
277
+ /* @__PURE__ */ jsx(
278
+ InkToolbar,
279
+ {
280
+ theme,
281
+ style: { pointerEvents: "auto" },
282
+ ariaLabel: "Outils de l'image",
283
+ tools: TOOLS,
284
+ activeTool,
285
+ onToolSelect: (id) => {
286
+ setDownloadOpen(false);
287
+ onToolChange(id);
288
+ },
289
+ activeColor: color,
290
+ actions,
291
+ compactTools: ["hand", "pen", "highlighter", "eraser"],
292
+ compactActions: ["undo", "close"],
293
+ renderToolOptions,
294
+ panel: downloadPanel
295
+ }
296
+ ),
297
+ currentIndex !== void 0 && totalImages !== void 0 && totalImages > 1 && /* @__PURE__ */ jsxs(
298
+ "span",
299
+ {
300
+ className: "tbi-root",
301
+ "data-theme": theme,
302
+ style: {
303
+ pointerEvents: "none",
304
+ padding: "3px 10px",
305
+ borderRadius: 999,
306
+ fontSize: 11,
307
+ fontWeight: 700,
308
+ fontVariantNumeric: "tabular-nums",
309
+ background: "var(--tbi-surface)",
310
+ border: "1px solid var(--tbi-border)",
311
+ color: "var(--tbi-muted)"
312
+ },
313
+ "aria-label": `Image ${currentIndex + 1} sur ${totalImages}`,
314
+ children: [
315
+ currentIndex + 1,
316
+ " / ",
317
+ totalImages
566
318
  ]
567
319
  }
568
- ) })
320
+ )
569
321
  ] });
570
322
  };
571
323
 
572
324
  // src/components/AnnotationCanvas.tsx
573
- import { useRef as useRef2, useState as useState2, useCallback, useMemo } from "react";
325
+ import { useRef, useState as useState2, useCallback, useMemo } from "react";
574
326
  import {
575
327
  pointsToSvgPath,
576
328
  hexToRgba
577
329
  } from "@tbib-image-viewer/core";
578
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
330
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
579
331
  var AnnotationCanvas = ({
580
332
  width,
581
333
  height,
@@ -590,13 +342,13 @@ var AnnotationCanvas = ({
590
342
  onPinchPan
591
343
  }) => {
592
344
  const [currentPoints, setCurrentPoints] = useState2(null);
593
- const isDrawingRef = useRef2(false);
594
- const svgRef = useRef2(null);
595
- const activePointersRef = useRef2(/* @__PURE__ */ new Map());
596
- const pinchStartDistRef = useRef2(null);
597
- const pinchStartScaleRef = useRef2(1);
598
- const pinchLastMidpointRef = useRef2(null);
599
- const isMultiTouchRef = useRef2(false);
345
+ const isDrawingRef = useRef(false);
346
+ const svgRef = useRef(null);
347
+ const activePointersRef = useRef(/* @__PURE__ */ new Map());
348
+ const pinchStartDistRef = useRef(null);
349
+ const pinchStartScaleRef = useRef(1);
350
+ const pinchLastMidpointRef = useRef(null);
351
+ const isMultiTouchRef = useRef(false);
600
352
  const isDrawableTool = activeTool === "pen" || activeTool === "highlighter";
601
353
  const isEraser = activeTool === "eraser";
602
354
  const getNormalizedPoint = useCallback(
@@ -716,7 +468,7 @@ var AnnotationCanvas = ({
716
468
  return pointsToSvgPath(currentPoints, width, height);
717
469
  }, [currentPoints, width, height]);
718
470
  const pointerEventsStyle = isDrawableTool || isEraser ? "auto" : "none";
719
- return /* @__PURE__ */ jsxs3(
471
+ return /* @__PURE__ */ jsxs2(
720
472
  "svg",
721
473
  {
722
474
  ref: svgRef,
@@ -734,11 +486,11 @@ var AnnotationCanvas = ({
734
486
  onPointerUp: handlePointerUp,
735
487
  onPointerCancel: handlePointerUp,
736
488
  children: [
737
- /* @__PURE__ */ jsx3("defs", { children: /* @__PURE__ */ jsx3("filter", { id: "highlighter-blend", children: /* @__PURE__ */ jsx3("feBlend", { mode: "multiply" }) }) }),
489
+ /* @__PURE__ */ jsx2("defs", { children: /* @__PURE__ */ jsx2("filter", { id: "highlighter-blend", children: /* @__PURE__ */ jsx2("feBlend", { mode: "multiply" }) }) }),
738
490
  strokes.map((stroke) => {
739
491
  const d = pointsToSvgPath(stroke.points, width, height);
740
492
  const isHighlighter = stroke.tool === "highlighter";
741
- return /* @__PURE__ */ jsx3(
493
+ return /* @__PURE__ */ jsx2(
742
494
  "path",
743
495
  {
744
496
  d,
@@ -749,365 +501,39 @@ var AnnotationCanvas = ({
749
501
  strokeLinejoin: "round",
750
502
  style: {
751
503
  mixBlendMode: isHighlighter ? "multiply" : "normal",
752
- pointerEvents: "none"
753
- }
754
- },
755
- stroke.id
756
- );
757
- }),
758
- currentPathD && /* @__PURE__ */ jsx3(
759
- "path",
760
- {
761
- d: currentPathD,
762
- fill: "none",
763
- stroke: activeTool === "highlighter" ? hexToRgba(color, 0.35) : color,
764
- strokeWidth: activeTool === "highlighter" ? strokeWidth * 2.5 : strokeWidth,
765
- strokeLinecap: "round",
766
- strokeLinejoin: "round",
767
- style: {
768
- mixBlendMode: activeTool === "highlighter" ? "multiply" : "normal",
769
- pointerEvents: "none"
770
- }
771
- }
772
- )
773
- ]
774
- }
775
- );
776
- };
777
-
778
- // src/components/LaserCursorLayer.tsx
779
- import { useEffect as useEffect2, useRef as useRef3 } from "react";
780
- import { Mesh, Program, Renderer, Triangle } from "ogl";
781
- import { jsx as jsx4 } from "react/jsx-runtime";
782
- var MAX_POINTS = 64;
783
- var VERTEX_SHADER = `
784
- attribute vec2 position;
785
- attribute vec2 uv;
786
- varying vec2 vUv;
787
-
788
- void main() {
789
- vUv = uv;
790
- gl_Position = vec4(position, 0.0, 1.0);
791
- }
792
- `;
793
- var FRAGMENT_SHADER = `
794
- precision highp float;
795
-
796
- #define MAX_POINTS 64
797
-
798
- uniform vec2 uResolution;
799
- uniform vec2 uPoints[MAX_POINTS];
800
- uniform float uPointCount;
801
- uniform vec3 uColor;
802
- uniform vec3 uSecondaryColor;
803
- uniform float uTrailWidth;
804
- uniform float uTaper;
805
- uniform float uGlowIntensity;
806
- uniform float uGlowSpread;
807
- uniform float uHotspot;
808
- uniform float uBrightness;
809
- uniform float uOpacity;
810
- uniform float uPulseSpeed;
811
- uniform float uNoiseStrength;
812
- uniform float uTime;
813
- uniform float uFade;
814
-
815
- varying vec2 vUv;
816
-
817
- float sRGB(float x) {
818
- if (x <= 0.00031308) return 12.92 * x;
819
- return 1.055 * pow(x, 1.0 / 2.4) - 0.055;
820
- }
821
-
822
- float hash(vec2 p) {
823
- return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
824
- }
825
-
826
- float filmGrain(vec2 p, float time) {
827
- float frame = time * 18.0;
828
- float frameIndex = mod(floor(frame), 256.0);
829
- float nextFrameIndex = mod(frameIndex + 1.0, 256.0);
830
- float blend = fract(frame);
831
- blend = blend * blend * (3.0 - 2.0 * blend);
832
- vec2 pixel = floor(p);
833
- float current = hash(pixel + vec2(frameIndex * 17.0, frameIndex * 31.0));
834
- float next = hash(pixel + vec2(nextFrameIndex * 17.0, nextFrameIndex * 31.0));
835
- return mix(current, next, blend) * 2.0 - 1.0;
836
- }
837
-
838
- void main() {
839
- vec2 pixel = vUv * uResolution;
840
- float denominator = max(uPointCount - 1.0, 1.0);
841
- float strongest = 0.0;
842
- float strongestCore = 0.0;
843
- float colorWeight = 0.0;
844
- vec3 colorSum = vec3(0.0);
845
-
846
- for (int i = 0; i < MAX_POINTS - 1; i++) {
847
- float index = float(i);
848
- vec2 start = uPoints[i];
849
- vec2 end = uPoints[i + 1];
850
- vec2 toPixel = pixel - start;
851
- vec2 segment = end - start;
852
- float along = clamp(dot(toPixel, segment) / max(dot(segment, segment), 0.0001), 0.0, 1.0);
853
- float progress = clamp((index + along) / denominator, 0.0, 1.0);
854
- float life = pow(max(1.0 - progress, 0.0), mix(0.55, 1.25, uTaper));
855
- float width = uTrailWidth * mix(1.0, 0.25, pow(progress, mix(0.55, 1.6, uTaper)));
856
- float distanceToTrail = length(toPixel - segment * along);
857
- float falloff = max(width * (0.8 + uGlowSpread * 1.4), 0.5);
858
- float beam = min(1.0, (falloff * falloff) / (distanceToTrail * distanceToTrail + falloff * falloff));
859
- float core = exp(-pow(distanceToTrail / max(width, 0.5), 2.0) * 2.5);
860
- float pulseAmount = min(abs(uPulseSpeed), 1.0);
861
- float pulse = 1.0 + sin(uTime * uPulseSpeed * 3.0 - progress * 11.0) * 0.16 * pulseAmount;
862
- float intensity = (core + beam * uGlowIntensity * 0.55) * life * pulse;
863
- vec3 segmentColor = mix(uColor, uSecondaryColor, progress);
864
-
865
- strongest = max(strongest, intensity);
866
- strongestCore = max(strongestCore, core * life);
867
- colorSum += segmentColor * intensity;
868
- colorWeight += intensity;
869
- }
870
-
871
- float grain = filmGrain(pixel, uTime);
872
- float noiseAmount = (1.0 - exp(-uNoiseStrength * 2.2)) * 0.4;
873
- float alpha = clamp(strongest * uOpacity * uFade, 0.0, 1.0);
874
- if (alpha < 0.0005) discard;
875
-
876
- vec3 color = colorSum / max(colorWeight, 0.0001);
877
- color = mix(color, vec3(1.0), smoothstep(0.25, 0.95, strongestCore) * uHotspot);
878
- float luminance = sRGB(clamp(strongest * uBrightness, 0.0, 1.0));
879
- luminance *= 1.0 + grain * noiseAmount;
880
- vec3 additiveColor = color * luminance;
881
- float normalAlpha = clamp(strongest * uBrightness * uOpacity * uFade, 0.0, 1.0);
882
- vec3 normalColor = mix(color, vec3(1.0), smoothstep(0.45, 1.0, strongestCore) * uHotspot * 0.35);
883
- gl_FragColor = vec4(mix(additiveColor, normalColor, 1.0), mix(alpha, normalAlpha, 1.0));
884
- }
885
- `;
886
- function hexToRgb(hex) {
887
- let value = (hex || "").replace("#", "").trim();
888
- if (value.length === 3) {
889
- value = value.split("").map((c) => c + c).join("");
890
- }
891
- const parsed = Number.parseInt(value || "ff0000", 16);
892
- return [
893
- (parsed >> 16 & 255) / 255,
894
- (parsed >> 8 & 255) / 255,
895
- (parsed & 255) / 255
896
- ];
897
- }
898
- var LaserCursorLayer = ({
899
- color = "#ef4444",
900
- secondaryColor = "#ef4444",
901
- trailLength = 29,
902
- trailWidth = 8,
903
- trailTaper = 0.22,
904
- followSpeed = 1.5,
905
- glowIntensity = 1.9,
906
- glowSpread = 0.1,
907
- hotspot = 0.5,
908
- brightness = 1.25,
909
- opacity = 1,
910
- pulseSpeed = 0.8,
911
- noiseStrength = 0.035,
912
- idleFade = true,
913
- idleTimeout = 700,
914
- fadeDuration = 1500,
915
- enabled = true,
916
- className = "",
917
- style,
918
- ...rest
919
- }) => {
920
- const containerRef = useRef3(null);
921
- const canvasRef = useRef3(null);
922
- useEffect2(() => {
923
- const container = containerRef.current;
924
- const canvas = canvasRef.current;
925
- if (!container || !canvas || !enabled) return;
926
- let renderer = null;
927
- try {
928
- renderer = new Renderer({
929
- canvas,
930
- alpha: true,
931
- dpr: Math.min(window.devicePixelRatio || 1, 1.5)
932
- });
933
- } catch {
934
- return;
935
- }
936
- const gl = renderer.gl;
937
- gl.clearColor(0, 0, 0, 0);
938
- const pointData = Array(MAX_POINTS * 2).fill(0);
939
- const points = Array.from({ length: MAX_POINTS }, () => ({ x: 0, y: 0 }));
940
- const target = { x: 0, y: 0 };
941
- const head = { x: 0, y: 0 };
942
- let program;
943
- let mesh;
944
- try {
945
- program = new Program(gl, {
946
- vertex: VERTEX_SHADER,
947
- fragment: FRAGMENT_SHADER,
948
- uniforms: {
949
- uResolution: { value: [1, 1] },
950
- uPoints: { value: pointData },
951
- uPointCount: { value: trailLength },
952
- uColor: { value: hexToRgb(color) },
953
- uSecondaryColor: { value: hexToRgb(secondaryColor) },
954
- uTrailWidth: { value: trailWidth },
955
- uTaper: { value: trailTaper },
956
- uGlowIntensity: { value: glowIntensity },
957
- uGlowSpread: { value: glowSpread },
958
- uHotspot: { value: hotspot },
959
- uBrightness: { value: brightness },
960
- uOpacity: { value: opacity },
961
- uPulseSpeed: { value: pulseSpeed },
962
- uNoiseStrength: { value: noiseStrength },
963
- uTime: { value: 0 },
964
- uFade: { value: 0 }
965
- },
966
- transparent: true,
967
- depthTest: false,
968
- depthWrite: false
969
- });
970
- mesh = new Mesh(gl, { geometry: new Triangle(gl), program });
971
- } catch {
972
- return;
973
- }
974
- let width = 0;
975
- let height = 0;
976
- let isHovered = false;
977
- let lastMoveTime = 0;
978
- let animationId;
979
- const resize = () => {
980
- const rect = container.getBoundingClientRect();
981
- const newWidth = Math.floor(rect.width);
982
- const newHeight = Math.floor(rect.height);
983
- if (newWidth <= 0 || newHeight <= 0) return;
984
- if (newWidth === width && newHeight === height) return;
985
- width = newWidth;
986
- height = newHeight;
987
- renderer?.setSize(width, height);
988
- program.uniforms.uResolution.value = [width, height];
989
- };
990
- resize();
991
- const resizeObserver = new ResizeObserver(resize);
992
- resizeObserver.observe(container);
993
- const onPointerMove = (e) => {
994
- const rect = container.getBoundingClientRect();
995
- target.x = e.clientX - rect.left;
996
- target.y = rect.height - (e.clientY - rect.top);
997
- lastMoveTime = performance.now();
998
- isHovered = true;
999
- };
1000
- const onPointerLeave = () => {
1001
- isHovered = false;
1002
- };
1003
- container.addEventListener("pointermove", onPointerMove);
1004
- container.addEventListener("pointerleave", onPointerLeave);
1005
- let lastTime = performance.now();
1006
- const render = (now) => {
1007
- animationId = requestAnimationFrame(render);
1008
- const dt = Math.min((now - lastTime) / 1e3, 0.1);
1009
- lastTime = now;
1010
- const speed = followSpeed * 20;
1011
- head.x += (target.x - head.x) * Math.min(dt * speed, 1);
1012
- head.y += (target.y - head.y) * Math.min(dt * speed, 1);
1013
- for (let i = MAX_POINTS - 1; i > 0; i--) {
1014
- points[i].x = points[i - 1].x;
1015
- points[i].y = points[i - 1].y;
1016
- }
1017
- points[0].x = head.x;
1018
- points[0].y = head.y;
1019
- for (let i = 0; i < MAX_POINTS; i++) {
1020
- pointData[i * 2] = points[i].x;
1021
- pointData[i * 2 + 1] = points[i].y;
1022
- }
1023
- program.uniforms.uTime.value = now * 1e-3;
1024
- let fade = 1;
1025
- if (idleFade) {
1026
- const idleTime = now - lastMoveTime;
1027
- if (!isHovered || idleTime > idleTimeout) {
1028
- const fadeProgress = Math.min(Math.max((idleTime - idleTimeout) / fadeDuration, 0), 1);
1029
- fade = 1 - fadeProgress;
1030
- }
1031
- }
1032
- program.uniforms.uFade.value = fade;
1033
- if (fade > 1e-3) {
1034
- renderer?.render({ scene: mesh });
1035
- } else {
1036
- gl.clear(gl.COLOR_BUFFER_BIT);
1037
- }
1038
- };
1039
- animationId = requestAnimationFrame(render);
1040
- return () => {
1041
- cancelAnimationFrame(animationId);
1042
- resizeObserver.disconnect();
1043
- container.removeEventListener("pointermove", onPointerMove);
1044
- container.removeEventListener("pointerleave", onPointerLeave);
1045
- };
1046
- }, [
1047
- color,
1048
- secondaryColor,
1049
- trailLength,
1050
- trailWidth,
1051
- trailTaper,
1052
- followSpeed,
1053
- glowIntensity,
1054
- glowSpread,
1055
- hotspot,
1056
- brightness,
1057
- opacity,
1058
- pulseSpeed,
1059
- noiseStrength,
1060
- idleFade,
1061
- idleTimeout,
1062
- fadeDuration,
1063
- enabled
1064
- ]);
1065
- return /* @__PURE__ */ jsx4(
1066
- "div",
1067
- {
1068
- ref: containerRef,
1069
- className: `tbib-iv-laser-layer ${className}`,
1070
- style: {
1071
- position: "absolute",
1072
- top: 0,
1073
- left: 0,
1074
- width: "100%",
1075
- height: "100%",
1076
- pointerEvents: "auto",
1077
- touchAction: "none",
1078
- cursor: "crosshair",
1079
- zIndex: 30,
1080
- overflow: "hidden",
1081
- ...style
1082
- },
1083
- ...rest,
1084
- children: /* @__PURE__ */ jsx4(
1085
- "canvas",
1086
- {
1087
- ref: canvasRef,
1088
- className: "tbib-iv-laser-canvas",
1089
- style: {
1090
- position: "absolute",
1091
- top: 0,
1092
- left: 0,
1093
- width: "100%",
1094
- height: "100%",
1095
- display: "block",
1096
- pointerEvents: "none"
504
+ pointerEvents: "none"
505
+ }
506
+ },
507
+ stroke.id
508
+ );
509
+ }),
510
+ currentPathD && /* @__PURE__ */ jsx2(
511
+ "path",
512
+ {
513
+ d: currentPathD,
514
+ fill: "none",
515
+ stroke: activeTool === "highlighter" ? hexToRgba(color, 0.35) : color,
516
+ strokeWidth: activeTool === "highlighter" ? strokeWidth * 2.5 : strokeWidth,
517
+ strokeLinecap: "round",
518
+ strokeLinejoin: "round",
519
+ style: {
520
+ mixBlendMode: activeTool === "highlighter" ? "multiply" : "normal",
521
+ pointerEvents: "none"
522
+ }
1097
523
  }
1098
- }
1099
- )
524
+ )
525
+ ]
1100
526
  }
1101
527
  );
1102
528
  };
1103
529
 
1104
530
  // src/hooks/useImageTransform.ts
1105
- import { useState as useState3, useCallback as useCallback2, useRef as useRef4 } from "react";
531
+ import { useState as useState3, useCallback as useCallback2, useRef as useRef2 } from "react";
1106
532
  import { clampScale, DEFAULT_TRANSFORM } from "@tbib-image-viewer/core";
1107
533
  function useImageTransform() {
1108
534
  const [transform, setTransform] = useState3(DEFAULT_TRANSFORM);
1109
- const pinchStartDistRef = useRef4(null);
1110
- const pinchStartScaleRef = useRef4(1);
535
+ const pinchStartDistRef = useRef2(null);
536
+ const pinchStartScaleRef = useRef2(1);
1111
537
  const zoomIn = useCallback2(() => {
1112
538
  setTransform((prev) => ({
1113
539
  ...prev,
@@ -1191,7 +617,8 @@ function useImageTransform() {
1191
617
  }
1192
618
 
1193
619
  // src/components/ImageViewer.tsx
1194
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
620
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
621
+ var LaserCursorLayer = lazy(() => import("@tbib-ink/react/laser"));
1195
622
  var ImageViewer = ({
1196
623
  src,
1197
624
  alt = "Medical illustration",
@@ -1213,7 +640,7 @@ var ImageViewer = ({
1213
640
  const [activeTool, setActiveTool] = useState4(initialTool);
1214
641
  const [color, setColor] = useState4(initialColor);
1215
642
  const [strokeWidth, setStrokeWidth] = useState4(initialStrokeWidth);
1216
- const storeRef = useRef5(
643
+ const storeRef = useRef3(
1217
644
  new AnnotationStore(
1218
645
  initialAnnotations ? [{ slideId: effectiveSlideId, strokes: initialAnnotations }] : void 0
1219
646
  )
@@ -1223,8 +650,8 @@ var ImageViewer = ({
1223
650
  );
1224
651
  const [canUndo, setCanUndo] = useState4(false);
1225
652
  const [canRedo, setCanRedo] = useState4(false);
1226
- const containerRef = useRef5(null);
1227
- const imgRef = useRef5(null);
653
+ const containerRef = useRef3(null);
654
+ const imgRef = useRef3(null);
1228
655
  const [imgSize, setImgSize] = useState4({ width: 800, height: 600 });
1229
656
  const [imageStatus, setImageStatus] = useState4("loading");
1230
657
  const [reloadKey, setReloadKey] = useState4(0);
@@ -1234,7 +661,7 @@ var ImageViewer = ({
1234
661
  const sep = src.includes("?") ? "&" : "?";
1235
662
  return `${src}${sep}_reload=${reloadKey}`;
1236
663
  }, [src, reloadKey]);
1237
- useEffect3(() => {
664
+ useEffect(() => {
1238
665
  setImageStatus("loading");
1239
666
  if (imgRef.current && imgRef.current.complete && imgRef.current.naturalWidth > 0) {
1240
667
  setImgSize({
@@ -1257,9 +684,9 @@ var ImageViewer = ({
1257
684
  handleTouchMove,
1258
685
  handleTouchEnd
1259
686
  } = useImageTransform();
1260
- const isDraggingRef = useRef5(false);
1261
- const lastMousePosRef = useRef5({ x: 0, y: 0 });
1262
- useEffect3(() => {
687
+ const isDraggingRef = useRef3(false);
688
+ const lastMousePosRef = useRef3({ x: 0, y: 0 });
689
+ useEffect(() => {
1263
690
  const store = storeRef.current;
1264
691
  const unsubscribe = store.subscribe((id, updated) => {
1265
692
  if (id === effectiveSlideId) {
@@ -1332,7 +759,7 @@ var ImageViewer = ({
1332
759
  const handleStagePointerUp = (e) => {
1333
760
  isDraggingRef.current = false;
1334
761
  };
1335
- useEffect3(() => {
762
+ useEffect(() => {
1336
763
  const handleKeyDown = (e) => {
1337
764
  if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "z") {
1338
765
  e.preventDefault();
@@ -1385,14 +812,14 @@ var ImageViewer = ({
1385
812
  link.click();
1386
813
  setTimeout(() => URL.revokeObjectURL(url), 1e3);
1387
814
  };
1388
- return /* @__PURE__ */ jsxs4(
815
+ return /* @__PURE__ */ jsxs3(
1389
816
  "div",
1390
817
  {
1391
818
  ref: containerRef,
1392
819
  className: `tbib-iv-container ${theme === "light" ? "tbib-iv-light" : ""} ${className}`,
1393
820
  style,
1394
821
  children: [
1395
- showToolbar && /* @__PURE__ */ jsx5(
822
+ showToolbar && /* @__PURE__ */ jsx3(
1396
823
  ImageToolbar,
1397
824
  {
1398
825
  activeTool,
@@ -1413,10 +840,11 @@ var ImageViewer = ({
1413
840
  onRotate: rotateClockwise,
1414
841
  onDownloadAnnotated: handleDownloadAnnotated,
1415
842
  onDownloadClean: handleDownloadClean,
1416
- onExportJson: handleExportJson
843
+ onExportJson: handleExportJson,
844
+ theme: theme === "light" ? "light" : "dark"
1417
845
  }
1418
846
  ),
1419
- /* @__PURE__ */ jsxs4(
847
+ /* @__PURE__ */ jsxs3(
1420
848
  "div",
1421
849
  {
1422
850
  className: "tbib-iv-stage",
@@ -1432,7 +860,7 @@ var ImageViewer = ({
1432
860
  cursor: activeTool === "hand" ? isDraggingRef.current ? "grabbing" : "grab" : "default"
1433
861
  },
1434
862
  children: [
1435
- /* @__PURE__ */ jsxs4(
863
+ /* @__PURE__ */ jsxs3(
1436
864
  "div",
1437
865
  {
1438
866
  className: "tbib-iv-stage-inner",
@@ -1441,7 +869,7 @@ var ImageViewer = ({
1441
869
  transition: isDraggingRef.current ? "none" : "transform 0.05s ease-out"
1442
870
  },
1443
871
  children: [
1444
- /* @__PURE__ */ jsx5(
872
+ /* @__PURE__ */ jsx3(
1445
873
  "img",
1446
874
  {
1447
875
  ref: imgRef,
@@ -1454,7 +882,7 @@ var ImageViewer = ({
1454
882
  },
1455
883
  `${src}-${reloadKey}`
1456
884
  ),
1457
- enableAnnotations && imageStatus === "loaded" && /* @__PURE__ */ jsx5(
885
+ enableAnnotations && imageStatus === "loaded" && /* @__PURE__ */ jsx3(
1458
886
  AnnotationCanvas,
1459
887
  {
1460
888
  width: imgSize.width,
@@ -1473,28 +901,28 @@ var ImageViewer = ({
1473
901
  ]
1474
902
  }
1475
903
  ),
1476
- imageStatus === "loading" && /* @__PURE__ */ jsxs4("div", { className: "tbib-iv-status-overlay", children: [
1477
- /* @__PURE__ */ jsx5("div", { className: "tbib-iv-spinner", children: /* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faSpinner2, spin: true, className: "tbib-iv-spinner-icon" }) }),
1478
- /* @__PURE__ */ jsx5("span", { className: "tbib-iv-status-text", children: "Chargement de l'illustration..." })
904
+ imageStatus === "loading" && /* @__PURE__ */ jsxs3("div", { className: "tbib-iv-status-overlay", children: [
905
+ /* @__PURE__ */ jsx3("div", { className: "tbib-iv-spinner", children: /* @__PURE__ */ jsx3(FontAwesomeIcon2, { icon: faSpinner, spin: true, className: "tbib-iv-spinner-icon" }) }),
906
+ /* @__PURE__ */ jsx3("span", { className: "tbib-iv-status-text", children: "Chargement de l'illustration..." })
1479
907
  ] }),
1480
- imageStatus === "error" && /* @__PURE__ */ jsxs4("div", { className: "tbib-iv-status-overlay tbib-iv-error-card", children: [
1481
- /* @__PURE__ */ jsx5("div", { className: "tbib-iv-error-icon", children: /* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faExclamationTriangle }) }),
1482
- /* @__PURE__ */ jsx5("h3", { className: "tbib-iv-error-title", children: "Impossible de charger l'image" }),
1483
- /* @__PURE__ */ jsx5("p", { className: "tbib-iv-error-desc", children: "Le fichier est temporairement inaccessible ou une erreur r\xE9seau est survenue." }),
1484
- /* @__PURE__ */ jsxs4("div", { className: "tbib-iv-error-actions", children: [
1485
- /* @__PURE__ */ jsxs4(
908
+ imageStatus === "error" && /* @__PURE__ */ jsxs3("div", { className: "tbib-iv-status-overlay tbib-iv-error-card", children: [
909
+ /* @__PURE__ */ jsx3("div", { className: "tbib-iv-error-icon", children: /* @__PURE__ */ jsx3(FontAwesomeIcon2, { icon: faExclamationTriangle }) }),
910
+ /* @__PURE__ */ jsx3("h3", { className: "tbib-iv-error-title", children: "Impossible de charger l'image" }),
911
+ /* @__PURE__ */ jsx3("p", { className: "tbib-iv-error-desc", children: "Le fichier est temporairement inaccessible ou une erreur r\xE9seau est survenue." }),
912
+ /* @__PURE__ */ jsxs3("div", { className: "tbib-iv-error-actions", children: [
913
+ /* @__PURE__ */ jsxs3(
1486
914
  "button",
1487
915
  {
1488
916
  type: "button",
1489
917
  className: "tbib-iv-btn tbib-iv-btn-primary tbib-iv-retry-btn",
1490
918
  onClick: handleReload,
1491
919
  children: [
1492
- /* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faRotateRight2 }),
1493
- /* @__PURE__ */ jsx5("span", { children: "R\xE9essayer" })
920
+ /* @__PURE__ */ jsx3(FontAwesomeIcon2, { icon: faRotateRight2 }),
921
+ /* @__PURE__ */ jsx3("span", { children: "R\xE9essayer" })
1494
922
  ]
1495
923
  }
1496
924
  ),
1497
- src && /* @__PURE__ */ jsxs4(
925
+ src && /* @__PURE__ */ jsxs3(
1498
926
  "a",
1499
927
  {
1500
928
  href: src,
@@ -1502,14 +930,14 @@ var ImageViewer = ({
1502
930
  rel: "noopener noreferrer",
1503
931
  className: "tbib-iv-btn tbib-iv-open-btn",
1504
932
  children: [
1505
- /* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faExternalLinkAlt }),
1506
- /* @__PURE__ */ jsx5("span", { children: "Lien direct" })
933
+ /* @__PURE__ */ jsx3(FontAwesomeIcon2, { icon: faExternalLinkAlt }),
934
+ /* @__PURE__ */ jsx3("span", { children: "Lien direct" })
1507
935
  ]
1508
936
  }
1509
937
  )
1510
938
  ] })
1511
939
  ] }),
1512
- enableLaser && activeTool === "laser" && imageStatus === "loaded" && /* @__PURE__ */ jsx5(LaserCursorLayer, { color, secondaryColor: color, enabled: activeTool === "laser" })
940
+ enableLaser && activeTool === "laser" && imageStatus === "loaded" && /* @__PURE__ */ jsx3(Suspense, { fallback: null, children: /* @__PURE__ */ jsx3(LaserCursorLayer, { color, secondaryColor: color, enabled: activeTool === "laser" }) })
1513
941
  ]
1514
942
  }
1515
943
  ),
@@ -1520,12 +948,12 @@ var ImageViewer = ({
1520
948
  };
1521
949
 
1522
950
  // src/components/ImageGalleryLightbox.tsx
1523
- import { useState as useState5, useRef as useRef7, useEffect as useEffect4, useCallback as useCallback5, useMemo as useMemo3 } from "react";
1524
- import { FontAwesomeIcon as FontAwesomeIcon4 } from "@fortawesome/react-fontawesome";
951
+ import { useState as useState5, useRef as useRef5, useEffect as useEffect2, useCallback as useCallback5, useMemo as useMemo3, Suspense as Suspense2, lazy as lazy2 } from "react";
952
+ import { FontAwesomeIcon as FontAwesomeIcon3 } from "@fortawesome/react-fontawesome";
1525
953
  import {
1526
954
  faChevronLeft,
1527
955
  faChevronRight,
1528
- faSpinner as faSpinner3,
956
+ faSpinner as faSpinner2,
1529
957
  faRotateRight as faRotateRight3
1530
958
  } from "@fortawesome/free-solid-svg-icons";
1531
959
  import { faExclamationTriangle as faExclamationTriangle2 } from "@fortawesome/free-solid-svg-icons/faExclamationTriangle";
@@ -1537,21 +965,21 @@ import {
1537
965
  } from "@tbib-image-viewer/core";
1538
966
 
1539
967
  // src/components/ThumbnailStrip.tsx
1540
- import { jsx as jsx6 } from "react/jsx-runtime";
968
+ import { jsx as jsx4 } from "react/jsx-runtime";
1541
969
  var ThumbnailStrip = ({
1542
970
  items,
1543
971
  activeIndex,
1544
972
  onSelect
1545
973
  }) => {
1546
974
  if (items.length <= 1) return null;
1547
- return /* @__PURE__ */ jsx6("div", { className: "tbib-iv-thumbnail-strip", children: items.map((item, idx) => /* @__PURE__ */ jsx6(
975
+ return /* @__PURE__ */ jsx4("div", { className: "tbib-iv-thumbnail-strip", children: items.map((item, idx) => /* @__PURE__ */ jsx4(
1548
976
  "button",
1549
977
  {
1550
978
  type: "button",
1551
979
  className: `tbib-iv-thumbnail-item ${idx === activeIndex ? "tbib-iv-thumbnail-item-active" : ""}`,
1552
980
  onClick: () => onSelect(idx),
1553
981
  title: item.title || `Image ${idx + 1}`,
1554
- children: /* @__PURE__ */ jsx6(
982
+ children: /* @__PURE__ */ jsx4(
1555
983
  "img",
1556
984
  {
1557
985
  src: item.thumbnailSrc || item.src,
@@ -1566,10 +994,10 @@ var ThumbnailStrip = ({
1566
994
  };
1567
995
 
1568
996
  // src/hooks/useSwipeGesture.ts
1569
- import { useRef as useRef6, useCallback as useCallback4 } from "react";
997
+ import { useRef as useRef4, useCallback as useCallback4 } from "react";
1570
998
  function useSwipeGesture({ onSwipeLeft, onSwipeRight, enabled = true }) {
1571
- const touchStartXRef = useRef6(null);
1572
- const touchStartYRef = useRef6(null);
999
+ const touchStartXRef = useRef4(null);
1000
+ const touchStartYRef = useRef4(null);
1573
1001
  const onTouchStart = useCallback4((e) => {
1574
1002
  if (!enabled || e.touches.length !== 1) return;
1575
1003
  touchStartXRef.current = e.touches[0].clientX;
@@ -1598,7 +1026,8 @@ function useSwipeGesture({ onSwipeLeft, onSwipeRight, enabled = true }) {
1598
1026
  }
1599
1027
 
1600
1028
  // src/components/ImageGalleryLightbox.tsx
1601
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1029
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1030
+ var LaserCursorLayer2 = lazy2(() => import("@tbib-ink/react/laser"));
1602
1031
  var ImageGalleryLightbox = ({
1603
1032
  items,
1604
1033
  activeIndex = 0,
@@ -1617,12 +1046,12 @@ var ImageGalleryLightbox = ({
1617
1046
  const [color, setColor] = useState5(initialColor);
1618
1047
  const [strokeWidth, setStrokeWidth] = useState5(4);
1619
1048
  const [isFullscreen, setIsFullscreen] = useState5(false);
1620
- useEffect4(() => {
1049
+ useEffect2(() => {
1621
1050
  setCurrentIndex(activeIndex);
1622
1051
  }, [activeIndex]);
1623
1052
  const currentItem = items[currentIndex] || items[0];
1624
1053
  const slideId = currentItem?.id || currentItem?.src || `slide-${currentIndex}`;
1625
- const storeRef = useRef7(new AnnotationStore2(initialAnnotations));
1054
+ const storeRef = useRef5(new AnnotationStore2(initialAnnotations));
1626
1055
  const [strokes, setStrokes] = useState5([]);
1627
1056
  const [canUndo, setCanUndo] = useState5(false);
1628
1057
  const [canRedo, setCanRedo] = useState5(false);
@@ -1639,21 +1068,21 @@ var ImageGalleryLightbox = ({
1639
1068
  handleTouchMove,
1640
1069
  handleTouchEnd
1641
1070
  } = useImageTransform();
1642
- useEffect4(() => {
1071
+ useEffect2(() => {
1643
1072
  resetTransform();
1644
1073
  }, [currentIndex, resetTransform]);
1645
- const imgRef = useRef7(null);
1074
+ const imgRef = useRef5(null);
1646
1075
  const [imgSize, setImgSize] = useState5({ width: 800, height: 600 });
1647
1076
  const [imageStatus, setImageStatus] = useState5("loading");
1648
1077
  const [reloadKey, setReloadKey] = useState5(0);
1649
- const containerRef = useRef7(null);
1078
+ const containerRef = useRef5(null);
1650
1079
  const effectiveSrc = useMemo3(() => {
1651
1080
  if (!currentItem?.src) return "";
1652
1081
  if (reloadKey === 0) return currentItem.src;
1653
1082
  const sep = currentItem.src.includes("?") ? "&" : "?";
1654
1083
  return `${currentItem.src}${sep}_reload=${reloadKey}`;
1655
1084
  }, [currentItem?.src, reloadKey]);
1656
- useEffect4(() => {
1085
+ useEffect2(() => {
1657
1086
  setImageStatus("loading");
1658
1087
  setReloadKey(0);
1659
1088
  if (imgRef.current && imgRef.current.complete && imgRef.current.naturalWidth > 0) {
@@ -1679,9 +1108,9 @@ var ImageGalleryLightbox = ({
1679
1108
  setImageStatus("loading");
1680
1109
  setReloadKey((prev) => prev + 1);
1681
1110
  };
1682
- const isDraggingRef = useRef7(false);
1683
- const lastMousePosRef = useRef7({ x: 0, y: 0 });
1684
- useEffect4(() => {
1111
+ const isDraggingRef = useRef5(false);
1112
+ const lastMousePosRef = useRef5({ x: 0, y: 0 });
1113
+ useEffect2(() => {
1685
1114
  const store = storeRef.current;
1686
1115
  const updateStrokes = () => {
1687
1116
  const s = store.getStrokes(slideId);
@@ -1725,7 +1154,7 @@ var ImageGalleryLightbox = ({
1725
1154
  handleTouchEnd();
1726
1155
  onSwipeTouchEnd(e);
1727
1156
  };
1728
- useEffect4(() => {
1157
+ useEffect2(() => {
1729
1158
  if (!isOpen) return;
1730
1159
  const handleKeyDown = (e) => {
1731
1160
  if (e.key === "Escape") {
@@ -1826,7 +1255,7 @@ var ImageGalleryLightbox = ({
1826
1255
  setTimeout(() => URL.revokeObjectURL(url), 1e3);
1827
1256
  };
1828
1257
  if (!isOpen || !currentItem) return null;
1829
- return /* @__PURE__ */ jsxs5(
1258
+ return /* @__PURE__ */ jsxs4(
1830
1259
  "div",
1831
1260
  {
1832
1261
  ref: containerRef,
@@ -1835,7 +1264,7 @@ var ImageGalleryLightbox = ({
1835
1264
  "aria-modal": "true",
1836
1265
  "aria-label": "Image Lightbox Gallery",
1837
1266
  children: [
1838
- /* @__PURE__ */ jsx7(
1267
+ /* @__PURE__ */ jsx5(
1839
1268
  ImageToolbar,
1840
1269
  {
1841
1270
  activeTool,
@@ -1857,6 +1286,7 @@ var ImageGalleryLightbox = ({
1857
1286
  onDownloadAnnotated: handleDownloadAnnotated,
1858
1287
  onDownloadClean: handleDownloadClean,
1859
1288
  onExportJson: handleExportJson,
1289
+ theme: theme === "light" ? "light" : "dark",
1860
1290
  onClose,
1861
1291
  isFullscreen,
1862
1292
  onToggleFullscreen: toggleFullscreen,
@@ -1864,7 +1294,7 @@ var ImageGalleryLightbox = ({
1864
1294
  totalImages: items.length
1865
1295
  }
1866
1296
  ),
1867
- currentIndex > 0 && /* @__PURE__ */ jsx7(
1297
+ currentIndex > 0 && /* @__PURE__ */ jsx5(
1868
1298
  "button",
1869
1299
  {
1870
1300
  type: "button",
@@ -1872,10 +1302,10 @@ var ImageGalleryLightbox = ({
1872
1302
  onClick: goToPrev,
1873
1303
  title: "Previous Image (Arrow Left)",
1874
1304
  "aria-label": "Previous image",
1875
- children: /* @__PURE__ */ jsx7(FontAwesomeIcon4, { icon: faChevronLeft })
1305
+ children: /* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faChevronLeft })
1876
1306
  }
1877
1307
  ),
1878
- currentIndex < items.length - 1 && /* @__PURE__ */ jsx7(
1308
+ currentIndex < items.length - 1 && /* @__PURE__ */ jsx5(
1879
1309
  "button",
1880
1310
  {
1881
1311
  type: "button",
@@ -1883,10 +1313,10 @@ var ImageGalleryLightbox = ({
1883
1313
  onClick: goToNext,
1884
1314
  title: "Next Image (Arrow Right)",
1885
1315
  "aria-label": "Next image",
1886
- children: /* @__PURE__ */ jsx7(FontAwesomeIcon4, { icon: faChevronRight })
1316
+ children: /* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faChevronRight })
1887
1317
  }
1888
1318
  ),
1889
- /* @__PURE__ */ jsxs5(
1319
+ /* @__PURE__ */ jsxs4(
1890
1320
  "div",
1891
1321
  {
1892
1322
  className: "tbib-iv-stage",
@@ -1902,7 +1332,7 @@ var ImageGalleryLightbox = ({
1902
1332
  cursor: activeTool === "hand" ? isDraggingRef.current ? "grabbing" : "grab" : "default"
1903
1333
  },
1904
1334
  children: [
1905
- /* @__PURE__ */ jsxs5(
1335
+ /* @__PURE__ */ jsxs4(
1906
1336
  "div",
1907
1337
  {
1908
1338
  className: "tbib-iv-stage-inner",
@@ -1911,7 +1341,7 @@ var ImageGalleryLightbox = ({
1911
1341
  transition: isDraggingRef.current ? "none" : "transform 0.05s ease-out"
1912
1342
  },
1913
1343
  children: [
1914
- /* @__PURE__ */ jsx7(
1344
+ /* @__PURE__ */ jsx5(
1915
1345
  "img",
1916
1346
  {
1917
1347
  ref: imgRef,
@@ -1924,7 +1354,7 @@ var ImageGalleryLightbox = ({
1924
1354
  },
1925
1355
  `${slideId}-${reloadKey}`
1926
1356
  ),
1927
- imageStatus === "loaded" && /* @__PURE__ */ jsx7(
1357
+ imageStatus === "loaded" && /* @__PURE__ */ jsx5(
1928
1358
  AnnotationCanvas,
1929
1359
  {
1930
1360
  width: imgSize.width,
@@ -1943,28 +1373,28 @@ var ImageGalleryLightbox = ({
1943
1373
  ]
1944
1374
  }
1945
1375
  ),
1946
- imageStatus === "loading" && /* @__PURE__ */ jsxs5("div", { className: "tbib-iv-status-overlay", children: [
1947
- /* @__PURE__ */ jsx7("div", { className: "tbib-iv-spinner", children: /* @__PURE__ */ jsx7(FontAwesomeIcon4, { icon: faSpinner3, spin: true, className: "tbib-iv-spinner-icon" }) }),
1948
- /* @__PURE__ */ jsx7("span", { className: "tbib-iv-status-text", children: "Chargement de l'illustration..." })
1376
+ imageStatus === "loading" && /* @__PURE__ */ jsxs4("div", { className: "tbib-iv-status-overlay", children: [
1377
+ /* @__PURE__ */ jsx5("div", { className: "tbib-iv-spinner", children: /* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faSpinner2, spin: true, className: "tbib-iv-spinner-icon" }) }),
1378
+ /* @__PURE__ */ jsx5("span", { className: "tbib-iv-status-text", children: "Chargement de l'illustration..." })
1949
1379
  ] }),
1950
- imageStatus === "error" && /* @__PURE__ */ jsxs5("div", { className: "tbib-iv-status-overlay tbib-iv-error-card", children: [
1951
- /* @__PURE__ */ jsx7("div", { className: "tbib-iv-error-icon", children: /* @__PURE__ */ jsx7(FontAwesomeIcon4, { icon: faExclamationTriangle2 }) }),
1952
- /* @__PURE__ */ jsx7("h3", { className: "tbib-iv-error-title", children: "Impossible de charger l'image" }),
1953
- /* @__PURE__ */ jsx7("p", { className: "tbib-iv-error-desc", children: "Le fichier est temporairement inaccessible ou une erreur r\xE9seau est survenue." }),
1954
- /* @__PURE__ */ jsxs5("div", { className: "tbib-iv-error-actions", children: [
1955
- /* @__PURE__ */ jsxs5(
1380
+ imageStatus === "error" && /* @__PURE__ */ jsxs4("div", { className: "tbib-iv-status-overlay tbib-iv-error-card", children: [
1381
+ /* @__PURE__ */ jsx5("div", { className: "tbib-iv-error-icon", children: /* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faExclamationTriangle2 }) }),
1382
+ /* @__PURE__ */ jsx5("h3", { className: "tbib-iv-error-title", children: "Impossible de charger l'image" }),
1383
+ /* @__PURE__ */ jsx5("p", { className: "tbib-iv-error-desc", children: "Le fichier est temporairement inaccessible ou une erreur r\xE9seau est survenue." }),
1384
+ /* @__PURE__ */ jsxs4("div", { className: "tbib-iv-error-actions", children: [
1385
+ /* @__PURE__ */ jsxs4(
1956
1386
  "button",
1957
1387
  {
1958
1388
  type: "button",
1959
1389
  className: "tbib-iv-btn tbib-iv-btn-primary tbib-iv-retry-btn",
1960
1390
  onClick: handleReload,
1961
1391
  children: [
1962
- /* @__PURE__ */ jsx7(FontAwesomeIcon4, { icon: faRotateRight3 }),
1963
- /* @__PURE__ */ jsx7("span", { children: "R\xE9essayer" })
1392
+ /* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faRotateRight3 }),
1393
+ /* @__PURE__ */ jsx5("span", { children: "R\xE9essayer" })
1964
1394
  ]
1965
1395
  }
1966
1396
  ),
1967
- currentItem?.src && /* @__PURE__ */ jsxs5(
1397
+ currentItem?.src && /* @__PURE__ */ jsxs4(
1968
1398
  "a",
1969
1399
  {
1970
1400
  href: currentItem.src,
@@ -1972,18 +1402,18 @@ var ImageGalleryLightbox = ({
1972
1402
  rel: "noopener noreferrer",
1973
1403
  className: "tbib-iv-btn tbib-iv-open-btn",
1974
1404
  children: [
1975
- /* @__PURE__ */ jsx7(FontAwesomeIcon4, { icon: faExternalLinkAlt2 }),
1976
- /* @__PURE__ */ jsx7("span", { children: "Lien direct" })
1405
+ /* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faExternalLinkAlt2 }),
1406
+ /* @__PURE__ */ jsx5("span", { children: "Lien direct" })
1977
1407
  ]
1978
1408
  }
1979
1409
  )
1980
1410
  ] })
1981
1411
  ] }),
1982
- activeTool === "laser" && imageStatus === "loaded" && /* @__PURE__ */ jsx7(LaserCursorLayer, { color, secondaryColor: color, enabled: activeTool === "laser" })
1412
+ activeTool === "laser" && imageStatus === "loaded" && /* @__PURE__ */ jsx5(Suspense2, { fallback: null, children: /* @__PURE__ */ jsx5(LaserCursorLayer2, { color, secondaryColor: color, enabled: activeTool === "laser" }) })
1983
1413
  ]
1984
1414
  }
1985
1415
  ),
1986
- showThumbnails && /* @__PURE__ */ jsx7(
1416
+ showThumbnails && /* @__PURE__ */ jsx5(
1987
1417
  ThumbnailStrip,
1988
1418
  {
1989
1419
  items,
@@ -1999,11 +1429,14 @@ var ImageGalleryLightbox = ({
1999
1429
  );
2000
1430
  };
2001
1431
 
1432
+ // src/components/LaserCursorLayer.tsx
1433
+ import { LaserCursorLayer as LaserCursorLayer3 } from "@tbib-ink/react/laser";
1434
+
2002
1435
  // src/components/ColorPicker.tsx
2003
- import { useState as useState6, useRef as useRef8, useEffect as useEffect5 } from "react";
2004
- import { FontAwesomeIcon as FontAwesomeIcon5 } from "@fortawesome/react-fontawesome";
1436
+ import { useState as useState6, useRef as useRef6, useEffect as useEffect3 } from "react";
1437
+ import { FontAwesomeIcon as FontAwesomeIcon4 } from "@fortawesome/react-fontawesome";
2005
1438
  import { faPalette } from "@fortawesome/free-solid-svg-icons";
2006
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
1439
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
2007
1440
  var PRESET_COLORS2 = [
2008
1441
  "#ef4444",
2009
1442
  // Red (Danger / Anatomy landmark)
@@ -2024,8 +1457,8 @@ var PRESET_COLORS2 = [
2024
1457
  ];
2025
1458
  var ColorPicker = ({ color, onChange }) => {
2026
1459
  const [isOpen, setIsOpen] = useState6(false);
2027
- const containerRef = useRef8(null);
2028
- useEffect5(() => {
1460
+ const containerRef = useRef6(null);
1461
+ useEffect3(() => {
2029
1462
  const handleOutsideClick = (e) => {
2030
1463
  if (containerRef.current && !containerRef.current.contains(e.target)) {
2031
1464
  setIsOpen(false);
@@ -2038,8 +1471,8 @@ var ColorPicker = ({ color, onChange }) => {
2038
1471
  document.removeEventListener("mousedown", handleOutsideClick);
2039
1472
  };
2040
1473
  }, [isOpen]);
2041
- return /* @__PURE__ */ jsxs6("div", { ref: containerRef, style: { position: "relative", display: "inline-block" }, children: [
2042
- /* @__PURE__ */ jsxs6(
1474
+ return /* @__PURE__ */ jsxs5("div", { ref: containerRef, style: { position: "relative", display: "inline-block" }, children: [
1475
+ /* @__PURE__ */ jsxs5(
2043
1476
  "button",
2044
1477
  {
2045
1478
  type: "button",
@@ -2047,7 +1480,7 @@ var ColorPicker = ({ color, onChange }) => {
2047
1480
  title: "Annotation Color",
2048
1481
  onClick: () => setIsOpen((prev) => !prev),
2049
1482
  children: [
2050
- /* @__PURE__ */ jsx8(
1483
+ /* @__PURE__ */ jsx6(
2051
1484
  "span",
2052
1485
  {
2053
1486
  style: {
@@ -2061,11 +1494,11 @@ var ColorPicker = ({ color, onChange }) => {
2061
1494
  }
2062
1495
  }
2063
1496
  ),
2064
- /* @__PURE__ */ jsx8(FontAwesomeIcon5, { icon: faPalette, style: { fontSize: "12px", opacity: 0.8 } })
1497
+ /* @__PURE__ */ jsx6(FontAwesomeIcon4, { icon: faPalette, style: { fontSize: "12px", opacity: 0.8 } })
2065
1498
  ]
2066
1499
  }
2067
1500
  ),
2068
- isOpen && /* @__PURE__ */ jsx8("div", { className: "tbib-iv-popover", children: PRESET_COLORS2.map((c) => /* @__PURE__ */ jsx8(
1501
+ isOpen && /* @__PURE__ */ jsx6("div", { className: "tbib-iv-popover", children: PRESET_COLORS2.map((c) => /* @__PURE__ */ jsx6(
2069
1502
  "button",
2070
1503
  {
2071
1504
  type: "button",
@@ -2083,8 +1516,8 @@ var ColorPicker = ({ color, onChange }) => {
2083
1516
  };
2084
1517
 
2085
1518
  // src/components/StrokeWidthPicker.tsx
2086
- import { useState as useState7, useRef as useRef9, useEffect as useEffect6 } from "react";
2087
- import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
1519
+ import { useState as useState7, useRef as useRef7, useEffect as useEffect4 } from "react";
1520
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
2088
1521
  var WIDTH_OPTIONS = [
2089
1522
  { label: "Fine (2px)", value: 2, iconSize: "6px" },
2090
1523
  { label: "Medium (4px)", value: 4, iconSize: "10px" },
@@ -2096,8 +1529,8 @@ var StrokeWidthPicker = ({
2096
1529
  onChange
2097
1530
  }) => {
2098
1531
  const [isOpen, setIsOpen] = useState7(false);
2099
- const containerRef = useRef9(null);
2100
- useEffect6(() => {
1532
+ const containerRef = useRef7(null);
1533
+ useEffect4(() => {
2101
1534
  const handleOutsideClick = (e) => {
2102
1535
  if (containerRef.current && !containerRef.current.contains(e.target)) {
2103
1536
  setIsOpen(false);
@@ -2111,15 +1544,15 @@ var StrokeWidthPicker = ({
2111
1544
  };
2112
1545
  }, [isOpen]);
2113
1546
  const currentOption = WIDTH_OPTIONS.find((o) => o.value === strokeWidth) || WIDTH_OPTIONS[1];
2114
- return /* @__PURE__ */ jsxs7("div", { ref: containerRef, style: { position: "relative", display: "inline-block" }, children: [
2115
- /* @__PURE__ */ jsx9(
1547
+ return /* @__PURE__ */ jsxs6("div", { ref: containerRef, style: { position: "relative", display: "inline-block" }, children: [
1548
+ /* @__PURE__ */ jsx7(
2116
1549
  "button",
2117
1550
  {
2118
1551
  type: "button",
2119
1552
  className: "tbib-iv-btn",
2120
1553
  title: "Stroke Thickness",
2121
1554
  onClick: () => setIsOpen((prev) => !prev),
2122
- children: /* @__PURE__ */ jsx9(
1555
+ children: /* @__PURE__ */ jsx7(
2123
1556
  "span",
2124
1557
  {
2125
1558
  style: {
@@ -2129,7 +1562,7 @@ var StrokeWidthPicker = ({
2129
1562
  width: "16px",
2130
1563
  height: "16px"
2131
1564
  },
2132
- children: /* @__PURE__ */ jsx9(
1565
+ children: /* @__PURE__ */ jsx7(
2133
1566
  "span",
2134
1567
  {
2135
1568
  style: {
@@ -2144,7 +1577,7 @@ var StrokeWidthPicker = ({
2144
1577
  )
2145
1578
  }
2146
1579
  ),
2147
- isOpen && /* @__PURE__ */ jsx9(
1580
+ isOpen && /* @__PURE__ */ jsx7(
2148
1581
  "div",
2149
1582
  {
2150
1583
  className: "tbib-iv-popover",
@@ -2153,7 +1586,7 @@ var StrokeWidthPicker = ({
2153
1586
  minWidth: "120px",
2154
1587
  padding: "4px"
2155
1588
  },
2156
- children: WIDTH_OPTIONS.map((opt) => /* @__PURE__ */ jsxs7(
1589
+ children: WIDTH_OPTIONS.map((opt) => /* @__PURE__ */ jsxs6(
2157
1590
  "button",
2158
1591
  {
2159
1592
  type: "button",
@@ -2170,7 +1603,7 @@ var StrokeWidthPicker = ({
2170
1603
  setIsOpen(false);
2171
1604
  },
2172
1605
  children: [
2173
- /* @__PURE__ */ jsx9(
1606
+ /* @__PURE__ */ jsx7(
2174
1607
  "span",
2175
1608
  {
2176
1609
  style: {
@@ -2182,7 +1615,7 @@ var StrokeWidthPicker = ({
2182
1615
  }
2183
1616
  }
2184
1617
  ),
2185
- /* @__PURE__ */ jsx9("span", { children: opt.label })
1618
+ /* @__PURE__ */ jsx7("span", { children: opt.label })
2186
1619
  ]
2187
1620
  },
2188
1621
  opt.value
@@ -2191,6 +1624,183 @@ var StrokeWidthPicker = ({
2191
1624
  )
2192
1625
  ] });
2193
1626
  };
1627
+
1628
+ // src/components/DownloadMenu.tsx
1629
+ import { useState as useState8, useRef as useRef8, useEffect as useEffect5 } from "react";
1630
+ import { FontAwesomeIcon as FontAwesomeIcon5 } from "@fortawesome/react-fontawesome";
1631
+ import {
1632
+ faDownload as faDownload2,
1633
+ faImage as faImage2,
1634
+ faPaintBrush,
1635
+ faSpinner as faSpinner3,
1636
+ faChevronDown
1637
+ } from "@fortawesome/free-solid-svg-icons";
1638
+ import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
1639
+ var DownloadMenu = ({
1640
+ onDownloadAnnotated,
1641
+ onDownloadClean,
1642
+ onExportJson
1643
+ }) => {
1644
+ const [isOpen, setIsOpen] = useState8(false);
1645
+ const [isExporting, setIsExporting] = useState8(false);
1646
+ const [popoverPos, setPopoverPos] = useState8({ top: 0, right: 0 });
1647
+ const containerRef = useRef8(null);
1648
+ useEffect5(() => {
1649
+ if (isOpen && containerRef.current) {
1650
+ const rect = containerRef.current.getBoundingClientRect();
1651
+ setPopoverPos({
1652
+ top: rect.bottom + 8,
1653
+ right: Math.max(12, window.innerWidth - rect.right)
1654
+ });
1655
+ }
1656
+ }, [isOpen]);
1657
+ useEffect5(() => {
1658
+ const handleOutsideClick = (e) => {
1659
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
1660
+ setIsOpen(false);
1661
+ }
1662
+ };
1663
+ if (isOpen) {
1664
+ document.addEventListener("mousedown", handleOutsideClick);
1665
+ document.addEventListener("touchstart", handleOutsideClick);
1666
+ }
1667
+ return () => {
1668
+ document.removeEventListener("mousedown", handleOutsideClick);
1669
+ document.removeEventListener("touchstart", handleOutsideClick);
1670
+ };
1671
+ }, [isOpen]);
1672
+ const handleAnnotated = async () => {
1673
+ if (isExporting) return;
1674
+ setIsExporting(true);
1675
+ try {
1676
+ await onDownloadAnnotated();
1677
+ } finally {
1678
+ setIsExporting(false);
1679
+ setIsOpen(false);
1680
+ }
1681
+ };
1682
+ const handleClean = async () => {
1683
+ if (isExporting) return;
1684
+ setIsExporting(true);
1685
+ try {
1686
+ await onDownloadClean();
1687
+ } finally {
1688
+ setIsExporting(false);
1689
+ setIsOpen(false);
1690
+ }
1691
+ };
1692
+ return /* @__PURE__ */ jsxs7(
1693
+ "div",
1694
+ {
1695
+ ref: containerRef,
1696
+ style: {
1697
+ position: "relative",
1698
+ display: "inline-flex",
1699
+ alignItems: "center"
1700
+ },
1701
+ children: [
1702
+ /* @__PURE__ */ jsx8(
1703
+ "button",
1704
+ {
1705
+ type: "button",
1706
+ className: "tbib-iv-btn",
1707
+ title: "Download Annotated Image (1-Click PNG)",
1708
+ "aria-label": "Download Image",
1709
+ disabled: isExporting,
1710
+ onClick: handleAnnotated,
1711
+ style: {
1712
+ borderTopRightRadius: 0,
1713
+ borderBottomRightRadius: 0,
1714
+ paddingRight: "6px"
1715
+ },
1716
+ children: /* @__PURE__ */ jsx8(
1717
+ FontAwesomeIcon5,
1718
+ {
1719
+ icon: isExporting ? faSpinner3 : faDownload2,
1720
+ className: isExporting ? "fa-spin" : "",
1721
+ style: { fontSize: "14px" }
1722
+ }
1723
+ )
1724
+ }
1725
+ ),
1726
+ /* @__PURE__ */ jsx8(
1727
+ "button",
1728
+ {
1729
+ type: "button",
1730
+ className: "tbib-iv-btn",
1731
+ title: "More Download Options",
1732
+ "aria-label": "More Download Options",
1733
+ disabled: isExporting,
1734
+ onClick: () => setIsOpen((prev) => !prev),
1735
+ style: {
1736
+ borderTopLeftRadius: 0,
1737
+ borderBottomLeftRadius: 0,
1738
+ paddingLeft: "4px",
1739
+ paddingRight: "6px",
1740
+ minWidth: "20px",
1741
+ borderLeft: "1px solid var(--tbib-iv-border)"
1742
+ },
1743
+ children: /* @__PURE__ */ jsx8(FontAwesomeIcon5, { icon: faChevronDown, style: { fontSize: "10px", opacity: 0.8 } })
1744
+ }
1745
+ ),
1746
+ isOpen && /* @__PURE__ */ jsxs7(
1747
+ "div",
1748
+ {
1749
+ className: "tbib-iv-popover",
1750
+ style: {
1751
+ position: "fixed",
1752
+ top: `${popoverPos.top}px`,
1753
+ right: `${popoverPos.right}px`,
1754
+ flexDirection: "column",
1755
+ minWidth: "210px",
1756
+ zIndex: 9999
1757
+ },
1758
+ children: [
1759
+ /* @__PURE__ */ jsxs7(
1760
+ "button",
1761
+ {
1762
+ type: "button",
1763
+ className: "tbib-iv-btn",
1764
+ style: {
1765
+ width: "100%",
1766
+ justifyContent: "flex-start",
1767
+ gap: "10px",
1768
+ padding: "8px 10px",
1769
+ fontSize: "12px"
1770
+ },
1771
+ onClick: handleAnnotated,
1772
+ children: [
1773
+ /* @__PURE__ */ jsx8(FontAwesomeIcon5, { icon: faPaintBrush, style: { fontSize: "13px", color: "var(--tbib-iv-accent)" } }),
1774
+ /* @__PURE__ */ jsx8("span", { children: "Annotated Image (PNG)" })
1775
+ ]
1776
+ }
1777
+ ),
1778
+ /* @__PURE__ */ jsxs7(
1779
+ "button",
1780
+ {
1781
+ type: "button",
1782
+ className: "tbib-iv-btn",
1783
+ style: {
1784
+ width: "100%",
1785
+ justifyContent: "flex-start",
1786
+ gap: "10px",
1787
+ padding: "8px 10px",
1788
+ fontSize: "12px"
1789
+ },
1790
+ onClick: handleClean,
1791
+ children: [
1792
+ /* @__PURE__ */ jsx8(FontAwesomeIcon5, { icon: faImage2, style: { fontSize: "13px" } }),
1793
+ /* @__PURE__ */ jsx8("span", { children: "Clean Image (Original)" })
1794
+ ]
1795
+ }
1796
+ )
1797
+ ]
1798
+ }
1799
+ )
1800
+ ]
1801
+ }
1802
+ );
1803
+ };
2194
1804
  export {
2195
1805
  AnnotationCanvas,
2196
1806
  ColorPicker,
@@ -2198,7 +1808,7 @@ export {
2198
1808
  ImageGalleryLightbox,
2199
1809
  ImageToolbar,
2200
1810
  ImageViewer,
2201
- LaserCursorLayer,
1811
+ LaserCursorLayer3 as LaserCursorLayer,
2202
1812
  StrokeWidthPicker,
2203
1813
  ThumbnailStrip,
2204
1814
  useImageTransform,