geotiff 3.0.2 → 3.0.4-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-browser/geotiff.js +3 -3
- package/dist-browser/geotiff.js.map +1 -1
- package/dist-module/compression/basedecoder.d.ts +30 -4
- package/dist-module/compression/basedecoder.d.ts.map +1 -1
- package/dist-module/compression/basedecoder.js +22 -1
- package/dist-module/compression/basedecoder.js.map +1 -0
- package/dist-module/compression/deflate.d.ts +2 -1
- package/dist-module/compression/deflate.d.ts.map +1 -1
- package/dist-module/compression/deflate.js +2 -0
- package/dist-module/compression/deflate.js.map +1 -0
- package/dist-module/compression/index.d.ts +14 -22
- package/dist-module/compression/index.d.ts.map +1 -1
- package/dist-module/compression/index.js +36 -25
- package/dist-module/compression/index.js.map +1 -0
- package/dist-module/compression/jpeg.d.ts +55 -15
- package/dist-module/compression/jpeg.d.ts.map +1 -1
- package/dist-module/compression/jpeg.js +187 -16
- package/dist-module/compression/jpeg.js.map +1 -0
- package/dist-module/compression/lerc.d.ts +11 -1
- package/dist-module/compression/lerc.d.ts.map +1 -1
- package/dist-module/compression/lerc.js +16 -4
- package/dist-module/compression/lerc.js.map +1 -0
- package/dist-module/compression/lzw.d.ts +2 -1
- package/dist-module/compression/lzw.d.ts.map +1 -1
- package/dist-module/compression/lzw.js +29 -1
- package/dist-module/compression/lzw.js.map +1 -0
- package/dist-module/compression/packbits.d.ts +2 -1
- package/dist-module/compression/packbits.d.ts.map +1 -1
- package/dist-module/compression/packbits.js +2 -0
- package/dist-module/compression/packbits.js.map +1 -0
- package/dist-module/compression/raw.d.ts +2 -1
- package/dist-module/compression/raw.d.ts.map +1 -1
- package/dist-module/compression/raw.js +2 -0
- package/dist-module/compression/raw.js.map +1 -0
- package/dist-module/compression/webimage.d.ts +2 -1
- package/dist-module/compression/webimage.d.ts.map +1 -1
- package/dist-module/compression/webimage.js +5 -0
- package/dist-module/compression/webimage.js.map +1 -0
- package/dist-module/compression/zstd.d.ts +4 -2
- package/dist-module/compression/zstd.d.ts.map +1 -1
- package/dist-module/compression/zstd.js +3 -1
- package/dist-module/compression/zstd.js.map +1 -0
- package/dist-module/dataslice.d.ts +78 -22
- package/dist-module/dataslice.d.ts.map +1 -1
- package/dist-module/dataslice.js +57 -1
- package/dist-module/dataslice.js.map +1 -0
- package/dist-module/dataview64.d.ts +71 -14
- package/dist-module/dataview64.d.ts.map +1 -1
- package/dist-module/dataview64.js +58 -1
- package/dist-module/dataview64.js.map +1 -0
- package/dist-module/geotiff.d.ts +61 -12
- package/dist-module/geotiff.d.ts.map +1 -1
- package/dist-module/geotiff.js +73 -14
- package/dist-module/geotiff.js.map +1 -0
- package/dist-module/geotiffimage.d.ts +41 -15
- package/dist-module/geotiffimage.d.ts.map +1 -1
- package/dist-module/geotiffimage.js +132 -52
- package/dist-module/geotiffimage.js.map +1 -0
- package/dist-module/geotiffwriter.d.ts +28 -1
- package/dist-module/geotiffwriter.d.ts.map +1 -1
- package/dist-module/geotiffwriter.js +206 -84
- package/dist-module/geotiffwriter.js.map +1 -0
- package/dist-module/globals.d.ts +912 -92
- package/dist-module/globals.d.ts.map +1 -1
- package/dist-module/globals.js +201 -227
- package/dist-module/globals.js.map +1 -0
- package/dist-module/imagefiledirectory.d.ts +72 -19
- package/dist-module/imagefiledirectory.d.ts.map +1 -1
- package/dist-module/imagefiledirectory.js +51 -26
- package/dist-module/imagefiledirectory.js.map +1 -0
- package/dist-module/logging.d.ts +36 -10
- package/dist-module/logging.d.ts.map +1 -1
- package/dist-module/logging.js +16 -2
- package/dist-module/logging.js.map +1 -0
- package/dist-module/pool.d.ts +15 -8
- package/dist-module/pool.d.ts.map +1 -1
- package/dist-module/pool.js +11 -3
- package/dist-module/pool.js.map +1 -0
- package/dist-module/predictor.d.ts +10 -1
- package/dist-module/predictor.d.ts.map +1 -1
- package/dist-module/predictor.js +19 -0
- package/dist-module/predictor.js.map +1 -0
- package/dist-module/resample.d.ts.map +1 -1
- package/dist-module/resample.js +12 -0
- package/dist-module/resample.js.map +1 -0
- package/dist-module/rgb.js +1 -0
- package/dist-module/rgb.js.map +1 -0
- package/dist-module/source/arraybuffer.d.ts +7 -4
- package/dist-module/source/arraybuffer.d.ts.map +1 -1
- package/dist-module/source/arraybuffer.js +15 -1
- package/dist-module/source/arraybuffer.js.map +1 -0
- package/dist-module/source/basesource.d.ts +11 -6
- package/dist-module/source/basesource.d.ts.map +1 -1
- package/dist-module/source/basesource.js +7 -4
- package/dist-module/source/basesource.js.map +1 -0
- package/dist-module/source/blockedsource.d.ts +2 -2
- package/dist-module/source/blockedsource.d.ts.map +1 -1
- package/dist-module/source/blockedsource.js +8 -5
- package/dist-module/source/blockedsource.js.map +1 -0
- package/dist-module/source/client/base.d.ts +8 -7
- package/dist-module/source/client/base.d.ts.map +1 -1
- package/dist-module/source/client/base.js +7 -5
- package/dist-module/source/client/base.js.map +1 -0
- package/dist-module/source/client/fetch.d.ts +6 -2
- package/dist-module/source/client/fetch.d.ts.map +1 -1
- package/dist-module/source/client/fetch.js +7 -2
- package/dist-module/source/client/fetch.js.map +1 -0
- package/dist-module/source/client/http.d.ts +27 -5
- package/dist-module/source/client/http.d.ts.map +1 -1
- package/dist-module/source/client/http.js +16 -2
- package/dist-module/source/client/http.js.map +1 -0
- package/dist-module/source/client/xhr.d.ts +22 -3
- package/dist-module/source/client/xhr.d.ts.map +1 -1
- package/dist-module/source/client/xhr.js +12 -2
- package/dist-module/source/client/xhr.js.map +1 -0
- package/dist-module/source/file.d.ts +8 -5
- package/dist-module/source/file.d.ts.map +1 -1
- package/dist-module/source/file.js +40 -8
- package/dist-module/source/file.js.map +1 -0
- package/dist-module/source/filereader.d.ts +12 -4
- package/dist-module/source/filereader.d.ts.map +1 -1
- package/dist-module/source/filereader.js +15 -2
- package/dist-module/source/filereader.js.map +1 -0
- package/dist-module/source/httputils.d.ts +16 -9
- package/dist-module/source/httputils.d.ts.map +1 -1
- package/dist-module/source/httputils.js +19 -12
- package/dist-module/source/httputils.js.map +1 -0
- package/dist-module/source/remote.d.ts.map +1 -1
- package/dist-module/source/remote.js +19 -7
- package/dist-module/source/remote.js.map +1 -0
- package/dist-module/utils.d.ts +36 -41
- package/dist-module/utils.d.ts.map +1 -1
- package/dist-module/utils.js +17 -12
- package/dist-module/utils.js.map +1 -0
- package/dist-module/worker/create.js +1 -1
- package/dist-module/worker/create.js.map +1 -0
- package/dist-module/worker/decoder.d.ts +2 -0
- package/dist-module/worker/decoder.d.ts.map +1 -0
- package/dist-module/worker/decoder.js +21 -0
- package/dist-module/worker/decoder.js.map +1 -0
- package/dist-node/compression/basedecoder.d.ts +30 -4
- package/dist-node/compression/basedecoder.d.ts.map +1 -1
- package/dist-node/compression/basedecoder.js +22 -1
- package/dist-node/compression/basedecoder.js.map +1 -1
- package/dist-node/compression/deflate.d.ts +2 -1
- package/dist-node/compression/deflate.d.ts.map +1 -1
- package/dist-node/compression/deflate.js +2 -0
- package/dist-node/compression/deflate.js.map +1 -1
- package/dist-node/compression/index.d.ts +14 -22
- package/dist-node/compression/index.d.ts.map +1 -1
- package/dist-node/compression/index.js +36 -25
- package/dist-node/compression/index.js.map +1 -1
- package/dist-node/compression/jpeg.d.ts +55 -16
- package/dist-node/compression/jpeg.d.ts.map +1 -1
- package/dist-node/compression/jpeg.js +187 -16
- package/dist-node/compression/jpeg.js.map +1 -1
- package/dist-node/compression/lerc.d.ts +11 -1
- package/dist-node/compression/lerc.d.ts.map +1 -1
- package/dist-node/compression/lerc.js +16 -4
- package/dist-node/compression/lerc.js.map +1 -1
- package/dist-node/compression/lzw.d.ts +2 -1
- package/dist-node/compression/lzw.d.ts.map +1 -1
- package/dist-node/compression/lzw.js +29 -1
- package/dist-node/compression/lzw.js.map +1 -1
- package/dist-node/compression/packbits.d.ts +2 -1
- package/dist-node/compression/packbits.d.ts.map +1 -1
- package/dist-node/compression/packbits.js +2 -0
- package/dist-node/compression/packbits.js.map +1 -1
- package/dist-node/compression/raw.d.ts +2 -1
- package/dist-node/compression/raw.d.ts.map +1 -1
- package/dist-node/compression/raw.js +2 -0
- package/dist-node/compression/raw.js.map +1 -1
- package/dist-node/compression/webimage.d.ts +2 -2
- package/dist-node/compression/webimage.d.ts.map +1 -1
- package/dist-node/compression/webimage.js +5 -0
- package/dist-node/compression/webimage.js.map +1 -1
- package/dist-node/compression/zstd.d.ts +2 -1
- package/dist-node/compression/zstd.d.ts.map +1 -1
- package/dist-node/compression/zstd.js +3 -1
- package/dist-node/compression/zstd.js.map +1 -1
- package/dist-node/dataslice.d.ts +78 -22
- package/dist-node/dataslice.d.ts.map +1 -1
- package/dist-node/dataslice.js +57 -1
- package/dist-node/dataslice.js.map +1 -1
- package/dist-node/dataview64.d.ts +71 -14
- package/dist-node/dataview64.d.ts.map +1 -1
- package/dist-node/dataview64.js +58 -1
- package/dist-node/dataview64.js.map +1 -1
- package/dist-node/geotiff.d.ts +61 -12
- package/dist-node/geotiff.d.ts.map +1 -1
- package/dist-node/geotiff.js +75 -15
- package/dist-node/geotiff.js.map +1 -1
- package/dist-node/geotiffimage.d.ts +41 -15
- package/dist-node/geotiffimage.d.ts.map +1 -1
- package/dist-node/geotiffimage.js +132 -52
- package/dist-node/geotiffimage.js.map +1 -1
- package/dist-node/geotiffwriter.d.ts +28 -1
- package/dist-node/geotiffwriter.d.ts.map +1 -1
- package/dist-node/geotiffwriter.js +206 -84
- package/dist-node/geotiffwriter.js.map +1 -1
- package/dist-node/globals.d.ts +910 -90
- package/dist-node/globals.d.ts.map +1 -1
- package/dist-node/globals.js +202 -228
- package/dist-node/globals.js.map +1 -1
- package/dist-node/imagefiledirectory.d.ts +72 -19
- package/dist-node/imagefiledirectory.d.ts.map +1 -1
- package/dist-node/imagefiledirectory.js +51 -26
- package/dist-node/imagefiledirectory.js.map +1 -1
- package/dist-node/logging.d.ts +36 -10
- package/dist-node/logging.d.ts.map +1 -1
- package/dist-node/logging.js +16 -2
- package/dist-node/logging.js.map +1 -1
- package/dist-node/pool.d.ts +15 -8
- package/dist-node/pool.d.ts.map +1 -1
- package/dist-node/pool.js +11 -3
- package/dist-node/pool.js.map +1 -1
- package/dist-node/predictor.d.ts +10 -1
- package/dist-node/predictor.d.ts.map +1 -1
- package/dist-node/predictor.js +19 -0
- package/dist-node/predictor.js.map +1 -1
- package/dist-node/resample.d.ts.map +1 -1
- package/dist-node/resample.js +12 -0
- package/dist-node/resample.js.map +1 -1
- package/dist-node/rgb.js +1 -0
- package/dist-node/rgb.js.map +1 -1
- package/dist-node/source/arraybuffer.d.ts +7 -4
- package/dist-node/source/arraybuffer.d.ts.map +1 -1
- package/dist-node/source/arraybuffer.js +15 -1
- package/dist-node/source/arraybuffer.js.map +1 -1
- package/dist-node/source/basesource.d.ts +11 -6
- package/dist-node/source/basesource.d.ts.map +1 -1
- package/dist-node/source/basesource.js +7 -4
- package/dist-node/source/basesource.js.map +1 -1
- package/dist-node/source/blockedsource.d.ts +2 -2
- package/dist-node/source/blockedsource.d.ts.map +1 -1
- package/dist-node/source/blockedsource.js +8 -5
- package/dist-node/source/blockedsource.js.map +1 -1
- package/dist-node/source/client/base.d.ts +8 -7
- package/dist-node/source/client/base.d.ts.map +1 -1
- package/dist-node/source/client/base.js +7 -5
- package/dist-node/source/client/base.js.map +1 -1
- package/dist-node/source/client/fetch.d.ts +5 -2
- package/dist-node/source/client/fetch.d.ts.map +1 -1
- package/dist-node/source/client/fetch.js +7 -2
- package/dist-node/source/client/fetch.js.map +1 -1
- package/dist-node/source/client/http.d.ts +22 -4
- package/dist-node/source/client/http.d.ts.map +1 -1
- package/dist-node/source/client/http.js +16 -2
- package/dist-node/source/client/http.js.map +1 -1
- package/dist-node/source/client/xhr.d.ts +23 -3
- package/dist-node/source/client/xhr.d.ts.map +1 -1
- package/dist-node/source/client/xhr.js +12 -2
- package/dist-node/source/client/xhr.js.map +1 -1
- package/dist-node/source/file.d.ts +8 -5
- package/dist-node/source/file.d.ts.map +1 -1
- package/dist-node/source/file.js +40 -8
- package/dist-node/source/file.js.map +1 -1
- package/dist-node/source/filereader.d.ts +12 -4
- package/dist-node/source/filereader.d.ts.map +1 -1
- package/dist-node/source/filereader.js +15 -2
- package/dist-node/source/filereader.js.map +1 -1
- package/dist-node/source/httputils.d.ts +16 -9
- package/dist-node/source/httputils.d.ts.map +1 -1
- package/dist-node/source/httputils.js +19 -12
- package/dist-node/source/httputils.js.map +1 -1
- package/dist-node/source/remote.d.ts.map +1 -1
- package/dist-node/source/remote.js +19 -7
- package/dist-node/source/remote.js.map +1 -1
- package/dist-node/utils.d.ts +9 -8
- package/dist-node/utils.d.ts.map +1 -1
- package/dist-node/utils.js +17 -12
- package/dist-node/utils.js.map +1 -1
- package/dist-node/worker/create.js +1 -1
- package/dist-node/worker/create.js.map +1 -1
- package/dist-node/worker/decoder.d.ts +2 -0
- package/dist-node/worker/decoder.d.ts.map +1 -0
- package/dist-node/worker/decoder.js +24 -0
- package/dist-node/worker/decoder.js.map +1 -0
- package/package.json +5 -3
|
@@ -1,10 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} BaseDecoderParameters
|
|
3
|
+
* @property {number} tileWidth
|
|
4
|
+
* @property {number} tileHeight
|
|
5
|
+
* @property {number} predictor
|
|
6
|
+
* @property {number|number[]|import('../geotiff.js').TypedArray} bitsPerSample
|
|
7
|
+
* @property {number} planarConfiguration
|
|
8
|
+
* @property {number} [samplesPerPixel]
|
|
9
|
+
*/
|
|
1
10
|
export default class BaseDecoder {
|
|
2
|
-
|
|
3
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @param {BaseDecoderParameters} parameters
|
|
13
|
+
*/
|
|
14
|
+
constructor(parameters: BaseDecoderParameters);
|
|
15
|
+
parameters: BaseDecoderParameters;
|
|
4
16
|
/**
|
|
5
17
|
* @abstract
|
|
18
|
+
* @param {ArrayBufferLike} _buffer
|
|
19
|
+
* @returns {Promise<ArrayBufferLike>|ArrayBufferLike}
|
|
20
|
+
*/
|
|
21
|
+
decodeBlock(_buffer: ArrayBufferLike): Promise<ArrayBufferLike> | ArrayBufferLike;
|
|
22
|
+
/**
|
|
23
|
+
* @param {ArrayBufferLike} buffer
|
|
24
|
+
* @returns {Promise<ArrayBufferLike>}
|
|
6
25
|
*/
|
|
7
|
-
|
|
8
|
-
decode(buffer: any): Promise<any>;
|
|
26
|
+
decode(buffer: ArrayBufferLike): Promise<ArrayBufferLike>;
|
|
9
27
|
}
|
|
28
|
+
export type BaseDecoderParameters = {
|
|
29
|
+
tileWidth: number;
|
|
30
|
+
tileHeight: number;
|
|
31
|
+
predictor: number;
|
|
32
|
+
bitsPerSample: number | number[] | import("../geotiff.js").TypedArray;
|
|
33
|
+
planarConfiguration: number;
|
|
34
|
+
samplesPerPixel?: number | undefined;
|
|
35
|
+
};
|
|
10
36
|
//# sourceMappingURL=basedecoder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basedecoder.d.ts","sourceRoot":"","sources":["../../src/compression/basedecoder.js"],"names":[],"mappings":"AAEA;IACE,
|
|
1
|
+
{"version":3,"file":"basedecoder.d.ts","sourceRoot":"","sources":["../../src/compression/basedecoder.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH;IACE;;OAEG;IACH,wBAFW,qBAAqB,EAI/B;IADC,kCAA4B;IAG9B;;;;OAIG;IACH,qBAHW,eAAe,GACb,OAAO,CAAC,eAAe,CAAC,GAAC,eAAe,CAIpD;IAED;;;OAGG;IACH,eAHW,eAAe,GACb,OAAO,CAAC,eAAe,CAAC,CAiBpC;CACF;;eA7Ca,MAAM;gBACN,MAAM;eACN,MAAM;mBACN,MAAM,GAAC,MAAM,EAAE,GAAC,OAAO,eAAe,EAAE,UAAU;yBAClD,MAAM"}
|
|
@@ -1,20 +1,41 @@
|
|
|
1
1
|
import { applyPredictor } from '../predictor.js';
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {Object} BaseDecoderParameters
|
|
4
|
+
* @property {number} tileWidth
|
|
5
|
+
* @property {number} tileHeight
|
|
6
|
+
* @property {number} predictor
|
|
7
|
+
* @property {number|number[]|import('../geotiff.js').TypedArray} bitsPerSample
|
|
8
|
+
* @property {number} planarConfiguration
|
|
9
|
+
* @property {number} [samplesPerPixel]
|
|
10
|
+
*/
|
|
2
11
|
export default class BaseDecoder {
|
|
12
|
+
/**
|
|
13
|
+
* @param {BaseDecoderParameters} parameters
|
|
14
|
+
*/
|
|
3
15
|
constructor(parameters) {
|
|
4
16
|
this.parameters = parameters;
|
|
5
17
|
}
|
|
6
18
|
/**
|
|
7
19
|
* @abstract
|
|
20
|
+
* @param {ArrayBufferLike} _buffer
|
|
21
|
+
* @returns {Promise<ArrayBufferLike>|ArrayBufferLike}
|
|
8
22
|
*/
|
|
9
23
|
decodeBlock(_buffer) {
|
|
10
24
|
throw new Error('decodeBlock not implemented');
|
|
11
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* @param {ArrayBufferLike} buffer
|
|
28
|
+
* @returns {Promise<ArrayBufferLike>}
|
|
29
|
+
*/
|
|
12
30
|
async decode(buffer) {
|
|
13
31
|
const decoded = await this.decodeBlock(buffer);
|
|
14
32
|
const { tileWidth, tileHeight, predictor, bitsPerSample, planarConfiguration, } = this.parameters;
|
|
15
33
|
if (predictor !== 1) {
|
|
16
|
-
|
|
34
|
+
const isBitsPerSampleArray = Array.isArray(bitsPerSample) || ArrayBuffer.isView(bitsPerSample);
|
|
35
|
+
const adaptedBitsPerSample = isBitsPerSampleArray ? Array.from(bitsPerSample) : [bitsPerSample];
|
|
36
|
+
return applyPredictor(decoded, predictor, tileWidth, tileHeight, adaptedBitsPerSample, planarConfiguration);
|
|
17
37
|
}
|
|
18
38
|
return decoded;
|
|
19
39
|
}
|
|
20
40
|
}
|
|
41
|
+
//# sourceMappingURL=basedecoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basedecoder.js","sourceRoot":"","sources":["../../src/compression/basedecoder.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;;;;GAQG;AAEH,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B;;OAEG;IACH,YAAY,UAAU;QACpB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,OAAO;QACjB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,MAAM;QACjB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE/C,MAAM,EACJ,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,mBAAmB,GACrE,GAAG,IAAI,CAAC,UAAU,CAAC;QACpB,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;YACpB,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YAC/F,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;YAChG,OAAO,cAAc,CACnB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,oBAAoB,EAC/D,mBAAmB,CACpB,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deflate.d.ts","sourceRoot":"","sources":["../../src/compression/deflate.js"],"names":[],"mappings":"AAGA;IACE,
|
|
1
|
+
{"version":3,"file":"deflate.d.ts","sourceRoot":"","sources":["../../src/compression/deflate.js"],"names":[],"mappings":"AAGA;IACE,kCAAkC;IAClC,oBADY,WAAW,eAGtB;CACF;wBAPuB,kBAAkB"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { inflate } from 'pako';
|
|
2
2
|
import BaseDecoder from './basedecoder.js';
|
|
3
3
|
export default class DeflateDecoder extends BaseDecoder {
|
|
4
|
+
/** @param {ArrayBuffer} buffer */
|
|
4
5
|
decodeBlock(buffer) {
|
|
5
6
|
return inflate(new Uint8Array(buffer)).buffer;
|
|
6
7
|
}
|
|
7
8
|
}
|
|
9
|
+
//# sourceMappingURL=deflate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deflate.js","sourceRoot":"","sources":["../../src/compression/deflate.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAE3C,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,WAAW;IACrD,kCAAkC;IAClC,WAAW,CAAC,MAAM;QAChB,OAAO,OAAO,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -1,43 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Either a number or undefined.
|
|
3
|
-
* @typedef {(number|undefined)} NumberOrUndefined
|
|
4
|
-
*/
|
|
5
1
|
/**
|
|
6
2
|
* Register a decoder for a specific compression method or a range of compressions
|
|
7
|
-
* @param {(
|
|
8
|
-
* @param {function():Promise} importFn the function to import the decoder
|
|
9
|
-
* @param {function(import("../imagefiledirectory").ImageFileDirectory):Promise} decoderParameterFn
|
|
3
|
+
* @param {(number|undefined|(number|undefined)[])} cases ids of the compression methods to register for
|
|
4
|
+
* @param {function():Promise<typeof BaseDecoder>} importFn the function to import the decoder
|
|
5
|
+
* @param {function(import("../imagefiledirectory").ImageFileDirectory):Promise<BaseDecoderParameters>} decoderParameterFn
|
|
10
6
|
* @param {boolean} preferWorker_ Whether to prefer running the decoder in a worker
|
|
11
7
|
*/
|
|
12
|
-
export function addDecoder(cases: (
|
|
8
|
+
export function addDecoder(cases: (number | undefined | (number | undefined)[]), importFn: () => Promise<typeof BaseDecoder>, decoderParameterFn?: (arg0: import("../imagefiledirectory").ImageFileDirectory) => Promise<BaseDecoderParameters>, preferWorker_?: boolean): void;
|
|
13
9
|
/**
|
|
14
10
|
* Get the required decoder parameters for a specific compression method
|
|
15
|
-
* @param {
|
|
11
|
+
* @param {number|undefined} compression
|
|
16
12
|
* @param {import('../imagefiledirectory.js').ImageFileDirectory} fileDirectory
|
|
17
13
|
*/
|
|
18
|
-
export function getDecoderParameters(compression:
|
|
14
|
+
export function getDecoderParameters(compression: number | undefined, fileDirectory: import("../imagefiledirectory.js").ImageFileDirectory): Promise<BaseDecoderParameters>;
|
|
19
15
|
/**
|
|
20
16
|
* Get a decoder for a specific compression and parameters
|
|
21
17
|
* @param {number} compression the compression method identifier
|
|
22
|
-
* @param {
|
|
18
|
+
* @param {BaseDecoderParameters} decoderParameters the parameters for the decoder
|
|
23
19
|
* @returns {Promise<import('./basedecoder.js').default>}
|
|
24
20
|
*/
|
|
25
|
-
export function getDecoder(compression: number, decoderParameters:
|
|
21
|
+
export function getDecoder(compression: number, decoderParameters: BaseDecoderParameters): Promise<import("./basedecoder.js").default>;
|
|
26
22
|
/**
|
|
27
23
|
* Whether to prefer running the decoder in a worker
|
|
28
24
|
* @param {number|undefined} compression the compression method identifier
|
|
29
25
|
* @returns {boolean}
|
|
30
26
|
*/
|
|
31
27
|
export function preferWorker(compression: number | undefined): boolean;
|
|
32
|
-
export type
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
bitsPerSample: number;
|
|
37
|
-
predictor: number;
|
|
28
|
+
export type RegistryEntry = {
|
|
29
|
+
importFn: () => Promise<typeof BaseDecoder>;
|
|
30
|
+
decoderParameterFn: (arg0: import("../imagefiledirectory").ImageFileDirectory) => Promise<BaseDecoderParameters>;
|
|
31
|
+
preferWorker: boolean;
|
|
38
32
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*/
|
|
42
|
-
export type NumberOrUndefined = (number | undefined);
|
|
33
|
+
import type BaseDecoder from "./basedecoder.js";
|
|
34
|
+
import type { BaseDecoderParameters } from "./basedecoder.js";
|
|
43
35
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compression/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compression/index.js"],"names":[],"mappings":"AAmCA;;;;;;GAMG;AACH,kCALW,CAAC,MAAM,GAAC,SAAS,GAAC,CAAC,MAAM,GAAC,SAAS,CAAC,EAAE,CAAC,YACvC,MAAW,OAAO,CAAC,kBAAkB,CAAC,uBACtC,CAAS,IAAkD,EAAlD,OAAO,uBAAuB,EAAE,kBAAkB,KAAE,OAAO,CAAC,qBAAqB,CAAC,kBAC3F,OAAO,QASjB;AAED;;;;GAIG;AACH,kDAHW,MAAM,GAAC,SAAS,iBAChB,OAAO,0BAA0B,EAAE,kBAAkB,kCAQ/D;AAED;;;;;GAKG;AACH,wCAJW,MAAM,qBACN,qBAAqB,GACnB,OAAO,CAAC,OAAO,kBAAkB,EAAE,OAAO,CAAC,CASvD;AAED;;;;GAIG;AACH,0CAHW,MAAM,GAAC,SAAS,GACd,OAAO,CAOnB;;cArFa,MAAW,OAAO,CAAC,kBAAkB,CAAC;wBACtC,CAAS,IAAkD,EAAlD,OAAO,uBAAuB,EAAE,kBAAkB,KAAE,OAAO,CAAC,qBAAqB,CAAC;kBAC3F,OAAO;;6BANiC,kBAAkB;2CAAlB,kBAAkB"}
|
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
/** @import BaseDecoder, {BaseDecoderParameters} from "./basedecoder.js" */
|
|
2
2
|
/**
|
|
3
|
-
* @typedef {Object}
|
|
4
|
-
* @property {
|
|
5
|
-
* @property {
|
|
6
|
-
* @property {
|
|
7
|
-
* @property {number} bitsPerSample
|
|
8
|
-
* @property {number} predictor
|
|
3
|
+
* @typedef {Object} RegistryEntry
|
|
4
|
+
* @property {function():Promise<typeof BaseDecoder>} importFn
|
|
5
|
+
* @property {function(import("../imagefiledirectory").ImageFileDirectory):Promise<BaseDecoderParameters>} decoderParameterFn
|
|
6
|
+
* @property {boolean} preferWorker
|
|
9
7
|
*/
|
|
8
|
+
/** @type {Map<number | undefined, RegistryEntry>} */
|
|
9
|
+
const registry = new Map();
|
|
10
10
|
/**
|
|
11
11
|
* Default decoder parameter retrieval function
|
|
12
12
|
* @param {import("../imagefiledirectory").ImageFileDirectory} fileDirectory
|
|
13
|
-
* @returns {Promise<
|
|
13
|
+
* @returns {Promise<BaseDecoderParameters>}
|
|
14
14
|
*/
|
|
15
15
|
async function defaultDecoderParameterFn(fileDirectory) {
|
|
16
16
|
const isTiled = !fileDirectory.hasTag('StripOffsets');
|
|
17
|
-
return {
|
|
18
|
-
tileWidth: isTiled
|
|
19
|
-
|
|
17
|
+
return /** @type {BaseDecoderParameters} */ ({
|
|
18
|
+
tileWidth: isTiled
|
|
19
|
+
? await fileDirectory.loadValue('TileWidth')
|
|
20
|
+
: await fileDirectory.loadValue('ImageWidth'),
|
|
21
|
+
tileHeight: isTiled
|
|
22
|
+
? await fileDirectory.loadValue('TileLength')
|
|
23
|
+
: (await fileDirectory.loadValue('RowsPerStrip')
|
|
24
|
+
|| await fileDirectory.loadValue('ImageLength')),
|
|
20
25
|
planarConfiguration: await fileDirectory.loadValue('PlanarConfiguration'),
|
|
21
26
|
bitsPerSample: await fileDirectory.loadValue('BitsPerSample'),
|
|
22
27
|
predictor: await fileDirectory.loadValue('Predictor') || 1,
|
|
23
|
-
};
|
|
28
|
+
});
|
|
24
29
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Either a number or undefined.
|
|
27
|
-
* @typedef {(number|undefined)} NumberOrUndefined
|
|
28
|
-
*/
|
|
29
30
|
/**
|
|
30
31
|
* Register a decoder for a specific compression method or a range of compressions
|
|
31
|
-
* @param {(
|
|
32
|
-
* @param {function():Promise} importFn the function to import the decoder
|
|
33
|
-
* @param {function(import("../imagefiledirectory").ImageFileDirectory):Promise} decoderParameterFn
|
|
32
|
+
* @param {(number|undefined|(number|undefined)[])} cases ids of the compression methods to register for
|
|
33
|
+
* @param {function():Promise<typeof BaseDecoder>} importFn the function to import the decoder
|
|
34
|
+
* @param {function(import("../imagefiledirectory").ImageFileDirectory):Promise<BaseDecoderParameters>} decoderParameterFn
|
|
34
35
|
* @param {boolean} preferWorker_ Whether to prefer running the decoder in a worker
|
|
35
36
|
*/
|
|
36
37
|
export function addDecoder(cases, importFn, decoderParameterFn = defaultDecoderParameterFn, preferWorker_ = true) {
|
|
@@ -43,27 +44,27 @@ export function addDecoder(cases, importFn, decoderParameterFn = defaultDecoderP
|
|
|
43
44
|
}
|
|
44
45
|
/**
|
|
45
46
|
* Get the required decoder parameters for a specific compression method
|
|
46
|
-
* @param {
|
|
47
|
+
* @param {number|undefined} compression
|
|
47
48
|
* @param {import('../imagefiledirectory.js').ImageFileDirectory} fileDirectory
|
|
48
49
|
*/
|
|
49
50
|
export async function getDecoderParameters(compression, fileDirectory) {
|
|
50
51
|
if (!registry.has(compression)) {
|
|
51
52
|
throw new Error(`Unknown compression method identifier: ${compression}`);
|
|
52
53
|
}
|
|
53
|
-
const { decoderParameterFn } = registry.get(compression);
|
|
54
|
+
const { decoderParameterFn } = /** @type {RegistryEntry} */ (registry.get(compression));
|
|
54
55
|
return decoderParameterFn(fileDirectory);
|
|
55
56
|
}
|
|
56
57
|
/**
|
|
57
58
|
* Get a decoder for a specific compression and parameters
|
|
58
59
|
* @param {number} compression the compression method identifier
|
|
59
|
-
* @param {
|
|
60
|
+
* @param {BaseDecoderParameters} decoderParameters the parameters for the decoder
|
|
60
61
|
* @returns {Promise<import('./basedecoder.js').default>}
|
|
61
62
|
*/
|
|
62
63
|
export async function getDecoder(compression, decoderParameters) {
|
|
63
64
|
if (!registry.has(compression)) {
|
|
64
65
|
throw new Error(`Unknown compression method identifier: ${compression}`);
|
|
65
66
|
}
|
|
66
|
-
const { importFn } = registry.get(compression);
|
|
67
|
+
const { importFn } = /** @type {RegistryEntry} */ (registry.get(compression));
|
|
67
68
|
const Decoder = await importFn();
|
|
68
69
|
return new Decoder(decoderParameters);
|
|
69
70
|
}
|
|
@@ -76,7 +77,7 @@ export function preferWorker(compression) {
|
|
|
76
77
|
if (!registry.has(compression)) {
|
|
77
78
|
throw new Error(`Unknown compression method identifier: ${compression}`);
|
|
78
79
|
}
|
|
79
|
-
return registry.get(compression).preferWorker;
|
|
80
|
+
return /** @type {RegistryEntry} */ (registry.get(compression)).preferWorker;
|
|
80
81
|
}
|
|
81
82
|
const defaultDecoderDefinitions = [
|
|
82
83
|
// No compression
|
|
@@ -101,6 +102,9 @@ const defaultDecoderDefinitions = [
|
|
|
101
102
|
{
|
|
102
103
|
cases: 7,
|
|
103
104
|
importFn: () => import('./jpeg.js').then((m) => m.default),
|
|
105
|
+
/**
|
|
106
|
+
* @param {import("../imagefiledirectory").ImageFileDirectory} fileDirectory
|
|
107
|
+
*/
|
|
104
108
|
decoderParameterFn: async (fileDirectory) => {
|
|
105
109
|
return {
|
|
106
110
|
...await defaultDecoderParameterFn(fileDirectory),
|
|
@@ -127,6 +131,9 @@ const defaultDecoderDefinitions = [
|
|
|
127
131
|
return m;
|
|
128
132
|
})
|
|
129
133
|
.then((m) => m.default),
|
|
134
|
+
/**
|
|
135
|
+
* @param {import("../imagefiledirectory").ImageFileDirectory} fileDirectory
|
|
136
|
+
*/
|
|
130
137
|
decoderParameterFn: async (fileDirectory) => {
|
|
131
138
|
return {
|
|
132
139
|
...await defaultDecoderParameterFn(fileDirectory),
|
|
@@ -148,10 +155,13 @@ const defaultDecoderDefinitions = [
|
|
|
148
155
|
{
|
|
149
156
|
cases: 50001,
|
|
150
157
|
importFn: () => import('./webimage.js').then((m) => m.default),
|
|
158
|
+
/**
|
|
159
|
+
* @param {import("../imagefiledirectory").ImageFileDirectory} fileDirectory
|
|
160
|
+
*/
|
|
151
161
|
decoderParameterFn: async (fileDirectory) => {
|
|
152
162
|
return {
|
|
153
163
|
...await defaultDecoderParameterFn(fileDirectory),
|
|
154
|
-
samplesPerPixel: await fileDirectory.loadValue('SamplesPerPixel') || 4,
|
|
164
|
+
samplesPerPixel: Number(await fileDirectory.loadValue('SamplesPerPixel')) || 4,
|
|
155
165
|
};
|
|
156
166
|
},
|
|
157
167
|
preferWorker: false,
|
|
@@ -162,3 +172,4 @@ for (const decoderDefinition of defaultDecoderDefinitions) {
|
|
|
162
172
|
const { cases, importFn, decoderParameterFn, preferWorker: preferWorker_ } = decoderDefinition;
|
|
163
173
|
addDecoder(cases, importFn, decoderParameterFn, preferWorker_);
|
|
164
174
|
}
|
|
175
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/compression/index.js"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E;;;;;GAKG;AAEH,qDAAqD;AACrD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;AAE3B;;;;GAIG;AACH,KAAK,UAAU,yBAAyB,CAAC,aAAa;IACpD,MAAM,OAAO,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACtD,OAAO,oCAAoC,CAAC,CAAC;QAC3C,SAAS,EAAE,OAAO;YAChB,CAAC,CAAC,MAAM,aAAa,CAAC,SAAS,CAAC,WAAW,CAAC;YAC5C,CAAC,CAAC,MAAM,aAAa,CAAC,SAAS,CAAC,YAAY,CAAC;QAC/C,UAAU,EAAE,OAAO;YACjB,CAAC,CAAC,MAAM,aAAa,CAAC,SAAS,CAAC,YAAY,CAAC;YAC7C,CAAC,CAAC,CACA,MAAM,aAAa,CAAC,SAAS,CAAC,cAAc,CAAC;mBAC1C,MAAM,aAAa,CAAC,SAAS,CAAC,aAAa,CAAC,CAChD;QACH,mBAAmB,EAAE,MAAM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ACZ,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC;aAChC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YAChB,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACpB,OAAO,CAAC,CAAC;QACX,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;KAC1B;IACD,cAAc;IACd;QACE,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QAC9D;;WAEG;QACH,kBAAkB,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE;YAC1C,OAAO;gBACL,GAAG,MAAM,yBAAyB,CAAC,aAAa,CAAC;gBACjD,eAAe,EAAE,MAAM,CAAC,MAAM,aAAa,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC;aAC/E,CAAC;QACJ,CAAC;QACD,YAAY,EAAE,KAAK;KACpB;CACF,CAAC;AAEF,sFAAsF;AACtF,KAAK,MAAM,iBAAiB,IAAI,yBAAyB,EAAE,CAAC;IAC1D,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,iBAAiB,CAAC;IAC/F,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,aAAa,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -1,39 +1,79 @@
|
|
|
1
1
|
export default class JpegDecoder extends BaseDecoder {
|
|
2
|
+
/**
|
|
3
|
+
* @param {import('./basedecoder.js').BaseDecoderParameters & { JPEGTables?: Uint8Array }} parameters
|
|
4
|
+
*/
|
|
5
|
+
constructor(parameters: import("./basedecoder.js").BaseDecoderParameters & {
|
|
6
|
+
JPEGTables?: Uint8Array;
|
|
7
|
+
});
|
|
2
8
|
reader: JpegStreamReader;
|
|
3
|
-
|
|
9
|
+
/** @param {ArrayBuffer} buffer */
|
|
10
|
+
decodeBlock(buffer: ArrayBuffer): ArrayBuffer;
|
|
4
11
|
}
|
|
5
12
|
export type HuffmanNode = (number | HuffmanNode)[];
|
|
6
13
|
export type Code = {
|
|
7
14
|
children: HuffmanNode;
|
|
8
15
|
index: number;
|
|
9
16
|
};
|
|
17
|
+
export type JpegComponent = {
|
|
18
|
+
h: number;
|
|
19
|
+
v: number;
|
|
20
|
+
quantizationIdx?: number | undefined;
|
|
21
|
+
quantizationTable?: Int32Array<ArrayBufferLike> | undefined;
|
|
22
|
+
blocksPerLine: number;
|
|
23
|
+
blocksPerColumn: number;
|
|
24
|
+
blocks: Int32Array[][];
|
|
25
|
+
huffmanTableDC?: HuffmanNode | undefined;
|
|
26
|
+
huffmanTableAC?: HuffmanNode | undefined;
|
|
27
|
+
pred?: number | undefined;
|
|
28
|
+
};
|
|
29
|
+
export type JpegFrame = {
|
|
30
|
+
extended: boolean;
|
|
31
|
+
progressive: boolean;
|
|
32
|
+
precision: number;
|
|
33
|
+
scanLines: number;
|
|
34
|
+
samplesPerLine: number;
|
|
35
|
+
components: {
|
|
36
|
+
[x: string]: JpegComponent;
|
|
37
|
+
};
|
|
38
|
+
componentsOrder: number[];
|
|
39
|
+
maxH: number;
|
|
40
|
+
maxV: number;
|
|
41
|
+
mcusPerLine: number;
|
|
42
|
+
mcusPerColumn: number;
|
|
43
|
+
};
|
|
10
44
|
import BaseDecoder from './basedecoder.js';
|
|
11
45
|
declare class JpegStreamReader {
|
|
12
46
|
jfif: {
|
|
13
47
|
version: {
|
|
14
|
-
major:
|
|
15
|
-
minor:
|
|
48
|
+
major: number;
|
|
49
|
+
minor: number;
|
|
16
50
|
};
|
|
17
|
-
densityUnits:
|
|
51
|
+
densityUnits: number;
|
|
18
52
|
xDensity: number;
|
|
19
53
|
yDensity: number;
|
|
20
|
-
thumbWidth:
|
|
21
|
-
thumbHeight:
|
|
22
|
-
thumbData:
|
|
54
|
+
thumbWidth: number;
|
|
55
|
+
thumbHeight: number;
|
|
56
|
+
thumbData: Uint8Array<ArrayBufferLike>;
|
|
23
57
|
} | null;
|
|
24
58
|
adobe: {
|
|
25
|
-
version:
|
|
59
|
+
version: number;
|
|
26
60
|
flags0: number;
|
|
27
61
|
flags1: number;
|
|
28
|
-
transformCode:
|
|
62
|
+
transformCode: number;
|
|
29
63
|
} | null;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
64
|
+
/** @type {number} */
|
|
65
|
+
resetInterval: number;
|
|
66
|
+
/** @type {Int32Array[]} */
|
|
67
|
+
quantizationTables: Int32Array[];
|
|
68
|
+
/** @type {HuffmanNode[]} */
|
|
69
|
+
huffmanTablesAC: HuffmanNode[];
|
|
70
|
+
/** @type {HuffmanNode[]} */
|
|
71
|
+
huffmanTablesDC: HuffmanNode[];
|
|
72
|
+
/** @type {JpegFrame[]} */
|
|
73
|
+
frames: JpegFrame[];
|
|
34
74
|
resetFrames(): void;
|
|
35
|
-
|
|
36
|
-
|
|
75
|
+
/** @param {Uint8Array} data */
|
|
76
|
+
parse(data: Uint8Array): void;
|
|
37
77
|
getResult(): Uint8Array<ArrayBuffer>;
|
|
38
78
|
}
|
|
39
79
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jpeg.d.ts","sourceRoot":"","sources":["../../src/compression/jpeg.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jpeg.d.ts","sourceRoot":"","sources":["../../src/compression/jpeg.js"],"names":[],"mappings":"AAykCA;IACE;;OAEG;IACH,wBAFW,OAAO,kBAAkB,EAAE,qBAAqB,GAAG;QAAE,UAAU,CAAC,EAAE,UAAU,CAAA;KAAE,EAQxF;IAJC,yBAAoC;IAMtC,kCAAkC;IAClC,oBADY,WAAW,eAKtB;CACF;0BAviCa,CAAC,MAAM,GAAC,WAAW,CAAC,EAAE;mBACtB;IAAC,QAAQ,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC;;OAItC,MAAM;OACN,MAAM;;;mBAGN,MAAM;qBACN,MAAM;YACN,UAAU,EAAE,EAAE;;;;;;cAQd,OAAO;iBACP,OAAO;eACP,MAAM;eACN,MAAM;oBACN,MAAM;;;;qBAEN,MAAM,EAAE;UACR,MAAM;UACN,MAAM;iBACN,MAAM;mBACN,MAAM;;wBAjFI,kBAAkB;AAsvB1C;IAEI;;;;;;;;;;;aAAgB;IAChB;;;;;aAAiB;IAEjB,qBAAqB;IACrB,eADW,MAAM,CACK;IAEtB,2BAA2B;IAC3B,oBADW,UAAU,EAAE,CACK;IAC5B,4BAA4B;IAC5B,iBADW,WAAW,EAAE,CACC;IACzB,4BAA4B;IAC5B,iBADW,WAAW,EAAE,CACC;IACzB,0BAA0B;IAC1B,QADW,SAAS,EAAE,CACN;IAGlB,oBAEC;IAED,+BAA+B;IAC/B,YADY,UAAU,QAsQrB;IAED,qCAkDC;CACF"}
|