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E,MAAO,GACL,QAAQ,IAAI,6BAA8B,GAC1C,EAAO,EACX,CACJ,GACJ","file":"/npm/client-side-image-resize@1.1.2/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/client-side-image-resize@1.1.2/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","module.exports = function({ file, width, height, type }) {\n    return new Promise(function (resolve, reject) {\n        let allow = ['jpg', 'gif', 'bmp', 'png', 'jpeg', 'svg'];\n        try {\n            if (file.name && file.name.split(\".\").reverse()[0] && allow.includes(file.name.split(\".\").reverse()[0].toLowerCase()) && file.size && file.type) {\n                let imageType = type ? type : 'jpeg';\n                const imgWidth = width ? width : 'auto';\n                const imgHeight = height ? height : 'auto';\n                if (imgWidth === 'auto' && imgHeight === 'auto') {\n                    throw new Error('Please define width or height');\n                }\n                const fileName = file.name;\n                const reader = new FileReader();\n                reader.readAsDataURL(file);\n                reader.onload = event => {\n                    const img = new Image();\n                    img.src = event.target.result;\n                    img.onload = () => {\n                        const elem = document.createElement('canvas');\n                        // Set propotional image size\n                        if (imgWidth !== 'auto' && imgHeight !== 'auto') {\n                            elem.width = imgWidth;\n                            elem.height = imgHeight;\n                        } else if (imgWidth !== 'auto') {\n                            elem.width = imgWidth;\n                            elem.height = img.height * (imgWidth / img.width);\n                        } else if (imgHeight !== 'auto') {\n                            elem.height = imgHeight;\n                            elem.width = img.width * (imgHeight / img.height);\n                        }\n                        const ctx = elem.getContext('2d');\n                        ctx.drawImage(img, 0, 0, elem.width, elem.height);\n                        ctx.canvas.toBlob((blob) => {\n                            const file = new File([blob], fileName, {\n                                type: `image/${imageType.toLowerCase()}`,\n                                lastModified: Date.now()\n                            });\n                            resolve(file)\n                        }, 'image/jpeg', 1);\n                    }, reader.onerror = error => reject(error);\n                };\n            } else reject('File not supported!')\n        } catch (error) {\n            console.log(\"Error while image resize: \", error);\n            reject(error)\n        }\n    })\n}\n"]}