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B,GAAhBtC,EAAI+B,EAAIH,GACtBK,GAAKQ,EAAOH,GAAcF,EAC1BF,GAAKO,EAAOH,EAAa,GAAKF,EAC9BD,GAAKM,EAAOH,EAAa,GAAKF,EAItCG,EAAa,EAAItB,EAAIe,EAAIc,EACzBC,EAAOR,GAAczB,EAAamB,GAClCc,EAAOR,EAAa,GAAKzB,EAAaoB,GACtCa,EAAOR,EAAa,GAAKzB,EAAaqB,GACtCY,EAAOR,EAAa,GAAK,GAC7B,CAEJ,OAAOQ,CACX,CCrIAE,UAAarC,IACX,MAAM,KAAEsC,EAAI,OAAEzB,EAAM,MAAED,GAAUZ,EAAEuC,KAElC,IAAKD,IAASzB,IAAWD,EAAO,OAEhC,MAAMuB,EAASxB,EAAe2B,EAAM1B,EAAOC,GACrC2B,EAAY,IAAIC,UAAUN,EAAQvB,EAAOC,GAE/C6B,YAAY,CACVF,YACAF,OACA1B,QACAC,UACA,C","sources":["webpack://app/../../node_modules/fast-blurhash/index.js","webpack://app/./src/workers/blurhashWorker.js"],"sourcesContent":["const digitLookup = new Uint8Array(128);\nfor (let i = 0; i < 83; i++) {\n digitLookup[\n '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~'.charCodeAt(\n i,\n )\n ] = i;\n}\nconst decode83 = (str, start, end) => {\n let value = 0;\n while (start < end) {\n value *= 83;\n value += digitLookup[str.charCodeAt(start++)];\n }\n return value;\n};\n\nconst pow = Math.pow;\nconst PI = Math.PI;\nconst PI2 = PI * 2;\n\nconst d = 3294.6;\nconst e = 269.025;\nconst sRGBToLinear = (value) =>\n value > 10.31475 ? pow(value / e + 0.052132, 2.4) : value / d;\n\nconst linearTosRGB = (v) =>\n ~~(v > 0.00001227 ? e * pow(v, 0.416666) - 13.025 : v * d + 1);\n\nconst signSqr = (x) => (x < 0 ? -1 : 1) * x * x;\n\n/**\n * Fast approximate cosine implementation\n * Based on FTrig https://github.com/netcell/FTrig\n */\nconst fastCos = (x) => {\n x += PI / 2;\n while (x > PI) {\n x -= PI2;\n }\n const cos = 1.27323954 * x - 0.405284735 * signSqr(x);\n return 0.225 * (signSqr(cos) - cos) + cos;\n};\n\n/**\n * Extracts average color from BlurHash image\n * @param {string} blurHash BlurHash image string\n * @returns {[number, number, number]}\n */\nexport function getBlurHashAverageColor(blurHash) {\n const val = decode83(blurHash, 2, 6);\n return [val >> 16, (val >> 8) & 255, val & 255];\n}\n\n/**\n * Decodes BlurHash image\n * @param {string} blurHash BlurHash image string\n * @param {number} width Output image width\n * @param {number} height Output image height\n * @param {?number} punch\n * @returns {Uint8ClampedArray}\n */\nexport function decodeBlurHash(blurHash, width, height, punch) {\n const sizeFlag = decode83(blurHash, 0, 1);\n const numX = (sizeFlag % 9) + 1;\n const numY = ~~(sizeFlag / 9) + 1;\n const size = numX * numY;\n\n let i = 0,\n j = 0,\n x = 0,\n y = 0,\n r = 0,\n g = 0,\n b = 0,\n basis = 0,\n basisY = 0,\n colorIndex = 0,\n pixelIndex = 0,\n value = 0;\n\n const maximumValue = ((decode83(blurHash, 1, 2) + 1) / 13446) * (punch | 1);\n\n const colors = new Float64Array(size * 3);\n\n const averageColor = getBlurHashAverageColor(blurHash);\n for (i = 0; i < 3; i++) {\n colors[i] = sRGBToLinear(averageColor[i]);\n }\n\n for (i = 1; i < size; i++) {\n value = decode83(blurHash, 4 + i * 2, 6 + i * 2);\n colors[i * 3] = signSqr(~~(value / 361) - 9) * maximumValue;\n colors[i * 3 + 1] = signSqr((~~(value / 19) % 19) - 9) * maximumValue;\n colors[i * 3 + 2] = signSqr((value % 19) - 9) * maximumValue;\n }\n\n const cosinesY = new Float64Array(numY * height);\n const cosinesX = new Float64Array(numX * width);\n for (j = 0; j < numY; j++) {\n for (y = 0; y < height; y++) {\n cosinesY[j * height + y] = fastCos((PI * y * j) / height);\n }\n }\n for (i = 0; i < numX; i++) {\n for (x = 0; x < width; x++) {\n cosinesX[i * width + x] = fastCos((PI * x * i) / width);\n }\n }\n\n const bytesPerRow = width * 4;\n const pixels = new Uint8ClampedArray(bytesPerRow * height);\n\n for (y = 0; y < height; y++) {\n for (x = 0; x < width; x++) {\n r = g = b = 0;\n for (j = 0; j < numY; j++) {\n basisY = cosinesY[j * height + y];\n for (i = 0; i < numX; i++) {\n basis = cosinesX[i * width + x] * basisY;\n colorIndex = (i + j * numX) * 3;\n r += colors[colorIndex] * basis;\n g += colors[colorIndex + 1] * basis;\n b += colors[colorIndex + 2] * basis;\n }\n }\n\n pixelIndex = 4 * x + y * bytesPerRow;\n pixels[pixelIndex] = linearTosRGB(r);\n pixels[pixelIndex + 1] = linearTosRGB(g);\n pixels[pixelIndex + 2] = linearTosRGB(b);\n pixels[pixelIndex + 3] = 255; // alpha\n }\n }\n return pixels;\n}\n","import { decodeBlurHash } from 'fast-blurhash';\n\nonmessage = (e) => {\n const { hash, height, width } = e.data;\n\n if (!hash || !height || !width) return;\n\n const pixels = decodeBlurHash(hash, width, height);\n const imageData = new ImageData(pixels, width, height);\n\n postMessage({\n imageData,\n hash,\n width,\n height,\n });\n};\n"],"names":["digitLookup","Uint8Array","i","charCodeAt","decode83","str","start","end","value","pow","Math","PI","PI2","d","e","sRGBToLinear","linearTosRGB","v","signSqr","x","fastCos","cos","getBlurHashAverageColor","blurHash","val","decodeBlurHash","width","height","punch","sizeFlag","numX","numY","size","j","y","r","g","b","basis","basisY","colorIndex","pixelIndex","maximumValue","colors","Float64Array","averageColor","cosinesY","cosinesX","bytesPerRow","pixels","Uint8ClampedArray","onmessage","hash","data","imageData","ImageData","postMessage"],"sourceRoot":""}