{"version":3,"sources":["webpack:///./node_modules/.pnpm/geotiff@1.0.9/node_modules/geotiff/src/compression/lzw.js","webpack:///./node_modules/.pnpm/geotiff@1.0.9/node_modules/geotiff/src/predictor.js","webpack:///./node_modules/.pnpm/geotiff@1.0.9/node_modules/geotiff/src/compression/basedecoder.js"],"names":["MIN_BITS","CLEAR_CODE","EOI_CODE","MAX_BYTELENGTH","getByte","array","position","length","d","a","Math","floor","de","ef","fg","dg","max","console","warn","chunk1","chunks","chunk2","hi","chunk3","appendReversed","dest","source","i","push","decompress","input","dictionaryIndex","Uint16Array","dictionaryChar","Uint8Array","dictionaryLength","byteLength","initDictionary","getNext","byte","addToDictionary","c","getDictionaryReversed","n","rev","result","oldCode","code","Error","val","oldVal","undefined","LZWDecoder","buffer","decodeRowAcc","row","stride","offset","decodeRowFloatingPoint","bytesPerSample","index","count","wc","copy","slice","b","applyPredictor","block","predictor","width","height","bitsPerSample","planarConfiguration","Uint32Array","fileDirectory","decoded","this","decodeBlock","Predictor","isTiled","StripOffsets","tileWidth","TileWidth","ImageWidth","tileHeight","TileLength","RowsPerStrip","ImageLength","BitsPerSample","PlanarConfiguration"],"mappings":"gHAAA,+DAEA,MAAMA,EAAW,EACXC,EAAa,IACbC,EAAW,IACXC,EAAiB,GAEvB,SAASC,EAAQC,EAAOC,EAAUC,GAChC,MAAMC,EAAIF,EAAW,EACfG,EAAIC,KAAKC,MAAML,EAAW,GAC1BM,EAAK,EAAIJ,EACTK,EAAMP,EAAWC,EAAqB,GAATE,EAAI,GACvC,IAAIK,EAAM,GAAKL,EAAI,IAAOH,EAAWC,GACrC,MAAMQ,EAAgB,GAATN,EAAI,GAAUH,EAE3B,GADAQ,EAAKJ,KAAKM,IAAI,EAAGF,GACbL,GAAKJ,EAAME,OAEb,OADAU,QAAQC,KAAK,6EACNhB,EAET,IAAIiB,EAASd,EAAMI,GAAO,IAAM,EAAID,GAAM,EAC1CW,IAAYZ,EAASK,EACrB,IAAIQ,EAASD,EACb,GAAIV,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E/DD,EAAuBH,EAAKC,EAAQG,IAGxC,OAAOQ,E,kCCpFM,MAAM,EACnB,aAAaO,EAAerB,GAC1B,MAAMsB,QAAgBC,KAAKC,YAAYxB,GACjCe,EAAYM,EAAcI,WAAa,EAC7C,GAAkB,IAAdV,EAAiB,CACnB,MAAMW,GAAWL,EAAcM,aACzBC,EAAYF,EAAUL,EAAcQ,UAAYR,EAAcS,WAC9DC,EAAaL,EAAUL,EAAcW,WACzCX,EAAcY,cAAgBZ,EAAca,YAE9C,OAAOrB,EACLS,EAASP,EAAWa,EAAWG,EAAYV,EAAcc,cACzDd,EAAce,qBAGlB,OAAOd","file":"chunk-3e0d8aaa.56704606ec8b39b8a9be.js","sourcesContent":["import BaseDecoder from './basedecoder';\n\nconst MIN_BITS = 9;\nconst CLEAR_CODE = 256; // clear code\nconst EOI_CODE = 257; // end of information\nconst MAX_BYTELENGTH = 12;\n\nfunction getByte(array, position, length) {\n const d = position % 8;\n const a = Math.floor(position / 8);\n const de = 8 - d;\n const ef = (position + length) - ((a + 1) * 8);\n let fg = (8 * (a + 2)) - (position + length);\n const dg = ((a + 2) * 8) - position;\n fg = Math.max(0, fg);\n if (a >= array.length) {\n console.warn('ran off the end of the buffer before finding EOI_CODE (end on input code)');\n return EOI_CODE;\n }\n let chunk1 = array[a] & ((2 ** (8 - d)) - 1);\n chunk1 <<= (length - de);\n let chunks = chunk1;\n if (a + 1 < array.length) {\n let chunk2 = array[a + 1] >>> fg;\n chunk2 <<= Math.max(0, (length - dg));\n chunks += chunk2;\n }\n if (ef > 8 && a + 2 < array.length) {\n const hi = ((a + 3) * 8) - (position + length);\n const chunk3 = array[a + 2] >>> hi;\n chunks += chunk3;\n }\n return chunks;\n}\n\nfunction appendReversed(dest, source) {\n for (let i = source.length - 1; i >= 0; i--) {\n dest.push(source[i]);\n }\n return dest;\n}\n\nfunction decompress(input) {\n const dictionaryIndex = new Uint16Array(4093);\n const dictionaryChar = new Uint8Array(4093);\n for (let i = 0; i <= 257; i++) {\n dictionaryIndex[i] = 4096;\n dictionaryChar[i] = i;\n }\n let dictionaryLength = 258;\n let byteLength = MIN_BITS;\n let position = 0;\n\n function initDictionary() {\n dictionaryLength = 258;\n byteLength = MIN_BITS;\n }\n function getNext(array) {\n const byte = getByte(array, position, byteLength);\n position += byteLength;\n return byte;\n }\n function addToDictionary(i, c) {\n dictionaryChar[dictionaryLength] = c;\n dictionaryIndex[dictionaryLength] = i;\n dictionaryLength++;\n return dictionaryLength - 1;\n }\n function getDictionaryReversed(n) {\n const rev = [];\n for (let i = n; i !== 4096; i = dictionaryIndex[i]) {\n rev.push(dictionaryChar[i]);\n }\n return rev;\n }\n\n const result = [];\n initDictionary();\n const array = new Uint8Array(input);\n let code = getNext(array);\n let oldCode;\n while (code !== EOI_CODE) {\n if (code === CLEAR_CODE) {\n initDictionary();\n code = getNext(array);\n while (code === CLEAR_CODE) {\n code = getNext(array);\n }\n\n if (code === EOI_CODE) {\n break;\n } else if (code > CLEAR_CODE) {\n throw new Error(`corrupted code at scanline ${code}`);\n } else {\n const val = getDictionaryReversed(code);\n appendReversed(result, val);\n oldCode = code;\n }\n } else if (code < dictionaryLength) {\n const val = getDictionaryReversed(code);\n appendReversed(result, val);\n addToDictionary(oldCode, val[val.length - 1]);\n oldCode = code;\n } else {\n const oldVal = getDictionaryReversed(oldCode);\n if (!oldVal) {\n throw new Error(`Bogus entry. Not in dictionary, ${oldCode} / ${dictionaryLength}, position: ${position}`);\n }\n appendReversed(result, oldVal);\n result.push(oldVal[oldVal.length - 1]);\n addToDictionary(oldCode, oldVal[oldVal.length - 1]);\n oldCode = code;\n }\n\n if (dictionaryLength + 1 >= (2 ** byteLength)) {\n if (byteLength === MAX_BYTELENGTH) {\n oldCode = undefined;\n } else {\n byteLength++;\n }\n }\n code = getNext(array);\n }\n return new Uint8Array(result);\n}\n\nexport default class LZWDecoder extends BaseDecoder {\n decodeBlock(buffer) {\n return decompress(buffer, false).buffer;\n }\n}\n","function decodeRowAcc(row, stride) {\n let length = row.length - stride;\n let offset = 0;\n do {\n for (let i = stride; i > 0; i--) {\n row[offset + stride] += row[offset];\n offset++;\n }\n\n length -= stride;\n } while (length > 0);\n}\n\nfunction decodeRowFloatingPoint(row, stride, bytesPerSample) {\n let index = 0;\n let count = row.length;\n const wc = count / bytesPerSample;\n\n while (count > stride) {\n for (let i = stride; i > 0; --i) {\n row[index + stride] += row[index];\n ++index;\n }\n count -= stride;\n }\n\n const copy = row.slice();\n for (let i = 0; i < wc; ++i) {\n for (let b = 0; b < bytesPerSample; ++b) {\n row[(bytesPerSample * i) + b] = copy[((bytesPerSample - b - 1) * wc) + i];\n }\n }\n}\n\nexport function applyPredictor(block, predictor, width, height, bitsPerSample,\n planarConfiguration) {\n if (!predictor || predictor === 1) {\n return block;\n }\n\n for (let i = 0; i < bitsPerSample.length; ++i) {\n if (bitsPerSample[i] % 8 !== 0) {\n throw new Error('When decoding with predictor, only multiple of 8 bits are supported.');\n }\n if (bitsPerSample[i] !== bitsPerSample[0]) {\n throw new Error('When decoding with predictor, all samples must have the same size.');\n }\n }\n\n const bytesPerSample = bitsPerSample[0] / 8;\n const stride = planarConfiguration === 2 ? 1 : bitsPerSample.length;\n\n for (let i = 0; i < height; ++i) {\n // Last strip will be truncated if height % stripHeight != 0\n if (i * stride * width * bytesPerSample >= block.byteLength) {\n break;\n }\n let row;\n if (predictor === 2) { // horizontal prediction\n switch (bitsPerSample[0]) {\n case 8:\n row = new Uint8Array(\n block, i * stride * width * bytesPerSample, stride * width * bytesPerSample,\n );\n break;\n case 16:\n row = new Uint16Array(\n block, i * stride * width * bytesPerSample, stride * width * bytesPerSample / 2,\n );\n break;\n case 32:\n row = new Uint32Array(\n block, i * stride * width * bytesPerSample, stride * width * bytesPerSample / 4,\n );\n break;\n default:\n throw new Error(`Predictor 2 not allowed with ${bitsPerSample[0]} bits per sample.`);\n }\n decodeRowAcc(row, stride, bytesPerSample);\n } else if (predictor === 3) { // horizontal floating point\n row = new Uint8Array(\n block, i * stride * width * bytesPerSample, stride * width * bytesPerSample,\n );\n decodeRowFloatingPoint(row, stride, bytesPerSample);\n }\n }\n return block;\n}\n","import { applyPredictor } from '../predictor';\n\nexport default class BaseDecoder {\n async decode(fileDirectory, buffer) {\n const decoded = await this.decodeBlock(buffer);\n const predictor = fileDirectory.Predictor || 1;\n if (predictor !== 1) {\n const isTiled = !fileDirectory.StripOffsets;\n const tileWidth = isTiled ? fileDirectory.TileWidth : fileDirectory.ImageWidth;\n const tileHeight = isTiled ? fileDirectory.TileLength : (\n fileDirectory.RowsPerStrip || fileDirectory.ImageLength\n );\n return applyPredictor(\n decoded, predictor, tileWidth, tileHeight, fileDirectory.BitsPerSample,\n fileDirectory.PlanarConfiguration,\n );\n }\n return decoded;\n }\n}\n"],"sourceRoot":""}