UNPKG

image-blob-reduce

Version:

High quality image resizing for blobs in browsers (`pica` wrapper with some sugar)

1 lines 176 kB
{"version":3,"file":"image-blob-reduce.browser.min.mjs","names":["_typeof","toPrimitive","toPropertyKey","_defineProperty","ownKeys","_objectSpread2"],"sources":["../node_modules/pica/dist/pica.mjs","../src/image_traverse.ts","../src/jpeg_plugins.ts","../src/index.ts"],"sourcesContent":["/*!\n\npica\nhttps://github.com/nodeca/pica\n\n*/\nvar BASE64_MAP = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\nfunction base64decode(str) {\n\tconst input = str.replace(/[\\r\\n=]/g, \"\"), max = input.length;\n\tconst out = new Uint8Array(max * 3 >> 2);\n\tlet bits = 0;\n\tlet ptr = 0;\n\tfor (let idx = 0; idx < max; idx++) {\n\t\tif (idx % 4 === 0 && idx) {\n\t\t\tout[ptr++] = bits >> 16 & 255;\n\t\t\tout[ptr++] = bits >> 8 & 255;\n\t\t\tout[ptr++] = bits & 255;\n\t\t}\n\t\tbits = bits << 6 | BASE64_MAP.indexOf(input.charAt(idx));\n\t}\n\tconst tailbits = max % 4 * 6;\n\tif (tailbits === 0) {\n\t\tout[ptr++] = bits >> 16 & 255;\n\t\tout[ptr++] = bits >> 8 & 255;\n\t\tout[ptr++] = bits & 255;\n\t} else if (tailbits === 18) {\n\t\tout[ptr++] = bits >> 10 & 255;\n\t\tout[ptr++] = bits >> 2 & 255;\n\t} else if (tailbits === 12) out[ptr++] = bits >> 4 & 255;\n\treturn out;\n}\nvar wa;\nfunction hasWebAssembly() {\n\tif (typeof wa !== \"undefined\") return wa;\n\twa = false;\n\tif (typeof WebAssembly === \"undefined\") return wa;\n\ttry {\n\t\tconst bin = new Uint8Array([\n\t\t\t0,\n\t\t\t97,\n\t\t\t115,\n\t\t\t109,\n\t\t\t1,\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\t1,\n\t\t\t6,\n\t\t\t1,\n\t\t\t96,\n\t\t\t1,\n\t\t\t127,\n\t\t\t1,\n\t\t\t127,\n\t\t\t3,\n\t\t\t2,\n\t\t\t1,\n\t\t\t0,\n\t\t\t5,\n\t\t\t3,\n\t\t\t1,\n\t\t\t0,\n\t\t\t1,\n\t\t\t7,\n\t\t\t8,\n\t\t\t1,\n\t\t\t4,\n\t\t\t116,\n\t\t\t101,\n\t\t\t115,\n\t\t\t116,\n\t\t\t0,\n\t\t\t0,\n\t\t\t10,\n\t\t\t16,\n\t\t\t1,\n\t\t\t14,\n\t\t\t0,\n\t\t\t32,\n\t\t\t0,\n\t\t\t65,\n\t\t\t1,\n\t\t\t54,\n\t\t\t2,\n\t\t\t0,\n\t\t\t32,\n\t\t\t0,\n\t\t\t40,\n\t\t\t2,\n\t\t\t0,\n\t\t\t11\n\t\t]);\n\t\tconst module = new WebAssembly.Module(bin);\n\t\tif (new WebAssembly.Instance(module, {}).exports.test(4) !== 0) wa = true;\n\t\treturn wa;\n\t} catch (__) {}\n\treturn wa;\n}\nvar DEFAULT_OPTIONS = {\n\tjs: true,\n\twasm: true\n};\nvar MultiMath = class {\n\tconstructor(options) {\n\t\tconst opts = Object.assign({}, DEFAULT_OPTIONS, options || {});\n\t\tthis.options = opts;\n\t\tthis.__cache = {};\n\t\tthis.__init_promise = null;\n\t\tthis.__modules = opts.modules || {};\n\t\tthis.__memory = null;\n\t\tthis.__wasm = {};\n\t\tthis.__isLE = new Uint32Array(new Uint8Array([\n\t\t\t1,\n\t\t\t0,\n\t\t\t0,\n\t\t\t0\n\t\t]).buffer)[0] === 1;\n\t\tif (!this.options.js && !this.options.wasm) throw new Error(\"mathlib: at least \\\"js\\\" or \\\"wasm\\\" should be enabled\");\n\t}\n\thas_wasm() {\n\t\treturn hasWebAssembly();\n\t}\n\tuse(module) {\n\t\tthis.__modules[module.name] = module;\n\t\tif (this.options.wasm && this.has_wasm() && module.wasm_fn) this[module.name] = module.wasm_fn;\n\t\telse this[module.name] = module.fn;\n\t\treturn this;\n\t}\n\tinit() {\n\t\tif (this.__init_promise) return this.__init_promise;\n\t\tif (!this.options.js && this.options.wasm && !this.has_wasm()) return Promise.reject(/* @__PURE__ */ new Error(\"mathlib: only \\\"wasm\\\" was enabled, but it's not supported\"));\n\t\tthis.__init_promise = Promise.all(Object.keys(this.__modules).map((name) => {\n\t\t\tconst module = this.__modules[name];\n\t\t\tif (!this.options.wasm || !this.has_wasm() || !module.wasm_fn) return null;\n\t\t\tif (this.__wasm[name]) return null;\n\t\t\treturn WebAssembly.compile(base64decode(module.wasm_src)).then((m) => {\n\t\t\t\tthis.__wasm[name] = m;\n\t\t\t});\n\t\t})).then(() => this);\n\t\treturn this.__init_promise;\n\t}\n\t__reallocate(bytes) {\n\t\tif (!this.__memory) {\n\t\t\tthis.__memory = new WebAssembly.Memory({ initial: Math.ceil(bytes / (64 * 1024)) });\n\t\t\treturn this.__memory;\n\t\t}\n\t\tconst mem_size = this.__memory.buffer.byteLength;\n\t\tif (mem_size < bytes) this.__memory.grow(Math.ceil((bytes - mem_size) / (64 * 1024)));\n\t\treturn this.__memory;\n\t}\n\t__instance(name, memsize, env_extra) {\n\t\tif (memsize) this.__reallocate(memsize);\n\t\tif (!this.__wasm[name]) {\n\t\t\tconst module = this.__modules[name];\n\t\t\tthis.__wasm[name] = new WebAssembly.Module(base64decode(module.wasm_src));\n\t\t}\n\t\tif (!this.__cache[name]) {\n\t\t\tconst env_base = {\n\t\t\t\tmemoryBase: 0,\n\t\t\t\tmemory: this.__memory,\n\t\t\t\ttableBase: 0,\n\t\t\t\ttable: new WebAssembly.Table({\n\t\t\t\t\tinitial: 0,\n\t\t\t\t\telement: \"anyfunc\"\n\t\t\t\t})\n\t\t\t};\n\t\t\tthis.__cache[name] = new WebAssembly.Instance(this.__wasm[name], { env: Object.assign(env_base, env_extra || {}) });\n\t\t}\n\t\treturn this.__cache[name];\n\t}\n\t__align(number, base) {\n\t\tbase = base || 8;\n\t\tconst reminder = number % base;\n\t\treturn number + (reminder ? base - reminder : 0);\n\t}\n};\nfunction gaussCoef(sigma) {\n\tif (sigma < .5) sigma = .5;\n\tconst a = Math.exp(.726 * .726) / sigma, g1 = Math.exp(-a), g2 = Math.exp(-2 * a), k = (1 - g1) * (1 - g1) / (1 + 2 * a * g1 - g2);\n\tconst a0 = k;\n\tconst a1 = k * (a - 1) * g1;\n\tconst a2 = k * (a + 1) * g1;\n\tconst a3 = -k * g2;\n\tconst b1 = 2 * g1;\n\tconst b2 = -g2;\n\tconst left_corner = (a0 + a1) / (1 - b1 - b2);\n\tconst right_corner = (a2 + a3) / (1 - b1 - b2);\n\treturn new Float32Array([\n\t\ta0,\n\t\ta1,\n\t\ta2,\n\t\ta3,\n\t\tb1,\n\t\tb2,\n\t\tleft_corner,\n\t\tright_corner\n\t]);\n}\nfunction convolveMono16(src, out, line, coeff, width, height) {\n\tlet prev_src, curr_src, curr_out, prev_out, prev_prev_out;\n\tlet src_index, out_index, line_index;\n\tlet i, j;\n\tlet coeff_a0, coeff_a1, coeff_b1, coeff_b2;\n\tfor (i = 0; i < height; i++) {\n\t\tsrc_index = i * width;\n\t\tout_index = i;\n\t\tline_index = 0;\n\t\tprev_src = src[src_index];\n\t\tprev_prev_out = prev_src * coeff[6];\n\t\tprev_out = prev_prev_out;\n\t\tcoeff_a0 = coeff[0];\n\t\tcoeff_a1 = coeff[1];\n\t\tcoeff_b1 = coeff[4];\n\t\tcoeff_b2 = coeff[5];\n\t\tfor (j = 0; j < width; j++) {\n\t\t\tcurr_src = src[src_index];\n\t\t\tcurr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;\n\t\t\tprev_prev_out = prev_out;\n\t\t\tprev_out = curr_out;\n\t\t\tprev_src = curr_src;\n\t\t\tline[line_index] = prev_out;\n\t\t\tline_index++;\n\t\t\tsrc_index++;\n\t\t}\n\t\tsrc_index--;\n\t\tline_index--;\n\t\tout_index += height * (width - 1);\n\t\tprev_src = src[src_index];\n\t\tprev_prev_out = prev_src * coeff[7];\n\t\tprev_out = prev_prev_out;\n\t\tcurr_src = prev_src;\n\t\tcoeff_a0 = coeff[2];\n\t\tcoeff_a1 = coeff[3];\n\t\tfor (j = width - 1; j >= 0; j--) {\n\t\t\tcurr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;\n\t\t\tprev_prev_out = prev_out;\n\t\t\tprev_out = curr_out;\n\t\t\tprev_src = curr_src;\n\t\t\tcurr_src = src[src_index];\n\t\t\tout[out_index] = line[line_index] + prev_out;\n\t\t\tsrc_index--;\n\t\t\tline_index--;\n\t\t\tout_index -= height;\n\t\t}\n\t}\n}\nfunction blurMono16(src, width, height, radius) {\n\tif (!radius) return;\n\tconst out = new Uint16Array(src.length), tmp_line = new Float32Array(Math.max(width, height));\n\tconst coeff = gaussCoef(radius);\n\tconvolveMono16(src, out, tmp_line, coeff, width, height, radius);\n\tconvolveMono16(out, src, tmp_line, coeff, height, width, radius);\n}\nfunction hsv_v16(img, width, height) {\n\tconst size = width * height;\n\tconst out = new Uint16Array(size);\n\tlet r, g, b, max;\n\tfor (let i = 0; i < size; i++) {\n\t\tr = img[4 * i];\n\t\tg = img[4 * i + 1];\n\t\tb = img[4 * i + 2];\n\t\tmax = r >= g && r >= b ? r : g >= b && g >= r ? g : b;\n\t\tout[i] = max << 8;\n\t}\n\treturn out;\n}\nfunction unsharp$1(img, width, height, amount, radius, threshold) {\n\tlet v1, v2, vmul;\n\tlet diff, iTimes4;\n\tif (amount === 0 || radius < .5) return;\n\tif (radius > 2) radius = 2;\n\tconst brightness = hsv_v16(img, width, height);\n\tconst blured = new Uint16Array(brightness);\n\tblurMono16(blured, width, height, radius);\n\tconst amountFp = amount / 100 * 4096 + .5 | 0;\n\tconst thresholdFp = threshold << 8;\n\tconst size = width * height;\n\tfor (let i = 0; i < size; i++) {\n\t\tv1 = brightness[i];\n\t\tdiff = v1 - blured[i];\n\t\tif (Math.abs(diff) >= thresholdFp) {\n\t\t\tv2 = v1 + (amountFp * diff + 2048 >> 12);\n\t\t\tv2 = v2 > 65280 ? 65280 : v2;\n\t\t\tv2 = v2 < 0 ? 0 : v2;\n\t\t\tv1 = v1 !== 0 ? v1 : 1;\n\t\t\tvmul = (v2 << 12) / v1 | 0;\n\t\t\tiTimes4 = i * 4;\n\t\t\timg[iTimes4] = img[iTimes4] * vmul + 2048 >> 12;\n\t\t\timg[iTimes4 + 1] = img[iTimes4 + 1] * vmul + 2048 >> 12;\n\t\t\timg[iTimes4 + 2] = img[iTimes4 + 2] * vmul + 2048 >> 12;\n\t\t}\n\t}\n}\nfunction unsharp(img, width, height, amount, radius, threshold) {\n\tif (amount === 0 || radius < .5) return;\n\tif (radius > 2) radius = 2;\n\tconst pixels = width * height;\n\tconst img_bytes_cnt = pixels * 4;\n\tconst hsv_bytes_cnt = pixels * 2;\n\tconst blur_bytes_cnt = pixels * 2;\n\tconst blur_line_byte_cnt = Math.max(width, height) * 4;\n\tconst blur_coeffs_byte_cnt = 32;\n\tconst img_offset = 0;\n\tconst hsv_offset = img_bytes_cnt;\n\tconst blur_offset = hsv_offset + hsv_bytes_cnt;\n\tconst blur_tmp_offset = blur_offset + blur_bytes_cnt;\n\tconst blur_line_offset = blur_tmp_offset + blur_bytes_cnt;\n\tconst blur_coeffs_offset = blur_line_offset + blur_line_byte_cnt;\n\tconst instance = this.__instance(\"unsharp_mask\", img_bytes_cnt + hsv_bytes_cnt + blur_bytes_cnt * 2 + blur_line_byte_cnt + blur_coeffs_byte_cnt, { exp: Math.exp });\n\tconst img32 = new Uint32Array(img.buffer);\n\tnew Uint32Array(this.__memory.buffer).set(img32);\n\tlet fn = instance.exports.hsv_v16 || instance.exports._hsv_v16;\n\tif (!fn) throw new Error(\"WASM hsv_v16 function is not available\");\n\tfn(img_offset, hsv_offset, width, height);\n\tfn = instance.exports.blurMono16 || instance.exports._blurMono16;\n\tif (!fn) throw new Error(\"WASM blurMono16 function is not available\");\n\tfn(hsv_offset, blur_offset, blur_tmp_offset, blur_line_offset, blur_coeffs_offset, width, height, radius);\n\tfn = instance.exports.unsharp || instance.exports._unsharp;\n\tif (!fn) throw new Error(\"WASM unsharp function is not available\");\n\tfn(img_offset, img_offset, hsv_offset, blur_offset, width, height, amount, threshold);\n\timg32.set(new Uint32Array(this.__memory.buffer, 0, pixels));\n}\nvar mm_unsharp_mask_default = {\n\tname: \"unsharp_mask\",\n\tfn: unsharp$1,\n\twasm_fn: unsharp,\n\twasm_src: \"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\"\n};\nvar resize_filter_info_default = { filter: {\n\tbox: {\n\t\twin: .5,\n\t\tfn(x) {\n\t\t\tif (x < 0) x = -x;\n\t\t\treturn x < .5 ? 1 : 0;\n\t\t}\n\t},\n\thamming: {\n\t\twin: 1,\n\t\tfn(x) {\n\t\t\tif (x < 0) x = -x;\n\t\t\tif (x >= 1) return 0;\n\t\t\tif (x < 1.1920929e-7) return 1;\n\t\t\tconst xpi = x * Math.PI;\n\t\t\treturn Math.sin(xpi) / xpi * (.54 + .46 * Math.cos(xpi / 1));\n\t\t}\n\t},\n\tlanczos2: {\n\t\twin: 2,\n\t\tfn(x) {\n\t\t\tif (x < 0) x = -x;\n\t\t\tif (x >= 2) return 0;\n\t\t\tif (x < 1.1920929e-7) return 1;\n\t\t\tconst xpi = x * Math.PI;\n\t\t\treturn Math.sin(xpi) / xpi * Math.sin(xpi / 2) / (xpi / 2);\n\t\t}\n\t},\n\tlanczos3: {\n\t\twin: 3,\n\t\tfn(x) {\n\t\t\tif (x < 0) x = -x;\n\t\t\tif (x >= 3) return 0;\n\t\t\tif (x < 1.1920929e-7) return 1;\n\t\t\tconst xpi = x * Math.PI;\n\t\t\treturn Math.sin(xpi) / xpi * Math.sin(xpi / 3) / (xpi / 3);\n\t\t}\n\t},\n\tmks2013: {\n\t\twin: 2.5,\n\t\tfn(x) {\n\t\t\tif (x < 0) x = -x;\n\t\t\tif (x >= 2.5) return 0;\n\t\t\tif (x >= 1.5) return -.125 * (x - 2.5) * (x - 2.5);\n\t\t\tif (x >= .5) return .25 * (4 * x * x - 11 * x + 7);\n\t\t\treturn 1.0625 - 1.75 * x * x;\n\t\t}\n\t}\n} };\nvar FIXED_FRAC_BITS = 14;\nfunction toFixedPoint(num) {\n\treturn Math.round(num * ((1 << FIXED_FRAC_BITS) - 1));\n}\nfunction resizeFilterGen(filter, srcSize, destSize, scale, offset) {\n\tconst filterFunction = resize_filter_info_default.filter[filter].fn;\n\tconst scaleInverted = 1 / scale;\n\tconst scaleClamped = Math.min(1, scale);\n\tconst srcWindow = resize_filter_info_default.filter[filter].win / scaleClamped;\n\tlet destPixel, srcPixel, srcFirst, srcLast, filterElementSize, floatFilter, fxpFilter, total, pxl, idx, floatVal, filterTotal, filterVal;\n\tlet leftNotEmpty, rightNotEmpty, filterShift, filterSize;\n\tconst maxFilterElementSize = Math.floor((srcWindow + 1) * 2);\n\tconst packedFilter = new Int16Array((maxFilterElementSize + 2) * destSize);\n\tlet packedFilterPtr = 0;\n\tconst slowCopy = !packedFilter.subarray || !packedFilter.set;\n\tfor (destPixel = 0; destPixel < destSize; destPixel++) {\n\t\tsrcPixel = (destPixel + .5) * scaleInverted + offset;\n\t\tsrcFirst = Math.max(0, Math.floor(srcPixel - srcWindow));\n\t\tsrcLast = Math.min(srcSize - 1, Math.ceil(srcPixel + srcWindow));\n\t\tfilterElementSize = srcLast - srcFirst + 1;\n\t\tfloatFilter = new Float32Array(filterElementSize);\n\t\tfxpFilter = new Int16Array(filterElementSize);\n\t\ttotal = 0;\n\t\tfor (pxl = srcFirst, idx = 0; pxl <= srcLast; pxl++, idx++) {\n\t\t\tfloatVal = filterFunction((pxl + .5 - srcPixel) * scaleClamped);\n\t\t\ttotal += floatVal;\n\t\t\tfloatFilter[idx] = floatVal;\n\t\t}\n\t\tfilterTotal = 0;\n\t\tfor (idx = 0; idx < floatFilter.length; idx++) {\n\t\t\tfilterVal = floatFilter[idx] / total;\n\t\t\tfilterTotal += filterVal;\n\t\t\tfxpFilter[idx] = toFixedPoint(filterVal);\n\t\t}\n\t\tfxpFilter[destSize >> 1] += toFixedPoint(1 - filterTotal);\n\t\tleftNotEmpty = 0;\n\t\twhile (leftNotEmpty < fxpFilter.length && fxpFilter[leftNotEmpty] === 0) leftNotEmpty++;\n\t\tif (leftNotEmpty < fxpFilter.length) {\n\t\t\trightNotEmpty = fxpFilter.length - 1;\n\t\t\twhile (rightNotEmpty > 0 && fxpFilter[rightNotEmpty] === 0) rightNotEmpty--;\n\t\t\tfilterShift = srcFirst + leftNotEmpty;\n\t\t\tfilterSize = rightNotEmpty - leftNotEmpty + 1;\n\t\t\tpackedFilter[packedFilterPtr++] = filterShift;\n\t\t\tpackedFilter[packedFilterPtr++] = filterSize;\n\t\t\tif (!slowCopy) {\n\t\t\t\tpackedFilter.set(fxpFilter.subarray(leftNotEmpty, rightNotEmpty + 1), packedFilterPtr);\n\t\t\t\tpackedFilterPtr += filterSize;\n\t\t\t} else for (idx = leftNotEmpty; idx <= rightNotEmpty; idx++) packedFilter[packedFilterPtr++] = fxpFilter[idx];\n\t\t} else {\n\t\t\tpackedFilter[packedFilterPtr++] = 0;\n\t\t\tpackedFilter[packedFilterPtr++] = 0;\n\t\t}\n\t}\n\treturn packedFilter;\n}\nfunction clampTo8(i) {\n\treturn i < 0 ? 0 : i > 255 ? 255 : i;\n}\nfunction clampNegative(i) {\n\treturn i >= 0 ? i : 0;\n}\nfunction convolveHor(src, dest, srcW, srcH, destW, filters) {\n\tlet r, g, b, a;\n\tlet filterPtr, filterShift, filterSize;\n\tlet srcPtr, srcY, destX, filterVal;\n\tlet srcOffset = 0, destOffset = 0;\n\tfor (srcY = 0; srcY < srcH; srcY++) {\n\t\tfilterPtr = 0;\n\t\tfor (destX = 0; destX < destW; destX++) {\n\t\t\tfilterShift = filters[filterPtr++];\n\t\t\tfilterSize = filters[filterPtr++];\n\t\t\tsrcPtr = srcOffset + filterShift * 4 | 0;\n\t\t\tr = g = b = a = 0;\n\t\t\tfor (; filterSize > 0; filterSize--) {\n\t\t\t\tfilterVal = filters[filterPtr++];\n\t\t\t\ta = a + filterVal * src[srcPtr + 3] | 0;\n\t\t\t\tb = b + filterVal * src[srcPtr + 2] | 0;\n\t\t\t\tg = g + filterVal * src[srcPtr + 1] | 0;\n\t\t\t\tr = r + filterVal * src[srcPtr] | 0;\n\t\t\t\tsrcPtr = srcPtr + 4 | 0;\n\t\t\t}\n\t\t\tdest[destOffset + 3] = clampNegative(a >> 7);\n\t\t\tdest[destOffset + 2] = clampNegative(b >> 7);\n\t\t\tdest[destOffset + 1] = clampNegative(g >> 7);\n\t\t\tdest[destOffset] = clampNegative(r >> 7);\n\t\t\tdestOffset = destOffset + srcH * 4 | 0;\n\t\t}\n\t\tdestOffset = (srcY + 1) * 4 | 0;\n\t\tsrcOffset = (srcY + 1) * srcW * 4 | 0;\n\t}\n}\nfunction convolveVert(src, dest, srcW, srcH, destW, filters) {\n\tlet r, g, b, a;\n\tlet filterPtr, filterShift, filterSize;\n\tlet srcPtr, srcY, destX, filterVal;\n\tlet srcOffset = 0, destOffset = 0;\n\tfor (srcY = 0; srcY < srcH; srcY++) {\n\t\tfilterPtr = 0;\n\t\tfor (destX = 0; destX < destW; destX++) {\n\t\t\tfilterShift = filters[filterPtr++];\n\t\t\tfilterSize = filters[filterPtr++];\n\t\t\tsrcPtr = srcOffset + filterShift * 4 | 0;\n\t\t\tr = g = b = a = 0;\n\t\t\tfor (; filterSize > 0; filterSize--) {\n\t\t\t\tfilterVal = filters[filterPtr++];\n\t\t\t\ta = a + filterVal * src[srcPtr + 3] | 0;\n\t\t\t\tb = b + filterVal * src[srcPtr + 2] | 0;\n\t\t\t\tg = g + filterVal * src[srcPtr + 1] | 0;\n\t\t\t\tr = r + filterVal * src[srcPtr] | 0;\n\t\t\t\tsrcPtr = srcPtr + 4 | 0;\n\t\t\t}\n\t\t\tr >>= 7;\n\t\t\tg >>= 7;\n\t\t\tb >>= 7;\n\t\t\ta >>= 7;\n\t\t\tdest[destOffset + 3] = clampTo8(a + 8192 >> 14);\n\t\t\tdest[destOffset + 2] = clampTo8(b + 8192 >> 14);\n\t\t\tdest[destOffset + 1] = clampTo8(g + 8192 >> 14);\n\t\t\tdest[destOffset] = clampTo8(r + 8192 >> 14);\n\t\t\tdestOffset = destOffset + srcH * 4 | 0;\n\t\t}\n\t\tdestOffset = (srcY + 1) * 4 | 0;\n\t\tsrcOffset = (srcY + 1) * srcW * 4 | 0;\n\t}\n}\nfunction convolveHorWithPre(src, dest, srcW, srcH, destW, filters) {\n\tlet r, g, b, a, alpha;\n\tlet filterPtr, filterShift, filterSize;\n\tlet srcPtr, srcY, destX, filterVal;\n\tlet srcOffset = 0, destOffset = 0;\n\tfor (srcY = 0; srcY < srcH; srcY++) {\n\t\tfilterPtr = 0;\n\t\tfor (destX = 0; destX < destW; destX++) {\n\t\t\tfilterShift = filters[filterPtr++];\n\t\t\tfilterSize = filters[filterPtr++];\n\t\t\tsrcPtr = srcOffset + filterShift * 4 | 0;\n\t\t\tr = g = b = a = 0;\n\t\t\tfor (; filterSize > 0; filterSize--) {\n\t\t\t\tfilterVal = filters[filterPtr++];\n\t\t\t\talpha = src[srcPtr + 3];\n\t\t\t\ta = a + filterVal * alpha | 0;\n\t\t\t\tb = b + filterVal * src[srcPtr + 2] * alpha | 0;\n\t\t\t\tg = g + filterVal * src[srcPtr + 1] * alpha | 0;\n\t\t\t\tr = r + filterVal * src[srcPtr] * alpha | 0;\n\t\t\t\tsrcPtr = srcPtr + 4 | 0;\n\t\t\t}\n\t\t\tb = b / 255 | 0;\n\t\t\tg = g / 255 | 0;\n\t\t\tr = r / 255 | 0;\n\t\t\tdest[destOffset + 3] = clampNegative(a >> 7);\n\t\t\tdest[destOffset + 2] = clampNegative(b >> 7);\n\t\t\tdest[destOffset + 1] = clampNegative(g >> 7);\n\t\t\tdest[destOffset] = clampNegative(r >> 7);\n\t\t\tdestOffset = destOffset + srcH * 4 | 0;\n\t\t}\n\t\tdestOffset = (srcY + 1) * 4 | 0;\n\t\tsrcOffset = (srcY + 1) * srcW * 4 | 0;\n\t}\n}\nfunction convolveVertWithPre(src, dest, srcW, srcH, destW, filters) {\n\tlet r, g, b, a;\n\tlet filterPtr, filterShift, filterSize;\n\tlet srcPtr, srcY, destX, filterVal;\n\tlet srcOffset = 0, destOffset = 0;\n\tfor (srcY = 0; srcY < srcH; srcY++) {\n\t\tfilterPtr = 0;\n\t\tfor (destX = 0; destX < destW; destX++) {\n\t\t\tfilterShift = filters[filterPtr++];\n\t\t\tfilterSize = filters[filterPtr++];\n\t\t\tsrcPtr = srcOffset + filterShift * 4 | 0;\n\t\t\tr = g = b = a = 0;\n\t\t\tfor (; filterSize > 0; filterSize--) {\n\t\t\t\tfilterVal = filters[filterPtr++];\n\t\t\t\ta = a + filterVal * src[srcPtr + 3] | 0;\n\t\t\t\tb = b + filterVal * src[srcPtr + 2] | 0;\n\t\t\t\tg = g + filterVal * src[srcPtr + 1] | 0;\n\t\t\t\tr = r + filterVal * src[srcPtr] | 0;\n\t\t\t\tsrcPtr = srcPtr + 4 | 0;\n\t\t\t}\n\t\t\tr >>= 7;\n\t\t\tg >>= 7;\n\t\t\tb >>= 7;\n\t\t\ta >>= 7;\n\t\t\ta = clampTo8(a + 8192 >> 14);\n\t\t\tif (a > 0) {\n\t\t\t\tr = r * 255 / a | 0;\n\t\t\t\tg = g * 255 / a | 0;\n\t\t\t\tb = b * 255 / a | 0;\n\t\t\t}\n\t\t\tdest[destOffset + 3] = a;\n\t\t\tdest[destOffset + 2] = clampTo8(b + 8192 >> 14);\n\t\t\tdest[destOffset + 1] = clampTo8(g + 8192 >> 14);\n\t\t\tdest[destOffset] = clampTo8(r + 8192 >> 14);\n\t\t\tdestOffset = destOffset + srcH * 4 | 0;\n\t\t}\n\t\tdestOffset = (srcY + 1) * 4 | 0;\n\t\tsrcOffset = (srcY + 1) * srcW * 4 | 0;\n\t}\n}\nfunction hasAlpha$1(src, width, height) {\n\tlet ptr = 3;\n\tconst len = width * height * 4 | 0;\n\twhile (ptr < len) {\n\t\tif (src[ptr] !== 255) return true;\n\t\tptr = ptr + 4 | 0;\n\t}\n\treturn false;\n}\nfunction resetAlpha$1(dst, width, height) {\n\tlet ptr = 3;\n\tconst len = width * height * 4 | 0;\n\twhile (ptr < len) {\n\t\tdst[ptr] = 255;\n\t\tptr = ptr + 4 | 0;\n\t}\n}\nfunction resize(options) {\n\tconst src = options.src;\n\tconst srcW = options.width;\n\tconst srcH = options.height;\n\tconst destW = options.toWidth;\n\tconst destH = options.toHeight;\n\tconst scaleX = options.scaleX || options.toWidth / options.width;\n\tconst scaleY = options.scaleY || options.toHeight / options.height;\n\tconst offsetX = options.offsetX || 0;\n\tconst offsetY = options.offsetY || 0;\n\tconst dest = options.dest || new Uint8Array(destW * destH * 4);\n\tconst filter = typeof options.filter === \"undefined\" ? \"mks2013\" : options.filter;\n\tconst filtersX = resizeFilterGen(filter, srcW, destW, scaleX, offsetX), filtersY = resizeFilterGen(filter, srcH, destH, scaleY, offsetY);\n\tconst tmp = new Uint16Array(destW * srcH * 4);\n\tif (hasAlpha$1(src, srcW, srcH)) {\n\t\tconvolveHorWithPre(src, tmp, srcW, srcH, destW, filtersX);\n\t\tconvolveVertWithPre(tmp, dest, srcH, destW, destH, filtersY);\n\t} else {\n\t\tconvolveHor(src, tmp, srcW, srcH, destW, filtersX);\n\t\tconvolveVert(tmp, dest, srcH, destW, destH, filtersY);\n\t\tresetAlpha$1(dest, destW, destH);\n\t}\n\treturn dest;\n}\nfunction hasAlpha(src, width, height) {\n\tlet ptr = 3;\n\tconst len = width * height * 4 | 0;\n\twhile (ptr < len) {\n\t\tif (src[ptr] !== 255) return true;\n\t\tptr = ptr + 4 | 0;\n\t}\n\treturn false;\n}\nfunction resetAlpha(dst, width, height) {\n\tlet ptr = 3;\n\tconst len = width * height * 4 | 0;\n\twhile (ptr < len) {\n\t\tdst[ptr] = 255;\n\t\tptr = ptr + 4 | 0;\n\t}\n}\nfunction asUint8Array(src) {\n\treturn new Uint8Array(src.buffer, 0, src.byteLength);\n}\nvar IS_LE = true;\ntry {\n\tIS_LE = new Uint32Array(new Uint8Array([\n\t\t1,\n\t\t0,\n\t\t0,\n\t\t0\n\t]).buffer)[0] === 1;\n} catch (__) {}\nfunction copyInt16asLE(src, target, target_offset) {\n\tif (IS_LE) {\n\t\ttarget.set(asUint8Array(src), target_offset);\n\t\treturn;\n\t}\n\tfor (let ptr = target_offset, i = 0; i < src.length; i++) {\n\t\tconst data = src[i];\n\t\ttarget[ptr++] = data & 255;\n\t\ttarget[ptr++] = data >> 8 & 255;\n\t}\n}\nfunction resize_wasm(options) {\n\tconst src = options.src;\n\tconst srcW = options.width;\n\tconst srcH = options.height;\n\tconst destW = options.toWidth;\n\tconst destH = options.toHeight;\n\tconst scaleX = options.scaleX || options.toWidth / options.width;\n\tconst scaleY = options.scaleY || options.toHeight / options.height;\n\tconst offsetX = options.offsetX || 0;\n\tconst offsetY = options.offsetY || 0;\n\tconst dest = options.dest || new Uint8Array(destW * destH * 4);\n\tconst filter = typeof options.filter === \"undefined\" ? \"mks2013\" : options.filter;\n\tconst filtersX = resizeFilterGen(filter, srcW, destW, scaleX, offsetX), filtersY = resizeFilterGen(filter, srcH, destH, scaleY, offsetY);\n\tconst src_offset = 0;\n\tconst src_size = Math.max(src.byteLength, dest.byteLength);\n\tconst tmp_offset = this.__align(src_offset + src_size);\n\tconst tmp_size = srcH * destW * 4 * 2;\n\tconst filtersX_offset = this.__align(tmp_offset + tmp_size);\n\tconst filtersY_offset = this.__align(filtersX_offset + filtersX.byteLength);\n\tconst alloc_bytes = filtersY_offset + filtersY.byteLength;\n\tconst instance = this.__instance(\"resize\", alloc_bytes);\n\tconst mem = new Uint8Array(this.__memory.buffer);\n\tconst mem32 = new Uint32Array(this.__memory.buffer);\n\tconst src32 = new Uint32Array(src.buffer);\n\tmem32.set(src32);\n\tcopyInt16asLE(filtersX, mem, filtersX_offset);\n\tcopyInt16asLE(filtersY, mem, filtersY_offset);\n\tconst fn = instance.exports.convolveHV || instance.exports._convolveHV;\n\tif (!fn) throw new Error(\"WASM resize function is not available\");\n\tif (hasAlpha(src, srcW, srcH)) fn(filtersX_offset, filtersY_offset, tmp_offset, srcW, srcH, destW, destH, 1);\n\telse {\n\t\tfn(filtersX_offset, filtersY_offset, tmp_offset, srcW, srcH, destW, destH, 0);\n\t\tresetAlpha(dest, destW, destH);\n\t}\n\tnew Uint32Array(dest.buffer).set(new Uint32Array(this.__memory.buffer, 0, destH * destW));\n\treturn dest;\n}\nvar mm_resize_default = {\n\tname: \"resize\",\n\tfn: resize,\n\twasm_fn: resize_wasm,\n\twasm_src: \"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\"\n};\nvar MathLib = class extends MultiMath {\n\tconstructor(requested_features) {\n\t\tconst __requested_features = requested_features || [];\n\t\tconst features = {\n\t\t\tjs: __requested_features.indexOf(\"js\") >= 0,\n\t\t\twasm: __requested_features.indexOf(\"wasm\") >= 0\n\t\t};\n\t\tsuper(features);\n\t\tthis.features = {\n\t\t\tjs: features.js,\n\t\t\twasm: features.wasm && this.has_wasm()\n\t\t};\n\t\tthis.use(mm_unsharp_mask_default);\n\t\tthis.use(mm_resize_default);\n\t}\n\tresizeAndUnsharp(options) {\n\t\tconst result = this.resize(options);\n\t\tif (options.unsharpAmount) this.unsharp_mask(result, options.toWidth, options.toHeight, options.unsharpAmount, options.unsharpRadius, options.unsharpThreshold);\n\t\treturn result;\n\t}\n};\nfunction _typeof(o) {\n\t\"@babel/helpers - typeof\";\n\treturn _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function(o) {\n\t\treturn typeof o;\n\t} : function(o) {\n\t\treturn o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;\n\t}, _typeof(o);\n}\nfunction toPrimitive(t, r) {\n\tif (\"object\" != _typeof(t) || !t) return t;\n\tvar e = t[Symbol.toPrimitive];\n\tif (void 0 !== e) {\n\t\tvar i = e.call(t, r || \"default\");\n\t\tif (\"object\" != _typeof(i)) return i;\n\t\tthrow new TypeError(\"@@toPrimitive must return a primitive value.\");\n\t}\n\treturn (\"string\" === r ? String : Number)(t);\n}\nfunction toPropertyKey(t) {\n\tvar i = toPrimitive(t, \"string\");\n\treturn \"symbol\" == _typeof(i) ? i : i + \"\";\n}\nfunction _defineProperty(e, r, t) {\n\treturn (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {\n\t\tvalue: t,\n\t\tenumerable: !0,\n\t\tconfigurable: !0,\n\t\twritable: !0\n\t}) : e[r] = t, e;\n}\nfunction ownKeys(e, r) {\n\tvar t = Object.keys(e);\n\tif (Object.getOwnPropertySymbols) {\n\t\tvar o = Object.getOwnPropertySymbols(e);\n\t\tr && (o = o.filter(function(r) {\n\t\t\treturn Object.getOwnPropertyDescriptor(e, r).enumerable;\n\t\t})), t.push.apply(t, o);\n\t}\n\treturn t;\n}\nfunction _objectSpread2(e) {\n\tfor (var r = 1; r < arguments.length; r++) {\n\t\tvar t = null != arguments[r] ? arguments[r] : {};\n\t\tr % 2 ? ownKeys(Object(t), !0).forEach(function(r) {\n\t\t\t_defineProperty(e, r, t[r]);\n\t\t}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {\n\t\t\tObject.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));\n\t\t});\n\t}\n\treturn e;\n}\nvar GC_INTERVAL = 100;\nvar Pool = class {\n\tconstructor(create, idle) {\n\t\t_defineProperty(this, \"create\", void 0);\n\t\t_defineProperty(this, \"available\", void 0);\n\t\t_defineProperty(this, \"acquired\", void 0);\n\t\t_defineProperty(this, \"lastId\", void 0);\n\t\t_defineProperty(this, \"timeoutId\", void 0);\n\t\t_defineProperty(this, \"idle\", void 0);\n\t\tthis.create = create;\n\t\tthis.available = [];\n\t\tthis.acquired = {};\n\t\tthis.lastId = 1;\n\t\tthis.timeoutId = 0;\n\t\tthis.idle = idle || 2e3;\n\t}\n\tacquire() {\n\t\tlet descriptor;\n\t\tif (this.available.length !== 0) descriptor = this.available.pop();\n\t\telse descriptor = _objectSpread2(_objectSpread2({}, this.create()), {}, {\n\t\t\tid: this.lastId++,\n\t\t\tlastUsed: 0\n\t\t});\n\t\tthis.acquired[descriptor.id] = descriptor;\n\t\treturn {\n\t\t\tvalue: descriptor.value,\n\t\t\trelease: () => this.release(descriptor)\n\t\t};\n\t}\n\trelease(descriptor) {\n\t\tdelete this.acquired[descriptor.id];\n\t\tdescriptor.lastUsed = Date.now();\n\t\tthis.available.push(descriptor);\n\t\tif (this.timeoutId === 0) this.timeoutId = setTimeout(() => this.gc(), GC_INTERVAL);\n\t}\n\tgc() {\n\t\tconst now = Date.now();\n\t\tthis.available = this.available.filter((descriptor) => {\n\t\t\tif (now - descriptor.lastUsed > this.idle) {\n\t\t\t\tdescriptor.destroy();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t});\n\t\tif (this.available.length !== 0) this.timeoutId = setTimeout(() => this.gc(), GC_INTERVAL);\n\t\telse this.timeoutId = 0;\n\t}\n};\nfunction objClass(obj) {\n\tvar _obj$constructor$name, _obj$constructor;\n\treturn (_obj$constructor$name = obj === null || obj === void 0 || (_obj$constructor = obj.constructor) === null || _obj$constructor === void 0 ? void 0 : _obj$constructor.name) !== null && _obj$constructor$name !== void 0 ? _obj$constructor$name : \"\";\n}\nfunction isCanvas(element) {\n\tconst cname = objClass(element);\n\treturn cname === \"HTMLCanvasElement\" || cname === \"OffscreenCanvas\" || cname === \"Canvas\" || cname === \"CanvasElement\";\n}\nfunction isImage(element) {\n\treturn objClass(element) === \"HTMLImageElement\";\n}\nfunction isImageBitmap(element) {\n\treturn objClass(element) === \"ImageBitmap\";\n}\nfunction limiter(concurrency) {\n\tlet active = 0;\n\tconst queue = [];\n\tfunction roll() {\n\t\tif (active < concurrency && queue.length) {\n\t\t\tvar _queue$shift;\n\t\t\tactive++;\n\t\t\t(_queue$shift = queue.shift()) === null || _queue$shift === void 0 || _queue$shift();\n\t\t}\n\t}\n\treturn function limit(fn) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tqueue.push(() => {\n\t\t\t\tfn().then((result) => {\n\t\t\t\t\tresolve(result);\n\t\t\t\t\tactive--;\n\t\t\t\t\troll();\n\t\t\t\t}, (err) => {\n\t\t\t\t\treject(err);\n\t\t\t\t\tactive--;\n\t\t\t\t\troll();\n\t\t\t\t});\n\t\t\t});\n\t\t\troll();\n\t\t});\n\t};\n}\nfunction cib_quality_name(num) {\n\tswitch (num) {\n\t\tcase 0: return \"pixelated\";\n\t\tcase 1: return \"low\";\n\t\tcase 2: return \"medium\";\n\t}\n\treturn \"high\";\n}\nvar CIB_QUALITY_FILTERS = [\n\t\"box\",\n\t\"hamming\",\n\t\"lanczos2\",\n\t\"lanczos3\"\n];\nfunction cib_quality_filter(num) {\n\treturn CIB_QUALITY_FILTERS[num];\n}\nfunction is_cib_filter(filter) {\n\treturn CIB_QUALITY_FILTERS.indexOf(filter) >= 0;\n}\nfunction filter_to_cib_quality(filter) {\n\tconst index = CIB_QUALITY_FILTERS.indexOf(filter);\n\treturn index >= 0 ? index : void 0;\n}\nvar MIN_INNER_TILE_SIZE = 2;\nvar DEST_TILE_BORDER = 3;\nfunction createStages(fromWidth, fromHeight, toWidth, toHeight, srcTileSize) {\n\tconst scaleX = toWidth / fromWidth;\n\tconst scaleY = toHeight / fromHeight;\n\tconst minScale = (2 * DEST_TILE_BORDER + MIN_INNER_TILE_SIZE + 1) / srcTileSize;\n\tif (minScale > .5) return [[toWidth, toHeight]];\n\tconst stageCount = Math.ceil(Math.log(Math.min(scaleX, scaleY)) / Math.log(minScale));\n\tif (stageCount <= 1) return [[toWidth, toHeight]];\n\tconst result = [];\n\tfor (let i = 0; i < stageCount; i++) {\n\t\tconst width = Math.round(Math.pow(Math.pow(fromWidth, stageCount - i - 1) * Math.pow(toWidth, i + 1), 1 / stageCount));\n\t\tconst height = Math.round(Math.pow(Math.pow(fromHeight, stageCount - i - 1) * Math.pow(toHeight, i + 1), 1 / stageCount));\n\t\tresult.push([width, height]);\n\t}\n\treturn result;\n}\nvar PIXEL_EPSILON = 1e-5;\nfunction pixelFloor(x) {\n\tconst nearest = Math.round(x);\n\tif (Math.abs(x - nearest) < PIXEL_EPSILON) return nearest;\n\treturn Math.floor(x);\n}\nfunction pixelCeil(x) {\n\tconst nearest = Math.round(x);\n\tif (Math.abs(x - nearest) < PIXEL_EPSILON) return nearest;\n\treturn Math.ceil(x);\n}\nfunction createRegions(options) {\n\tconst scaleX = options.toWidth / options.width;\n\tconst scaleY = options.toHeight / options.height;\n\tconst innerTileWidth = pixelFloor(options.srcTileSize * scaleX) - 2 * options.destTileBorder;\n\tconst innerTileHeight = pixelFloor(options.srcTileSize * scaleY) - 2 * options.destTileBorder;\n\tif (innerTileWidth < 1 || innerTileHeight < 1) throw new Error(\"Internal error in pica: target tile width/height is too small.\");\n\tlet x, y;\n\tlet innerX, innerY, toTileWidth, toTileHeight;\n\tconst tiles = [];\n\tlet tile;\n\tfor (innerY = 0; innerY < options.toHeight; innerY += innerTileHeight) for (innerX = 0; innerX < options.toWidth; innerX += innerTileWidth) {\n\t\tx = innerX - options.destTileBorder;\n\t\tif (x < 0) x = 0;\n\t\ttoTileWidth = innerX + innerTileWidth + options.destTileBorder - x;\n\t\tif (x + toTileWidth >= options.toWidth) toTileWidth = options.toWidth - x;\n\t\ty = innerY - options.destTileBorder;\n\t\tif (y < 0) y = 0;\n\t\ttoTileHeight = innerY + innerTileHeight + options.destTileBorder - y;\n\t\tif (y + toTileHeight >= options.toHeight) toTileHeight = options.toHeight - y;\n\t\ttile = {\n\t\t\ttoX: x,\n\t\t\ttoY: y,\n\t\t\ttoWidth: toTileWidth,\n\t\t\ttoHeight: toTileHeight,\n\t\t\ttoInnerX: innerX,\n\t\t\ttoInnerY: innerY,\n\t\t\ttoInnerWidth: innerTileWidth,\n\t\t\ttoInnerHeight: innerTileHeight,\n\t\t\toffsetX: x / scaleX - pixelFloor(x / scaleX),\n\t\t\toffsetY: y / scaleY - pixelFloor(y / scaleY),\n\t\t\tscaleX,\n\t\t\tscaleY,\n\t\t\tx: pixelFloor(x / scaleX),\n\t\t\ty: pixelFloor(y / scaleY),\n\t\t\twidth: pixelCeil(toTileWidth / scaleX),\n\t\t\theight: pixelCeil(toTileHeight / scaleY)\n\t\t};\n\t\ttiles.push(tile);\n\t}\n\treturn tiles;\n}\nvar ORIENTED_JPEG_BASE64 = \"/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/4AAQskZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/wAALCAACAAMBAREA/8QAFAABAAAAAAAAAAAAAAAAAAAACf/EABsQAAMBAQADAAAAAAAAAAAAAAECAwQFABEx/9oACAEBAAA/AC06fW6va0ps7PT179E88MiV02arrCEkjGQZiSEnKc5ovxURVHoADz//2Q==\";\nvar features = {\n\tcanvas: false,\n\toffscreen_canvas: false,\n\tmay_be_worker: false,\n\tcreate_image_bitmap: false,\n\tsafari_put_image_data_fix: false,\n\tbug_canvas_orientation_region: true,\n\tbug_image_bitmap_orientation_region: true,\n\tcib_resize: false\n};\nvar checked = false;\nvar checking = null;\nfunction check_canvas() {\n\tif (typeof document === \"undefined\" || !document.createElement) return false;\n\ttry {\n\t\tconst canvas = document.createElement(\"canvas\");\n\t\tcanvas.width = 2;\n\t\tcanvas.height = 1;\n\t\tconst ctx = canvas.getContext(\"2d\");\n\t\tlet d = ctx.createImageData(2, 1);\n\t\td.data[0] = 12;\n\t\td.data[1] = 23;\n\t\td.data[2] = 34;\n\t\td.data[3] = 255;\n\t\td.data[4] = 45;\n\t\td.data[5] = 56;\n\t\td.data[6] = 67;\n\t\td.data[7] = 255;\n\t\tctx.putImageData(d, 0, 0);\n\t\td = ctx.getImageData(0, 0, 2, 1);\n\t\treturn d.data[0] === 12 && d.data[1] === 23 && d.data[2] === 34 && d.data[3] === 255 && d.data[4] === 45 && d.data[5] === 56 && d.data[6] === 67 && d.data[7] === 255;\n\t} catch (__) {\n\t\treturn false;\n\t}\n}\nfunction check_offscreen_canvas() {\n\tif (typeof OffscreenCanvas === \"undefined\") return false;\n\ttry {\n\t\tconst ctx = new OffscreenCanvas(2, 1).getContext(\"2d\");\n\t\tlet d = ctx.createImageData(2, 1);\n\t\td.data[0] = 12;\n\t\td.data[1] = 23;\n\t\td.data[2] = 34;\n\t\td.data[3] = 255;\n\t\td.data[4] = 45;\n\t\td.data[5] = 56;\n\t\td.data[6] = 67;\n\t\td.data[7] = 255;\n\t\tctx.putImageData(d, 0, 0);\n\t\td = ctx.getImageData(0, 0, 2, 1);\n\t\treturn d.data[0] === 12 && d.data[1] === 23 && d.data[2] === 34 && d.data[3] === 255 && d.data[4] === 45 && d.data[5] === 56 && d.data[6] === 67 && d.data[7] === 255;\n\t} catch (__) {\n\t\treturn false;\n\t}\n}\nfunction check_create_image_bitmap() {\n\treturn typeof createImageBitmap !== \"undefined\";\n}\nfunction check_may_be_worker() {\n\treturn typeof Worker !== \"undefined\" && typeof URL !== \"undefined\" && !!URL.createObjectURL;\n}\nfunction check_safari_put_image_data_fix() {\n\ttry {\n\t\treturn !!(typeof navigator !== \"undefined\" && navigator.userAgent && navigator.userAgent.indexOf(\"Safari\") >= 0 && navigator.userAgent.indexOf(\"Chrome\") < 0);\n\t} catch (__) {\n\t\treturn false;\n\t}\n}\nfunction check_bug_canvas_orientation_region_async() {\n\treturn Promise.resolve().then(() => {\n\t\tif (check_offscreen_canvas() && check_create_image_bitmap() && typeof Blob !== \"undefined\" && typeof atob !== \"undefined\") {\n\t\t\tconst binary = atob(ORIENTED_JPEG_BASE64);\n\t\t\tconst bytes = new Uint8Array(binary.length);\n\t\t\tfor (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n\t\t\treturn createImageBitmap(new Blob([bytes], { type: \"image/jpeg\" })).then((bitmap) => {\n\t\t\t\tconst canvas = new OffscreenCanvas(1, 1);\n\t\t\t\ttry {\n\t\t\t\t\tconst ctx = canvas.getContext(\"2d\");\n\t\t\t\t\tctx.drawImage(bitmap, 1, 1, 1, 1, 0, 0, 1, 1);\n\t\t\t\t\treturn ctx.getImageData(0, 0, 1, 1).data[0] < 240;\n\t\t\t\t} finally {\n\t\t\t\t\tbitmap.close();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (check_canvas() && typeof Image !== \"undefined\") return new Promise((resolve) => {\n\t\t\tconst image = new Image();\n\t\t\timage.onload = () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst canvas = document.createElement(\"canvas\");\n\t\t\t\t\tcanvas.width = 1;\n\t\t\t\t\tcanvas.height = 1;\n\t\t\t\t\tconst ctx = canvas.getContext(\"2d\");\n\t\t\t\t\tctx.drawImage(image, 1, 1, 1, 1, 0, 0, 1, 1);\n\t\t\t\t\tresolve(ctx.getImageData(0, 0, 1, 1).data[0] < 240);\n\t\t\t\t} catch (__) {\n\t\t\t\t\tresolve(true);\n\t\t\t\t}\n\t\t\t};\n\t\t\timage.onerror = () => resolve(true);\n\t\t\timage.src = `data:image/jpeg;base64,${ORIENTED_JPEG_BASE64}`;\n\t\t});\n\t\treturn true;\n\t}).catch(() => true);\n}\nfunction check_bug_image_bitmap_orientation_region_async() {\n\treturn Promise.resolve().then(() => {\n\t\tif (!features.create_image_bitmap && !check_create_image_bitmap()) return true;\n\t\tif (typeof Blob === \"undefined\" || typeof atob === \"undefined\") return true;\n\t\tconst canOffscreenCanvas = check_offscreen_canvas();\n\t\tconst canCanvas = check_canvas();\n\t\tif (!canOffscreenCanvas && !canCanvas) return true;\n\t\tconst binary = atob(ORIENTED_JPEG_BASE64);\n\t\tconst bytes = new Uint8Array(binary.length);\n\t\tfor (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n\t\treturn createImageBitmap(new Blob([bytes], { type: \"image/jpeg\" })).then((imageBitmap) => createImageBitmap(imageBitmap, 1, 1, 1, 1).then((bitmap) => {\n\t\t\tlet canvas;\n\t\t\tif (canOffscreenCanvas) canvas = new OffscreenCanvas(1, 1);\n\t\t\telse {\n\t\t\t\tcanvas = document.createElement(\"canvas\");\n\t\t\t\tcanvas.width = 1;\n\t\t\t\tcanvas.height = 1;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst ctx = canvas.getContext(\"2d\");\n\t\t\t\tctx.drawImage(bitmap, 0, 0);\n\t\t\t\treturn bitmap.width !== 1 || bitmap.height !== 1 || ctx.getImageData(0, 0, 1, 1).data[0] < 240;\n\t\t\t} finally {\n\t\t\t\timageBitmap.close();\n\t\t\t\tbitmap.close();\n\t\t\t}\n\t\t}, () => {\n\t\t\timageBitmap.close();\n\t\t\treturn true;\n\t\t}));\n\t}).catch(() => true);\n}\nfunction check_cib_resize_async() {\n\treturn Promise.resolve().then(() => {\n\t\tif (!check_create_image_bitmap()) return false;\n\t\tconst SRC_SIZE = 20;\n\t\tconst DST_SIZE = 5;\n\t\tlet canvas;\n\t\tif (features.canvas || check_canvas()) {\n\t\t\tcanvas = document.createElement(\"canvas\");\n\t\t\tcanvas.width = SRC_SIZE;\n\t\t\tcanvas.height = SRC_SIZE;\n\t\t} else if (features.offscreen_canvas || check_offscreen_canvas()) {\n\t\t\tcanvas = new OffscreenCanvas(SRC_SIZE, SRC_SIZE);\n\t\t\tcanvas.getContext(\"2d\").clearRect(0, 0, SRC_SIZE, SRC_SIZE);\n\t\t} else return false;\n\t\treturn createImageBitmap(canvas, 0, 0, SRC_SIZE, SRC_SIZE, {\n\t\t\tresizeWidth: DST_SIZE,\n\t\t\tresizeHeight: DST_SIZE,\n\t\t\tresizeQuality: \"high\"\n\t\t}).then((bitmap) => {\n\t\t\tconst status = bitmap.width === DST_SIZE && !!bitmap.close;\n\t\t\tif (bitmap.close) bitmap.close();\n\t\t\tcanvas = null;\n\t\t\treturn status;\n\t\t});\n\t}).catch(() => false);\n}\nfunction get_supported_features() {\n\tif (checked) return Promise.resolve(Object.assign({}, features));\n\tif (checking) return checking.then(() => Object.assign({}, features));\n\tfeatures.canvas = check_canvas();\n\tfeatures.offscreen_canvas = check_offscreen_canvas();\n\tfeatures.may_be_worker = check_may_be_worker();\n\tfeatures.create_image_bitmap = check_create_image_bitmap();\n\tfeatures.safari_put_image_data_fix = check_safari_put_image_data_fix();\n\tconst bugCanvasOrientationRegion = check_bug_canvas_orientation_region_async().then((result) => {\n\t\tfeatures.bug_canvas_orientation_region = result;\n\t}).catch(() => {});\n\tconst bugImageBitmapOrientationRegion = check_bug_image_bitmap_orientation_region_async().then((result) => {\n\t\tfeatures.bug_image_bitmap_orientation_region = result;\n\t}).catch(() => {});\n\tconst cibResize = check_cib_resize_async().then((result) => {\n\t\tfeatures.cib_resize = result;\n\t}).catch(() => {});\n\tchecking = Promise.all([\n\t\tbugCanvasOrientationRegion,\n\t\tbugImageBitmapOrientationRegion,\n\t\tcibResize\n\t]).then(() => {\n\t\tchecked = true;\n\t\tchecking = null;\n\t\treturn Object.assign({}, features);\n\t}, (err) => {\n\t\tchecking = null;\n\t\tthrow err;\n\t});\n\treturn checking;\n}\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) {\n\ttry {\n\t\tvar i = n[a](c), u = i.value;\n\t} catch (n) {\n\t\te(n);\n\t\treturn;\n\t}\n\ti.done ? t(u) : Promise.resolve(u).then(r, o);\n}\nfunction _asyncToGenerator(n) {\n\treturn function() {\n\t\tvar t = this, e = arguments;\n\t\treturn new Promise(function(r, o) {\n\t\t\tvar a = n.apply(t, e);\n\t\t\tfunction _next(n) {\n\t\t\t\tasyncGeneratorStep(a, r, o, _next, _throw, \"next\", n);\n\t\t\t}\n\t\t\tfunction _throw(n) {\n\t\t\t\tasyncGeneratorStep(a, r, o, _next, _throw, \"throw\", n);\n\t\t\t}\n\t\t\t_next(void 0);\n\t\t});\n\t};\n}\nvar WORKER_SRC = \"/*!\\n\\npica\\nhttps://github.com/nodeca/pica\\n\\n*/\\n!function(){var A;function t(A){const t=A.replace(/[\\\\r\\\\n=]/g,\\\"\\\"),e=t.length,n=new Uint8Array(3*e>>2);let a=0,i=0;for(let s=0;s<e;s++)s%4==0&&s&&(n[i++]=a>>16&255,n[i++]=a>>8&255,n[i++]=255&a),a=a<<6|\\\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\\\".indexOf(t.charAt(s));const r=e%4*6;return 0===r?(n[i++]=a>>16&255,n[i++]=a>>8&255,n[i++]=255&a):18===r?(n[i++]=a>>10&255,n[i++]=a>>2&255):12===r&&(n[i++]=a>>4&255),n}var e={js:!0,wasm:!0},n=class{constructor(A){const t=Object.assign({},e,A||{});if(this.options=t,this.__cache={},this.__init_promise=null,this.__modules=t.modules||{},this.__memory=null,this.__wasm={},this.__isLE=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0],!this.options.js&&!this.options.wasm)throw new Error('mathlib: at least \\\"js\\\" or \\\"wasm\\\" should be enabled')}has_wasm(){return function(){if(void 0!==A)return A;if(A=!1,\\\"undefined\\\"==typeof WebAssembly)return A;try{const t=new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]),e=new WebAssembly.Module(t);return 0!==new WebAssembly.Instance(e,{}).exports.test(4)&&(A=!0),A}catch(t){}return A}()}use(A){return this.__modules[A.name]=A,this.options.wasm&&this.has_wasm()&&A.wasm_fn?this[A.name]=A.wasm_fn:this[A.name]=A.fn,this}init(){return this.__init_promise?this.__init_promise:this.options.js||!this.options.wasm||this.has_wasm()?(this.__init_promise=Promise.all(Object.keys(this.__modules).map(A=>{const e=this.__modules[A];return this.options.wasm&&this.has_wasm()&&e.wasm_fn?this.__wasm[A]?null:WebAssembly.compile(t(e.wasm_src)).then(t=>{this.__wasm[A]=t}):null})).then(()=>this),this.__init_promise):Promise.reject(new Error('mathlib: only \\\"wasm\\\" was enabled, but it\\\\'s not supported'))}__reallocate(A){if(!this.__memory)return this.__memory=new WebAssembly.Memory({initial:Math.ceil(A/65536)}),this.__memory;const t=this.__memory.buffer.byteLength;return t<A&&this.__memory.grow(Math.ceil((A-t)/65536)),this.__memory}__instance(A,e,n){if(e&&this.__reallocate(e),!this.__wasm[A]){const e=this.__modules[A];this.__wasm[A]=new WebAssembly.Module(t(e.wasm_src))}if(!this.__cache[A]){const t={memoryBase:0,memory:this.__memory,tableBase:0,table:new WebAssembly.Table({initial:0,element:\\\"anyfunc\\\"})};this.__cache[A]=new WebAssembly.Instance(this.__wasm[A],{env:Object.assign(t,n||{})})}return this.__cache[A]}__align(A,t){const e=A%(t=t||8);return A+(e?t-e:0)}};function a(A,t,e,n,a,i){let r,s,o,g,I,h,B,Q,E,C,c,f,u,m;for(E=0;E<i;E++){for(h=E*a,B=E,Q=0,r=A[h],I=r*n[6],g=I,c=n[0],f=n[1],u=n[4],m=n[5],C=0;C<a;C++)s=A[h],o=s*c+r*f+g*u+I*m,I=g,g=o,r=s,e[Q]=g,Q++,h++;for(h--,Q--,B+=i*(a-1),r=A[h],I=r*n[7],g=I,s=r,c=n[2],f=n[3],C=a-1;C>=0;C--)o=s*c+r*f+g*u+I*m,I=g,g=o,r=s,s=A[h],t[B]=e[Q]+g,h--,Q--,B-=i}}function i(A,t,e,n){if(!n)return;const i=new Uint16Array(A.length),r=new Float32Array(Math.max(t,e)),s=function(A){A<.5&&(A=.5);const t=Math.exp(.527076)/A,e=Math.exp(-t),n=Math.exp(-2*t),a=(1-e)*(1-e)/(1+2*t*e-n),i=a*(t-1)*e,r=a*(t+1)*e,s=-a*n,o=2*e,g=-n;return new Float32Array([a,i,r,s,o,g,(a+i)/(1-o-g),(r+s)/(1-o-g)])}(n);a(A,i,r,s,t,e),a(i,A,r,s,e,t)}var r={name:\\\"unsharp_mask\\\",fn:function(A,t,e,n,a,r){let s,o,g,I,h;if(0===n||a<.5)return;