@ddunigma/node 6.0.0 → 6.1.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/CHANGELOG.md +23 -0
- package/README.md +12 -20
- package/dist/Ddu64Secure-CRWKMJLL.js +1 -0
- package/dist/Ddu64Secure-VAMXBO3O.cjs +1 -0
- package/dist/Ddu64SecureBrowser-EZBTEXVI.cjs +1 -0
- package/dist/Ddu64SecureBrowser-FR3TZJQ7.js +1 -0
- package/dist/{ObfuscationLayer-4rCOCRWH.d.cts → ObfuscationLayer-CK0ptcW-.d.cts} +1 -1
- package/dist/{ObfuscationLayer-DTlA723P.d.ts → ObfuscationLayer-CotTuQ5X.d.ts} +1 -1
- package/dist/{WebStreams-CY9E19f5.d.cts → WebStreams-BSCrvsT3.d.cts} +1 -1
- package/dist/{WebStreams-C16QV2Dz.d.ts → WebStreams-CJyGMELL.d.ts} +1 -1
- package/dist/browser.cjs +1 -1
- package/dist/browser.d.cts +12 -21
- package/dist/browser.d.ts +12 -21
- package/dist/browser.js +1 -1
- package/dist/chunk-3TG2ZEF2.cjs +1 -0
- package/dist/chunk-4247T4B7.cjs +1 -0
- package/dist/chunk-5VZELPTG.js +1 -0
- package/dist/chunk-6AYKT6DL.cjs +1 -0
- package/dist/chunk-A3OZJS5G.cjs +9 -0
- package/dist/chunk-DMUAPREO.cjs +1 -0
- package/dist/chunk-DVOLAE33.js +1 -0
- package/dist/chunk-EY5OURIG.cjs +1 -0
- package/dist/chunk-FQI54AXA.cjs +1 -0
- package/dist/chunk-IZSFO3ET.js +1 -0
- package/dist/chunk-LZFOWWT2.js +1 -0
- package/dist/chunk-Q7QV2G7V.js +1 -0
- package/dist/chunk-TCRCZHZC.js +9 -0
- package/dist/chunk-UNBJQMMP.js +1 -0
- package/dist/{core-BsIwjJK-.d.cts → core-ihIEWmI5.d.cts} +9 -11
- package/dist/{core-BsIwjJK-.d.ts → core-ihIEWmI5.d.ts} +9 -11
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +24 -23
- package/dist/index.d.ts +24 -23
- package/dist/index.js +1 -1
- package/dist/secure.browser.cjs +1 -1
- package/dist/secure.browser.d.cts +4 -4
- package/dist/secure.browser.d.ts +4 -4
- package/dist/secure.browser.js +1 -1
- package/dist/secure.cjs +1 -1
- package/dist/secure.d.cts +4 -4
- package/dist/secure.d.ts +4 -4
- package/dist/secure.js +1 -1
- package/docs/REFERENCE.md +53 -55
- package/package.json +1 -1
- package/dist/chunk-6N7QYPEJ.js +0 -1
- package/dist/chunk-7KUEHTG2.js +0 -1
- package/dist/chunk-BDP7E7K3.cjs +0 -1
- package/dist/chunk-JBUTKSCC.cjs +0 -9
- package/dist/chunk-LCOYWJWO.cjs +0 -1
- package/dist/chunk-VW2SZR2Z.js +0 -9
package/dist/secure.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkDMUAPREO_cjs=require('./chunk-DMUAPREO.cjs'),chunkFQI54AXA_cjs=require('./chunk-FQI54AXA.cjs'),chunkEY5OURIG_cjs=require('./chunk-EY5OURIG.cjs'),chunk3TG2ZEF2_cjs=require('./chunk-3TG2ZEF2.cjs'),chunk6AYKT6DL_cjs=require('./chunk-6AYKT6DL.cjs'),chunk4247T4B7_cjs=require('./chunk-4247T4B7.cjs'),chunkA3OZJS5G_cjs=require('./chunk-A3OZJS5G.cjs'),chunkHUUB5BUS_cjs=require('./chunk-HUUB5BUS.cjs'),chunkZTGECGM2_cjs=require('./chunk-ZTGECGM2.cjs'),chunk76X5J2OF_cjs=require('./chunk-76X5J2OF.cjs');require('./chunk-JY2ZPBJK.cjs');var chunkBCUBYE76_cjs=require('./chunk-BCUBYE76.cjs');async function j(){let t=chunkEY5OURIG_cjs.a();switch(t){case "node":{let{NodeAdapter:e}=await import('./NodeAdapter-4R7CNTHP.cjs');return new e}case "deno":case "bun":case "browser":case "edge":{let{BrowserAdapter:e}=await import('./BrowserAdapter-NWASGV3D.cjs');return new e(t)}default:throw new chunkZTGECGM2_cjs.m("[ddunigma] No suitable crypto provider found. Detected runtime lacks both Node.js crypto module and Web Crypto API (SubtleCrypto).","adapter")}}chunkBCUBYE76_cjs.a(j,"getAdapter");Object.defineProperty(exports,"Ddu64",{enumerable:true,get:function(){return chunkDMUAPREO_cjs.a}});Object.defineProperty(exports,"Ddu64Secure",{enumerable:true,get:function(){return chunkDMUAPREO_cjs.a}});Object.defineProperty(exports,"createReadableDecodeStream",{enumerable:true,get:function(){return chunkFQI54AXA_cjs.b}});Object.defineProperty(exports,"createReadableEncodeStream",{enumerable:true,get:function(){return chunkFQI54AXA_cjs.a}});Object.defineProperty(exports,"detectRuntime",{enumerable:true,get:function(){return chunkEY5OURIG_cjs.a}});Object.defineProperty(exports,"CharsetBuilder",{enumerable:true,get:function(){return chunk3TG2ZEF2_cjs.a}});Object.defineProperty(exports,"Ddu64SecureBrowser",{enumerable:true,get:function(){return chunk6AYKT6DL_cjs.a}});Object.defineProperty(exports,"HangulObfuscationLayer",{enumerable:true,get:function(){return chunk4247T4B7_cjs.a}});Object.defineProperty(exports,"createEncoderObfuscationLayer",{enumerable:true,get:function(){return chunk4247T4B7_cjs.b}});Object.defineProperty(exports,"Ddu64Core",{enumerable:true,get:function(){return chunkA3OZJS5G_cjs.i}});Object.defineProperty(exports,"DduSetSymbol",{enumerable:true,get:function(){return chunkA3OZJS5G_cjs.a}});Object.defineProperty(exports,"BrowserAdapter",{enumerable:true,get:function(){return chunkHUUB5BUS_cjs.a}});Object.defineProperty(exports,"Ddu64AdapterError",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.m}});Object.defineProperty(exports,"Ddu64CharsetError",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.j}});Object.defineProperty(exports,"Ddu64ChecksumError",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.i}});Object.defineProperty(exports,"Ddu64CompressionError",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.e}});Object.defineProperty(exports,"Ddu64DecodeError",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.d}});Object.defineProperty(exports,"Ddu64DecompressionError",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.f}});Object.defineProperty(exports,"Ddu64DecryptionError",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.h}});Object.defineProperty(exports,"Ddu64EncodeError",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.c}});Object.defineProperty(exports,"Ddu64EncryptionError",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.g}});Object.defineProperty(exports,"Ddu64Error",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.b}});Object.defineProperty(exports,"Ddu64ErrorCode",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.a}});Object.defineProperty(exports,"Ddu64InvalidInputError",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.k}});Object.defineProperty(exports,"Ddu64LimitError",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.l}});Object.defineProperty(exports,"Ddu64ObfuscationError",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.n}});Object.defineProperty(exports,"Ddu64StreamError",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.o}});Object.defineProperty(exports,"isDdu64Error",{enumerable:true,get:function(){return chunkZTGECGM2_cjs.p}});Object.defineProperty(exports,"NodeAdapter",{enumerable:true,get:function(){return chunk76X5J2OF_cjs.a}});exports.getAdapter=j;
|
package/dist/secure.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { D as Ddu64Core,
|
|
2
|
-
export { C as CharSetConfig, d as CharSetInfo, e as CharsetBuilder, f as Ddu64AdapterError, g as Ddu64CharsetError, h as Ddu64ChecksumError, i as Ddu64CompressionError, j as Ddu64DecodeError, k as Ddu64DecompressionError, l as Ddu64DecryptionError, m as Ddu64EncodeError, n as Ddu64EncryptionError, o as Ddu64Error, p as Ddu64ErrorCode, q as Ddu64ErrorOptions, r as Ddu64InvalidInputError, s as Ddu64LimitError, t as Ddu64ObfuscationError, u as Ddu64Operation, v as Ddu64StreamError,
|
|
3
|
-
export { B as BrowserAdapter, D as Ddu64SecureBrowser, c as createReadableDecodeStream, a as createReadableEncodeStream } from './WebStreams-
|
|
4
|
-
export { H as HangulObfuscationLayer, c as createEncoderObfuscationLayer, d as detectRuntime } from './ObfuscationLayer-
|
|
1
|
+
import { D as Ddu64Core, a as DduSecureConstructorOptions, G as DduSecureOptions, P as PlatformAdapter, I as KeyDerivationOptions } from './core-ihIEWmI5.cjs';
|
|
2
|
+
export { C as CharSetConfig, d as CharSetInfo, e as CharsetBuilder, f as Ddu64AdapterError, g as Ddu64CharsetError, h as Ddu64ChecksumError, i as Ddu64CompressionError, j as Ddu64DecodeError, k as Ddu64DecompressionError, l as Ddu64DecryptionError, m as Ddu64EncodeError, n as Ddu64EncryptionError, o as Ddu64Error, p as Ddu64ErrorCode, q as Ddu64ErrorOptions, r as Ddu64InvalidInputError, s as Ddu64LimitError, t as Ddu64ObfuscationError, u as Ddu64Operation, v as Ddu64StreamError, w as DduBaseConstructorOptions, x as DduBaseOptions, F as DduConstructorOptions, c as DduEncodeStats, b as DduOptions, y as DduProgressInfo, z as DduSetSymbol, A as DduSetSymbolInput, H as DduStreamOptions, E as EncodingProfile, K as KeyDerivationAlgorithm, O as ObfuscationLayer, B as isDdu64Error } from './core-ihIEWmI5.cjs';
|
|
3
|
+
export { B as BrowserAdapter, D as Ddu64SecureBrowser, c as createReadableDecodeStream, a as createReadableEncodeStream } from './WebStreams-BSCrvsT3.cjs';
|
|
4
|
+
export { H as HangulObfuscationLayer, c as createEncoderObfuscationLayer, d as detectRuntime } from './ObfuscationLayer-CK0ptcW-.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Node.js 전용 secure Ddu64 래퍼.
|
package/dist/secure.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { D as Ddu64Core,
|
|
2
|
-
export { C as CharSetConfig, d as CharSetInfo, e as CharsetBuilder, f as Ddu64AdapterError, g as Ddu64CharsetError, h as Ddu64ChecksumError, i as Ddu64CompressionError, j as Ddu64DecodeError, k as Ddu64DecompressionError, l as Ddu64DecryptionError, m as Ddu64EncodeError, n as Ddu64EncryptionError, o as Ddu64Error, p as Ddu64ErrorCode, q as Ddu64ErrorOptions, r as Ddu64InvalidInputError, s as Ddu64LimitError, t as Ddu64ObfuscationError, u as Ddu64Operation, v as Ddu64StreamError,
|
|
3
|
-
export { B as BrowserAdapter, D as Ddu64SecureBrowser, c as createReadableDecodeStream, a as createReadableEncodeStream } from './WebStreams-
|
|
4
|
-
export { H as HangulObfuscationLayer, c as createEncoderObfuscationLayer, d as detectRuntime } from './ObfuscationLayer-
|
|
1
|
+
import { D as Ddu64Core, a as DduSecureConstructorOptions, G as DduSecureOptions, P as PlatformAdapter, I as KeyDerivationOptions } from './core-ihIEWmI5.js';
|
|
2
|
+
export { C as CharSetConfig, d as CharSetInfo, e as CharsetBuilder, f as Ddu64AdapterError, g as Ddu64CharsetError, h as Ddu64ChecksumError, i as Ddu64CompressionError, j as Ddu64DecodeError, k as Ddu64DecompressionError, l as Ddu64DecryptionError, m as Ddu64EncodeError, n as Ddu64EncryptionError, o as Ddu64Error, p as Ddu64ErrorCode, q as Ddu64ErrorOptions, r as Ddu64InvalidInputError, s as Ddu64LimitError, t as Ddu64ObfuscationError, u as Ddu64Operation, v as Ddu64StreamError, w as DduBaseConstructorOptions, x as DduBaseOptions, F as DduConstructorOptions, c as DduEncodeStats, b as DduOptions, y as DduProgressInfo, z as DduSetSymbol, A as DduSetSymbolInput, H as DduStreamOptions, E as EncodingProfile, K as KeyDerivationAlgorithm, O as ObfuscationLayer, B as isDdu64Error } from './core-ihIEWmI5.js';
|
|
3
|
+
export { B as BrowserAdapter, D as Ddu64SecureBrowser, c as createReadableDecodeStream, a as createReadableEncodeStream } from './WebStreams-CJyGMELL.js';
|
|
4
|
+
export { H as HangulObfuscationLayer, c as createEncoderObfuscationLayer, d as detectRuntime } from './ObfuscationLayer-CotTuQ5X.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Node.js 전용 secure Ddu64 래퍼.
|
package/dist/secure.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as
|
|
1
|
+
export{a as Ddu64,a as Ddu64Secure}from'./chunk-UNBJQMMP.js';export{b as createReadableDecodeStream,a as createReadableEncodeStream}from'./chunk-Q7QV2G7V.js';import {a as a$1}from'./chunk-DVOLAE33.js';export{a as detectRuntime}from'./chunk-DVOLAE33.js';export{a as CharsetBuilder}from'./chunk-IZSFO3ET.js';export{a as Ddu64SecureBrowser}from'./chunk-LZFOWWT2.js';export{a as HangulObfuscationLayer,b as createEncoderObfuscationLayer}from'./chunk-5VZELPTG.js';export{i as Ddu64Core,a as DduSetSymbol}from'./chunk-TCRCZHZC.js';export{a as BrowserAdapter}from'./chunk-6ZYMNHFT.js';import {m}from'./chunk-IZK7KCU7.js';export{m as Ddu64AdapterError,j as Ddu64CharsetError,i as Ddu64ChecksumError,e as Ddu64CompressionError,d as Ddu64DecodeError,f as Ddu64DecompressionError,h as Ddu64DecryptionError,c as Ddu64EncodeError,g as Ddu64EncryptionError,b as Ddu64Error,a as Ddu64ErrorCode,k as Ddu64InvalidInputError,l as Ddu64LimitError,n as Ddu64ObfuscationError,o as Ddu64StreamError,p as isDdu64Error}from'./chunk-IZK7KCU7.js';export{a as NodeAdapter}from'./chunk-7EPVCA2F.js';import'./chunk-Q6SCBUV2.js';import {a}from'./chunk-EI7MMDWY.js';async function j(){let t=a$1();switch(t){case "node":{let{NodeAdapter:e}=await import('./NodeAdapter-YP22CLUP.js');return new e}case "deno":case "bun":case "browser":case "edge":{let{BrowserAdapter:e}=await import('./BrowserAdapter-A6RBN4N3.js');return new e(t)}default:throw new m("[ddunigma] No suitable crypto provider found. Detected runtime lacks both Node.js crypto module and Web Crypto API (SubtleCrypto).","adapter")}}a(j,"getAdapter");export{j as getAdapter};
|
package/docs/REFERENCE.md
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# ddunigma Node Reference
|
|
2
2
|
|
|
3
|
-
`@ddunigma/node` 6.0 상세 사용법입니다. README는 빠른 시작과 정체성 중심이고, 전체 옵션과 고급
|
|
4
|
-
진입점 사용법은 이 문서가 기준입니다.
|
|
5
|
-
|
|
6
3
|
## 문자열과 바이너리
|
|
7
4
|
|
|
8
5
|
```typescript
|
|
@@ -53,52 +50,53 @@ charset 문자와 `paddingChar`는 각각 단일 UTF-16 코드 유닛이어야
|
|
|
53
50
|
|
|
54
51
|
### 공통 옵션
|
|
55
52
|
|
|
56
|
-
| 옵션
|
|
57
|
-
|
|
|
58
|
-
| `compress`
|
|
59
|
-
| `compressionAlgorithm` | `"deflate" \| "brotli"`
|
|
60
|
-
| `compressionLevel`
|
|
61
|
-
| `checksum`
|
|
62
|
-
| `checksumScope`
|
|
63
|
-
| `chunkSize`
|
|
64
|
-
| `chunkSeparator`
|
|
65
|
-
| `maxDecodedBytes`
|
|
66
|
-
| `maxEncodedChars`
|
|
67
|
-
| `maxDecompressedBytes` | `number`
|
|
68
|
-
| `obfuscate`
|
|
69
|
-
| `requireEncryption`
|
|
70
|
-
| `onProgress`
|
|
71
|
-
|
|
72
|
-
`compress
|
|
73
|
-
`
|
|
74
|
-
|
|
53
|
+
| 옵션 | 타입 | 기본값 | 용도 |
|
|
54
|
+
| ---------------------- | --------------------------------- | ----------------- | --------------------------------------- |
|
|
55
|
+
| `compress` | `boolean` | `false` | 압축 사용 |
|
|
56
|
+
| `compressionAlgorithm` | `"deflate" \| "brotli"` | `"deflate"` | 압축 알고리즘 |
|
|
57
|
+
| `compressionLevel` | `number` | `6` | 압축 레벨 |
|
|
58
|
+
| `checksum` | `boolean` | `false` | CRC32 체크섬 추가 및 검증 |
|
|
59
|
+
| `checksumScope` | `"plaintext" \| "output"` | `"output"` | CRC32 계산 범위 |
|
|
60
|
+
| `chunkSize` | `number` | 미사용 | 출력 문자열 분할 크기 |
|
|
61
|
+
| `chunkSeparator` | `string` | `"\n"` | 청크 구분자 |
|
|
62
|
+
| `maxDecodedBytes` | `number` | `67108864` | 최대 디코딩 바이트 수 |
|
|
63
|
+
| `maxEncodedChars` | `number` | 비례 자동 산정 | 최대 디코딩 입력 문자열 길이 |
|
|
64
|
+
| `maxDecompressedBytes` | `number` | `67108864` | 최대 압축 해제 바이트 수 |
|
|
65
|
+
| `obfuscate` | `boolean` | `false` | 출력을 한글 음절로 난독화 |
|
|
66
|
+
| `requireEncryption` | `boolean` | 키 사용 시 `true` | 키가 있는 decoder에서 평문 payload 거부 |
|
|
67
|
+
| `onProgress` | `(info: DduProgressInfo) => void` | 미사용 | 처리 진행률 콜백 |
|
|
68
|
+
|
|
69
|
+
`@ddunigma/node`와 `@ddunigma/node/browser`는 adapter-backed 옵션(`compress`,
|
|
70
|
+
`encryptionKey`)이 켜진 비동기 encode/decode 호출에서만 secure 래퍼를 동적 import합니다. 동기
|
|
71
|
+
압축/암호화는 `@ddunigma/node/secure`를 사용하세요. `checksum`/`checksumScope`/청킹/
|
|
72
|
+
난독화는 플랫폼 어댑터 없이도 동작합니다.
|
|
75
73
|
|
|
76
74
|
Web Streams API는 축적 모드 메모리 제한용 `maxBufferedBytes`(인코딩, 기본 64 MiB)와
|
|
77
75
|
`maxBufferedChars`(디코딩, 기본 64 Mi 문자)를 추가로 지원합니다.
|
|
78
76
|
|
|
79
77
|
### 생성자 전용 옵션
|
|
80
78
|
|
|
81
|
-
| 옵션
|
|
82
|
-
|
|
|
83
|
-
| `dduSetSymbol`
|
|
84
|
-
| `dduChar`
|
|
85
|
-
| `codaChar`
|
|
86
|
-
| `paddingChar`
|
|
87
|
-
| `requiredLength`
|
|
88
|
-
| `usePowerOfTwo`
|
|
89
|
-
| `useRepeatPadding` | `boolean`
|
|
90
|
-
| `throwOnError`
|
|
91
|
-
| `urlSafe`
|
|
92
|
-
| `encryptionKey`
|
|
93
|
-
| `keyDerivation`
|
|
94
|
-
| `adapter`
|
|
79
|
+
| 옵션 | 타입 | 기본값 | 용도 |
|
|
80
|
+
| ------------------ | ---------------------------- | ----------- | ----------------------------------- |
|
|
81
|
+
| `dduSetSymbol` | `DduSetSymbol \| "ddu" \| …` | `DDU` | 기본 charset 프리셋 선택 |
|
|
82
|
+
| `dduChar` | `string \| string[]` | 프리셋 사용 | 커스텀 charset |
|
|
83
|
+
| `codaChar` | `string[]` | 미사용 | 기본 문자와 조합할 한글 종성 |
|
|
84
|
+
| `paddingChar` | `string` | 프리셋 사용 | 커스텀 패딩 문자 |
|
|
85
|
+
| `requiredLength` | `number` | `64` | 필요한 charset 문자 수 |
|
|
86
|
+
| `usePowerOfTwo` | `boolean` | 자동 결정 | 2의 제곱수 charset 직접 인덱스 모드 |
|
|
87
|
+
| `useRepeatPadding` | `boolean` | 프리셋 설정 | 반복 패딩 방식 사용 |
|
|
88
|
+
| `throwOnError` | `boolean` | `true` | 잘못된 charset 설정에서 예외 발생 |
|
|
89
|
+
| `urlSafe` | `boolean` | `false` | URL-Safe 출력 변환 |
|
|
90
|
+
| `encryptionKey` | `string` | 미사용 | AES-256-GCM 암호화 키 |
|
|
91
|
+
| `keyDerivation` | `KeyDerivationOptions` | `pbkdf2` | 암호화 키 파생 방식 |
|
|
92
|
+
| `adapter` | `PlatformAdapter` | 진입점 설정 | 플랫폼 어댑터 직접 주입 |
|
|
95
93
|
|
|
96
94
|
## 압축, 암호화, 체크섬
|
|
97
95
|
|
|
98
|
-
|
|
96
|
+
기본 진입점은 비동기 메서드에서 압축/암호화 어댑터를 필요할 때만 불러옵니다.
|
|
99
97
|
|
|
100
98
|
```typescript
|
|
101
|
-
import { Ddu64 } from "@ddunigma/node
|
|
99
|
+
import { Ddu64 } from "@ddunigma/node";
|
|
102
100
|
|
|
103
101
|
const ddu = new Ddu64({
|
|
104
102
|
compress: true,
|
|
@@ -113,10 +111,14 @@ const ddu = new Ddu64({
|
|
|
113
111
|
checksum: true,
|
|
114
112
|
});
|
|
115
113
|
|
|
116
|
-
const encoded = ddu.
|
|
117
|
-
const decoded = ddu.
|
|
114
|
+
const encoded = await ddu.encodeAsync("보호할 데이터");
|
|
115
|
+
const decoded = await ddu.decodeAsync(encoded);
|
|
118
116
|
```
|
|
119
117
|
|
|
118
|
+
동기 압축/암호화나 Web Streams가 필요하면 `@ddunigma/node/secure`를 사용합니다.
|
|
119
|
+
호출 옵션으로 `compress: true`를 켰다면 decode 쪽에도 `compress: true`를 전달해야 기본
|
|
120
|
+
진입점의 lazy adapter가 켜집니다. 생성자 기본값으로 두면 반복 전달하지 않아도 됩니다.
|
|
121
|
+
|
|
120
122
|
복호화에는 인코딩에 사용한 `encryptionKey`와 키 파생 설정(`algorithm`/`salt`/`iterations`)이
|
|
121
123
|
동일하게 필요합니다. 키 파생 파라미터는 wire format에 기록되지 않습니다.
|
|
122
124
|
|
|
@@ -124,10 +126,6 @@ const decoded = ddu.decode(encoded);
|
|
|
124
126
|
레거시 평문을 같은 인스턴스로 읽어야 하면 해당 decode 호출에 `requireEncryption: false`를
|
|
125
127
|
명시합니다.
|
|
126
128
|
|
|
127
|
-
> 보안 주의: AES-256-GCM 암호화는 부가 기능이며 단독 보안 솔루션이 아닙니다. 기본 PBKDF2는
|
|
128
|
-
> 210k 반복 + 고정 기본 salt라 저엔트로피 키에는 부족합니다. 애플리케이션 고유 `salt`와 높은
|
|
129
|
-
> `iterations`를 명시하세요.
|
|
130
|
-
|
|
131
129
|
## URL-Safe와 청크 분할
|
|
132
130
|
|
|
133
131
|
```typescript
|
|
@@ -160,12 +158,12 @@ const decoded = ddu.decode(encoded);
|
|
|
160
158
|
## 브라우저와 Workers
|
|
161
159
|
|
|
162
160
|
기본 브라우저 진입점(`@ddunigma/node/browser`)은 인코딩 + 난독화(lean)를 제공합니다.
|
|
163
|
-
브라우저에서
|
|
164
|
-
|
|
165
|
-
|
|
161
|
+
브라우저에서 압축/암호화가 필요하면 기본 브라우저 진입점의 비동기 메서드를 쓰면 됩니다.
|
|
162
|
+
해당 옵션이 켜진 호출에서만 secure 브라우저 래퍼(WebCrypto·CompressionStream 기반)를
|
|
163
|
+
동적 import합니다.
|
|
166
164
|
|
|
167
165
|
```typescript
|
|
168
|
-
import { Ddu64 } from "@ddunigma/node/
|
|
166
|
+
import { Ddu64 } from "@ddunigma/node/browser";
|
|
169
167
|
|
|
170
168
|
const ddu = new Ddu64({ compress: true, checksum: true });
|
|
171
169
|
const encoded = await ddu.encodeAsync("browser data");
|
|
@@ -196,16 +194,16 @@ const stats = ddu.getStats("payload");
|
|
|
196
194
|
const asyncStats = await ddu.getStatsAsync("payload", { compress: true });
|
|
197
195
|
```
|
|
198
196
|
|
|
199
|
-
브라우저에서 압축
|
|
197
|
+
브라우저에서 압축 통계나 Web Streams가 필요하면 `@ddunigma/node/secure`를 사용합니다.
|
|
200
198
|
|
|
201
199
|
## 진입점
|
|
202
200
|
|
|
203
|
-
| 진입점
|
|
204
|
-
|
|
|
205
|
-
| `@ddunigma/node`
|
|
206
|
-
| `@ddunigma/node/browser` | `Ddu64Browser`
|
|
207
|
-
| `@ddunigma/node/secure`
|
|
208
|
-
| `@ddunigma/node/core`
|
|
201
|
+
| 진입점 | 노출 `Ddu64` | 기능 | 용도 |
|
|
202
|
+
| ------------------------ | ---------------- | ----------------------------------------- | ---------------------------- |
|
|
203
|
+
| `@ddunigma/node` | `Ddu64Node` | 인코딩 + 난독화, async encode/decode secure lazy | Node 기본 |
|
|
204
|
+
| `@ddunigma/node/browser` | `Ddu64Browser` | 인코딩 + 난독화, async encode/decode secure lazy | 브라우저/Workers 기본 |
|
|
205
|
+
| `@ddunigma/node/secure` | `Ddu64Secure` | sync/async 압축/암호화/체크섬/Web Streams | 보안·압축 배터리 명시 사용 |
|
|
206
|
+
| `@ddunigma/node/core` | `Ddu64Core` | 순수 인코딩/디코딩 | 어댑터/난독 미포함 최소 번들 |
|
|
209
207
|
|
|
210
208
|
```typescript
|
|
211
209
|
import { Ddu64 as NodeDdu64 } from "@ddunigma/node";
|
package/package.json
CHANGED
package/dist/chunk-6N7QYPEJ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {g as g$1}from'./chunk-VW2SZR2Z.js';import {n}from'./chunk-IZK7KCU7.js';import {a}from'./chunk-EI7MMDWY.js';var l=44032,b=55203,u=b-l+1;function d(e){if(e.length===0)throw new n("[Ddu64 obfuscation] Alphabet must not be empty.");if(e.length>u)throw new n(`[Ddu64 obfuscation] Alphabet size (${e.length}) exceeds available Hangul syllables (${u}).`);let r=Math.floor(u/e.length),t=new Map;for(let n=0;n<e.length;n++)t.set(e[n],n);return {alphabet:e,syllablesPerChar:r,charToIndex:t}}a(d,"buildSyllableMap");function g(e,r,t){let n=l+e*t.syllablesPerChar,s=r%t.syllablesPerChar;return n+s}a(g,"charToSyllable");function h(e,r){if(e<l||e>b)return -1;let t=e-l,n=Math.floor(t/r.syllablesPerChar);return n>=r.alphabet.length?-1:n}a(h,"syllableToCharIndex");var c=class{static{a(this,"HangulObfuscationLayer");}config;constructor(r){this.config=d(r);}obfuscate(r){if(r.length===0)return "";let t=new Array(r.length);for(let n$1=0;n$1<r.length;n$1++){let s=r[n$1],a=this.config.charToIndex.get(s);if(a===void 0)throw new n(`[Ddu64 obfuscation] Character "${s}" (U+${s.charCodeAt(0).toString(16).padStart(4,"0").toUpperCase()}) not found in obfuscation alphabet.`);let p=g(a,n$1,this.config);t[n$1]=String.fromCharCode(p);}return t.join("")}deobfuscate(r){if(r.length===0)return "";let t=new Array(r.length);for(let n$1=0;n$1<r.length;n$1++){let s=r.charCodeAt(n$1),a=h(s,this.config);if(a===-1)throw new n(`[Ddu64 obfuscation] Invalid syllable at position ${n$1}: U+${s.toString(16).padStart(4,"0").toUpperCase()} is not in the mapped range.`);t[n$1]=this.config.alphabet[a];}return t.join("")}};function L(e,r){return new c(g$1(e,r))}a(L,"createEncoderObfuscationLayer");function T(){let e=globalThis;return e.Deno?.version?.deno?"deno":e.Bun?.version?"bun":e.process?.versions?.node?"node":typeof e.EdgeRuntime=="string"||typeof e.WebSocketPair<"u"&&e.crypto?.subtle?"edge":typeof e.crypto<"u"&&e.crypto?.subtle?"browser":"unknown"}a(T,"detectRuntime");export{c as a,L as b,T as c};
|
package/dist/chunk-7KUEHTG2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-6N7QYPEJ.js';import {i,b,h,c,e,d,f}from'./chunk-VW2SZR2Z.js';import {a as a$2}from'./chunk-6ZYMNHFT.js';import {r,l}from'./chunk-IZK7KCU7.js';import {a}from'./chunk-EI7MMDWY.js';var T=class extends i{static{a(this,"Ddu64SecureBrowser");}constructor(e,t,i){let n=b(e,t,i),y={...n.dduOptions,...n.dduChar!==void 0?{dduChar:n.dduChar}:{},...n.paddingChar!==void 0?{paddingChar:n.paddingChar}:{},adapter:n.dduOptions?.adapter,adapterFactory:n.dduOptions?.adapterFactory??(()=>new a$2),obfuscationLayerFactory:n.dduOptions?.obfuscationLayerFactory??(g=>new a$1(g))};super(y);}};var H=64*1024*1024,W=64*1024*1024;function N(r$1,e$1){h(e$1,"stream");let t=r$1.getCharSetInfo(),i=e$1?.compress??t.defaultCompress,n=t.hasEncryptionKey,y=e$1?.checksum??t.defaultChecksum,g=i?e$1?.compressionAlgorithm??t.defaultCompressionAlgorithm:void 0,s=t.paddingChar,S=c(e$1?.maxBufferedBytes,H,true,"maxBufferedBytes"),l$1=M(t,{compressed:i,encrypted:n,checksum:y}),f=false,u=[],m=0,o=null;return new TransformStream({async transform(a,d){if(l$1){if(!f){let D=e(s,{compressionAlgorithm:void 0,encrypted:false});d.enqueue(D),f=true;}let c;o&&o.length>0?(c=new Uint8Array(o.length+a.length),c.set(o,0),c.set(a,o.length)):c=a;let A=t.bitLength,C=R(A,8)/8,p=Math.floor(c.length/C)*C;if(p>0){let D=c.subarray(0,p),q=await r$1.encodeAsync(D,{compress:false,encrypt:false,checksum:false,chunkSize:0,chunkSeparator:void 0,omitFooter:true});d.enqueue(q);}p<c.length?o=c.slice(p):o=null;}else {if(m+a.length>S){d.error(new l(`[WebStreams encode] Buffered input exceeds limit. Limit: ${S} bytes`,"stream"));return}u.push(a),m+=a.length;}},async flush(a){try{if(l$1){if(!f){let d=e(s,{compressionAlgorithm:void 0,encrypted:!1});a.enqueue(d);}if(o&&o.length>0){let d=await r$1.encodeAsync(o,{compress:!1,encrypt:!1,checksum:!1,chunkSize:0,chunkSeparator:void 0});a.enqueue(d);}o=null;}else {let d=e(s,{compressionAlgorithm:g,encrypted:n});a.enqueue(d);let c=new Uint8Array(m),A=0;for(let p of u)c.set(p,A),A+=p.length;let C=await r$1.encodeAsync(c,{...e$1,compress:i,encrypt:n,checksum:y,chunkSize:0,chunkSeparator:void 0});C.length>0&&a.enqueue(C),u=[],m=0;}}catch(d){a.error(r(d,"stream"));}}})}a(N,"createReadableEncodeStream");function Q(r$1,e){h(e,"stream");let t=r$1.getCharSetInfo(),i=t.paddingChar,n=d(i),y=e?.checksum??t.defaultChecksum,g=c(e?.maxBufferedChars,W,true,"maxBufferedChars"),s="",S=false,l$1=null;return new TransformStream({async transform(f$1,u){try{if(s+=f$1,s.length>g)throw new l(`[WebStreams decode] Buffered encoded input exceeds limit. Limit: ${g} characters`,"stream");if(!S&&s.length>=n){if(!s.startsWith(i))throw new Error("[WebStreams decode] Invalid or missing stream header");if(l$1=f(s,i),l$1===null)throw new Error("[WebStreams decode] Invalid or missing stream header");if(l$1.encrypted&&!t.hasEncryptionKey)throw new Error("[WebStreams decode] Encrypted stream requires an encryptionKey");S=!0,s=s.slice(n);}}catch(m){u.error(r(m,"stream"));}},async flush(f){try{if(!S){if(s.length===0)return;throw new Error("[WebStreams decode] Incomplete stream header")}let u=l$1.compressionAlgorithm,m=await r$1.decodeToUint8ArrayAsync(s,{...e,compress:e?.compress,compressionAlgorithm:u,checksum:y,chunkSize:void 0,chunkSeparator:void 0});m.length>0&&f.enqueue(m),s="";}catch(u){f.error(r(u,"stream"));}}})}a(Q,"createReadableDecodeStream");function M(r,e){return r.usePowerOfTwo&&!e.compressed&&!e.encrypted&&!e.checksum}a(M,"canUseChunkStreaming");function R(r,e){return r*e/_(r,e)}a(R,"lcm");function _(r,e){for(;e!==0;){let t=e;e=r%e,r=t;}return r}a(_,"gcd");export{T as a,N as b,Q as c};
|
package/dist/chunk-BDP7E7K3.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkJBUTKSCC_cjs=require('./chunk-JBUTKSCC.cjs'),chunkZTGECGM2_cjs=require('./chunk-ZTGECGM2.cjs'),chunkBCUBYE76_cjs=require('./chunk-BCUBYE76.cjs');var l=44032,b=55203,u=b-l+1;function d(e){if(e.length===0)throw new chunkZTGECGM2_cjs.n("[Ddu64 obfuscation] Alphabet must not be empty.");if(e.length>u)throw new chunkZTGECGM2_cjs.n(`[Ddu64 obfuscation] Alphabet size (${e.length}) exceeds available Hangul syllables (${u}).`);let r=Math.floor(u/e.length),t=new Map;for(let n=0;n<e.length;n++)t.set(e[n],n);return {alphabet:e,syllablesPerChar:r,charToIndex:t}}chunkBCUBYE76_cjs.a(d,"buildSyllableMap");function g(e,r,t){let n=l+e*t.syllablesPerChar,s=r%t.syllablesPerChar;return n+s}chunkBCUBYE76_cjs.a(g,"charToSyllable");function h(e,r){if(e<l||e>b)return -1;let t=e-l,n=Math.floor(t/r.syllablesPerChar);return n>=r.alphabet.length?-1:n}chunkBCUBYE76_cjs.a(h,"syllableToCharIndex");var c=class{static{chunkBCUBYE76_cjs.a(this,"HangulObfuscationLayer");}config;constructor(r){this.config=d(r);}obfuscate(r){if(r.length===0)return "";let t=new Array(r.length);for(let n=0;n<r.length;n++){let s=r[n],a=this.config.charToIndex.get(s);if(a===void 0)throw new chunkZTGECGM2_cjs.n(`[Ddu64 obfuscation] Character "${s}" (U+${s.charCodeAt(0).toString(16).padStart(4,"0").toUpperCase()}) not found in obfuscation alphabet.`);let p=g(a,n,this.config);t[n]=String.fromCharCode(p);}return t.join("")}deobfuscate(r){if(r.length===0)return "";let t=new Array(r.length);for(let n=0;n<r.length;n++){let s=r.charCodeAt(n),a=h(s,this.config);if(a===-1)throw new chunkZTGECGM2_cjs.n(`[Ddu64 obfuscation] Invalid syllable at position ${n}: U+${s.toString(16).padStart(4,"0").toUpperCase()} is not in the mapped range.`);t[n]=this.config.alphabet[a];}return t.join("")}};function L(e,r){return new c(chunkJBUTKSCC_cjs.g(e,r))}chunkBCUBYE76_cjs.a(L,"createEncoderObfuscationLayer");function T(){let e=globalThis;return e.Deno?.version?.deno?"deno":e.Bun?.version?"bun":e.process?.versions?.node?"node":typeof e.EdgeRuntime=="string"||typeof e.WebSocketPair<"u"&&e.crypto?.subtle?"edge":typeof e.crypto<"u"&&e.crypto?.subtle?"browser":"unknown"}chunkBCUBYE76_cjs.a(T,"detectRuntime");exports.a=c;exports.b=L;exports.c=T;
|
package/dist/chunk-JBUTKSCC.cjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkZTGECGM2_cjs=require('./chunk-ZTGECGM2.cjs'),chunkBCUBYE76_cjs=require('./chunk-BCUBYE76.cjs');var Ae=(n=>(n.DDU="ddu",n.DDU_V1="ddu_v1",n.ONECHARSET="oneCharSet",n))(Ae||{}),de={dduSetSymbol:"ddu",usePowerOfTwo:true,requiredLength:64};function Se(e,r){return e<=1?0:r?Math.floor(Math.log2(e)):Math.ceil(Math.log2(e))}chunkBCUBYE76_cjs.a(Se,"calculateBitLength");function we(e){return e>0&&(e&e-1)===0}chunkBCUBYE76_cjs.a(we,"isPowerOfTwo");function Pe(e){return e<31?1<<e:Math.pow(2,e)}chunkBCUBYE76_cjs.a(Pe,"maxValueForBitLength");var Mr=(()=>{let e=new Uint32Array(256);for(let r=0;r<256;r++){let t=r;for(let n=0;n<8;n++)t=t>>>1^(t&1?3988292384:0);e[r]=t;}return e})();function U(e){let r=4294967295;for(let t=0;t<e.length;t++)r=r>>>8^Mr[(r^e[t])&255];return ((r^4294967295)>>>0).toString(16).padStart(8,"0")}chunkBCUBYE76_cjs.a(U,"calculateCRC32");function ce(e,r){let t=Math.max(e.length,r.length),n=e.length^r.length;for(let o=0;o<t;o++){let i=o<e.length?e.charCodeAt(o):0,s=o<r.length?r.charCodeAt(o):0;n|=i^s;}return n===0}chunkBCUBYE76_cjs.a(ce,"constantTimeEquals");var De=["-","_","."];function Ee(e){return e.length===0?e:e.replaceAll("+","-").replaceAll("/","_").replaceAll("=",".")}chunkBCUBYE76_cjs.a(Ee,"toUrlSafe");function ke(e){return e.length===0?e:e.replaceAll("-","+").replaceAll("_","/").replaceAll(".","=")}chunkBCUBYE76_cjs.a(ke,"fromUrlSafe");function xe(e,r,t){if(r<=0||e.length<=r)return e;let n=Math.ceil(e.length/r),o=new Array(n*2-1),i=0;for(let s=0;s<e.length;s+=r)o[i++]=e.slice(s,s+r),s+r<e.length&&(o[i++]=t);return o.join("")}chunkBCUBYE76_cjs.a(xe,"splitIntoChunks");function ve(e,r){if(e.length===0)return e;let t=r&&r!==`
|
|
2
|
-
`&&r!==`\r
|
|
3
|
-
`&&r!=="\r"?r:"",n=e.includes(`
|
|
4
|
-
`)||e.includes("\r"),o=t.length>0&&e.includes(t);if(!n&&!o)return e;let i=n?e.replace(/[\r\n]/g,""):e;return o&&(i=i.replaceAll(t,"")),i}chunkBCUBYE76_cjs.a(ve,"removeChunks");var Ue={"":0,\u3131:1,\u3132:2,\u3133:3,\u3134:4,\u3135:5,\u3136:6,\u3137:7,\u3139:8,\u313A:9,\u313B:10,\u313C:11,\u313D:12,\u313E:13,\u313F:14,\u3140:15,\u3141:16,\u3142:17,\u3144:18,\u3145:19,\u3146:20,\u3147:21,\u3148:22,\u314A:23,\u314B:24,\u314C:25,\u314D:26,\u314E:27};function Be(e){return Object.prototype.hasOwnProperty.call(Ue,e)}chunkBCUBYE76_cjs.a(Be,"isKnownCodaChar");function Kr(e,r){let t=e.charCodeAt(0);if(t<44032||t>55203)return e;let n=t-(t-44032)%28,o=Ue[r]??0;return String.fromCharCode(n+o)}chunkBCUBYE76_cjs.a(Kr,"combineCoda");function Y(e,r){let t=new Array(e.length*r.length),n=0;for(let o of e)for(let i of r)t[n++]=Kr(o,i);return t}chunkBCUBYE76_cjs.a(Y,"buildCodaCharset");function X(e,r){let n=e===void 0||!Number.isFinite(e)?6:Math.floor(e);return Math.min(r==="brotli"?11:9,Math.max(0,n))}chunkBCUBYE76_cjs.a(X,"normalizeCompressionLevel");var Nr=new TextEncoder,_r=new TextDecoder;function K(e){return Nr.encode(e)}chunkBCUBYE76_cjs.a(K,"stringToBytes");function ue(e){return _r.decode(e)}chunkBCUBYE76_cjs.a(ue,"bytesToString");var zr={symbol:"ddu",charSet:["\uB70C","\uB568","\uC774","\uC6B0","\uC57C","\uB4C0","\uB31C","\uB3A8"],codaChar:["","\u3131","\u3132","\u3137","\u3148","\u3147","\u3145","\u3146"],maxRequiredLength:64,bitLength:6,paddingChar:"\uBB50",useRepeatPadding:true},Fr={symbol:"ddu_v1",charSet:["\uB70C","\uB568","\uC774","\uC6B0","\uC57C","!","?","."],maxRequiredLength:8,bitLength:6,paddingChar:"\uBB50",useRepeatPadding:true,usePowerOfTwo:false,encodingProfile:{bitLength:6,usePowerOfTwo:false,bitsPerPadChar:2}},$r={symbol:"oneCharSet",charSet:["A","s","q","r","0","z","3","t","y","1","5","2","4","E","B","C","Q","F","R","T","U","W","V","X","Y","Z","b","a","c","d","D","G","L","H","I","-","J","K","M","O","N","f","e","h","g","P","i","S","k","l","m","u","j","v","n","o","p","9","w","6","7","8","x","_"],paddingChar:"=",maxRequiredLength:64,bitLength:6};function J(e){switch(e){case "ddu":return zr;case "ddu_v1":return Fr;case "oneCharSet":return $r;default:return}}chunkBCUBYE76_cjs.a(J,"getCharSet");var Vr=65536;function Re(e,r,t,n){let o=chunkBCUBYE76_cjs.a((i,s,c,d,u)=>{if(Hr(c,t?.usePowerOfTwo)&&c>0){let f=Math.floor(Math.log2(c)),h=1<<f;return {charSet:i.length===h?i:i.slice(0,h),padding:s,requiredLength:h,bitLength:f,isPredefined:d,useRepeatPadding:u}}return {charSet:i.length===c?i:i.slice(0,c),padding:s,requiredLength:c,bitLength:c>0?Math.ceil(Math.log2(c)):0,isPredefined:d,useRepeatPadding:u}},"buildMeta");try{let i=e??t?.dduChar,s=r??t?.paddingChar;if(i){if(!s)throw new Error("[Ddu64 Constructor] paddingChar is required when dduChar is provided.");let f=typeof i=="string"?[...i]:[...i],h=t?.codaChar,m=h?!0:t?.useRepeatPadding??!1;if(h&&h.length>0){if(n){let g=h.filter(w=>!Be(w));if(g.length>0)throw new Error(`[Ddu64 Constructor] Unknown coda character(s): [${g.join(", ")}]. Coda must be empty ("") or a Hangul jongseong jamo (\u3131, \u3132, \u3133, \u2026 \u314E). Unknown coda collapses to no-coda and can create duplicate symbols.`)}f=Y(f,h);}if(n&&new Set(f).size!==f.length){let w=f.filter((C,S)=>f.indexOf(C)!==S);throw new Error(`[Ddu64 Constructor] Character set contains duplicate characters: [${[...new Set(w)].join(", ")}]`)}let y=t?.requiredLength??f.length;if(f.length<y)throw new Error("[Ddu64 Constructor] Insufficient characters.");return o(f,s,y,!1,m)}let c=t?.dduSetSymbol??de.dduSetSymbol??"ddu",d=qr(c),u=d.codaChar?Y(d.charSet,d.codaChar):d.charSet,l=o(u,d.paddingChar,d.maxRequiredLength,!0,d.useRepeatPadding),p=d.encodingProfile;return p?(l.encodingProfile=p,l.bitLength=p.bitLength,l.usePowerOfTwo=p.usePowerOfTwo,l.bitsPerPadChar=p.bitsPerPadChar):(l.bitsPerPadChar=d.bitsPerPadChar,l.usePowerOfTwo=d.usePowerOfTwo,d.usePowerOfTwo===!1&&(l.bitLength=d.bitLength)),l}catch(i){if(n)throw i;return le(t)}}chunkBCUBYE76_cjs.a(Re,"resolveInitialCharSet");function Ie(e,r,t){let n=[e,null];for(let i of n){let s=i?{...i}:le(t);try{let c=s.charSet,d=s.requiredLength,u=Array.from(new Set(c));if(u.length!==c.length){if(r){let f=c.filter((h,m)=>c.indexOf(h)!==m);throw new Error(`[Ddu64 normalizeCharSet] Character set contains duplicate characters: [${[...new Set(f)].join(", ")}]`)}c=u,s.isPredefined||(d=c.length);}if(c.length<d)throw new Error(`[Ddu64 normalizeCharSet] Insufficient characters. Required: ${d}, Has: ${c.length}`);if(d<2)throw new Error("[Ddu64 normalizeCharSet] At least 2 unique characters required.");if(c.length===0)throw new Error("[Ddu64 normalizeCharSet] Empty charset.");if(c.find(f=>f.length!==1)){if(r)throw new Error("[Ddu64 normalizeCharSet] Multi-character symbols are not supported.");continue}if(c.length>Vr){if(r)throw new Error("[Ddu64 normalizeCharSet] Charset size exceeds maximum supported size of 65536.");continue}if(s.padding.length!==1)throw new Error(`[Ddu64 normalizeCharSet] Padding length mismatch. Expected 1, got ${s.padding.length}`);if(c.includes(s.padding)){if(r)throw new Error(`[Ddu64 normalizeCharSet] Padding character "${s.padding}" conflicts with charset.`);c=c.filter(f=>f!==s.padding);}for(let f of c){if(f.includes(`
|
|
5
|
-
`)||f.includes("\r"))throw new Error("[Ddu64 normalizeCharSet] Newline and carriage return characters are reserved.");if(Oe(f))throw new Error(`[Ddu64 normalizeCharSet] Lone surrogate code unit (U+${f.charCodeAt(0).toString(16).toUpperCase()}) is not allowed; it corrupts on UTF-8/URL/JSON boundaries.`)}if(s.padding.includes(`
|
|
6
|
-
`)||s.padding.includes("\r"))throw new Error("[Ddu64 normalizeCharSet] Newline and carriage return characters are reserved.");if(Oe(s.padding))throw new Error("[Ddu64 normalizeCharSet] Padding character must not be a lone surrogate code unit.");return {charSet:c.length===d?c:c.slice(0,d),padding:s.padding,isPredefined:s.isPredefined}}catch(c){if(r)throw c}}let o=le(t);return {charSet:o.charSet.slice(0,o.requiredLength),padding:o.padding,isPredefined:true}}chunkBCUBYE76_cjs.a(Ie,"normalizeCharSet");function Le(e,r,t){for(let n of De){for(let o of e)if(o.includes(n)){let i=`[Ddu64 Constructor] URL-Safe mode conflict: charset character "${o}" contains "${n}".`;if(t)throw new Error(i);return false}if(r.includes(n)){let o=`[Ddu64 Constructor] URL-Safe mode conflict: padding character "${r}" contains "${n}".`;if(t)throw new Error(o);return false}}return true}chunkBCUBYE76_cjs.a(Le,"isUrlSafeCompatible");function Oe(e){if(e.length!==1)return false;let r=e.charCodeAt(0);return r>=55296&&r<=57343}chunkBCUBYE76_cjs.a(Oe,"isLoneSurrogate");function Hr(e,r){return r!==void 0?r?e>0:false:e>0&&(e&e-1)===0}chunkBCUBYE76_cjs.a(Hr,"shouldUsePowerOfTwo");function qr(e){let r=J(e);if(!r)throw new Error(`CharSet with symbol ${e} not found`);return r}chunkBCUBYE76_cjs.a(qr,"getCharSetOrThrow");function le(e){let r=e?.dduSetSymbol??de.dduSetSymbol??"oneCharSet",t=J(r)??J("oneCharSet");if(!t)throw new Error("Critical: No fallback CharSet available");return {charSet:t.codaChar?Y(t.charSet,t.codaChar):t.charSet,padding:t.paddingChar,requiredLength:t.maxRequiredLength,bitLength:t.encodingProfile?.bitLength??t.bitLength,isPredefined:true,useRepeatPadding:t.useRepeatPadding,bitsPerPadChar:t.encodingProfile?.bitsPerPadChar??t.bitsPerPadChar,usePowerOfTwo:t.encodingProfile?.usePowerOfTwo??t.usePowerOfTwo,encodingProfile:t.encodingProfile}}chunkBCUBYE76_cjs.a(le,"getFallbackCharSet");var Gr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Te(e,r,t,n){return t&&n===6&&r==="="&&e.join("")===Gr}chunkBCUBYE76_cjs.a(Te,"canUseNativeBase64FastPath");function Me(e){let r=jr(e);if(r===null)return null;let t=0,n=r.length;for(;n>0&&r[n-1]==="=";)t++,n--;return {payload:r.slice(0,n),paddingBits:t===2?4:t===1?2:0}}chunkBCUBYE76_cjs.a(Me,"encodeNativeBase64");function Ke(e,r,t){let n=r===4?2:r===2?1:r===0?0:-1;if(n<0)return null;for(let o=0;o<e.length;o++)if(!t(e.charCodeAt(o)))return null;return Wr(e+"=".repeat(n))}chunkBCUBYE76_cjs.a(Ke,"decodeNativeBase64");function jr(e){let r=e.toBase64;if(typeof r=="function")return r.call(e);let t=globalThis.Buffer;return t?.from?t.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"):null}chunkBCUBYE76_cjs.a(jr,"bytesToBase64");function Wr(e){let r=Uint8Array;if(typeof r.fromBase64=="function")return r.fromBase64(e);let t=globalThis.Buffer;if(t?.from){let n=t.from(e,"base64");return new Uint8Array(n)}return null}chunkBCUBYE76_cjs.a(Wr,"base64ToBytes");function Z(e,r){if(!e)throw new chunkZTGECGM2_cjs.m("[Ddu64 adapter] No platform adapter available. Use encodeAsync()/decodeAsync() in browser environments, or provide an adapter via options.adapter.",r);return e}chunkBCUBYE76_cjs.a(Z,"requireSyncAdapter");function Ne(e,r,t){let n=Z(e.adapter,"encode");if(!n.encryptSync)throw new chunkZTGECGM2_cjs.m("[Ddu64 encrypt] Sync encryption unavailable. Use encodeAsync() in browser environments.","encode");let o=$e(e,n,"encrypt","encode");return n.encryptSync(r,o,t)}chunkBCUBYE76_cjs.a(Ne,"encryptSyncWithAdapter");function _e(e,r,t){let n=Z(e.adapter,"decode");if(!n.decryptSync)throw new chunkZTGECGM2_cjs.m("[Ddu64 decrypt] Sync decryption unavailable. Use decodeAsync() in browser environments.","decode");let o=$e(e,n,"decrypt","decode");return n.decryptSync(r,o,t)}chunkBCUBYE76_cjs.a(_e,"decryptSyncWithAdapter");function ze(e,r,t,n){let o=Z(e,"encode");if(t==="brotli"){if(!o.brotliCompressSync)throw new chunkZTGECGM2_cjs.m("[Ddu64 compress] Brotli compression is unavailable in the current runtime.","encode");return o.brotliCompressSync(r,n)}if(!o.deflateSync)throw new chunkZTGECGM2_cjs.m("[Ddu64 compress] Sync compression unavailable. Use encodeAsync() in browser environments.","encode");return o.deflateSync(r,n)}chunkBCUBYE76_cjs.a(ze,"compressSyncWithAdapter");function Fe(e,r,t,n){let o=Z(e,"decode");if(t==="brotli"){if(!o.brotliDecompressSync)throw new chunkZTGECGM2_cjs.m("[Ddu64 decompress] Brotli decompression is unavailable in the current runtime.","decode");return o.brotliDecompressSync(r,n)}if(!o.inflateSync)throw new chunkZTGECGM2_cjs.m("[Ddu64 decompress] Sync decompression unavailable. Use decodeAsync() in browser environments.","decode");return o.inflateSync(r,n)}chunkBCUBYE76_cjs.a(Fe,"decompressSyncWithAdapter");function $e(e,r,t,n){if(e.encryptionKeyHash)return e.encryptionKeyHash;if(!r.deriveKeySync){let i=t==="encrypt"?"encodeAsync":"decodeAsync";throw new chunkZTGECGM2_cjs.m(`[Ddu64 ${t}] Sync key derivation unavailable. Use ${i}() in browser environments.`,n)}let o=r.deriveKeySync(e.encryptionKey,e.keyDerivation);return e.setEncryptionKeyHash(o),o}chunkBCUBYE76_cjs.a($e,"getSyncKeyHash");function Q(e,r){throw chunkZTGECGM2_cjs.p(e)?e:new r(chunkZTGECGM2_cjs.q(e),e)}chunkBCUBYE76_cjs.a(Q,"rethrowTyped");function Ve(e,r,t){try{return Ne(e,r,t)}catch(n){Q(n,chunkZTGECGM2_cjs.g);}}chunkBCUBYE76_cjs.a(Ve,"runEncryptSync");function He(e,r,t){try{return _e(e,r,t)}catch(n){Q(n,chunkZTGECGM2_cjs.h);}}chunkBCUBYE76_cjs.a(He,"runDecryptSync");function he(e,r,t,n){try{return ze(e,r,t,n)}catch(o){Q(o,chunkZTGECGM2_cjs.e);}}chunkBCUBYE76_cjs.a(he,"runCompressSync");function qe(e,r,t,n){try{return Fe(e,r,t,n)}catch(o){Q(o,chunkZTGECGM2_cjs.f);}}chunkBCUBYE76_cjs.a(qe,"runDecompressSync");async function Ge(e,r,t){try{let n=ee(e.adapter,"encode"),o=await Ye(e,n);return await n.encrypt(r,o,t)}catch(n){throw re(n,"encode","encrypt")}}chunkBCUBYE76_cjs.a(Ge,"encryptAsyncWithAdapter");async function je(e,r,t){try{let n=ee(e.adapter,"decode"),o=await Ye(e,n);return await n.decrypt(r,o,t)}catch(n){throw re(n,"decode","decrypt")}}chunkBCUBYE76_cjs.a(je,"decryptAsyncWithAdapter");async function fe(e,r,t,n){try{let o=ee(e,"encode");if(t==="brotli"){if(!o.brotliCompress)throw new chunkZTGECGM2_cjs.m("[Ddu64 compress] Brotli compression is unavailable in the current runtime.","encode");return await o.brotliCompress(r,n)}return await o.deflate(r,n)}catch(o){throw re(o,"encode","compress")}}chunkBCUBYE76_cjs.a(fe,"compressAsyncWithAdapter");async function We(e,r,t,n){try{let o=ee(e,"decode");if(t==="brotli"){if(!o.brotliDecompress)throw new chunkZTGECGM2_cjs.m("[Ddu64 decompress] Brotli decompression is unavailable in the current runtime.","decode");return await o.brotliDecompress(r,n)}return await o.inflate(r,n)}catch(o){throw re(o,"decode","decompress")}}chunkBCUBYE76_cjs.a(We,"decompressAsyncWithAdapter");function ee(e,r){if(!e)throw new chunkZTGECGM2_cjs.m("[Ddu64 adapter] No platform adapter available. Use @ddunigma/node or @ddunigma/node/browser, or provide an adapter via options.adapter.",r);return e}chunkBCUBYE76_cjs.a(ee,"requireAsyncAdapter");async function Ye(e,r){if(e.encryptionKeyHash)return e.encryptionKeyHash;if(e.encryptionKeyHashPromise)return e.encryptionKeyHashPromise;let t=r.deriveKey(e.encryptionKey,e.keyDerivation).then(n=>(e.setEncryptionKeyHash(n),n)).finally(()=>{e.encryptionKeyHashPromise=void 0;});return e.encryptionKeyHashPromise=t,t}chunkBCUBYE76_cjs.a(Ye,"getAsyncKeyHash");function re(e,r,t){if(chunkZTGECGM2_cjs.p(e))return e;let n=chunkZTGECGM2_cjs.q(e);switch(t){case "compress":return new chunkZTGECGM2_cjs.e(n,e);case "decompress":return new chunkZTGECGM2_cjs.f(n,e);case "encrypt":return new chunkZTGECGM2_cjs.g(n,e);case "decrypt":return new chunkZTGECGM2_cjs.h(n,e)}}chunkBCUBYE76_cjs.a(re,"toAsyncGatewayError");function Xe(e,r,t){return e!=null&&typeof e=="object"&&!Array.isArray(e)?{dduChar:void 0,paddingChar:void 0,dduOptions:e}:{dduChar:e,paddingChar:r,dduOptions:t}}chunkBCUBYE76_cjs.a(Xe,"resolveConstructorArgs");var Je=new Map;function Ze(e,r=false){let t=r?e.join(""):void 0;if(t!==void 0){let u=Je.get(t);if(u)return u}let n=new Uint16Array(e.length),o=65535,i=0;for(let u=0;u<e.length;u++){let l=e[u].charCodeAt(0);n[u]=l,l>i&&(i=l),l<o&&(o=l);}let s=e.length>0?o:0,c=new Int32Array(i-s+1);c.fill(-1);for(let u=0;u<e.length;u++)c[n[u]-s]=u;let d={charCodeLookup:c,charCodes:n,lookupOffset:s};return t!==void 0&&Je.set(t,d),d}chunkBCUBYE76_cjs.a(Ze,"buildCharsetLookupTables");function N(e,r,t){let n=r-t;return n>=0&&n<e.length?e[n]:-1}chunkBCUBYE76_cjs.a(N,"lookupCharIndex");var Qe=8;function er(e,r,t,n){return Math.ceil(e/(n?1:2))*t-r}chunkBCUBYE76_cjs.a(er,"decodedBitCount");function x(e,r,t,n){if(e===void 0)return r;if(e===Number.POSITIVE_INFINITY)return Number.POSITIVE_INFINITY;if(!Number.isFinite(e)||e<=0){if(t)throw new chunkZTGECGM2_cjs.k(`[Ddu64 options] Invalid ${n}. Must be a positive finite number or Infinity.`);return r}return Math.floor(e)}chunkBCUBYE76_cjs.a(x,"normalizeLimit");function rr(e,r,t,n){if(e===0)return 0;if(r<0||r>=t)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid padding bits: ${r}`);let o=er(e,r,t,n);if(o<0)throw new chunkZTGECGM2_cjs.d("[Ddu64 decode] Invalid decoded bit length");return Math.ceil(o/Qe)}chunkBCUBYE76_cjs.a(rr,"estimateDecodedBytes");function tr(e,r){if(!r&&e.length%2!==0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid encoded length for variable charset. Expected multiple of 2, got ${e.length}`)}chunkBCUBYE76_cjs.a(tr,"assertEncodedInputAligned");function nr(e,r,t,n){if(e.length===0)return;let o=er(e.length,r,t,n);if(o<0||o%Qe!==0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid encoded bit length. Expected a whole number of bytes, got ${o} bits.`)}chunkBCUBYE76_cjs.a(nr,"assertDecodedBitLength");function or(e,r,t,n,o,i){if(r===0)return;if(e.length===0)throw new chunkZTGECGM2_cjs.d("[Ddu64 decode] Invalid padding bits without payload");let s=(1<<r)-1,c;if(t){let d=e[e.length-1],u=N(n,d.charCodeAt(0),i);if(u<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${d}" at ${e.length-1}`);c=u;}else {let d=e[e.length-2],u=e[e.length-1],l=N(n,d.charCodeAt(0),i),p=N(n,u.charCodeAt(0),i);if(l<0||p<0)throw new chunkZTGECGM2_cjs.d("[Ddu64 decode] Invalid character in final encoded chunk");c=l*o+p;}if((c&s)!==0)throw new chunkZTGECGM2_cjs.d("[Ddu64 decode] Invalid non-zero padding bits in final symbol")}chunkBCUBYE76_cjs.a(or,"assertCanonicalPadding");var _="DDS1",z="ELYSIA",F="GRISEO";var Yr=new TextEncoder;function B(e,r,t){let n=t-r.length;if(n<0)return false;for(let o=0;o<r.length;o++)if(e.charCodeAt(n+o)!==r.charCodeAt(o))return false;return true}chunkBCUBYE76_cjs.a(B,"endsWithAt");function ir(e,r,t,n=2){let o=e.length,i=r.length,s={cleanedInput:e,paddingBits:0,isEncrypted:false,pipelineVersion:2};if(i===0||o<i)return s;let d=Math.max(0,t-1).toString().length;for(let u=Math.min(d,o);u>=1;u--){let l=o-u,p=true;for(let C=l;C<o;C++){let S=e.charCodeAt(C);if(S<48||S>57){p=false;break}}if(!p||u>1&&e.charCodeAt(l)===48)continue;let f=0;for(let C=l;C<o;C++)f=f*10+(e.charCodeAt(C)-48);if(f>=t)continue;let h=l,m=false,y,g=2;h>=2&&B(e,"V4",h)?(g=4,h-=2):h>=2&&B(e,"V3",h)&&(g=3,h-=2),h>=3&&B(e,"ENC",h)&&(m=true,h-=3),h>=z.length&&B(e,z,h)?(y="deflate",h-=z.length):h>=F.length&&B(e,F,h)&&(y="brotli",h-=F.length);let w=h-i;if(w>=0&&B(e,r,h))return {cleanedInput:e.substring(0,w),paddingBits:f,compressionAlgorithm:y,isEncrypted:m,pipelineVersion:g}}if(B(e,r,o)){let u=0,l=o;for(;l>=i&&B(e,r,l);)u++,l-=i;if(u>0){let p=u*n;if(p<t)return {cleanedInput:e.substring(0,l),paddingBits:p,isEncrypted:false,pipelineVersion:2}}}return s}chunkBCUBYE76_cjs.a(ir,"parseFooter");function Xr(e){let r=e.lastIndexOf("CHK");if(r===-1)return {data:e,checksum:null};let t=e.slice(r+3);return t.length!==8||!/^[0-9a-f]+$/i.test(t)?{data:e,checksum:null}:{data:e.slice(0,r),checksum:t.toLowerCase()}}chunkBCUBYE76_cjs.a(Xr,"extractChecksum");var Jr=/^[0-9a-f]{8}$/i;function ar(e){let r=e.length;if(r>=11){let n=e.charCodeAt(r-11),o=e.charCodeAt(r-10),i=e[r-9];if(n===67&&o===75&&(i==="P"||i==="O")){let s=e.slice(r-8);if(Jr.test(s))return {data:e.slice(0,r-11),checksum:s.toLowerCase(),scope:i==="P"?"plaintext":"output"}}}let t=Xr(e);return {data:t.data,checksum:t.checksum,scope:null}}chunkBCUBYE76_cjs.a(ar,"extractScopedChecksum");function Zr(e){return e.length*2+_.length+2}chunkBCUBYE76_cjs.a(Zr,"getStreamHeaderLength");function $t(e,r){let t=r.compressionAlgorithm==="brotli"?"B":r.compressionAlgorithm==="deflate"?"D":"N",n=r.encrypted?"1":"0";return `${e}${_}${t}${n}${e}`}chunkBCUBYE76_cjs.a($t,"buildStreamHeader");function Vt(e,r){let t=Zr(r);if(e.length<t||!e.startsWith(r))return null;let n=r.length;if(e.slice(n,n+_.length)!==_)throw new Error("[wireFormat] Invalid stream header magic");let i=e[n+_.length],s=e[n+_.length+1];if(e.slice(t-r.length,t)!==r)throw new Error("[wireFormat] Invalid stream header terminator");let d=i==="B"?"brotli":i==="D"?"deflate":i==="N"?void 0:null;if(d===null)throw new Error("[wireFormat] Invalid stream header compression flag");if(s!=="0"&&s!=="1")throw new Error("[wireFormat] Invalid stream header encryption flag");return {compressionAlgorithm:d,encrypted:s==="1"}}chunkBCUBYE76_cjs.a(Vt,"parseStreamHeader");function sr(e){let{paddingBits:r,compressionAlgorithm:t,isEncrypted:n,paddingChar:o,useRepeatPadding:i,bitsPerPadChar:s=2,pipelineVersion:c=2}=e;if(!n&&c!==2)throw new Error("[wireFormat] Pipeline version markers require encryption");if(r===0&&!t&&!n&&c===2)return "";if(i&&!t&&!n&&c===2&&r>0&&r%s===0){let u=r/s;return o.repeat(u)}return o+(t==="deflate"?z:t==="brotli"?F:"")+(n?"ENC":"")+(c===4?"V4":c===3?"V3":"")+r.toString()}chunkBCUBYE76_cjs.a(sr,"buildFooter");function te(e){return Yr.encode(`ddunigma:wire:v4;enc=1;compress=${e.compressionAlgorithm??"none"}`)}chunkBCUBYE76_cjs.a(te,"buildEncryptionAAD");function dr(e,r,t){let n=r?.checksum??t.defaultChecksum,o=r?.compress!==false,i=r?.encrypt!==false,s=e;t.reportDecodeStart(e.length);let c=x(r?.maxEncodedChars,t.defaultMaxEncodedChars,true,"maxEncodedChars");if(e.length>c)throw new chunkZTGECGM2_cjs.l(`[Ddu64 decode] Encoded input exceeds limit. Length: ${e.length}, Limit: ${c} characters`,"decode");let d=r?.chunkSeparator??t.defaultChunkSeparator;s=ve(s,d),t.urlSafe&&(s=ke(s));let u=null,l=null;if(n){let O=ar(s);if(u=O.checksum,l=O.scope,s=O.data,!u)throw new chunkZTGECGM2_cjs.i("[Ddu64 checksum] Checksum verification requested, but no checksum marker was found.")}t.shouldObfuscate(r)&&(s=t.deobfuscate(s));let{cleanedInput:p,paddingBits:f,compressionAlgorithm:h,isEncrypted:m,pipelineVersion:y}=ir(s,t.paddingChar,t.bitLength,t.bitsPerPadChar);if((r?.requireEncryption??t.defaultRequireEncryption)&&i&&!m)throw new chunkZTGECGM2_cjs.h("[Ddu64 decode] Encryption is required, but the payload has no authenticated encryption footer.");if(m&&i&&!t.encryptionKey)throw new chunkZTGECGM2_cjs.h("[Ddu64 decode] Encrypted payload requires an encryptionKey");let w=m&&y===4?te({compressionAlgorithm:h}):void 0;tr(p,t.usePowerOfTwo),or(p,f,t.usePowerOfTwo,t.dduCharCodeLookup,t.charSetSize,t.dduCharCodeLookupOffset),nr(p,f,t.bitLength,t.usePowerOfTwo);let C=x(r?.maxDecodedBytes,t.defaultMaxDecodedBytes,true,"maxDecodedBytes"),S=rr(p.length,f,t.bitLength,t.usePowerOfTwo);if(S>C)throw new chunkZTGECGM2_cjs.l(`[Ddu64 decode] Decoded output exceeds limit. Estimated: ${S} bytes, Limit: ${C} bytes`,"decode");return t.reportBitpackDecode(p.length,e.length),{decoded:t.decodeChars(p,f),extractedChecksum:u,extractedChecksumScope:l,compressionAlgorithm:h,isEncrypted:m,pipelineVersion:y,encryptionAAD:w,allowInternalDecompress:o,allowInternalDecrypt:i}}chunkBCUBYE76_cjs.a(dr,"runDecodePrelude");function cr(e){return e.omitFooter?"":sr({paddingBits:e.paddingBits,compressionAlgorithm:e.compressionAlgorithm,isEncrypted:e.isEncrypted,paddingChar:e.paddingChar,useRepeatPadding:e.useRepeatPadding&&!e.compressionAlgorithm&&!e.isEncrypted,bitsPerPadChar:e.bitsPerPadChar,pipelineVersion:e.isEncrypted?e.pipelineVersion:2})}chunkBCUBYE76_cjs.a(cr,"buildEncodeFooter");function ur(e){let r=e.encoded;if(e.shouldObfuscate(e.options)&&(r=e.getObfuscationLayer().obfuscate(r)),e.shouldChecksum&&e.checksum){let t=e.checksumScope==="plaintext"?"P":"O";r=r+"CK"+t+e.checksum;}return e.urlSafe&&(r=Ee(r)),e.chunkSize&&e.chunkSize>0&&(e.assertSafeChunkSeparator(r,e.chunkSeparator),r=xe(r,e.chunkSize,e.chunkSeparator)),r}chunkBCUBYE76_cjs.a(ur,"applyPostEncoding");var pe=8192;function lr(e,r,t){let n=e.length;if(n===0)return {payload:"",paddingBits:0};let o=Math.ceil(n*8/r),i=Math.min(o,pe),s=new Uint16Array(i),c=[],d=0,u=0;if(r===6){let l=0;for(;l+2<n;l+=3){let f=e[l],h=e[l+1],m=e[l+2];s[d++]=t[f>>>2],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),s[d++]=t[(f&3)<<4|h>>>4],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),s[d++]=t[(h&15)<<2|m>>>6],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),s[d++]=t[m&63],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0);}let p=n-l;if(p===1){let f=e[l];s[d++]=t[f>>>2],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),s[d++]=t[(f&3)<<4],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),u=4;}else if(p===2){let f=e[l],h=e[l+1];s[d++]=t[f>>>2],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),s[d++]=t[(f&3)<<4|h>>>4],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),s[d++]=t[(h&15)<<2],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),u=2;}}else if(r===8)for(let l=0;l<n;l++)s[d++]=t[e[l]],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0);else {let l=(1<<r)-1,p=0,f=0;for(let h=0;h<n;h++)for(p=p<<8|e[h],f+=8;f>=r;)f-=r,s[d++]=t[p>>f&l],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),p&=(1<<f)-1;f>0&&(u=r-f,s[d++]=t[p<<u&l]);}return d>0&&c.push(String.fromCharCode.apply(null,s.subarray(0,d))),{payload:c.length===1?c[0]:c.join(""),paddingBits:u}}chunkBCUBYE76_cjs.a(lr,"packPow2ToString");function hr(e,r,t,n,o){let i=e.length;if(i===0)return new Uint8Array(0);let s=Math.ceil((i*t-r)/8),c=new Uint8Array(s+1),d=0,u=n.length;if(t===6){let h=i-i%4;h===i&&r>0&&(h-=4);let m=0;for(;m<h;m+=4){let C=e.charCodeAt(m)-o,S=C>=0&&C<u?n[C]:-1;if(S<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[m]}" at ${m}`);let D=e.charCodeAt(m+1)-o,O=D>=0&&D<u?n[D]:-1;if(O<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[m+1]}" at ${m+1}`);let ne=e.charCodeAt(m+2)-o,oe=ne>=0&&ne<u?n[ne]:-1;if(oe<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[m+2]}" at ${m+2}`);let ie=e.charCodeAt(m+3)-o,ge=ie>=0&&ie<u?n[ie]:-1;if(ge<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[m+3]}" at ${m+3}`);c[d++]=S<<2|O>>>4,c[d++]=(O&15)<<4|oe>>>2,c[d++]=(oe&3)<<6|ge;}let y=0,g=0,w=i-1;for(;m<i;m++){let S=e.charCodeAt(m)-o,D=S>=0&&S<u?n[S]:-1;if(D<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[m]}" at ${m}`);for(y=y<<6|D,g+=6,m===w&&r>0&&(y>>=r,g-=r);g>=8;)g-=8,c[d++]=y>>g&255,y&=(1<<g)-1;}return c.subarray(0,d)}if(t===8&&r===0){for(let h=0;h<i;h++){let y=e.charCodeAt(h)-o,g=y>=0&&y<u?n[y]:-1;if(g<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[h]}" at ${h}`);c[d++]=g;}return c.subarray(0,d)}let l=0,p=0,f=i-1;for(let h=0;h<i;h++){let y=e.charCodeAt(h)-o,g=y>=0&&y<u?n[y]:-1;if(g<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[h]}" at ${h}`);for(l=l<<t|g,p+=t,h===f&&r>0&&(l>>=r,p-=r);p>=8;)p-=8,c[d++]=l>>p&255,l&=(1<<p)-1;}return c.subarray(0,d)}chunkBCUBYE76_cjs.a(hr,"unpackPow2FromString");function fr(e,r,t,n){let o=e.length;if(o===0)return {payload:"",paddingBits:0};let i=[],s=new Uint16Array(pe),c=0,d=0,u=0,l=0,p=chunkBCUBYE76_cjs.a(f=>{s[c++]=f,c===pe&&(i.push(String.fromCharCode.apply(null,s)),c=0);},"pushCode");for(let f=0;f<o;f++)for(d=d<<8|e[f],u+=8;u>=r;){u-=r;let h=d>>u,m=h/t|0;p(n[m]),p(n[h-m*t]),d&=(1<<u)-1;}if(u>0){l=r-u;let f=d<<l,h=f/t|0;p(n[h]),p(n[f-h*t]);}return c>0&&i.push(String.fromCharCode.apply(null,s.subarray(0,c))),{payload:i.length===1?i[0]:i.join(""),paddingBits:l}}chunkBCUBYE76_cjs.a(fr,"packNonPow2ToString");function pr(e,r,t,n,o,i){let s=e.length;if(s===0)return new Uint8Array(0);let c=Math.ceil(s/2),d=Math.ceil((c*t-r)/8),u=new Uint8Array(d+1),l=0,p=Pe(t),f=o.length,h=0,m=0;for(let y=0;y<s;y+=2){let g=e.charCodeAt(y)-i,w=g>=0&&g<f?o[g]:-1;if(w<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[y]}" at ${y}`);if(y+1>=s)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Truncated symbol pair at ${y+1}`);let C=e.charCodeAt(y+1)-i,S=C>=0&&C<f?o[C]:-1;if(S<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[y+1]}" at ${y+1}`);let D=w*n+S;if(D>=p)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Value ${D} exceeds range at position ${y}`);for(h=h<<t|D,m+=t,y+2>=s&&r>0&&(h>>=r,m-=r);m>=8;)m-=8,u[l++]=h>>m&255,h&=(1<<m)-1;}return u.subarray(0,l)}chunkBCUBYE76_cjs.a(pr,"unpackNonPow2FromString");function mr(e,r,t,n,o){if(e.length===0)return "";let i=o.canUseNativeBase64?Me(e):null,s,c;if(i)s=i.paddingBits,c=i.payload;else if(o.bitPackConfig.usePowerOfTwo){let u=lr(e,o.bitPackConfig.bitLength,o.dduCharCodes);s=u.paddingBits,c=u.payload;}else {let u=fr(e,o.bitPackConfig.bitLength,o.bitPackConfig.charsetSize,o.dduCharCodes);s=u.paddingBits,c=u.payload;}let d=cr({paddingBits:s,compressionAlgorithm:r,isEncrypted:t,paddingChar:o.paddingChar,useRepeatPadding:o.useRepeatPadding,bitsPerPadChar:o.bitsPerPadChar,pipelineVersion:o.encryptedPipelineVersion,omitFooter:n?.omitFooter});return c+d}chunkBCUBYE76_cjs.a(mr,"encodePayload");function yr(e,r,t){if(e.length===0)return new Uint8Array(0);let o=t.canUseNativeBase64?Ke(e,r,i=>N(t.dduCharCodeLookup,i,t.dduCharCodeLookupOffset)>=0):null;return o||(t.bitPackConfig.usePowerOfTwo?hr(e,r,t.bitPackConfig.bitLength,t.dduCharCodeLookup,t.dduCharCodeLookupOffset):pr(e,r,t.bitPackConfig.bitLength,t.bitPackConfig.charsetSize,t.dduCharCodeLookup,t.dduCharCodeLookupOffset))}chunkBCUBYE76_cjs.a(yr,"decodePayload");function gr(e,r){let t=new Set(e);t.add(r);let n=z+F+"ENC"+"V3"+"V4";for(let o of n)t.add(o);for(let o of "0123456789")t.add(o);return [...t]}chunkBCUBYE76_cjs.a(gr,"buildObfuscationAlphabet");function k(e,r="construct"){if(e===void 0)return;if(typeof e!="object"||e===null||Array.isArray(e))throw new chunkZTGECGM2_cjs.k("[Ddu64 options] Options must be an object.",r);let t=e;E(e.compress,"compress",r),E(t.encrypt,"encrypt",r),E(e.checksum,"checksum",r),E(t.omitFooter,"omitFooter",r),E(e.obfuscate,"obfuscate",r),E(e.requireEncryption,"requireEncryption",r),e.compressionLevel!==void 0&&(typeof e.compressionLevel!="number"||!Number.isFinite(e.compressionLevel))&&A(r,"compressionLevel must be a finite number"),e.onProgress!==void 0&&typeof e.onProgress!="function"&&A(r,"onProgress must be a function"),e.compressionAlgorithm!==void 0&&e.compressionAlgorithm!=="deflate"&&e.compressionAlgorithm!=="brotli"&&A(r,`compressionAlgorithm must be "deflate" or "brotli", got ${String(e.compressionAlgorithm)}`),e.checksumScope!==void 0&&e.checksumScope!=="plaintext"&&e.checksumScope!=="output"&&A(r,`checksumScope must be "plaintext" or "output", got ${String(e.checksumScope)}`),e.chunkSize!==void 0&&(!Number.isSafeInteger(e.chunkSize)||e.chunkSize<0)&&A(r,"chunkSize must be a non-negative safe integer (0 disables chunking)"),e.chunkSeparator!==void 0&&typeof e.chunkSeparator!="string"&&A(r,"chunkSeparator must be a string"),e.chunkSize!==void 0&&e.chunkSize>0&&e.chunkSeparator===""&&A(r,"chunkSeparator must not be empty when chunkSize is enabled"),V(e.maxDecodedBytes,"maxDecodedBytes",r),V(e.maxEncodedChars,"maxEncodedChars",r),V(e.maxDecompressedBytes,"maxDecompressedBytes",r),"maxBufferedBytes"in e&&V(e.maxBufferedBytes,"maxBufferedBytes",r),"maxBufferedChars"in e&&V(e.maxBufferedChars,"maxBufferedChars",r);let n=e;E(n.throwOnError,"throwOnError",r),E(n.urlSafe,"urlSafe",r),E(n.useRepeatPadding,"useRepeatPadding",r),E(n.usePowerOfTwo,"usePowerOfTwo",r),n.encryptionKey!==void 0&&(typeof n.encryptionKey!="string"||n.encryptionKey.length===0)&&A(r,"encryptionKey must be a non-empty string"),n.dduChar!==void 0&&typeof n.dduChar!="string"&&!(Array.isArray(n.dduChar)&&n.dduChar.every(i=>typeof i=="string"))&&A(r,"dduChar must be a string or string array"),n.paddingChar!==void 0&&typeof n.paddingChar!="string"&&A(r,"paddingChar must be a string"),n.codaChar!==void 0&&!(Array.isArray(n.codaChar)&&n.codaChar.every(i=>typeof i=="string"))&&A(r,"codaChar must be a string array"),n.requiredLength!==void 0&&(!Number.isSafeInteger(n.requiredLength)||n.requiredLength<=0)&&A(r,"requiredLength must be a positive safe integer"),n.adapter!==void 0&&(typeof n.adapter!="object"||n.adapter===null)&&A(r,"adapter must be an object");let o="keyDerivation"in e?e.keyDerivation:void 0;o!==void 0&&((typeof o!="object"||o===null)&&A(r,"keyDerivation must be an object"),o.algorithm!==void 0&&o.algorithm!=="sha256"&&o.algorithm!=="pbkdf2"&&A(r,`keyDerivation.algorithm must be "sha256" or "pbkdf2", got ${String(o.algorithm)}`),o.hash!==void 0&&o.hash!=="SHA-256"&&o.hash!=="SHA-384"&&o.hash!=="SHA-512"&&A(r,`Unsupported PBKDF2 hash: ${String(o.hash)}`),o.iterations!==void 0&&(!Number.isFinite(o.iterations)||o.iterations<=0)&&A(r,"keyDerivation.iterations must be a positive finite number"),o.salt!==void 0&&typeof o.salt!="string"&&!Cr(o.salt)&&A(r,"keyDerivation.salt must be a string or Uint8Array"));}chunkBCUBYE76_cjs.a(k,"validateRuntimeOptions");function H(e,r="encode"){if(typeof e!="string"&&!Cr(e))throw new chunkZTGECGM2_cjs.k("[Ddu64 input] Encode input must be a string or Uint8Array.",r)}chunkBCUBYE76_cjs.a(H,"validateEncodeInput");function q(e,r="decode"){if(typeof e!="string")throw new chunkZTGECGM2_cjs.k("[Ddu64 input] Decode input must be a string.",r)}chunkBCUBYE76_cjs.a(q,"validateDecodeInput");function Cr(e){return ArrayBuffer.isView(e)&&Object.prototype.toString.call(e)==="[object Uint8Array]"}chunkBCUBYE76_cjs.a(Cr,"isUint8Array");function E(e,r,t){e!==void 0&&typeof e!="boolean"&&A(t,`${r} must be a boolean`);}chunkBCUBYE76_cjs.a(E,"validateBoolean");function V(e,r,t){e!==void 0&&e!==Number.POSITIVE_INFINITY&&(!Number.isSafeInteger(e)||e<=0)&&A(t,`${r} must be a positive safe integer or Infinity`);}chunkBCUBYE76_cjs.a(V,"validatePositiveLimit");function A(e,r){throw new chunkZTGECGM2_cjs.k(`[Ddu64 options] Invalid ${r}.`,e)}chunkBCUBYE76_cjs.a(A,"invalid");function br(e,r,t){let n=e.decoded,o=e.extractedChecksumScope??r?.checksumScope??"plaintext";return o==="output"&&Dr(e,t),n=nt(e,t,n),n=ot(e,r,t,n),o==="plaintext"&&Er(e,t,n),n=it(e,t,n),xr(t,n),n}chunkBCUBYE76_cjs.a(br,"runSyncDecodePipeline");async function Ar(e,r,t){let n=e.decoded,o=e.extractedChecksumScope??r?.checksumScope??"plaintext";if(o==="output"&&Dr(e,t),Sr(e,t)&&(v(t,n.length,55,"decrypt"),n=await t.decrypt(n,e.encryptionAAD)),Pr(e)){let i=kr(r,t);v(t,n.length,70,"decompress"),n=await t.decompress(n,e.compressionAlgorithm,i);}return o==="plaintext"&&Er(e,t,n),wr(e,t)&&(v(t,n.length,90,"decrypt"),n=await t.decrypt(n,e.encryptionAAD)),xr(t,n),n}chunkBCUBYE76_cjs.a(Ar,"runAsyncDecodePipeline");function nt(e,r,t){return Sr(e,r)?(v(r,t.length,55,"decrypt"),r.decrypt(t,e.encryptionAAD)):t}chunkBCUBYE76_cjs.a(nt,"runPreDecompressDecrypt");function ot(e,r,t,n){if(!Pr(e))return n;let o=kr(r,t);return v(t,n.length,70,"decompress"),t.decompress(n,e.compressionAlgorithm,o)}chunkBCUBYE76_cjs.a(ot,"runDecompress");function it(e,r,t){return wr(e,r)?(v(r,t.length,90,"decrypt"),r.decrypt(t,e.encryptionAAD)):t}chunkBCUBYE76_cjs.a(it,"runPostChecksumDecrypt");function Sr(e,r){return (e.pipelineVersion===3||e.pipelineVersion===4)&&e.isEncrypted&&!!r.encryptionKey&&e.allowInternalDecrypt}chunkBCUBYE76_cjs.a(Sr,"shouldRunPreDecompressDecrypt");function wr(e,r){return e.pipelineVersion===2&&e.isEncrypted&&!!r.encryptionKey&&e.allowInternalDecrypt}chunkBCUBYE76_cjs.a(wr,"shouldRunPostChecksumDecrypt");function Pr(e){return !!e.compressionAlgorithm&&e.allowInternalDecompress&&(e.pipelineVersion===2||!e.isEncrypted||e.allowInternalDecrypt)}chunkBCUBYE76_cjs.a(Pr,"shouldDecompress");function Dr(e,r){if(!e.extractedChecksum)return;v(r,e.decoded.length,85,"checksum");let t=U(e.decoded);if(!ce(t,e.extractedChecksum))throw new chunkZTGECGM2_cjs.i(`[Ddu64 decode] Checksum mismatch. Expected: ${e.extractedChecksum}, Got: ${t}`)}chunkBCUBYE76_cjs.a(Dr,"verifyWireChecksum");function Er(e,r,t){if(!e.extractedChecksum||!(e.pipelineVersion===2||!e.isEncrypted||e.allowInternalDecrypt))return;v(r,t.length,85,"checksum");let n=U(t);if(!ce(n,e.extractedChecksum))throw new chunkZTGECGM2_cjs.i(`[Ddu64 decode] Checksum mismatch. Expected: ${e.extractedChecksum}, Got: ${n}`)}chunkBCUBYE76_cjs.a(Er,"verifyDecodedChecksum");function kr(e,r){return x(e?.maxDecompressedBytes,r.defaultMaxDecompressedBytes,true,"maxDecompressedBytes")}chunkBCUBYE76_cjs.a(kr,"getMaxDecompressedBytes");function v(e,r,t,n){e.reportProgress({processedBytes:r,totalBytes:r,percent:t,stage:n});}chunkBCUBYE76_cjs.a(v,"reportStage");function xr(e,r){v(e,r.length,100,"done");}chunkBCUBYE76_cjs.a(xr,"reportDone");function me(e,r,t){let n=Ur(r,t),o=typeof e=="string"?K(e):e;Br(t,o.length);let i="";n.shouldChecksum&&n.checksumScope==="plaintext"&&(i=U(o));let s,c;if(n.shouldCompress){let{algo:u,level:l}=vr(r,t);Or(t,o.length);let p=t.compress(o,u,l);p.length<o.length&&(c=p.length,o=p,s=u);}let d=false;return n.shouldEncrypt&&(Rr(t,o.length),o=t.encrypt(o,t.getEncryptionAAD(s)),d=true),n.shouldChecksum&&n.checksumScope==="output"&&(i=U(o)),{encoded:t.finalize(o,s,d,i,n.shouldChecksum,n.checksumScope,n.chunkSize,n.chunkSeparator),compressedSize:c}}chunkBCUBYE76_cjs.a(me,"runSyncEncodePipeline");async function ye(e,r,t){let n=Ur(r,t),o=typeof e=="string"?K(e):e;Br(t,o.length);let i="";n.shouldChecksum&&n.checksumScope==="plaintext"&&(i=U(o));let s,c;if(n.shouldCompress){let{algo:u,level:l}=vr(r,t);Or(t,o.length);let p=await t.compress(o,u,l);p.length<o.length&&(c=p.length,o=p,s=u);}let d=false;return n.shouldEncrypt&&(Rr(t,o.length),o=await t.encrypt(o,t.getEncryptionAAD(s)),d=true),n.shouldChecksum&&n.checksumScope==="output"&&(i=U(o)),{encoded:t.finalize(o,s,d,i,n.shouldChecksum,n.checksumScope,n.chunkSize,n.chunkSeparator),compressedSize:c}}chunkBCUBYE76_cjs.a(ye,"runAsyncEncodePipeline");function vr(e,r){let t=e?.compressionAlgorithm??r.defaultCompressionAlgorithm,n=X(e?.compressionLevel??r.defaultCompressionLevel,t);return {algo:t,level:n}}chunkBCUBYE76_cjs.a(vr,"resolveCompressionParams");function Ur(e,r){return {shouldCompress:e?.compress??r.defaultCompress,shouldChecksum:e?.checksum??r.defaultChecksum,checksumScope:e?.checksumScope??r.defaultChecksumScope,shouldEncrypt:(e?.encrypt??true)&&r.hasEncryptionKey,chunkSize:e?.chunkSize??r.defaultChunkSize,chunkSeparator:e?.chunkSeparator??r.defaultChunkSeparator}}chunkBCUBYE76_cjs.a(Ur,"resolveEncodeSettings");function Br(e,r){e.reportProgress({processedBytes:0,totalBytes:r,percent:0,stage:"start"});}chunkBCUBYE76_cjs.a(Br,"reportStart");function Or(e,r){e.reportProgress({processedBytes:r,totalBytes:r,percent:20,stage:"compress"});}chunkBCUBYE76_cjs.a(Or,"reportCompress");function Rr(e,r){e.reportProgress({processedBytes:r,totalBytes:r,percent:45,stage:"encrypt"});}chunkBCUBYE76_cjs.a(Rr,"reportEncrypt");var at=64*1024*1024,st=64*1024*1024,dt=256*1024*1024,Ir=28,Lr=class{static{chunkBCUBYE76_cjs.a(this,"Ddu64Core");}dduChar;dduCharCodes;paddingChar;bitLength;usePowerOfTwo;dduCharCodeLookup;dduCharCodeLookupOffset;defaultCompress;defaultMaxDecodedBytes;defaultMaxEncodedChars;defaultMaxDecompressedBytes;urlSafe;encryptionKey;keyDerivation;encryptionKeyHash;syncGatewayContext;defaultChecksum;defaultChecksumScope;defaultChunkSize;defaultChunkSeparator;defaultCompressionLevel;defaultCompressionAlgorithm;useRepeatPadding;bitsPerPadChar;bitPackConfig;canUseNativeBase64;payloadCodecContext;adapter;adapterFactory;obfuscationLayerFactory;defaultObfuscate;defaultOnProgress;defaultRequireEncryption;obfuscationLayer;constructor(r,t,n){let o=Xe(r,t,n);r=o.dduChar,t=o.paddingChar,n=o.dduOptions,k(n);let i=n?.throwOnError??true;this.adapter=n?.adapter,this.adapterFactory=n?.adapterFactory,this.obfuscationLayerFactory=n?.obfuscationLayerFactory;let s,c;try{s=Re(r,t,n,i),c=Ie(s,i,n);}catch(y){throw chunkZTGECGM2_cjs.p(y)?y:new chunkZTGECGM2_cjs.j(chunkZTGECGM2_cjs.q(y),y)}this.dduChar=c.charSet,this.paddingChar=c.padding;let d=c.isPredefined;this.defaultCompress=n?.compress??false,this.defaultMaxDecodedBytes=x(n?.maxDecodedBytes,at,i,"maxDecodedBytes"),this.defaultMaxDecompressedBytes=x(n?.maxDecompressedBytes,st,i,"maxDecompressedBytes"),this.defaultMaxEncodedChars=x(n?.maxEncodedChars,this.defaultMaxDecodedBytes===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(dt,this.defaultMaxDecodedBytes*4),i,"maxEncodedChars");let u=this.dduChar.length,l=we(u),p=n?.usePowerOfTwo,f=s.encodingProfile;this.usePowerOfTwo=f?.usePowerOfTwo??s.usePowerOfTwo??(p!==void 0?p&&l:l);let h=f?.bitLength??(s.isPredefined&&s.usePowerOfTwo!==void 0?s.bitLength:void 0);this.bitLength=h??Se(u,this.usePowerOfTwo);let m=Ze(this.dduChar,d);this.dduCharCodeLookup=m.charCodeLookup,this.dduCharCodeLookupOffset=m.lookupOffset,this.dduCharCodes=m.charCodes,this.urlSafe=ct(this.dduChar,this.paddingChar,n?.urlSafe??false,i),this.encryptionKey=n?.encryptionKey,this.keyDerivation=n?.keyDerivation,this.defaultChecksum=n?.checksum??false,this.defaultChecksumScope=n?.checksumScope??"output",this.defaultChunkSize=n?.chunkSize,this.defaultChunkSeparator=n?.chunkSeparator??`
|
|
7
|
-
`,this.defaultCompressionAlgorithm=n?.compressionAlgorithm??"deflate",this.defaultCompressionLevel=X(n?.compressionLevel,this.defaultCompressionAlgorithm),this.useRepeatPadding=n?.useRepeatPadding??s.useRepeatPadding??false,this.bitsPerPadChar=f?.bitsPerPadChar??s.bitsPerPadChar??2,this.defaultObfuscate=n?.obfuscate??false,this.defaultOnProgress=n?.onProgress,this.defaultRequireEncryption=n?.requireEncryption??this.encryptionKey!==void 0,this.bitPackConfig={bitLength:this.bitLength,usePowerOfTwo:this.usePowerOfTwo,charsetSize:u},this.canUseNativeBase64=Te(this.dduChar,this.paddingChar,this.usePowerOfTwo,this.bitLength),this.payloadCodecContext={bitPackConfig:this.bitPackConfig,canUseNativeBase64:this.canUseNativeBase64,dduCharCodes:this.dduCharCodes,dduCharCodeLookup:this.dduCharCodeLookup,dduCharCodeLookupOffset:this.dduCharCodeLookupOffset,paddingChar:this.paddingChar,useRepeatPadding:this.useRepeatPadding,bitsPerPadChar:this.bitsPerPadChar,encryptedPipelineVersion:4};}encode(r,t){try{return k(t,"encode"),H(r),this.encodeInternal(r,t).encoded}catch(n){throw chunkZTGECGM2_cjs.r(n,"encode")}}decode(r,t){try{k(t,"decode"),q(r);let n=this.decodeToUint8Array(r,t);return ue(n)}catch(n){throw chunkZTGECGM2_cjs.r(n,"decode")}}decodeToUint8Array(r,t){try{return k(t,"decode"),q(r),this.decodeToUint8ArrayInternal(r,t)}catch(n){throw chunkZTGECGM2_cjs.r(n,"decode")}}decodeToUint8ArrayInternal(r,t){let n=this.decodePrelude(r,t);return br(n,t,{...this.buildDecodeBaseContext(t),decrypt:chunkBCUBYE76_cjs.a((o,i)=>He(this.getSyncGatewayContext(),o,i),"decrypt"),decompress:chunkBCUBYE76_cjs.a((o,i,s)=>qe(this.getAdapter(),o,i,s),"decompress")})}async encodeAsync(r,t){try{return k(t,"encode"),H(r),await this.encodeAsyncInternal(r,t)}catch(n){throw chunkZTGECGM2_cjs.r(n,"encode")}}async encodeAsyncInternal(r,t){return (await ye(r,t,{...this.buildEncodeBaseContext(t),compress:chunkBCUBYE76_cjs.a((o,i,s)=>fe(this.getAdapter(),o,i,s),"compress"),encrypt:chunkBCUBYE76_cjs.a((o,i)=>Ge(this.getSyncGatewayContext(),o,i),"encrypt")})).encoded}async decodeAsync(r,t){try{k(t,"decode"),q(r);let n=await this.decodeToUint8ArrayAsync(r,t);return ue(n)}catch(n){throw chunkZTGECGM2_cjs.r(n,"decode")}}async decodeToUint8ArrayAsync(r,t){try{return k(t,"decode"),q(r),await this.decodeToUint8ArrayAsyncInternal(r,t)}catch(n){throw chunkZTGECGM2_cjs.r(n,"decode")}}async decodeToUint8ArrayAsyncInternal(r,t){let n=this.decodePrelude(r,t);return Ar(n,t,{...this.buildDecodeBaseContext(t),decrypt:chunkBCUBYE76_cjs.a((o,i)=>je(this.getSyncGatewayContext(),o,i),"decrypt"),decompress:chunkBCUBYE76_cjs.a((o,i,s)=>We(this.getAdapter(),o,i,s),"decompress")})}buildDecodeBaseContext(r){return {encryptionKey:this.encryptionKey,defaultMaxDecompressedBytes:this.defaultMaxDecompressedBytes,reportProgress:chunkBCUBYE76_cjs.a(t=>this.reportProgress(r,t),"reportProgress")}}getCharSetInfo(){return {charSet:[...this.dduChar],paddingChar:this.paddingChar,bitLength:this.bitLength,usePowerOfTwo:this.usePowerOfTwo,encoding:"utf-8",defaultCompress:this.defaultCompress,defaultMaxDecodedBytes:this.defaultMaxDecodedBytes,defaultMaxDecompressedBytes:this.defaultMaxDecompressedBytes,urlSafe:this.urlSafe,hasEncryptionKey:!!this.encryptionKey,defaultChecksum:this.defaultChecksum,defaultChecksumScope:this.defaultChecksumScope,defaultObfuscate:this.defaultObfuscate,defaultRequireEncryption:this.defaultRequireEncryption,defaultChunkSize:this.defaultChunkSize,defaultChunkSeparator:this.defaultChunkSeparator,defaultCompressionLevel:this.defaultCompressionLevel,defaultCompressionAlgorithm:this.defaultCompressionAlgorithm}}getStats(r,t){k(t,"encode"),H(r);let n=typeof r=="string"?K(r):r,{encoded:o,compressedSize:i}=this.encodeStatsInternal(n,t);return this.buildEncodeStats(n.length,o.length,i,t)}async getStatsAsync(r,t){k(t,"encode"),H(r);let n=typeof r=="string"?K(r):r,{encoded:o,compressedSize:i}=await this.encodeStatsAsyncInternal(n,t);return this.buildEncodeStats(n.length,o.length,i,t)}buildEncodeStats(r,t,n,o){let i=r>0?t/r:0,c=(o?.compress??this.defaultCompress)&&n!==void 0&&r>0?n/r:void 0;return {originalSize:r,encodedSize:t,compressedSize:n,compressionRatio:c,expansionRatio:i,charsetSize:this.dduChar.length,bitLength:this.bitLength}}encodeInternal(r,t){return me(r,t,{...this.buildEncodeBaseContext(t),compress:chunkBCUBYE76_cjs.a((n,o,i)=>he(this.getAdapter(),n,o,i),"compress"),encrypt:chunkBCUBYE76_cjs.a((n,o)=>Ve(this.getSyncGatewayContext(),n,o),"encrypt")})}encodeStatsInternal(r,t){return me(r,t,{...this.buildEncodeBaseContext(t),compress:chunkBCUBYE76_cjs.a((n,o,i)=>he(this.getAdapter(),n,o,i),"compress"),encrypt:chunkBCUBYE76_cjs.a(n=>new Uint8Array(n.length+Ir),"encrypt")})}async encodeStatsAsyncInternal(r,t){return ye(r,t,{...this.buildEncodeBaseContext(t),compress:chunkBCUBYE76_cjs.a((n,o,i)=>fe(this.getAdapter(),n,o,i),"compress"),encrypt:chunkBCUBYE76_cjs.a(async n=>new Uint8Array(n.length+Ir),"encrypt")})}buildEncodeBaseContext(r){return {defaultCompress:this.defaultCompress,defaultChecksum:this.defaultChecksum,defaultChecksumScope:this.defaultChecksumScope,defaultChunkSize:this.defaultChunkSize,defaultChunkSeparator:this.defaultChunkSeparator,defaultCompressionLevel:this.defaultCompressionLevel,defaultCompressionAlgorithm:this.defaultCompressionAlgorithm,hasEncryptionKey:!!this.encryptionKey,reportProgress:chunkBCUBYE76_cjs.a(t=>this.reportProgress(r,t),"reportProgress"),getEncryptionAAD:chunkBCUBYE76_cjs.a(t=>te({compressionAlgorithm:t}),"getEncryptionAAD"),finalize:chunkBCUBYE76_cjs.a((t,n,o,i,s,c,d,u)=>this.finalizeEncode(t,n,o,i,s,c,d,u,r),"finalize")}}finalizeEncode(r,t,n,o,i,s,c,d,u){this.reportProgress(u,{processedBytes:r.length,totalBytes:r.length,percent:70,stage:"encode"});let l=mr(r,t,n,u,this.getPayloadCodecContext());return l=this.applyPostEncoding(l,u,o,i,s,c,d),this.reportProgress(u,{processedBytes:r.length,totalBytes:r.length,percent:100,stage:"done"}),l}applyPostEncoding(r,t,n,o,i,s,c){return ur({encoded:r,options:t,checksum:n,shouldChecksum:o,checksumScope:i,chunkSize:s,chunkSeparator:c,urlSafe:this.urlSafe,shouldObfuscate:chunkBCUBYE76_cjs.a(d=>this.shouldObfuscate(d),"shouldObfuscate"),getObfuscationLayer:chunkBCUBYE76_cjs.a(()=>this.getObfuscationLayer(),"getObfuscationLayer"),assertSafeChunkSeparator:chunkBCUBYE76_cjs.a((d,u)=>this.assertSafeChunkSeparator(d,u),"assertSafeChunkSeparator")})}decodePrelude(r,t){return dr(r,t,{defaultChecksum:this.defaultChecksum,defaultChunkSeparator:this.defaultChunkSeparator,defaultMaxDecodedBytes:this.defaultMaxDecodedBytes,defaultMaxEncodedChars:this.defaultMaxEncodedChars,urlSafe:this.urlSafe,paddingChar:this.paddingChar,bitLength:this.bitLength,bitsPerPadChar:this.bitsPerPadChar,usePowerOfTwo:this.usePowerOfTwo,dduCharCodeLookup:this.dduCharCodeLookup,dduCharCodeLookupOffset:this.dduCharCodeLookupOffset,charSetSize:this.dduChar.length,encryptionKey:this.encryptionKey,defaultRequireEncryption:this.defaultRequireEncryption,shouldObfuscate:chunkBCUBYE76_cjs.a(n=>this.shouldObfuscate(n),"shouldObfuscate"),deobfuscate:chunkBCUBYE76_cjs.a(n=>this.getObfuscationLayer().deobfuscate(n),"deobfuscate"),decodeChars:chunkBCUBYE76_cjs.a((n,o)=>yr(n,o,this.getPayloadCodecContext()),"decodeChars"),reportDecodeStart:chunkBCUBYE76_cjs.a(n=>{this.reportProgress(t,{processedBytes:0,totalBytes:n,percent:0,stage:"start"});},"reportDecodeStart"),reportBitpackDecode:chunkBCUBYE76_cjs.a((n,o)=>{this.reportProgress(t,{processedBytes:n,totalBytes:o,percent:30,stage:"decode"});},"reportBitpackDecode")})}getPayloadCodecContext(){return this.payloadCodecContext}reportProgress(r,t){(r?.onProgress??this.defaultOnProgress)?.(t);}getAdapter(){return this.adapter===void 0&&this.adapterFactory!==void 0&&(this.adapter=this.adapterFactory()),this.adapter}getSyncGatewayContext(){if(!this.syncGatewayContext){let r={adapter:this.getAdapter(),encryptionKey:this.encryptionKey,keyDerivation:this.keyDerivation,encryptionKeyHash:this.encryptionKeyHash,setEncryptionKeyHash:chunkBCUBYE76_cjs.a(t=>{this.encryptionKeyHash=t,r.encryptionKeyHash=t;},"setEncryptionKeyHash")};this.syncGatewayContext=r;}return this.syncGatewayContext}getObfuscationLayer(){if(!this.obfuscationLayer){if(!this.obfuscationLayerFactory)throw new chunkZTGECGM2_cjs.n("[Ddu64 obfuscation] No obfuscation layer is wired. Use Ddu64Node/Ddu64Browser (batteries-included), or inject `obfuscationLayerFactory` when constructing Ddu64Core directly.");this.obfuscationLayer=this.obfuscationLayerFactory(gr(this.dduChar,this.paddingChar));}return this.obfuscationLayer}shouldObfuscate(r){return r?.obfuscate??this.defaultObfuscate}assertSafeChunkSeparator(r,t){if(!(t.length===0||this.isLineBreakSeparator(t))&&r.includes(t))throw new chunkZTGECGM2_cjs.c(`[Ddu64 chunking] Unsafe chunkSeparator "${t}" appears in encoded output. Use a separator that cannot be produced by the charset, footer, checksum, or URL-safe output.`)}isLineBreakSeparator(r){return r===`
|
|
8
|
-
`||r===`\r
|
|
9
|
-
`||r==="\r"}};function ct(e,r,t,n){try{return t?Le(e,r,n):!1}catch(o){throw chunkZTGECGM2_cjs.p(o)?o:new chunkZTGECGM2_cjs.j(chunkZTGECGM2_cjs.q(o),o)}}chunkBCUBYE76_cjs.a(ct,"validateFinalCharsetConfiguration");var Tr=class e{static{chunkBCUBYE76_cjs.a(this,"CharsetBuilder");}chars=[];constructor(){}static create(){return new e}static fromUnicodeRange(r,t){return new e().addUnicodeRange(r,t)}static fromString(r){return new e().addString(r)}static base64(){return new e().addString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")}static base32(){return new e().addString("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")}static uppercase(){return e.fromUnicodeRange(65,90)}static lowercase(){return e.fromUnicodeRange(97,122)}static digits(){return e.fromUnicodeRange(48,57)}static hangulJamo(){return new e().addUnicodeRange(4352,4370).addUnicodeRange(4449,4469).addUnicodeRange(4520,4546)}addUnicodeRange(r,t){if(!Number.isInteger(r)||!Number.isInteger(t)||r<0||t>1114111||r>t)throw new RangeError("Unicode range must use integer code points with 0 <= start <= end <= 0x10FFFF");for(let n=r;n<=t;n++)this.chars.push(String.fromCodePoint(n));return this}addString(r){return typeof r=="string"?this.chars.push(...r):this.chars.push(...r),this}add(...r){return this.chars.push(...r),this}excludeConfusing(){let r=new Set(["0","O","o","1","l","I","i","|","L"]);return this.chars=this.chars.filter(t=>!r.has(t)),this}exclude(...r){let t=new Set(r);return this.chars=this.chars.filter(n=>!t.has(n)),this}excludeUrlUnsafe(){let r=new Set(["+","/","=","?","&","#","%"," "]);return this.chars=this.chars.filter(t=>!r.has(t)),this}unique(){return this.chars=[...new Set(this.chars)],this}shuffle(r){let t=r!==void 0?this.seededRandom(r):Math.random;for(let n=this.chars.length-1;n>0;n--){let o=Math.floor(t()*(n+1));[this.chars[n],this.chars[o]]=[this.chars[o],this.chars[n]];}return this}seededRandom(r){let t=r|0||1;return ()=>(t^=t<<13,t^=t>>17,t^=t<<5,(t>>>0)/4294967296)}limit(r){if(!Number.isSafeInteger(r)||r<0)throw new RangeError("Charset limit must be a non-negative safe integer");return this.chars=this.chars.slice(0,r),this}limitToPowerOfTwo(){let r=this.chars.length;if(r===0)return this;let t=1<<Math.floor(Math.log2(r));return this.chars=this.chars.slice(0,t),this}sort(){return this.chars.sort(),this}reverse(){return this.chars.reverse(),this}get length(){return this.chars.length}buildString(){return this.chars.join("")}build(){return [...this.chars]}buildWithPadding(r){let t=[...this.chars],n=r;if(!n){let o=["=",".","_","-","~","!"];for(let i of o)if(!t.includes(i)){n=i;break}if(!n)throw new Error("Cannot find suitable padding character")}if(n.length!==1)throw new Error("Padding character must be one UTF-16 code unit");if(t.includes(n))throw new Error("Padding character must not appear in charset");return {charset:t,padding:n}}};exports.a=Ae;exports.b=Xe;exports.c=x;exports.d=Zr;exports.e=$t;exports.f=Vt;exports.g=gr;exports.h=k;exports.i=Lr;exports.j=Tr;
|
package/dist/chunk-LCOYWJWO.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkBDP7E7K3_cjs=require('./chunk-BDP7E7K3.cjs'),chunkJBUTKSCC_cjs=require('./chunk-JBUTKSCC.cjs'),chunkHUUB5BUS_cjs=require('./chunk-HUUB5BUS.cjs'),chunkZTGECGM2_cjs=require('./chunk-ZTGECGM2.cjs'),chunkBCUBYE76_cjs=require('./chunk-BCUBYE76.cjs');var T=class extends chunkJBUTKSCC_cjs.i{static{chunkBCUBYE76_cjs.a(this,"Ddu64SecureBrowser");}constructor(e,t,i){let n=chunkJBUTKSCC_cjs.b(e,t,i),y={...n.dduOptions,...n.dduChar!==void 0?{dduChar:n.dduChar}:{},...n.paddingChar!==void 0?{paddingChar:n.paddingChar}:{},adapter:n.dduOptions?.adapter,adapterFactory:n.dduOptions?.adapterFactory??(()=>new chunkHUUB5BUS_cjs.a),obfuscationLayerFactory:n.dduOptions?.obfuscationLayerFactory??(g=>new chunkBDP7E7K3_cjs.a(g))};super(y);}};var H=64*1024*1024,W=64*1024*1024;function N(r,e){chunkJBUTKSCC_cjs.h(e,"stream");let t=r.getCharSetInfo(),i=e?.compress??t.defaultCompress,n=t.hasEncryptionKey,y=e?.checksum??t.defaultChecksum,g=i?e?.compressionAlgorithm??t.defaultCompressionAlgorithm:void 0,s=t.paddingChar,S=chunkJBUTKSCC_cjs.c(e?.maxBufferedBytes,H,true,"maxBufferedBytes"),l=M(t,{compressed:i,encrypted:n,checksum:y}),f=false,u=[],m=0,o=null;return new TransformStream({async transform(a,d){if(l){if(!f){let D=chunkJBUTKSCC_cjs.e(s,{compressionAlgorithm:void 0,encrypted:false});d.enqueue(D),f=true;}let c;o&&o.length>0?(c=new Uint8Array(o.length+a.length),c.set(o,0),c.set(a,o.length)):c=a;let A=t.bitLength,C=R(A,8)/8,p=Math.floor(c.length/C)*C;if(p>0){let D=c.subarray(0,p),q=await r.encodeAsync(D,{compress:false,encrypt:false,checksum:false,chunkSize:0,chunkSeparator:void 0,omitFooter:true});d.enqueue(q);}p<c.length?o=c.slice(p):o=null;}else {if(m+a.length>S){d.error(new chunkZTGECGM2_cjs.l(`[WebStreams encode] Buffered input exceeds limit. Limit: ${S} bytes`,"stream"));return}u.push(a),m+=a.length;}},async flush(a){try{if(l){if(!f){let d=chunkJBUTKSCC_cjs.e(s,{compressionAlgorithm:void 0,encrypted:!1});a.enqueue(d);}if(o&&o.length>0){let d=await r.encodeAsync(o,{compress:!1,encrypt:!1,checksum:!1,chunkSize:0,chunkSeparator:void 0});a.enqueue(d);}o=null;}else {let d=chunkJBUTKSCC_cjs.e(s,{compressionAlgorithm:g,encrypted:n});a.enqueue(d);let c=new Uint8Array(m),A=0;for(let p of u)c.set(p,A),A+=p.length;let C=await r.encodeAsync(c,{...e,compress:i,encrypt:n,checksum:y,chunkSize:0,chunkSeparator:void 0});C.length>0&&a.enqueue(C),u=[],m=0;}}catch(d){a.error(chunkZTGECGM2_cjs.r(d,"stream"));}}})}chunkBCUBYE76_cjs.a(N,"createReadableEncodeStream");function Q(r,e){chunkJBUTKSCC_cjs.h(e,"stream");let t=r.getCharSetInfo(),i=t.paddingChar,n=chunkJBUTKSCC_cjs.d(i),y=e?.checksum??t.defaultChecksum,g=chunkJBUTKSCC_cjs.c(e?.maxBufferedChars,W,true,"maxBufferedChars"),s="",S=false,l=null;return new TransformStream({async transform(f,u){try{if(s+=f,s.length>g)throw new chunkZTGECGM2_cjs.l(`[WebStreams decode] Buffered encoded input exceeds limit. Limit: ${g} characters`,"stream");if(!S&&s.length>=n){if(!s.startsWith(i))throw new Error("[WebStreams decode] Invalid or missing stream header");if(l=chunkJBUTKSCC_cjs.f(s,i),l===null)throw new Error("[WebStreams decode] Invalid or missing stream header");if(l.encrypted&&!t.hasEncryptionKey)throw new Error("[WebStreams decode] Encrypted stream requires an encryptionKey");S=!0,s=s.slice(n);}}catch(m){u.error(chunkZTGECGM2_cjs.r(m,"stream"));}},async flush(f){try{if(!S){if(s.length===0)return;throw new Error("[WebStreams decode] Incomplete stream header")}let u=l.compressionAlgorithm,m=await r.decodeToUint8ArrayAsync(s,{...e,compress:e?.compress,compressionAlgorithm:u,checksum:y,chunkSize:void 0,chunkSeparator:void 0});m.length>0&&f.enqueue(m),s="";}catch(u){f.error(chunkZTGECGM2_cjs.r(u,"stream"));}}})}chunkBCUBYE76_cjs.a(Q,"createReadableDecodeStream");function M(r,e){return r.usePowerOfTwo&&!e.compressed&&!e.encrypted&&!e.checksum}chunkBCUBYE76_cjs.a(M,"canUseChunkStreaming");function R(r,e){return r*e/_(r,e)}chunkBCUBYE76_cjs.a(R,"lcm");function _(r,e){for(;e!==0;){let t=e;e=r%e,r=t;}return r}chunkBCUBYE76_cjs.a(_,"gcd");exports.a=T;exports.b=N;exports.c=Q;
|
package/dist/chunk-VW2SZR2Z.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import {j,p,q as q$1,r,n,c,m,g,h,e,f,k as k$1,d,l,i}from'./chunk-IZK7KCU7.js';import {a}from'./chunk-EI7MMDWY.js';var Ae=(n=>(n.DDU="ddu",n.DDU_V1="ddu_v1",n.ONECHARSET="oneCharSet",n))(Ae||{}),de={dduSetSymbol:"ddu",usePowerOfTwo:true,requiredLength:64};function Se(e,r){return e<=1?0:r?Math.floor(Math.log2(e)):Math.ceil(Math.log2(e))}a(Se,"calculateBitLength");function we(e){return e>0&&(e&e-1)===0}a(we,"isPowerOfTwo");function Pe(e){return e<31?1<<e:Math.pow(2,e)}a(Pe,"maxValueForBitLength");var Mr=(()=>{let e=new Uint32Array(256);for(let r=0;r<256;r++){let t=r;for(let n=0;n<8;n++)t=t>>>1^(t&1?3988292384:0);e[r]=t;}return e})();function U(e){let r=4294967295;for(let t=0;t<e.length;t++)r=r>>>8^Mr[(r^e[t])&255];return ((r^4294967295)>>>0).toString(16).padStart(8,"0")}a(U,"calculateCRC32");function ce(e,r){let t=Math.max(e.length,r.length),n=e.length^r.length;for(let o=0;o<t;o++){let i=o<e.length?e.charCodeAt(o):0,s=o<r.length?r.charCodeAt(o):0;n|=i^s;}return n===0}a(ce,"constantTimeEquals");var De=["-","_","."];function Ee(e){return e.length===0?e:e.replaceAll("+","-").replaceAll("/","_").replaceAll("=",".")}a(Ee,"toUrlSafe");function ke(e){return e.length===0?e:e.replaceAll("-","+").replaceAll("_","/").replaceAll(".","=")}a(ke,"fromUrlSafe");function xe(e,r,t){if(r<=0||e.length<=r)return e;let n=Math.ceil(e.length/r),o=new Array(n*2-1),i=0;for(let s=0;s<e.length;s+=r)o[i++]=e.slice(s,s+r),s+r<e.length&&(o[i++]=t);return o.join("")}a(xe,"splitIntoChunks");function ve(e,r){if(e.length===0)return e;let t=r&&r!==`
|
|
2
|
-
`&&r!==`\r
|
|
3
|
-
`&&r!=="\r"?r:"",n=e.includes(`
|
|
4
|
-
`)||e.includes("\r"),o=t.length>0&&e.includes(t);if(!n&&!o)return e;let i=n?e.replace(/[\r\n]/g,""):e;return o&&(i=i.replaceAll(t,"")),i}a(ve,"removeChunks");var Ue={"":0,\u3131:1,\u3132:2,\u3133:3,\u3134:4,\u3135:5,\u3136:6,\u3137:7,\u3139:8,\u313A:9,\u313B:10,\u313C:11,\u313D:12,\u313E:13,\u313F:14,\u3140:15,\u3141:16,\u3142:17,\u3144:18,\u3145:19,\u3146:20,\u3147:21,\u3148:22,\u314A:23,\u314B:24,\u314C:25,\u314D:26,\u314E:27};function Be(e){return Object.prototype.hasOwnProperty.call(Ue,e)}a(Be,"isKnownCodaChar");function Kr(e,r){let t=e.charCodeAt(0);if(t<44032||t>55203)return e;let n=t-(t-44032)%28,o=Ue[r]??0;return String.fromCharCode(n+o)}a(Kr,"combineCoda");function Y(e,r){let t=new Array(e.length*r.length),n=0;for(let o of e)for(let i of r)t[n++]=Kr(o,i);return t}a(Y,"buildCodaCharset");function X(e,r){let n=e===void 0||!Number.isFinite(e)?6:Math.floor(e);return Math.min(r==="brotli"?11:9,Math.max(0,n))}a(X,"normalizeCompressionLevel");var Nr=new TextEncoder,_r=new TextDecoder;function K(e){return Nr.encode(e)}a(K,"stringToBytes");function ue(e){return _r.decode(e)}a(ue,"bytesToString");var zr={symbol:"ddu",charSet:["\uB70C","\uB568","\uC774","\uC6B0","\uC57C","\uB4C0","\uB31C","\uB3A8"],codaChar:["","\u3131","\u3132","\u3137","\u3148","\u3147","\u3145","\u3146"],maxRequiredLength:64,bitLength:6,paddingChar:"\uBB50",useRepeatPadding:true},Fr={symbol:"ddu_v1",charSet:["\uB70C","\uB568","\uC774","\uC6B0","\uC57C","!","?","."],maxRequiredLength:8,bitLength:6,paddingChar:"\uBB50",useRepeatPadding:true,usePowerOfTwo:false,encodingProfile:{bitLength:6,usePowerOfTwo:false,bitsPerPadChar:2}},$r={symbol:"oneCharSet",charSet:["A","s","q","r","0","z","3","t","y","1","5","2","4","E","B","C","Q","F","R","T","U","W","V","X","Y","Z","b","a","c","d","D","G","L","H","I","-","J","K","M","O","N","f","e","h","g","P","i","S","k","l","m","u","j","v","n","o","p","9","w","6","7","8","x","_"],paddingChar:"=",maxRequiredLength:64,bitLength:6};function J(e){switch(e){case "ddu":return zr;case "ddu_v1":return Fr;case "oneCharSet":return $r;default:return}}a(J,"getCharSet");var Vr=65536;function Re(e,r,t,n){let o=a((i,s,c,d,u)=>{if(Hr(c,t?.usePowerOfTwo)&&c>0){let f=Math.floor(Math.log2(c)),h=1<<f;return {charSet:i.length===h?i:i.slice(0,h),padding:s,requiredLength:h,bitLength:f,isPredefined:d,useRepeatPadding:u}}return {charSet:i.length===c?i:i.slice(0,c),padding:s,requiredLength:c,bitLength:c>0?Math.ceil(Math.log2(c)):0,isPredefined:d,useRepeatPadding:u}},"buildMeta");try{let i=e??t?.dduChar,s=r??t?.paddingChar;if(i){if(!s)throw new Error("[Ddu64 Constructor] paddingChar is required when dduChar is provided.");let f=typeof i=="string"?[...i]:[...i],h=t?.codaChar,m=h?!0:t?.useRepeatPadding??!1;if(h&&h.length>0){if(n){let g=h.filter(w=>!Be(w));if(g.length>0)throw new Error(`[Ddu64 Constructor] Unknown coda character(s): [${g.join(", ")}]. Coda must be empty ("") or a Hangul jongseong jamo (\u3131, \u3132, \u3133, \u2026 \u314E). Unknown coda collapses to no-coda and can create duplicate symbols.`)}f=Y(f,h);}if(n&&new Set(f).size!==f.length){let w=f.filter((C,S)=>f.indexOf(C)!==S);throw new Error(`[Ddu64 Constructor] Character set contains duplicate characters: [${[...new Set(w)].join(", ")}]`)}let y=t?.requiredLength??f.length;if(f.length<y)throw new Error("[Ddu64 Constructor] Insufficient characters.");return o(f,s,y,!1,m)}let c=t?.dduSetSymbol??de.dduSetSymbol??"ddu",d=qr(c),u=d.codaChar?Y(d.charSet,d.codaChar):d.charSet,l=o(u,d.paddingChar,d.maxRequiredLength,!0,d.useRepeatPadding),p=d.encodingProfile;return p?(l.encodingProfile=p,l.bitLength=p.bitLength,l.usePowerOfTwo=p.usePowerOfTwo,l.bitsPerPadChar=p.bitsPerPadChar):(l.bitsPerPadChar=d.bitsPerPadChar,l.usePowerOfTwo=d.usePowerOfTwo,d.usePowerOfTwo===!1&&(l.bitLength=d.bitLength)),l}catch(i){if(n)throw i;return le(t)}}a(Re,"resolveInitialCharSet");function Ie(e,r,t){let n=[e,null];for(let i of n){let s=i?{...i}:le(t);try{let c=s.charSet,d=s.requiredLength,u=Array.from(new Set(c));if(u.length!==c.length){if(r){let f=c.filter((h,m)=>c.indexOf(h)!==m);throw new Error(`[Ddu64 normalizeCharSet] Character set contains duplicate characters: [${[...new Set(f)].join(", ")}]`)}c=u,s.isPredefined||(d=c.length);}if(c.length<d)throw new Error(`[Ddu64 normalizeCharSet] Insufficient characters. Required: ${d}, Has: ${c.length}`);if(d<2)throw new Error("[Ddu64 normalizeCharSet] At least 2 unique characters required.");if(c.length===0)throw new Error("[Ddu64 normalizeCharSet] Empty charset.");if(c.find(f=>f.length!==1)){if(r)throw new Error("[Ddu64 normalizeCharSet] Multi-character symbols are not supported.");continue}if(c.length>Vr){if(r)throw new Error("[Ddu64 normalizeCharSet] Charset size exceeds maximum supported size of 65536.");continue}if(s.padding.length!==1)throw new Error(`[Ddu64 normalizeCharSet] Padding length mismatch. Expected 1, got ${s.padding.length}`);if(c.includes(s.padding)){if(r)throw new Error(`[Ddu64 normalizeCharSet] Padding character "${s.padding}" conflicts with charset.`);c=c.filter(f=>f!==s.padding);}for(let f of c){if(f.includes(`
|
|
5
|
-
`)||f.includes("\r"))throw new Error("[Ddu64 normalizeCharSet] Newline and carriage return characters are reserved.");if(Oe(f))throw new Error(`[Ddu64 normalizeCharSet] Lone surrogate code unit (U+${f.charCodeAt(0).toString(16).toUpperCase()}) is not allowed; it corrupts on UTF-8/URL/JSON boundaries.`)}if(s.padding.includes(`
|
|
6
|
-
`)||s.padding.includes("\r"))throw new Error("[Ddu64 normalizeCharSet] Newline and carriage return characters are reserved.");if(Oe(s.padding))throw new Error("[Ddu64 normalizeCharSet] Padding character must not be a lone surrogate code unit.");return {charSet:c.length===d?c:c.slice(0,d),padding:s.padding,isPredefined:s.isPredefined}}catch(c){if(r)throw c}}let o=le(t);return {charSet:o.charSet.slice(0,o.requiredLength),padding:o.padding,isPredefined:true}}a(Ie,"normalizeCharSet");function Le(e,r,t){for(let n of De){for(let o of e)if(o.includes(n)){let i=`[Ddu64 Constructor] URL-Safe mode conflict: charset character "${o}" contains "${n}".`;if(t)throw new Error(i);return false}if(r.includes(n)){let o=`[Ddu64 Constructor] URL-Safe mode conflict: padding character "${r}" contains "${n}".`;if(t)throw new Error(o);return false}}return true}a(Le,"isUrlSafeCompatible");function Oe(e){if(e.length!==1)return false;let r=e.charCodeAt(0);return r>=55296&&r<=57343}a(Oe,"isLoneSurrogate");function Hr(e,r){return r!==void 0?r?e>0:false:e>0&&(e&e-1)===0}a(Hr,"shouldUsePowerOfTwo");function qr(e){let r=J(e);if(!r)throw new Error(`CharSet with symbol ${e} not found`);return r}a(qr,"getCharSetOrThrow");function le(e){let r=e?.dduSetSymbol??de.dduSetSymbol??"oneCharSet",t=J(r)??J("oneCharSet");if(!t)throw new Error("Critical: No fallback CharSet available");return {charSet:t.codaChar?Y(t.charSet,t.codaChar):t.charSet,padding:t.paddingChar,requiredLength:t.maxRequiredLength,bitLength:t.encodingProfile?.bitLength??t.bitLength,isPredefined:true,useRepeatPadding:t.useRepeatPadding,bitsPerPadChar:t.encodingProfile?.bitsPerPadChar??t.bitsPerPadChar,usePowerOfTwo:t.encodingProfile?.usePowerOfTwo??t.usePowerOfTwo,encodingProfile:t.encodingProfile}}a(le,"getFallbackCharSet");var Gr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Te(e,r,t,n){return t&&n===6&&r==="="&&e.join("")===Gr}a(Te,"canUseNativeBase64FastPath");function Me(e){let r=jr(e);if(r===null)return null;let t=0,n=r.length;for(;n>0&&r[n-1]==="=";)t++,n--;return {payload:r.slice(0,n),paddingBits:t===2?4:t===1?2:0}}a(Me,"encodeNativeBase64");function Ke(e,r,t){let n=r===4?2:r===2?1:r===0?0:-1;if(n<0)return null;for(let o=0;o<e.length;o++)if(!t(e.charCodeAt(o)))return null;return Wr(e+"=".repeat(n))}a(Ke,"decodeNativeBase64");function jr(e){let r=e.toBase64;if(typeof r=="function")return r.call(e);let t=globalThis.Buffer;return t?.from?t.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"):null}a(jr,"bytesToBase64");function Wr(e){let r=Uint8Array;if(typeof r.fromBase64=="function")return r.fromBase64(e);let t=globalThis.Buffer;if(t?.from){let n=t.from(e,"base64");return new Uint8Array(n)}return null}a(Wr,"base64ToBytes");function Z(e,r){if(!e)throw new m("[Ddu64 adapter] No platform adapter available. Use encodeAsync()/decodeAsync() in browser environments, or provide an adapter via options.adapter.",r);return e}a(Z,"requireSyncAdapter");function Ne(e,r,t){let n=Z(e.adapter,"encode");if(!n.encryptSync)throw new m("[Ddu64 encrypt] Sync encryption unavailable. Use encodeAsync() in browser environments.","encode");let o=$e(e,n,"encrypt","encode");return n.encryptSync(r,o,t)}a(Ne,"encryptSyncWithAdapter");function _e(e,r,t){let n=Z(e.adapter,"decode");if(!n.decryptSync)throw new m("[Ddu64 decrypt] Sync decryption unavailable. Use decodeAsync() in browser environments.","decode");let o=$e(e,n,"decrypt","decode");return n.decryptSync(r,o,t)}a(_e,"decryptSyncWithAdapter");function ze(e,r,t,n){let o=Z(e,"encode");if(t==="brotli"){if(!o.brotliCompressSync)throw new m("[Ddu64 compress] Brotli compression is unavailable in the current runtime.","encode");return o.brotliCompressSync(r,n)}if(!o.deflateSync)throw new m("[Ddu64 compress] Sync compression unavailable. Use encodeAsync() in browser environments.","encode");return o.deflateSync(r,n)}a(ze,"compressSyncWithAdapter");function Fe(e,r,t,n){let o=Z(e,"decode");if(t==="brotli"){if(!o.brotliDecompressSync)throw new m("[Ddu64 decompress] Brotli decompression is unavailable in the current runtime.","decode");return o.brotliDecompressSync(r,n)}if(!o.inflateSync)throw new m("[Ddu64 decompress] Sync decompression unavailable. Use decodeAsync() in browser environments.","decode");return o.inflateSync(r,n)}a(Fe,"decompressSyncWithAdapter");function $e(e,r,t,n){if(e.encryptionKeyHash)return e.encryptionKeyHash;if(!r.deriveKeySync){let i=t==="encrypt"?"encodeAsync":"decodeAsync";throw new m(`[Ddu64 ${t}] Sync key derivation unavailable. Use ${i}() in browser environments.`,n)}let o=r.deriveKeySync(e.encryptionKey,e.keyDerivation);return e.setEncryptionKeyHash(o),o}a($e,"getSyncKeyHash");function Q(e,r){throw p(e)?e:new r(q$1(e),e)}a(Q,"rethrowTyped");function Ve(e,r,t){try{return Ne(e,r,t)}catch(n){Q(n,g);}}a(Ve,"runEncryptSync");function He(e,r,t){try{return _e(e,r,t)}catch(n){Q(n,h);}}a(He,"runDecryptSync");function he(e$1,r,t,n){try{return ze(e$1,r,t,n)}catch(o){Q(o,e);}}a(he,"runCompressSync");function qe(e,r,t,n){try{return Fe(e,r,t,n)}catch(o){Q(o,f);}}a(qe,"runDecompressSync");async function Ge(e,r,t){try{let n=ee(e.adapter,"encode"),o=await Ye(e,n);return await n.encrypt(r,o,t)}catch(n){throw re(n,"encode","encrypt")}}a(Ge,"encryptAsyncWithAdapter");async function je(e,r,t){try{let n=ee(e.adapter,"decode"),o=await Ye(e,n);return await n.decrypt(r,o,t)}catch(n){throw re(n,"decode","decrypt")}}a(je,"decryptAsyncWithAdapter");async function fe(e,r,t,n){try{let o=ee(e,"encode");if(t==="brotli"){if(!o.brotliCompress)throw new m("[Ddu64 compress] Brotli compression is unavailable in the current runtime.","encode");return await o.brotliCompress(r,n)}return await o.deflate(r,n)}catch(o){throw re(o,"encode","compress")}}a(fe,"compressAsyncWithAdapter");async function We(e,r,t,n){try{let o=ee(e,"decode");if(t==="brotli"){if(!o.brotliDecompress)throw new m("[Ddu64 decompress] Brotli decompression is unavailable in the current runtime.","decode");return await o.brotliDecompress(r,n)}return await o.inflate(r,n)}catch(o){throw re(o,"decode","decompress")}}a(We,"decompressAsyncWithAdapter");function ee(e,r){if(!e)throw new m("[Ddu64 adapter] No platform adapter available. Use @ddunigma/node or @ddunigma/node/browser, or provide an adapter via options.adapter.",r);return e}a(ee,"requireAsyncAdapter");async function Ye(e,r){if(e.encryptionKeyHash)return e.encryptionKeyHash;if(e.encryptionKeyHashPromise)return e.encryptionKeyHashPromise;let t=r.deriveKey(e.encryptionKey,e.keyDerivation).then(n=>(e.setEncryptionKeyHash(n),n)).finally(()=>{e.encryptionKeyHashPromise=void 0;});return e.encryptionKeyHashPromise=t,t}a(Ye,"getAsyncKeyHash");function re(e$1,r,t){if(p(e$1))return e$1;let n=q$1(e$1);switch(t){case "compress":return new e(n,e$1);case "decompress":return new f(n,e$1);case "encrypt":return new g(n,e$1);case "decrypt":return new h(n,e$1)}}a(re,"toAsyncGatewayError");function Xe(e,r,t){return e!=null&&typeof e=="object"&&!Array.isArray(e)?{dduChar:void 0,paddingChar:void 0,dduOptions:e}:{dduChar:e,paddingChar:r,dduOptions:t}}a(Xe,"resolveConstructorArgs");var Je=new Map;function Ze(e,r=false){let t=r?e.join(""):void 0;if(t!==void 0){let u=Je.get(t);if(u)return u}let n=new Uint16Array(e.length),o=65535,i=0;for(let u=0;u<e.length;u++){let l=e[u].charCodeAt(0);n[u]=l,l>i&&(i=l),l<o&&(o=l);}let s=e.length>0?o:0,c=new Int32Array(i-s+1);c.fill(-1);for(let u=0;u<e.length;u++)c[n[u]-s]=u;let d={charCodeLookup:c,charCodes:n,lookupOffset:s};return t!==void 0&&Je.set(t,d),d}a(Ze,"buildCharsetLookupTables");function N(e,r,t){let n=r-t;return n>=0&&n<e.length?e[n]:-1}a(N,"lookupCharIndex");var Qe=8;function er(e,r,t,n){return Math.ceil(e/(n?1:2))*t-r}a(er,"decodedBitCount");function x(e,r,t,n){if(e===void 0)return r;if(e===Number.POSITIVE_INFINITY)return Number.POSITIVE_INFINITY;if(!Number.isFinite(e)||e<=0){if(t)throw new k$1(`[Ddu64 options] Invalid ${n}. Must be a positive finite number or Infinity.`);return r}return Math.floor(e)}a(x,"normalizeLimit");function rr(e,r,t,n){if(e===0)return 0;if(r<0||r>=t)throw new d(`[Ddu64 decode] Invalid padding bits: ${r}`);let o=er(e,r,t,n);if(o<0)throw new d("[Ddu64 decode] Invalid decoded bit length");return Math.ceil(o/Qe)}a(rr,"estimateDecodedBytes");function tr(e,r){if(!r&&e.length%2!==0)throw new d(`[Ddu64 decode] Invalid encoded length for variable charset. Expected multiple of 2, got ${e.length}`)}a(tr,"assertEncodedInputAligned");function nr(e,r,t,n){if(e.length===0)return;let o=er(e.length,r,t,n);if(o<0||o%Qe!==0)throw new d(`[Ddu64 decode] Invalid encoded bit length. Expected a whole number of bytes, got ${o} bits.`)}a(nr,"assertDecodedBitLength");function or(e,r,t,n,o,i){if(r===0)return;if(e.length===0)throw new d("[Ddu64 decode] Invalid padding bits without payload");let s=(1<<r)-1,c;if(t){let d$1=e[e.length-1],u=N(n,d$1.charCodeAt(0),i);if(u<0)throw new d(`[Ddu64 decode] Invalid character "${d$1}" at ${e.length-1}`);c=u;}else {let d$1=e[e.length-2],u=e[e.length-1],l=N(n,d$1.charCodeAt(0),i),p=N(n,u.charCodeAt(0),i);if(l<0||p<0)throw new d("[Ddu64 decode] Invalid character in final encoded chunk");c=l*o+p;}if((c&s)!==0)throw new d("[Ddu64 decode] Invalid non-zero padding bits in final symbol")}a(or,"assertCanonicalPadding");var _="DDS1",z="ELYSIA",F="GRISEO";var Yr=new TextEncoder;function B(e,r,t){let n=t-r.length;if(n<0)return false;for(let o=0;o<r.length;o++)if(e.charCodeAt(n+o)!==r.charCodeAt(o))return false;return true}a(B,"endsWithAt");function ir(e,r,t,n=2){let o=e.length,i=r.length,s={cleanedInput:e,paddingBits:0,isEncrypted:false,pipelineVersion:2};if(i===0||o<i)return s;let d=Math.max(0,t-1).toString().length;for(let u=Math.min(d,o);u>=1;u--){let l=o-u,p=true;for(let C=l;C<o;C++){let S=e.charCodeAt(C);if(S<48||S>57){p=false;break}}if(!p||u>1&&e.charCodeAt(l)===48)continue;let f=0;for(let C=l;C<o;C++)f=f*10+(e.charCodeAt(C)-48);if(f>=t)continue;let h=l,m=false,y,g=2;h>=2&&B(e,"V4",h)?(g=4,h-=2):h>=2&&B(e,"V3",h)&&(g=3,h-=2),h>=3&&B(e,"ENC",h)&&(m=true,h-=3),h>=z.length&&B(e,z,h)?(y="deflate",h-=z.length):h>=F.length&&B(e,F,h)&&(y="brotli",h-=F.length);let w=h-i;if(w>=0&&B(e,r,h))return {cleanedInput:e.substring(0,w),paddingBits:f,compressionAlgorithm:y,isEncrypted:m,pipelineVersion:g}}if(B(e,r,o)){let u=0,l=o;for(;l>=i&&B(e,r,l);)u++,l-=i;if(u>0){let p=u*n;if(p<t)return {cleanedInput:e.substring(0,l),paddingBits:p,isEncrypted:false,pipelineVersion:2}}}return s}a(ir,"parseFooter");function Xr(e){let r=e.lastIndexOf("CHK");if(r===-1)return {data:e,checksum:null};let t=e.slice(r+3);return t.length!==8||!/^[0-9a-f]+$/i.test(t)?{data:e,checksum:null}:{data:e.slice(0,r),checksum:t.toLowerCase()}}a(Xr,"extractChecksum");var Jr=/^[0-9a-f]{8}$/i;function ar(e){let r=e.length;if(r>=11){let n=e.charCodeAt(r-11),o=e.charCodeAt(r-10),i=e[r-9];if(n===67&&o===75&&(i==="P"||i==="O")){let s=e.slice(r-8);if(Jr.test(s))return {data:e.slice(0,r-11),checksum:s.toLowerCase(),scope:i==="P"?"plaintext":"output"}}}let t=Xr(e);return {data:t.data,checksum:t.checksum,scope:null}}a(ar,"extractScopedChecksum");function Zr(e){return e.length*2+_.length+2}a(Zr,"getStreamHeaderLength");function $t(e,r){let t=r.compressionAlgorithm==="brotli"?"B":r.compressionAlgorithm==="deflate"?"D":"N",n=r.encrypted?"1":"0";return `${e}${_}${t}${n}${e}`}a($t,"buildStreamHeader");function Vt(e,r){let t=Zr(r);if(e.length<t||!e.startsWith(r))return null;let n=r.length;if(e.slice(n,n+_.length)!==_)throw new Error("[wireFormat] Invalid stream header magic");let i=e[n+_.length],s=e[n+_.length+1];if(e.slice(t-r.length,t)!==r)throw new Error("[wireFormat] Invalid stream header terminator");let d=i==="B"?"brotli":i==="D"?"deflate":i==="N"?void 0:null;if(d===null)throw new Error("[wireFormat] Invalid stream header compression flag");if(s!=="0"&&s!=="1")throw new Error("[wireFormat] Invalid stream header encryption flag");return {compressionAlgorithm:d,encrypted:s==="1"}}a(Vt,"parseStreamHeader");function sr(e){let{paddingBits:r,compressionAlgorithm:t,isEncrypted:n,paddingChar:o,useRepeatPadding:i,bitsPerPadChar:s=2,pipelineVersion:c=2}=e;if(!n&&c!==2)throw new Error("[wireFormat] Pipeline version markers require encryption");if(r===0&&!t&&!n&&c===2)return "";if(i&&!t&&!n&&c===2&&r>0&&r%s===0){let u=r/s;return o.repeat(u)}return o+(t==="deflate"?z:t==="brotli"?F:"")+(n?"ENC":"")+(c===4?"V4":c===3?"V3":"")+r.toString()}a(sr,"buildFooter");function te(e){return Yr.encode(`ddunigma:wire:v4;enc=1;compress=${e.compressionAlgorithm??"none"}`)}a(te,"buildEncryptionAAD");function dr(e,r,t){let n=r?.checksum??t.defaultChecksum,o=r?.compress!==false,i$1=r?.encrypt!==false,s=e;t.reportDecodeStart(e.length);let c=x(r?.maxEncodedChars,t.defaultMaxEncodedChars,true,"maxEncodedChars");if(e.length>c)throw new l(`[Ddu64 decode] Encoded input exceeds limit. Length: ${e.length}, Limit: ${c} characters`,"decode");let d=r?.chunkSeparator??t.defaultChunkSeparator;s=ve(s,d),t.urlSafe&&(s=ke(s));let u=null,l$1=null;if(n){let O=ar(s);if(u=O.checksum,l$1=O.scope,s=O.data,!u)throw new i("[Ddu64 checksum] Checksum verification requested, but no checksum marker was found.")}t.shouldObfuscate(r)&&(s=t.deobfuscate(s));let{cleanedInput:p,paddingBits:f,compressionAlgorithm:h$1,isEncrypted:m,pipelineVersion:y}=ir(s,t.paddingChar,t.bitLength,t.bitsPerPadChar);if((r?.requireEncryption??t.defaultRequireEncryption)&&i$1&&!m)throw new h("[Ddu64 decode] Encryption is required, but the payload has no authenticated encryption footer.");if(m&&i$1&&!t.encryptionKey)throw new h("[Ddu64 decode] Encrypted payload requires an encryptionKey");let w=m&&y===4?te({compressionAlgorithm:h$1}):void 0;tr(p,t.usePowerOfTwo),or(p,f,t.usePowerOfTwo,t.dduCharCodeLookup,t.charSetSize,t.dduCharCodeLookupOffset),nr(p,f,t.bitLength,t.usePowerOfTwo);let C=x(r?.maxDecodedBytes,t.defaultMaxDecodedBytes,true,"maxDecodedBytes"),S=rr(p.length,f,t.bitLength,t.usePowerOfTwo);if(S>C)throw new l(`[Ddu64 decode] Decoded output exceeds limit. Estimated: ${S} bytes, Limit: ${C} bytes`,"decode");return t.reportBitpackDecode(p.length,e.length),{decoded:t.decodeChars(p,f),extractedChecksum:u,extractedChecksumScope:l$1,compressionAlgorithm:h$1,isEncrypted:m,pipelineVersion:y,encryptionAAD:w,allowInternalDecompress:o,allowInternalDecrypt:i$1}}a(dr,"runDecodePrelude");function cr(e){return e.omitFooter?"":sr({paddingBits:e.paddingBits,compressionAlgorithm:e.compressionAlgorithm,isEncrypted:e.isEncrypted,paddingChar:e.paddingChar,useRepeatPadding:e.useRepeatPadding&&!e.compressionAlgorithm&&!e.isEncrypted,bitsPerPadChar:e.bitsPerPadChar,pipelineVersion:e.isEncrypted?e.pipelineVersion:2})}a(cr,"buildEncodeFooter");function ur(e){let r=e.encoded;if(e.shouldObfuscate(e.options)&&(r=e.getObfuscationLayer().obfuscate(r)),e.shouldChecksum&&e.checksum){let t=e.checksumScope==="plaintext"?"P":"O";r=r+"CK"+t+e.checksum;}return e.urlSafe&&(r=Ee(r)),e.chunkSize&&e.chunkSize>0&&(e.assertSafeChunkSeparator(r,e.chunkSeparator),r=xe(r,e.chunkSize,e.chunkSeparator)),r}a(ur,"applyPostEncoding");var pe=8192;function lr(e,r,t){let n=e.length;if(n===0)return {payload:"",paddingBits:0};let o=Math.ceil(n*8/r),i=Math.min(o,pe),s=new Uint16Array(i),c=[],d=0,u=0;if(r===6){let l=0;for(;l+2<n;l+=3){let f=e[l],h=e[l+1],m=e[l+2];s[d++]=t[f>>>2],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),s[d++]=t[(f&3)<<4|h>>>4],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),s[d++]=t[(h&15)<<2|m>>>6],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),s[d++]=t[m&63],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0);}let p=n-l;if(p===1){let f=e[l];s[d++]=t[f>>>2],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),s[d++]=t[(f&3)<<4],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),u=4;}else if(p===2){let f=e[l],h=e[l+1];s[d++]=t[f>>>2],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),s[d++]=t[(f&3)<<4|h>>>4],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),s[d++]=t[(h&15)<<2],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),u=2;}}else if(r===8)for(let l=0;l<n;l++)s[d++]=t[e[l]],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0);else {let l=(1<<r)-1,p=0,f=0;for(let h=0;h<n;h++)for(p=p<<8|e[h],f+=8;f>=r;)f-=r,s[d++]=t[p>>f&l],d===i&&(c.push(String.fromCharCode.apply(null,s)),d=0),p&=(1<<f)-1;f>0&&(u=r-f,s[d++]=t[p<<u&l]);}return d>0&&c.push(String.fromCharCode.apply(null,s.subarray(0,d))),{payload:c.length===1?c[0]:c.join(""),paddingBits:u}}a(lr,"packPow2ToString");function hr(e,r,t,n,o){let i=e.length;if(i===0)return new Uint8Array(0);let s=Math.ceil((i*t-r)/8),c=new Uint8Array(s+1),d$1=0,u=n.length;if(t===6){let h=i-i%4;h===i&&r>0&&(h-=4);let m=0;for(;m<h;m+=4){let C=e.charCodeAt(m)-o,S=C>=0&&C<u?n[C]:-1;if(S<0)throw new d(`[Ddu64 decode] Invalid character "${e[m]}" at ${m}`);let D=e.charCodeAt(m+1)-o,O=D>=0&&D<u?n[D]:-1;if(O<0)throw new d(`[Ddu64 decode] Invalid character "${e[m+1]}" at ${m+1}`);let ne=e.charCodeAt(m+2)-o,oe=ne>=0&&ne<u?n[ne]:-1;if(oe<0)throw new d(`[Ddu64 decode] Invalid character "${e[m+2]}" at ${m+2}`);let ie=e.charCodeAt(m+3)-o,ge=ie>=0&&ie<u?n[ie]:-1;if(ge<0)throw new d(`[Ddu64 decode] Invalid character "${e[m+3]}" at ${m+3}`);c[d$1++]=S<<2|O>>>4,c[d$1++]=(O&15)<<4|oe>>>2,c[d$1++]=(oe&3)<<6|ge;}let y=0,g=0,w=i-1;for(;m<i;m++){let S=e.charCodeAt(m)-o,D=S>=0&&S<u?n[S]:-1;if(D<0)throw new d(`[Ddu64 decode] Invalid character "${e[m]}" at ${m}`);for(y=y<<6|D,g+=6,m===w&&r>0&&(y>>=r,g-=r);g>=8;)g-=8,c[d$1++]=y>>g&255,y&=(1<<g)-1;}return c.subarray(0,d$1)}if(t===8&&r===0){for(let h=0;h<i;h++){let y=e.charCodeAt(h)-o,g=y>=0&&y<u?n[y]:-1;if(g<0)throw new d(`[Ddu64 decode] Invalid character "${e[h]}" at ${h}`);c[d$1++]=g;}return c.subarray(0,d$1)}let l=0,p=0,f=i-1;for(let h=0;h<i;h++){let y=e.charCodeAt(h)-o,g=y>=0&&y<u?n[y]:-1;if(g<0)throw new d(`[Ddu64 decode] Invalid character "${e[h]}" at ${h}`);for(l=l<<t|g,p+=t,h===f&&r>0&&(l>>=r,p-=r);p>=8;)p-=8,c[d$1++]=l>>p&255,l&=(1<<p)-1;}return c.subarray(0,d$1)}a(hr,"unpackPow2FromString");function fr(e,r,t,n){let o=e.length;if(o===0)return {payload:"",paddingBits:0};let i=[],s=new Uint16Array(pe),c=0,d=0,u=0,l=0,p=a(f=>{s[c++]=f,c===pe&&(i.push(String.fromCharCode.apply(null,s)),c=0);},"pushCode");for(let f=0;f<o;f++)for(d=d<<8|e[f],u+=8;u>=r;){u-=r;let h=d>>u,m=h/t|0;p(n[m]),p(n[h-m*t]),d&=(1<<u)-1;}if(u>0){l=r-u;let f=d<<l,h=f/t|0;p(n[h]),p(n[f-h*t]);}return c>0&&i.push(String.fromCharCode.apply(null,s.subarray(0,c))),{payload:i.length===1?i[0]:i.join(""),paddingBits:l}}a(fr,"packNonPow2ToString");function pr(e,r,t,n,o,i){let s=e.length;if(s===0)return new Uint8Array(0);let c=Math.ceil(s/2),d$1=Math.ceil((c*t-r)/8),u=new Uint8Array(d$1+1),l=0,p=Pe(t),f=o.length,h=0,m=0;for(let y=0;y<s;y+=2){let g=e.charCodeAt(y)-i,w=g>=0&&g<f?o[g]:-1;if(w<0)throw new d(`[Ddu64 decode] Invalid character "${e[y]}" at ${y}`);if(y+1>=s)throw new d(`[Ddu64 decode] Truncated symbol pair at ${y+1}`);let C=e.charCodeAt(y+1)-i,S=C>=0&&C<f?o[C]:-1;if(S<0)throw new d(`[Ddu64 decode] Invalid character "${e[y+1]}" at ${y+1}`);let D=w*n+S;if(D>=p)throw new d(`[Ddu64 decode] Value ${D} exceeds range at position ${y}`);for(h=h<<t|D,m+=t,y+2>=s&&r>0&&(h>>=r,m-=r);m>=8;)m-=8,u[l++]=h>>m&255,h&=(1<<m)-1;}return u.subarray(0,l)}a(pr,"unpackNonPow2FromString");function mr(e,r,t,n,o){if(e.length===0)return "";let i=o.canUseNativeBase64?Me(e):null,s,c;if(i)s=i.paddingBits,c=i.payload;else if(o.bitPackConfig.usePowerOfTwo){let u=lr(e,o.bitPackConfig.bitLength,o.dduCharCodes);s=u.paddingBits,c=u.payload;}else {let u=fr(e,o.bitPackConfig.bitLength,o.bitPackConfig.charsetSize,o.dduCharCodes);s=u.paddingBits,c=u.payload;}let d=cr({paddingBits:s,compressionAlgorithm:r,isEncrypted:t,paddingChar:o.paddingChar,useRepeatPadding:o.useRepeatPadding,bitsPerPadChar:o.bitsPerPadChar,pipelineVersion:o.encryptedPipelineVersion,omitFooter:n?.omitFooter});return c+d}a(mr,"encodePayload");function yr(e,r,t){if(e.length===0)return new Uint8Array(0);let o=t.canUseNativeBase64?Ke(e,r,i=>N(t.dduCharCodeLookup,i,t.dduCharCodeLookupOffset)>=0):null;return o||(t.bitPackConfig.usePowerOfTwo?hr(e,r,t.bitPackConfig.bitLength,t.dduCharCodeLookup,t.dduCharCodeLookupOffset):pr(e,r,t.bitPackConfig.bitLength,t.bitPackConfig.charsetSize,t.dduCharCodeLookup,t.dduCharCodeLookupOffset))}a(yr,"decodePayload");function gr(e,r){let t=new Set(e);t.add(r);let n=z+F+"ENC"+"V3"+"V4";for(let o of n)t.add(o);for(let o of "0123456789")t.add(o);return [...t]}a(gr,"buildObfuscationAlphabet");function k(e,r="construct"){if(e===void 0)return;if(typeof e!="object"||e===null||Array.isArray(e))throw new k$1("[Ddu64 options] Options must be an object.",r);let t=e;E(e.compress,"compress",r),E(t.encrypt,"encrypt",r),E(e.checksum,"checksum",r),E(t.omitFooter,"omitFooter",r),E(e.obfuscate,"obfuscate",r),E(e.requireEncryption,"requireEncryption",r),e.compressionLevel!==void 0&&(typeof e.compressionLevel!="number"||!Number.isFinite(e.compressionLevel))&&A(r,"compressionLevel must be a finite number"),e.onProgress!==void 0&&typeof e.onProgress!="function"&&A(r,"onProgress must be a function"),e.compressionAlgorithm!==void 0&&e.compressionAlgorithm!=="deflate"&&e.compressionAlgorithm!=="brotli"&&A(r,`compressionAlgorithm must be "deflate" or "brotli", got ${String(e.compressionAlgorithm)}`),e.checksumScope!==void 0&&e.checksumScope!=="plaintext"&&e.checksumScope!=="output"&&A(r,`checksumScope must be "plaintext" or "output", got ${String(e.checksumScope)}`),e.chunkSize!==void 0&&(!Number.isSafeInteger(e.chunkSize)||e.chunkSize<0)&&A(r,"chunkSize must be a non-negative safe integer (0 disables chunking)"),e.chunkSeparator!==void 0&&typeof e.chunkSeparator!="string"&&A(r,"chunkSeparator must be a string"),e.chunkSize!==void 0&&e.chunkSize>0&&e.chunkSeparator===""&&A(r,"chunkSeparator must not be empty when chunkSize is enabled"),V(e.maxDecodedBytes,"maxDecodedBytes",r),V(e.maxEncodedChars,"maxEncodedChars",r),V(e.maxDecompressedBytes,"maxDecompressedBytes",r),"maxBufferedBytes"in e&&V(e.maxBufferedBytes,"maxBufferedBytes",r),"maxBufferedChars"in e&&V(e.maxBufferedChars,"maxBufferedChars",r);let n=e;E(n.throwOnError,"throwOnError",r),E(n.urlSafe,"urlSafe",r),E(n.useRepeatPadding,"useRepeatPadding",r),E(n.usePowerOfTwo,"usePowerOfTwo",r),n.encryptionKey!==void 0&&(typeof n.encryptionKey!="string"||n.encryptionKey.length===0)&&A(r,"encryptionKey must be a non-empty string"),n.dduChar!==void 0&&typeof n.dduChar!="string"&&!(Array.isArray(n.dduChar)&&n.dduChar.every(i=>typeof i=="string"))&&A(r,"dduChar must be a string or string array"),n.paddingChar!==void 0&&typeof n.paddingChar!="string"&&A(r,"paddingChar must be a string"),n.codaChar!==void 0&&!(Array.isArray(n.codaChar)&&n.codaChar.every(i=>typeof i=="string"))&&A(r,"codaChar must be a string array"),n.requiredLength!==void 0&&(!Number.isSafeInteger(n.requiredLength)||n.requiredLength<=0)&&A(r,"requiredLength must be a positive safe integer"),n.adapter!==void 0&&(typeof n.adapter!="object"||n.adapter===null)&&A(r,"adapter must be an object");let o="keyDerivation"in e?e.keyDerivation:void 0;o!==void 0&&((typeof o!="object"||o===null)&&A(r,"keyDerivation must be an object"),o.algorithm!==void 0&&o.algorithm!=="sha256"&&o.algorithm!=="pbkdf2"&&A(r,`keyDerivation.algorithm must be "sha256" or "pbkdf2", got ${String(o.algorithm)}`),o.hash!==void 0&&o.hash!=="SHA-256"&&o.hash!=="SHA-384"&&o.hash!=="SHA-512"&&A(r,`Unsupported PBKDF2 hash: ${String(o.hash)}`),o.iterations!==void 0&&(!Number.isFinite(o.iterations)||o.iterations<=0)&&A(r,"keyDerivation.iterations must be a positive finite number"),o.salt!==void 0&&typeof o.salt!="string"&&!Cr(o.salt)&&A(r,"keyDerivation.salt must be a string or Uint8Array"));}a(k,"validateRuntimeOptions");function H(e,r="encode"){if(typeof e!="string"&&!Cr(e))throw new k$1("[Ddu64 input] Encode input must be a string or Uint8Array.",r)}a(H,"validateEncodeInput");function q(e,r="decode"){if(typeof e!="string")throw new k$1("[Ddu64 input] Decode input must be a string.",r)}a(q,"validateDecodeInput");function Cr(e){return ArrayBuffer.isView(e)&&Object.prototype.toString.call(e)==="[object Uint8Array]"}a(Cr,"isUint8Array");function E(e,r,t){e!==void 0&&typeof e!="boolean"&&A(t,`${r} must be a boolean`);}a(E,"validateBoolean");function V(e,r,t){e!==void 0&&e!==Number.POSITIVE_INFINITY&&(!Number.isSafeInteger(e)||e<=0)&&A(t,`${r} must be a positive safe integer or Infinity`);}a(V,"validatePositiveLimit");function A(e,r){throw new k$1(`[Ddu64 options] Invalid ${r}.`,e)}a(A,"invalid");function br(e,r,t){let n=e.decoded,o=e.extractedChecksumScope??r?.checksumScope??"plaintext";return o==="output"&&Dr(e,t),n=nt(e,t,n),n=ot(e,r,t,n),o==="plaintext"&&Er(e,t,n),n=it(e,t,n),xr(t,n),n}a(br,"runSyncDecodePipeline");async function Ar(e,r,t){let n=e.decoded,o=e.extractedChecksumScope??r?.checksumScope??"plaintext";if(o==="output"&&Dr(e,t),Sr(e,t)&&(v(t,n.length,55,"decrypt"),n=await t.decrypt(n,e.encryptionAAD)),Pr(e)){let i=kr(r,t);v(t,n.length,70,"decompress"),n=await t.decompress(n,e.compressionAlgorithm,i);}return o==="plaintext"&&Er(e,t,n),wr(e,t)&&(v(t,n.length,90,"decrypt"),n=await t.decrypt(n,e.encryptionAAD)),xr(t,n),n}a(Ar,"runAsyncDecodePipeline");function nt(e,r,t){return Sr(e,r)?(v(r,t.length,55,"decrypt"),r.decrypt(t,e.encryptionAAD)):t}a(nt,"runPreDecompressDecrypt");function ot(e,r,t,n){if(!Pr(e))return n;let o=kr(r,t);return v(t,n.length,70,"decompress"),t.decompress(n,e.compressionAlgorithm,o)}a(ot,"runDecompress");function it(e,r,t){return wr(e,r)?(v(r,t.length,90,"decrypt"),r.decrypt(t,e.encryptionAAD)):t}a(it,"runPostChecksumDecrypt");function Sr(e,r){return (e.pipelineVersion===3||e.pipelineVersion===4)&&e.isEncrypted&&!!r.encryptionKey&&e.allowInternalDecrypt}a(Sr,"shouldRunPreDecompressDecrypt");function wr(e,r){return e.pipelineVersion===2&&e.isEncrypted&&!!r.encryptionKey&&e.allowInternalDecrypt}a(wr,"shouldRunPostChecksumDecrypt");function Pr(e){return !!e.compressionAlgorithm&&e.allowInternalDecompress&&(e.pipelineVersion===2||!e.isEncrypted||e.allowInternalDecrypt)}a(Pr,"shouldDecompress");function Dr(e,r){if(!e.extractedChecksum)return;v(r,e.decoded.length,85,"checksum");let t=U(e.decoded);if(!ce(t,e.extractedChecksum))throw new i(`[Ddu64 decode] Checksum mismatch. Expected: ${e.extractedChecksum}, Got: ${t}`)}a(Dr,"verifyWireChecksum");function Er(e,r,t){if(!e.extractedChecksum||!(e.pipelineVersion===2||!e.isEncrypted||e.allowInternalDecrypt))return;v(r,t.length,85,"checksum");let n=U(t);if(!ce(n,e.extractedChecksum))throw new i(`[Ddu64 decode] Checksum mismatch. Expected: ${e.extractedChecksum}, Got: ${n}`)}a(Er,"verifyDecodedChecksum");function kr(e,r){return x(e?.maxDecompressedBytes,r.defaultMaxDecompressedBytes,true,"maxDecompressedBytes")}a(kr,"getMaxDecompressedBytes");function v(e,r,t,n){e.reportProgress({processedBytes:r,totalBytes:r,percent:t,stage:n});}a(v,"reportStage");function xr(e,r){v(e,r.length,100,"done");}a(xr,"reportDone");function me(e,r,t){let n=Ur(r,t),o=typeof e=="string"?K(e):e;Br(t,o.length);let i="";n.shouldChecksum&&n.checksumScope==="plaintext"&&(i=U(o));let s,c;if(n.shouldCompress){let{algo:u,level:l}=vr(r,t);Or(t,o.length);let p=t.compress(o,u,l);p.length<o.length&&(c=p.length,o=p,s=u);}let d=false;return n.shouldEncrypt&&(Rr(t,o.length),o=t.encrypt(o,t.getEncryptionAAD(s)),d=true),n.shouldChecksum&&n.checksumScope==="output"&&(i=U(o)),{encoded:t.finalize(o,s,d,i,n.shouldChecksum,n.checksumScope,n.chunkSize,n.chunkSeparator),compressedSize:c}}a(me,"runSyncEncodePipeline");async function ye(e,r,t){let n=Ur(r,t),o=typeof e=="string"?K(e):e;Br(t,o.length);let i="";n.shouldChecksum&&n.checksumScope==="plaintext"&&(i=U(o));let s,c;if(n.shouldCompress){let{algo:u,level:l}=vr(r,t);Or(t,o.length);let p=await t.compress(o,u,l);p.length<o.length&&(c=p.length,o=p,s=u);}let d=false;return n.shouldEncrypt&&(Rr(t,o.length),o=await t.encrypt(o,t.getEncryptionAAD(s)),d=true),n.shouldChecksum&&n.checksumScope==="output"&&(i=U(o)),{encoded:t.finalize(o,s,d,i,n.shouldChecksum,n.checksumScope,n.chunkSize,n.chunkSeparator),compressedSize:c}}a(ye,"runAsyncEncodePipeline");function vr(e,r){let t=e?.compressionAlgorithm??r.defaultCompressionAlgorithm,n=X(e?.compressionLevel??r.defaultCompressionLevel,t);return {algo:t,level:n}}a(vr,"resolveCompressionParams");function Ur(e,r){return {shouldCompress:e?.compress??r.defaultCompress,shouldChecksum:e?.checksum??r.defaultChecksum,checksumScope:e?.checksumScope??r.defaultChecksumScope,shouldEncrypt:(e?.encrypt??true)&&r.hasEncryptionKey,chunkSize:e?.chunkSize??r.defaultChunkSize,chunkSeparator:e?.chunkSeparator??r.defaultChunkSeparator}}a(Ur,"resolveEncodeSettings");function Br(e,r){e.reportProgress({processedBytes:0,totalBytes:r,percent:0,stage:"start"});}a(Br,"reportStart");function Or(e,r){e.reportProgress({processedBytes:r,totalBytes:r,percent:20,stage:"compress"});}a(Or,"reportCompress");function Rr(e,r){e.reportProgress({processedBytes:r,totalBytes:r,percent:45,stage:"encrypt"});}a(Rr,"reportEncrypt");var at=64*1024*1024,st=64*1024*1024,dt=256*1024*1024,Ir=28,Lr=class{static{a(this,"Ddu64Core");}dduChar;dduCharCodes;paddingChar;bitLength;usePowerOfTwo;dduCharCodeLookup;dduCharCodeLookupOffset;defaultCompress;defaultMaxDecodedBytes;defaultMaxEncodedChars;defaultMaxDecompressedBytes;urlSafe;encryptionKey;keyDerivation;encryptionKeyHash;syncGatewayContext;defaultChecksum;defaultChecksumScope;defaultChunkSize;defaultChunkSeparator;defaultCompressionLevel;defaultCompressionAlgorithm;useRepeatPadding;bitsPerPadChar;bitPackConfig;canUseNativeBase64;payloadCodecContext;adapter;adapterFactory;obfuscationLayerFactory;defaultObfuscate;defaultOnProgress;defaultRequireEncryption;obfuscationLayer;constructor(r,t,n){let o=Xe(r,t,n);r=o.dduChar,t=o.paddingChar,n=o.dduOptions,k(n);let i=n?.throwOnError??true;this.adapter=n?.adapter,this.adapterFactory=n?.adapterFactory,this.obfuscationLayerFactory=n?.obfuscationLayerFactory;let s,c;try{s=Re(r,t,n,i),c=Ie(s,i,n);}catch(y){throw p(y)?y:new j(q$1(y),y)}this.dduChar=c.charSet,this.paddingChar=c.padding;let d=c.isPredefined;this.defaultCompress=n?.compress??false,this.defaultMaxDecodedBytes=x(n?.maxDecodedBytes,at,i,"maxDecodedBytes"),this.defaultMaxDecompressedBytes=x(n?.maxDecompressedBytes,st,i,"maxDecompressedBytes"),this.defaultMaxEncodedChars=x(n?.maxEncodedChars,this.defaultMaxDecodedBytes===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(dt,this.defaultMaxDecodedBytes*4),i,"maxEncodedChars");let u=this.dduChar.length,l=we(u),p$1=n?.usePowerOfTwo,f=s.encodingProfile;this.usePowerOfTwo=f?.usePowerOfTwo??s.usePowerOfTwo??(p$1!==void 0?p$1&&l:l);let h=f?.bitLength??(s.isPredefined&&s.usePowerOfTwo!==void 0?s.bitLength:void 0);this.bitLength=h??Se(u,this.usePowerOfTwo);let m=Ze(this.dduChar,d);this.dduCharCodeLookup=m.charCodeLookup,this.dduCharCodeLookupOffset=m.lookupOffset,this.dduCharCodes=m.charCodes,this.urlSafe=ct(this.dduChar,this.paddingChar,n?.urlSafe??false,i),this.encryptionKey=n?.encryptionKey,this.keyDerivation=n?.keyDerivation,this.defaultChecksum=n?.checksum??false,this.defaultChecksumScope=n?.checksumScope??"output",this.defaultChunkSize=n?.chunkSize,this.defaultChunkSeparator=n?.chunkSeparator??`
|
|
7
|
-
`,this.defaultCompressionAlgorithm=n?.compressionAlgorithm??"deflate",this.defaultCompressionLevel=X(n?.compressionLevel,this.defaultCompressionAlgorithm),this.useRepeatPadding=n?.useRepeatPadding??s.useRepeatPadding??false,this.bitsPerPadChar=f?.bitsPerPadChar??s.bitsPerPadChar??2,this.defaultObfuscate=n?.obfuscate??false,this.defaultOnProgress=n?.onProgress,this.defaultRequireEncryption=n?.requireEncryption??this.encryptionKey!==void 0,this.bitPackConfig={bitLength:this.bitLength,usePowerOfTwo:this.usePowerOfTwo,charsetSize:u},this.canUseNativeBase64=Te(this.dduChar,this.paddingChar,this.usePowerOfTwo,this.bitLength),this.payloadCodecContext={bitPackConfig:this.bitPackConfig,canUseNativeBase64:this.canUseNativeBase64,dduCharCodes:this.dduCharCodes,dduCharCodeLookup:this.dduCharCodeLookup,dduCharCodeLookupOffset:this.dduCharCodeLookupOffset,paddingChar:this.paddingChar,useRepeatPadding:this.useRepeatPadding,bitsPerPadChar:this.bitsPerPadChar,encryptedPipelineVersion:4};}encode(r$1,t){try{return k(t,"encode"),H(r$1),this.encodeInternal(r$1,t).encoded}catch(n){throw r(n,"encode")}}decode(r$1,t){try{k(t,"decode"),q(r$1);let n=this.decodeToUint8Array(r$1,t);return ue(n)}catch(n){throw r(n,"decode")}}decodeToUint8Array(r$1,t){try{return k(t,"decode"),q(r$1),this.decodeToUint8ArrayInternal(r$1,t)}catch(n){throw r(n,"decode")}}decodeToUint8ArrayInternal(r,t){let n=this.decodePrelude(r,t);return br(n,t,{...this.buildDecodeBaseContext(t),decrypt:a((o,i)=>He(this.getSyncGatewayContext(),o,i),"decrypt"),decompress:a((o,i,s)=>qe(this.getAdapter(),o,i,s),"decompress")})}async encodeAsync(r$1,t){try{return k(t,"encode"),H(r$1),await this.encodeAsyncInternal(r$1,t)}catch(n){throw r(n,"encode")}}async encodeAsyncInternal(r,t){return (await ye(r,t,{...this.buildEncodeBaseContext(t),compress:a((o,i,s)=>fe(this.getAdapter(),o,i,s),"compress"),encrypt:a((o,i)=>Ge(this.getSyncGatewayContext(),o,i),"encrypt")})).encoded}async decodeAsync(r$1,t){try{k(t,"decode"),q(r$1);let n=await this.decodeToUint8ArrayAsync(r$1,t);return ue(n)}catch(n){throw r(n,"decode")}}async decodeToUint8ArrayAsync(r$1,t){try{return k(t,"decode"),q(r$1),await this.decodeToUint8ArrayAsyncInternal(r$1,t)}catch(n){throw r(n,"decode")}}async decodeToUint8ArrayAsyncInternal(r,t){let n=this.decodePrelude(r,t);return Ar(n,t,{...this.buildDecodeBaseContext(t),decrypt:a((o,i)=>je(this.getSyncGatewayContext(),o,i),"decrypt"),decompress:a((o,i,s)=>We(this.getAdapter(),o,i,s),"decompress")})}buildDecodeBaseContext(r){return {encryptionKey:this.encryptionKey,defaultMaxDecompressedBytes:this.defaultMaxDecompressedBytes,reportProgress:a(t=>this.reportProgress(r,t),"reportProgress")}}getCharSetInfo(){return {charSet:[...this.dduChar],paddingChar:this.paddingChar,bitLength:this.bitLength,usePowerOfTwo:this.usePowerOfTwo,encoding:"utf-8",defaultCompress:this.defaultCompress,defaultMaxDecodedBytes:this.defaultMaxDecodedBytes,defaultMaxDecompressedBytes:this.defaultMaxDecompressedBytes,urlSafe:this.urlSafe,hasEncryptionKey:!!this.encryptionKey,defaultChecksum:this.defaultChecksum,defaultChecksumScope:this.defaultChecksumScope,defaultObfuscate:this.defaultObfuscate,defaultRequireEncryption:this.defaultRequireEncryption,defaultChunkSize:this.defaultChunkSize,defaultChunkSeparator:this.defaultChunkSeparator,defaultCompressionLevel:this.defaultCompressionLevel,defaultCompressionAlgorithm:this.defaultCompressionAlgorithm}}getStats(r,t){k(t,"encode"),H(r);let n=typeof r=="string"?K(r):r,{encoded:o,compressedSize:i}=this.encodeStatsInternal(n,t);return this.buildEncodeStats(n.length,o.length,i,t)}async getStatsAsync(r,t){k(t,"encode"),H(r);let n=typeof r=="string"?K(r):r,{encoded:o,compressedSize:i}=await this.encodeStatsAsyncInternal(n,t);return this.buildEncodeStats(n.length,o.length,i,t)}buildEncodeStats(r,t,n,o){let i=r>0?t/r:0,c=(o?.compress??this.defaultCompress)&&n!==void 0&&r>0?n/r:void 0;return {originalSize:r,encodedSize:t,compressedSize:n,compressionRatio:c,expansionRatio:i,charsetSize:this.dduChar.length,bitLength:this.bitLength}}encodeInternal(r,t){return me(r,t,{...this.buildEncodeBaseContext(t),compress:a((n,o,i)=>he(this.getAdapter(),n,o,i),"compress"),encrypt:a((n,o)=>Ve(this.getSyncGatewayContext(),n,o),"encrypt")})}encodeStatsInternal(r,t){return me(r,t,{...this.buildEncodeBaseContext(t),compress:a((n,o,i)=>he(this.getAdapter(),n,o,i),"compress"),encrypt:a(n=>new Uint8Array(n.length+Ir),"encrypt")})}async encodeStatsAsyncInternal(r,t){return ye(r,t,{...this.buildEncodeBaseContext(t),compress:a((n,o,i)=>fe(this.getAdapter(),n,o,i),"compress"),encrypt:a(async n=>new Uint8Array(n.length+Ir),"encrypt")})}buildEncodeBaseContext(r){return {defaultCompress:this.defaultCompress,defaultChecksum:this.defaultChecksum,defaultChecksumScope:this.defaultChecksumScope,defaultChunkSize:this.defaultChunkSize,defaultChunkSeparator:this.defaultChunkSeparator,defaultCompressionLevel:this.defaultCompressionLevel,defaultCompressionAlgorithm:this.defaultCompressionAlgorithm,hasEncryptionKey:!!this.encryptionKey,reportProgress:a(t=>this.reportProgress(r,t),"reportProgress"),getEncryptionAAD:a(t=>te({compressionAlgorithm:t}),"getEncryptionAAD"),finalize:a((t,n,o,i,s,c,d,u)=>this.finalizeEncode(t,n,o,i,s,c,d,u,r),"finalize")}}finalizeEncode(r,t,n,o,i,s,c,d,u){this.reportProgress(u,{processedBytes:r.length,totalBytes:r.length,percent:70,stage:"encode"});let l=mr(r,t,n,u,this.getPayloadCodecContext());return l=this.applyPostEncoding(l,u,o,i,s,c,d),this.reportProgress(u,{processedBytes:r.length,totalBytes:r.length,percent:100,stage:"done"}),l}applyPostEncoding(r,t,n,o,i,s,c){return ur({encoded:r,options:t,checksum:n,shouldChecksum:o,checksumScope:i,chunkSize:s,chunkSeparator:c,urlSafe:this.urlSafe,shouldObfuscate:a(d=>this.shouldObfuscate(d),"shouldObfuscate"),getObfuscationLayer:a(()=>this.getObfuscationLayer(),"getObfuscationLayer"),assertSafeChunkSeparator:a((d,u)=>this.assertSafeChunkSeparator(d,u),"assertSafeChunkSeparator")})}decodePrelude(r,t){return dr(r,t,{defaultChecksum:this.defaultChecksum,defaultChunkSeparator:this.defaultChunkSeparator,defaultMaxDecodedBytes:this.defaultMaxDecodedBytes,defaultMaxEncodedChars:this.defaultMaxEncodedChars,urlSafe:this.urlSafe,paddingChar:this.paddingChar,bitLength:this.bitLength,bitsPerPadChar:this.bitsPerPadChar,usePowerOfTwo:this.usePowerOfTwo,dduCharCodeLookup:this.dduCharCodeLookup,dduCharCodeLookupOffset:this.dduCharCodeLookupOffset,charSetSize:this.dduChar.length,encryptionKey:this.encryptionKey,defaultRequireEncryption:this.defaultRequireEncryption,shouldObfuscate:a(n=>this.shouldObfuscate(n),"shouldObfuscate"),deobfuscate:a(n=>this.getObfuscationLayer().deobfuscate(n),"deobfuscate"),decodeChars:a((n,o)=>yr(n,o,this.getPayloadCodecContext()),"decodeChars"),reportDecodeStart:a(n=>{this.reportProgress(t,{processedBytes:0,totalBytes:n,percent:0,stage:"start"});},"reportDecodeStart"),reportBitpackDecode:a((n,o)=>{this.reportProgress(t,{processedBytes:n,totalBytes:o,percent:30,stage:"decode"});},"reportBitpackDecode")})}getPayloadCodecContext(){return this.payloadCodecContext}reportProgress(r,t){(r?.onProgress??this.defaultOnProgress)?.(t);}getAdapter(){return this.adapter===void 0&&this.adapterFactory!==void 0&&(this.adapter=this.adapterFactory()),this.adapter}getSyncGatewayContext(){if(!this.syncGatewayContext){let r={adapter:this.getAdapter(),encryptionKey:this.encryptionKey,keyDerivation:this.keyDerivation,encryptionKeyHash:this.encryptionKeyHash,setEncryptionKeyHash:a(t=>{this.encryptionKeyHash=t,r.encryptionKeyHash=t;},"setEncryptionKeyHash")};this.syncGatewayContext=r;}return this.syncGatewayContext}getObfuscationLayer(){if(!this.obfuscationLayer){if(!this.obfuscationLayerFactory)throw new n("[Ddu64 obfuscation] No obfuscation layer is wired. Use Ddu64Node/Ddu64Browser (batteries-included), or inject `obfuscationLayerFactory` when constructing Ddu64Core directly.");this.obfuscationLayer=this.obfuscationLayerFactory(gr(this.dduChar,this.paddingChar));}return this.obfuscationLayer}shouldObfuscate(r){return r?.obfuscate??this.defaultObfuscate}assertSafeChunkSeparator(r,t){if(!(t.length===0||this.isLineBreakSeparator(t))&&r.includes(t))throw new c(`[Ddu64 chunking] Unsafe chunkSeparator "${t}" appears in encoded output. Use a separator that cannot be produced by the charset, footer, checksum, or URL-safe output.`)}isLineBreakSeparator(r){return r===`
|
|
8
|
-
`||r===`\r
|
|
9
|
-
`||r==="\r"}};function ct(e,r,t,n){try{return t?Le(e,r,n):!1}catch(o){throw p(o)?o:new j(q$1(o),o)}}a(ct,"validateFinalCharsetConfiguration");var Tr=class e{static{a(this,"CharsetBuilder");}chars=[];constructor(){}static create(){return new e}static fromUnicodeRange(r,t){return new e().addUnicodeRange(r,t)}static fromString(r){return new e().addString(r)}static base64(){return new e().addString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")}static base32(){return new e().addString("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")}static uppercase(){return e.fromUnicodeRange(65,90)}static lowercase(){return e.fromUnicodeRange(97,122)}static digits(){return e.fromUnicodeRange(48,57)}static hangulJamo(){return new e().addUnicodeRange(4352,4370).addUnicodeRange(4449,4469).addUnicodeRange(4520,4546)}addUnicodeRange(r,t){if(!Number.isInteger(r)||!Number.isInteger(t)||r<0||t>1114111||r>t)throw new RangeError("Unicode range must use integer code points with 0 <= start <= end <= 0x10FFFF");for(let n=r;n<=t;n++)this.chars.push(String.fromCodePoint(n));return this}addString(r){return typeof r=="string"?this.chars.push(...r):this.chars.push(...r),this}add(...r){return this.chars.push(...r),this}excludeConfusing(){let r=new Set(["0","O","o","1","l","I","i","|","L"]);return this.chars=this.chars.filter(t=>!r.has(t)),this}exclude(...r){let t=new Set(r);return this.chars=this.chars.filter(n=>!t.has(n)),this}excludeUrlUnsafe(){let r=new Set(["+","/","=","?","&","#","%"," "]);return this.chars=this.chars.filter(t=>!r.has(t)),this}unique(){return this.chars=[...new Set(this.chars)],this}shuffle(r){let t=r!==void 0?this.seededRandom(r):Math.random;for(let n=this.chars.length-1;n>0;n--){let o=Math.floor(t()*(n+1));[this.chars[n],this.chars[o]]=[this.chars[o],this.chars[n]];}return this}seededRandom(r){let t=r|0||1;return ()=>(t^=t<<13,t^=t>>17,t^=t<<5,(t>>>0)/4294967296)}limit(r){if(!Number.isSafeInteger(r)||r<0)throw new RangeError("Charset limit must be a non-negative safe integer");return this.chars=this.chars.slice(0,r),this}limitToPowerOfTwo(){let r=this.chars.length;if(r===0)return this;let t=1<<Math.floor(Math.log2(r));return this.chars=this.chars.slice(0,t),this}sort(){return this.chars.sort(),this}reverse(){return this.chars.reverse(),this}get length(){return this.chars.length}buildString(){return this.chars.join("")}build(){return [...this.chars]}buildWithPadding(r){let t=[...this.chars],n=r;if(!n){let o=["=",".","_","-","~","!"];for(let i of o)if(!t.includes(i)){n=i;break}if(!n)throw new Error("Cannot find suitable padding character")}if(n.length!==1)throw new Error("Padding character must be one UTF-16 code unit");if(t.includes(n))throw new Error("Padding character must not appear in charset");return {charset:t,padding:n}}};export{Ae as a,Xe as b,x as c,Zr as d,$t as e,Vt as f,gr as g,k as h,Lr as i,Tr as j};
|