pushfeedback 0.1.69 → 0.1.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/components/canvas-editor.d.ts +11 -0
  2. package/dist/components/index.d.ts +1 -0
  3. package/dist/pushfeedback/app-globals-0f993ce5.js +3 -0
  4. package/dist/pushfeedback/canvas-editor.entry.js +860 -0
  5. package/dist/pushfeedback/css-shim-b7d3d95f.js +4 -0
  6. package/dist/pushfeedback/dom-64053c71.js +73 -0
  7. package/dist/{components/feedback-button.js → pushfeedback/feedback-button.entry.js} +30 -73
  8. package/dist/pushfeedback/feedback-modal.entry.js +295 -0
  9. package/dist/pushfeedback/index-36434da0.js +3371 -0
  10. package/dist/pushfeedback/index.esm.js +1 -0
  11. package/dist/pushfeedback/pushfeedback.css +146 -1
  12. package/dist/pushfeedback/pushfeedback.esm.js +148 -1
  13. package/dist/pushfeedback/shadow-css-98135883.js +387 -0
  14. package/dist/types/components/canvas-editor/canvas-editor.d.ts +108 -0
  15. package/dist/types/components/feedback-button/feedback-button.d.ts +11 -0
  16. package/dist/types/components/feedback-modal/feedback-modal.d.ts +22 -79
  17. package/dist/types/components.d.ts +102 -0
  18. package/package.json +3 -4
  19. package/dist/cjs/feedback-button_2.cjs.entry.js +0 -1202
  20. package/dist/cjs/index-9a8f4784.js +0 -1584
  21. package/dist/cjs/index.cjs.js +0 -2
  22. package/dist/cjs/loader.cjs.js +0 -22
  23. package/dist/cjs/pushfeedback.cjs.js +0 -23
  24. package/dist/collection/collection-manifest.json +0 -13
  25. package/dist/collection/components/feedback-button/feedback-button.css +0 -81
  26. package/dist/collection/components/feedback-button/feedback-button.js +0 -949
  27. package/dist/collection/components/feedback-modal/feedback-modal.css +0 -1003
  28. package/dist/collection/components/feedback-modal/feedback-modal.js +0 -1792
  29. package/dist/collection/index.js +0 -1
  30. package/dist/components/feedback-modal.js +0 -6
  31. package/dist/components/feedback-modal2.js +0 -1101
  32. package/dist/components/index.js +0 -3
  33. package/dist/esm/feedback-button_2.entry.js +0 -1197
  34. package/dist/esm/index-f65e9124.js +0 -1555
  35. package/dist/esm/index.js +0 -1
  36. package/dist/esm/loader.js +0 -18
  37. package/dist/esm/polyfills/core-js.js +0 -11
  38. package/dist/esm/polyfills/css-shim.js +0 -1
  39. package/dist/esm/polyfills/dom.js +0 -79
  40. package/dist/esm/polyfills/es5-html-element.js +0 -1
  41. package/dist/esm/polyfills/index.js +0 -34
  42. package/dist/esm/polyfills/system.js +0 -6
  43. package/dist/esm/pushfeedback.js +0 -18
  44. package/dist/index.cjs.js +0 -1
  45. package/dist/index.js +0 -1
  46. package/dist/pushfeedback/p-af2a1f7f.js +0 -2
  47. package/dist/pushfeedback/p-e7f48090.entry.js +0 -1
@@ -0,0 +1,860 @@
1
+ import { r as registerInstance, e as createEvent, h } from './index-36434da0.js';
2
+
3
+ const canvasEditorCss = ":host{display:block}.canvas-editor-wrapper{position:relative}.canvas-editor-overlay{position:fixed;top:0;left:0;width:100vw;height:100vh;background:rgba(0, 0, 0, 0.8);display:flex;align-items:center;justify-content:center;z-index:9999}.canvas-editor-modal{width:95vw;max-width:1400px;max-height:900px;background:var(--feedback-canvas-editor-bg-color, #ffffff);border-radius:8px;border:1px solid var(--feedback-canvas-editor-border-color, #e0e0e0);display:flex;flex-direction:column;overflow:hidden;box-shadow:0 10px 40px rgba(0, 0, 0, 0.2)}.canvas-editor-header{background:var(--feedback-canvas-editor-header-bg-color, #f5f5f5);border-bottom:1px solid var(--feedback-canvas-editor-border-color, #e0e0e0);padding:12px 16px;display:flex;flex-direction:column;gap:12px}.canvas-editor-title h3{margin:0;font-size:16px;font-weight:600;color:var(--feedback-canvas-editor-tool-text-color, #333)}.canvas-editor-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:16px}.toolbar-section{display:flex;align-items:center;gap:8px}.tool-group{display:flex;align-items:center;gap:4px}.tool-btn{width:36px;height:36px;display:flex;align-items:center;justify-content:center;background:var(--feedback-canvas-editor-tool-bg-color, #ffffff);border:1px solid var(--feedback-canvas-editor-border-color, #e0e0e0);border-radius:6px;cursor:pointer;transition:all 0.2s ease;padding:0}.tool-btn svg{width:18px;height:18px;color:var(--feedback-canvas-editor-tool-text-color, #333)}.tool-btn:hover:not(:disabled){background:var(--feedback-canvas-editor-tool-bg-hover, #f0f0f0)}.tool-btn.active,.tool-btn.active:hover{background:var(--feedback-canvas-editor-tool-bg-active, #0070f4);color:var(--feedback-canvas-editor-tool-text-active, #ffffff)}.tool-btn.active svg{color:var(--feedback-canvas-editor-tool-text-active, #ffffff)}.tool-btn:disabled{opacity:0.4;cursor:not-allowed;color:var(--feedback-canvas-editor-tool-text-color, #333)}.toolbar-divider{width:1px;height:24px;background:var(--feedback-canvas-editor-divider-color, #e0e0e0);margin:0 4px}.undo-btn{background:var(--feedback-canvas-editor-tool-bg-color, #ffffff) !important;border:1px solid var(--feedback-canvas-editor-border-color, #e0e0e0) !important}.undo-btn:hover:not(:disabled){background:var(--feedback-canvas-editor-tool-bg-hover, #f0f0f0) !important}.color-palette{display:flex;align-items:center;gap:6px}.color-slot-wrapper{position:relative;display:flex;align-items:center}.color-btn{width:32px;height:32px;border-radius:6px;border:2px solid transparent;cursor:pointer;transition:all 0.2s ease;display:flex;align-items:center;justify-content:center;background:var(--feedback-canvas-editor-tool-bg-color, #ffffff);border:1px solid var(--feedback-canvas-editor-border-color, #e0e0e0)}.color-btn:hover{transform:scale(1.1)}.color-btn.active{border-color:var(--feedback-primary-color, #0070f4);box-shadow:0 0 0 2px rgba(0, 112, 244, 0.2)}.color-btn.editing{border-color:var(--feedback-primary-color, #0070f4)}.color-picker-dropdown{position:absolute;top:100%;left:0;z-index:1000;margin-top:4px;background:var(--feedback-canvas-editor-tool-bg-color, #ffffff);border:1px solid var(--feedback-canvas-editor-border-color, #e0e0e0);border-radius:6px;padding:8px;box-shadow:0 4px 12px rgba(0, 0, 0, 0.1)}.color-picker-dropdown input[type=\"color\"]{width:40px;height:40px;border:none;border-radius:4px;cursor:pointer}.size-control{display:flex;align-items:center;gap:8px;background:var(--feedback-canvas-editor-tool-bg-color, #ffffff);border:1px solid var(--feedback-canvas-editor-border-color, #e0e0e0);border-radius:6px;padding:6px 12px}.size-slider{width:80px;height:20px;-webkit-appearance:none;appearance:none;background:transparent;cursor:pointer}.size-slider::-webkit-slider-track{width:100%;height:4px;background:var(--feedback-canvas-editor-slider-track, #e0e0e0);border-radius:2px}.size-slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;background:var(--feedback-primary-color, #0070f4);border-radius:50%;cursor:pointer}.size-slider::-moz-range-track{width:100%;height:4px;background:var(--feedback-canvas-editor-slider-track, #e0e0e0);border-radius:2px;border:none}.size-slider::-moz-range-thumb{width:16px;height:16px;background:var(--feedback-primary-color, #0070f4);border-radius:50%;border:none;cursor:pointer}.size-slider::-ms-track{width:100%;height:4px;background:var(--feedback-canvas-editor-slider-track, #e0e0e0);border-radius:2px;border:none;color:transparent}.size-slider::-ms-thumb{width:16px;height:16px;background:var(--feedback-primary-color, #0070f4);border-radius:50%;border:none;cursor:pointer}.size-value{font-weight:500;color:var(--feedback-canvas-editor-tool-text-color, #333);font-size:12px;min-width:30px}.selected-annotation-controls{border-left:2px solid var(--feedback-canvas-editor-divider-color, #e0e0e0);padding-left:12px;margin-left:8px;min-width:200px}.text-controls{display:flex;flex-direction:row;align-items:center;gap:12px}.font-size-control,.border-width-control{display:flex;align-items:center;gap:6px}.font-size-control label,.border-width-control label{font-size:12px;color:var(--feedback-canvas-editor-tool-text-color, #333);font-weight:500;min-width:35px}.action-btn{display:flex;align-items:center;gap:6px;padding:5px 12px;border:1px solid var(--feedback-canvas-editor-border-color, #e0e0e0);border-radius:6px;cursor:pointer;font-size:12px;font-weight:500;transition:all 0.2s ease;min-width:65px;justify-content:center;height:36px}.action-btn.secondary{background:var(--feedback-canvas-editor-tool-bg-color, #ffffff);color:var(--feedback-canvas-editor-tool-text-color, #333);border-color:var(--feedback-canvas-editor-border-color, #e0e0e0)}.action-btn.secondary:hover{background:var(--feedback-canvas-editor-tool-bg-hover, #f0f0f0)}.action-btn.primary{background:var(--feedback-primary-color, #0070f4);color:#ffffff;border-color:var(--feedback-primary-color, #0070f4)}.action-btn.primary:hover{background:#0056cc;border-color:#0056cc}.action-btn.small{height:28px;padding:4px 8px;font-size:12px;min-width:65px}.shape-controls{display:flex;flex-direction:column;gap:8px}.canvas-editor-content{flex:1;display:flex;align-items:center;justify-content:center;padding:16px;background:var(--feedback-canvas-editor-content-bg, #f5f5f5);overflow:hidden;min-height:0;min-width:0}.annotation-canvas{max-width:100%;max-height:100%;width:auto;height:auto;cursor:crosshair;border-radius:6px;box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .30), 0px 2px 6px 2px rgba(60, 64, 67, .15);background:#ffffff;transition:box-shadow 0.3s ease;object-fit:contain;display:block}.annotation-canvas:hover{box-shadow:0px 2px 4px 0px rgba(60, 64, 67, .35), 0px 4px 12px 4px rgba(60, 64, 67, .20)}@media screen and (max-width: 768px){.canvas-editor-modal{width:100vw;height:100vh;border-radius:0}.canvas-editor-toolbar{flex-direction:column;align-items:stretch;gap:8px}.toolbar-section{justify-content:center}.selected-annotation-controls{border-left:none;border-top:2px solid var(--feedback-canvas-editor-divider-color, #e0e0e0);padding-left:0;padding-top:8px;margin-left:0;margin-top:8px;min-width:auto}}";
4
+
5
+ const CanvasEditor = class {
6
+ constructor(hostRef) {
7
+ registerInstance(this, hostRef);
8
+ this.screenshotReady = createEvent(this, "screenshotReady", 7);
9
+ this.screenshotCancelled = createEvent(this, "screenshotCancelled", 7);
10
+ this.screenshotFailed = createEvent(this, "screenshotFailed", 7);
11
+ this.openScreenShot = async () => {
12
+ // Show loading state immediately
13
+ this.takingScreenshot = true;
14
+ // Clear any previous annotations when taking a new screenshot
15
+ this.annotations = [];
16
+ this.currentAnnotation = null;
17
+ this.isDrawing = false;
18
+ this.hoveredAnnotation = null;
19
+ // Hide any feedback buttons on the page
20
+ this.hideAllFeedbackElements();
21
+ try {
22
+ // Wait a moment for UI to update before capturing
23
+ await new Promise(resolve => setTimeout(resolve, 100));
24
+ // Capture viewport screenshot using browser API
25
+ const dataUrl = await this.captureViewportScreenshot();
26
+ this.originalImageData = dataUrl;
27
+ // Reset loading state
28
+ this.takingScreenshot = false;
29
+ // Go directly to canvas editor
30
+ this.showCanvasEditor = true;
31
+ // Restore feedback elements visibility
32
+ this.showAllFeedbackElements();
33
+ // Initialize canvas after a short delay to ensure DOM is ready
34
+ setTimeout(() => {
35
+ this.initializeCanvas();
36
+ }, 100);
37
+ }
38
+ catch (error) {
39
+ console.error('Failed to capture screenshot:', error);
40
+ // Reset loading state on error
41
+ this.takingScreenshot = false;
42
+ // Restore feedback elements on error
43
+ this.showAllFeedbackElements();
44
+ // Show error message to user
45
+ this.handleScreenshotError(error);
46
+ }
47
+ };
48
+ this.hideAllFeedbackElements = () => {
49
+ // Hide all feedback buttons and modals on the page
50
+ const feedbackElements = document.querySelectorAll('feedback-button, feedback-modal');
51
+ feedbackElements.forEach(element => {
52
+ element.style.visibility = 'hidden';
53
+ });
54
+ };
55
+ this.showAllFeedbackElements = () => {
56
+ // Show all feedback buttons and modals on the page
57
+ const feedbackElements = document.querySelectorAll('feedback-button, feedback-modal');
58
+ feedbackElements.forEach(element => {
59
+ element.style.visibility = 'visible';
60
+ });
61
+ };
62
+ this.handleScreenshotError = (error) => {
63
+ let errorMessage = this.screenshotErrorGeneral;
64
+ if (error.name === 'NotAllowedError') {
65
+ errorMessage += ' ' + this.screenshotErrorPermission;
66
+ }
67
+ else if (error.name === 'NotSupportedError') {
68
+ errorMessage += ' ' + this.screenshotErrorNotSupported;
69
+ }
70
+ else if (error.name === 'NotFoundError') {
71
+ errorMessage += ' ' + this.screenshotErrorNotFound;
72
+ }
73
+ else if (error.name === 'AbortError') {
74
+ errorMessage += ' ' + this.screenshotErrorCancelled;
75
+ }
76
+ else if (error.message && error.message.includes('not supported')) {
77
+ errorMessage += ' ' + this.screenshotErrorBrowserNotSupported;
78
+ }
79
+ else {
80
+ errorMessage += ' ' + this.screenshotErrorUnexpected;
81
+ }
82
+ // Just emit the error to parent - don't show internal notification
83
+ this.screenshotFailed.emit({ error: errorMessage });
84
+ };
85
+ this.closeCanvasEditor = () => {
86
+ this.showCanvasEditor = false;
87
+ this.screenshotCancelled.emit();
88
+ };
89
+ this.saveAnnotations = () => {
90
+ if (this.canvasRef) {
91
+ // Create final image with annotations
92
+ const finalDataUrl = this.canvasRef.toDataURL('image/png');
93
+ this.screenshotReady.emit({ screenshot: finalDataUrl });
94
+ }
95
+ this.showCanvasEditor = false;
96
+ };
97
+ this.initializeCanvas = () => {
98
+ if (!this.canvasRef || !this.originalImageData)
99
+ return;
100
+ this.canvasContext = this.canvasRef.getContext('2d');
101
+ const img = new Image();
102
+ img.onload = () => {
103
+ // Set canvas to original image dimensions
104
+ this.canvasRef.width = img.width;
105
+ this.canvasRef.height = img.height;
106
+ // Get available container dimensions
107
+ const containerWidth = this.canvasRef.parentElement.clientWidth - 32;
108
+ const containerHeight = this.canvasRef.parentElement.clientHeight - 32;
109
+ // Calculate scale factors for both dimensions
110
+ const scaleX = containerWidth / img.width;
111
+ const scaleY = containerHeight / img.height;
112
+ // Use the smaller scale to ensure complete image fits
113
+ const scale = Math.min(scaleX, scaleY, 1);
114
+ // Calculate final display dimensions
115
+ const displayWidth = img.width * scale;
116
+ const displayHeight = img.height * scale;
117
+ // Set CSS size for display
118
+ this.canvasRef.style.width = `${displayWidth}px`;
119
+ this.canvasRef.style.height = `${displayHeight}px`;
120
+ // Draw the original image at full resolution
121
+ this.canvasContext.drawImage(img, 0, 0);
122
+ // Redraw existing annotations
123
+ this.redrawAnnotations();
124
+ };
125
+ img.src = this.originalImageData;
126
+ };
127
+ this.redrawAnnotations = () => {
128
+ if (!this.canvasContext)
129
+ return;
130
+ // Clear and redraw background image
131
+ const img = new Image();
132
+ img.onload = () => {
133
+ this.canvasContext.clearRect(0, 0, this.canvasRef.width, this.canvasRef.height);
134
+ this.canvasContext.drawImage(img, 0, 0);
135
+ // Draw all annotations
136
+ this.annotations.forEach(annotation => {
137
+ this.drawAnnotation(annotation);
138
+ });
139
+ };
140
+ img.src = this.originalImageData;
141
+ };
142
+ this.drawAnnotation = (annotation) => {
143
+ if (!this.canvasContext)
144
+ return;
145
+ this.canvasContext.strokeStyle = annotation.color;
146
+ this.canvasContext.lineWidth = annotation.lineWidth;
147
+ this.canvasContext.lineCap = 'round';
148
+ this.canvasContext.lineJoin = 'round';
149
+ switch (annotation.type) {
150
+ case 'rectangle':
151
+ this.canvasContext.strokeRect(annotation.startX, annotation.startY, annotation.width, annotation.height);
152
+ // Draw selection indicator if this annotation is selected
153
+ if (this.selectedAnnotation === annotation) {
154
+ this.drawSelectionIndicator(annotation);
155
+ }
156
+ // Draw resize handles if this annotation is hovered
157
+ if (this.hoveredAnnotation === annotation) {
158
+ this.drawRectangleResizeHandles(annotation);
159
+ }
160
+ break;
161
+ case 'line':
162
+ this.canvasContext.beginPath();
163
+ this.canvasContext.moveTo(annotation.startX, annotation.startY);
164
+ this.canvasContext.lineTo(annotation.endX, annotation.endY);
165
+ this.canvasContext.stroke();
166
+ // Draw selection indicator if this annotation is selected
167
+ if (this.selectedAnnotation === annotation) {
168
+ this.drawSelectionIndicator(annotation);
169
+ }
170
+ // Draw resize handles if this annotation is hovered
171
+ if (this.hoveredAnnotation === annotation) {
172
+ this.drawLineResizeHandles(annotation);
173
+ }
174
+ break;
175
+ case 'arrow':
176
+ this.drawArrow(annotation.startX, annotation.startY, annotation.endX, annotation.endY);
177
+ // Draw selection indicator if this annotation is selected
178
+ if (this.selectedAnnotation === annotation) {
179
+ this.drawSelectionIndicator(annotation);
180
+ }
181
+ // Draw resize handles if this annotation is hovered
182
+ if (this.hoveredAnnotation === annotation) {
183
+ this.drawLineResizeHandles(annotation);
184
+ }
185
+ break;
186
+ case 'text':
187
+ const fontSize = annotation.fontSize || 24;
188
+ this.canvasContext.fillStyle = annotation.color;
189
+ this.canvasContext.font = `${fontSize}px Arial`;
190
+ this.canvasContext.fillText(annotation.text, annotation.x, annotation.y);
191
+ // Draw selection indicator if this annotation is selected
192
+ if (this.selectedAnnotation === annotation) {
193
+ this.drawTextSelectionIndicator(annotation);
194
+ }
195
+ break;
196
+ }
197
+ };
198
+ // Draw selection indicator for shapes
199
+ this.drawSelectionIndicator = (annotation) => {
200
+ if (!this.canvasContext)
201
+ return;
202
+ // Save current context
203
+ const originalStrokeStyle = this.canvasContext.strokeStyle;
204
+ const originalLineWidth = this.canvasContext.lineWidth;
205
+ // Draw selection outline
206
+ this.canvasContext.strokeStyle = '#0070F4';
207
+ this.canvasContext.lineWidth = 2;
208
+ this.canvasContext.setLineDash([5, 5]);
209
+ switch (annotation.type) {
210
+ case 'rectangle':
211
+ this.canvasContext.strokeRect(annotation.startX - 2, annotation.startY - 2, annotation.width + 4, annotation.height + 4);
212
+ break;
213
+ case 'line':
214
+ case 'arrow':
215
+ this.canvasContext.beginPath();
216
+ this.canvasContext.moveTo(annotation.startX, annotation.startY);
217
+ this.canvasContext.lineTo(annotation.endX, annotation.endY);
218
+ this.canvasContext.stroke();
219
+ break;
220
+ }
221
+ // Restore context
222
+ this.canvasContext.setLineDash([]);
223
+ this.canvasContext.strokeStyle = originalStrokeStyle;
224
+ this.canvasContext.lineWidth = originalLineWidth;
225
+ };
226
+ // Draw selection indicator for text
227
+ this.drawTextSelectionIndicator = (annotation) => {
228
+ if (!this.canvasContext)
229
+ return;
230
+ const fontSize = annotation.fontSize || 24;
231
+ const textWidth = this.getTextWidth(annotation.text, fontSize);
232
+ // Save current context
233
+ const originalStrokeStyle = this.canvasContext.strokeStyle;
234
+ const originalLineWidth = this.canvasContext.lineWidth;
235
+ // Draw selection outline around text
236
+ this.canvasContext.strokeStyle = '#0070F4';
237
+ this.canvasContext.lineWidth = 2;
238
+ this.canvasContext.setLineDash([3, 3]);
239
+ this.canvasContext.strokeRect(annotation.x - 4, annotation.y - fontSize - 4, textWidth + 8, fontSize + 8);
240
+ // Restore context
241
+ this.canvasContext.setLineDash([]);
242
+ this.canvasContext.strokeStyle = originalStrokeStyle;
243
+ this.canvasContext.lineWidth = originalLineWidth;
244
+ };
245
+ this.drawArrow = (fromX, fromY, toX, toY) => {
246
+ const headlen = 15; // Arrow head length
247
+ const angle = Math.atan2(toY - fromY, toX - fromX);
248
+ // Draw line
249
+ this.canvasContext.beginPath();
250
+ this.canvasContext.moveTo(fromX, fromY);
251
+ this.canvasContext.lineTo(toX, toY);
252
+ this.canvasContext.stroke();
253
+ // Draw arrow head
254
+ this.canvasContext.beginPath();
255
+ this.canvasContext.moveTo(toX, toY);
256
+ this.canvasContext.lineTo(toX - headlen * Math.cos(angle - Math.PI / 6), toY - headlen * Math.sin(angle - Math.PI / 6));
257
+ this.canvasContext.moveTo(toX, toY);
258
+ this.canvasContext.lineTo(toX - headlen * Math.cos(angle + Math.PI / 6), toY - headlen * Math.sin(angle + Math.PI / 6));
259
+ this.canvasContext.stroke();
260
+ };
261
+ this.undoLastAnnotation = () => {
262
+ this.annotations = this.annotations.slice(0, -1);
263
+ this.redrawAnnotations();
264
+ };
265
+ // Handle color slot editing
266
+ this.handleColorSlotClick = (colorIndex) => {
267
+ if (this.editingColorIndex === colorIndex) {
268
+ // If already editing this slot, just select the color
269
+ this.canvasDrawingColor = this.defaultColors[colorIndex];
270
+ this.showColorPicker = false;
271
+ this.editingColorIndex = -1;
272
+ }
273
+ else {
274
+ // Start editing this color slot
275
+ this.editingColorIndex = colorIndex;
276
+ this.showColorPicker = true;
277
+ this.canvasDrawingColor = this.defaultColors[colorIndex];
278
+ }
279
+ };
280
+ // Update color in slot
281
+ this.updateColorSlot = (newColor) => {
282
+ if (this.editingColorIndex >= 0 && this.editingColorIndex < this.defaultColors.length) {
283
+ this.defaultColors[this.editingColorIndex] = newColor;
284
+ this.canvasDrawingColor = newColor;
285
+ this.showColorPicker = false;
286
+ this.editingColorIndex = -1;
287
+ // Force reactivity
288
+ this.defaultColors = [...this.defaultColors];
289
+ }
290
+ };
291
+ // Handle color picker input without closing
292
+ this.handleColorPickerInput = (event) => {
293
+ event.stopPropagation();
294
+ const newColor = event.target.value;
295
+ if (this.editingColorIndex >= 0 && this.editingColorIndex < this.defaultColors.length) {
296
+ this.defaultColors[this.editingColorIndex] = newColor;
297
+ this.canvasDrawingColor = newColor;
298
+ // Force reactivity
299
+ this.defaultColors = [...this.defaultColors];
300
+ }
301
+ };
302
+ // Handle color picker click to prevent closing
303
+ this.handleColorPickerClick = (event) => {
304
+ event.stopPropagation();
305
+ };
306
+ // Close color picker
307
+ this.closeColorPicker = () => {
308
+ this.showColorPicker = false;
309
+ this.editingColorIndex = -1;
310
+ };
311
+ // Get text width for resize handle positioning
312
+ this.getTextWidth = (text, fontSize) => {
313
+ // Better text width calculation
314
+ if (!this.canvasContext) {
315
+ return text.length * fontSize * 0.6; // Fallback
316
+ }
317
+ // Use actual canvas measurement for accuracy
318
+ const originalFont = this.canvasContext.font;
319
+ this.canvasContext.font = `${fontSize}px Arial`;
320
+ const width = this.canvasContext.measureText(text).width;
321
+ this.canvasContext.font = originalFont;
322
+ return width;
323
+ };
324
+ // Check if point is in resize handle for shapes (not text)
325
+ this.isPointInResizeHandle = (x, y, annotation) => {
326
+ const handleSize = 8;
327
+ switch (annotation.type) {
328
+ case 'rectangle':
329
+ const right = annotation.startX + annotation.width;
330
+ const bottom = annotation.startY + annotation.height;
331
+ // Only check bottom-right corner handle
332
+ return x >= right - handleSize / 2 && x <= right + handleSize / 2 &&
333
+ y >= bottom - handleSize / 2 && y <= bottom + handleSize / 2;
334
+ case 'line':
335
+ case 'arrow':
336
+ // Check both endpoint handles
337
+ const lineHandles = [
338
+ { x: annotation.startX, y: annotation.startY, point: 'start' },
339
+ { x: annotation.endX, y: annotation.endY, point: 'end' }
340
+ ];
341
+ for (const handle of lineHandles) {
342
+ if (x >= handle.x - handleSize / 2 && x <= handle.x + handleSize / 2 &&
343
+ y >= handle.y - handleSize / 2 && y <= handle.y + handleSize / 2) {
344
+ return handle.point; // Return which endpoint was clicked
345
+ }
346
+ }
347
+ return false;
348
+ default:
349
+ return false;
350
+ }
351
+ };
352
+ // Draw resize handles for rectangle annotation (only bottom-right corner)
353
+ this.drawRectangleResizeHandles = (annotation) => {
354
+ if (!this.canvasContext || annotation.type !== 'rectangle')
355
+ return;
356
+ const handleSize = 8;
357
+ const right = annotation.startX + annotation.width;
358
+ const bottom = annotation.startY + annotation.height;
359
+ // Only draw bottom-right corner handle
360
+ const handle = { x: right, y: bottom };
361
+ // Draw the handle
362
+ this.canvasContext.fillStyle = '#0070F4'; // Primary color
363
+ this.canvasContext.strokeStyle = '#ffffff';
364
+ this.canvasContext.lineWidth = 2;
365
+ this.canvasContext.fillRect(handle.x - handleSize / 2, handle.y - handleSize / 2, handleSize, handleSize);
366
+ this.canvasContext.strokeRect(handle.x - handleSize / 2, handle.y - handleSize / 2, handleSize, handleSize);
367
+ };
368
+ // Draw resize handles for line/arrow annotation
369
+ this.drawLineResizeHandles = (annotation) => {
370
+ if (!this.canvasContext || (annotation.type !== 'line' && annotation.type !== 'arrow'))
371
+ return;
372
+ const handleSize = 8;
373
+ // Define handle positions (2 endpoints)
374
+ const handles = [
375
+ { x: annotation.startX, y: annotation.startY },
376
+ { x: annotation.endX, y: annotation.endY } // End point
377
+ ];
378
+ // Draw each handle
379
+ this.canvasContext.fillStyle = '#0070F4'; // Primary color
380
+ this.canvasContext.strokeStyle = '#ffffff';
381
+ this.canvasContext.lineWidth = 2;
382
+ handles.forEach(handle => {
383
+ this.canvasContext.fillRect(handle.x - handleSize / 2, handle.y - handleSize / 2, handleSize, handleSize);
384
+ this.canvasContext.strokeRect(handle.x - handleSize / 2, handle.y - handleSize / 2, handleSize, handleSize);
385
+ });
386
+ };
387
+ // Start resize for shapes
388
+ this.startResize = (annotation, handle, startPos) => {
389
+ this.isResizing = true;
390
+ this.resizingAnnotation = annotation;
391
+ this.resizeHandle = handle;
392
+ this.dragStartPos = startPos;
393
+ // Store original values for different annotation types
394
+ if (annotation.type === 'rectangle') {
395
+ this.resizeStartDimensions = { width: annotation.width, height: annotation.height };
396
+ }
397
+ };
398
+ // Handle resize for different annotation types
399
+ this.handleResize = (currentPos) => {
400
+ if (!this.resizingAnnotation || !this.dragStartPos)
401
+ return;
402
+ const annotation = this.resizingAnnotation;
403
+ const index = this.annotations.findIndex(a => a === annotation);
404
+ if (index === -1)
405
+ return;
406
+ let updatedAnnotation = Object.assign({}, annotation);
407
+ switch (annotation.type) {
408
+ case 'rectangle':
409
+ // Rectangle resize logic - only bottom-right corner
410
+ const rectDeltaX = currentPos.x - this.dragStartPos.x;
411
+ const rectDeltaY = currentPos.y - this.dragStartPos.y;
412
+ // Update width and height based on original dimensions plus delta
413
+ updatedAnnotation.width = Math.max(10, this.resizeStartDimensions.width + rectDeltaX);
414
+ updatedAnnotation.height = Math.max(10, this.resizeStartDimensions.height + rectDeltaY);
415
+ break;
416
+ case 'line':
417
+ case 'arrow':
418
+ // Line/arrow resize logic - move endpoints
419
+ if (this.resizeHandle === 'start') {
420
+ updatedAnnotation.startX = currentPos.x;
421
+ updatedAnnotation.startY = currentPos.y;
422
+ }
423
+ else if (this.resizeHandle === 'end') {
424
+ updatedAnnotation.endX = currentPos.x;
425
+ updatedAnnotation.endY = currentPos.y;
426
+ }
427
+ break;
428
+ }
429
+ // Update annotation in array
430
+ this.annotations[index] = updatedAnnotation;
431
+ this.resizingAnnotation = updatedAnnotation;
432
+ this.redrawAnnotations();
433
+ };
434
+ // Text editing methods
435
+ this.startTextEditing = (annotation) => {
436
+ const newText = prompt(this.editTextPromptText, annotation.text);
437
+ if (newText !== null && newText.trim()) {
438
+ const index = this.annotations.findIndex(a => a === annotation);
439
+ if (index !== -1) {
440
+ this.annotations[index] = Object.assign(Object.assign({}, annotation), { text: newText.trim() });
441
+ this.selectedAnnotation = this.annotations[index];
442
+ this.redrawAnnotations();
443
+ }
444
+ }
445
+ };
446
+ // Update selected annotation font size
447
+ this.updateSelectedTextSize = (newSize) => {
448
+ if (this.selectedAnnotation && this.selectedAnnotation.type === 'text') {
449
+ const index = this.annotations.findIndex(a => a === this.selectedAnnotation);
450
+ if (index !== -1) {
451
+ this.annotations[index] = Object.assign(Object.assign({}, this.selectedAnnotation), { fontSize: Math.max(8, Math.min(72, newSize)) });
452
+ this.selectedAnnotation = this.annotations[index];
453
+ this.redrawAnnotations();
454
+ }
455
+ }
456
+ };
457
+ // Update selected annotation border width
458
+ this.updateSelectedBorderWidth = (newWidth) => {
459
+ if (this.selectedAnnotation && ['rectangle', 'line', 'arrow'].includes(this.selectedAnnotation.type)) {
460
+ const index = this.annotations.findIndex(a => a === this.selectedAnnotation);
461
+ if (index !== -1) {
462
+ this.annotations[index] = Object.assign(Object.assign({}, this.selectedAnnotation), { lineWidth: Math.max(1, Math.min(20, newWidth)) });
463
+ this.selectedAnnotation = this.annotations[index];
464
+ this.redrawAnnotations();
465
+ }
466
+ }
467
+ };
468
+ // Enhanced mouse down handler with resize support
469
+ this.handleCanvasMouseDown = (event) => {
470
+ if (!this.canvasRef)
471
+ return;
472
+ // Disable drawing on mobile devices
473
+ if (window.innerWidth <= 768)
474
+ return;
475
+ // Close color picker if open
476
+ if (this.showColorPicker) {
477
+ this.closeColorPicker();
478
+ }
479
+ const coords = this.getCanvasCoordinates(event);
480
+ // Check if clicking on existing annotation first
481
+ const found = this.findAnnotationAt(coords.x, coords.y);
482
+ if (found) {
483
+ // Select the annotation
484
+ this.selectedAnnotation = found.annotation;
485
+ // Check if clicking on resize handle for shapes (not text)
486
+ if (found.annotation.type !== 'text') {
487
+ const handle = this.isPointInResizeHandle(coords.x, coords.y, found.annotation);
488
+ if (handle) {
489
+ this.startResize(found.annotation, handle, coords);
490
+ this.canvasRef.style.cursor = 'nw-resize';
491
+ return;
492
+ }
493
+ }
494
+ // Check for double-click to edit text
495
+ if (found.annotation.type === 'text' && event.detail === 2) {
496
+ this.startTextEditing(found.annotation);
497
+ return;
498
+ }
499
+ // Start dragging existing annotation
500
+ if (!this.isDrawing) {
501
+ this.isDragging = true;
502
+ this.draggedAnnotation = found.annotation;
503
+ this.dragStartPos = coords;
504
+ this.canvasRef.style.cursor = 'grabbing';
505
+ return;
506
+ }
507
+ }
508
+ else {
509
+ // Clear selection if clicking on empty space
510
+ this.selectedAnnotation = null;
511
+ }
512
+ // Original drawing logic
513
+ this.isDrawing = true;
514
+ if (this.canvasDrawingTool === 'text') {
515
+ const text = prompt(this.editTextPromptText);
516
+ if (text) {
517
+ const annotation = {
518
+ type: 'text',
519
+ x: coords.x,
520
+ y: coords.y,
521
+ text,
522
+ color: this.canvasDrawingColor,
523
+ fontSize: this.canvasTextSize
524
+ };
525
+ this.annotations = [...this.annotations, annotation];
526
+ this.redrawAnnotations();
527
+ }
528
+ this.isDrawing = false;
529
+ }
530
+ else {
531
+ this.currentAnnotation = {
532
+ type: this.canvasDrawingTool,
533
+ startX: coords.x,
534
+ startY: coords.y,
535
+ color: this.canvasDrawingColor,
536
+ lineWidth: this.canvasLineWidth
537
+ };
538
+ }
539
+ };
540
+ this.handleCanvasMouseMove = (event) => {
541
+ if (!this.canvasRef)
542
+ return;
543
+ // Disable drawing on mobile devices
544
+ if (window.innerWidth <= 768)
545
+ return;
546
+ const coords = this.getCanvasCoordinates(event);
547
+ // Handle resizing for shapes
548
+ if (this.isResizing && this.resizingAnnotation) {
549
+ this.handleResize(coords);
550
+ return;
551
+ }
552
+ // Handle dragging existing annotation
553
+ if (this.isDragging && this.draggedAnnotation && this.dragStartPos) {
554
+ const deltaX = coords.x - this.dragStartPos.x;
555
+ const deltaY = coords.y - this.dragStartPos.y;
556
+ // Update annotation position
557
+ const updatedAnnotation = Object.assign({}, this.draggedAnnotation);
558
+ switch (updatedAnnotation.type) {
559
+ case 'rectangle':
560
+ updatedAnnotation.startX += deltaX;
561
+ updatedAnnotation.startY += deltaY;
562
+ break;
563
+ case 'line':
564
+ case 'arrow':
565
+ updatedAnnotation.startX += deltaX;
566
+ updatedAnnotation.startY += deltaY;
567
+ updatedAnnotation.endX += deltaX;
568
+ updatedAnnotation.endY += deltaY;
569
+ break;
570
+ case 'text':
571
+ updatedAnnotation.x += deltaX;
572
+ updatedAnnotation.y += deltaY;
573
+ break;
574
+ }
575
+ // Update annotation in array
576
+ const index = this.annotations.findIndex(a => a === this.draggedAnnotation);
577
+ if (index !== -1) {
578
+ this.annotations[index] = updatedAnnotation;
579
+ this.draggedAnnotation = updatedAnnotation;
580
+ }
581
+ this.dragStartPos = coords;
582
+ this.redrawAnnotations();
583
+ return;
584
+ }
585
+ // Handle drawing new annotation
586
+ if (this.isDrawing && this.currentAnnotation) {
587
+ if (this.canvasDrawingTool === 'rectangle') {
588
+ this.currentAnnotation.width = coords.x - this.currentAnnotation.startX;
589
+ this.currentAnnotation.height = coords.y - this.currentAnnotation.startY;
590
+ }
591
+ else {
592
+ this.currentAnnotation.endX = coords.x;
593
+ this.currentAnnotation.endY = coords.y;
594
+ }
595
+ this.redrawAnnotations();
596
+ this.drawAnnotation(this.currentAnnotation);
597
+ return;
598
+ }
599
+ // Handle hover states and cursor changes
600
+ const found = this.findAnnotationAt(coords.x, coords.y);
601
+ if (found) {
602
+ // Check if hovering over resize handle for shapes (not text)
603
+ if (found.annotation.type !== 'text') {
604
+ const handle = this.isPointInResizeHandle(coords.x, coords.y, found.annotation);
605
+ if (handle) {
606
+ this.canvasRef.style.cursor = 'nw-resize';
607
+ this.hoveredAnnotation = found.annotation;
608
+ this.redrawAnnotations();
609
+ return;
610
+ }
611
+ }
612
+ // Regular hover over annotation
613
+ this.canvasRef.style.cursor = 'grab';
614
+ if (this.hoveredAnnotation !== found.annotation) {
615
+ this.hoveredAnnotation = found.annotation;
616
+ this.redrawAnnotations();
617
+ }
618
+ }
619
+ else {
620
+ // No annotation under cursor
621
+ this.canvasRef.style.cursor = 'crosshair';
622
+ if (this.hoveredAnnotation) {
623
+ this.hoveredAnnotation = null;
624
+ this.redrawAnnotations();
625
+ }
626
+ }
627
+ };
628
+ this.handleCanvasMouseUp = () => {
629
+ // Disable drawing on mobile devices
630
+ if (window.innerWidth <= 768)
631
+ return;
632
+ // Handle end of resizing
633
+ if (this.isResizing) {
634
+ this.isResizing = false;
635
+ this.resizingAnnotation = null;
636
+ this.dragStartPos = null;
637
+ this.resizeHandle = false;
638
+ this.resizeStartDimensions = null;
639
+ if (this.canvasRef) {
640
+ this.canvasRef.style.cursor = 'crosshair';
641
+ }
642
+ return;
643
+ }
644
+ // Handle end of dragging
645
+ if (this.isDragging) {
646
+ this.isDragging = false;
647
+ this.draggedAnnotation = null;
648
+ this.dragStartPos = null;
649
+ if (this.canvasRef) {
650
+ this.canvasRef.style.cursor = 'crosshair';
651
+ }
652
+ return;
653
+ }
654
+ // Handle end of drawing
655
+ if (!this.isDrawing || !this.currentAnnotation)
656
+ return;
657
+ this.isDrawing = false;
658
+ this.annotations = [...this.annotations, this.currentAnnotation];
659
+ this.currentAnnotation = null;
660
+ this.redrawAnnotations();
661
+ };
662
+ // Convert screen coordinates to canvas coordinates
663
+ this.getCanvasCoordinates = (event) => {
664
+ if (!this.canvasRef)
665
+ return { x: 0, y: 0 };
666
+ const rect = this.canvasRef.getBoundingClientRect();
667
+ // Calculate the scale factor between display size and actual canvas size
668
+ const scaleX = this.canvasRef.width / rect.width;
669
+ const scaleY = this.canvasRef.height / rect.height;
670
+ const x = (event.clientX - rect.left) * scaleX;
671
+ const y = (event.clientY - rect.top) * scaleY;
672
+ return { x, y };
673
+ };
674
+ // Find annotation under mouse cursor
675
+ this.findAnnotationAt = (x, y) => {
676
+ // Check in reverse order (top to bottom)
677
+ for (let i = this.annotations.length - 1; i >= 0; i--) {
678
+ const annotation = this.annotations[i];
679
+ if (this.isPointInAnnotation(x, y, annotation)) {
680
+ return { annotation, index: i };
681
+ }
682
+ }
683
+ return null;
684
+ };
685
+ // Check if point is within annotation bounds
686
+ this.isPointInAnnotation = (x, y, annotation) => {
687
+ const tolerance = 10; // Click tolerance
688
+ switch (annotation.type) {
689
+ case 'rectangle':
690
+ const left = Math.min(annotation.startX, annotation.startX + annotation.width);
691
+ const right = Math.max(annotation.startX, annotation.startX + annotation.width);
692
+ const top = Math.min(annotation.startY, annotation.startY + annotation.height);
693
+ const bottom = Math.max(annotation.startY, annotation.startY + annotation.height);
694
+ return x >= left - tolerance && x <= right + tolerance &&
695
+ y >= top - tolerance && y <= bottom + tolerance;
696
+ case 'line':
697
+ case 'arrow':
698
+ // Distance from point to line
699
+ const A = annotation.endY - annotation.startY;
700
+ const B = annotation.startX - annotation.endX;
701
+ const C = annotation.endX * annotation.startY - annotation.startX * annotation.endY;
702
+ const distance = Math.abs(A * x + B * y + C) / Math.sqrt(A * A + B * B);
703
+ return distance <= tolerance;
704
+ case 'text':
705
+ // Use actual text dimensions for better dragging
706
+ const fontSize = annotation.fontSize || 24;
707
+ const textWidth = this.getTextWidth(annotation.text, fontSize);
708
+ const textHeight = fontSize;
709
+ // Text bounding box (y coordinate is baseline, so subtract font size for top)
710
+ const textLeft = annotation.x - tolerance;
711
+ const textRight = annotation.x + textWidth + tolerance;
712
+ const textTop = annotation.y - textHeight - tolerance;
713
+ const textBottom = annotation.y + tolerance;
714
+ return x >= textLeft && x <= textRight &&
715
+ y >= textTop && y <= textBottom;
716
+ default:
717
+ return false;
718
+ }
719
+ };
720
+ this.canvasEditorTitle = 'Edit screenshot';
721
+ this.canvasEditorCancelText = 'Cancel';
722
+ this.canvasEditorSaveText = 'Save';
723
+ this.screenshotTakingText = 'Taking screenshot...';
724
+ this.screenshotAttachedText = 'Screenshot attached';
725
+ this.screenshotButtonText = 'Add a screenshot';
726
+ this.autoStartScreenshot = false;
727
+ this.existingScreenshot = '';
728
+ this.editTextButtonText = 'Edit Text';
729
+ this.sizeLabelText = 'Size:';
730
+ this.borderLabelText = 'Border:';
731
+ this.editTextPromptText = 'Edit text:';
732
+ this.screenshotErrorGeneral = 'Failed to capture screenshot.';
733
+ this.screenshotErrorPermission = 'Permission denied. Please allow screen sharing to take screenshots.';
734
+ this.screenshotErrorNotSupported = 'Screen capture is not supported in this browser.';
735
+ this.screenshotErrorNotFound = 'No screen sources available for capture.';
736
+ this.screenshotErrorCancelled = 'Screenshot capture was cancelled.';
737
+ this.screenshotErrorBrowserNotSupported = 'Your browser does not support screen capture. Please use a browser like Chrome, Firefox, or Safari on desktop.';
738
+ this.screenshotErrorUnexpected = 'An unexpected error occurred. Please try again.';
739
+ this.takingScreenshot = false;
740
+ this.showCanvasEditor = false;
741
+ this.canvasDrawingTool = 'rectangle';
742
+ this.canvasDrawingColor = '#ff0000';
743
+ this.canvasLineWidth = 3;
744
+ this.canvasTextSize = 24;
745
+ this.isDrawing = false;
746
+ this.annotations = [];
747
+ this.currentAnnotation = null;
748
+ this.isDragging = false;
749
+ this.draggedAnnotation = null;
750
+ this.dragStartPos = null;
751
+ this.showColorPicker = false;
752
+ this.editingColorIndex = -1;
753
+ this.selectedAnnotation = null;
754
+ this.isResizing = false;
755
+ this.resizingAnnotation = null;
756
+ this.resizeStartSize = 24;
757
+ this.resizeStartDimensions = null;
758
+ this.hoveredAnnotation = null;
759
+ this.resizeHandle = false;
760
+ this.defaultColors = ['#ff0000', '#00ff00', '#0000ff', '#000000'];
761
+ }
762
+ componentDidLoad() {
763
+ if (this.autoStartScreenshot) {
764
+ // Show the editor UI and start screenshot capture
765
+ this.showCanvasEditor = true;
766
+ setTimeout(() => {
767
+ this.openScreenShot();
768
+ }, 100); // Small delay to ensure component is fully rendered
769
+ }
770
+ else if (this.existingScreenshot) {
771
+ // Show editor with existing screenshot data
772
+ this.originalImageData = this.existingScreenshot;
773
+ this.showCanvasEditor = true;
774
+ setTimeout(() => {
775
+ this.initializeCanvas();
776
+ }, 100);
777
+ }
778
+ }
779
+ async captureViewportScreenshot() {
780
+ try {
781
+ // Check if Screen Capture API is supported
782
+ if (!navigator.mediaDevices || !navigator.mediaDevices.getDisplayMedia) {
783
+ throw new Error('Screen Capture API is not supported in this browser');
784
+ }
785
+ // Request screen capture with preference for current tab
786
+ const stream = await navigator.mediaDevices.getDisplayMedia({
787
+ video: {
788
+ mediaSource: 'screen',
789
+ width: { ideal: window.innerWidth },
790
+ height: { ideal: window.innerHeight }
791
+ },
792
+ audio: false,
793
+ preferCurrentTab: true
794
+ });
795
+ // Create video element to capture frame
796
+ const video = document.createElement('video');
797
+ video.srcObject = stream;
798
+ video.autoplay = true;
799
+ video.muted = true;
800
+ return new Promise((resolve, reject) => {
801
+ video.onloadedmetadata = () => {
802
+ video.play();
803
+ // Wait a moment for video to stabilize
804
+ setTimeout(() => {
805
+ try {
806
+ // Create canvas to capture frame
807
+ const canvas = document.createElement('canvas');
808
+ canvas.width = video.videoWidth;
809
+ canvas.height = video.videoHeight;
810
+ const ctx = canvas.getContext('2d');
811
+ ctx.drawImage(video, 0, 0);
812
+ // Stop the stream
813
+ stream.getTracks().forEach(track => track.stop());
814
+ // Convert to data URL
815
+ const dataUrl = canvas.toDataURL('image/png');
816
+ console.log('Screenshot captured successfully using Screen Capture API');
817
+ resolve(dataUrl);
818
+ }
819
+ catch (error) {
820
+ stream.getTracks().forEach(track => track.stop());
821
+ reject(error);
822
+ }
823
+ }, 100);
824
+ };
825
+ video.onerror = () => {
826
+ stream.getTracks().forEach(track => track.stop());
827
+ reject(new Error('Failed to load video for screenshot capture'));
828
+ };
829
+ });
830
+ }
831
+ catch (error) {
832
+ console.error('Screen capture failed:', error);
833
+ throw error;
834
+ }
835
+ }
836
+ render() {
837
+ var _a, _b, _c, _d, _e, _f;
838
+ return (h("div", { class: "canvas-editor-wrapper" }, this.showCanvasEditor && (h("div", { class: "canvas-editor-overlay" }, h("div", { class: "canvas-editor-modal" }, h("div", { class: "canvas-editor-header" }, h("div", { class: "canvas-editor-title" }, h("h3", null, this.canvasEditorTitle)), h("div", { class: "canvas-editor-toolbar" }, h("div", { class: "toolbar-section" }, h("div", { class: "tool-group" }, h("button", { class: `tool-btn ${this.canvasDrawingTool === 'rectangle' ? 'active' : ''}`, onClick: () => this.canvasDrawingTool = 'rectangle', title: "Rectangle" }, h("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }))), h("button", { class: `tool-btn ${this.canvasDrawingTool === 'line' ? 'active' : ''}`, onClick: () => this.canvasDrawingTool = 'line', title: "Line" }, h("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("line", { x1: "5", y1: "12", x2: "19", y2: "12" }))), h("button", { class: `tool-btn ${this.canvasDrawingTool === 'arrow' ? 'active' : ''}`, onClick: () => this.canvasDrawingTool = 'arrow', title: "Arrow" }, h("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("line", { x1: "7", y1: "17", x2: "17", y2: "7" }), h("polyline", { points: "7,7 17,7 17,17" }))), h("button", { class: `tool-btn ${this.canvasDrawingTool === 'text' ? 'active' : ''}`, onClick: () => this.canvasDrawingTool = 'text', title: "Text" }, h("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("polyline", { points: "4,7 4,4 20,4 20,7" }), h("line", { x1: "9", y1: "20", x2: "15", y2: "20" }), h("line", { x1: "12", y1: "4", x2: "12", y2: "20" }))), h("div", { class: "toolbar-divider" }), h("button", { class: "tool-btn undo-btn", onClick: this.undoLastAnnotation, disabled: this.annotations.length === 0, title: "Undo" }, h("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("polyline", { points: "1,4 1,10 7,10" }), h("path", { d: "M3.51,15a9,9,0,0,0,14.85-3.36,9,9,0,0,0-9.19-10.15L1.83,10" }))))), h("div", { class: "toolbar-section" }, h("div", { class: "color-palette" }, this.defaultColors.map((color, index) => (h("div", { class: "color-slot-wrapper" }, h("button", { class: `color-btn ${this.canvasDrawingColor === color ? 'active' : ''} ${this.editingColorIndex === index ? 'editing' : ''}`, style: { backgroundColor: color }, onClick: () => this.handleColorSlotClick(index), title: `Color ${index + 1} - Click to customize` }, this.editingColorIndex === index && (h("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "white", "stroke-width": "2" }, h("path", { d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" })))), this.editingColorIndex === index && this.showColorPicker && (h("div", { class: "color-picker-dropdown" }, h("input", { type: "color", value: color, onInput: (e) => this.handleColorPickerInput(e), onClick: (e) => this.handleColorPickerClick(e) })))))))), (this.selectedAnnotation || this.canvasDrawingTool) && (h("div", { class: "toolbar-section selected-annotation-controls" }, (((_a = this.selectedAnnotation) === null || _a === void 0 ? void 0 : _a.type) === 'text' || (!this.selectedAnnotation && this.canvasDrawingTool === 'text')) && (h("div", { class: "text-controls" }, h("div", { class: "font-size-control" }, h("label", null, this.sizeLabelText), h("input", { type: "range", min: "8", max: "72", value: ((_b = this.selectedAnnotation) === null || _b === void 0 ? void 0 : _b.fontSize) || this.canvasTextSize, onInput: (e) => {
839
+ const newSize = parseInt(e.target.value);
840
+ if (this.selectedAnnotation) {
841
+ this.updateSelectedTextSize(newSize);
842
+ }
843
+ else {
844
+ this.canvasTextSize = newSize;
845
+ }
846
+ }, class: "size-slider" }), h("span", { class: "size-value" }, ((_c = this.selectedAnnotation) === null || _c === void 0 ? void 0 : _c.fontSize) || this.canvasTextSize, "px")), this.selectedAnnotation && (h("button", { class: "action-btn small", onClick: () => this.startTextEditing(this.selectedAnnotation) }, this.editTextButtonText)))), ((['rectangle', 'line', 'arrow'].includes((_d = this.selectedAnnotation) === null || _d === void 0 ? void 0 : _d.type)) ||
847
+ (!this.selectedAnnotation && ['rectangle', 'line', 'arrow'].includes(this.canvasDrawingTool))) && (h("div", { class: "shape-controls" }, h("div", { class: "border-width-control" }, h("label", null, this.borderLabelText), h("input", { type: "range", min: "1", max: "20", value: ((_e = this.selectedAnnotation) === null || _e === void 0 ? void 0 : _e.lineWidth) || this.canvasLineWidth, onInput: (e) => {
848
+ const newWidth = parseInt(e.target.value);
849
+ if (this.selectedAnnotation) {
850
+ this.updateSelectedBorderWidth(newWidth);
851
+ }
852
+ else {
853
+ this.canvasLineWidth = newWidth;
854
+ }
855
+ }, class: "size-slider" }), h("span", { class: "size-value" }, ((_f = this.selectedAnnotation) === null || _f === void 0 ? void 0 : _f.lineWidth) || this.canvasLineWidth, "px")))))), h("div", { class: "toolbar-section" }, h("button", { class: "action-btn secondary", onClick: this.closeCanvasEditor }, this.canvasEditorCancelText), h("button", { class: "action-btn primary", onClick: this.saveAnnotations }, this.canvasEditorSaveText))), h("div", { class: "canvas-editor-content" }, h("canvas", { ref: (el) => this.canvasRef = el, class: "annotation-canvas", onMouseDown: this.handleCanvasMouseDown, onMouseMove: this.handleCanvasMouseMove, onMouseUp: this.handleCanvasMouseUp, onMouseLeave: this.handleCanvasMouseUp }))))))));
856
+ }
857
+ };
858
+ CanvasEditor.style = canvasEditorCss;
859
+
860
+ export { CanvasEditor as canvas_editor };