@tbib-image-viewer/react 0.1.5 → 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.js CHANGED
@@ -36,7 +36,7 @@ __export(index_exports, {
36
36
  ImageGalleryLightbox: () => ImageGalleryLightbox,
37
37
  ImageToolbar: () => ImageToolbar,
38
38
  ImageViewer: () => ImageViewer,
39
- LaserCursorLayer: () => LaserCursorLayer,
39
+ LaserCursorLayer: () => import_laser.LaserCursorLayer,
40
40
  StrokeWidthPicker: () => StrokeWidthPicker,
41
41
  ThumbnailStrip: () => ThumbnailStrip,
42
42
  useImageTransform: () => useImageTransform,
@@ -45,191 +45,19 @@ __export(index_exports, {
45
45
  module.exports = __toCommonJS(index_exports);
46
46
 
47
47
  // src/components/ImageViewer.tsx
48
- var import_react6 = require("react");
49
- var import_react_fontawesome3 = require("@fortawesome/react-fontawesome");
50
- var import_free_solid_svg_icons3 = require("@fortawesome/free-solid-svg-icons");
48
+ var import_react5 = require("react");
49
+ var import_react_fontawesome2 = require("@fortawesome/react-fontawesome");
50
+ var import_free_solid_svg_icons2 = require("@fortawesome/free-solid-svg-icons");
51
51
  var import_faExclamationTriangle = require("@fortawesome/free-solid-svg-icons/faExclamationTriangle");
52
52
  var import_faExternalLinkAlt = require("@fortawesome/free-solid-svg-icons/faExternalLinkAlt");
53
53
  var import_core3 = require("@tbib-image-viewer/core");
54
54
 
55
55
  // src/components/ImageToolbar.tsx
56
- var import_react2 = __toESM(require("react"));
57
- var import_react_fontawesome2 = require("@fortawesome/react-fontawesome");
58
- var import_free_solid_svg_icons2 = require("@fortawesome/free-solid-svg-icons");
59
-
60
- // src/components/DownloadMenu.tsx
61
56
  var import_react = require("react");
62
57
  var import_react_fontawesome = require("@fortawesome/react-fontawesome");
63
58
  var import_free_solid_svg_icons = require("@fortawesome/free-solid-svg-icons");
59
+ var import_react2 = require("@tbib-ink/react");
64
60
  var import_jsx_runtime = require("react/jsx-runtime");
65
- var DownloadMenu = ({
66
- onDownloadAnnotated,
67
- onDownloadClean,
68
- onExportJson
69
- }) => {
70
- const [isOpen, setIsOpen] = (0, import_react.useState)(false);
71
- const [isExporting, setIsExporting] = (0, import_react.useState)(false);
72
- const [popoverPos, setPopoverPos] = (0, import_react.useState)({ top: 0, right: 0 });
73
- const containerRef = (0, import_react.useRef)(null);
74
- (0, import_react.useEffect)(() => {
75
- if (isOpen && containerRef.current) {
76
- const rect = containerRef.current.getBoundingClientRect();
77
- setPopoverPos({
78
- top: rect.bottom + 8,
79
- right: Math.max(12, window.innerWidth - rect.right)
80
- });
81
- }
82
- }, [isOpen]);
83
- (0, import_react.useEffect)(() => {
84
- const handleOutsideClick = (e) => {
85
- if (containerRef.current && !containerRef.current.contains(e.target)) {
86
- setIsOpen(false);
87
- }
88
- };
89
- if (isOpen) {
90
- document.addEventListener("mousedown", handleOutsideClick);
91
- document.addEventListener("touchstart", handleOutsideClick);
92
- }
93
- return () => {
94
- document.removeEventListener("mousedown", handleOutsideClick);
95
- document.removeEventListener("touchstart", handleOutsideClick);
96
- };
97
- }, [isOpen]);
98
- const handleAnnotated = async () => {
99
- if (isExporting) return;
100
- setIsExporting(true);
101
- try {
102
- await onDownloadAnnotated();
103
- } finally {
104
- setIsExporting(false);
105
- setIsOpen(false);
106
- }
107
- };
108
- const handleClean = async () => {
109
- if (isExporting) return;
110
- setIsExporting(true);
111
- try {
112
- await onDownloadClean();
113
- } finally {
114
- setIsExporting(false);
115
- setIsOpen(false);
116
- }
117
- };
118
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
119
- "div",
120
- {
121
- ref: containerRef,
122
- style: {
123
- position: "relative",
124
- display: "inline-flex",
125
- alignItems: "center"
126
- },
127
- children: [
128
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
129
- "button",
130
- {
131
- type: "button",
132
- className: "tbib-iv-btn",
133
- title: "Download Annotated Image (1-Click PNG)",
134
- "aria-label": "Download Image",
135
- disabled: isExporting,
136
- onClick: handleAnnotated,
137
- style: {
138
- borderTopRightRadius: 0,
139
- borderBottomRightRadius: 0,
140
- paddingRight: "6px"
141
- },
142
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
143
- import_react_fontawesome.FontAwesomeIcon,
144
- {
145
- icon: isExporting ? import_free_solid_svg_icons.faSpinner : import_free_solid_svg_icons.faDownload,
146
- className: isExporting ? "fa-spin" : "",
147
- style: { fontSize: "14px" }
148
- }
149
- )
150
- }
151
- ),
152
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
153
- "button",
154
- {
155
- type: "button",
156
- className: "tbib-iv-btn",
157
- title: "More Download Options",
158
- "aria-label": "More Download Options",
159
- disabled: isExporting,
160
- onClick: () => setIsOpen((prev) => !prev),
161
- style: {
162
- borderTopLeftRadius: 0,
163
- borderBottomLeftRadius: 0,
164
- paddingLeft: "4px",
165
- paddingRight: "6px",
166
- minWidth: "20px",
167
- borderLeft: "1px solid var(--tbib-iv-border)"
168
- },
169
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_fontawesome.FontAwesomeIcon, { icon: import_free_solid_svg_icons.faChevronDown, style: { fontSize: "10px", opacity: 0.8 } })
170
- }
171
- ),
172
- isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
173
- "div",
174
- {
175
- className: "tbib-iv-popover",
176
- style: {
177
- position: "fixed",
178
- top: `${popoverPos.top}px`,
179
- right: `${popoverPos.right}px`,
180
- flexDirection: "column",
181
- minWidth: "210px",
182
- zIndex: 9999
183
- },
184
- children: [
185
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
186
- "button",
187
- {
188
- type: "button",
189
- className: "tbib-iv-btn",
190
- style: {
191
- width: "100%",
192
- justifyContent: "flex-start",
193
- gap: "10px",
194
- padding: "8px 10px",
195
- fontSize: "12px"
196
- },
197
- onClick: handleAnnotated,
198
- children: [
199
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_fontawesome.FontAwesomeIcon, { icon: import_free_solid_svg_icons.faPaintBrush, style: { fontSize: "13px", color: "var(--tbib-iv-accent)" } }),
200
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Annotated Image (PNG)" })
201
- ]
202
- }
203
- ),
204
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
205
- "button",
206
- {
207
- type: "button",
208
- className: "tbib-iv-btn",
209
- style: {
210
- width: "100%",
211
- justifyContent: "flex-start",
212
- gap: "10px",
213
- padding: "8px 10px",
214
- fontSize: "12px"
215
- },
216
- onClick: handleClean,
217
- children: [
218
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_fontawesome.FontAwesomeIcon, { icon: import_free_solid_svg_icons.faImage, style: { fontSize: "13px" } }),
219
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Clean Image (Original)" })
220
- ]
221
- }
222
- )
223
- ]
224
- }
225
- )
226
- ]
227
- }
228
- );
229
- };
230
-
231
- // src/components/ImageToolbar.tsx
232
- var import_jsx_runtime2 = require("react/jsx-runtime");
233
61
  var PRESET_COLORS = [
234
62
  "#ef4444",
235
63
  // Red
@@ -249,11 +77,46 @@ var PRESET_COLORS = [
249
77
  // Black
250
78
  ];
251
79
  var THICKNESS_OPTIONS = [
252
- { label: "Fine", value: 2 },
253
- { label: "Medium", value: 4 },
254
- { label: "Bold", value: 7 },
255
- { label: "Heavy", value: 12 }
80
+ { label: "Fin", value: 2 },
81
+ { label: "Moyen", value: 4 },
82
+ { label: "\xC9pais", value: 7 },
83
+ { label: "Gras", value: 12 }
256
84
  ];
85
+ var TOOLS = [
86
+ { id: "hand", label: "Main", icon: import_free_solid_svg_icons.faHand, shortcut: "H" },
87
+ { id: "pen", label: "Stylo", icon: import_free_solid_svg_icons.faPen, shortcut: "P", hasOptions: true },
88
+ { id: "highlighter", label: "Surligneur", icon: import_free_solid_svg_icons.faHighlighter, shortcut: "S", hasOptions: true },
89
+ { id: "eraser", label: "Gomme", icon: import_free_solid_svg_icons.faEraser, shortcut: "E" },
90
+ { id: "laser", label: "Laser", icon: import_free_solid_svg_icons.faWandMagicSparkles, shortcut: "L", hasOptions: true }
91
+ ];
92
+ var panelStyle = {
93
+ display: "flex",
94
+ flexDirection: "column",
95
+ gap: 10,
96
+ padding: 12,
97
+ width: "min(296px, calc(100vw - 24px))",
98
+ background: "var(--tbi-surface)",
99
+ border: "1px solid var(--tbi-border)",
100
+ borderRadius: 16,
101
+ boxShadow: "var(--tbi-shadow)",
102
+ color: "var(--tbi-fg)"
103
+ };
104
+ var chipStyle = (active) => ({
105
+ display: "inline-flex",
106
+ alignItems: "center",
107
+ justifyContent: "center",
108
+ gap: 6,
109
+ padding: "7px 0",
110
+ flex: 1,
111
+ borderRadius: 10,
112
+ border: `1px solid ${active ? "color-mix(in oklch, var(--tbi-primary) 40%, transparent)" : "var(--tbi-border)"}`,
113
+ background: active ? "color-mix(in oklch, var(--tbi-primary) 15%, transparent)" : "var(--tbi-surface-2)",
114
+ color: active ? "var(--tbi-primary)" : "var(--tbi-fg)",
115
+ font: "inherit",
116
+ fontSize: 11,
117
+ fontWeight: 700,
118
+ cursor: "pointer"
119
+ });
257
120
  var ImageToolbar = ({
258
121
  activeTool,
259
122
  onToolChange,
@@ -278,311 +141,198 @@ var ImageToolbar = ({
278
141
  isFullscreen,
279
142
  onToggleFullscreen,
280
143
  currentIndex,
281
- totalImages
144
+ totalImages,
145
+ theme = "dark"
282
146
  }) => {
283
- const showSubtoolbar = activeTool === "pen" || activeTool === "highlighter" || activeTool === "laser";
284
- const toolbarRef = import_react2.default.useRef(null);
285
- const subtoolbarRef = import_react2.default.useRef(null);
286
- const toolbarTouchState = import_react2.default.useRef({ isDown: false, startX: 0, scrollLeft: 0 });
287
- const subtoolbarTouchState = import_react2.default.useRef({ isDown: false, startX: 0, scrollLeft: 0 });
288
- const handleToolbarTouchStart = (e) => {
289
- if (!toolbarRef.current) return;
290
- toolbarTouchState.current = {
291
- isDown: true,
292
- startX: e.touches[0].clientX,
293
- scrollLeft: toolbarRef.current.scrollLeft
294
- };
295
- };
296
- const handleToolbarTouchMove = (e) => {
297
- if (!toolbarTouchState.current.isDown || !toolbarRef.current) return;
298
- const dx = e.touches[0].clientX - toolbarTouchState.current.startX;
299
- toolbarRef.current.scrollLeft = toolbarTouchState.current.scrollLeft - dx;
300
- };
301
- const handleToolbarTouchEnd = () => {
302
- toolbarTouchState.current.isDown = false;
303
- };
304
- const handleSubtoolbarTouchStart = (e) => {
305
- if (!subtoolbarRef.current) return;
306
- subtoolbarTouchState.current = {
307
- isDown: true,
308
- startX: e.touches[0].clientX,
309
- scrollLeft: subtoolbarRef.current.scrollLeft
310
- };
311
- };
312
- const handleSubtoolbarTouchMove = (e) => {
313
- if (!subtoolbarTouchState.current.isDown || !subtoolbarRef.current) return;
314
- const dx = e.touches[0].clientX - subtoolbarTouchState.current.startX;
315
- subtoolbarRef.current.scrollLeft = subtoolbarTouchState.current.scrollLeft - dx;
316
- };
317
- const handleSubtoolbarTouchEnd = () => {
318
- subtoolbarTouchState.current.isDown = false;
147
+ const [downloadOpen, setDownloadOpen] = (0, import_react.useState)(false);
148
+ const [downloading, setDownloading] = (0, import_react.useState)(false);
149
+ const runDownload = async (fn) => {
150
+ setDownloadOpen(false);
151
+ setDownloading(true);
152
+ try {
153
+ await fn();
154
+ } finally {
155
+ setDownloading(false);
156
+ }
319
157
  };
320
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "tbib-iv-toolbar-wrapper", children: [
321
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
322
- "header",
323
- {
324
- ref: toolbarRef,
325
- className: "tbib-iv-toolbar",
326
- role: "toolbar",
327
- "aria-label": "Image tools",
328
- onTouchStart: handleToolbarTouchStart,
329
- onTouchMove: handleToolbarTouchMove,
330
- onTouchEnd: handleToolbarTouchEnd,
331
- children: [
332
- currentIndex !== void 0 && totalImages !== void 0 && totalImages > 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
333
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "tbib-iv-tabular", title: "Current Image", children: [
334
- currentIndex + 1,
335
- " / ",
336
- totalImages
337
- ] }),
338
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" })
339
- ] }),
340
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
341
- "button",
342
- {
343
- type: "button",
344
- className: `tbib-iv-btn ${activeTool === "hand" ? "tbib-iv-btn-active" : ""}`,
345
- onClick: () => onToolChange("hand"),
346
- title: "Pan & Move (1-finger / drag)",
347
- "aria-label": "Hand Pan Tool",
348
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faHand })
349
- }
350
- ),
351
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
352
- "button",
353
- {
354
- type: "button",
355
- className: `tbib-iv-btn ${activeTool === "pen" ? "tbib-iv-btn-active" : ""}`,
356
- onClick: () => onToolChange("pen"),
357
- title: "Draw Pen",
358
- "aria-label": "Pen Tool",
359
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faPen })
360
- }
361
- ),
362
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
363
- "button",
364
- {
365
- type: "button",
366
- className: `tbib-iv-btn ${activeTool === "highlighter" ? "tbib-iv-btn-active" : ""}`,
367
- onClick: () => onToolChange("highlighter"),
368
- title: "Highlighter (Semi-transparent)",
369
- "aria-label": "Highlighter Tool",
370
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faHighlighter })
371
- }
372
- ),
373
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
374
- "button",
375
- {
376
- type: "button",
377
- className: `tbib-iv-btn ${activeTool === "laser" ? "tbib-iv-btn-active" : ""}`,
378
- onClick: () => onToolChange("laser"),
379
- title: "Laser Pointer (Glowing WebGL trail)",
380
- "aria-label": "Laser Pointer",
381
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faCrosshairs })
382
- }
383
- ),
384
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
385
- "button",
386
- {
387
- type: "button",
388
- className: `tbib-iv-btn ${activeTool === "eraser" ? "tbib-iv-btn-active" : ""}`,
389
- onClick: () => onToolChange("eraser"),
390
- title: "Eraser (Erase strokes on tap)",
391
- "aria-label": "Eraser Tool",
392
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faEraser })
393
- }
394
- ),
395
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" }),
396
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
397
- "button",
398
- {
399
- type: "button",
400
- className: "tbib-iv-btn",
401
- disabled: !canUndo,
402
- onClick: onUndo,
403
- title: "Undo (Ctrl+Z)",
404
- "aria-label": "Undo",
405
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faRotateLeft })
406
- }
407
- ),
408
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
409
- "button",
410
- {
411
- type: "button",
412
- className: "tbib-iv-btn",
413
- disabled: !canRedo,
414
- onClick: onRedo,
415
- title: "Redo (Ctrl+Y)",
416
- "aria-label": "Redo",
417
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faRotateRight })
418
- }
419
- ),
420
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
421
- "button",
422
- {
423
- type: "button",
424
- className: "tbib-iv-btn",
425
- onClick: onClear,
426
- title: "Clear Slide Annotations",
427
- "aria-label": "Clear All",
428
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faTrashCan })
429
- }
430
- ),
431
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" }),
432
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
433
- "button",
434
- {
435
- type: "button",
436
- className: "tbib-iv-btn",
437
- onClick: onZoomOut,
438
- title: "Zoom Out (-)",
439
- "aria-label": "Zoom Out",
440
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faMagnifyingGlassMinus })
441
- }
442
- ),
443
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "tbib-iv-tabular", title: "Current Zoom Scale", children: [
444
- Math.round(zoomScale * 100),
445
- "%"
446
- ] }),
447
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
448
- "button",
449
- {
450
- type: "button",
451
- className: "tbib-iv-btn",
452
- onClick: onZoomIn,
453
- title: "Zoom In (+)",
454
- "aria-label": "Zoom In",
455
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faMagnifyingGlassPlus })
456
- }
457
- ),
458
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
459
- "button",
460
- {
461
- type: "button",
462
- className: "tbib-iv-btn",
463
- onClick: onZoomReset,
464
- title: "Reset Fit to Screen (0)",
465
- "aria-label": "Reset Zoom",
466
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faExpand })
467
- }
468
- ),
469
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
470
- "button",
471
- {
472
- type: "button",
473
- className: "tbib-iv-btn",
474
- onClick: onRotate,
475
- title: "Rotate 90\xB0 Clockwise",
476
- "aria-label": "Rotate Image",
477
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faRotate })
478
- }
479
- ),
480
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" }),
481
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
482
- DownloadMenu,
483
- {
484
- onDownloadAnnotated,
485
- onDownloadClean,
486
- onExportJson
487
- }
488
- ),
489
- onToggleFullscreen && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
490
- "button",
491
- {
492
- type: "button",
493
- className: "tbib-iv-btn",
494
- onClick: onToggleFullscreen,
495
- title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
496
- "aria-label": "Toggle Fullscreen",
497
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: isFullscreen ? import_free_solid_svg_icons2.faCompressAlt : import_free_solid_svg_icons2.faExpandAlt })
498
- }
499
- ),
500
- onClose && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
501
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" }),
502
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
503
- "button",
158
+ const zoomPct = Math.round(zoomScale * 100);
159
+ const actions = [
160
+ { id: "undo", label: "Annuler", icon: import_free_solid_svg_icons.faRotateLeft, disabled: !canUndo, onSelect: onUndo },
161
+ { id: "redo", label: "R\xE9tablir", icon: import_free_solid_svg_icons.faRotateRight, disabled: !canRedo, onSelect: onRedo },
162
+ { id: "clear", label: "Tout effacer", icon: import_free_solid_svg_icons.faTrashCan, placement: "sheet", onSelect: onClear },
163
+ { id: "zoom-out", label: "Zoom arri\xE8re", icon: import_free_solid_svg_icons.faMagnifyingGlassMinus, onSelect: onZoomOut },
164
+ { id: "zoom-in", label: "Zoom avant", icon: import_free_solid_svg_icons.faMagnifyingGlassPlus, onSelect: onZoomIn },
165
+ { id: "zoom-reset", label: `Ajuster (${zoomPct}%)`, icon: import_free_solid_svg_icons.faExpand, onSelect: onZoomReset },
166
+ { id: "rotate", label: "Pivoter", icon: import_free_solid_svg_icons.faRotate, onSelect: onRotate },
167
+ {
168
+ id: "download",
169
+ label: "T\xE9l\xE9charger",
170
+ icon: import_free_solid_svg_icons.faDownload,
171
+ primary: true,
172
+ busy: downloading,
173
+ active: downloadOpen,
174
+ onSelect: () => setDownloadOpen((v) => !v)
175
+ }
176
+ ];
177
+ if (onToggleFullscreen) {
178
+ actions.push({
179
+ id: "fullscreen",
180
+ label: isFullscreen ? "Quitter le plein \xE9cran" : "Plein \xE9cran",
181
+ icon: isFullscreen ? import_free_solid_svg_icons.faDownLeftAndUpRightToCenter : import_free_solid_svg_icons.faUpRightAndDownLeftFromCenter,
182
+ active: isFullscreen,
183
+ onSelect: onToggleFullscreen
184
+ });
185
+ }
186
+ if (onClose) {
187
+ actions.push({ id: "close", label: "Fermer", icon: import_free_solid_svg_icons.faXmark, placement: "bar", onSelect: onClose });
188
+ }
189
+ const renderToolOptions = (toolId) => {
190
+ const showThickness = toolId === "pen" || toolId === "highlighter";
191
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: panelStyle, role: "group", "aria-label": "Options de l'outil", children: [
192
+ showThickness && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "flex", gap: 6 }, children: THICKNESS_OPTIONS.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
193
+ "button",
194
+ {
195
+ type: "button",
196
+ "aria-pressed": strokeWidth === opt.value,
197
+ style: chipStyle(strokeWidth === opt.value),
198
+ onClick: () => onStrokeWidthChange(opt.value),
199
+ title: `${opt.label} (${opt.value}px)`,
200
+ children: [
201
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
202
+ "span",
504
203
  {
505
- type: "button",
506
- className: "tbib-iv-btn",
507
- onClick: onClose,
508
- title: "Close Viewer (Esc)",
509
- "aria-label": "Close",
510
- style: { color: "#ef4444" },
511
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faXmark, style: { fontSize: "16px" } })
204
+ "aria-hidden": "true",
205
+ style: {
206
+ width: Math.min(opt.value * 1.4, 11),
207
+ height: Math.min(opt.value * 1.4, 11),
208
+ borderRadius: 999,
209
+ background: "currentColor"
210
+ }
512
211
  }
513
- )
514
- ] })
515
- ]
516
- }
517
- ),
518
- showSubtoolbar && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
519
- "div",
520
- {
521
- ref: subtoolbarRef,
522
- className: "tbib-iv-subtoolbar",
523
- role: "region",
524
- "aria-label": "Tool customization",
525
- onTouchStart: handleSubtoolbarTouchStart,
526
- onTouchMove: handleSubtoolbarTouchMove,
527
- onTouchEnd: handleSubtoolbarTouchEnd,
528
- children: [
529
- activeTool !== "laser" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-thickness-group", children: THICKNESS_OPTIONS.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
212
+ ),
213
+ opt.label
214
+ ]
215
+ },
216
+ opt.value
217
+ )) }),
218
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" }, children: [
219
+ PRESET_COLORS.map((c) => {
220
+ const selected = color.toLowerCase() === c.toLowerCase();
221
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
530
222
  "button",
531
223
  {
532
224
  type: "button",
533
- className: `tbib-iv-thickness-btn ${strokeWidth === opt.value ? "tbib-iv-thickness-active" : ""}`,
534
- onClick: () => onStrokeWidthChange(opt.value),
535
- title: `${opt.label} stroke (${opt.value}px)`,
536
- children: [
537
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
538
- "span",
539
- {
540
- style: {
541
- display: "inline-block",
542
- width: `${Math.min(opt.value * 1.5, 12)}px`,
543
- height: `${Math.min(opt.value * 1.5, 12)}px`,
544
- borderRadius: "50%",
545
- backgroundColor: "currentColor"
546
- }
547
- }
548
- ),
549
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: opt.label })
550
- ]
225
+ "aria-label": `Couleur ${c}`,
226
+ "aria-pressed": selected,
227
+ onClick: () => onColorChange(c),
228
+ style: {
229
+ width: 24,
230
+ height: 24,
231
+ borderRadius: 999,
232
+ background: c,
233
+ cursor: "pointer",
234
+ border: "1px solid var(--tbi-border)",
235
+ boxShadow: selected ? "0 0 0 2px var(--tbi-surface), 0 0 0 4px var(--tbi-primary)" : "none"
236
+ }
551
237
  },
552
- opt.value
553
- )) }),
554
- activeTool === "laser" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: "11px", color: "var(--tbib-iv-text-muted)", fontStyle: "italic", paddingRight: "4px" }, children: "Laser Beam Color:" }),
555
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider", style: { height: "16px", margin: "0 2px" } }),
556
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "inline-flex", alignItems: "center", gap: "6px" }, children: [
557
- PRESET_COLORS.map((c) => {
558
- const isSelected = color.toLowerCase() === c.toLowerCase();
559
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
560
- "button",
561
- {
562
- type: "button",
563
- className: `tbib-iv-swatch-btn ${isSelected ? "tbib-iv-swatch-active" : ""}`,
564
- style: { backgroundColor: c },
565
- onClick: () => onColorChange(c),
566
- title: `Select color: ${c}`,
567
- "aria-label": `Color ${c}`
568
- },
569
- c
570
- );
571
- }),
572
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "tbib-iv-custom-color-btn", title: "Custom Color Picker", children: [
573
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faEyeDropper, style: { fontSize: "10px", opacity: 0.8 } }),
574
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
238
+ c
239
+ );
240
+ }),
241
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
242
+ "label",
243
+ {
244
+ title: "Couleur personnalis\xE9e",
245
+ style: {
246
+ position: "relative",
247
+ width: 24,
248
+ height: 24,
249
+ borderRadius: 999,
250
+ display: "inline-flex",
251
+ alignItems: "center",
252
+ justifyContent: "center",
253
+ border: "1px dashed var(--tbi-border)",
254
+ color: "var(--tbi-muted)",
255
+ cursor: "pointer",
256
+ overflow: "hidden"
257
+ },
258
+ children: [
259
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_fontawesome.FontAwesomeIcon, { icon: import_free_solid_svg_icons.faEyeDropper, style: { width: 11, height: 11 } }),
260
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
575
261
  "input",
576
262
  {
577
263
  type: "color",
578
264
  value: color,
579
265
  onChange: (e) => onColorChange(e.target.value),
580
- className: "tbib-iv-custom-color-input",
581
- "aria-label": "Custom color picker"
266
+ "aria-label": "Couleur personnalis\xE9e",
267
+ style: { position: "absolute", inset: 0, opacity: 0, cursor: "pointer" }
582
268
  }
583
269
  )
584
- ] })
585
- ] })
270
+ ]
271
+ }
272
+ )
273
+ ] })
274
+ ] });
275
+ };
276
+ const downloadPanel = downloadOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { ...panelStyle, width: "min(260px, calc(100vw - 24px))", gap: 6 }, role: "menu", "aria-label": "T\xE9l\xE9charger", children: [
277
+ { id: "annotated", label: "Image annot\xE9e (PNG)", icon: import_free_solid_svg_icons.faPenToSquare, run: onDownloadAnnotated },
278
+ { id: "clean", label: "Image originale", icon: import_free_solid_svg_icons.faImage, run: onDownloadClean },
279
+ ...onExportJson ? [{ id: "json", label: "Annotations (JSON)", icon: import_free_solid_svg_icons.faFileCode, run: onExportJson }] : []
280
+ ].map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
281
+ "button",
282
+ {
283
+ type: "button",
284
+ role: "menuitem",
285
+ onClick: () => void runDownload(o.run),
286
+ style: { ...chipStyle(false), justifyContent: "flex-start", padding: "10px 12px", fontSize: 12, gap: 10 },
287
+ children: [
288
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_fontawesome.FontAwesomeIcon, { icon: o.icon, style: { width: 13, height: 13 } }),
289
+ o.label
290
+ ]
291
+ },
292
+ o.id
293
+ )) }) : null;
294
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tbib-iv-toolbar-wrapper", children: [
295
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
296
+ import_react2.InkToolbar,
297
+ {
298
+ theme,
299
+ style: { pointerEvents: "auto" },
300
+ ariaLabel: "Outils de l'image",
301
+ tools: TOOLS,
302
+ activeTool,
303
+ onToolSelect: (id) => {
304
+ setDownloadOpen(false);
305
+ onToolChange(id);
306
+ },
307
+ activeColor: color,
308
+ actions,
309
+ compactTools: ["hand", "pen", "highlighter", "eraser"],
310
+ compactActions: ["undo", "close"],
311
+ renderToolOptions,
312
+ panel: downloadPanel
313
+ }
314
+ ),
315
+ currentIndex !== void 0 && totalImages !== void 0 && totalImages > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
316
+ "span",
317
+ {
318
+ className: "tbi-root",
319
+ "data-theme": theme,
320
+ style: {
321
+ pointerEvents: "none",
322
+ padding: "3px 10px",
323
+ borderRadius: 999,
324
+ fontSize: 11,
325
+ fontWeight: 700,
326
+ fontVariantNumeric: "tabular-nums",
327
+ background: "var(--tbi-surface)",
328
+ border: "1px solid var(--tbi-border)",
329
+ color: "var(--tbi-muted)"
330
+ },
331
+ "aria-label": `Image ${currentIndex + 1} sur ${totalImages}`,
332
+ children: [
333
+ currentIndex + 1,
334
+ " / ",
335
+ totalImages
586
336
  ]
587
337
  }
588
338
  )
@@ -592,7 +342,7 @@ var ImageToolbar = ({
592
342
  // src/components/AnnotationCanvas.tsx
593
343
  var import_react3 = require("react");
594
344
  var import_core = require("@tbib-image-viewer/core");
595
- var import_jsx_runtime3 = require("react/jsx-runtime");
345
+ var import_jsx_runtime2 = require("react/jsx-runtime");
596
346
  var AnnotationCanvas = ({
597
347
  width,
598
348
  height,
@@ -733,7 +483,7 @@ var AnnotationCanvas = ({
733
483
  return (0, import_core.pointsToSvgPath)(currentPoints, width, height);
734
484
  }, [currentPoints, width, height]);
735
485
  const pointerEventsStyle = isDrawableTool || isEraser ? "auto" : "none";
736
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
486
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
737
487
  "svg",
738
488
  {
739
489
  ref: svgRef,
@@ -751,11 +501,11 @@ var AnnotationCanvas = ({
751
501
  onPointerUp: handlePointerUp,
752
502
  onPointerCancel: handlePointerUp,
753
503
  children: [
754
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("filter", { id: "highlighter-blend", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("feBlend", { mode: "multiply" }) }) }),
504
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("filter", { id: "highlighter-blend", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("feBlend", { mode: "multiply" }) }) }),
755
505
  strokes.map((stroke) => {
756
506
  const d = (0, import_core.pointsToSvgPath)(stroke.points, width, height);
757
507
  const isHighlighter = stroke.tool === "highlighter";
758
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
508
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
759
509
  "path",
760
510
  {
761
511
  d,
@@ -766,400 +516,74 @@ var AnnotationCanvas = ({
766
516
  strokeLinejoin: "round",
767
517
  style: {
768
518
  mixBlendMode: isHighlighter ? "multiply" : "normal",
769
- pointerEvents: "none"
770
- }
771
- },
772
- stroke.id
773
- );
774
- }),
775
- currentPathD && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
776
- "path",
777
- {
778
- d: currentPathD,
779
- fill: "none",
780
- stroke: activeTool === "highlighter" ? (0, import_core.hexToRgba)(color, 0.35) : color,
781
- strokeWidth: activeTool === "highlighter" ? strokeWidth * 2.5 : strokeWidth,
782
- strokeLinecap: "round",
783
- strokeLinejoin: "round",
784
- style: {
785
- mixBlendMode: activeTool === "highlighter" ? "multiply" : "normal",
786
- pointerEvents: "none"
787
- }
788
- }
789
- )
790
- ]
791
- }
792
- );
793
- };
794
-
795
- // src/components/LaserCursorLayer.tsx
796
- var import_react4 = require("react");
797
- var import_ogl = require("ogl");
798
- var import_jsx_runtime4 = require("react/jsx-runtime");
799
- var MAX_POINTS = 64;
800
- var VERTEX_SHADER = `
801
- attribute vec2 position;
802
- attribute vec2 uv;
803
- varying vec2 vUv;
804
-
805
- void main() {
806
- vUv = uv;
807
- gl_Position = vec4(position, 0.0, 1.0);
808
- }
809
- `;
810
- var FRAGMENT_SHADER = `
811
- precision highp float;
812
-
813
- #define MAX_POINTS 64
814
-
815
- uniform vec2 uResolution;
816
- uniform vec2 uPoints[MAX_POINTS];
817
- uniform float uPointCount;
818
- uniform vec3 uColor;
819
- uniform vec3 uSecondaryColor;
820
- uniform float uTrailWidth;
821
- uniform float uTaper;
822
- uniform float uGlowIntensity;
823
- uniform float uGlowSpread;
824
- uniform float uHotspot;
825
- uniform float uBrightness;
826
- uniform float uOpacity;
827
- uniform float uPulseSpeed;
828
- uniform float uNoiseStrength;
829
- uniform float uTime;
830
- uniform float uFade;
831
-
832
- varying vec2 vUv;
833
-
834
- float sRGB(float x) {
835
- if (x <= 0.00031308) return 12.92 * x;
836
- return 1.055 * pow(x, 1.0 / 2.4) - 0.055;
837
- }
838
-
839
- float hash(vec2 p) {
840
- return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
841
- }
842
-
843
- float filmGrain(vec2 p, float time) {
844
- float frame = time * 18.0;
845
- float frameIndex = mod(floor(frame), 256.0);
846
- float nextFrameIndex = mod(frameIndex + 1.0, 256.0);
847
- float blend = fract(frame);
848
- blend = blend * blend * (3.0 - 2.0 * blend);
849
- vec2 pixel = floor(p);
850
- float current = hash(pixel + vec2(frameIndex * 17.0, frameIndex * 31.0));
851
- float next = hash(pixel + vec2(nextFrameIndex * 17.0, nextFrameIndex * 31.0));
852
- return mix(current, next, blend) * 2.0 - 1.0;
853
- }
854
-
855
- void main() {
856
- vec2 pixel = vUv * uResolution;
857
- float denominator = max(uPointCount - 1.0, 1.0);
858
- float strongest = 0.0;
859
- float strongestCore = 0.0;
860
- float colorWeight = 0.0;
861
- vec3 colorSum = vec3(0.0);
862
-
863
- for (int i = 0; i < MAX_POINTS - 1; i++) {
864
- float index = float(i);
865
- vec2 start = uPoints[i];
866
- vec2 end = uPoints[i + 1];
867
- vec2 toPixel = pixel - start;
868
- vec2 segment = end - start;
869
- float along = clamp(dot(toPixel, segment) / max(dot(segment, segment), 0.0001), 0.0, 1.0);
870
- float progress = clamp((index + along) / denominator, 0.0, 1.0);
871
- float life = pow(max(1.0 - progress, 0.0), mix(0.55, 1.25, uTaper));
872
- float width = uTrailWidth * mix(1.0, 0.25, pow(progress, mix(0.55, 1.6, uTaper)));
873
- float distanceToTrail = length(toPixel - segment * along);
874
- float falloff = max(width * (0.8 + uGlowSpread * 1.4), 0.5);
875
- float beam = min(1.0, (falloff * falloff) / (distanceToTrail * distanceToTrail + falloff * falloff));
876
- float core = exp(-pow(distanceToTrail / max(width, 0.5), 2.0) * 2.5);
877
- float pulseAmount = min(abs(uPulseSpeed), 1.0);
878
- float pulse = 1.0 + sin(uTime * uPulseSpeed * 3.0 - progress * 11.0) * 0.16 * pulseAmount;
879
- float intensity = (core + beam * uGlowIntensity * 0.55) * life * pulse;
880
- vec3 segmentColor = mix(uColor, uSecondaryColor, progress);
881
-
882
- strongest = max(strongest, intensity);
883
- strongestCore = max(strongestCore, core * life);
884
- colorSum += segmentColor * intensity;
885
- colorWeight += intensity;
886
- }
887
-
888
- float grain = filmGrain(pixel, uTime);
889
- float noiseAmount = (1.0 - exp(-uNoiseStrength * 2.2)) * 0.4;
890
- float alpha = clamp(strongest * uOpacity * uFade, 0.0, 1.0);
891
- if (alpha < 0.0005) discard;
892
-
893
- vec3 color = colorSum / max(colorWeight, 0.0001);
894
- color = mix(color, vec3(1.0), smoothstep(0.25, 0.95, strongestCore) * uHotspot);
895
- float luminance = sRGB(clamp(strongest * uBrightness, 0.0, 1.0));
896
- luminance *= 1.0 + grain * noiseAmount;
897
- vec3 additiveColor = color * luminance;
898
- float normalAlpha = clamp(strongest * uBrightness * uOpacity * uFade, 0.0, 1.0);
899
- vec3 normalColor = mix(color, vec3(1.0), smoothstep(0.45, 1.0, strongestCore) * uHotspot * 0.35);
900
- gl_FragColor = vec4(mix(additiveColor, normalColor, 1.0), mix(alpha, normalAlpha, 1.0));
901
- }
902
- `;
903
- function hexToRgb(hex) {
904
- let value = (hex || "").replace("#", "").trim();
905
- if (value.length === 3) {
906
- value = value.split("").map((c) => c + c).join("");
907
- }
908
- const parsed = Number.parseInt(value || "ff0000", 16);
909
- return [
910
- (parsed >> 16 & 255) / 255,
911
- (parsed >> 8 & 255) / 255,
912
- (parsed & 255) / 255
913
- ];
914
- }
915
- var LaserCursorLayer = ({
916
- color = "#ef4444",
917
- secondaryColor = "#ef4444",
918
- trailLength = 29,
919
- trailWidth = 8,
920
- trailTaper = 0.22,
921
- followSpeed = 1.5,
922
- glowIntensity = 1.9,
923
- glowSpread = 0.1,
924
- hotspot = 0.5,
925
- brightness = 1.25,
926
- opacity = 1,
927
- pulseSpeed = 0.8,
928
- noiseStrength = 0.035,
929
- idleFade = true,
930
- idleTimeout = 700,
931
- fadeDuration = 1500,
932
- enabled = true,
933
- className = "",
934
- style,
935
- ...rest
936
- }) => {
937
- const containerRef = (0, import_react4.useRef)(null);
938
- const canvasRef = (0, import_react4.useRef)(null);
939
- (0, import_react4.useEffect)(() => {
940
- const container = containerRef.current;
941
- const canvas = canvasRef.current;
942
- if (!container || !canvas || !enabled) return;
943
- let renderer = null;
944
- try {
945
- renderer = new import_ogl.Renderer({
946
- canvas,
947
- alpha: true,
948
- dpr: Math.min(window.devicePixelRatio || 1, 1.5)
949
- });
950
- } catch {
951
- return;
952
- }
953
- const gl = renderer.gl;
954
- gl.clearColor(0, 0, 0, 0);
955
- const pointData = Array(MAX_POINTS * 2).fill(0);
956
- const points = Array.from({ length: MAX_POINTS }, () => ({ x: 0, y: 0 }));
957
- const target = { x: 0, y: 0 };
958
- const head = { x: 0, y: 0 };
959
- let program;
960
- let mesh;
961
- try {
962
- program = new import_ogl.Program(gl, {
963
- vertex: VERTEX_SHADER,
964
- fragment: FRAGMENT_SHADER,
965
- uniforms: {
966
- uResolution: { value: [1, 1] },
967
- uPoints: { value: pointData },
968
- uPointCount: { value: trailLength },
969
- uColor: { value: hexToRgb(color) },
970
- uSecondaryColor: { value: hexToRgb(secondaryColor) },
971
- uTrailWidth: { value: trailWidth },
972
- uTaper: { value: trailTaper },
973
- uGlowIntensity: { value: glowIntensity },
974
- uGlowSpread: { value: glowSpread },
975
- uHotspot: { value: hotspot },
976
- uBrightness: { value: brightness },
977
- uOpacity: { value: opacity },
978
- uPulseSpeed: { value: pulseSpeed },
979
- uNoiseStrength: { value: noiseStrength },
980
- uTime: { value: 0 },
981
- uFade: { value: 0 }
982
- },
983
- transparent: true,
984
- depthTest: false,
985
- depthWrite: false
986
- });
987
- mesh = new import_ogl.Mesh(gl, { geometry: new import_ogl.Triangle(gl), program });
988
- } catch {
989
- return;
990
- }
991
- let width = 0;
992
- let height = 0;
993
- let isHovered = false;
994
- let lastMoveTime = 0;
995
- let animationId;
996
- const resize = () => {
997
- const rect = container.getBoundingClientRect();
998
- const newWidth = Math.floor(rect.width);
999
- const newHeight = Math.floor(rect.height);
1000
- if (newWidth <= 0 || newHeight <= 0) return;
1001
- if (newWidth === width && newHeight === height) return;
1002
- width = newWidth;
1003
- height = newHeight;
1004
- renderer?.setSize(width, height);
1005
- program.uniforms.uResolution.value = [width, height];
1006
- };
1007
- resize();
1008
- const resizeObserver = new ResizeObserver(resize);
1009
- resizeObserver.observe(container);
1010
- const onPointerMove = (e) => {
1011
- const rect = container.getBoundingClientRect();
1012
- target.x = e.clientX - rect.left;
1013
- target.y = rect.height - (e.clientY - rect.top);
1014
- lastMoveTime = performance.now();
1015
- isHovered = true;
1016
- };
1017
- const onPointerLeave = () => {
1018
- isHovered = false;
1019
- };
1020
- container.addEventListener("pointermove", onPointerMove);
1021
- container.addEventListener("pointerleave", onPointerLeave);
1022
- let lastTime = performance.now();
1023
- const render = (now) => {
1024
- animationId = requestAnimationFrame(render);
1025
- const dt = Math.min((now - lastTime) / 1e3, 0.1);
1026
- lastTime = now;
1027
- const speed = followSpeed * 20;
1028
- head.x += (target.x - head.x) * Math.min(dt * speed, 1);
1029
- head.y += (target.y - head.y) * Math.min(dt * speed, 1);
1030
- for (let i = MAX_POINTS - 1; i > 0; i--) {
1031
- points[i].x = points[i - 1].x;
1032
- points[i].y = points[i - 1].y;
1033
- }
1034
- points[0].x = head.x;
1035
- points[0].y = head.y;
1036
- for (let i = 0; i < MAX_POINTS; i++) {
1037
- pointData[i * 2] = points[i].x;
1038
- pointData[i * 2 + 1] = points[i].y;
1039
- }
1040
- program.uniforms.uTime.value = now * 1e-3;
1041
- let fade = 1;
1042
- if (idleFade) {
1043
- const idleTime = now - lastMoveTime;
1044
- if (!isHovered || idleTime > idleTimeout) {
1045
- const fadeProgress = Math.min(Math.max((idleTime - idleTimeout) / fadeDuration, 0), 1);
1046
- fade = 1 - fadeProgress;
1047
- }
1048
- }
1049
- program.uniforms.uFade.value = fade;
1050
- if (fade > 1e-3) {
1051
- renderer?.render({ scene: mesh });
1052
- } else {
1053
- gl.clear(gl.COLOR_BUFFER_BIT);
1054
- }
1055
- };
1056
- animationId = requestAnimationFrame(render);
1057
- return () => {
1058
- cancelAnimationFrame(animationId);
1059
- resizeObserver.disconnect();
1060
- container.removeEventListener("pointermove", onPointerMove);
1061
- container.removeEventListener("pointerleave", onPointerLeave);
1062
- };
1063
- }, [
1064
- color,
1065
- secondaryColor,
1066
- trailLength,
1067
- trailWidth,
1068
- trailTaper,
1069
- followSpeed,
1070
- glowIntensity,
1071
- glowSpread,
1072
- hotspot,
1073
- brightness,
1074
- opacity,
1075
- pulseSpeed,
1076
- noiseStrength,
1077
- idleFade,
1078
- idleTimeout,
1079
- fadeDuration,
1080
- enabled
1081
- ]);
1082
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1083
- "div",
1084
- {
1085
- ref: containerRef,
1086
- className: `tbib-iv-laser-layer ${className}`,
1087
- style: {
1088
- position: "absolute",
1089
- top: 0,
1090
- left: 0,
1091
- width: "100%",
1092
- height: "100%",
1093
- pointerEvents: "auto",
1094
- touchAction: "none",
1095
- cursor: "crosshair",
1096
- zIndex: 30,
1097
- overflow: "hidden",
1098
- ...style
1099
- },
1100
- ...rest,
1101
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1102
- "canvas",
1103
- {
1104
- ref: canvasRef,
1105
- className: "tbib-iv-laser-canvas",
1106
- style: {
1107
- position: "absolute",
1108
- top: 0,
1109
- left: 0,
1110
- width: "100%",
1111
- height: "100%",
1112
- display: "block",
1113
- pointerEvents: "none"
519
+ pointerEvents: "none"
520
+ }
521
+ },
522
+ stroke.id
523
+ );
524
+ }),
525
+ currentPathD && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
526
+ "path",
527
+ {
528
+ d: currentPathD,
529
+ fill: "none",
530
+ stroke: activeTool === "highlighter" ? (0, import_core.hexToRgba)(color, 0.35) : color,
531
+ strokeWidth: activeTool === "highlighter" ? strokeWidth * 2.5 : strokeWidth,
532
+ strokeLinecap: "round",
533
+ strokeLinejoin: "round",
534
+ style: {
535
+ mixBlendMode: activeTool === "highlighter" ? "multiply" : "normal",
536
+ pointerEvents: "none"
537
+ }
1114
538
  }
1115
- }
1116
- )
539
+ )
540
+ ]
1117
541
  }
1118
542
  );
1119
543
  };
1120
544
 
1121
545
  // src/hooks/useImageTransform.ts
1122
- var import_react5 = require("react");
546
+ var import_react4 = require("react");
1123
547
  var import_core2 = require("@tbib-image-viewer/core");
1124
548
  function useImageTransform() {
1125
- const [transform, setTransform] = (0, import_react5.useState)(import_core2.DEFAULT_TRANSFORM);
1126
- const pinchStartDistRef = (0, import_react5.useRef)(null);
1127
- const pinchStartScaleRef = (0, import_react5.useRef)(1);
1128
- const zoomIn = (0, import_react5.useCallback)(() => {
549
+ const [transform, setTransform] = (0, import_react4.useState)(import_core2.DEFAULT_TRANSFORM);
550
+ const pinchStartDistRef = (0, import_react4.useRef)(null);
551
+ const pinchStartScaleRef = (0, import_react4.useRef)(1);
552
+ const zoomIn = (0, import_react4.useCallback)(() => {
1129
553
  setTransform((prev) => ({
1130
554
  ...prev,
1131
555
  scale: (0, import_core2.clampScale)(prev.scale * 1.25)
1132
556
  }));
1133
557
  }, []);
1134
- const zoomOut = (0, import_react5.useCallback)(() => {
558
+ const zoomOut = (0, import_react4.useCallback)(() => {
1135
559
  setTransform((prev) => ({
1136
560
  ...prev,
1137
561
  scale: (0, import_core2.clampScale)(prev.scale / 1.25)
1138
562
  }));
1139
563
  }, []);
1140
- const resetTransform = (0, import_react5.useCallback)(() => {
564
+ const resetTransform = (0, import_react4.useCallback)(() => {
1141
565
  setTransform(import_core2.DEFAULT_TRANSFORM);
1142
566
  }, []);
1143
- const rotateClockwise = (0, import_react5.useCallback)(() => {
567
+ const rotateClockwise = (0, import_react4.useCallback)(() => {
1144
568
  setTransform((prev) => ({
1145
569
  ...prev,
1146
570
  rotate: (prev.rotate + 90) % 360
1147
571
  }));
1148
572
  }, []);
1149
- const panBy = (0, import_react5.useCallback)((dx, dy) => {
573
+ const panBy = (0, import_react4.useCallback)((dx, dy) => {
1150
574
  setTransform((prev) => ({
1151
575
  ...prev,
1152
576
  translateX: prev.translateX + dx,
1153
577
  translateY: prev.translateY + dy
1154
578
  }));
1155
579
  }, []);
1156
- const pinchZoomByRatio = (0, import_react5.useCallback)((startScale, ratio) => {
580
+ const pinchZoomByRatio = (0, import_react4.useCallback)((startScale, ratio) => {
1157
581
  setTransform((prev) => ({
1158
582
  ...prev,
1159
583
  scale: (0, import_core2.clampScale)(startScale * ratio)
1160
584
  }));
1161
585
  }, []);
1162
- const handleWheel = (0, import_react5.useCallback)((e) => {
586
+ const handleWheel = (0, import_react4.useCallback)((e) => {
1163
587
  e.preventDefault();
1164
588
  const factor = e.deltaY < 0 ? 1.15 : 1 / 1.15;
1165
589
  setTransform((prev) => ({
@@ -1167,7 +591,7 @@ function useImageTransform() {
1167
591
  scale: (0, import_core2.clampScale)(prev.scale * factor)
1168
592
  }));
1169
593
  }, []);
1170
- const handleTouchStart = (0, import_react5.useCallback)((e) => {
594
+ const handleTouchStart = (0, import_react4.useCallback)((e) => {
1171
595
  if (e.touches.length === 2) {
1172
596
  const t1 = e.touches[0];
1173
597
  const t2 = e.touches[1];
@@ -1176,7 +600,7 @@ function useImageTransform() {
1176
600
  pinchStartScaleRef.current = transform.scale;
1177
601
  }
1178
602
  }, [transform.scale]);
1179
- const handleTouchMove = (0, import_react5.useCallback)((e) => {
603
+ const handleTouchMove = (0, import_react4.useCallback)((e) => {
1180
604
  if (e.touches.length === 2 && pinchStartDistRef.current !== null) {
1181
605
  const t1 = e.touches[0];
1182
606
  const t2 = e.touches[1];
@@ -1188,7 +612,7 @@ function useImageTransform() {
1188
612
  }));
1189
613
  }
1190
614
  }, []);
1191
- const handleTouchEnd = (0, import_react5.useCallback)(() => {
615
+ const handleTouchEnd = (0, import_react4.useCallback)(() => {
1192
616
  pinchStartDistRef.current = null;
1193
617
  }, []);
1194
618
  return {
@@ -1208,7 +632,8 @@ function useImageTransform() {
1208
632
  }
1209
633
 
1210
634
  // src/components/ImageViewer.tsx
1211
- var import_jsx_runtime5 = require("react/jsx-runtime");
635
+ var import_jsx_runtime3 = require("react/jsx-runtime");
636
+ var LaserCursorLayer = (0, import_react5.lazy)(() => import("@tbib-ink/react/laser"));
1212
637
  var ImageViewer = ({
1213
638
  src,
1214
639
  alt = "Medical illustration",
@@ -1226,32 +651,32 @@ var ImageViewer = ({
1226
651
  onAnnotationsChange,
1227
652
  children
1228
653
  }) => {
1229
- const effectiveSlideId = (0, import_react6.useMemo)(() => slideId || src, [slideId, src]);
1230
- const [activeTool, setActiveTool] = (0, import_react6.useState)(initialTool);
1231
- const [color, setColor] = (0, import_react6.useState)(initialColor);
1232
- const [strokeWidth, setStrokeWidth] = (0, import_react6.useState)(initialStrokeWidth);
1233
- const storeRef = (0, import_react6.useRef)(
654
+ const effectiveSlideId = (0, import_react5.useMemo)(() => slideId || src, [slideId, src]);
655
+ const [activeTool, setActiveTool] = (0, import_react5.useState)(initialTool);
656
+ const [color, setColor] = (0, import_react5.useState)(initialColor);
657
+ const [strokeWidth, setStrokeWidth] = (0, import_react5.useState)(initialStrokeWidth);
658
+ const storeRef = (0, import_react5.useRef)(
1234
659
  new import_core3.AnnotationStore(
1235
660
  initialAnnotations ? [{ slideId: effectiveSlideId, strokes: initialAnnotations }] : void 0
1236
661
  )
1237
662
  );
1238
- const [strokes, setStrokes] = (0, import_react6.useState)(
663
+ const [strokes, setStrokes] = (0, import_react5.useState)(
1239
664
  () => storeRef.current.getStrokes(effectiveSlideId)
1240
665
  );
1241
- const [canUndo, setCanUndo] = (0, import_react6.useState)(false);
1242
- const [canRedo, setCanRedo] = (0, import_react6.useState)(false);
1243
- const containerRef = (0, import_react6.useRef)(null);
1244
- const imgRef = (0, import_react6.useRef)(null);
1245
- const [imgSize, setImgSize] = (0, import_react6.useState)({ width: 800, height: 600 });
1246
- const [imageStatus, setImageStatus] = (0, import_react6.useState)("loading");
1247
- const [reloadKey, setReloadKey] = (0, import_react6.useState)(0);
1248
- const effectiveSrc = (0, import_react6.useMemo)(() => {
666
+ const [canUndo, setCanUndo] = (0, import_react5.useState)(false);
667
+ const [canRedo, setCanRedo] = (0, import_react5.useState)(false);
668
+ const containerRef = (0, import_react5.useRef)(null);
669
+ const imgRef = (0, import_react5.useRef)(null);
670
+ const [imgSize, setImgSize] = (0, import_react5.useState)({ width: 800, height: 600 });
671
+ const [imageStatus, setImageStatus] = (0, import_react5.useState)("loading");
672
+ const [reloadKey, setReloadKey] = (0, import_react5.useState)(0);
673
+ const effectiveSrc = (0, import_react5.useMemo)(() => {
1249
674
  if (!src) return "";
1250
675
  if (reloadKey === 0) return src;
1251
676
  const sep = src.includes("?") ? "&" : "?";
1252
677
  return `${src}${sep}_reload=${reloadKey}`;
1253
678
  }, [src, reloadKey]);
1254
- (0, import_react6.useEffect)(() => {
679
+ (0, import_react5.useEffect)(() => {
1255
680
  setImageStatus("loading");
1256
681
  if (imgRef.current && imgRef.current.complete && imgRef.current.naturalWidth > 0) {
1257
682
  setImgSize({
@@ -1274,9 +699,9 @@ var ImageViewer = ({
1274
699
  handleTouchMove,
1275
700
  handleTouchEnd
1276
701
  } = useImageTransform();
1277
- const isDraggingRef = (0, import_react6.useRef)(false);
1278
- const lastMousePosRef = (0, import_react6.useRef)({ x: 0, y: 0 });
1279
- (0, import_react6.useEffect)(() => {
702
+ const isDraggingRef = (0, import_react5.useRef)(false);
703
+ const lastMousePosRef = (0, import_react5.useRef)({ x: 0, y: 0 });
704
+ (0, import_react5.useEffect)(() => {
1280
705
  const store = storeRef.current;
1281
706
  const unsubscribe = store.subscribe((id, updated) => {
1282
707
  if (id === effectiveSlideId) {
@@ -1306,13 +731,13 @@ var ImageViewer = ({
1306
731
  setImageStatus("loading");
1307
732
  setReloadKey((prev) => prev + 1);
1308
733
  };
1309
- const handleStrokeComplete = (0, import_react6.useCallback)(
734
+ const handleStrokeComplete = (0, import_react5.useCallback)(
1310
735
  (newStroke) => {
1311
736
  storeRef.current.addStroke(effectiveSlideId, newStroke);
1312
737
  },
1313
738
  [effectiveSlideId]
1314
739
  );
1315
- const handleEraseStroke = (0, import_react6.useCallback)(
740
+ const handleEraseStroke = (0, import_react5.useCallback)(
1316
741
  (point) => {
1317
742
  storeRef.current.removeStrokesNear(
1318
743
  effectiveSlideId,
@@ -1324,13 +749,13 @@ var ImageViewer = ({
1324
749
  },
1325
750
  [effectiveSlideId]
1326
751
  );
1327
- const handleUndo = (0, import_react6.useCallback)(() => {
752
+ const handleUndo = (0, import_react5.useCallback)(() => {
1328
753
  storeRef.current.undo(effectiveSlideId);
1329
754
  }, [effectiveSlideId]);
1330
- const handleRedo = (0, import_react6.useCallback)(() => {
755
+ const handleRedo = (0, import_react5.useCallback)(() => {
1331
756
  storeRef.current.redo(effectiveSlideId);
1332
757
  }, [effectiveSlideId]);
1333
- const handleClear = (0, import_react6.useCallback)(() => {
758
+ const handleClear = (0, import_react5.useCallback)(() => {
1334
759
  storeRef.current.clear(effectiveSlideId);
1335
760
  }, [effectiveSlideId]);
1336
761
  const handleStagePointerDown = (e) => {
@@ -1349,7 +774,7 @@ var ImageViewer = ({
1349
774
  const handleStagePointerUp = (e) => {
1350
775
  isDraggingRef.current = false;
1351
776
  };
1352
- (0, import_react6.useEffect)(() => {
777
+ (0, import_react5.useEffect)(() => {
1353
778
  const handleKeyDown = (e) => {
1354
779
  if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "z") {
1355
780
  e.preventDefault();
@@ -1402,14 +827,14 @@ var ImageViewer = ({
1402
827
  link.click();
1403
828
  setTimeout(() => URL.revokeObjectURL(url), 1e3);
1404
829
  };
1405
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
830
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1406
831
  "div",
1407
832
  {
1408
833
  ref: containerRef,
1409
834
  className: `tbib-iv-container ${theme === "light" ? "tbib-iv-light" : ""} ${className}`,
1410
835
  style,
1411
836
  children: [
1412
- showToolbar && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
837
+ showToolbar && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1413
838
  ImageToolbar,
1414
839
  {
1415
840
  activeTool,
@@ -1430,10 +855,11 @@ var ImageViewer = ({
1430
855
  onRotate: rotateClockwise,
1431
856
  onDownloadAnnotated: handleDownloadAnnotated,
1432
857
  onDownloadClean: handleDownloadClean,
1433
- onExportJson: handleExportJson
858
+ onExportJson: handleExportJson,
859
+ theme: theme === "light" ? "light" : "dark"
1434
860
  }
1435
861
  ),
1436
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
862
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1437
863
  "div",
1438
864
  {
1439
865
  className: "tbib-iv-stage",
@@ -1449,7 +875,7 @@ var ImageViewer = ({
1449
875
  cursor: activeTool === "hand" ? isDraggingRef.current ? "grabbing" : "grab" : "default"
1450
876
  },
1451
877
  children: [
1452
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
878
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1453
879
  "div",
1454
880
  {
1455
881
  className: "tbib-iv-stage-inner",
@@ -1458,7 +884,7 @@ var ImageViewer = ({
1458
884
  transition: isDraggingRef.current ? "none" : "transform 0.05s ease-out"
1459
885
  },
1460
886
  children: [
1461
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
887
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1462
888
  "img",
1463
889
  {
1464
890
  ref: imgRef,
@@ -1471,7 +897,7 @@ var ImageViewer = ({
1471
897
  },
1472
898
  `${src}-${reloadKey}`
1473
899
  ),
1474
- enableAnnotations && imageStatus === "loaded" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
900
+ enableAnnotations && imageStatus === "loaded" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1475
901
  AnnotationCanvas,
1476
902
  {
1477
903
  width: imgSize.width,
@@ -1490,28 +916,28 @@ var ImageViewer = ({
1490
916
  ]
1491
917
  }
1492
918
  ),
1493
- imageStatus === "loading" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "tbib-iv-status-overlay", children: [
1494
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "tbib-iv-spinner", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_free_solid_svg_icons3.faSpinner, spin: true, className: "tbib-iv-spinner-icon" }) }),
1495
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "tbib-iv-status-text", children: "Chargement de l'illustration..." })
919
+ imageStatus === "loading" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "tbib-iv-status-overlay", children: [
920
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "tbib-iv-spinner", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faSpinner, spin: true, className: "tbib-iv-spinner-icon" }) }),
921
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "tbib-iv-status-text", children: "Chargement de l'illustration..." })
1496
922
  ] }),
1497
- imageStatus === "error" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "tbib-iv-status-overlay tbib-iv-error-card", children: [
1498
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "tbib-iv-error-icon", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_faExclamationTriangle.faExclamationTriangle }) }),
1499
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { className: "tbib-iv-error-title", children: "Impossible de charger l'image" }),
1500
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "tbib-iv-error-desc", children: "Le fichier est temporairement inaccessible ou une erreur r\xE9seau est survenue." }),
1501
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "tbib-iv-error-actions", children: [
1502
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
923
+ imageStatus === "error" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "tbib-iv-status-overlay tbib-iv-error-card", children: [
924
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "tbib-iv-error-icon", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_faExclamationTriangle.faExclamationTriangle }) }),
925
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { className: "tbib-iv-error-title", children: "Impossible de charger l'image" }),
926
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "tbib-iv-error-desc", children: "Le fichier est temporairement inaccessible ou une erreur r\xE9seau est survenue." }),
927
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "tbib-iv-error-actions", children: [
928
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1503
929
  "button",
1504
930
  {
1505
931
  type: "button",
1506
932
  className: "tbib-iv-btn tbib-iv-btn-primary tbib-iv-retry-btn",
1507
933
  onClick: handleReload,
1508
934
  children: [
1509
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_free_solid_svg_icons3.faRotateRight }),
1510
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "R\xE9essayer" })
935
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faRotateRight }),
936
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "R\xE9essayer" })
1511
937
  ]
1512
938
  }
1513
939
  ),
1514
- src && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
940
+ src && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1515
941
  "a",
1516
942
  {
1517
943
  href: src,
@@ -1519,14 +945,14 @@ var ImageViewer = ({
1519
945
  rel: "noopener noreferrer",
1520
946
  className: "tbib-iv-btn tbib-iv-open-btn",
1521
947
  children: [
1522
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_faExternalLinkAlt.faExternalLinkAlt }),
1523
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Lien direct" })
948
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_faExternalLinkAlt.faExternalLinkAlt }),
949
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Lien direct" })
1524
950
  ]
1525
951
  }
1526
952
  )
1527
953
  ] })
1528
954
  ] }),
1529
- enableLaser && activeTool === "laser" && imageStatus === "loaded" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LaserCursorLayer, { color, secondaryColor: color, enabled: activeTool === "laser" })
955
+ enableLaser && activeTool === "laser" && imageStatus === "loaded" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react5.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LaserCursorLayer, { color, secondaryColor: color, enabled: activeTool === "laser" }) })
1530
956
  ]
1531
957
  }
1532
958
  ),
@@ -1537,29 +963,29 @@ var ImageViewer = ({
1537
963
  };
1538
964
 
1539
965
  // src/components/ImageGalleryLightbox.tsx
1540
- var import_react8 = require("react");
1541
- var import_react_fontawesome4 = require("@fortawesome/react-fontawesome");
1542
- var import_free_solid_svg_icons4 = require("@fortawesome/free-solid-svg-icons");
966
+ var import_react7 = require("react");
967
+ var import_react_fontawesome3 = require("@fortawesome/react-fontawesome");
968
+ var import_free_solid_svg_icons3 = require("@fortawesome/free-solid-svg-icons");
1543
969
  var import_faExclamationTriangle2 = require("@fortawesome/free-solid-svg-icons/faExclamationTriangle");
1544
970
  var import_faExternalLinkAlt2 = require("@fortawesome/free-solid-svg-icons/faExternalLinkAlt");
1545
971
  var import_core4 = require("@tbib-image-viewer/core");
1546
972
 
1547
973
  // src/components/ThumbnailStrip.tsx
1548
- var import_jsx_runtime6 = require("react/jsx-runtime");
974
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1549
975
  var ThumbnailStrip = ({
1550
976
  items,
1551
977
  activeIndex,
1552
978
  onSelect
1553
979
  }) => {
1554
980
  if (items.length <= 1) return null;
1555
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "tbib-iv-thumbnail-strip", children: items.map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
981
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "tbib-iv-thumbnail-strip", children: items.map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1556
982
  "button",
1557
983
  {
1558
984
  type: "button",
1559
985
  className: `tbib-iv-thumbnail-item ${idx === activeIndex ? "tbib-iv-thumbnail-item-active" : ""}`,
1560
986
  onClick: () => onSelect(idx),
1561
987
  title: item.title || `Image ${idx + 1}`,
1562
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
988
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1563
989
  "img",
1564
990
  {
1565
991
  src: item.thumbnailSrc || item.src,
@@ -1574,16 +1000,16 @@ var ThumbnailStrip = ({
1574
1000
  };
1575
1001
 
1576
1002
  // src/hooks/useSwipeGesture.ts
1577
- var import_react7 = require("react");
1003
+ var import_react6 = require("react");
1578
1004
  function useSwipeGesture({ onSwipeLeft, onSwipeRight, enabled = true }) {
1579
- const touchStartXRef = (0, import_react7.useRef)(null);
1580
- const touchStartYRef = (0, import_react7.useRef)(null);
1581
- const onTouchStart = (0, import_react7.useCallback)((e) => {
1005
+ const touchStartXRef = (0, import_react6.useRef)(null);
1006
+ const touchStartYRef = (0, import_react6.useRef)(null);
1007
+ const onTouchStart = (0, import_react6.useCallback)((e) => {
1582
1008
  if (!enabled || e.touches.length !== 1) return;
1583
1009
  touchStartXRef.current = e.touches[0].clientX;
1584
1010
  touchStartYRef.current = e.touches[0].clientY;
1585
1011
  }, [enabled]);
1586
- const onTouchEnd = (0, import_react7.useCallback)((e) => {
1012
+ const onTouchEnd = (0, import_react6.useCallback)((e) => {
1587
1013
  if (!enabled || touchStartXRef.current === null || touchStartYRef.current === null) return;
1588
1014
  const touchEndX = e.changedTouches[0].clientX;
1589
1015
  const touchEndY = e.changedTouches[0].clientY;
@@ -1606,7 +1032,8 @@ function useSwipeGesture({ onSwipeLeft, onSwipeRight, enabled = true }) {
1606
1032
  }
1607
1033
 
1608
1034
  // src/components/ImageGalleryLightbox.tsx
1609
- var import_jsx_runtime7 = require("react/jsx-runtime");
1035
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1036
+ var LaserCursorLayer2 = (0, import_react7.lazy)(() => import("@tbib-ink/react/laser"));
1610
1037
  var ImageGalleryLightbox = ({
1611
1038
  items,
1612
1039
  activeIndex = 0,
@@ -1620,20 +1047,20 @@ var ImageGalleryLightbox = ({
1620
1047
  initialAnnotations,
1621
1048
  onAnnotationsChange
1622
1049
  }) => {
1623
- const [currentIndex, setCurrentIndex] = (0, import_react8.useState)(activeIndex);
1624
- const [activeTool, setActiveTool] = (0, import_react8.useState)(initialTool);
1625
- const [color, setColor] = (0, import_react8.useState)(initialColor);
1626
- const [strokeWidth, setStrokeWidth] = (0, import_react8.useState)(4);
1627
- const [isFullscreen, setIsFullscreen] = (0, import_react8.useState)(false);
1628
- (0, import_react8.useEffect)(() => {
1050
+ const [currentIndex, setCurrentIndex] = (0, import_react7.useState)(activeIndex);
1051
+ const [activeTool, setActiveTool] = (0, import_react7.useState)(initialTool);
1052
+ const [color, setColor] = (0, import_react7.useState)(initialColor);
1053
+ const [strokeWidth, setStrokeWidth] = (0, import_react7.useState)(4);
1054
+ const [isFullscreen, setIsFullscreen] = (0, import_react7.useState)(false);
1055
+ (0, import_react7.useEffect)(() => {
1629
1056
  setCurrentIndex(activeIndex);
1630
1057
  }, [activeIndex]);
1631
1058
  const currentItem = items[currentIndex] || items[0];
1632
1059
  const slideId = currentItem?.id || currentItem?.src || `slide-${currentIndex}`;
1633
- const storeRef = (0, import_react8.useRef)(new import_core4.AnnotationStore(initialAnnotations));
1634
- const [strokes, setStrokes] = (0, import_react8.useState)([]);
1635
- const [canUndo, setCanUndo] = (0, import_react8.useState)(false);
1636
- const [canRedo, setCanRedo] = (0, import_react8.useState)(false);
1060
+ const storeRef = (0, import_react7.useRef)(new import_core4.AnnotationStore(initialAnnotations));
1061
+ const [strokes, setStrokes] = (0, import_react7.useState)([]);
1062
+ const [canUndo, setCanUndo] = (0, import_react7.useState)(false);
1063
+ const [canRedo, setCanRedo] = (0, import_react7.useState)(false);
1637
1064
  const {
1638
1065
  transform,
1639
1066
  zoomIn,
@@ -1647,21 +1074,21 @@ var ImageGalleryLightbox = ({
1647
1074
  handleTouchMove,
1648
1075
  handleTouchEnd
1649
1076
  } = useImageTransform();
1650
- (0, import_react8.useEffect)(() => {
1077
+ (0, import_react7.useEffect)(() => {
1651
1078
  resetTransform();
1652
1079
  }, [currentIndex, resetTransform]);
1653
- const imgRef = (0, import_react8.useRef)(null);
1654
- const [imgSize, setImgSize] = (0, import_react8.useState)({ width: 800, height: 600 });
1655
- const [imageStatus, setImageStatus] = (0, import_react8.useState)("loading");
1656
- const [reloadKey, setReloadKey] = (0, import_react8.useState)(0);
1657
- const containerRef = (0, import_react8.useRef)(null);
1658
- const effectiveSrc = (0, import_react8.useMemo)(() => {
1080
+ const imgRef = (0, import_react7.useRef)(null);
1081
+ const [imgSize, setImgSize] = (0, import_react7.useState)({ width: 800, height: 600 });
1082
+ const [imageStatus, setImageStatus] = (0, import_react7.useState)("loading");
1083
+ const [reloadKey, setReloadKey] = (0, import_react7.useState)(0);
1084
+ const containerRef = (0, import_react7.useRef)(null);
1085
+ const effectiveSrc = (0, import_react7.useMemo)(() => {
1659
1086
  if (!currentItem?.src) return "";
1660
1087
  if (reloadKey === 0) return currentItem.src;
1661
1088
  const sep = currentItem.src.includes("?") ? "&" : "?";
1662
1089
  return `${currentItem.src}${sep}_reload=${reloadKey}`;
1663
1090
  }, [currentItem?.src, reloadKey]);
1664
- (0, import_react8.useEffect)(() => {
1091
+ (0, import_react7.useEffect)(() => {
1665
1092
  setImageStatus("loading");
1666
1093
  setReloadKey(0);
1667
1094
  if (imgRef.current && imgRef.current.complete && imgRef.current.naturalWidth > 0) {
@@ -1687,9 +1114,9 @@ var ImageGalleryLightbox = ({
1687
1114
  setImageStatus("loading");
1688
1115
  setReloadKey((prev) => prev + 1);
1689
1116
  };
1690
- const isDraggingRef = (0, import_react8.useRef)(false);
1691
- const lastMousePosRef = (0, import_react8.useRef)({ x: 0, y: 0 });
1692
- (0, import_react8.useEffect)(() => {
1117
+ const isDraggingRef = (0, import_react7.useRef)(false);
1118
+ const lastMousePosRef = (0, import_react7.useRef)({ x: 0, y: 0 });
1119
+ (0, import_react7.useEffect)(() => {
1693
1120
  const store = storeRef.current;
1694
1121
  const updateStrokes = () => {
1695
1122
  const s = store.getStrokes(slideId);
@@ -1706,14 +1133,14 @@ var ImageGalleryLightbox = ({
1706
1133
  });
1707
1134
  return unsubscribe;
1708
1135
  }, [slideId, onAnnotationsChange]);
1709
- const goToNext = (0, import_react8.useCallback)(() => {
1136
+ const goToNext = (0, import_react7.useCallback)(() => {
1710
1137
  if (currentIndex < items.length - 1) {
1711
1138
  const nextIdx = currentIndex + 1;
1712
1139
  setCurrentIndex(nextIdx);
1713
1140
  onIndexChange?.(nextIdx);
1714
1141
  }
1715
1142
  }, [currentIndex, items.length, onIndexChange]);
1716
- const goToPrev = (0, import_react8.useCallback)(() => {
1143
+ const goToPrev = (0, import_react7.useCallback)(() => {
1717
1144
  if (currentIndex > 0) {
1718
1145
  const prevIdx = currentIndex - 1;
1719
1146
  setCurrentIndex(prevIdx);
@@ -1733,7 +1160,7 @@ var ImageGalleryLightbox = ({
1733
1160
  handleTouchEnd();
1734
1161
  onSwipeTouchEnd(e);
1735
1162
  };
1736
- (0, import_react8.useEffect)(() => {
1163
+ (0, import_react7.useEffect)(() => {
1737
1164
  if (!isOpen) return;
1738
1165
  const handleKeyDown = (e) => {
1739
1166
  if (e.key === "Escape") {
@@ -1779,21 +1206,21 @@ var ImageGalleryLightbox = ({
1779
1206
  const handleStagePointerUp = () => {
1780
1207
  isDraggingRef.current = false;
1781
1208
  };
1782
- const handleStrokeComplete = (0, import_react8.useCallback)(
1209
+ const handleStrokeComplete = (0, import_react7.useCallback)(
1783
1210
  (stroke) => {
1784
1211
  storeRef.current.addStroke(slideId, stroke);
1785
1212
  },
1786
1213
  [slideId]
1787
1214
  );
1788
- const handleEraseStroke = (0, import_react8.useCallback)(
1215
+ const handleEraseStroke = (0, import_react7.useCallback)(
1789
1216
  (pt) => {
1790
1217
  storeRef.current.removeStrokesNear(slideId, pt, 0.03, import_core4.isPointNearStroke);
1791
1218
  },
1792
1219
  [slideId]
1793
1220
  );
1794
- const handleUndo = (0, import_react8.useCallback)(() => storeRef.current.undo(slideId), [slideId]);
1795
- const handleRedo = (0, import_react8.useCallback)(() => storeRef.current.redo(slideId), [slideId]);
1796
- const handleClear = (0, import_react8.useCallback)(() => storeRef.current.clear(slideId), [slideId]);
1221
+ const handleUndo = (0, import_react7.useCallback)(() => storeRef.current.undo(slideId), [slideId]);
1222
+ const handleRedo = (0, import_react7.useCallback)(() => storeRef.current.redo(slideId), [slideId]);
1223
+ const handleClear = (0, import_react7.useCallback)(() => storeRef.current.clear(slideId), [slideId]);
1797
1224
  const toggleFullscreen = () => {
1798
1225
  if (!document.fullscreenElement) {
1799
1226
  containerRef.current?.requestFullscreen?.();
@@ -1834,7 +1261,7 @@ var ImageGalleryLightbox = ({
1834
1261
  setTimeout(() => URL.revokeObjectURL(url), 1e3);
1835
1262
  };
1836
1263
  if (!isOpen || !currentItem) return null;
1837
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1264
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1838
1265
  "div",
1839
1266
  {
1840
1267
  ref: containerRef,
@@ -1843,7 +1270,7 @@ var ImageGalleryLightbox = ({
1843
1270
  "aria-modal": "true",
1844
1271
  "aria-label": "Image Lightbox Gallery",
1845
1272
  children: [
1846
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1273
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1847
1274
  ImageToolbar,
1848
1275
  {
1849
1276
  activeTool,
@@ -1865,6 +1292,7 @@ var ImageGalleryLightbox = ({
1865
1292
  onDownloadAnnotated: handleDownloadAnnotated,
1866
1293
  onDownloadClean: handleDownloadClean,
1867
1294
  onExportJson: handleExportJson,
1295
+ theme: theme === "light" ? "light" : "dark",
1868
1296
  onClose,
1869
1297
  isFullscreen,
1870
1298
  onToggleFullscreen: toggleFullscreen,
@@ -1872,7 +1300,7 @@ var ImageGalleryLightbox = ({
1872
1300
  totalImages: items.length
1873
1301
  }
1874
1302
  ),
1875
- currentIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1303
+ currentIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1876
1304
  "button",
1877
1305
  {
1878
1306
  type: "button",
@@ -1880,10 +1308,10 @@ var ImageGalleryLightbox = ({
1880
1308
  onClick: goToPrev,
1881
1309
  title: "Previous Image (Arrow Left)",
1882
1310
  "aria-label": "Previous image",
1883
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_fontawesome4.FontAwesomeIcon, { icon: import_free_solid_svg_icons4.faChevronLeft })
1311
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_free_solid_svg_icons3.faChevronLeft })
1884
1312
  }
1885
1313
  ),
1886
- currentIndex < items.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1314
+ currentIndex < items.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1887
1315
  "button",
1888
1316
  {
1889
1317
  type: "button",
@@ -1891,10 +1319,10 @@ var ImageGalleryLightbox = ({
1891
1319
  onClick: goToNext,
1892
1320
  title: "Next Image (Arrow Right)",
1893
1321
  "aria-label": "Next image",
1894
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_fontawesome4.FontAwesomeIcon, { icon: import_free_solid_svg_icons4.faChevronRight })
1322
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_free_solid_svg_icons3.faChevronRight })
1895
1323
  }
1896
1324
  ),
1897
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1325
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1898
1326
  "div",
1899
1327
  {
1900
1328
  className: "tbib-iv-stage",
@@ -1910,7 +1338,7 @@ var ImageGalleryLightbox = ({
1910
1338
  cursor: activeTool === "hand" ? isDraggingRef.current ? "grabbing" : "grab" : "default"
1911
1339
  },
1912
1340
  children: [
1913
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1341
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1914
1342
  "div",
1915
1343
  {
1916
1344
  className: "tbib-iv-stage-inner",
@@ -1919,7 +1347,7 @@ var ImageGalleryLightbox = ({
1919
1347
  transition: isDraggingRef.current ? "none" : "transform 0.05s ease-out"
1920
1348
  },
1921
1349
  children: [
1922
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1350
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1923
1351
  "img",
1924
1352
  {
1925
1353
  ref: imgRef,
@@ -1932,7 +1360,7 @@ var ImageGalleryLightbox = ({
1932
1360
  },
1933
1361
  `${slideId}-${reloadKey}`
1934
1362
  ),
1935
- imageStatus === "loaded" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1363
+ imageStatus === "loaded" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1936
1364
  AnnotationCanvas,
1937
1365
  {
1938
1366
  width: imgSize.width,
@@ -1951,28 +1379,28 @@ var ImageGalleryLightbox = ({
1951
1379
  ]
1952
1380
  }
1953
1381
  ),
1954
- imageStatus === "loading" && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "tbib-iv-status-overlay", children: [
1955
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "tbib-iv-spinner", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_fontawesome4.FontAwesomeIcon, { icon: import_free_solid_svg_icons4.faSpinner, spin: true, className: "tbib-iv-spinner-icon" }) }),
1956
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "tbib-iv-status-text", children: "Chargement de l'illustration..." })
1382
+ imageStatus === "loading" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "tbib-iv-status-overlay", children: [
1383
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "tbib-iv-spinner", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_free_solid_svg_icons3.faSpinner, spin: true, className: "tbib-iv-spinner-icon" }) }),
1384
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "tbib-iv-status-text", children: "Chargement de l'illustration..." })
1957
1385
  ] }),
1958
- imageStatus === "error" && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "tbib-iv-status-overlay tbib-iv-error-card", children: [
1959
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "tbib-iv-error-icon", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_fontawesome4.FontAwesomeIcon, { icon: import_faExclamationTriangle2.faExclamationTriangle }) }),
1960
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h3", { className: "tbib-iv-error-title", children: "Impossible de charger l'image" }),
1961
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "tbib-iv-error-desc", children: "Le fichier est temporairement inaccessible ou une erreur r\xE9seau est survenue." }),
1962
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "tbib-iv-error-actions", children: [
1963
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1386
+ imageStatus === "error" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "tbib-iv-status-overlay tbib-iv-error-card", children: [
1387
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "tbib-iv-error-icon", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_faExclamationTriangle2.faExclamationTriangle }) }),
1388
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { className: "tbib-iv-error-title", children: "Impossible de charger l'image" }),
1389
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "tbib-iv-error-desc", children: "Le fichier est temporairement inaccessible ou une erreur r\xE9seau est survenue." }),
1390
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "tbib-iv-error-actions", children: [
1391
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1964
1392
  "button",
1965
1393
  {
1966
1394
  type: "button",
1967
1395
  className: "tbib-iv-btn tbib-iv-btn-primary tbib-iv-retry-btn",
1968
1396
  onClick: handleReload,
1969
1397
  children: [
1970
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_fontawesome4.FontAwesomeIcon, { icon: import_free_solid_svg_icons4.faRotateRight }),
1971
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "R\xE9essayer" })
1398
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_free_solid_svg_icons3.faRotateRight }),
1399
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "R\xE9essayer" })
1972
1400
  ]
1973
1401
  }
1974
1402
  ),
1975
- currentItem?.src && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1403
+ currentItem?.src && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1976
1404
  "a",
1977
1405
  {
1978
1406
  href: currentItem.src,
@@ -1980,18 +1408,18 @@ var ImageGalleryLightbox = ({
1980
1408
  rel: "noopener noreferrer",
1981
1409
  className: "tbib-iv-btn tbib-iv-open-btn",
1982
1410
  children: [
1983
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_fontawesome4.FontAwesomeIcon, { icon: import_faExternalLinkAlt2.faExternalLinkAlt }),
1984
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Lien direct" })
1411
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_faExternalLinkAlt2.faExternalLinkAlt }),
1412
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Lien direct" })
1985
1413
  ]
1986
1414
  }
1987
1415
  )
1988
1416
  ] })
1989
1417
  ] }),
1990
- activeTool === "laser" && imageStatus === "loaded" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LaserCursorLayer, { color, secondaryColor: color, enabled: activeTool === "laser" })
1418
+ activeTool === "laser" && imageStatus === "loaded" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react7.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LaserCursorLayer2, { color, secondaryColor: color, enabled: activeTool === "laser" }) })
1991
1419
  ]
1992
1420
  }
1993
1421
  ),
1994
- showThumbnails && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1422
+ showThumbnails && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1995
1423
  ThumbnailStrip,
1996
1424
  {
1997
1425
  items,
@@ -2007,11 +1435,14 @@ var ImageGalleryLightbox = ({
2007
1435
  );
2008
1436
  };
2009
1437
 
1438
+ // src/components/LaserCursorLayer.tsx
1439
+ var import_laser = require("@tbib-ink/react/laser");
1440
+
2010
1441
  // src/components/ColorPicker.tsx
2011
- var import_react9 = require("react");
2012
- var import_react_fontawesome5 = require("@fortawesome/react-fontawesome");
2013
- var import_free_solid_svg_icons5 = require("@fortawesome/free-solid-svg-icons");
2014
- var import_jsx_runtime8 = require("react/jsx-runtime");
1442
+ var import_react8 = require("react");
1443
+ var import_react_fontawesome4 = require("@fortawesome/react-fontawesome");
1444
+ var import_free_solid_svg_icons4 = require("@fortawesome/free-solid-svg-icons");
1445
+ var import_jsx_runtime6 = require("react/jsx-runtime");
2015
1446
  var PRESET_COLORS2 = [
2016
1447
  "#ef4444",
2017
1448
  // Red (Danger / Anatomy landmark)
@@ -2031,9 +1462,9 @@ var PRESET_COLORS2 = [
2031
1462
  // Slate / Black
2032
1463
  ];
2033
1464
  var ColorPicker = ({ color, onChange }) => {
2034
- const [isOpen, setIsOpen] = (0, import_react9.useState)(false);
2035
- const containerRef = (0, import_react9.useRef)(null);
2036
- (0, import_react9.useEffect)(() => {
1465
+ const [isOpen, setIsOpen] = (0, import_react8.useState)(false);
1466
+ const containerRef = (0, import_react8.useRef)(null);
1467
+ (0, import_react8.useEffect)(() => {
2037
1468
  const handleOutsideClick = (e) => {
2038
1469
  if (containerRef.current && !containerRef.current.contains(e.target)) {
2039
1470
  setIsOpen(false);
@@ -2046,8 +1477,8 @@ var ColorPicker = ({ color, onChange }) => {
2046
1477
  document.removeEventListener("mousedown", handleOutsideClick);
2047
1478
  };
2048
1479
  }, [isOpen]);
2049
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref: containerRef, style: { position: "relative", display: "inline-block" }, children: [
2050
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1480
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ref: containerRef, style: { position: "relative", display: "inline-block" }, children: [
1481
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
2051
1482
  "button",
2052
1483
  {
2053
1484
  type: "button",
@@ -2055,7 +1486,7 @@ var ColorPicker = ({ color, onChange }) => {
2055
1486
  title: "Annotation Color",
2056
1487
  onClick: () => setIsOpen((prev) => !prev),
2057
1488
  children: [
2058
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1489
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2059
1490
  "span",
2060
1491
  {
2061
1492
  style: {
@@ -2069,11 +1500,11 @@ var ColorPicker = ({ color, onChange }) => {
2069
1500
  }
2070
1501
  }
2071
1502
  ),
2072
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_fontawesome5.FontAwesomeIcon, { icon: import_free_solid_svg_icons5.faPalette, style: { fontSize: "12px", opacity: 0.8 } })
1503
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_fontawesome4.FontAwesomeIcon, { icon: import_free_solid_svg_icons4.faPalette, style: { fontSize: "12px", opacity: 0.8 } })
2073
1504
  ]
2074
1505
  }
2075
1506
  ),
2076
- isOpen && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "tbib-iv-popover", children: PRESET_COLORS2.map((c) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1507
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "tbib-iv-popover", children: PRESET_COLORS2.map((c) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2077
1508
  "button",
2078
1509
  {
2079
1510
  type: "button",
@@ -2091,8 +1522,8 @@ var ColorPicker = ({ color, onChange }) => {
2091
1522
  };
2092
1523
 
2093
1524
  // src/components/StrokeWidthPicker.tsx
2094
- var import_react10 = require("react");
2095
- var import_jsx_runtime9 = require("react/jsx-runtime");
1525
+ var import_react9 = require("react");
1526
+ var import_jsx_runtime7 = require("react/jsx-runtime");
2096
1527
  var WIDTH_OPTIONS = [
2097
1528
  { label: "Fine (2px)", value: 2, iconSize: "6px" },
2098
1529
  { label: "Medium (4px)", value: 4, iconSize: "10px" },
@@ -2103,9 +1534,9 @@ var StrokeWidthPicker = ({
2103
1534
  strokeWidth,
2104
1535
  onChange
2105
1536
  }) => {
2106
- const [isOpen, setIsOpen] = (0, import_react10.useState)(false);
2107
- const containerRef = (0, import_react10.useRef)(null);
2108
- (0, import_react10.useEffect)(() => {
1537
+ const [isOpen, setIsOpen] = (0, import_react9.useState)(false);
1538
+ const containerRef = (0, import_react9.useRef)(null);
1539
+ (0, import_react9.useEffect)(() => {
2109
1540
  const handleOutsideClick = (e) => {
2110
1541
  if (containerRef.current && !containerRef.current.contains(e.target)) {
2111
1542
  setIsOpen(false);
@@ -2119,15 +1550,15 @@ var StrokeWidthPicker = ({
2119
1550
  };
2120
1551
  }, [isOpen]);
2121
1552
  const currentOption = WIDTH_OPTIONS.find((o) => o.value === strokeWidth) || WIDTH_OPTIONS[1];
2122
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { ref: containerRef, style: { position: "relative", display: "inline-block" }, children: [
2123
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1553
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { ref: containerRef, style: { position: "relative", display: "inline-block" }, children: [
1554
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2124
1555
  "button",
2125
1556
  {
2126
1557
  type: "button",
2127
1558
  className: "tbib-iv-btn",
2128
1559
  title: "Stroke Thickness",
2129
1560
  onClick: () => setIsOpen((prev) => !prev),
2130
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1561
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2131
1562
  "span",
2132
1563
  {
2133
1564
  style: {
@@ -2137,7 +1568,7 @@ var StrokeWidthPicker = ({
2137
1568
  width: "16px",
2138
1569
  height: "16px"
2139
1570
  },
2140
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1571
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2141
1572
  "span",
2142
1573
  {
2143
1574
  style: {
@@ -2152,7 +1583,7 @@ var StrokeWidthPicker = ({
2152
1583
  )
2153
1584
  }
2154
1585
  ),
2155
- isOpen && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1586
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2156
1587
  "div",
2157
1588
  {
2158
1589
  className: "tbib-iv-popover",
@@ -2161,7 +1592,7 @@ var StrokeWidthPicker = ({
2161
1592
  minWidth: "120px",
2162
1593
  padding: "4px"
2163
1594
  },
2164
- children: WIDTH_OPTIONS.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1595
+ children: WIDTH_OPTIONS.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
2165
1596
  "button",
2166
1597
  {
2167
1598
  type: "button",
@@ -2178,7 +1609,7 @@ var StrokeWidthPicker = ({
2178
1609
  setIsOpen(false);
2179
1610
  },
2180
1611
  children: [
2181
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1612
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2182
1613
  "span",
2183
1614
  {
2184
1615
  style: {
@@ -2190,7 +1621,7 @@ var StrokeWidthPicker = ({
2190
1621
  }
2191
1622
  }
2192
1623
  ),
2193
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: opt.label })
1624
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: opt.label })
2194
1625
  ]
2195
1626
  },
2196
1627
  opt.value
@@ -2199,6 +1630,177 @@ var StrokeWidthPicker = ({
2199
1630
  )
2200
1631
  ] });
2201
1632
  };
1633
+
1634
+ // src/components/DownloadMenu.tsx
1635
+ var import_react10 = require("react");
1636
+ var import_react_fontawesome5 = require("@fortawesome/react-fontawesome");
1637
+ var import_free_solid_svg_icons5 = require("@fortawesome/free-solid-svg-icons");
1638
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1639
+ var DownloadMenu = ({
1640
+ onDownloadAnnotated,
1641
+ onDownloadClean,
1642
+ onExportJson
1643
+ }) => {
1644
+ const [isOpen, setIsOpen] = (0, import_react10.useState)(false);
1645
+ const [isExporting, setIsExporting] = (0, import_react10.useState)(false);
1646
+ const [popoverPos, setPopoverPos] = (0, import_react10.useState)({ top: 0, right: 0 });
1647
+ const containerRef = (0, import_react10.useRef)(null);
1648
+ (0, import_react10.useEffect)(() => {
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
+ (0, import_react10.useEffect)(() => {
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__ */ (0, import_jsx_runtime8.jsxs)(
1693
+ "div",
1694
+ {
1695
+ ref: containerRef,
1696
+ style: {
1697
+ position: "relative",
1698
+ display: "inline-flex",
1699
+ alignItems: "center"
1700
+ },
1701
+ children: [
1702
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
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__ */ (0, import_jsx_runtime8.jsx)(
1717
+ import_react_fontawesome5.FontAwesomeIcon,
1718
+ {
1719
+ icon: isExporting ? import_free_solid_svg_icons5.faSpinner : import_free_solid_svg_icons5.faDownload,
1720
+ className: isExporting ? "fa-spin" : "",
1721
+ style: { fontSize: "14px" }
1722
+ }
1723
+ )
1724
+ }
1725
+ ),
1726
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
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__ */ (0, import_jsx_runtime8.jsx)(import_react_fontawesome5.FontAwesomeIcon, { icon: import_free_solid_svg_icons5.faChevronDown, style: { fontSize: "10px", opacity: 0.8 } })
1744
+ }
1745
+ ),
1746
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
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__ */ (0, import_jsx_runtime8.jsxs)(
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__ */ (0, import_jsx_runtime8.jsx)(import_react_fontawesome5.FontAwesomeIcon, { icon: import_free_solid_svg_icons5.faPaintBrush, style: { fontSize: "13px", color: "var(--tbib-iv-accent)" } }),
1774
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: "Annotated Image (PNG)" })
1775
+ ]
1776
+ }
1777
+ ),
1778
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
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__ */ (0, import_jsx_runtime8.jsx)(import_react_fontawesome5.FontAwesomeIcon, { icon: import_free_solid_svg_icons5.faImage, style: { fontSize: "13px" } }),
1793
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: "Clean Image (Original)" })
1794
+ ]
1795
+ }
1796
+ )
1797
+ ]
1798
+ }
1799
+ )
1800
+ ]
1801
+ }
1802
+ );
1803
+ };
2202
1804
  // Annotate the CommonJS export names for ESM import in node:
2203
1805
  0 && (module.exports = {
2204
1806
  AnnotationCanvas,