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AI,MAAM,2BAEpB,GAAiB,iBAAN,GAA+B,iBAAN,EAChC,MAAM,IAAI,MAAM,2BAEpB,OAAO,EAAI,QAAQ,cAAc,KAAM,EAAG,EAAG,EAAG,EACpD,GAEJ,OAAO,CACX,CA/dA,OAAO,eAAe,QAAS,YAAa,CAAE,YAAY,EAAM,IAAK,WAAc,OAAO,eAAe,SAAW,IACpH,aAAa,QAAQ,wBAAyB","file":"/npm/@jimp/core@1.6.1/dist/commonjs/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@jimp/core@1.6.1/dist/commonjs/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","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n    if (k2 === undefined) k2 = k;\n    var desc = Object.getOwnPropertyDescriptor(m, k);\n    if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n      desc = { enumerable: true, get: function() { return m[k]; } };\n    }\n    Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n    if (k2 === undefined) k2 = k;\n    o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n    for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.composite = exports.getExifOrientation = void 0;\nexports.createJimp = createJimp;\nconst types_1 = require(\"@jimp/types\");\nconst utils_1 = require(\"@jimp/utils\");\nconst await_to_js_1 = require(\"await-to-js\");\nconst file_ops_1 = require(\"@jimp/file-ops\");\nconst lite_js_1 = __importDefault(require(\"mime/lite.js\"));\nconst composite_js_1 = require(\"./utils/composite.js\");\nconst image_bitmap_js_1 = require(\"./utils/image-bitmap.js\");\nconst emptyBitmap = {\n    data: Buffer.alloc(0),\n    width: 0,\n    height: 0,\n};\n/**\n * Prepare a Buffer object from the arrayBuffer.\n */\nfunction bufferFromArrayBuffer(arrayBuffer) {\n    const buffer = Buffer.alloc(arrayBuffer.byteLength);\n    const view = new Uint8Array(arrayBuffer);\n    for (let i = 0; i < buffer.length; ++i) {\n        buffer[i] = view[i];\n    }\n    return buffer;\n}\nasync function detectFileTypeFromBuffer(buffer) {\n    const { fileTypeFromBuffer } = await import(\"file-type\");\n    return fileTypeFromBuffer(buffer instanceof ArrayBuffer\n        ? buffer\n        : new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength));\n}\nvar image_bitmap_js_2 = require(\"./utils/image-bitmap.js\");\nObject.defineProperty(exports, \"getExifOrientation\", { enumerable: true, get: function () { return image_bitmap_js_2.getExifOrientation; } });\nvar composite_js_2 = require(\"./utils/composite.js\");\nObject.defineProperty(exports, \"composite\", { enumerable: true, get: function () { return composite_js_2.composite; } });\n__exportStar(require(\"./utils/constants.js\"), exports);\n/**\n * Create a Jimp class that support the given image formats and methods\n */\nfunction createJimp({ plugins: pluginsArg, formats: formatsArg, } = {}) {\n    const plugins = pluginsArg || [];\n    const formats = (formatsArg || []).map((format) => format());\n    const CustomJimp = class Jimp {\n        /**\n         * The bitmap data of the image\n         */\n        bitmap = emptyBitmap;\n        /**  Default color to use for new pixels */\n        background = 0x00000000;\n        /** Formats that can be used with Jimp */\n        formats = [];\n        /** The original MIME type of the image */\n        mime;\n        constructor(options = emptyBitmap) {\n            // Add the formats\n            this.formats = formats;\n            if (\"data\" in options) {\n                this.bitmap = options;\n            }\n            else {\n                this.bitmap = {\n                    data: Buffer.alloc(options.width * options.height * 4),\n                    width: options.width,\n                    height: options.height,\n                };\n                if (options.color) {\n                    this.background =\n                        typeof options.color === \"string\"\n                            ? (0, utils_1.cssColorToHex)(options.color)\n                            : options.color;\n                    for (let i = 0; i < this.bitmap.data.length; i += 4) {\n                        this.bitmap.data.writeUInt32BE(this.background, i);\n                    }\n                }\n            }\n            // Add the plugins\n            for (const methods of plugins) {\n                for (const key in methods) {\n                    this[key] = (...args) => {\n                        const result = methods[key]?.(this, ...args);\n                        if (typeof result === \"object\" && \"bitmap\" in result) {\n                            this.bitmap = result.bitmap;\n                            return this;\n                        }\n                        return result;\n                    };\n                }\n            }\n        }\n        /**\n         * Create a Jimp instance from a URL, a file path, or a Buffer\n         * @example\n         * ```ts\n         * import { Jimp } from \"jimp\";\n         *\n         * // Read from a file path\n         * const image = await Jimp.read(\"test/image.png\");\n         *\n         * // Read from a URL\n         * const image = await Jimp.read(\"https://upload.wikimedia.org/wikipedia/commons/0/01/Bot-Test.jpg\");\n         * ```\n         */\n        static async read(url, options) {\n            if (Buffer.isBuffer(url) || url instanceof ArrayBuffer) {\n                return this.fromBuffer(url);\n            }\n            if ((0, file_ops_1.existsSync)(url)) {\n                return this.fromBuffer(await (0, file_ops_1.readFile)(url));\n            }\n            const [fetchErr, response] = await (0, await_to_js_1.to)(fetch(url));\n            if (fetchErr) {\n                throw new Error(`Could not load Buffer from URL: ${url}`);\n            }\n            if (!response.ok) {\n                throw new Error(`HTTP Status ${response.status} for url ${url}`);\n            }\n            const [arrayBufferErr, data] = await (0, await_to_js_1.to)(response.arrayBuffer());\n            if (arrayBufferErr) {\n                throw new Error(`Could not load Buffer from ${url}`);\n            }\n            const buffer = bufferFromArrayBuffer(data);\n            return this.fromBuffer(buffer, options);\n        }\n        /**\n         * Create a Jimp instance from a bitmap.\n         * The difference between this and just using the constructor is that this will\n         * convert raw image data into the bitmap format that Jimp uses.\n         *\n         * @example\n         * ```ts\n         * import { Jimp } from \"jimp\";\n         *\n         * const image = Jimp.fromBitmap({\n         *   data: Buffer.from([\n         *     0xffffffff, 0xffffffff, 0xffffffff,\n         *     0xffffffff, 0xffffffff, 0xffffffff,\n         *     0xffffffff, 0xffffffff, 0xffffffff,\n         *   ]),\n         *   width: 3,\n         *   height: 3,\n         * });\n         * ```\n         */\n        static fromBitmap(bitmap) {\n            let data;\n            if (bitmap.data instanceof Buffer) {\n                data = Buffer.from(bitmap.data);\n            }\n            if (bitmap.data instanceof Uint8Array ||\n                bitmap.data instanceof Uint8ClampedArray) {\n                data = Buffer.from(bitmap.data.buffer);\n            }\n            if (Array.isArray(bitmap.data)) {\n                data = Buffer.concat(bitmap.data.map((hex) => Buffer.from(hex.toString(16).padStart(8, \"0\"), \"hex\")));\n            }\n            if (!data) {\n                throw new Error(\"data must be a Buffer\");\n            }\n            if (typeof bitmap.height !== \"number\" ||\n                typeof bitmap.width !== \"number\") {\n                throw new Error(\"bitmap must have width and height\");\n            }\n            return new CustomJimp({\n                height: bitmap.height,\n                width: bitmap.width,\n                data,\n            });\n        }\n        /**\n         * Parse a bitmap with the loaded image types.\n         *\n         * @param buffer Raw image data\n         * @example\n         * ```ts\n         * import { Jimp } from \"jimp\";\n         *\n         * const buffer = await fs.readFile(\"test/image.png\");\n         * const image = await Jimp.fromBuffer(buffer);\n         * ```\n         */\n        static async fromBuffer(buffer, options) {\n            const actualBuffer = buffer instanceof ArrayBuffer ? bufferFromArrayBuffer(buffer) : buffer;\n            const mime = await detectFileTypeFromBuffer(actualBuffer);\n            if (!mime || !mime.mime) {\n                throw new Error(\"Could not find MIME for Buffer\");\n            }\n            const format = formats.find((format) => format.mime === mime.mime);\n            if (!format || !format.decode) {\n                throw new Error(`Mime type ${mime.mime} does not support decoding`);\n            }\n            const image = new CustomJimp(await format.decode(actualBuffer, options?.[format.mime]));\n            image.mime = mime.mime;\n            (0, image_bitmap_js_1.attemptExifRotate)(image, actualBuffer);\n            return image;\n        }\n        /**\n         * Nicely format Jimp object when sent to the console e.g. console.log(image)\n         * @returns Pretty printed jimp object\n         * @example\n         * ```ts\n         * import { Jimp } from \"jimp\";\n         *\n         * const image = await Jimp.read(\"test/image.png\");\n         *\n         * console.log(image);\n         * ```\n         */\n        inspect() {\n            return (\"<Jimp \" +\n                (this.bitmap === emptyBitmap\n                    ? \"pending...\"\n                    : this.bitmap.width + \"x\" + this.bitmap.height) +\n                \">\");\n        }\n        /**\n         * Nicely format Jimp object when converted to a string\n         * @returns pretty printed\n         */\n        toString() {\n            return \"[object Jimp]\";\n        }\n        /** Get the width of the image */\n        get width() {\n            return this.bitmap.width;\n        }\n        /** Get the height of the image */\n        get height() {\n            return this.bitmap.height;\n        }\n        /**\n         * Converts the Jimp instance to an image buffer\n         * @param mime The mime type to export to\n         * @param options The options to use when exporting\n         * @example\n         * ```ts\n         * import { Jimp } from \"jimp\";\n         * import { promises as fs } from \"fs\";\n         *\n         * const image = new Jimp({ width: 3, height: 3, color: 0xffffffff });\n         *\n         * await image.getBuffer(\"image/jpeg\", {\n         *   quality: 50,\n         * });\n         * ```\n         */\n        async getBuffer(mime, options) {\n            const format = this.formats.find((format) => format.mime === mime);\n            if (!format || !format.encode) {\n                throw new Error(`Unsupported MIME type: ${mime}`);\n            }\n            let outputImage;\n            if (format.hasAlpha) {\n                // eslint-disable-next-line @typescript-eslint/no-this-alias\n                outputImage = this;\n            }\n            else {\n                outputImage = new CustomJimp({\n                    width: this.bitmap.width,\n                    height: this.bitmap.height,\n                    color: this.background,\n                });\n                (0, composite_js_1.composite)(outputImage, this);\n            }\n            return format.encode(outputImage.bitmap, options);\n        }\n        /**\n         * Converts the image to a base 64 string\n         *\n         * @param mime The mime type to export to\n         * @param options The options to use when exporting\n         * @example\n         * ```ts\n         * import { Jimp } from \"jimp\";\n         *\n         * const image = Jimp.fromBuffer(Buffer.from([\n         *   0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,\n         *   0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,\n         *   0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,\n         * ]));\n         *\n         * const base64 = image.getBase64(\"image/jpeg\", {\n         *   quality: 50,\n         * });\n         * ```\n         */\n        async getBase64(mime, options) {\n            const data = await this.getBuffer(mime, options);\n            return \"data:\" + mime + \";base64,\" + data.toString(\"base64\");\n        }\n        /**\n         * Write the image to a file\n         * @param path the path to write the image to\n         * @param options the options to use when writing the image\n         * @example\n         * ```ts\n         * import { Jimp } from \"jimp\";\n         *\n         * const image = Jimp.fromBuffer(Buffer.from([\n         *   0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,\n         *   0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,\n         *   0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,\n         * ]));\n         *\n         * await image.write(\"test/output.png\");\n         * ```\n         */\n        async write(path, options) {\n            const mimeType = lite_js_1.default.getType(path);\n            await (0, file_ops_1.writeFile)(path, await this.getBuffer(mimeType, options));\n        }\n        /**\n         * Clone the image into a new Jimp instance.\n         * @param this\n         * @returns A new Jimp instance\n         * @example\n         * ```ts\n         * import { Jimp } from \"jimp\";\n         *\n         * const image = new Jimp({ width: 3, height: 3, color: 0xffffffff });\n         *\n         * const clone = image.clone();\n         * ```\n         */\n        clone() {\n            return new CustomJimp({\n                ...this.bitmap,\n                data: Buffer.from(this.bitmap.data),\n            });\n        }\n        /**\n         * Returns the offset of a pixel in the bitmap buffer\n         * @param x the x coordinate\n         * @param y the y coordinate\n         * @param edgeHandling (optional) define how to sum pixels from outside the border\n         * @returns the index of the pixel or -1 if not found\n         * @example\n         * ```ts\n         * import { Jimp } from \"jimp\";\n         *\n         * const image = new Jimp({ width: 3, height: 3, color: 0xffffffff });\n         *\n         * image.getPixelIndex(1, 1); // 2\n         * ```\n         */\n        getPixelIndex(x, y, edgeHandling) {\n            let xi;\n            let yi;\n            if (!edgeHandling) {\n                edgeHandling = types_1.Edge.EXTEND;\n            }\n            if (typeof x !== \"number\" || typeof y !== \"number\") {\n                throw new Error(\"x and y must be numbers\");\n            }\n            // round input\n            x = Math.round(x);\n            y = Math.round(y);\n            xi = x;\n            yi = y;\n            if (edgeHandling === types_1.Edge.EXTEND) {\n                if (x < 0)\n                    xi = 0;\n                if (x >= this.bitmap.width)\n                    xi = this.bitmap.width - 1;\n                if (y < 0)\n                    yi = 0;\n                if (y >= this.bitmap.height)\n                    yi = this.bitmap.height - 1;\n            }\n            if (edgeHandling === types_1.Edge.WRAP) {\n                if (x < 0) {\n                    xi = this.bitmap.width + x;\n                }\n                if (x >= this.bitmap.width) {\n                    xi = x % this.bitmap.width;\n                }\n                if (y < 0) {\n                    yi = this.bitmap.height + y;\n                }\n                if (y >= this.bitmap.height) {\n                    yi = y % this.bitmap.height;\n                }\n            }\n            let i = (this.bitmap.width * yi + xi) << 2;\n            // if out of bounds index is -1\n            if (xi < 0 || xi >= this.bitmap.width) {\n                i = -1;\n            }\n            if (yi < 0 || yi >= this.bitmap.height) {\n                i = -1;\n            }\n            return i;\n        }\n        /**\n         * Returns the hex color value of a pixel\n         * @param x the x coordinate\n         * @param y the y coordinate\n         * @returns the color of the pixel\n         * @example\n         * ```ts\n         * import { Jimp } from \"jimp\";\n         *\n         * const image = new Jimp({ width: 3, height: 3, color: 0xffffffff });\n         *\n         * image.getPixelColor(1, 1); // 0xffffffff\n         * ```\n         */\n        getPixelColor(x, y) {\n            if (typeof x !== \"number\" || typeof y !== \"number\") {\n                throw new Error(\"x and y must be numbers\");\n            }\n            const idx = this.getPixelIndex(x, y);\n            return this.bitmap.data.readUInt32BE(idx);\n        }\n        /**\n         * Sets the hex colour value of a pixel\n         *\n         * @param hex color to set\n         * @param x the x coordinate\n         * @param y the y coordinate\n         *\n         * @example\n         * ```ts\n         * import { Jimp } from \"jimp\";\n         *\n         * const image = new Jimp({ width: 3, height: 3, color: 0xffffffff });\n         *\n         * image.setPixelColor(0xff0000ff, 0, 0);\n         * ```\n         */\n        setPixelColor(hex, x, y) {\n            if (typeof hex !== \"number\" ||\n                typeof x !== \"number\" ||\n                typeof y !== \"number\") {\n                throw new Error(\"hex, x and y must be numbers\");\n            }\n            const idx = this.getPixelIndex(x, y);\n            this.bitmap.data.writeUInt32BE(hex, idx);\n            return this;\n        }\n        /**\n         * Determine if the image contains opaque pixels.\n         *\n         * @example\n         * ```ts\n         * import { Jimp } from \"jimp\";\n         *\n         * const image = new Jimp({ width: 3, height: 3, color: 0xffffffaa });\n         * const image2 = new Jimp({ width: 3, height: 3, color: 0xff0000ff });\n         *\n         * image.hasAlpha(); // false\n         * image2.hasAlpha(); // true\n         * ```\n         */\n        hasAlpha() {\n            const { width, height, data } = this.bitmap;\n            const byteLen = (width * height) << 2;\n            for (let idx = 3; idx < byteLen; idx += 4) {\n                if (data[idx] !== 0xff) {\n                    return true;\n                }\n            }\n            return false;\n        }\n        /**\n         * Composites a source image over to this image respecting alpha channels\n         * @param src the source Jimp instance\n         * @param x the x position to blit the image\n         * @param y the y position to blit the image\n         * @param options determine what mode to use\n         * @example\n         * ```ts\n         * import { Jimp } from \"jimp\";\n         *\n         * const image = new Jimp({ width: 10, height: 10, color: 0xffffffff });\n         * const image2 = new Jimp({ width: 3, height: 3, color: 0xff0000ff });\n         *\n         * image.composite(image2, 3, 3);\n         * ```\n         */\n        composite(src, x = 0, y = 0, options = {}) {\n            return (0, composite_js_1.composite)(this, src, x, y, options);\n        }\n        scan(x, y, w, h, f) {\n            return (0, utils_1.scan)(this, x, y, w, h, f);\n        }\n        /**\n         * Iterate scan through a region of the bitmap\n         * @param x the x coordinate to begin the scan at\n         * @param y the y coordinate to begin the scan at\n         * @param w the width of the scan region\n         * @param h the height of the scan region\n         * @example\n         * ```ts\n         * import { Jimp } from \"jimp\";\n         *\n         * const image = new Jimp({ width: 3, height: 3, color: 0xffffffff });\n         *\n         * for (const { x, y, idx, image } of j.scanIterator()) {\n         *   // do something with the pixel\n         * }\n         * ```\n         */\n        scanIterator(x = 0, y = 0, w = this.bitmap.width, h = this.bitmap.height) {\n            if (typeof x !== \"number\" || typeof y !== \"number\") {\n                throw new Error(\"x and y must be numbers\");\n            }\n            if (typeof w !== \"number\" || typeof h !== \"number\") {\n                throw new Error(\"w and h must be numbers\");\n            }\n            return (0, utils_1.scanIterator)(this, x, y, w, h);\n        }\n    };\n    return CustomJimp;\n}\n"]}