@pixerate/editor-react 0.7.0 → 0.8.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.
@@ -0,0 +1,1200 @@
1
+ // src/image-editor/useImageEditor.ts
2
+ import { useRef, useState, useEffect, useCallback, useMemo } from "react";
3
+ import {
4
+ ImageEditorController
5
+ } from "@pixerate/editor";
6
+ function useImageEditor(options = {}) {
7
+ const controllerRef = useRef(null);
8
+ if (!controllerRef.current) {
9
+ controllerRef.current = new ImageEditorController(options);
10
+ }
11
+ const controller = controllerRef.current;
12
+ const [state, setState] = useState(() => controller.getState());
13
+ const [historyTicks, setHistoryTicks] = useState(0);
14
+ useEffect(() => {
15
+ const unsub = controller.subscribe((next) => {
16
+ setState(next);
17
+ setHistoryTicks((t) => t + 1);
18
+ });
19
+ return unsub;
20
+ }, [controller]);
21
+ useEffect(() => {
22
+ if (options.image && options.image !== state.sourceUrl) {
23
+ controller.loadImage(options.image);
24
+ }
25
+ }, [options.image, controller, state.sourceUrl]);
26
+ const setTool = useCallback((tool) => controller.setTool(tool), [controller]);
27
+ const setCrop = useCallback(
28
+ (crop, addToHistory = true) => controller.setCrop(crop, addToHistory),
29
+ [controller]
30
+ );
31
+ const applyCropPreset = useCallback((ratio) => controller.applyCropPreset(ratio), [controller]);
32
+ const resetCrop = useCallback(() => controller.resetCrop(), [controller]);
33
+ const rotate = useCallback((deg) => controller.rotate(deg), [controller]);
34
+ const setRotation = useCallback((deg) => controller.setRotation(deg), [controller]);
35
+ const flipHorizontal = useCallback(() => controller.flipHorizontal(), [controller]);
36
+ const flipVertical = useCallback(() => controller.flipVertical(), [controller]);
37
+ const setAdjustments = useCallback(
38
+ (partial, commitToHistory = true) => controller.setAdjustments(partial, commitToHistory),
39
+ [controller]
40
+ );
41
+ const resetAdjustments = useCallback(() => controller.resetAdjustments(), [controller]);
42
+ const setDepthMask = useCallback((partial) => controller.setDepthMask(partial), [controller]);
43
+ const resetDepthMask = useCallback(() => controller.resetDepthMask(), [controller]);
44
+ const addAnnotation = useCallback((ann) => controller.addAnnotation(ann), [controller]);
45
+ const updateAnnotation = useCallback(
46
+ (id, partial, commitToHistory = true) => controller.updateAnnotation(id, partial, commitToHistory),
47
+ [controller]
48
+ );
49
+ const removeAnnotation = useCallback((id) => controller.removeAnnotation(id), [controller]);
50
+ const clearAnnotations = useCallback(() => controller.clearAnnotations(), [controller]);
51
+ const selectAnnotation = useCallback((id) => controller.selectAnnotation(id), [controller]);
52
+ const undo = useCallback(() => controller.undo(), [controller]);
53
+ const redo = useCallback(() => controller.redo(), [controller]);
54
+ const reset = useCallback(() => controller.reset(), [controller]);
55
+ const zoomIn = useCallback((factor) => controller.zoomIn(factor), [controller]);
56
+ const zoomOut = useCallback((factor) => controller.zoomOut(factor), [controller]);
57
+ const resetZoom = useCallback(() => controller.resetZoom(), [controller]);
58
+ const setZoom = useCallback((zoom) => controller.setZoom(zoom), [controller]);
59
+ const setPan = useCallback((pan) => controller.setPan(pan), [controller]);
60
+ const setComparing = useCallback((comp) => controller.setComparing(comp), [controller]);
61
+ const loadImage = useCallback((src) => controller.loadImage(src), [controller]);
62
+ const toDataURL = useCallback((opts) => controller.toDataURL(opts), [controller]);
63
+ const toBlob = useCallback((opts) => controller.toBlob(opts), [controller]);
64
+ const toJSON = useCallback(() => controller.toJSON(), [controller]);
65
+ const loadJSON = useCallback((data) => controller.loadJSON(data), [controller]);
66
+ return useMemo(
67
+ () => ({
68
+ controller,
69
+ state,
70
+ canUndo: controller.canUndo,
71
+ canRedo: controller.canRedo,
72
+ setTool,
73
+ setCrop,
74
+ applyCropPreset,
75
+ resetCrop,
76
+ rotate,
77
+ setRotation,
78
+ flipHorizontal,
79
+ flipVertical,
80
+ setAdjustments,
81
+ resetAdjustments,
82
+ setDepthMask,
83
+ resetDepthMask,
84
+ addAnnotation,
85
+ updateAnnotation,
86
+ removeAnnotation,
87
+ clearAnnotations,
88
+ selectAnnotation,
89
+ undo,
90
+ redo,
91
+ reset,
92
+ zoomIn,
93
+ zoomOut,
94
+ resetZoom,
95
+ setZoom,
96
+ setPan,
97
+ setComparing,
98
+ loadImage,
99
+ toDataURL,
100
+ toBlob,
101
+ toJSON,
102
+ loadJSON
103
+ }),
104
+ // eslint-disable-next-line react-hooks/exhaustive-deps
105
+ [controller, state, historyTicks]
106
+ );
107
+ }
108
+
109
+ // src/image-editor/ImageEditor.tsx
110
+ import { useRef as useRef2, useEffect as useEffect2, useState as useState2, useCallback as useCallback2 } from "react";
111
+ import {
112
+ canvasToImagePoint,
113
+ hitTestCrop,
114
+ getCropCursor,
115
+ calculateCropDrag,
116
+ hitTestAnnotation
117
+ } from "@pixerate/editor";
118
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
119
+ var ImageEditor = ({
120
+ editor: externalEditor,
121
+ src,
122
+ className = "",
123
+ style,
124
+ onSave,
125
+ exportOptions
126
+ }) => {
127
+ const internalEditor = useImageEditor({ image: src });
128
+ const editor = externalEditor || internalEditor;
129
+ const { state, controller } = editor;
130
+ const canvasRef = useRef2(null);
131
+ const containerRef = useRef2(null);
132
+ const [activeTab, setActiveTab] = useState2("crop");
133
+ const [activeCropRatio, setActiveCropRatio] = useState2(null);
134
+ const [activeColor, setActiveColor] = useState2("#ef4444");
135
+ const [strokeWidth, setStrokeWidth] = useState2(3);
136
+ const [fontSize, setFontSize] = useState2(24);
137
+ const [textInput, setTextInput] = useState2("");
138
+ const draftAnnotationRef = useRef2(null);
139
+ const draftCropRef = useRef2(null);
140
+ const cropDragInfoRef = useRef2(null);
141
+ const annotationDragInfoRef = useRef2(null);
142
+ const isDrawingRef = useRef2(false);
143
+ const currentPathRef = useRef2([]);
144
+ const dragStartPointRef = useRef2(null);
145
+ const renderCanvas = useCallback2(
146
+ async (draftAnnotation, draftCrop) => {
147
+ const canvas = canvasRef.current;
148
+ const container = containerRef.current;
149
+ if (!canvas || !container) return;
150
+ const vpWidth = container.clientWidth || 800;
151
+ const vpHeight = container.clientHeight || 500;
152
+ await controller.render(canvas, {
153
+ viewportWidth: vpWidth,
154
+ viewportHeight: vpHeight,
155
+ showCropOverlay: activeTab === "crop",
156
+ showSelectionOverlay: true,
157
+ interactive: true,
158
+ draftAnnotation: draftAnnotation !== void 0 ? draftAnnotation : draftAnnotationRef.current,
159
+ draftCrop: draftCrop !== void 0 ? draftCrop : draftCropRef.current
160
+ });
161
+ },
162
+ [controller, activeTab]
163
+ );
164
+ useEffect2(() => {
165
+ const raf = typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : (cb) => setTimeout(cb, 0);
166
+ const caf = typeof cancelAnimationFrame !== "undefined" ? cancelAnimationFrame : (id) => clearTimeout(id);
167
+ const animId = raf(() => {
168
+ renderCanvas();
169
+ });
170
+ return () => caf(animId);
171
+ }, [renderCanvas, state]);
172
+ useEffect2(() => {
173
+ if (activeTab === "crop" && editor.state.activeTool !== "crop") {
174
+ editor.setTool("crop");
175
+ }
176
+ }, [activeTab, editor]);
177
+ useEffect2(() => {
178
+ const container = containerRef.current;
179
+ if (!container) return;
180
+ if (typeof ResizeObserver !== "undefined") {
181
+ const observer = new ResizeObserver(() => {
182
+ renderCanvas();
183
+ });
184
+ observer.observe(container);
185
+ return () => observer.disconnect();
186
+ } else {
187
+ const handleResize = () => renderCanvas();
188
+ window.addEventListener("resize", handleResize);
189
+ return () => window.removeEventListener("resize", handleResize);
190
+ }
191
+ }, [renderCanvas]);
192
+ const getCanvasEventPoint = (e) => {
193
+ const canvas = canvasRef.current;
194
+ if (!canvas) return { x: 0, y: 0 };
195
+ const rect = canvas.getBoundingClientRect();
196
+ const scaleX = rect.width > 0 ? canvas.width / rect.width : 1;
197
+ const scaleY = rect.height > 0 ? canvas.height / rect.height : 1;
198
+ return {
199
+ x: (e.clientX - rect.left) * scaleX,
200
+ y: (e.clientY - rect.top) * scaleY
201
+ };
202
+ };
203
+ const handleMouseDown = (e) => {
204
+ const canvas = canvasRef.current;
205
+ if (!canvas) return;
206
+ const canvasPt = getCanvasEventPoint(e);
207
+ if (activeTab === "crop") {
208
+ const activeCrop = draftCropRef.current || state.crop || {
209
+ x: 0,
210
+ y: 0,
211
+ width: state.imageDimensions.width,
212
+ height: state.imageDimensions.height
213
+ };
214
+ const handle = hitTestCrop(canvasPt, state, canvas.width, canvas.height, 14, activeCrop);
215
+ const startImgPt = canvasToImagePoint(canvasPt, state, canvas.width, canvas.height, true);
216
+ if (handle) {
217
+ cropDragInfoRef.current = {
218
+ handle,
219
+ startCanvasPt: canvasPt,
220
+ startImgPt,
221
+ startCrop: activeCrop
222
+ };
223
+ } else {
224
+ cropDragInfoRef.current = {
225
+ handle: "new",
226
+ startCanvasPt: canvasPt,
227
+ startImgPt,
228
+ startCrop: { x: startImgPt.x, y: startImgPt.y, width: 0, height: 0 }
229
+ };
230
+ }
231
+ return;
232
+ }
233
+ if (activeTab === "annotate") {
234
+ const imgPt = canvasToImagePoint(canvasPt, state, canvas.width, canvas.height, false);
235
+ dragStartPointRef.current = imgPt;
236
+ if (state.activeTool === "select") {
237
+ for (let i = state.annotations.length - 1; i >= 0; i--) {
238
+ const ann = state.annotations[i];
239
+ if (hitTestAnnotation(imgPt, ann)) {
240
+ editor.selectAnnotation(ann.id);
241
+ annotationDragInfoRef.current = {
242
+ annId: ann.id,
243
+ startImgPt: imgPt,
244
+ initialAnn: { ...ann }
245
+ };
246
+ return;
247
+ }
248
+ }
249
+ editor.selectAnnotation(null);
250
+ return;
251
+ }
252
+ if (state.activeTool === "pen") {
253
+ isDrawingRef.current = true;
254
+ currentPathRef.current = [imgPt];
255
+ const draft = {
256
+ id: "draft",
257
+ type: "pen",
258
+ x: 0,
259
+ y: 0,
260
+ points: [imgPt],
261
+ strokeColor: activeColor,
262
+ strokeWidth
263
+ };
264
+ draftAnnotationRef.current = draft;
265
+ renderCanvas(draft);
266
+ }
267
+ }
268
+ };
269
+ const handleMouseMove = (e) => {
270
+ const canvas = canvasRef.current;
271
+ if (!canvas) return;
272
+ const canvasPt = getCanvasEventPoint(e);
273
+ if (activeTab === "crop") {
274
+ const drag = cropDragInfoRef.current;
275
+ if (drag) {
276
+ const currentImgPt = canvasToImagePoint(canvasPt, state, canvas.width, canvas.height, true);
277
+ let newCrop;
278
+ if (drag.handle === "new") {
279
+ const minX = Math.max(0, Math.min(drag.startImgPt.x, currentImgPt.x));
280
+ const minY = Math.max(0, Math.min(drag.startImgPt.y, currentImgPt.y));
281
+ const maxX = Math.min(state.imageDimensions.width, Math.max(drag.startImgPt.x, currentImgPt.x));
282
+ const maxY = Math.min(state.imageDimensions.height, Math.max(drag.startImgPt.y, currentImgPt.y));
283
+ newCrop = {
284
+ x: Math.round(minX),
285
+ y: Math.round(minY),
286
+ width: Math.round(Math.max(20, maxX - minX)),
287
+ height: Math.round(Math.max(20, maxY - minY))
288
+ };
289
+ } else {
290
+ newCrop = calculateCropDrag(
291
+ drag.startCrop,
292
+ drag.handle,
293
+ drag.startImgPt,
294
+ currentImgPt,
295
+ state.imageDimensions.width,
296
+ state.imageDimensions.height,
297
+ activeCropRatio
298
+ );
299
+ }
300
+ draftCropRef.current = newCrop;
301
+ renderCanvas(null, newCrop);
302
+ } else {
303
+ const activeCrop = draftCropRef.current || state.crop || {
304
+ x: 0,
305
+ y: 0,
306
+ width: state.imageDimensions.width,
307
+ height: state.imageDimensions.height
308
+ };
309
+ const handle = hitTestCrop(canvasPt, state, canvas.width, canvas.height, 14, activeCrop);
310
+ canvas.style.cursor = getCropCursor(handle);
311
+ }
312
+ return;
313
+ }
314
+ if (activeTab === "annotate") {
315
+ if (annotationDragInfoRef.current) {
316
+ const drag = annotationDragInfoRef.current;
317
+ const currentImgPt2 = canvasToImagePoint(canvasPt, state, canvas.width, canvas.height, false);
318
+ const dx = currentImgPt2.x - drag.startImgPt.x;
319
+ const dy = currentImgPt2.y - drag.startImgPt.y;
320
+ editor.updateAnnotation(drag.annId, {
321
+ x: Math.round(drag.initialAnn.x + dx),
322
+ y: Math.round(drag.initialAnn.y + dy)
323
+ });
324
+ return;
325
+ }
326
+ const startPt = dragStartPointRef.current;
327
+ if (!startPt) {
328
+ if (state.activeTool === "select") {
329
+ const imgPt = canvasToImagePoint(canvasPt, state, canvas.width, canvas.height, false);
330
+ let hovered = false;
331
+ for (let i = state.annotations.length - 1; i >= 0; i--) {
332
+ if (hitTestAnnotation(imgPt, state.annotations[i])) {
333
+ hovered = true;
334
+ break;
335
+ }
336
+ }
337
+ canvas.style.cursor = hovered ? "move" : "default";
338
+ } else {
339
+ canvas.style.cursor = "crosshair";
340
+ }
341
+ return;
342
+ }
343
+ const currentImgPt = canvasToImagePoint(canvasPt, state, canvas.width, canvas.height, false);
344
+ if (state.activeTool === "pen" && isDrawingRef.current) {
345
+ currentPathRef.current.push(currentImgPt);
346
+ const draft = {
347
+ id: "draft",
348
+ type: "pen",
349
+ x: 0,
350
+ y: 0,
351
+ points: [...currentPathRef.current],
352
+ strokeColor: activeColor,
353
+ strokeWidth
354
+ };
355
+ draftAnnotationRef.current = draft;
356
+ renderCanvas(draft);
357
+ } else if (state.activeTool === "rect") {
358
+ const w = currentImgPt.x - startPt.x;
359
+ const h = currentImgPt.y - startPt.y;
360
+ const draft = {
361
+ id: "draft",
362
+ type: "rect",
363
+ x: Math.min(startPt.x, currentImgPt.x),
364
+ y: Math.min(startPt.y, currentImgPt.y),
365
+ width: Math.abs(w),
366
+ height: Math.abs(h),
367
+ strokeColor: activeColor,
368
+ strokeWidth
369
+ };
370
+ draftAnnotationRef.current = draft;
371
+ renderCanvas(draft);
372
+ } else if (state.activeTool === "circle") {
373
+ const rx = Math.abs(currentImgPt.x - startPt.x) / 2;
374
+ const ry = Math.abs(currentImgPt.y - startPt.y) / 2;
375
+ const draft = {
376
+ id: "draft",
377
+ type: "circle",
378
+ x: Math.min(startPt.x, currentImgPt.x) + rx,
379
+ y: Math.min(startPt.y, currentImgPt.y) + ry,
380
+ radiusX: rx,
381
+ radiusY: ry,
382
+ strokeColor: activeColor,
383
+ strokeWidth
384
+ };
385
+ draftAnnotationRef.current = draft;
386
+ renderCanvas(draft);
387
+ } else if (state.activeTool === "arrow") {
388
+ const draft = {
389
+ id: "draft",
390
+ type: "arrow",
391
+ x: startPt.x,
392
+ y: startPt.y,
393
+ endX: currentImgPt.x,
394
+ endY: currentImgPt.y,
395
+ strokeColor: activeColor,
396
+ strokeWidth
397
+ };
398
+ draftAnnotationRef.current = draft;
399
+ renderCanvas(draft);
400
+ } else if (state.activeTool === "line") {
401
+ const draft = {
402
+ id: "draft",
403
+ type: "line",
404
+ x: startPt.x,
405
+ y: startPt.y,
406
+ endX: currentImgPt.x,
407
+ endY: currentImgPt.y,
408
+ strokeColor: activeColor,
409
+ strokeWidth
410
+ };
411
+ draftAnnotationRef.current = draft;
412
+ renderCanvas(draft);
413
+ }
414
+ }
415
+ };
416
+ const handleMouseUp = (e) => {
417
+ const canvas = canvasRef.current;
418
+ if (!canvas) return;
419
+ const canvasPt = getCanvasEventPoint(e);
420
+ if (activeTab === "crop") {
421
+ if (cropDragInfoRef.current) {
422
+ if (draftCropRef.current && draftCropRef.current.width >= 20 && draftCropRef.current.height >= 20) {
423
+ editor.setCrop(draftCropRef.current, true);
424
+ }
425
+ cropDragInfoRef.current = null;
426
+ draftCropRef.current = null;
427
+ renderCanvas();
428
+ }
429
+ return;
430
+ }
431
+ if (activeTab === "annotate") {
432
+ if (annotationDragInfoRef.current) {
433
+ annotationDragInfoRef.current = null;
434
+ return;
435
+ }
436
+ const startPt = dragStartPointRef.current;
437
+ if (startPt) {
438
+ const currentImgPt = canvasToImagePoint(canvasPt, state, canvas.width, canvas.height, false);
439
+ if (state.activeTool === "pen" && isDrawingRef.current) {
440
+ if (currentPathRef.current.length > 1) {
441
+ editor.addAnnotation({
442
+ type: "pen",
443
+ x: 0,
444
+ y: 0,
445
+ points: [...currentPathRef.current],
446
+ strokeColor: activeColor,
447
+ strokeWidth
448
+ });
449
+ }
450
+ isDrawingRef.current = false;
451
+ currentPathRef.current = [];
452
+ } else if (state.activeTool === "rect") {
453
+ const w = Math.abs(currentImgPt.x - startPt.x);
454
+ const h = Math.abs(currentImgPt.y - startPt.y);
455
+ if (w > 4 && h > 4) {
456
+ editor.addAnnotation({
457
+ type: "rect",
458
+ x: Math.min(startPt.x, currentImgPt.x),
459
+ y: Math.min(startPt.y, currentImgPt.y),
460
+ width: w,
461
+ height: h,
462
+ strokeColor: activeColor,
463
+ strokeWidth
464
+ });
465
+ }
466
+ } else if (state.activeTool === "circle") {
467
+ const rx = Math.abs(currentImgPt.x - startPt.x) / 2;
468
+ const ry = Math.abs(currentImgPt.y - startPt.y) / 2;
469
+ if (rx > 4 && ry > 4) {
470
+ editor.addAnnotation({
471
+ type: "circle",
472
+ x: Math.min(startPt.x, currentImgPt.x) + rx,
473
+ y: Math.min(startPt.y, currentImgPt.y) + ry,
474
+ radiusX: rx,
475
+ radiusY: ry,
476
+ strokeColor: activeColor,
477
+ strokeWidth
478
+ });
479
+ }
480
+ } else if (state.activeTool === "arrow") {
481
+ if (Math.hypot(currentImgPt.x - startPt.x, currentImgPt.y - startPt.y) > 4) {
482
+ editor.addAnnotation({
483
+ type: "arrow",
484
+ x: startPt.x,
485
+ y: startPt.y,
486
+ endX: currentImgPt.x,
487
+ endY: currentImgPt.y,
488
+ strokeColor: activeColor,
489
+ strokeWidth
490
+ });
491
+ }
492
+ } else if (state.activeTool === "line") {
493
+ if (Math.hypot(currentImgPt.x - startPt.x, currentImgPt.y - startPt.y) > 4) {
494
+ editor.addAnnotation({
495
+ type: "line",
496
+ x: startPt.x,
497
+ y: startPt.y,
498
+ endX: currentImgPt.x,
499
+ endY: currentImgPt.y,
500
+ strokeColor: activeColor,
501
+ strokeWidth
502
+ });
503
+ }
504
+ }
505
+ draftAnnotationRef.current = null;
506
+ dragStartPointRef.current = null;
507
+ renderCanvas();
508
+ }
509
+ }
510
+ };
511
+ const handleAddText = () => {
512
+ if (!textInput.trim()) return;
513
+ editor.addAnnotation({
514
+ type: "text",
515
+ x: 50,
516
+ y: 50,
517
+ text: textInput.trim(),
518
+ fontSize,
519
+ color: activeColor
520
+ });
521
+ setTextInput("");
522
+ };
523
+ const handleExport = async () => {
524
+ const dataUrl = await editor.toDataURL(exportOptions);
525
+ if (onSave) {
526
+ onSave(dataUrl);
527
+ } else {
528
+ const link = document.createElement("a");
529
+ link.download = `edited-image-${Date.now()}.png`;
530
+ link.href = dataUrl;
531
+ link.click();
532
+ }
533
+ };
534
+ return /* @__PURE__ */ jsxs(
535
+ "div",
536
+ {
537
+ className: `flex flex-col bg-slate-900 border border-slate-800 rounded-xl overflow-hidden shadow-2xl text-slate-100 ${className}`,
538
+ style,
539
+ children: [
540
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between px-4 py-3 bg-slate-950/80 border-b border-slate-800 gap-3", children: [
541
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 bg-slate-900 p-1 rounded-lg border border-slate-800 text-xs", children: [
542
+ /* @__PURE__ */ jsx(
543
+ "button",
544
+ {
545
+ type: "button",
546
+ onClick: () => {
547
+ setActiveTab("crop");
548
+ editor.setTool("crop");
549
+ },
550
+ className: `px-3 py-1.5 rounded-md font-medium transition-colors ${activeTab === "crop" ? "bg-indigo-600 text-white shadow" : "text-slate-400 hover:text-slate-200"}`,
551
+ children: "Transform & Crop"
552
+ }
553
+ ),
554
+ /* @__PURE__ */ jsx(
555
+ "button",
556
+ {
557
+ type: "button",
558
+ onClick: () => {
559
+ setActiveTab("adjust");
560
+ editor.setTool("select");
561
+ },
562
+ className: `px-3 py-1.5 rounded-md font-medium transition-colors ${activeTab === "adjust" ? "bg-indigo-600 text-white shadow" : "text-slate-400 hover:text-slate-200"}`,
563
+ children: "Adjustments"
564
+ }
565
+ ),
566
+ /* @__PURE__ */ jsx(
567
+ "button",
568
+ {
569
+ type: "button",
570
+ onClick: () => {
571
+ setActiveTab("annotate");
572
+ editor.setTool("pen");
573
+ },
574
+ className: `px-3 py-1.5 rounded-md font-medium transition-colors ${activeTab === "annotate" ? "bg-indigo-600 text-white shadow" : "text-slate-400 hover:text-slate-200"}`,
575
+ children: "Annotations"
576
+ }
577
+ ),
578
+ /* @__PURE__ */ jsx(
579
+ "button",
580
+ {
581
+ type: "button",
582
+ onClick: () => {
583
+ setActiveTab("depth");
584
+ editor.setTool("select");
585
+ },
586
+ className: `px-3 py-1.5 rounded-md font-medium transition-colors ${activeTab === "depth" ? "bg-indigo-600 text-white shadow" : "text-slate-400 hover:text-slate-200"}`,
587
+ children: "Depth Mask"
588
+ }
589
+ )
590
+ ] }),
591
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs", children: [
592
+ /* @__PURE__ */ jsx(
593
+ "button",
594
+ {
595
+ type: "button",
596
+ disabled: !editor.canUndo,
597
+ onClick: () => editor.undo(),
598
+ className: "p-1.5 rounded-lg border border-slate-800 bg-slate-900 text-slate-300 disabled:opacity-40 disabled:cursor-not-allowed hover:bg-slate-800",
599
+ title: "Undo",
600
+ children: "\u21A9"
601
+ }
602
+ ),
603
+ /* @__PURE__ */ jsx(
604
+ "button",
605
+ {
606
+ type: "button",
607
+ disabled: !editor.canRedo,
608
+ onClick: () => editor.redo(),
609
+ className: "p-1.5 rounded-lg border border-slate-800 bg-slate-900 text-slate-300 disabled:opacity-40 disabled:cursor-not-allowed hover:bg-slate-800",
610
+ title: "Redo",
611
+ children: "\u21AA"
612
+ }
613
+ ),
614
+ /* @__PURE__ */ jsx(
615
+ "button",
616
+ {
617
+ type: "button",
618
+ onClick: () => editor.reset(),
619
+ className: "px-2 py-1.5 rounded-lg border border-slate-800 bg-slate-900 text-slate-400 hover:text-slate-200 hover:bg-slate-800",
620
+ children: "Reset"
621
+ }
622
+ ),
623
+ /* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-slate-800 mx-1" }),
624
+ /* @__PURE__ */ jsx(
625
+ "button",
626
+ {
627
+ type: "button",
628
+ onClick: () => editor.zoomOut(),
629
+ className: "p-1.5 rounded-lg border border-slate-800 bg-slate-900 text-slate-300 hover:bg-slate-800",
630
+ title: "Zoom Out",
631
+ children: "-"
632
+ }
633
+ ),
634
+ /* @__PURE__ */ jsxs("span", { className: "font-mono text-slate-400 w-10 text-center", children: [
635
+ Math.round(state.zoom * 100),
636
+ "%"
637
+ ] }),
638
+ /* @__PURE__ */ jsx(
639
+ "button",
640
+ {
641
+ type: "button",
642
+ onClick: () => editor.zoomIn(),
643
+ className: "p-1.5 rounded-lg border border-slate-800 bg-slate-900 text-slate-300 hover:bg-slate-800",
644
+ title: "Zoom In",
645
+ children: "+"
646
+ }
647
+ ),
648
+ /* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-slate-800 mx-1" }),
649
+ /* @__PURE__ */ jsx(
650
+ "button",
651
+ {
652
+ type: "button",
653
+ onMouseDown: () => editor.setComparing(true),
654
+ onMouseUp: () => editor.setComparing(false),
655
+ onMouseLeave: () => editor.setComparing(false),
656
+ className: "px-2.5 py-1.5 rounded-lg border border-slate-800 bg-slate-900 text-amber-400 hover:bg-slate-800 select-none active:bg-amber-950/40",
657
+ children: "Hold Compare"
658
+ }
659
+ ),
660
+ /* @__PURE__ */ jsx(
661
+ "button",
662
+ {
663
+ type: "button",
664
+ onClick: handleExport,
665
+ className: "px-4 py-1.5 rounded-lg bg-emerald-600 hover:bg-emerald-500 text-white font-medium shadow-md shadow-emerald-900/30 transition-colors",
666
+ children: "Export Image"
667
+ }
668
+ )
669
+ ] })
670
+ ] }),
671
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col md:flex-row flex-1 min-h-[520px] md:h-[560px]", children: [
672
+ /* @__PURE__ */ jsx(
673
+ "div",
674
+ {
675
+ ref: containerRef,
676
+ className: "relative flex-1 h-[360px] md:h-full min-h-[320px] bg-slate-950 overflow-hidden select-none",
677
+ children: /* @__PURE__ */ jsx(
678
+ "canvas",
679
+ {
680
+ ref: canvasRef,
681
+ onMouseDown: handleMouseDown,
682
+ onMouseMove: handleMouseMove,
683
+ onMouseUp: handleMouseUp,
684
+ onMouseLeave: handleMouseUp,
685
+ className: "absolute inset-0 w-full h-full block"
686
+ }
687
+ )
688
+ }
689
+ ),
690
+ /* @__PURE__ */ jsxs("div", { className: "w-full md:w-80 bg-slate-900/90 border-t md:border-t-0 md:border-l border-slate-800 p-4 overflow-y-auto h-auto md:h-full md:max-h-[560px]", children: [
691
+ activeTab === "crop" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 text-xs", children: [
692
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Aspect Ratio Presets" }),
693
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 gap-2", children: [
694
+ /* @__PURE__ */ jsx(
695
+ "button",
696
+ {
697
+ type: "button",
698
+ onClick: () => {
699
+ setActiveCropRatio(null);
700
+ editor.applyCropPreset(null);
701
+ },
702
+ className: `px-2.5 py-2 rounded-lg border font-medium ${activeCropRatio === null && state.crop ? "bg-indigo-600 border-indigo-500 text-white" : "bg-slate-800 hover:bg-slate-700 text-slate-200 border-slate-700"}`,
703
+ children: "Freeform"
704
+ }
705
+ ),
706
+ /* @__PURE__ */ jsx(
707
+ "button",
708
+ {
709
+ type: "button",
710
+ onClick: () => {
711
+ setActiveCropRatio(1);
712
+ editor.applyCropPreset(1);
713
+ },
714
+ className: `px-2.5 py-2 rounded-lg border font-medium ${activeCropRatio === 1 ? "bg-indigo-600 border-indigo-500 text-white" : "bg-slate-800 hover:bg-slate-700 text-slate-200 border-slate-700"}`,
715
+ children: "1:1 Square"
716
+ }
717
+ ),
718
+ /* @__PURE__ */ jsx(
719
+ "button",
720
+ {
721
+ type: "button",
722
+ onClick: () => {
723
+ setActiveCropRatio(4 / 3);
724
+ editor.applyCropPreset(4 / 3);
725
+ },
726
+ className: `px-2.5 py-2 rounded-lg border font-medium ${activeCropRatio === 4 / 3 ? "bg-indigo-600 border-indigo-500 text-white" : "bg-slate-800 hover:bg-slate-700 text-slate-200 border-slate-700"}`,
727
+ children: "4:3 Standard"
728
+ }
729
+ ),
730
+ /* @__PURE__ */ jsx(
731
+ "button",
732
+ {
733
+ type: "button",
734
+ onClick: () => {
735
+ setActiveCropRatio(16 / 9);
736
+ editor.applyCropPreset(16 / 9);
737
+ },
738
+ className: `px-2.5 py-2 rounded-lg border font-medium ${activeCropRatio === 16 / 9 ? "bg-indigo-600 border-indigo-500 text-white" : "bg-slate-800 hover:bg-slate-700 text-slate-200 border-slate-700"}`,
739
+ children: "16:9 Wide"
740
+ }
741
+ ),
742
+ /* @__PURE__ */ jsx(
743
+ "button",
744
+ {
745
+ type: "button",
746
+ onClick: () => {
747
+ setActiveCropRatio(3 / 2);
748
+ editor.applyCropPreset(3 / 2);
749
+ },
750
+ className: `px-2.5 py-2 rounded-lg border font-medium ${activeCropRatio === 3 / 2 ? "bg-indigo-600 border-indigo-500 text-white" : "bg-slate-800 hover:bg-slate-700 text-slate-200 border-slate-700"}`,
751
+ children: "3:2 Photo"
752
+ }
753
+ ),
754
+ /* @__PURE__ */ jsx(
755
+ "button",
756
+ {
757
+ type: "button",
758
+ onClick: () => {
759
+ setActiveCropRatio(null);
760
+ editor.resetCrop();
761
+ },
762
+ className: "px-2.5 py-2 rounded-lg bg-rose-950/40 hover:bg-rose-900/60 text-rose-300 border border-rose-800/40 font-medium",
763
+ children: "Clear Crop"
764
+ }
765
+ )
766
+ ] }),
767
+ /* @__PURE__ */ jsx("div", { className: "h-px bg-slate-800 my-1" }),
768
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Orientation & Flips" }),
769
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
770
+ /* @__PURE__ */ jsx(
771
+ "button",
772
+ {
773
+ type: "button",
774
+ onClick: () => editor.rotate(-90),
775
+ className: "px-3 py-2 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-200 border border-slate-700",
776
+ children: "Rotate -90\xB0"
777
+ }
778
+ ),
779
+ /* @__PURE__ */ jsx(
780
+ "button",
781
+ {
782
+ type: "button",
783
+ onClick: () => editor.rotate(90),
784
+ className: "px-3 py-2 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-200 border border-slate-700",
785
+ children: "Rotate +90\xB0"
786
+ }
787
+ ),
788
+ /* @__PURE__ */ jsx(
789
+ "button",
790
+ {
791
+ type: "button",
792
+ onClick: () => editor.flipHorizontal(),
793
+ className: `px-3 py-2 rounded-lg border transition-colors ${state.transform.flipH ? "bg-indigo-600 border-indigo-500 text-white" : "bg-slate-800 border-slate-700 text-slate-200 hover:bg-slate-700"}`,
794
+ children: "Flip Horizontal"
795
+ }
796
+ ),
797
+ /* @__PURE__ */ jsx(
798
+ "button",
799
+ {
800
+ type: "button",
801
+ onClick: () => editor.flipVertical(),
802
+ className: `px-3 py-2 rounded-lg border transition-colors ${state.transform.flipV ? "bg-indigo-600 border-indigo-500 text-white" : "bg-slate-800 border-slate-700 text-slate-200 hover:bg-slate-700"}`,
803
+ children: "Flip Vertical"
804
+ }
805
+ )
806
+ ] })
807
+ ] }),
808
+ activeTab === "adjust" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 text-xs", children: [
809
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
810
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Color Adjustments" }),
811
+ /* @__PURE__ */ jsx(
812
+ "button",
813
+ {
814
+ type: "button",
815
+ onClick: () => editor.resetAdjustments(),
816
+ className: "text-[10px] text-rose-400 hover:underline",
817
+ children: "Reset Sliders"
818
+ }
819
+ )
820
+ ] }),
821
+ /* @__PURE__ */ jsxs("div", { children: [
822
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-slate-400 mb-1", children: [
823
+ /* @__PURE__ */ jsx("span", { children: "Brightness" }),
824
+ /* @__PURE__ */ jsx("span", { className: "font-mono", children: state.adjustments.brightness })
825
+ ] }),
826
+ /* @__PURE__ */ jsx(
827
+ "input",
828
+ {
829
+ type: "range",
830
+ min: "-100",
831
+ max: "100",
832
+ value: state.adjustments.brightness,
833
+ onChange: (e) => editor.setAdjustments({ brightness: Number(e.target.value) }),
834
+ className: "w-full accent-indigo-500"
835
+ }
836
+ )
837
+ ] }),
838
+ /* @__PURE__ */ jsxs("div", { children: [
839
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-slate-400 mb-1", children: [
840
+ /* @__PURE__ */ jsx("span", { children: "Contrast" }),
841
+ /* @__PURE__ */ jsx("span", { className: "font-mono", children: state.adjustments.contrast })
842
+ ] }),
843
+ /* @__PURE__ */ jsx(
844
+ "input",
845
+ {
846
+ type: "range",
847
+ min: "-100",
848
+ max: "100",
849
+ value: state.adjustments.contrast,
850
+ onChange: (e) => editor.setAdjustments({ contrast: Number(e.target.value) }),
851
+ className: "w-full accent-indigo-500"
852
+ }
853
+ )
854
+ ] }),
855
+ /* @__PURE__ */ jsxs("div", { children: [
856
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-slate-400 mb-1", children: [
857
+ /* @__PURE__ */ jsx("span", { children: "Saturation" }),
858
+ /* @__PURE__ */ jsx("span", { className: "font-mono", children: state.adjustments.saturation })
859
+ ] }),
860
+ /* @__PURE__ */ jsx(
861
+ "input",
862
+ {
863
+ type: "range",
864
+ min: "-100",
865
+ max: "100",
866
+ value: state.adjustments.saturation,
867
+ onChange: (e) => editor.setAdjustments({ saturation: Number(e.target.value) }),
868
+ className: "w-full accent-indigo-500"
869
+ }
870
+ )
871
+ ] }),
872
+ /* @__PURE__ */ jsxs("div", { children: [
873
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-slate-400 mb-1", children: [
874
+ /* @__PURE__ */ jsx("span", { children: "Exposure" }),
875
+ /* @__PURE__ */ jsx("span", { className: "font-mono", children: state.adjustments.exposure })
876
+ ] }),
877
+ /* @__PURE__ */ jsx(
878
+ "input",
879
+ {
880
+ type: "range",
881
+ min: "-100",
882
+ max: "100",
883
+ value: state.adjustments.exposure,
884
+ onChange: (e) => editor.setAdjustments({ exposure: Number(e.target.value) }),
885
+ className: "w-full accent-indigo-500"
886
+ }
887
+ )
888
+ ] }),
889
+ /* @__PURE__ */ jsxs("div", { children: [
890
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-slate-400 mb-1", children: [
891
+ /* @__PURE__ */ jsx("span", { children: "Warmth / Temperature" }),
892
+ /* @__PURE__ */ jsx("span", { className: "font-mono", children: state.adjustments.temperature })
893
+ ] }),
894
+ /* @__PURE__ */ jsx(
895
+ "input",
896
+ {
897
+ type: "range",
898
+ min: "-100",
899
+ max: "100",
900
+ value: state.adjustments.temperature,
901
+ onChange: (e) => editor.setAdjustments({ temperature: Number(e.target.value) }),
902
+ className: "w-full accent-indigo-500"
903
+ }
904
+ )
905
+ ] }),
906
+ /* @__PURE__ */ jsxs("div", { children: [
907
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-slate-400 mb-1", children: [
908
+ /* @__PURE__ */ jsx("span", { children: "Blur" }),
909
+ /* @__PURE__ */ jsxs("span", { className: "font-mono", children: [
910
+ state.adjustments.blur,
911
+ "px"
912
+ ] })
913
+ ] }),
914
+ /* @__PURE__ */ jsx(
915
+ "input",
916
+ {
917
+ type: "range",
918
+ min: "0",
919
+ max: "30",
920
+ value: state.adjustments.blur,
921
+ onChange: (e) => editor.setAdjustments({ blur: Number(e.target.value) }),
922
+ className: "w-full accent-indigo-500"
923
+ }
924
+ )
925
+ ] }),
926
+ /* @__PURE__ */ jsxs("div", { children: [
927
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-slate-400 mb-1", children: [
928
+ /* @__PURE__ */ jsx("span", { children: "Opacity" }),
929
+ /* @__PURE__ */ jsxs("span", { className: "font-mono", children: [
930
+ Math.round(state.adjustments.opacity * 100),
931
+ "%"
932
+ ] })
933
+ ] }),
934
+ /* @__PURE__ */ jsx(
935
+ "input",
936
+ {
937
+ type: "range",
938
+ min: "0",
939
+ max: "1",
940
+ step: "0.05",
941
+ value: state.adjustments.opacity,
942
+ onChange: (e) => editor.setAdjustments({ opacity: Number(e.target.value) }),
943
+ className: "w-full accent-indigo-500"
944
+ }
945
+ )
946
+ ] })
947
+ ] }),
948
+ activeTab === "annotate" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 text-xs", children: [
949
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Draw & Annotate" }),
950
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-1.5", children: ["pen", "rect", "circle", "arrow", "line"].map((t) => /* @__PURE__ */ jsx(
951
+ "button",
952
+ {
953
+ type: "button",
954
+ onClick: () => editor.setTool(t),
955
+ className: `py-1.5 px-2 rounded-lg font-medium capitalize border transition-colors ${state.activeTool === t ? "bg-indigo-600 border-indigo-500 text-white" : "bg-slate-800 border-slate-700 text-slate-300 hover:bg-slate-700"}`,
956
+ children: t
957
+ },
958
+ t
959
+ )) }),
960
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mt-2", children: [
961
+ /* @__PURE__ */ jsx("label", { className: "text-slate-400", children: "Color:" }),
962
+ /* @__PURE__ */ jsx(
963
+ "input",
964
+ {
965
+ type: "color",
966
+ value: activeColor,
967
+ onChange: (e) => setActiveColor(e.target.value),
968
+ className: "w-8 h-8 rounded border border-slate-700 cursor-pointer bg-transparent"
969
+ }
970
+ ),
971
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 ml-2", children: [
972
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-slate-400 mb-0.5", children: [
973
+ /* @__PURE__ */ jsx("span", { children: "Width:" }),
974
+ /* @__PURE__ */ jsxs("span", { className: "font-mono", children: [
975
+ strokeWidth,
976
+ "px"
977
+ ] })
978
+ ] }),
979
+ /* @__PURE__ */ jsx(
980
+ "input",
981
+ {
982
+ type: "range",
983
+ min: "1",
984
+ max: "20",
985
+ value: strokeWidth,
986
+ onChange: (e) => setStrokeWidth(Number(e.target.value)),
987
+ className: "w-full accent-indigo-500"
988
+ }
989
+ )
990
+ ] })
991
+ ] }),
992
+ /* @__PURE__ */ jsx("div", { className: "h-px bg-slate-800 my-1" }),
993
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Add Text" }),
994
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
995
+ /* @__PURE__ */ jsx(
996
+ "input",
997
+ {
998
+ type: "text",
999
+ placeholder: "Type watermark or label...",
1000
+ value: textInput,
1001
+ onChange: (e) => setTextInput(e.target.value),
1002
+ onKeyDown: (e) => e.key === "Enter" && handleAddText(),
1003
+ className: "flex-1 bg-slate-950 border border-slate-700 rounded-lg px-2.5 py-1.5 text-xs text-slate-100 placeholder-slate-500 focus:outline-none focus:border-indigo-500"
1004
+ }
1005
+ ),
1006
+ /* @__PURE__ */ jsx(
1007
+ "button",
1008
+ {
1009
+ type: "button",
1010
+ onClick: handleAddText,
1011
+ className: "px-3 py-1.5 rounded-lg bg-indigo-600 hover:bg-indigo-500 text-white font-medium shadow",
1012
+ children: "Add"
1013
+ }
1014
+ )
1015
+ ] }),
1016
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between text-slate-400", children: [
1017
+ /* @__PURE__ */ jsx("span", { children: "Font Size:" }),
1018
+ /* @__PURE__ */ jsxs("span", { className: "font-mono", children: [
1019
+ fontSize,
1020
+ "px"
1021
+ ] })
1022
+ ] }),
1023
+ /* @__PURE__ */ jsx(
1024
+ "input",
1025
+ {
1026
+ type: "range",
1027
+ min: "12",
1028
+ max: "72",
1029
+ value: fontSize,
1030
+ onChange: (e) => setFontSize(Number(e.target.value)),
1031
+ className: "w-full accent-indigo-500"
1032
+ }
1033
+ ),
1034
+ /* @__PURE__ */ jsx("div", { className: "h-px bg-slate-800 my-1" }),
1035
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
1036
+ /* @__PURE__ */ jsxs("span", { className: "text-slate-400", children: [
1037
+ "Layers (",
1038
+ state.annotations.length,
1039
+ ")"
1040
+ ] }),
1041
+ state.selectedAnnotationId && /* @__PURE__ */ jsx(
1042
+ "button",
1043
+ {
1044
+ type: "button",
1045
+ onClick: () => editor.removeAnnotation(state.selectedAnnotationId),
1046
+ className: "text-rose-400 hover:underline text-[11px]",
1047
+ children: "Delete Selected"
1048
+ }
1049
+ ),
1050
+ state.annotations.length > 0 && /* @__PURE__ */ jsx(
1051
+ "button",
1052
+ {
1053
+ type: "button",
1054
+ onClick: () => editor.clearAnnotations(),
1055
+ className: "text-slate-400 hover:text-slate-200 text-[11px]",
1056
+ children: "Clear All"
1057
+ }
1058
+ )
1059
+ ] })
1060
+ ] }),
1061
+ activeTab === "depth" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 text-xs", children: [
1062
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
1063
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-slate-200 uppercase tracking-wider text-[11px]", children: "Depth Masking" }),
1064
+ /* @__PURE__ */ jsx(
1065
+ "button",
1066
+ {
1067
+ type: "button",
1068
+ onClick: () => editor.resetDepthMask(),
1069
+ className: "text-[10px] text-rose-400 hover:underline",
1070
+ children: "Reset Mask"
1071
+ }
1072
+ )
1073
+ ] }),
1074
+ /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 cursor-pointer text-slate-300", children: [
1075
+ /* @__PURE__ */ jsx(
1076
+ "input",
1077
+ {
1078
+ type: "checkbox",
1079
+ checked: state.depthMask.enabled,
1080
+ onChange: (e) => editor.setDepthMask({ enabled: e.target.checked }),
1081
+ className: "rounded accent-indigo-500"
1082
+ }
1083
+ ),
1084
+ /* @__PURE__ */ jsx("span", { children: "Enable Depth / Alpha Mask" })
1085
+ ] }),
1086
+ state.depthMask.enabled && /* @__PURE__ */ jsxs(Fragment, { children: [
1087
+ /* @__PURE__ */ jsxs("div", { children: [
1088
+ /* @__PURE__ */ jsx("label", { className: "text-slate-400 block mb-1", children: "Mask Image URL:" }),
1089
+ /* @__PURE__ */ jsx(
1090
+ "input",
1091
+ {
1092
+ type: "text",
1093
+ placeholder: "https://.../depthmap.png",
1094
+ value: state.depthMask.maskSource || "",
1095
+ onChange: (e) => editor.setDepthMask({ maskSource: e.target.value || null }),
1096
+ className: "w-full bg-slate-950 border border-slate-700 rounded-lg px-2.5 py-1.5 text-xs text-slate-100 placeholder-slate-500"
1097
+ }
1098
+ )
1099
+ ] }),
1100
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
1101
+ /* @__PURE__ */ jsx(
1102
+ "button",
1103
+ {
1104
+ type: "button",
1105
+ onClick: () => editor.setDepthMask({ mode: "threshold" }),
1106
+ className: `flex-1 py-1.5 rounded-lg border text-xs font-medium ${state.depthMask.mode === "threshold" ? "bg-indigo-600 border-indigo-500 text-white" : "bg-slate-800 border-slate-700 text-slate-300"}`,
1107
+ children: "Threshold Mode"
1108
+ }
1109
+ ),
1110
+ /* @__PURE__ */ jsx(
1111
+ "button",
1112
+ {
1113
+ type: "button",
1114
+ onClick: () => editor.setDepthMask({ mode: "brightness" }),
1115
+ className: `flex-1 py-1.5 rounded-lg border text-xs font-medium ${state.depthMask.mode === "brightness" ? "bg-indigo-600 border-indigo-500 text-white" : "bg-slate-800 border-slate-700 text-slate-300"}`,
1116
+ children: "Brightness Mode"
1117
+ }
1118
+ )
1119
+ ] }),
1120
+ /* @__PURE__ */ jsxs("div", { children: [
1121
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-slate-400 mb-1", children: [
1122
+ /* @__PURE__ */ jsx("span", { children: "Depth Start (Lower):" }),
1123
+ /* @__PURE__ */ jsx("span", { className: "font-mono", children: state.depthMask.depthRange[0] })
1124
+ ] }),
1125
+ /* @__PURE__ */ jsx(
1126
+ "input",
1127
+ {
1128
+ type: "range",
1129
+ min: "0",
1130
+ max: "255",
1131
+ value: state.depthMask.depthRange[0],
1132
+ onChange: (e) => editor.setDepthMask({
1133
+ depthRange: [Number(e.target.value), state.depthMask.depthRange[1]]
1134
+ }),
1135
+ className: "w-full accent-indigo-500"
1136
+ }
1137
+ )
1138
+ ] }),
1139
+ /* @__PURE__ */ jsxs("div", { children: [
1140
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-slate-400 mb-1", children: [
1141
+ /* @__PURE__ */ jsx("span", { children: "Depth Stop (Upper):" }),
1142
+ /* @__PURE__ */ jsx("span", { className: "font-mono", children: state.depthMask.depthRange[1] })
1143
+ ] }),
1144
+ /* @__PURE__ */ jsx(
1145
+ "input",
1146
+ {
1147
+ type: "range",
1148
+ min: "0",
1149
+ max: "255",
1150
+ value: state.depthMask.depthRange[1],
1151
+ onChange: (e) => editor.setDepthMask({
1152
+ depthRange: [state.depthMask.depthRange[0], Number(e.target.value)]
1153
+ }),
1154
+ className: "w-full accent-indigo-500"
1155
+ }
1156
+ )
1157
+ ] }),
1158
+ /* @__PURE__ */ jsxs("div", { children: [
1159
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between text-slate-400 mb-1", children: [
1160
+ /* @__PURE__ */ jsx("span", { children: "Softness:" }),
1161
+ /* @__PURE__ */ jsx("span", { className: "font-mono", children: state.depthMask.softness })
1162
+ ] }),
1163
+ /* @__PURE__ */ jsx(
1164
+ "input",
1165
+ {
1166
+ type: "range",
1167
+ min: "1",
1168
+ max: "50",
1169
+ value: state.depthMask.softness,
1170
+ onChange: (e) => editor.setDepthMask({ softness: Number(e.target.value) }),
1171
+ className: "w-full accent-indigo-500"
1172
+ }
1173
+ )
1174
+ ] }),
1175
+ /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 cursor-pointer text-slate-300 mt-1", children: [
1176
+ /* @__PURE__ */ jsx(
1177
+ "input",
1178
+ {
1179
+ type: "checkbox",
1180
+ checked: state.depthMask.invert,
1181
+ onChange: (e) => editor.setDepthMask({ invert: e.target.checked }),
1182
+ className: "rounded accent-indigo-500"
1183
+ }
1184
+ ),
1185
+ /* @__PURE__ */ jsx("span", { children: "Invert Mask" })
1186
+ ] })
1187
+ ] })
1188
+ ] })
1189
+ ] })
1190
+ ] })
1191
+ ]
1192
+ }
1193
+ );
1194
+ };
1195
+
1196
+ export {
1197
+ useImageEditor,
1198
+ ImageEditor
1199
+ };
1200
+ //# sourceMappingURL=chunk-NKQKD43U.js.map