{"version":3,"file":"ImageUploader-bad42a24.js","sources":["../../../../js/icons/src/Camera.svelte","../../../../js/icons/src/Circle.svelte","../../../../js/icons/src/Square.svelte","../../../../js/image/shared/utils.ts","../../../../js/image/shared/ImagePreview.svelte","../../../../js/image/shared/WebcamPermissions.svelte","../../../../js/image/shared/Webcam.svelte","../../../../js/image/shared/ClearImage.svelte","../../../../js/image/shared/ImageUploader.svelte"],"sourcesContent":["\n","\n","\n","export const get_coordinates_of_clicked_image = (\n\tevt: MouseEvent\n): [number, number] | null => {\n\tlet image;\n\tif (evt.currentTarget instanceof Element) {\n\t\timage = evt.currentTarget.querySelector(\"img\") as HTMLImageElement;\n\t} else {\n\t\treturn [NaN, NaN];\n\t}\n\n\tconst imageRect = image.getBoundingClientRect();\n\tconst xScale = image.naturalWidth / imageRect.width;\n\tconst yScale = image.naturalHeight / imageRect.height;\n\tif (xScale > yScale) {\n\t\tconst displayed_height = image.naturalHeight / xScale;\n\t\tconst y_offset = (imageRect.height - displayed_height) / 2;\n\t\tvar x = Math.round((evt.clientX - imageRect.left) * xScale);\n\t\tvar y = Math.round((evt.clientY - imageRect.top - y_offset) * xScale);\n\t} else {\n\t\tconst displayed_width = image.naturalWidth / yScale;\n\t\tconst x_offset = (imageRect.width - displayed_width) / 2;\n\t\tvar x = Math.round((evt.clientX - imageRect.left - x_offset) * yScale);\n\t\tvar y = Math.round((evt.clientY - imageRect.top) * yScale);\n\t}\n\tif (x < 0 || x >= image.naturalWidth || y < 0 || y >= image.naturalHeight) {\n\t\treturn null;\n\t}\n\treturn [x, y];\n};\n","\n\n