@tbib-image-viewer/react 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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,317 +141,208 @@ 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 toolbarScrollRef = import_react2.default.useRef(null);
285
- const subtoolbarScrollRef = 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 (!toolbarScrollRef.current) return;
290
- toolbarTouchState.current = {
291
- isDown: true,
292
- startX: e.touches[0].clientX,
293
- scrollLeft: toolbarScrollRef.current.scrollLeft
294
- };
295
- };
296
- const handleToolbarTouchMove = (e) => {
297
- if (!toolbarTouchState.current.isDown || !toolbarScrollRef.current) return;
298
- const dx = e.touches[0].clientX - toolbarTouchState.current.startX;
299
- toolbarScrollRef.current.scrollLeft = toolbarTouchState.current.scrollLeft - dx;
300
- };
301
- const handleToolbarTouchEnd = () => {
302
- toolbarTouchState.current.isDown = false;
303
- };
304
- const handleSubtoolbarTouchStart = (e) => {
305
- if (!subtoolbarScrollRef.current) return;
306
- subtoolbarTouchState.current = {
307
- isDown: true,
308
- startX: e.touches[0].clientX,
309
- scrollLeft: subtoolbarScrollRef.current.scrollLeft
310
- };
311
- };
312
- const handleSubtoolbarTouchMove = (e) => {
313
- if (!subtoolbarTouchState.current.isDown || !subtoolbarScrollRef.current) return;
314
- const dx = e.touches[0].clientX - subtoolbarTouchState.current.startX;
315
- subtoolbarScrollRef.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.jsx)("header", { className: "tbib-iv-toolbar", role: "toolbar", "aria-label": "Image tools", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
322
- "div",
323
- {
324
- ref: toolbarScrollRef,
325
- className: "tbib-iv-toolbar-scroll",
326
- onTouchStart: handleToolbarTouchStart,
327
- onTouchMove: handleToolbarTouchMove,
328
- onTouchEnd: handleToolbarTouchEnd,
329
- children: [
330
- currentIndex !== void 0 && totalImages !== void 0 && totalImages > 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
331
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "tbib-iv-tabular", title: "Current Image", children: [
332
- currentIndex + 1,
333
- " / ",
334
- totalImages
335
- ] }),
336
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" })
337
- ] }),
338
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
339
- "button",
340
- {
341
- type: "button",
342
- className: `tbib-iv-btn ${activeTool === "hand" ? "tbib-iv-btn-active" : ""}`,
343
- onClick: () => onToolChange("hand"),
344
- title: "Pan & Move (1-finger / drag)",
345
- "aria-label": "Hand Pan Tool",
346
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faHand })
347
- }
348
- ),
349
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
350
- "button",
351
- {
352
- type: "button",
353
- className: `tbib-iv-btn ${activeTool === "pen" ? "tbib-iv-btn-active" : ""}`,
354
- onClick: () => onToolChange("pen"),
355
- title: "Draw Pen",
356
- "aria-label": "Pen Tool",
357
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faPen })
358
- }
359
- ),
360
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
361
- "button",
362
- {
363
- type: "button",
364
- className: `tbib-iv-btn ${activeTool === "highlighter" ? "tbib-iv-btn-active" : ""}`,
365
- onClick: () => onToolChange("highlighter"),
366
- title: "Highlighter (Semi-transparent)",
367
- "aria-label": "Highlighter Tool",
368
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faHighlighter })
369
- }
370
- ),
371
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
372
- "button",
373
- {
374
- type: "button",
375
- className: `tbib-iv-btn ${activeTool === "laser" ? "tbib-iv-btn-active" : ""}`,
376
- onClick: () => onToolChange("laser"),
377
- title: "Laser Pointer (Glowing WebGL trail)",
378
- "aria-label": "Laser Pointer",
379
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faCrosshairs })
380
- }
381
- ),
382
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
383
- "button",
384
- {
385
- type: "button",
386
- className: `tbib-iv-btn ${activeTool === "eraser" ? "tbib-iv-btn-active" : ""}`,
387
- onClick: () => onToolChange("eraser"),
388
- title: "Eraser (Erase strokes on tap)",
389
- "aria-label": "Eraser Tool",
390
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faEraser })
391
- }
392
- ),
393
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" }),
394
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
395
- "button",
396
- {
397
- type: "button",
398
- className: "tbib-iv-btn",
399
- disabled: !canUndo,
400
- onClick: onUndo,
401
- title: "Undo (Ctrl+Z)",
402
- "aria-label": "Undo",
403
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faRotateLeft })
404
- }
405
- ),
406
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
407
- "button",
408
- {
409
- type: "button",
410
- className: "tbib-iv-btn",
411
- disabled: !canRedo,
412
- onClick: onRedo,
413
- title: "Redo (Ctrl+Y)",
414
- "aria-label": "Redo",
415
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faRotateRight })
416
- }
417
- ),
418
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
419
- "button",
420
- {
421
- type: "button",
422
- className: "tbib-iv-btn",
423
- onClick: onClear,
424
- title: "Clear Slide Annotations",
425
- "aria-label": "Clear All",
426
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faTrashCan })
427
- }
428
- ),
429
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" }),
430
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
431
- "button",
432
- {
433
- type: "button",
434
- className: "tbib-iv-btn",
435
- onClick: onZoomOut,
436
- title: "Zoom Out (-)",
437
- "aria-label": "Zoom Out",
438
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faMagnifyingGlassMinus })
439
- }
440
- ),
441
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "tbib-iv-tabular", title: "Current Zoom Scale", children: [
442
- Math.round(zoomScale * 100),
443
- "%"
444
- ] }),
445
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
446
- "button",
447
- {
448
- type: "button",
449
- className: "tbib-iv-btn",
450
- onClick: onZoomIn,
451
- title: "Zoom In (+)",
452
- "aria-label": "Zoom In",
453
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faMagnifyingGlassPlus })
454
- }
455
- ),
456
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
457
- "button",
458
- {
459
- type: "button",
460
- className: "tbib-iv-btn",
461
- onClick: onZoomReset,
462
- title: "Reset Fit to Screen (0)",
463
- "aria-label": "Reset Zoom",
464
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faExpand })
465
- }
466
- ),
467
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
468
- "button",
469
- {
470
- type: "button",
471
- className: "tbib-iv-btn",
472
- onClick: onRotate,
473
- title: "Rotate 90\xB0 Clockwise",
474
- "aria-label": "Rotate Image",
475
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faRotate })
476
- }
477
- ),
478
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" }),
479
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
480
- DownloadMenu,
481
- {
482
- onDownloadAnnotated,
483
- onDownloadClean,
484
- onExportJson
485
- }
486
- ),
487
- onToggleFullscreen && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
488
- "button",
489
- {
490
- type: "button",
491
- className: "tbib-iv-btn",
492
- onClick: onToggleFullscreen,
493
- title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
494
- "aria-label": "Toggle Fullscreen",
495
- 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 })
496
- }
497
- ),
498
- onClose && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
499
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" }),
500
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
501
- "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",
502
203
  {
503
- type: "button",
504
- className: "tbib-iv-btn",
505
- onClick: onClose,
506
- title: "Close Viewer (Esc)",
507
- "aria-label": "Close",
508
- style: { color: "#ef4444" },
509
- 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
+ }
510
211
  }
511
- )
512
- ] })
513
- ]
514
- }
515
- ) }),
516
- showSubtoolbar && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-subtoolbar", role: "region", "aria-label": "Tool customization", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
517
- "div",
518
- {
519
- ref: subtoolbarScrollRef,
520
- className: "tbib-iv-subtoolbar-scroll",
521
- onTouchStart: handleSubtoolbarTouchStart,
522
- onTouchMove: handleSubtoolbarTouchMove,
523
- onTouchEnd: handleSubtoolbarTouchEnd,
524
- children: [
525
- 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)(
526
222
  "button",
527
223
  {
528
224
  type: "button",
529
- className: `tbib-iv-thickness-btn ${strokeWidth === opt.value ? "tbib-iv-thickness-active" : ""}`,
530
- onClick: () => onStrokeWidthChange(opt.value),
531
- title: `${opt.label} stroke (${opt.value}px)`,
532
- children: [
533
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
534
- "span",
535
- {
536
- style: {
537
- display: "inline-block",
538
- width: `${Math.min(opt.value * 1.5, 12)}px`,
539
- height: `${Math.min(opt.value * 1.5, 12)}px`,
540
- borderRadius: "50%",
541
- backgroundColor: "currentColor"
542
- }
543
- }
544
- ),
545
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: opt.label })
546
- ]
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
+ }
547
237
  },
548
- opt.value
549
- )) }),
550
- 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:" }),
551
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider", style: { height: "16px", margin: "0 2px" } }),
552
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "inline-flex", alignItems: "center", gap: "6px" }, children: [
553
- PRESET_COLORS.map((c) => {
554
- const isSelected = color.toLowerCase() === c.toLowerCase();
555
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
556
- "button",
557
- {
558
- type: "button",
559
- className: `tbib-iv-swatch-btn ${isSelected ? "tbib-iv-swatch-active" : ""}`,
560
- style: { backgroundColor: c },
561
- onClick: () => onColorChange(c),
562
- title: `Select color: ${c}`,
563
- "aria-label": `Color ${c}`
564
- },
565
- c
566
- );
567
- }),
568
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "tbib-iv-custom-color-btn", title: "Custom Color Picker", children: [
569
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faEyeDropper, style: { fontSize: "10px", opacity: 0.8 } }),
570
- /* @__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)(
571
261
  "input",
572
262
  {
573
263
  type: "color",
574
264
  value: color,
575
265
  onChange: (e) => onColorChange(e.target.value),
576
- className: "tbib-iv-custom-color-input",
577
- "aria-label": "Custom color picker"
266
+ "aria-label": "Couleur personnalis\xE9e",
267
+ style: { position: "absolute", inset: 0, opacity: 0, cursor: "pointer" }
578
268
  }
579
269
  )
580
- ] })
581
- ] })
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
582
336
  ]
583
337
  }
584
- ) })
338
+ )
585
339
  ] });
586
340
  };
587
341
 
588
342
  // src/components/AnnotationCanvas.tsx
589
343
  var import_react3 = require("react");
590
344
  var import_core = require("@tbib-image-viewer/core");
591
- var import_jsx_runtime3 = require("react/jsx-runtime");
345
+ var import_jsx_runtime2 = require("react/jsx-runtime");
592
346
  var AnnotationCanvas = ({
593
347
  width,
594
348
  height,
@@ -729,7 +483,7 @@ var AnnotationCanvas = ({
729
483
  return (0, import_core.pointsToSvgPath)(currentPoints, width, height);
730
484
  }, [currentPoints, width, height]);
731
485
  const pointerEventsStyle = isDrawableTool || isEraser ? "auto" : "none";
732
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
486
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
733
487
  "svg",
734
488
  {
735
489
  ref: svgRef,
@@ -747,11 +501,11 @@ var AnnotationCanvas = ({
747
501
  onPointerUp: handlePointerUp,
748
502
  onPointerCancel: handlePointerUp,
749
503
  children: [
750
- /* @__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" }) }) }),
751
505
  strokes.map((stroke) => {
752
506
  const d = (0, import_core.pointsToSvgPath)(stroke.points, width, height);
753
507
  const isHighlighter = stroke.tool === "highlighter";
754
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
508
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
755
509
  "path",
756
510
  {
757
511
  d,
@@ -762,400 +516,74 @@ var AnnotationCanvas = ({
762
516
  strokeLinejoin: "round",
763
517
  style: {
764
518
  mixBlendMode: isHighlighter ? "multiply" : "normal",
765
- pointerEvents: "none"
766
- }
767
- },
768
- stroke.id
769
- );
770
- }),
771
- currentPathD && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
772
- "path",
773
- {
774
- d: currentPathD,
775
- fill: "none",
776
- stroke: activeTool === "highlighter" ? (0, import_core.hexToRgba)(color, 0.35) : color,
777
- strokeWidth: activeTool === "highlighter" ? strokeWidth * 2.5 : strokeWidth,
778
- strokeLinecap: "round",
779
- strokeLinejoin: "round",
780
- style: {
781
- mixBlendMode: activeTool === "highlighter" ? "multiply" : "normal",
782
- pointerEvents: "none"
783
- }
784
- }
785
- )
786
- ]
787
- }
788
- );
789
- };
790
-
791
- // src/components/LaserCursorLayer.tsx
792
- var import_react4 = require("react");
793
- var import_ogl = require("ogl");
794
- var import_jsx_runtime4 = require("react/jsx-runtime");
795
- var MAX_POINTS = 64;
796
- var VERTEX_SHADER = `
797
- attribute vec2 position;
798
- attribute vec2 uv;
799
- varying vec2 vUv;
800
-
801
- void main() {
802
- vUv = uv;
803
- gl_Position = vec4(position, 0.0, 1.0);
804
- }
805
- `;
806
- var FRAGMENT_SHADER = `
807
- precision highp float;
808
-
809
- #define MAX_POINTS 64
810
-
811
- uniform vec2 uResolution;
812
- uniform vec2 uPoints[MAX_POINTS];
813
- uniform float uPointCount;
814
- uniform vec3 uColor;
815
- uniform vec3 uSecondaryColor;
816
- uniform float uTrailWidth;
817
- uniform float uTaper;
818
- uniform float uGlowIntensity;
819
- uniform float uGlowSpread;
820
- uniform float uHotspot;
821
- uniform float uBrightness;
822
- uniform float uOpacity;
823
- uniform float uPulseSpeed;
824
- uniform float uNoiseStrength;
825
- uniform float uTime;
826
- uniform float uFade;
827
-
828
- varying vec2 vUv;
829
-
830
- float sRGB(float x) {
831
- if (x <= 0.00031308) return 12.92 * x;
832
- return 1.055 * pow(x, 1.0 / 2.4) - 0.055;
833
- }
834
-
835
- float hash(vec2 p) {
836
- return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
837
- }
838
-
839
- float filmGrain(vec2 p, float time) {
840
- float frame = time * 18.0;
841
- float frameIndex = mod(floor(frame), 256.0);
842
- float nextFrameIndex = mod(frameIndex + 1.0, 256.0);
843
- float blend = fract(frame);
844
- blend = blend * blend * (3.0 - 2.0 * blend);
845
- vec2 pixel = floor(p);
846
- float current = hash(pixel + vec2(frameIndex * 17.0, frameIndex * 31.0));
847
- float next = hash(pixel + vec2(nextFrameIndex * 17.0, nextFrameIndex * 31.0));
848
- return mix(current, next, blend) * 2.0 - 1.0;
849
- }
850
-
851
- void main() {
852
- vec2 pixel = vUv * uResolution;
853
- float denominator = max(uPointCount - 1.0, 1.0);
854
- float strongest = 0.0;
855
- float strongestCore = 0.0;
856
- float colorWeight = 0.0;
857
- vec3 colorSum = vec3(0.0);
858
-
859
- for (int i = 0; i < MAX_POINTS - 1; i++) {
860
- float index = float(i);
861
- vec2 start = uPoints[i];
862
- vec2 end = uPoints[i + 1];
863
- vec2 toPixel = pixel - start;
864
- vec2 segment = end - start;
865
- float along = clamp(dot(toPixel, segment) / max(dot(segment, segment), 0.0001), 0.0, 1.0);
866
- float progress = clamp((index + along) / denominator, 0.0, 1.0);
867
- float life = pow(max(1.0 - progress, 0.0), mix(0.55, 1.25, uTaper));
868
- float width = uTrailWidth * mix(1.0, 0.25, pow(progress, mix(0.55, 1.6, uTaper)));
869
- float distanceToTrail = length(toPixel - segment * along);
870
- float falloff = max(width * (0.8 + uGlowSpread * 1.4), 0.5);
871
- float beam = min(1.0, (falloff * falloff) / (distanceToTrail * distanceToTrail + falloff * falloff));
872
- float core = exp(-pow(distanceToTrail / max(width, 0.5), 2.0) * 2.5);
873
- float pulseAmount = min(abs(uPulseSpeed), 1.0);
874
- float pulse = 1.0 + sin(uTime * uPulseSpeed * 3.0 - progress * 11.0) * 0.16 * pulseAmount;
875
- float intensity = (core + beam * uGlowIntensity * 0.55) * life * pulse;
876
- vec3 segmentColor = mix(uColor, uSecondaryColor, progress);
877
-
878
- strongest = max(strongest, intensity);
879
- strongestCore = max(strongestCore, core * life);
880
- colorSum += segmentColor * intensity;
881
- colorWeight += intensity;
882
- }
883
-
884
- float grain = filmGrain(pixel, uTime);
885
- float noiseAmount = (1.0 - exp(-uNoiseStrength * 2.2)) * 0.4;
886
- float alpha = clamp(strongest * uOpacity * uFade, 0.0, 1.0);
887
- if (alpha < 0.0005) discard;
888
-
889
- vec3 color = colorSum / max(colorWeight, 0.0001);
890
- color = mix(color, vec3(1.0), smoothstep(0.25, 0.95, strongestCore) * uHotspot);
891
- float luminance = sRGB(clamp(strongest * uBrightness, 0.0, 1.0));
892
- luminance *= 1.0 + grain * noiseAmount;
893
- vec3 additiveColor = color * luminance;
894
- float normalAlpha = clamp(strongest * uBrightness * uOpacity * uFade, 0.0, 1.0);
895
- vec3 normalColor = mix(color, vec3(1.0), smoothstep(0.45, 1.0, strongestCore) * uHotspot * 0.35);
896
- gl_FragColor = vec4(mix(additiveColor, normalColor, 1.0), mix(alpha, normalAlpha, 1.0));
897
- }
898
- `;
899
- function hexToRgb(hex) {
900
- let value = (hex || "").replace("#", "").trim();
901
- if (value.length === 3) {
902
- value = value.split("").map((c) => c + c).join("");
903
- }
904
- const parsed = Number.parseInt(value || "ff0000", 16);
905
- return [
906
- (parsed >> 16 & 255) / 255,
907
- (parsed >> 8 & 255) / 255,
908
- (parsed & 255) / 255
909
- ];
910
- }
911
- var LaserCursorLayer = ({
912
- color = "#ef4444",
913
- secondaryColor = "#ef4444",
914
- trailLength = 29,
915
- trailWidth = 8,
916
- trailTaper = 0.22,
917
- followSpeed = 1.5,
918
- glowIntensity = 1.9,
919
- glowSpread = 0.1,
920
- hotspot = 0.5,
921
- brightness = 1.25,
922
- opacity = 1,
923
- pulseSpeed = 0.8,
924
- noiseStrength = 0.035,
925
- idleFade = true,
926
- idleTimeout = 700,
927
- fadeDuration = 1500,
928
- enabled = true,
929
- className = "",
930
- style,
931
- ...rest
932
- }) => {
933
- const containerRef = (0, import_react4.useRef)(null);
934
- const canvasRef = (0, import_react4.useRef)(null);
935
- (0, import_react4.useEffect)(() => {
936
- const container = containerRef.current;
937
- const canvas = canvasRef.current;
938
- if (!container || !canvas || !enabled) return;
939
- let renderer = null;
940
- try {
941
- renderer = new import_ogl.Renderer({
942
- canvas,
943
- alpha: true,
944
- dpr: Math.min(window.devicePixelRatio || 1, 1.5)
945
- });
946
- } catch {
947
- return;
948
- }
949
- const gl = renderer.gl;
950
- gl.clearColor(0, 0, 0, 0);
951
- const pointData = Array(MAX_POINTS * 2).fill(0);
952
- const points = Array.from({ length: MAX_POINTS }, () => ({ x: 0, y: 0 }));
953
- const target = { x: 0, y: 0 };
954
- const head = { x: 0, y: 0 };
955
- let program;
956
- let mesh;
957
- try {
958
- program = new import_ogl.Program(gl, {
959
- vertex: VERTEX_SHADER,
960
- fragment: FRAGMENT_SHADER,
961
- uniforms: {
962
- uResolution: { value: [1, 1] },
963
- uPoints: { value: pointData },
964
- uPointCount: { value: trailLength },
965
- uColor: { value: hexToRgb(color) },
966
- uSecondaryColor: { value: hexToRgb(secondaryColor) },
967
- uTrailWidth: { value: trailWidth },
968
- uTaper: { value: trailTaper },
969
- uGlowIntensity: { value: glowIntensity },
970
- uGlowSpread: { value: glowSpread },
971
- uHotspot: { value: hotspot },
972
- uBrightness: { value: brightness },
973
- uOpacity: { value: opacity },
974
- uPulseSpeed: { value: pulseSpeed },
975
- uNoiseStrength: { value: noiseStrength },
976
- uTime: { value: 0 },
977
- uFade: { value: 0 }
978
- },
979
- transparent: true,
980
- depthTest: false,
981
- depthWrite: false
982
- });
983
- mesh = new import_ogl.Mesh(gl, { geometry: new import_ogl.Triangle(gl), program });
984
- } catch {
985
- return;
986
- }
987
- let width = 0;
988
- let height = 0;
989
- let isHovered = false;
990
- let lastMoveTime = 0;
991
- let animationId;
992
- const resize = () => {
993
- const rect = container.getBoundingClientRect();
994
- const newWidth = Math.floor(rect.width);
995
- const newHeight = Math.floor(rect.height);
996
- if (newWidth <= 0 || newHeight <= 0) return;
997
- if (newWidth === width && newHeight === height) return;
998
- width = newWidth;
999
- height = newHeight;
1000
- renderer?.setSize(width, height);
1001
- program.uniforms.uResolution.value = [width, height];
1002
- };
1003
- resize();
1004
- const resizeObserver = new ResizeObserver(resize);
1005
- resizeObserver.observe(container);
1006
- const onPointerMove = (e) => {
1007
- const rect = container.getBoundingClientRect();
1008
- target.x = e.clientX - rect.left;
1009
- target.y = rect.height - (e.clientY - rect.top);
1010
- lastMoveTime = performance.now();
1011
- isHovered = true;
1012
- };
1013
- const onPointerLeave = () => {
1014
- isHovered = false;
1015
- };
1016
- container.addEventListener("pointermove", onPointerMove);
1017
- container.addEventListener("pointerleave", onPointerLeave);
1018
- let lastTime = performance.now();
1019
- const render = (now) => {
1020
- animationId = requestAnimationFrame(render);
1021
- const dt = Math.min((now - lastTime) / 1e3, 0.1);
1022
- lastTime = now;
1023
- const speed = followSpeed * 20;
1024
- head.x += (target.x - head.x) * Math.min(dt * speed, 1);
1025
- head.y += (target.y - head.y) * Math.min(dt * speed, 1);
1026
- for (let i = MAX_POINTS - 1; i > 0; i--) {
1027
- points[i].x = points[i - 1].x;
1028
- points[i].y = points[i - 1].y;
1029
- }
1030
- points[0].x = head.x;
1031
- points[0].y = head.y;
1032
- for (let i = 0; i < MAX_POINTS; i++) {
1033
- pointData[i * 2] = points[i].x;
1034
- pointData[i * 2 + 1] = points[i].y;
1035
- }
1036
- program.uniforms.uTime.value = now * 1e-3;
1037
- let fade = 1;
1038
- if (idleFade) {
1039
- const idleTime = now - lastMoveTime;
1040
- if (!isHovered || idleTime > idleTimeout) {
1041
- const fadeProgress = Math.min(Math.max((idleTime - idleTimeout) / fadeDuration, 0), 1);
1042
- fade = 1 - fadeProgress;
1043
- }
1044
- }
1045
- program.uniforms.uFade.value = fade;
1046
- if (fade > 1e-3) {
1047
- renderer?.render({ scene: mesh });
1048
- } else {
1049
- gl.clear(gl.COLOR_BUFFER_BIT);
1050
- }
1051
- };
1052
- animationId = requestAnimationFrame(render);
1053
- return () => {
1054
- cancelAnimationFrame(animationId);
1055
- resizeObserver.disconnect();
1056
- container.removeEventListener("pointermove", onPointerMove);
1057
- container.removeEventListener("pointerleave", onPointerLeave);
1058
- };
1059
- }, [
1060
- color,
1061
- secondaryColor,
1062
- trailLength,
1063
- trailWidth,
1064
- trailTaper,
1065
- followSpeed,
1066
- glowIntensity,
1067
- glowSpread,
1068
- hotspot,
1069
- brightness,
1070
- opacity,
1071
- pulseSpeed,
1072
- noiseStrength,
1073
- idleFade,
1074
- idleTimeout,
1075
- fadeDuration,
1076
- enabled
1077
- ]);
1078
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1079
- "div",
1080
- {
1081
- ref: containerRef,
1082
- className: `tbib-iv-laser-layer ${className}`,
1083
- style: {
1084
- position: "absolute",
1085
- top: 0,
1086
- left: 0,
1087
- width: "100%",
1088
- height: "100%",
1089
- pointerEvents: "auto",
1090
- touchAction: "none",
1091
- cursor: "crosshair",
1092
- zIndex: 30,
1093
- overflow: "hidden",
1094
- ...style
1095
- },
1096
- ...rest,
1097
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1098
- "canvas",
1099
- {
1100
- ref: canvasRef,
1101
- className: "tbib-iv-laser-canvas",
1102
- style: {
1103
- position: "absolute",
1104
- top: 0,
1105
- left: 0,
1106
- width: "100%",
1107
- height: "100%",
1108
- display: "block",
1109
- 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
+ }
1110
538
  }
1111
- }
1112
- )
539
+ )
540
+ ]
1113
541
  }
1114
542
  );
1115
543
  };
1116
544
 
1117
545
  // src/hooks/useImageTransform.ts
1118
- var import_react5 = require("react");
546
+ var import_react4 = require("react");
1119
547
  var import_core2 = require("@tbib-image-viewer/core");
1120
548
  function useImageTransform() {
1121
- const [transform, setTransform] = (0, import_react5.useState)(import_core2.DEFAULT_TRANSFORM);
1122
- const pinchStartDistRef = (0, import_react5.useRef)(null);
1123
- const pinchStartScaleRef = (0, import_react5.useRef)(1);
1124
- 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)(() => {
1125
553
  setTransform((prev) => ({
1126
554
  ...prev,
1127
555
  scale: (0, import_core2.clampScale)(prev.scale * 1.25)
1128
556
  }));
1129
557
  }, []);
1130
- const zoomOut = (0, import_react5.useCallback)(() => {
558
+ const zoomOut = (0, import_react4.useCallback)(() => {
1131
559
  setTransform((prev) => ({
1132
560
  ...prev,
1133
561
  scale: (0, import_core2.clampScale)(prev.scale / 1.25)
1134
562
  }));
1135
563
  }, []);
1136
- const resetTransform = (0, import_react5.useCallback)(() => {
564
+ const resetTransform = (0, import_react4.useCallback)(() => {
1137
565
  setTransform(import_core2.DEFAULT_TRANSFORM);
1138
566
  }, []);
1139
- const rotateClockwise = (0, import_react5.useCallback)(() => {
567
+ const rotateClockwise = (0, import_react4.useCallback)(() => {
1140
568
  setTransform((prev) => ({
1141
569
  ...prev,
1142
570
  rotate: (prev.rotate + 90) % 360
1143
571
  }));
1144
572
  }, []);
1145
- const panBy = (0, import_react5.useCallback)((dx, dy) => {
573
+ const panBy = (0, import_react4.useCallback)((dx, dy) => {
1146
574
  setTransform((prev) => ({
1147
575
  ...prev,
1148
576
  translateX: prev.translateX + dx,
1149
577
  translateY: prev.translateY + dy
1150
578
  }));
1151
579
  }, []);
1152
- const pinchZoomByRatio = (0, import_react5.useCallback)((startScale, ratio) => {
580
+ const pinchZoomByRatio = (0, import_react4.useCallback)((startScale, ratio) => {
1153
581
  setTransform((prev) => ({
1154
582
  ...prev,
1155
583
  scale: (0, import_core2.clampScale)(startScale * ratio)
1156
584
  }));
1157
585
  }, []);
1158
- const handleWheel = (0, import_react5.useCallback)((e) => {
586
+ const handleWheel = (0, import_react4.useCallback)((e) => {
1159
587
  e.preventDefault();
1160
588
  const factor = e.deltaY < 0 ? 1.15 : 1 / 1.15;
1161
589
  setTransform((prev) => ({
@@ -1163,7 +591,7 @@ function useImageTransform() {
1163
591
  scale: (0, import_core2.clampScale)(prev.scale * factor)
1164
592
  }));
1165
593
  }, []);
1166
- const handleTouchStart = (0, import_react5.useCallback)((e) => {
594
+ const handleTouchStart = (0, import_react4.useCallback)((e) => {
1167
595
  if (e.touches.length === 2) {
1168
596
  const t1 = e.touches[0];
1169
597
  const t2 = e.touches[1];
@@ -1172,7 +600,7 @@ function useImageTransform() {
1172
600
  pinchStartScaleRef.current = transform.scale;
1173
601
  }
1174
602
  }, [transform.scale]);
1175
- const handleTouchMove = (0, import_react5.useCallback)((e) => {
603
+ const handleTouchMove = (0, import_react4.useCallback)((e) => {
1176
604
  if (e.touches.length === 2 && pinchStartDistRef.current !== null) {
1177
605
  const t1 = e.touches[0];
1178
606
  const t2 = e.touches[1];
@@ -1184,7 +612,7 @@ function useImageTransform() {
1184
612
  }));
1185
613
  }
1186
614
  }, []);
1187
- const handleTouchEnd = (0, import_react5.useCallback)(() => {
615
+ const handleTouchEnd = (0, import_react4.useCallback)(() => {
1188
616
  pinchStartDistRef.current = null;
1189
617
  }, []);
1190
618
  return {
@@ -1204,7 +632,8 @@ function useImageTransform() {
1204
632
  }
1205
633
 
1206
634
  // src/components/ImageViewer.tsx
1207
- 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"));
1208
637
  var ImageViewer = ({
1209
638
  src,
1210
639
  alt = "Medical illustration",
@@ -1222,32 +651,32 @@ var ImageViewer = ({
1222
651
  onAnnotationsChange,
1223
652
  children
1224
653
  }) => {
1225
- const effectiveSlideId = (0, import_react6.useMemo)(() => slideId || src, [slideId, src]);
1226
- const [activeTool, setActiveTool] = (0, import_react6.useState)(initialTool);
1227
- const [color, setColor] = (0, import_react6.useState)(initialColor);
1228
- const [strokeWidth, setStrokeWidth] = (0, import_react6.useState)(initialStrokeWidth);
1229
- 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)(
1230
659
  new import_core3.AnnotationStore(
1231
660
  initialAnnotations ? [{ slideId: effectiveSlideId, strokes: initialAnnotations }] : void 0
1232
661
  )
1233
662
  );
1234
- const [strokes, setStrokes] = (0, import_react6.useState)(
663
+ const [strokes, setStrokes] = (0, import_react5.useState)(
1235
664
  () => storeRef.current.getStrokes(effectiveSlideId)
1236
665
  );
1237
- const [canUndo, setCanUndo] = (0, import_react6.useState)(false);
1238
- const [canRedo, setCanRedo] = (0, import_react6.useState)(false);
1239
- const containerRef = (0, import_react6.useRef)(null);
1240
- const imgRef = (0, import_react6.useRef)(null);
1241
- const [imgSize, setImgSize] = (0, import_react6.useState)({ width: 800, height: 600 });
1242
- const [imageStatus, setImageStatus] = (0, import_react6.useState)("loading");
1243
- const [reloadKey, setReloadKey] = (0, import_react6.useState)(0);
1244
- 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)(() => {
1245
674
  if (!src) return "";
1246
675
  if (reloadKey === 0) return src;
1247
676
  const sep = src.includes("?") ? "&" : "?";
1248
677
  return `${src}${sep}_reload=${reloadKey}`;
1249
678
  }, [src, reloadKey]);
1250
- (0, import_react6.useEffect)(() => {
679
+ (0, import_react5.useEffect)(() => {
1251
680
  setImageStatus("loading");
1252
681
  if (imgRef.current && imgRef.current.complete && imgRef.current.naturalWidth > 0) {
1253
682
  setImgSize({
@@ -1270,9 +699,9 @@ var ImageViewer = ({
1270
699
  handleTouchMove,
1271
700
  handleTouchEnd
1272
701
  } = useImageTransform();
1273
- const isDraggingRef = (0, import_react6.useRef)(false);
1274
- const lastMousePosRef = (0, import_react6.useRef)({ x: 0, y: 0 });
1275
- (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)(() => {
1276
705
  const store = storeRef.current;
1277
706
  const unsubscribe = store.subscribe((id, updated) => {
1278
707
  if (id === effectiveSlideId) {
@@ -1302,13 +731,13 @@ var ImageViewer = ({
1302
731
  setImageStatus("loading");
1303
732
  setReloadKey((prev) => prev + 1);
1304
733
  };
1305
- const handleStrokeComplete = (0, import_react6.useCallback)(
734
+ const handleStrokeComplete = (0, import_react5.useCallback)(
1306
735
  (newStroke) => {
1307
736
  storeRef.current.addStroke(effectiveSlideId, newStroke);
1308
737
  },
1309
738
  [effectiveSlideId]
1310
739
  );
1311
- const handleEraseStroke = (0, import_react6.useCallback)(
740
+ const handleEraseStroke = (0, import_react5.useCallback)(
1312
741
  (point) => {
1313
742
  storeRef.current.removeStrokesNear(
1314
743
  effectiveSlideId,
@@ -1320,13 +749,13 @@ var ImageViewer = ({
1320
749
  },
1321
750
  [effectiveSlideId]
1322
751
  );
1323
- const handleUndo = (0, import_react6.useCallback)(() => {
752
+ const handleUndo = (0, import_react5.useCallback)(() => {
1324
753
  storeRef.current.undo(effectiveSlideId);
1325
754
  }, [effectiveSlideId]);
1326
- const handleRedo = (0, import_react6.useCallback)(() => {
755
+ const handleRedo = (0, import_react5.useCallback)(() => {
1327
756
  storeRef.current.redo(effectiveSlideId);
1328
757
  }, [effectiveSlideId]);
1329
- const handleClear = (0, import_react6.useCallback)(() => {
758
+ const handleClear = (0, import_react5.useCallback)(() => {
1330
759
  storeRef.current.clear(effectiveSlideId);
1331
760
  }, [effectiveSlideId]);
1332
761
  const handleStagePointerDown = (e) => {
@@ -1345,7 +774,7 @@ var ImageViewer = ({
1345
774
  const handleStagePointerUp = (e) => {
1346
775
  isDraggingRef.current = false;
1347
776
  };
1348
- (0, import_react6.useEffect)(() => {
777
+ (0, import_react5.useEffect)(() => {
1349
778
  const handleKeyDown = (e) => {
1350
779
  if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "z") {
1351
780
  e.preventDefault();
@@ -1398,14 +827,14 @@ var ImageViewer = ({
1398
827
  link.click();
1399
828
  setTimeout(() => URL.revokeObjectURL(url), 1e3);
1400
829
  };
1401
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
830
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1402
831
  "div",
1403
832
  {
1404
833
  ref: containerRef,
1405
834
  className: `tbib-iv-container ${theme === "light" ? "tbib-iv-light" : ""} ${className}`,
1406
835
  style,
1407
836
  children: [
1408
- showToolbar && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
837
+ showToolbar && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1409
838
  ImageToolbar,
1410
839
  {
1411
840
  activeTool,
@@ -1426,10 +855,11 @@ var ImageViewer = ({
1426
855
  onRotate: rotateClockwise,
1427
856
  onDownloadAnnotated: handleDownloadAnnotated,
1428
857
  onDownloadClean: handleDownloadClean,
1429
- onExportJson: handleExportJson
858
+ onExportJson: handleExportJson,
859
+ theme: theme === "light" ? "light" : "dark"
1430
860
  }
1431
861
  ),
1432
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
862
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1433
863
  "div",
1434
864
  {
1435
865
  className: "tbib-iv-stage",
@@ -1445,7 +875,7 @@ var ImageViewer = ({
1445
875
  cursor: activeTool === "hand" ? isDraggingRef.current ? "grabbing" : "grab" : "default"
1446
876
  },
1447
877
  children: [
1448
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
878
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1449
879
  "div",
1450
880
  {
1451
881
  className: "tbib-iv-stage-inner",
@@ -1454,7 +884,7 @@ var ImageViewer = ({
1454
884
  transition: isDraggingRef.current ? "none" : "transform 0.05s ease-out"
1455
885
  },
1456
886
  children: [
1457
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
887
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1458
888
  "img",
1459
889
  {
1460
890
  ref: imgRef,
@@ -1467,7 +897,7 @@ var ImageViewer = ({
1467
897
  },
1468
898
  `${src}-${reloadKey}`
1469
899
  ),
1470
- enableAnnotations && imageStatus === "loaded" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
900
+ enableAnnotations && imageStatus === "loaded" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1471
901
  AnnotationCanvas,
1472
902
  {
1473
903
  width: imgSize.width,
@@ -1486,28 +916,28 @@ var ImageViewer = ({
1486
916
  ]
1487
917
  }
1488
918
  ),
1489
- imageStatus === "loading" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "tbib-iv-status-overlay", children: [
1490
- /* @__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" }) }),
1491
- /* @__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..." })
1492
922
  ] }),
1493
- imageStatus === "error" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "tbib-iv-status-overlay tbib-iv-error-card", children: [
1494
- /* @__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 }) }),
1495
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { className: "tbib-iv-error-title", children: "Impossible de charger l'image" }),
1496
- /* @__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." }),
1497
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "tbib-iv-error-actions", children: [
1498
- /* @__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)(
1499
929
  "button",
1500
930
  {
1501
931
  type: "button",
1502
932
  className: "tbib-iv-btn tbib-iv-btn-primary tbib-iv-retry-btn",
1503
933
  onClick: handleReload,
1504
934
  children: [
1505
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_free_solid_svg_icons3.faRotateRight }),
1506
- /* @__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" })
1507
937
  ]
1508
938
  }
1509
939
  ),
1510
- src && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
940
+ src && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1511
941
  "a",
1512
942
  {
1513
943
  href: src,
@@ -1515,14 +945,14 @@ var ImageViewer = ({
1515
945
  rel: "noopener noreferrer",
1516
946
  className: "tbib-iv-btn tbib-iv-open-btn",
1517
947
  children: [
1518
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_fontawesome3.FontAwesomeIcon, { icon: import_faExternalLinkAlt.faExternalLinkAlt }),
1519
- /* @__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" })
1520
950
  ]
1521
951
  }
1522
952
  )
1523
953
  ] })
1524
954
  ] }),
1525
- 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" }) })
1526
956
  ]
1527
957
  }
1528
958
  ),
@@ -1533,29 +963,29 @@ var ImageViewer = ({
1533
963
  };
1534
964
 
1535
965
  // src/components/ImageGalleryLightbox.tsx
1536
- var import_react8 = require("react");
1537
- var import_react_fontawesome4 = require("@fortawesome/react-fontawesome");
1538
- 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");
1539
969
  var import_faExclamationTriangle2 = require("@fortawesome/free-solid-svg-icons/faExclamationTriangle");
1540
970
  var import_faExternalLinkAlt2 = require("@fortawesome/free-solid-svg-icons/faExternalLinkAlt");
1541
971
  var import_core4 = require("@tbib-image-viewer/core");
1542
972
 
1543
973
  // src/components/ThumbnailStrip.tsx
1544
- var import_jsx_runtime6 = require("react/jsx-runtime");
974
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1545
975
  var ThumbnailStrip = ({
1546
976
  items,
1547
977
  activeIndex,
1548
978
  onSelect
1549
979
  }) => {
1550
980
  if (items.length <= 1) return null;
1551
- 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)(
1552
982
  "button",
1553
983
  {
1554
984
  type: "button",
1555
985
  className: `tbib-iv-thumbnail-item ${idx === activeIndex ? "tbib-iv-thumbnail-item-active" : ""}`,
1556
986
  onClick: () => onSelect(idx),
1557
987
  title: item.title || `Image ${idx + 1}`,
1558
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
988
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1559
989
  "img",
1560
990
  {
1561
991
  src: item.thumbnailSrc || item.src,
@@ -1570,16 +1000,16 @@ var ThumbnailStrip = ({
1570
1000
  };
1571
1001
 
1572
1002
  // src/hooks/useSwipeGesture.ts
1573
- var import_react7 = require("react");
1003
+ var import_react6 = require("react");
1574
1004
  function useSwipeGesture({ onSwipeLeft, onSwipeRight, enabled = true }) {
1575
- const touchStartXRef = (0, import_react7.useRef)(null);
1576
- const touchStartYRef = (0, import_react7.useRef)(null);
1577
- 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) => {
1578
1008
  if (!enabled || e.touches.length !== 1) return;
1579
1009
  touchStartXRef.current = e.touches[0].clientX;
1580
1010
  touchStartYRef.current = e.touches[0].clientY;
1581
1011
  }, [enabled]);
1582
- const onTouchEnd = (0, import_react7.useCallback)((e) => {
1012
+ const onTouchEnd = (0, import_react6.useCallback)((e) => {
1583
1013
  if (!enabled || touchStartXRef.current === null || touchStartYRef.current === null) return;
1584
1014
  const touchEndX = e.changedTouches[0].clientX;
1585
1015
  const touchEndY = e.changedTouches[0].clientY;
@@ -1602,7 +1032,8 @@ function useSwipeGesture({ onSwipeLeft, onSwipeRight, enabled = true }) {
1602
1032
  }
1603
1033
 
1604
1034
  // src/components/ImageGalleryLightbox.tsx
1605
- 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"));
1606
1037
  var ImageGalleryLightbox = ({
1607
1038
  items,
1608
1039
  activeIndex = 0,
@@ -1616,20 +1047,20 @@ var ImageGalleryLightbox = ({
1616
1047
  initialAnnotations,
1617
1048
  onAnnotationsChange
1618
1049
  }) => {
1619
- const [currentIndex, setCurrentIndex] = (0, import_react8.useState)(activeIndex);
1620
- const [activeTool, setActiveTool] = (0, import_react8.useState)(initialTool);
1621
- const [color, setColor] = (0, import_react8.useState)(initialColor);
1622
- const [strokeWidth, setStrokeWidth] = (0, import_react8.useState)(4);
1623
- const [isFullscreen, setIsFullscreen] = (0, import_react8.useState)(false);
1624
- (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)(() => {
1625
1056
  setCurrentIndex(activeIndex);
1626
1057
  }, [activeIndex]);
1627
1058
  const currentItem = items[currentIndex] || items[0];
1628
1059
  const slideId = currentItem?.id || currentItem?.src || `slide-${currentIndex}`;
1629
- const storeRef = (0, import_react8.useRef)(new import_core4.AnnotationStore(initialAnnotations));
1630
- const [strokes, setStrokes] = (0, import_react8.useState)([]);
1631
- const [canUndo, setCanUndo] = (0, import_react8.useState)(false);
1632
- 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);
1633
1064
  const {
1634
1065
  transform,
1635
1066
  zoomIn,
@@ -1643,21 +1074,21 @@ var ImageGalleryLightbox = ({
1643
1074
  handleTouchMove,
1644
1075
  handleTouchEnd
1645
1076
  } = useImageTransform();
1646
- (0, import_react8.useEffect)(() => {
1077
+ (0, import_react7.useEffect)(() => {
1647
1078
  resetTransform();
1648
1079
  }, [currentIndex, resetTransform]);
1649
- const imgRef = (0, import_react8.useRef)(null);
1650
- const [imgSize, setImgSize] = (0, import_react8.useState)({ width: 800, height: 600 });
1651
- const [imageStatus, setImageStatus] = (0, import_react8.useState)("loading");
1652
- const [reloadKey, setReloadKey] = (0, import_react8.useState)(0);
1653
- const containerRef = (0, import_react8.useRef)(null);
1654
- 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)(() => {
1655
1086
  if (!currentItem?.src) return "";
1656
1087
  if (reloadKey === 0) return currentItem.src;
1657
1088
  const sep = currentItem.src.includes("?") ? "&" : "?";
1658
1089
  return `${currentItem.src}${sep}_reload=${reloadKey}`;
1659
1090
  }, [currentItem?.src, reloadKey]);
1660
- (0, import_react8.useEffect)(() => {
1091
+ (0, import_react7.useEffect)(() => {
1661
1092
  setImageStatus("loading");
1662
1093
  setReloadKey(0);
1663
1094
  if (imgRef.current && imgRef.current.complete && imgRef.current.naturalWidth > 0) {
@@ -1683,9 +1114,9 @@ var ImageGalleryLightbox = ({
1683
1114
  setImageStatus("loading");
1684
1115
  setReloadKey((prev) => prev + 1);
1685
1116
  };
1686
- const isDraggingRef = (0, import_react8.useRef)(false);
1687
- const lastMousePosRef = (0, import_react8.useRef)({ x: 0, y: 0 });
1688
- (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)(() => {
1689
1120
  const store = storeRef.current;
1690
1121
  const updateStrokes = () => {
1691
1122
  const s = store.getStrokes(slideId);
@@ -1702,14 +1133,14 @@ var ImageGalleryLightbox = ({
1702
1133
  });
1703
1134
  return unsubscribe;
1704
1135
  }, [slideId, onAnnotationsChange]);
1705
- const goToNext = (0, import_react8.useCallback)(() => {
1136
+ const goToNext = (0, import_react7.useCallback)(() => {
1706
1137
  if (currentIndex < items.length - 1) {
1707
1138
  const nextIdx = currentIndex + 1;
1708
1139
  setCurrentIndex(nextIdx);
1709
1140
  onIndexChange?.(nextIdx);
1710
1141
  }
1711
1142
  }, [currentIndex, items.length, onIndexChange]);
1712
- const goToPrev = (0, import_react8.useCallback)(() => {
1143
+ const goToPrev = (0, import_react7.useCallback)(() => {
1713
1144
  if (currentIndex > 0) {
1714
1145
  const prevIdx = currentIndex - 1;
1715
1146
  setCurrentIndex(prevIdx);
@@ -1729,7 +1160,7 @@ var ImageGalleryLightbox = ({
1729
1160
  handleTouchEnd();
1730
1161
  onSwipeTouchEnd(e);
1731
1162
  };
1732
- (0, import_react8.useEffect)(() => {
1163
+ (0, import_react7.useEffect)(() => {
1733
1164
  if (!isOpen) return;
1734
1165
  const handleKeyDown = (e) => {
1735
1166
  if (e.key === "Escape") {
@@ -1775,21 +1206,21 @@ var ImageGalleryLightbox = ({
1775
1206
  const handleStagePointerUp = () => {
1776
1207
  isDraggingRef.current = false;
1777
1208
  };
1778
- const handleStrokeComplete = (0, import_react8.useCallback)(
1209
+ const handleStrokeComplete = (0, import_react7.useCallback)(
1779
1210
  (stroke) => {
1780
1211
  storeRef.current.addStroke(slideId, stroke);
1781
1212
  },
1782
1213
  [slideId]
1783
1214
  );
1784
- const handleEraseStroke = (0, import_react8.useCallback)(
1215
+ const handleEraseStroke = (0, import_react7.useCallback)(
1785
1216
  (pt) => {
1786
1217
  storeRef.current.removeStrokesNear(slideId, pt, 0.03, import_core4.isPointNearStroke);
1787
1218
  },
1788
1219
  [slideId]
1789
1220
  );
1790
- const handleUndo = (0, import_react8.useCallback)(() => storeRef.current.undo(slideId), [slideId]);
1791
- const handleRedo = (0, import_react8.useCallback)(() => storeRef.current.redo(slideId), [slideId]);
1792
- 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]);
1793
1224
  const toggleFullscreen = () => {
1794
1225
  if (!document.fullscreenElement) {
1795
1226
  containerRef.current?.requestFullscreen?.();
@@ -1830,7 +1261,7 @@ var ImageGalleryLightbox = ({
1830
1261
  setTimeout(() => URL.revokeObjectURL(url), 1e3);
1831
1262
  };
1832
1263
  if (!isOpen || !currentItem) return null;
1833
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1264
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1834
1265
  "div",
1835
1266
  {
1836
1267
  ref: containerRef,
@@ -1839,7 +1270,7 @@ var ImageGalleryLightbox = ({
1839
1270
  "aria-modal": "true",
1840
1271
  "aria-label": "Image Lightbox Gallery",
1841
1272
  children: [
1842
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1273
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1843
1274
  ImageToolbar,
1844
1275
  {
1845
1276
  activeTool,
@@ -1861,6 +1292,7 @@ var ImageGalleryLightbox = ({
1861
1292
  onDownloadAnnotated: handleDownloadAnnotated,
1862
1293
  onDownloadClean: handleDownloadClean,
1863
1294
  onExportJson: handleExportJson,
1295
+ theme: theme === "light" ? "light" : "dark",
1864
1296
  onClose,
1865
1297
  isFullscreen,
1866
1298
  onToggleFullscreen: toggleFullscreen,
@@ -1868,7 +1300,7 @@ var ImageGalleryLightbox = ({
1868
1300
  totalImages: items.length
1869
1301
  }
1870
1302
  ),
1871
- currentIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1303
+ currentIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1872
1304
  "button",
1873
1305
  {
1874
1306
  type: "button",
@@ -1876,10 +1308,10 @@ var ImageGalleryLightbox = ({
1876
1308
  onClick: goToPrev,
1877
1309
  title: "Previous Image (Arrow Left)",
1878
1310
  "aria-label": "Previous image",
1879
- 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 })
1880
1312
  }
1881
1313
  ),
1882
- currentIndex < items.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1314
+ currentIndex < items.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1883
1315
  "button",
1884
1316
  {
1885
1317
  type: "button",
@@ -1887,10 +1319,10 @@ var ImageGalleryLightbox = ({
1887
1319
  onClick: goToNext,
1888
1320
  title: "Next Image (Arrow Right)",
1889
1321
  "aria-label": "Next image",
1890
- 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 })
1891
1323
  }
1892
1324
  ),
1893
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1325
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1894
1326
  "div",
1895
1327
  {
1896
1328
  className: "tbib-iv-stage",
@@ -1906,7 +1338,7 @@ var ImageGalleryLightbox = ({
1906
1338
  cursor: activeTool === "hand" ? isDraggingRef.current ? "grabbing" : "grab" : "default"
1907
1339
  },
1908
1340
  children: [
1909
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1341
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1910
1342
  "div",
1911
1343
  {
1912
1344
  className: "tbib-iv-stage-inner",
@@ -1915,7 +1347,7 @@ var ImageGalleryLightbox = ({
1915
1347
  transition: isDraggingRef.current ? "none" : "transform 0.05s ease-out"
1916
1348
  },
1917
1349
  children: [
1918
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1350
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1919
1351
  "img",
1920
1352
  {
1921
1353
  ref: imgRef,
@@ -1928,7 +1360,7 @@ var ImageGalleryLightbox = ({
1928
1360
  },
1929
1361
  `${slideId}-${reloadKey}`
1930
1362
  ),
1931
- imageStatus === "loaded" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1363
+ imageStatus === "loaded" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1932
1364
  AnnotationCanvas,
1933
1365
  {
1934
1366
  width: imgSize.width,
@@ -1947,28 +1379,28 @@ var ImageGalleryLightbox = ({
1947
1379
  ]
1948
1380
  }
1949
1381
  ),
1950
- imageStatus === "loading" && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "tbib-iv-status-overlay", children: [
1951
- /* @__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" }) }),
1952
- /* @__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..." })
1953
1385
  ] }),
1954
- imageStatus === "error" && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "tbib-iv-status-overlay tbib-iv-error-card", children: [
1955
- /* @__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 }) }),
1956
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h3", { className: "tbib-iv-error-title", children: "Impossible de charger l'image" }),
1957
- /* @__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." }),
1958
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "tbib-iv-error-actions", children: [
1959
- /* @__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)(
1960
1392
  "button",
1961
1393
  {
1962
1394
  type: "button",
1963
1395
  className: "tbib-iv-btn tbib-iv-btn-primary tbib-iv-retry-btn",
1964
1396
  onClick: handleReload,
1965
1397
  children: [
1966
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_fontawesome4.FontAwesomeIcon, { icon: import_free_solid_svg_icons4.faRotateRight }),
1967
- /* @__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" })
1968
1400
  ]
1969
1401
  }
1970
1402
  ),
1971
- currentItem?.src && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1403
+ currentItem?.src && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1972
1404
  "a",
1973
1405
  {
1974
1406
  href: currentItem.src,
@@ -1976,18 +1408,18 @@ var ImageGalleryLightbox = ({
1976
1408
  rel: "noopener noreferrer",
1977
1409
  className: "tbib-iv-btn tbib-iv-open-btn",
1978
1410
  children: [
1979
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_fontawesome4.FontAwesomeIcon, { icon: import_faExternalLinkAlt2.faExternalLinkAlt }),
1980
- /* @__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" })
1981
1413
  ]
1982
1414
  }
1983
1415
  )
1984
1416
  ] })
1985
1417
  ] }),
1986
- 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" }) })
1987
1419
  ]
1988
1420
  }
1989
1421
  ),
1990
- showThumbnails && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1422
+ showThumbnails && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1991
1423
  ThumbnailStrip,
1992
1424
  {
1993
1425
  items,
@@ -2003,11 +1435,14 @@ var ImageGalleryLightbox = ({
2003
1435
  );
2004
1436
  };
2005
1437
 
1438
+ // src/components/LaserCursorLayer.tsx
1439
+ var import_laser = require("@tbib-ink/react/laser");
1440
+
2006
1441
  // src/components/ColorPicker.tsx
2007
- var import_react9 = require("react");
2008
- var import_react_fontawesome5 = require("@fortawesome/react-fontawesome");
2009
- var import_free_solid_svg_icons5 = require("@fortawesome/free-solid-svg-icons");
2010
- 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");
2011
1446
  var PRESET_COLORS2 = [
2012
1447
  "#ef4444",
2013
1448
  // Red (Danger / Anatomy landmark)
@@ -2027,9 +1462,9 @@ var PRESET_COLORS2 = [
2027
1462
  // Slate / Black
2028
1463
  ];
2029
1464
  var ColorPicker = ({ color, onChange }) => {
2030
- const [isOpen, setIsOpen] = (0, import_react9.useState)(false);
2031
- const containerRef = (0, import_react9.useRef)(null);
2032
- (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)(() => {
2033
1468
  const handleOutsideClick = (e) => {
2034
1469
  if (containerRef.current && !containerRef.current.contains(e.target)) {
2035
1470
  setIsOpen(false);
@@ -2042,8 +1477,8 @@ var ColorPicker = ({ color, onChange }) => {
2042
1477
  document.removeEventListener("mousedown", handleOutsideClick);
2043
1478
  };
2044
1479
  }, [isOpen]);
2045
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref: containerRef, style: { position: "relative", display: "inline-block" }, children: [
2046
- /* @__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)(
2047
1482
  "button",
2048
1483
  {
2049
1484
  type: "button",
@@ -2051,7 +1486,7 @@ var ColorPicker = ({ color, onChange }) => {
2051
1486
  title: "Annotation Color",
2052
1487
  onClick: () => setIsOpen((prev) => !prev),
2053
1488
  children: [
2054
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1489
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2055
1490
  "span",
2056
1491
  {
2057
1492
  style: {
@@ -2065,11 +1500,11 @@ var ColorPicker = ({ color, onChange }) => {
2065
1500
  }
2066
1501
  }
2067
1502
  ),
2068
- /* @__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 } })
2069
1504
  ]
2070
1505
  }
2071
1506
  ),
2072
- 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)(
2073
1508
  "button",
2074
1509
  {
2075
1510
  type: "button",
@@ -2087,8 +1522,8 @@ var ColorPicker = ({ color, onChange }) => {
2087
1522
  };
2088
1523
 
2089
1524
  // src/components/StrokeWidthPicker.tsx
2090
- var import_react10 = require("react");
2091
- var import_jsx_runtime9 = require("react/jsx-runtime");
1525
+ var import_react9 = require("react");
1526
+ var import_jsx_runtime7 = require("react/jsx-runtime");
2092
1527
  var WIDTH_OPTIONS = [
2093
1528
  { label: "Fine (2px)", value: 2, iconSize: "6px" },
2094
1529
  { label: "Medium (4px)", value: 4, iconSize: "10px" },
@@ -2099,9 +1534,9 @@ var StrokeWidthPicker = ({
2099
1534
  strokeWidth,
2100
1535
  onChange
2101
1536
  }) => {
2102
- const [isOpen, setIsOpen] = (0, import_react10.useState)(false);
2103
- const containerRef = (0, import_react10.useRef)(null);
2104
- (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)(() => {
2105
1540
  const handleOutsideClick = (e) => {
2106
1541
  if (containerRef.current && !containerRef.current.contains(e.target)) {
2107
1542
  setIsOpen(false);
@@ -2115,15 +1550,15 @@ var StrokeWidthPicker = ({
2115
1550
  };
2116
1551
  }, [isOpen]);
2117
1552
  const currentOption = WIDTH_OPTIONS.find((o) => o.value === strokeWidth) || WIDTH_OPTIONS[1];
2118
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { ref: containerRef, style: { position: "relative", display: "inline-block" }, children: [
2119
- /* @__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)(
2120
1555
  "button",
2121
1556
  {
2122
1557
  type: "button",
2123
1558
  className: "tbib-iv-btn",
2124
1559
  title: "Stroke Thickness",
2125
1560
  onClick: () => setIsOpen((prev) => !prev),
2126
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1561
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2127
1562
  "span",
2128
1563
  {
2129
1564
  style: {
@@ -2133,7 +1568,7 @@ var StrokeWidthPicker = ({
2133
1568
  width: "16px",
2134
1569
  height: "16px"
2135
1570
  },
2136
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1571
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2137
1572
  "span",
2138
1573
  {
2139
1574
  style: {
@@ -2148,7 +1583,7 @@ var StrokeWidthPicker = ({
2148
1583
  )
2149
1584
  }
2150
1585
  ),
2151
- isOpen && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1586
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2152
1587
  "div",
2153
1588
  {
2154
1589
  className: "tbib-iv-popover",
@@ -2157,7 +1592,7 @@ var StrokeWidthPicker = ({
2157
1592
  minWidth: "120px",
2158
1593
  padding: "4px"
2159
1594
  },
2160
- children: WIDTH_OPTIONS.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1595
+ children: WIDTH_OPTIONS.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
2161
1596
  "button",
2162
1597
  {
2163
1598
  type: "button",
@@ -2174,7 +1609,7 @@ var StrokeWidthPicker = ({
2174
1609
  setIsOpen(false);
2175
1610
  },
2176
1611
  children: [
2177
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1612
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2178
1613
  "span",
2179
1614
  {
2180
1615
  style: {
@@ -2186,7 +1621,7 @@ var StrokeWidthPicker = ({
2186
1621
  }
2187
1622
  }
2188
1623
  ),
2189
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: opt.label })
1624
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: opt.label })
2190
1625
  ]
2191
1626
  },
2192
1627
  opt.value
@@ -2195,6 +1630,177 @@ var StrokeWidthPicker = ({
2195
1630
  )
2196
1631
  ] });
2197
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
+ };
2198
1804
  // Annotate the CommonJS export names for ESM import in node:
2199
1805
  0 && (module.exports = {
2200
1806
  AnnotationCanvas,