pushfeedback 0.1.70 → 0.1.72

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 (46) hide show
  1. package/dist/cjs/canvas-editor_3.cjs.entry.js +1364 -0
  2. package/dist/cjs/index-9a8f4784.js +1584 -0
  3. package/dist/cjs/index.cjs.js +2 -0
  4. package/dist/cjs/loader.cjs.js +22 -0
  5. package/dist/cjs/pushfeedback.cjs.js +23 -0
  6. package/dist/collection/collection-manifest.json +14 -0
  7. package/dist/collection/components/canvas-editor/canvas-editor.css +404 -0
  8. package/dist/collection/components/canvas-editor/canvas-editor.js +1282 -0
  9. package/dist/collection/components/feedback-button/feedback-button.css +81 -0
  10. package/dist/collection/components/feedback-button/feedback-button.js +1149 -0
  11. package/dist/collection/components/feedback-modal/feedback-modal.css +547 -0
  12. package/dist/collection/components/feedback-modal/feedback-modal.js +1238 -0
  13. package/dist/collection/index.js +1 -0
  14. package/dist/components/canvas-editor.js +6 -0
  15. package/dist/{pushfeedback/canvas-editor.entry.js → components/canvas-editor2.js} +64 -7
  16. package/dist/{pushfeedback/feedback-button.entry.js → components/feedback-button.js} +112 -33
  17. package/dist/components/feedback-modal.js +6 -0
  18. package/dist/{pushfeedback/feedback-modal.entry.js → components/feedback-modal2.js} +106 -18
  19. package/dist/components/index.js +4 -0
  20. package/dist/esm/canvas-editor_3.entry.js +1358 -0
  21. package/dist/esm/index-f65e9124.js +1555 -0
  22. package/dist/esm/index.js +1 -0
  23. package/dist/esm/loader.js +18 -0
  24. package/dist/esm/polyfills/core-js.js +11 -0
  25. package/dist/esm/polyfills/css-shim.js +1 -0
  26. package/dist/esm/polyfills/dom.js +79 -0
  27. package/dist/esm/polyfills/es5-html-element.js +1 -0
  28. package/dist/esm/polyfills/index.js +34 -0
  29. package/dist/esm/polyfills/system.js +6 -0
  30. package/dist/esm/pushfeedback.js +18 -0
  31. package/dist/index.cjs.js +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/pushfeedback/index.esm.js +0 -1
  34. package/dist/pushfeedback/p-881a733a.entry.js +1 -0
  35. package/dist/pushfeedback/p-af2a1f7f.js +2 -0
  36. package/dist/pushfeedback/pushfeedback.css +1 -146
  37. package/dist/pushfeedback/pushfeedback.esm.js +1 -148
  38. package/dist/types/components/feedback-button/feedback-button.d.ts +16 -17
  39. package/dist/types/components/feedback-modal/feedback-modal.d.ts +8 -9
  40. package/dist/types/components.d.ts +28 -32
  41. package/package.json +1 -1
  42. package/dist/pushfeedback/app-globals-0f993ce5.js +0 -3
  43. package/dist/pushfeedback/css-shim-b7d3d95f.js +0 -4
  44. package/dist/pushfeedback/dom-64053c71.js +0 -73
  45. package/dist/pushfeedback/index-36434da0.js +0 -3371
  46. package/dist/pushfeedback/shadow-css-98135883.js +0 -387
@@ -0,0 +1,1358 @@
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-f65e9124.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
+ const feedbackButtonCss = ".feedback-button-content{cursor:pointer;max-width:fit-content;z-index:var(--feedback-button-z-index);font-family:var(--feedback-font-family)}.feedback-button-content--custom-font{font-family:inherit}.feedback-button-content--light{align-items:center;background-color:var(--feedback-button-light-bg-color);border-radius:var(--feedback-button-border-radius);box-shadow:rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;box-sizing:border-box;color:var(--feedback-button-light-text-color);display:flex;font-size:var(--feedback-button-text-font-size);font-weight:var(--feedback-button-text-font-weight);padding:8px 15px}.feedback-button-content--dark{align-items:center;background-color:var(--feedback-button-dark-bg-color);border-radius:var(--feedback-button-border-radius);box-shadow:rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;box-sizing:border-box;color:var(--feedback-button-dark-text-color);display:flex;font-weight:var(--feedback-button-text-font-weight);font-size:var(--feedback-button-text-font-size);padding:8px 15px}.icon-edit{stroke:var(--feedback-button-light-icon-color)}.feedback-button-content--dark .icon-edit{stroke:var(--feedback-button-dark-icon-color)}.feedback-button-content--bottom-right{bottom:10px;position:fixed;right:10px}.feedback-button-content--center-right{position:fixed;transform:rotate(-90deg) translateY(-50%);top:50%}.feedback-button-content--center-right.feedback-button-content--dark,.feedback-button-content--center-right.feedback-button-content--light{border-radius:4px;border-bottom-left-radius:0px;border-bottom-right-radius:0px}.feedback-button-content-icon{height:16px;margin-right:5px;width:16px}.feedback-button-content--center-right .feedback-button-content-icon{rotate:90deg}@media screen and (max-width: 767px){.feedback-button-content--hide-mobile{display:none}}";
861
+
862
+ const FeedbackButton = class {
863
+ constructor(hostRef) {
864
+ registerInstance(this, hostRef);
865
+ this.feedbackSent = createEvent(this, "feedbackSent", 7);
866
+ this.feedbackError = createEvent(this, "feedbackError", 7);
867
+ this.buttonPosition = 'default';
868
+ this.buttonStyle = 'default';
869
+ this.hideIcon = false;
870
+ this.hideMobile = false;
871
+ this.sessionId = '';
872
+ this.metadata = '';
873
+ this.submit = false;
874
+ this.customFont = false;
875
+ this.emailAddress = '';
876
+ this.isEmailRequired = false;
877
+ this.fetchData = true;
878
+ this.hideEmail = false;
879
+ this.hidePrivacyPolicy = true;
880
+ this.hideRating = false;
881
+ this.hideScreenshotButton = false;
882
+ this.modalPosition = 'center';
883
+ this.project = '';
884
+ this.rating = undefined;
885
+ this.ratingMode = 'thumbs';
886
+ this.emailPlaceholder = 'Email address (optional)';
887
+ this.errorMessage = 'Please try again later.';
888
+ this.errorMessage403 = 'The request URL does not match the one defined in PushFeedback for this project.';
889
+ this.errorMessage404 = 'We could not find the provided project id in PushFeedback.';
890
+ this.footerText = '';
891
+ this.messagePlaceholder = 'Comments';
892
+ this.modalTitle = 'Share your feedback';
893
+ this.modalTitleError = 'Oops!';
894
+ this.modalTitleSuccess = 'Thanks for your feedback!';
895
+ this.privacyPolicyText = "I have read and expressly consent to the terms of the <a href='https://pushfeedback.com/privacy'>Privacy Policy</a>.";
896
+ this.ratingPlaceholder = 'Was this page helpful?';
897
+ this.ratingStarsPlaceholder = 'How would you rate this page?';
898
+ this.sendButtonText = 'Send';
899
+ this.successMessage = '';
900
+ this.screenshotAttachedText = 'Screenshot attached';
901
+ this.screenshotButtonText = 'Add a screenshot';
902
+ this.screenshotTakingText = 'Taking screenshot...';
903
+ this.screenshotEditTextButtonText = 'Edit text';
904
+ this.screenshotEditorTitle = 'Edit screenshot';
905
+ this.screenshotEditorCancelText = 'Cancel';
906
+ this.screenshotEditorSaveText = 'Save';
907
+ this.screenshotSizeLabelText = 'Size:';
908
+ this.screenshotBorderLabelText = 'Border:';
909
+ this.screenshotEditTextPromptText = 'Edit text:';
910
+ this.screenshotErrorGeneral = 'Failed to capture screenshot.';
911
+ this.screenshotErrorPermission = 'Permission denied. Please allow screen sharing to take screenshots.';
912
+ this.screenshotErrorNotSupported = 'Screen capture is not supported in this browser.';
913
+ this.screenshotErrorNotFound = 'No screen sources available for capture.';
914
+ this.screenshotErrorCancelled = 'Screenshot capture was cancelled.';
915
+ this.screenshotErrorBrowserNotSupported = 'Your browser does not support screen capture. Please use a browser like Chrome, Firefox, or Safari on desktop.';
916
+ this.screenshotErrorUnexpected = 'An unexpected error occurred. Please try again.';
917
+ }
918
+ componentWillLoad() {
919
+ if (!this.sessionId) {
920
+ let storedSessionId = localStorage.getItem('pushfeedback_sessionid');
921
+ if (!storedSessionId) {
922
+ storedSessionId = this.generateRandomSessionId();
923
+ localStorage.setItem('pushfeedback_sessionid', storedSessionId);
924
+ this.sessionId = storedSessionId;
925
+ }
926
+ }
927
+ else {
928
+ localStorage.setItem('pushfeedback_sessionid', this.sessionId);
929
+ }
930
+ }
931
+ componentDidLoad() {
932
+ if (this.buttonPosition === 'center-right') {
933
+ const buttonContent = this.el.shadowRoot.querySelector('.feedback-button-content');
934
+ let adjustement = 0;
935
+ if (this.isSafariBrowser()) {
936
+ adjustement = 5;
937
+ }
938
+ buttonContent.style.right = `${((buttonContent.offsetWidth + adjustement) / 2) * -1}px`;
939
+ }
940
+ if (!this.customFont) {
941
+ this.loadInterFont();
942
+ }
943
+ }
944
+ connectedCallback() {
945
+ this.feedbackModal = document.createElement('feedback-modal');
946
+ const props = [
947
+ 'customFont',
948
+ 'emailAddress',
949
+ 'fetchData',
950
+ 'hideEmail',
951
+ 'hidePrivacyPolicy',
952
+ 'hideRating',
953
+ 'hideScreenshotButton',
954
+ 'isEmailRequired',
955
+ 'modalPosition',
956
+ 'project',
957
+ 'rating',
958
+ 'ratingMode',
959
+ 'screenshotEditorTitle',
960
+ 'screenshotEditorCancelText',
961
+ 'screenshotEditorSaveText',
962
+ 'screenshotEditTextButtonText',
963
+ 'screenshotSizeLabelText',
964
+ 'screenshotBorderLabelText',
965
+ 'screenshotEditTextPromptText',
966
+ 'screenshotErrorGeneral',
967
+ 'screenshotErrorPermission',
968
+ 'screenshotErrorNotSupported',
969
+ 'screenshotErrorNotFound',
970
+ 'screenshotErrorCancelled',
971
+ 'screenshotErrorBrowserNotSupported',
972
+ 'screenshotErrorUnexpected',
973
+ 'emailPlaceholder',
974
+ 'errorMessage',
975
+ 'errorMessage403',
976
+ 'errorMessage404',
977
+ 'footerText',
978
+ 'messagePlaceholder',
979
+ 'metadata',
980
+ 'modalTitle',
981
+ 'modalTitleError',
982
+ 'modalTitleSuccess',
983
+ 'privacyPolicyText',
984
+ 'ratingPlaceholder',
985
+ 'ratingStarsPlaceholder',
986
+ 'screenshotAttachedText',
987
+ 'screenshotButtonText',
988
+ 'screenshotTakingText',
989
+ 'sendButtonText',
990
+ 'successMessage',
991
+ ];
992
+ props.forEach((prop) => {
993
+ this.feedbackModal[prop] = this[prop];
994
+ });
995
+ document.body.appendChild(this.feedbackModal);
996
+ }
997
+ disconnectedCallback() {
998
+ document.body.removeChild(this.feedbackModal);
999
+ }
1000
+ generateRandomSessionId(length = 16) {
1001
+ return Math.random().toString(36).substr(2, length);
1002
+ }
1003
+ isSafariBrowser() {
1004
+ const isSafari = /safari/i.test(navigator.userAgent) && !/chrome/i.test(navigator.userAgent);
1005
+ return isSafari;
1006
+ }
1007
+ loadInterFont() {
1008
+ const link = document.createElement('link');
1009
+ link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';
1010
+ link.rel = 'stylesheet';
1011
+ document.head.appendChild(link);
1012
+ }
1013
+ showModal() {
1014
+ if (this.submit) {
1015
+ this.submitRatingFeedback();
1016
+ }
1017
+ else {
1018
+ this.feedbackModal.openModal();
1019
+ }
1020
+ }
1021
+ async submitRatingFeedback() {
1022
+ try {
1023
+ const body = {
1024
+ url: window.location.href,
1025
+ project: this.project,
1026
+ rating: this.rating || -1,
1027
+ ratingMode: this.ratingMode,
1028
+ message: '',
1029
+ metadata: this.metadata,
1030
+ session: localStorage.getItem('pushfeedback_sessionid') || '',
1031
+ };
1032
+ const res = await fetch('https://app.pushfeedback.com/api/feedback/', {
1033
+ method: 'POST',
1034
+ body: JSON.stringify(body),
1035
+ headers: {
1036
+ 'Content-Type': 'application/json',
1037
+ },
1038
+ });
1039
+ if (res.status === 201) {
1040
+ const feedback_with_id = Object.assign(Object.assign({}, body), { id: await res.json() });
1041
+ this.feedbackSent.emit({ feedback: feedback_with_id });
1042
+ }
1043
+ else {
1044
+ const errorText = await res.text();
1045
+ const response = {
1046
+ status: res.status,
1047
+ message: errorText,
1048
+ };
1049
+ this.feedbackError.emit({ error: response });
1050
+ }
1051
+ }
1052
+ catch (error) {
1053
+ const response = {
1054
+ status: 500,
1055
+ message: error,
1056
+ };
1057
+ this.feedbackError.emit({ error: response });
1058
+ }
1059
+ }
1060
+ render() {
1061
+ return (h(Host, null, h("a", { class: `feedback-button-content feedback-button-content--${this.buttonStyle} feedback-button-content--${this.buttonPosition} ${this.customFont ? 'feedback-button-content--custom-font' : ''} ${this.hideMobile ? 'feedback-button-content--hide-mobile' : ''}`, onClick: () => this.showModal() }, !this.hideIcon && this.buttonStyle != 'default' && (h("span", { class: "feedback-button-content-icon" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "#fff", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "icon-edit" }, h("path", { d: "M12 20h9" }), h("path", { d: "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z" })))), h("slot", null))));
1062
+ }
1063
+ get el() { return getElement(this); }
1064
+ };
1065
+ FeedbackButton.style = feedbackButtonCss;
1066
+
1067
+ const feedbackModalCss = ".text-center{flex-grow:1;text-align:center}.feedback-modal-wrapper *{font-family:var(--feedback-font-family)}.feedback-modal-wrapper--custom-font *{font-family:inherit}.feedback-modal-wrapper{position:absolute;z-index:var(--feedback-modal-modal-wrapper-z-index)}.feedback-overlay{background-color:var(--feedback-modal-screenshot-bg-color);height:100%;left:0;opacity:0;position:fixed;top:0;width:100%;z-index:var(--feedback-modal-screnshot-z-index);transition:opacity 0.2s ease-out}.feedback-overlay--visible{opacity:1}.feedback-modal{display:inline-block;position:relative}.feedback-modal-content{background-color:var(--feedback-modal-content-bg-color);border-color:1px solid var(--feedback-modal-header-text-color);border-radius:var(--feedback-modal-content-border-radius);box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .30), 0px 2px 6px 2px rgba(60, 64, 67, .15);box-sizing:border-box;color:var(--feedback-modal-content-text-color);display:flex;flex-direction:column;left:50%;max-width:90%;padding:20px;position:fixed;top:50%;transform:translate(-50%, -50%) scale(0.95);opacity:0;width:100%;z-index:var(--feedback-modal-content-z-index);transition:transform 0.2s ease-out, opacity 0.2s ease-out}.feedback-modal-content--open{transform:translate(-50%, -50%) scale(1);opacity:1}.feedback-modal-header{align-items:center;color:var(--feedback-modal-header-text-color);display:flex;font-size:var(--feedback-header-font-size);font-weight:var(--feedback-modal-header-font-weight);justify-content:space-between;margin-bottom:20px}.feedback-modal-rating-buttons{width:100%;margin-bottom:20px}.feedback-modal-rating-button{padding:0;background-color:transparent;border:transparent;margin-right:5px;cursor:pointer}.feedback-modal-rating-buttons--thumbs .feedback-modal-rating-button{border:1px solid var(--feedback-modal-button-border-color);border-radius:var(--feedback-modal-button-border-radius);color:var(--feedback-modal-button-text-color);font-size:var(--feedback-modal-button-font-size);font-weight:500;margin-right:10px;justify-content:center;padding:5px 10px}.feedback-modal-rating-buttons--thumbs .feedback-modal-rating-button:hover,.feedback-modal-rating-buttons--thumbs .feedback-modal-rating-button--selected{background-color:var(--feedback-modal-button-bg-color-active);border:1px solid var(--feedback-modal-button-border-color-active);color:var(--feedback-modal-button-text-color-active)}.feedback-modal-rating-buttons--thumbs .feedback-modal-rating-button:hover svg,.feedback-modal-rating-buttons--thumbs .feedback-modal-rating-button--selected svg{stroke:var(--feedback-modal-rating-button-selected-color)}.feedback-modal-rating-buttons svg{stroke:var(--feedback-modal-rating-button-color);cursor:pointer}.feedback-modal-rating-buttons--stars .feedback-modal-rating-button--selected svg{fill:var(--feedback-modal-rating-button-stars-selected-color);stroke:var(--feedback-modal-rating-button-stars-selected-color)}.feedback-modal-text textarea{background-color:var(--feedback-modal-input-bg-color);border:1px solid var(--feedback-modal-input-border-color);border-radius:var(--feedback-modal-input-border-radius);box-sizing:border-box;color:var(--feedback-modal-input-text-color);font-size:var(--feedback-modal-input-font-size);margin-bottom:20px;height:100px;min-height:100px;padding:10px;resize:vertical;width:100%}.feedback-modal-email input{background-color:var(--feedback-modal-input-bg-color);border:1px solid var(--feedback-modal-input-border-color);border-radius:var(--feedback-modal-input-border-radius);box-sizing:border-box;color:var(--feedback-modal-input-text-color);font-size:var(--feedback-modal-input-font-size);margin-bottom:20px;height:40px;padding:10px;width:100%;margin-bottom:20px}.feedback-modal-privacy{font-size:var(--feedback-modal-input-font-size);margin-bottom:20px}.feedback-modal-text textarea:focus,.feedback-modal-email input:focus{border:1px solid var(--feedback-modal-input-border-color-focused);outline:none}.feedback-modal-buttons{display:flex;flex-direction:column}.feedback-modal-buttons .feedback-modal-button{margin-bottom:20px}.feedback-modal-button{align-items:center;background-color:transparent;border:1px solid var(--feedback-modal-button-border-color);border-radius:var(--feedback-modal-button-border-radius);color:var(--feedback-modal-button-text-color);cursor:pointer;display:flex;font-size:var(--feedback-modal-button-font-size);font-weight:500;justify-content:center;min-height:40px;padding:5px 10px}.feedback-modal-button svg{margin-right:6px}.feedback-modal-button path{fill:var(--feedback-modal-button-icon-color)}.feedback-modal-button:hover path,.feedback-modal-button--active path{fill:var(--feedback-modal-button-icon-color-active)}.feedback-modal-button--submit{background-color:var(--feedback-modal-button-submit-bg-color);border:1px solid var(--feedback-modal-button-border-color-active);color:var(--feedback-modal-button-submit-text-color)}.feedback-modal-button:hover,.feedback-modal-button--active{background-color:var(--feedback-modal-button-bg-color-active);border:1px solid var(--feedback-modal-button-border-color-active);color:var(--feedback-modal-button-text-color-active)}.feedback-modal-button--submit:hover{background-color:var(--feedback-modal-button-submit-bg-color-hover);border:1px solid var(--feedback-modal-button-submit-border-color-hover);color:var(--feedback-modal-button-submit-text-color-hover)}.feedback-modal-input-heading{display:block;font-size:14px;font-weight:300;padding-bottom:10px}.feedback-modal-footer{font-size:12px;text-align:center}.feedback-modal-footer a{color:var(--feedback-modal-footer-link);font-weight:500;text-decoration:none}.feedback-logo,.feedback-footer-text{display:block;text-align:center;margin-top:5px}.feedback-footer-text{margin-top:10px;line-height:1.5}.feedback-modal-close{background-color:var(--feedback-modal-close-bg-color);border:0;border-radius:50%;cursor:pointer;height:22px;margin-left:auto;padding:0;width:22px}.feedback-modal-close svg{stroke:var(--feedback-modal-close-color)}.feedback-modal-screenshot{background-color:var(--feedback-modal-screenshot-bg-color);height:100%;left:0;position:fixed;top:0;width:100%;z-index:var(--feedback-modal-screnshot-z-index)}.feedback-modal-screenshot-header{align-items:center;background-color:var(--feedback-modal-screenshot-header-bg-color);border-radius:var(--feedback-modal-content-border-radius);box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .30), 0px 2px 6px 2px rgba(60, 64, 67, .15);box-sizing:border-box;color:var(--feedback-modal-screenshot-header-text-color);cursor:pointer;display:flex;left:50%;top:20px;transform:translateX(-50%);padding:10px;position:fixed;width:max-content;z-index:var(--feedback-modal-screenshot-header-z-index)}.feedback-modal-screenshot-close{height:24px;padding-left:10px;width:24px}.feedback-modal-screenshot-close svg{stroke:var(--feedback-modal-close-color)}.feedback-modal-message{font-size:var(--feedback-modal-message-font-size);margin-top:0}.feedback-modal-element-hover{background-color:transparent;cursor:pointer;border:1px solid var(--feedback-modal-element-hover-border-color)}.feedback-modal-element-selected{background-color:transparent;border:3px solid var(--feedback-modal-element-selected-border-color) !important;box-shadow:0 0 0 2px rgba(0, 123, 255, 0.3) !important}.screenshot-preview{display:inline-block;width:30px;height:30px;overflow:hidden;border-radius:4px;margin-right:10px;box-shadow:0 2px 4px rgba(0, 0, 0, 0.1);cursor:pointer;transition:transform 0.2s ease}.screenshot-preview:hover{transform:scale(1.1)}.screenshot-preview img{width:100%;height:100%;object-fit:cover}.screenshot-loading{display:inline-flex;align-items:center;margin-right:8px}@media screen and (min-width: 768px){.feedback-modal-content{max-width:var(--feedback-modal-content-max-width)}.feedback-modal-content.feedback-modal-content--bottom-right{bottom:var(--feedback-modal-content-position-bottom);left:initial;right:var(--feedback-modal-content-position-right);top:initial;transform:initial}.feedback-modal-content.feedback-modal-content--bottom-left{bottom:var(--feedback-modal-content-position-bottom);left:var(--feedback-modal-content-position-left);top:initial;transform:initial}.feedback-modal-content.feedback-modal-content--top-right{right:var(--feedback-modal-content-position-right);top:var(--feedback-modal-content-position-top);transform:initial}.feedback-modal-content.feedback-modal-content--top-left{left:var(--feedback-modal-content-position-left);top:var(--feedback-modal-content-position-top);transform:initial}.feedback-modal-content.feedback-modal-content--center-left{left:5px;right:auto;top:50%;transform:translateY(-50%)}.feedback-modal-content.feedback-modal-content--center-right{left:auto;right:5px;top:50%;transform:translateY(-50%)}.feedback-modal-content.feedback-modal-content--sidebar-left.feedback-modal-content--open,.feedback-modal-content.feedback-modal-content--sidebar-right.feedback-modal-content--open{transform:translateX(0)}.feedback-modal-content.feedback-modal-content--sidebar-left{max-width:var(--feedback-modal-content-sidebar-max-width);left:0;right:auto;height:100vh;top:0;transform:translateX(-100%);transition:transform 0.5s ease-in-out;border-radius:0}.feedback-modal-content.feedback-modal-content--sidebar-right{max-width:var(--feedback-modal-content-sidebar-max-width);left:auto;right:0;height:100vh;top:0;transform:translateX(100%);transition:transform 0.5s ease-in-out;border-radius:0}.feedback-modal-text textarea{height:150px;min-height:150px}.feedback-modal-content.feedback-modal-content--bottom-right{transform:translateY(20px)}.feedback-modal-content.feedback-modal-content--bottom-right.feedback-modal-content--open{transform:translateY(0)}.feedback-modal-content.feedback-modal-content--bottom-left{transform:translateY(20px)}.feedback-modal-content.feedback-modal-content--bottom-left.feedback-modal-content--open{transform:translateY(0)}.feedback-modal-content.feedback-modal-content--top-right{transform:translateY(-20px)}.feedback-modal-content.feedback-modal-content--top-right.feedback-modal-content--open{transform:translateY(0)}.feedback-modal-content.feedback-modal-content--top-left{transform:translateY(-20px)}.feedback-modal-content.feedback-modal-content--top-left.feedback-modal-content--open{transform:translateY(0)}}@keyframes feather-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.feather-loader{animation:feather-spin 1s linear infinite;display:block}.screenshot-error-notification{position:fixed;top:20px;left:50%;transform:translateX(-50%);z-index:10001;max-width:500px;width:90%;animation:slideDown 0.3s ease-out}@keyframes slideDown{from{opacity:0;transform:translateX(-50%) translateY(-20px)}to{opacity:1;transform:translateX(-50%) translateY(0)}}.screenshot-error-content{background:#fee;border:1px solid #fcc;border-radius:8px;padding:12px 16px;display:flex;align-items:center;gap:12px;box-shadow:0 4px 12px rgba(0, 0, 0, 0.15);color:#c53030}.screenshot-error-content svg:first-child{color:#e53e3e;flex-shrink:0}.screenshot-error-content span{flex:1;font-size:14px;line-height:1.4;font-weight:500}.error-close-btn{background:none;border:none;cursor:pointer;padding:4px;border-radius:4px;color:#c53030;flex-shrink:0;transition:background-color 0.2s ease}.error-close-btn:hover{background:rgba(197, 48, 48, 0.1)}";
1068
+
1069
+ const FeedbackModal = class {
1070
+ constructor(hostRef) {
1071
+ registerInstance(this, hostRef);
1072
+ this.feedbackSent = createEvent(this, "feedbackSent", 7);
1073
+ this.feedbackError = createEvent(this, "feedbackError", 7);
1074
+ this.onScrollDebounced = () => {
1075
+ clearTimeout(this.scrollTimeout);
1076
+ this.scrollTimeout = setTimeout(() => {
1077
+ document.documentElement.classList.remove('feedback-modal-screenshot-closing');
1078
+ document.documentElement.style.top = '';
1079
+ window.removeEventListener('scroll', this.onScrollDebounced);
1080
+ }, 200);
1081
+ };
1082
+ this.handleSubmit = async (event) => {
1083
+ event.preventDefault();
1084
+ if (this.isEmailRequired && !this.formEmail) {
1085
+ return;
1086
+ }
1087
+ this.resetOverflow();
1088
+ this.showScreenshotMode = false;
1089
+ this.showScreenshotTopBar = false;
1090
+ this.showModal = false;
1091
+ this.sending = true;
1092
+ try {
1093
+ const body = {
1094
+ url: window.location.href,
1095
+ message: this.formMessage,
1096
+ email: this.formEmail,
1097
+ project: this.project,
1098
+ screenshot: this.encodedScreenshot,
1099
+ rating: this.selectedRating,
1100
+ ratingMode: this.ratingMode,
1101
+ metadata: this.metadata,
1102
+ verification: this.formVerification,
1103
+ session: localStorage.getItem('pushfeedback_sessionid') || '',
1104
+ };
1105
+ const res = await fetch('https://app.pushfeedback.com/api/feedback/', {
1106
+ method: 'POST',
1107
+ body: JSON.stringify(body),
1108
+ headers: {
1109
+ 'Content-Type': 'application/json',
1110
+ },
1111
+ });
1112
+ if (res.status === 201) {
1113
+ const feedback_with_id = Object.assign(Object.assign({}, body), { id: await res.json() });
1114
+ this.feedbackSent.emit({ feedback: feedback_with_id });
1115
+ this.formSuccess = true;
1116
+ this.formError = false;
1117
+ }
1118
+ else {
1119
+ const errorText = await res.text();
1120
+ const response = {
1121
+ status: res.status,
1122
+ message: errorText,
1123
+ };
1124
+ this.feedbackError.emit({ error: response });
1125
+ this.formSuccess = false;
1126
+ this.formError = true;
1127
+ this.formErrorStatus = res.status;
1128
+ }
1129
+ }
1130
+ catch (error) {
1131
+ const response = {
1132
+ status: 500,
1133
+ message: error,
1134
+ };
1135
+ this.feedbackError.emit({ error: response });
1136
+ this.formSuccess = false;
1137
+ this.formError = true;
1138
+ this.formErrorStatus = 500;
1139
+ }
1140
+ finally {
1141
+ this.sending = false;
1142
+ this.showModal = true;
1143
+ }
1144
+ };
1145
+ this.close = () => {
1146
+ this.isAnimating = false;
1147
+ setTimeout(() => {
1148
+ this.sending = false;
1149
+ this.showModal = false;
1150
+ this.showScreenshotMode = false;
1151
+ this.showScreenshotTopBar = false;
1152
+ this.hasSelectedElement = false;
1153
+ this.encodedScreenshot = null;
1154
+ // Remove highlight from ALL selected elements
1155
+ document.querySelectorAll('.feedback-modal-element-selected').forEach(el => {
1156
+ el.classList.remove('feedback-modal-element-selected');
1157
+ });
1158
+ // Reset form states
1159
+ this.formSuccess = false;
1160
+ this.formError = false;
1161
+ this.formErrorStatus = 500;
1162
+ this.formMessage = '';
1163
+ this.formEmail = '';
1164
+ this.resetOverflow();
1165
+ }, 200);
1166
+ };
1167
+ // Handle screenshot events from canvas editor
1168
+ this.handleScreenshotReady = (event) => {
1169
+ this.encodedScreenshot = event.detail.screenshot;
1170
+ this.showModal = true;
1171
+ this.takingScreenshot = false;
1172
+ this.showCanvasEditor = false;
1173
+ this.autoStartCapture = false;
1174
+ };
1175
+ this.handleScreenshotCancelled = () => {
1176
+ this.showModal = true;
1177
+ this.takingScreenshot = false;
1178
+ this.showCanvasEditor = false;
1179
+ this.autoStartCapture = false;
1180
+ };
1181
+ this.handleScreenshotError = (event) => {
1182
+ console.error('Screenshot error:', event.detail.error);
1183
+ // Store error message to display in feedback modal
1184
+ this.screenshotError = event.detail.error;
1185
+ this.showScreenshotError = true;
1186
+ // Close canvas editor and return to feedback modal
1187
+ this.showModal = true;
1188
+ this.takingScreenshot = false;
1189
+ this.showCanvasEditor = false;
1190
+ this.autoStartCapture = false;
1191
+ // Auto-hide error after 8 seconds
1192
+ setTimeout(() => {
1193
+ this.showScreenshotError = false;
1194
+ }, 8000);
1195
+ };
1196
+ // Trigger screenshot capture
1197
+ this.openScreenShot = () => {
1198
+ this.showModal = false;
1199
+ this.takingScreenshot = true;
1200
+ this.autoStartCapture = true; // Auto-start new screenshot
1201
+ this.showCanvasEditor = true;
1202
+ };
1203
+ // Open canvas editor for existing screenshot
1204
+ this.openCanvasEditor = (event) => {
1205
+ if (event) {
1206
+ event.stopPropagation();
1207
+ }
1208
+ this.showModal = false;
1209
+ this.autoStartCapture = false; // Don't auto-start, just edit existing
1210
+ this.showCanvasEditor = true;
1211
+ };
1212
+ this.sending = false;
1213
+ this.formMessage = '';
1214
+ this.formEmail = '';
1215
+ this.formSuccess = false;
1216
+ this.formVerification = '';
1217
+ this.formError = false;
1218
+ this.formErrorStatus = 500;
1219
+ this.encodedScreenshot = undefined;
1220
+ this.isPrivacyChecked = false;
1221
+ this.whitelabel = false;
1222
+ this.selectedRating = -1;
1223
+ this.overlayVisible = false;
1224
+ this.isAnimating = false;
1225
+ this.takingScreenshot = false;
1226
+ this.showScreenshotError = false;
1227
+ this.screenshotError = '';
1228
+ this.showCanvasEditor = false;
1229
+ this.autoStartCapture = false;
1230
+ this.customFont = false;
1231
+ this.emailAddress = '';
1232
+ this.hideEmail = false;
1233
+ this.isEmailRequired = false;
1234
+ this.ratingMode = 'thumbs';
1235
+ this.hasSelectedElement = false;
1236
+ this.hidePrivacyPolicy = true;
1237
+ this.hideRating = false;
1238
+ this.hideScreenshotButton = false;
1239
+ this.project = '';
1240
+ this.showScreenshotMode = false;
1241
+ this.showScreenshotTopBar = false;
1242
+ this.showModal = false;
1243
+ this.rating = undefined;
1244
+ this.metadata = undefined;
1245
+ this.fetchData = true;
1246
+ this.emailPlaceholder = 'Email address (optional)';
1247
+ this.errorMessage = 'Please try again later.';
1248
+ this.errorMessage403 = 'The request URL does not match the one defined in PushFeedback for this project.';
1249
+ this.errorMessage404 = 'We could not find the provided project ID in PushFeedback.';
1250
+ this.messagePlaceholder = 'Comments';
1251
+ this.footerText = '';
1252
+ this.modalPosition = 'center';
1253
+ this.modalTitle = 'Share your feedback';
1254
+ this.modalTitleError = 'Oops!';
1255
+ this.modalTitleSuccess = 'Thanks for your feedback!';
1256
+ this.privacyPolicyText = "I have read and expressly consent to the terms of the <a href='https://pushfeedback.com/privacy'>Privacy Policy</a>.";
1257
+ this.ratingPlaceholder = 'Was this page helpful?';
1258
+ this.ratingStarsPlaceholder = 'How would you rate this page?';
1259
+ this.sendButtonText = 'Send';
1260
+ this.successMessage = '';
1261
+ this.screenshotEditorTitle = 'Edit screenshot';
1262
+ this.screenshotEditorCancelText = 'Cancel';
1263
+ this.screenshotEditorSaveText = 'Save';
1264
+ this.screenshotAttachedText = 'Screenshot attached';
1265
+ this.screenshotButtonText = 'Add a screenshot';
1266
+ this.screenshotTakingText = 'Taking screenshot...';
1267
+ this.screenshotEditTextButtonText = 'Edit text';
1268
+ this.screenshotSizeLabelText = 'Size:';
1269
+ this.screenshotBorderLabelText = 'Border:';
1270
+ this.screenshotEditTextPromptText = 'Edit text:';
1271
+ this.screenshotErrorGeneral = 'Failed to capture screenshot.';
1272
+ this.screenshotErrorPermission = 'Permission denied. Please allow screen sharing to take screenshots.';
1273
+ this.screenshotErrorNotSupported = 'Screen capture is not supported in this browser.';
1274
+ this.screenshotErrorNotFound = 'No screen sources available for capture.';
1275
+ this.screenshotErrorCancelled = 'Screenshot capture was cancelled.';
1276
+ this.screenshotErrorBrowserNotSupported = 'Your browser does not support screen capture. Please use a browser like Chrome, Firefox, or Safari on desktop.';
1277
+ this.screenshotErrorUnexpected = 'An unexpected error occurred. Please try again.';
1278
+ }
1279
+ componentWillLoad() {
1280
+ if (this.fetchData)
1281
+ this.fetchProjectData();
1282
+ this.formEmail = this.emailAddress;
1283
+ if (this.rating) {
1284
+ this.selectedRating = this.rating;
1285
+ }
1286
+ if (this.ratingMode == 'thumbs' && this.rating == 0) {
1287
+ this.selectedRating = 5;
1288
+ }
1289
+ }
1290
+ async fetchProjectData() {
1291
+ try {
1292
+ const response = await fetch('https://app.pushfeedback.com/api/projects/' + this.project + '/');
1293
+ const data = await response.json();
1294
+ this.whitelabel = data.whitelabel;
1295
+ }
1296
+ catch (error) {
1297
+ console.log(error);
1298
+ }
1299
+ }
1300
+ resetOverflow() {
1301
+ // Just clean up any stray classes, don't add/remove during screenshot
1302
+ document.documentElement.classList.remove('feedback-modal-screenshot-open');
1303
+ document.documentElement.classList.remove('feedback-modal-screenshot-open--scroll');
1304
+ document.documentElement.classList.remove('feedback-modal-screenshot-closing');
1305
+ }
1306
+ handleMessageInput(event) {
1307
+ this.formMessage = event.target.value;
1308
+ }
1309
+ handleEmailInput(event) {
1310
+ this.formEmail = event.target.value;
1311
+ }
1312
+ handleCheckboxChange(event) {
1313
+ this.isPrivacyChecked = event.target.checked;
1314
+ }
1315
+ handleVerification(event) {
1316
+ this.formVerification = event.target.value;
1317
+ }
1318
+ handleRatingChange(newRating) {
1319
+ this.selectedRating = newRating;
1320
+ }
1321
+ render() {
1322
+ return (h("div", { class: `feedback-modal-wrapper ${this.customFont ? 'feedback-modal-wrapper--custom-font' : ''}` }, this.showCanvasEditor && (h("canvas-editor", { ref: (el) => this.canvasEditorRef = el, "canvas-editor-title": this.screenshotEditorTitle, "canvas-editor-cancel-text": this.screenshotEditorCancelText, "canvas-editor-save-text": this.screenshotEditorSaveText, "screenshot-taking-text": this.screenshotTakingText, "screenshot-attached-text": this.screenshotAttachedText, "screenshot-button-text": this.screenshotButtonText, "auto-start-screenshot": this.autoStartCapture, "existing-screenshot": this.encodedScreenshot || '', "edit-text-button-text": this.screenshotEditTextButtonText, "size-label-text": this.screenshotSizeLabelText, "border-label-text": this.screenshotBorderLabelText, "edit-text-prompt-text": this.screenshotEditTextPromptText, "screenshot-error-general": this.screenshotErrorGeneral, "screenshot-error-permission": this.screenshotErrorPermission, "screenshot-error-not-supported": this.screenshotErrorNotSupported, "screenshot-error-not-found": this.screenshotErrorNotFound, "screenshot-error-cancelled": this.screenshotErrorCancelled, "screenshot-error-browser-not-supported": this.screenshotErrorBrowserNotSupported, "screenshot-error-unexpected": this.screenshotErrorUnexpected, onScreenshotReady: this.handleScreenshotReady, onScreenshotCancelled: this.handleScreenshotCancelled, onScreenshotFailed: this.handleScreenshotError })), this.showScreenshotError && (h("div", { class: "screenshot-error-notification" }, h("div", { class: "screenshot-error-content" }, h("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("circle", { cx: "12", cy: "12", r: "10" }), h("line", { x1: "15", y1: "9", x2: "9", y2: "15" }), h("line", { x1: "9", y1: "9", x2: "15", y2: "15" })), h("span", null, this.screenshotError), h("button", { class: "error-close-btn", onClick: () => this.showScreenshotError = false, title: "Close" }, h("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), h("line", { x1: "6", y1: "6", x2: "18", y2: "18" })))))), this.showModal && (h("div", { class: `feedback-overlay ${this.isAnimating ? 'feedback-overlay--visible' : ''}` })), this.showModal && (h("div", { class: `feedback-modal-content feedback-modal-content--${this.modalPosition} ${this.isAnimating ? 'feedback-modal-content--open' : ''}`, ref: (el) => (this.modalContent = el) }, h("div", { class: "feedback-modal-header" }, !this.formSuccess && !this.formError ? (h("span", null, this.modalTitle)) : this.formSuccess ? (h("span", null, this.modalTitleSuccess)) : (h("span", null, this.modalTitleError)), h("button", { class: "feedback-modal-close", onClick: this.close }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", stroke: "#191919", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "feather feather-x" }, h("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), h("line", { x1: "6", y1: "6", x2: "18", y2: "18" })))), h("div", { class: "feedback-modal-body" }, !this.formSuccess && !this.formError ? (h("form", { onSubmit: this.handleSubmit }, !this.hideRating && (h("div", { class: "feedback-modal-rating" }, this.ratingMode === 'thumbs' ? (h("div", { class: "feedback-modal-rating-content" }, h("span", { class: "feedback-modal-input-heading" }, this.ratingPlaceholder), h("div", { class: "feedback-modal-rating-buttons feedback-modal-rating-buttons--thumbs" }, h("button", { title: "Yes", class: `feedback-modal-rating-button ${this.selectedRating === 1
1323
+ ? 'feedback-modal-rating-button--selected'
1324
+ : ''}`, onClick: (event) => {
1325
+ event.preventDefault();
1326
+ this.handleRatingChange(1);
1327
+ } }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "#5F6368", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("path", { d: "M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3" }))), h("button", { title: "No", class: `feedback-modal-rating-button ${this.selectedRating === 5
1328
+ ? 'feedback-modal-rating-button--selected'
1329
+ : ''}`, onClick: (event) => {
1330
+ event.preventDefault();
1331
+ this.handleRatingChange(5);
1332
+ } }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "#5F6368", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("path", { d: "M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17" })))))) : (h("div", { class: "feedback-modal-rating-content" }, h("span", { class: "feedback-modal-input-heading" }, this.ratingStarsPlaceholder), h("div", { class: "feedback-modal-rating-buttons feedback-modal-rating-buttons--stars" }, [1, 2, 3, 4, 5].map((rating) => (h("button", { key: rating, class: `feedback-modal-rating-button ${this.selectedRating >= rating
1333
+ ? 'feedback-modal-rating-button--selected'
1334
+ : ''}`, onClick: (event) => {
1335
+ event.preventDefault();
1336
+ this.handleRatingChange(rating);
1337
+ } }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "28", height: "28", viewBox: "0 0 24 24", fill: "none", stroke: "#5F6368", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("polygon", { points: "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" })))))))))), h("div", { class: "feedback-modal-text" }, h("textarea", { placeholder: this.messagePlaceholder, value: this.formMessage, onInput: (event) => this.handleMessageInput(event) })), !this.hideEmail && (h("div", { class: "feedback-modal-email" }, h("input", { placeholder: this.emailPlaceholder, type: "email", onInput: (event) => this.handleEmailInput(event), value: this.formEmail, required: this.isEmailRequired }))), h("div", { class: "feedback-verification" }, h("input", { type: "text", name: "verification", style: { display: 'none' }, onInput: (event) => this.handleVerification(event), value: this.formVerification })), !this.hidePrivacyPolicy && (h("div", { class: "feedback-modal-privacy" }, h("input", { type: "checkbox", id: "privacyPolicy", onChange: (ev) => this.handleCheckboxChange(ev), required: true }), h("span", { innerHTML: this.privacyPolicyText }))), h("div", { class: `feedback-modal-buttons ${this.hideScreenshotButton ? 'single' : ''}` }, !this.hideScreenshotButton && (h("button", { type: "button", class: `feedback-modal-button feedback-modal-button--screenshot ${this.encodedScreenshot ? 'feedback-modal-button--active' : ''}`, onClick: this.openScreenShot, disabled: this.sending || this.takingScreenshot }, this.encodedScreenshot && (h("div", { class: "screenshot-preview", onClick: this.openCanvasEditor }, h("img", { src: this.encodedScreenshot, alt: "Screenshot Preview" }))), !this.encodedScreenshot && !this.takingScreenshot && (h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24", viewBox: "0 -960 960 960", width: "24" }, h("path", { d: "M680-80v-120H560v-80h120v-120h80v120h120v80H760v120h-80ZM200-200v-200h80v120h120v80H200Zm0-360v-200h200v80H280v120h-80Zm480 0v-120H560v-80h200v200h-80Z" }))), this.takingScreenshot && (h("div", { class: "screenshot-loading" }, h("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "#666", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "feather-loader" }, h("line", { x1: "12", y1: "2", x2: "12", y2: "6" }), h("line", { x1: "12", y1: "18", x2: "12", y2: "22" }), h("line", { x1: "4.93", y1: "4.93", x2: "7.76", y2: "7.76" }), h("line", { x1: "16.24", y1: "16.24", x2: "19.07", y2: "19.07" }), h("line", { x1: "2", y1: "12", x2: "6", y2: "12" }), h("line", { x1: "18", y1: "12", x2: "22", y2: "12" }), h("line", { x1: "4.93", y1: "19.07", x2: "7.76", y2: "16.24" }), h("line", { x1: "16.24", y1: "7.76", x2: "19.07", y2: "4.93" })))), this.takingScreenshot ? this.screenshotTakingText :
1338
+ this.encodedScreenshot ? this.screenshotAttachedText : this.screenshotButtonText)), h("button", { class: "feedback-modal-button feedback-modal-button--submit", type: "submit", disabled: this.sending }, this.sendButtonText)))) : this.formSuccess && !this.formError ? (h("div", { class: "feedback-modal-success" }, h("p", { class: "feedback-modal-message" }, this.successMessage))) : this.formError && this.formErrorStatus == 404 ? (h("p", { class: "feedback-modal-message" }, this.errorMessage404)) : this.formError && this.formErrorStatus == 403 ? (h("p", { class: "feedback-modal-message" }, this.errorMessage403)) : this.formError ? (h("p", { class: "feedback-modal-message" }, this.errorMessage)) : (h("span", null))), h("div", { class: "feedback-modal-footer" }, h("div", { class: "feedback-logo", style: { display: this.whitelabel ? 'none' : 'block' } }, "Powered by", ' ', h("a", { target: "_blank", href: "https://pushfeedback.com" }, "PushFeedback.com")), this.footerText && (h("div", { class: "feedback-footer-text" }, h("span", { innerHTML: this.footerText }))))))));
1339
+ }
1340
+ componentDidRender() {
1341
+ if (this.showModal) {
1342
+ requestAnimationFrame(() => {
1343
+ this.overlayVisible = true;
1344
+ });
1345
+ }
1346
+ }
1347
+ async openModal() {
1348
+ this.showModal = true;
1349
+ requestAnimationFrame(() => {
1350
+ requestAnimationFrame(() => {
1351
+ this.isAnimating = true;
1352
+ });
1353
+ });
1354
+ }
1355
+ };
1356
+ FeedbackModal.style = feedbackModalCss;
1357
+
1358
+ export { CanvasEditor as canvas_editor, FeedbackButton as feedback_button, FeedbackModal as feedback_modal };