@lubomirklimes/character-runtime 0.0.0-stage → 0.1.0-preview.1
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/LICENSE +21 -0
- package/README.md +89 -2
- package/dist/acs/acs15.d.ts +9 -0
- package/dist/acs/acs15.js +382 -0
- package/dist/acs/acs2-reader.d.ts +2 -0
- package/dist/acs/acs2-reader.js +277 -0
- package/dist/acs/binary.d.ts +1 -0
- package/dist/acs/binary.js +107 -0
- package/dist/acs/compound-file.d.ts +1 -0
- package/dist/acs/compound-file.js +326 -0
- package/dist/acs/document.d.ts +33 -0
- package/dist/acs/document.js +99 -0
- package/dist/acs/errors.d.ts +28 -0
- package/dist/acs/errors.js +41 -0
- package/dist/acs/image.d.ts +30 -0
- package/dist/acs/image.js +113 -0
- package/dist/acs/index.d.ts +11 -0
- package/dist/acs/index.js +10 -0
- package/dist/acs/lz.d.ts +7 -0
- package/dist/acs/lz.js +102 -0
- package/dist/acs/metadata.d.ts +14 -0
- package/dist/acs/metadata.js +126 -0
- package/dist/acs/model.d.ts +130 -0
- package/dist/acs/model.js +12 -0
- package/dist/acs/mouth.d.ts +37 -0
- package/dist/acs/mouth.js +43 -0
- package/dist/acs/wave.d.ts +53 -0
- package/dist/acs/wave.js +422 -0
- package/dist/browser/animation-frame-clock.d.ts +18 -0
- package/dist/browser/animation-frame-clock.js +42 -0
- package/dist/browser/canvas-renderer.d.ts +50 -0
- package/dist/browser/canvas-renderer.js +145 -0
- package/dist/browser/host.d.ts +84 -0
- package/dist/browser/host.js +206 -0
- package/dist/browser/index.d.ts +6 -0
- package/dist/browser/index.js +8 -0
- package/dist/browser/web-audio.d.ts +48 -0
- package/dist/browser/web-audio.js +205 -0
- package/dist/browser/web-speech.d.ts +131 -0
- package/dist/browser/web-speech.js +302 -0
- package/dist/core/activities.d.ts +10 -0
- package/dist/core/activities.js +479 -0
- package/dist/core/agent.d.ts +263 -0
- package/dist/core/agent.js +764 -0
- package/dist/core/audio.d.ts +17 -0
- package/dist/core/audio.js +174 -0
- package/dist/core/balloon.d.ts +43 -0
- package/dist/core/balloon.js +94 -0
- package/dist/core/clock.d.ts +32 -0
- package/dist/core/clock.js +51 -0
- package/dist/core/compositor.d.ts +22 -0
- package/dist/core/compositor.js +67 -0
- package/dist/core/events.d.ts +131 -0
- package/dist/core/events.js +1 -0
- package/dist/core/host.d.ts +29 -0
- package/dist/core/host.js +77 -0
- package/dist/core/index.d.ts +16 -0
- package/dist/core/index.js +13 -0
- package/dist/core/lipsync.d.ts +41 -0
- package/dist/core/lipsync.js +209 -0
- package/dist/core/random.d.ts +52 -0
- package/dist/core/random.js +105 -0
- package/dist/core/request.d.ts +68 -0
- package/dist/core/request.js +131 -0
- package/dist/core/resources.d.ts +70 -0
- package/dist/core/resources.js +243 -0
- package/dist/core/scheduler.d.ts +25 -0
- package/dist/core/scheduler.js +766 -0
- package/dist/core/source.d.ts +21 -0
- package/dist/core/source.js +54 -0
- package/dist/core/speech.d.ts +91 -0
- package/dist/core/speech.js +86 -0
- package/dist/core/text.d.ts +38 -0
- package/dist/core/text.js +97 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/package.json +68 -4
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { equalsIgnoreCase, foldCase, guidText, u16, u32, utf16 } from './binary.js';
|
|
2
|
+
import { AcsFormatError } from './errors.js';
|
|
3
|
+
import { MAX_FILE_BYTES } from './acs2-reader.js';
|
|
4
|
+
const MAX_REG_SECT = 0xfffffffa, DIF_SECT = 0xfffffffc, FAT_SECT = 0xfffffffd, END_OF_CHAIN = 0xfffffffe, FREE_SECT = 0xffffffff, NO_STREAM = 0xffffffff;
|
|
5
|
+
const SIGNATURE = [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1];
|
|
6
|
+
const MAX_STREAM_BYTES = 64 * 1024 * 1024;
|
|
7
|
+
const MAX_DIRECTORY_ENTRIES = 65_536;
|
|
8
|
+
function container(message) {
|
|
9
|
+
return new AcsFormatError('container', message);
|
|
10
|
+
}
|
|
11
|
+
function limit(message) {
|
|
12
|
+
return new AcsFormatError('limit', message);
|
|
13
|
+
}
|
|
14
|
+
/** @internal True when the bytes start with the 8-byte compound-file signature. */
|
|
15
|
+
export function hasCompoundFileSignature(data) {
|
|
16
|
+
if (data.length < 8)
|
|
17
|
+
return false;
|
|
18
|
+
for (let i = 0; i < 8; i++)
|
|
19
|
+
if (data[i] !== SIGNATURE[i])
|
|
20
|
+
return false;
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @internal A bounded, read-only reader of the Compound File Binary format subset that ACS 1.5 characters use (ACS15.md §2): version 3
|
|
25
|
+
* and 4 headers, DIFAT chains, FAT and mini-FAT chains, the root mini stream and the root's streams. Every sector number is checked,
|
|
26
|
+
* every chain is cycle-checked by length and sector ownership, and sizes are bounded. Failures are `container` or `limit`.
|
|
27
|
+
*/
|
|
28
|
+
export class CompoundFile {
|
|
29
|
+
bytes;
|
|
30
|
+
majorVersion;
|
|
31
|
+
rootClsid;
|
|
32
|
+
streams;
|
|
33
|
+
sectorSize;
|
|
34
|
+
miniSectorSize;
|
|
35
|
+
sectorCount;
|
|
36
|
+
fat;
|
|
37
|
+
miniFat;
|
|
38
|
+
miniStream;
|
|
39
|
+
byName = new Map();
|
|
40
|
+
constructor(bytes) {
|
|
41
|
+
this.bytes = bytes;
|
|
42
|
+
const data = bytes;
|
|
43
|
+
if (data.length > MAX_FILE_BYTES)
|
|
44
|
+
throw limit('Compound file exceeds the file size policy.');
|
|
45
|
+
if (data.length < 512)
|
|
46
|
+
throw container('Truncated compound-file header.');
|
|
47
|
+
if (!hasCompoundFileSignature(data))
|
|
48
|
+
throw container('Missing compound-file signature.');
|
|
49
|
+
const major = u16(data, 26);
|
|
50
|
+
this.majorVersion = major;
|
|
51
|
+
if (u16(data, 28) !== 0xfffe)
|
|
52
|
+
throw container('Unsupported byte order mark.');
|
|
53
|
+
const sectorShift = u16(data, 30), miniShift = u16(data, 32);
|
|
54
|
+
if (major === 3 ? sectorShift !== 9 : major === 4 ? sectorShift !== 12 : true)
|
|
55
|
+
throw container(`Unsupported compound-file version ${major}.`);
|
|
56
|
+
if (miniShift !== 6)
|
|
57
|
+
throw container(`Unsupported mini sector shift ${miniShift}.`);
|
|
58
|
+
const sectorSize = 1 << sectorShift, miniSectorSize = 1 << miniShift;
|
|
59
|
+
this.sectorSize = sectorSize;
|
|
60
|
+
this.miniSectorSize = miniSectorSize;
|
|
61
|
+
const directorySectors = u32(data, 40), fatSectors = u32(data, 44), firstDirectory = u32(data, 48);
|
|
62
|
+
const miniCutoff = u32(data, 56);
|
|
63
|
+
const firstMiniFat = u32(data, 60), miniFatSectors = u32(data, 64), firstDifat = u32(data, 68), difatSectors = u32(data, 72);
|
|
64
|
+
if (major === 3 && directorySectors !== 0)
|
|
65
|
+
throw container('Version 3 compound files must not declare a directory sector count.');
|
|
66
|
+
if (miniCutoff !== 4096)
|
|
67
|
+
throw container(`Unsupported mini-stream cutoff ${miniCutoff}.`);
|
|
68
|
+
if (data.length < sectorSize)
|
|
69
|
+
throw container('Truncated compound-file header sector.');
|
|
70
|
+
const body = data.length - sectorSize;
|
|
71
|
+
const count = Math.floor((body + sectorSize - 1) / sectorSize);
|
|
72
|
+
this.sectorCount = count;
|
|
73
|
+
const owner = new Int32Array(count);
|
|
74
|
+
const OWNER_FAT = -1, OWNER_DIFAT = -2, OWNER_DIRECTORY = -3, OWNER_MINI_FAT = -4, OWNER_MINI_STREAM = -5;
|
|
75
|
+
const own = (sector, id, what) => {
|
|
76
|
+
if (sector >= count)
|
|
77
|
+
throw container(`${what} references sector ${sector} outside the file.`);
|
|
78
|
+
if (owner[sector] === id)
|
|
79
|
+
throw container(`${what} chain is cyclic (sector ${sector} repeats).`);
|
|
80
|
+
if (owner[sector] !== 0)
|
|
81
|
+
throw container(`${what} sector ${sector} is already used by another structure.`);
|
|
82
|
+
owner[sector] = id;
|
|
83
|
+
};
|
|
84
|
+
if (fatSectors > count)
|
|
85
|
+
throw container('FAT sector count exceeds the file.');
|
|
86
|
+
if (difatSectors > count)
|
|
87
|
+
throw container('DIFAT sector count exceeds the file.');
|
|
88
|
+
const fatList = [];
|
|
89
|
+
for (let i = 0; i < 109 && fatList.length < fatSectors; i++)
|
|
90
|
+
fatList.push(u32(data, 76 + 4 * i));
|
|
91
|
+
for (let i = fatList.length; i < 109; i++)
|
|
92
|
+
if (u32(data, 76 + 4 * i) !== FREE_SECT)
|
|
93
|
+
throw container('Unused header DIFAT entries must be free.');
|
|
94
|
+
let difat = firstDifat;
|
|
95
|
+
const perDifat = sectorSize / 4 - 1;
|
|
96
|
+
let difatSeen = 0;
|
|
97
|
+
while (fatList.length < fatSectors) {
|
|
98
|
+
if (difat === END_OF_CHAIN || difat === FREE_SECT)
|
|
99
|
+
throw container('DIFAT chain ends before every FAT sector is listed.');
|
|
100
|
+
if (++difatSeen > difatSectors)
|
|
101
|
+
throw container('DIFAT chain is longer than declared (or cyclic).');
|
|
102
|
+
own(difat, OWNER_DIFAT, 'DIFAT');
|
|
103
|
+
const s = this.sector(difat);
|
|
104
|
+
for (let i = 0; i < perDifat && fatList.length < fatSectors; i++)
|
|
105
|
+
fatList.push(u32(data, s + 4 * i));
|
|
106
|
+
difat = u32(data, s + 4 * perDifat);
|
|
107
|
+
}
|
|
108
|
+
if (difatSeen !== difatSectors)
|
|
109
|
+
throw container('DIFAT sector count does not match the chain.');
|
|
110
|
+
if (difatSectors === 0 && firstDifat !== END_OF_CHAIN && firstDifat !== FREE_SECT)
|
|
111
|
+
throw container('DIFAT start without DIFAT sectors.');
|
|
112
|
+
const entriesPerSector = sectorSize / 4;
|
|
113
|
+
if (fatList.length * entriesPerSector < count)
|
|
114
|
+
throw container('FAT does not cover every sector of the file.');
|
|
115
|
+
const fat = new Uint32Array(count);
|
|
116
|
+
this.fat = fat;
|
|
117
|
+
for (let i = 0; i < fatList.length; i++) {
|
|
118
|
+
const sector = fatList[i];
|
|
119
|
+
own(sector, OWNER_FAT, 'FAT');
|
|
120
|
+
const s = this.sector(sector);
|
|
121
|
+
for (let j = 0; j < entriesPerSector; j++) {
|
|
122
|
+
const at = i * entriesPerSector + j, value = u32(data, s + 4 * j);
|
|
123
|
+
if (at < count)
|
|
124
|
+
fat[at] = value;
|
|
125
|
+
else if (value !== FREE_SECT)
|
|
126
|
+
throw container(`FAT entry ${at} beyond the last sector is not free.`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
for (const sector of fatList)
|
|
130
|
+
if (fat[sector] !== FAT_SECT)
|
|
131
|
+
throw container(`FAT sector ${sector} is not marked as FAT in the FAT.`);
|
|
132
|
+
for (let i = 0; i < count; i++)
|
|
133
|
+
if (owner[i] === OWNER_DIFAT && fat[i] !== DIF_SECT)
|
|
134
|
+
throw container(`DIFAT sector ${i} is not marked as DIFAT in the FAT.`);
|
|
135
|
+
const directoryChain = this.chain(firstDirectory, OWNER_DIRECTORY, 'Directory', own);
|
|
136
|
+
if (directoryChain.length === 0)
|
|
137
|
+
throw container('Empty directory chain.');
|
|
138
|
+
if (major === 4 && directorySectors !== 0 && directorySectors !== directoryChain.length)
|
|
139
|
+
throw container('Directory sector count does not match the chain.');
|
|
140
|
+
const entryCount = directoryChain.length * (sectorSize / 128);
|
|
141
|
+
if (entryCount > MAX_DIRECTORY_ENTRIES)
|
|
142
|
+
throw limit('Directory exceeds the entry policy.');
|
|
143
|
+
const directory = new Uint8Array(entryCount * 128);
|
|
144
|
+
directoryChain.forEach((sector, i) => directory.set(data.subarray(this.sector(sector), this.sector(sector) + sectorSize), i * sectorSize));
|
|
145
|
+
const entryAt = (i) => this.readEntry(directory, i);
|
|
146
|
+
const root = entryAt(0);
|
|
147
|
+
if (root.type !== 5)
|
|
148
|
+
throw container('Directory entry 0 is not the root storage.');
|
|
149
|
+
this.rootClsid = root.clsid;
|
|
150
|
+
const miniFatChain = this.chain(firstMiniFat, OWNER_MINI_FAT, 'Mini FAT', own);
|
|
151
|
+
if (miniFatChain.length !== miniFatSectors)
|
|
152
|
+
throw container('Mini FAT sector count does not match the chain.');
|
|
153
|
+
const miniFat = new Uint32Array(miniFatChain.length * entriesPerSector);
|
|
154
|
+
miniFatChain.forEach((sector, i) => {
|
|
155
|
+
const s = this.sector(sector);
|
|
156
|
+
for (let j = 0; j < entriesPerSector; j++)
|
|
157
|
+
miniFat[i * entriesPerSector + j] = u32(data, s + 4 * j);
|
|
158
|
+
});
|
|
159
|
+
this.miniFat = miniFat;
|
|
160
|
+
if (root.size === 0)
|
|
161
|
+
this.miniStream = new Uint8Array(0);
|
|
162
|
+
else {
|
|
163
|
+
const chain = this.chain(root.start, OWNER_MINI_STREAM, 'Mini stream', own);
|
|
164
|
+
this.checkFits(chain, root.size, 'Mini stream');
|
|
165
|
+
this.miniStream = this.readChain(chain, root.size);
|
|
166
|
+
}
|
|
167
|
+
const miniSectors = Math.floor((root.size + miniSectorSize - 1) / miniSectorSize);
|
|
168
|
+
const miniOwner = new Int32Array(Math.min(miniFat.length, miniSectors));
|
|
169
|
+
const list = [];
|
|
170
|
+
const visited = new Uint8Array(entryCount);
|
|
171
|
+
const pending = [];
|
|
172
|
+
if (root.child !== NO_STREAM)
|
|
173
|
+
pending.push(root.child);
|
|
174
|
+
visited[0] = 1;
|
|
175
|
+
let declared = 0, streamId = 1;
|
|
176
|
+
while (pending.length > 0) {
|
|
177
|
+
const id = pending.pop();
|
|
178
|
+
if (id >= entryCount)
|
|
179
|
+
throw container(`Directory reference ${id} outside the directory.`);
|
|
180
|
+
if (visited[id])
|
|
181
|
+
throw container(`Directory entry ${id} is referenced twice (cyclic or shared tree).`);
|
|
182
|
+
visited[id] = 1;
|
|
183
|
+
const e = entryAt(id);
|
|
184
|
+
if (e.type !== 1 && e.type !== 2)
|
|
185
|
+
throw container(`Directory entry ${id} in the root tree is not a stream or storage.`);
|
|
186
|
+
if (e.left !== NO_STREAM)
|
|
187
|
+
pending.push(e.left);
|
|
188
|
+
if (e.right !== NO_STREAM)
|
|
189
|
+
pending.push(e.right);
|
|
190
|
+
if (e.type === 1)
|
|
191
|
+
continue; // a nested storage: never entered
|
|
192
|
+
declared += e.size;
|
|
193
|
+
if (declared > MAX_FILE_BYTES)
|
|
194
|
+
throw limit('Declared stream sizes exceed the aggregate policy.');
|
|
195
|
+
const mini = e.size > 0 && e.size < miniCutoff;
|
|
196
|
+
const sid = ++streamId;
|
|
197
|
+
if (mini)
|
|
198
|
+
this.miniChain(e.start, e.size, sid, miniOwner, e.name);
|
|
199
|
+
else if (e.size > 0)
|
|
200
|
+
this.checkFits(this.chain(e.start, sid, `Stream '${e.name}'`, own), e.size, `Stream '${e.name}'`);
|
|
201
|
+
const stream = { name: e.name, length: e.size, entryIndex: id, inMiniStream: mini };
|
|
202
|
+
const key = foldCase(e.name);
|
|
203
|
+
if (this.byName.has(key))
|
|
204
|
+
throw container(`Ambiguous root stream name '${e.name}'.`);
|
|
205
|
+
this.byName.set(key, { stream, start: e.start });
|
|
206
|
+
list.push(stream);
|
|
207
|
+
}
|
|
208
|
+
list.sort((a, b) => a.entryIndex - b.entryIndex);
|
|
209
|
+
this.streams = list;
|
|
210
|
+
}
|
|
211
|
+
/** The root stream named `name` (compared ignoring case), or null. */
|
|
212
|
+
find(name) {
|
|
213
|
+
return this.byName.get(foldCase(name))?.stream ?? null;
|
|
214
|
+
}
|
|
215
|
+
/** The content of a root stream. */
|
|
216
|
+
read(stream) {
|
|
217
|
+
const known = this.byName.get(foldCase(stream.name));
|
|
218
|
+
if (!known || known.stream !== stream || !equalsIgnoreCase(known.stream.name, stream.name))
|
|
219
|
+
throw container('Stream does not belong to this file.');
|
|
220
|
+
const length = stream.length;
|
|
221
|
+
const result = new Uint8Array(length);
|
|
222
|
+
let s = known.start, at = 0;
|
|
223
|
+
if (stream.inMiniStream) {
|
|
224
|
+
while (at < length) {
|
|
225
|
+
const n = Math.min(this.miniSectorSize, length - at);
|
|
226
|
+
result.set(this.miniStream.subarray(s * this.miniSectorSize, s * this.miniSectorSize + n), at);
|
|
227
|
+
at += n;
|
|
228
|
+
s = this.miniFat[s];
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
while (at < length) {
|
|
233
|
+
const n = Math.min(this.sectorSize, length - at), start = (s + 1) * this.sectorSize;
|
|
234
|
+
result.set(this.bytes.subarray(start, start + n), at);
|
|
235
|
+
at += n;
|
|
236
|
+
s = this.fat[s];
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
241
|
+
sector(sector) {
|
|
242
|
+
const start = (sector + 1) * this.sectorSize;
|
|
243
|
+
if (sector >= this.sectorCount || start >= this.bytes.length)
|
|
244
|
+
throw container(`Sector ${sector} is outside the file.`);
|
|
245
|
+
if (this.bytes.length - start < this.sectorSize)
|
|
246
|
+
throw container(`Sector ${sector} is truncated.`);
|
|
247
|
+
return start;
|
|
248
|
+
}
|
|
249
|
+
chain(start, id, what, own) {
|
|
250
|
+
const chain = [];
|
|
251
|
+
let s = start;
|
|
252
|
+
while (s !== END_OF_CHAIN) {
|
|
253
|
+
if (s > MAX_REG_SECT || s >= this.sectorCount)
|
|
254
|
+
throw container(`${what} chain references invalid sector 0x${s.toString(16)}.`);
|
|
255
|
+
if (chain.length >= this.sectorCount)
|
|
256
|
+
throw container(`${what} chain is cyclic.`);
|
|
257
|
+
own(s, id, what);
|
|
258
|
+
chain.push(s);
|
|
259
|
+
s = this.fat[s];
|
|
260
|
+
}
|
|
261
|
+
return chain;
|
|
262
|
+
}
|
|
263
|
+
checkFits(chain, size, what) {
|
|
264
|
+
if (chain.length * this.sectorSize < size || (chain.length - 1) * this.sectorSize >= size)
|
|
265
|
+
throw container(`${what} size ${size} does not match its ${chain.length}-sector chain.`);
|
|
266
|
+
const last = size - (chain.length - 1) * this.sectorSize;
|
|
267
|
+
if ((chain[chain.length - 1] + 1) * this.sectorSize + last > this.bytes.length)
|
|
268
|
+
throw container(`${what} extends past the end of the file.`);
|
|
269
|
+
for (let i = 0; i < chain.length - 1; i++)
|
|
270
|
+
if ((chain[i] + 2) * this.sectorSize > this.bytes.length)
|
|
271
|
+
throw container(`${what} sector ${chain[i]} is truncated.`);
|
|
272
|
+
}
|
|
273
|
+
miniChain(start, size, id, owner, name) {
|
|
274
|
+
const needed = Math.floor((size + this.miniSectorSize - 1) / this.miniSectorSize);
|
|
275
|
+
let remaining = size, s = start, n = 0;
|
|
276
|
+
while (s !== END_OF_CHAIN) {
|
|
277
|
+
if (s >= this.miniFat.length || s >= owner.length)
|
|
278
|
+
throw container(`Stream '${name}' mini chain references invalid mini sector 0x${s.toString(16)}.`);
|
|
279
|
+
if (++n > needed)
|
|
280
|
+
throw container(`Stream '${name}' mini chain is longer than its size (or cyclic).`);
|
|
281
|
+
if (owner[s] !== 0)
|
|
282
|
+
throw container(`Stream '${name}' mini sector ${s} is already used by another stream.`);
|
|
283
|
+
owner[s] = id;
|
|
284
|
+
const used = Math.min(this.miniSectorSize, remaining);
|
|
285
|
+
if (s * this.miniSectorSize + used > this.miniStream.length)
|
|
286
|
+
throw container(`Stream '${name}' extends past the mini stream.`);
|
|
287
|
+
remaining -= used;
|
|
288
|
+
s = this.miniFat[s];
|
|
289
|
+
}
|
|
290
|
+
if (n !== needed)
|
|
291
|
+
throw container(`Stream '${name}' size ${size} does not match its ${n}-sector mini chain.`);
|
|
292
|
+
}
|
|
293
|
+
readChain(chain, length) {
|
|
294
|
+
const result = new Uint8Array(length);
|
|
295
|
+
let at = 0;
|
|
296
|
+
for (const s of chain) {
|
|
297
|
+
const n = Math.min(this.sectorSize, length - at), start = (s + 1) * this.sectorSize;
|
|
298
|
+
result.set(this.bytes.subarray(start, start + n), at);
|
|
299
|
+
at += n;
|
|
300
|
+
}
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
303
|
+
readEntry(directory, index) {
|
|
304
|
+
const e = index * 128;
|
|
305
|
+
const type = directory[e + 66];
|
|
306
|
+
if (type === 0)
|
|
307
|
+
return { name: '', type: 0, left: NO_STREAM, right: NO_STREAM, child: NO_STREAM, clsid: '', start: 0, size: 0 };
|
|
308
|
+
if (type !== 1 && type !== 2 && type !== 5)
|
|
309
|
+
throw container(`Directory entry ${index} has unsupported type ${type}.`);
|
|
310
|
+
const nameBytes = u16(directory, e + 64);
|
|
311
|
+
if (nameBytes < 2 || nameBytes > 64 || (nameBytes & 1) !== 0)
|
|
312
|
+
throw container(`Directory entry ${index} has an invalid name length ${nameBytes}.`);
|
|
313
|
+
if (u16(directory, e + nameBytes - 2) !== 0)
|
|
314
|
+
throw container(`Directory entry ${index} name is not terminated.`);
|
|
315
|
+
const name = utf16(directory, e, (nameBytes - 2) / 2);
|
|
316
|
+
if (name === null)
|
|
317
|
+
throw container(`Directory entry ${index} name is not valid UTF-16.`);
|
|
318
|
+
if (name.length === 0 && type !== 5)
|
|
319
|
+
throw container(`Directory entry ${index} has an empty name.`);
|
|
320
|
+
const low = u32(directory, e + 120), high = u32(directory, e + 124);
|
|
321
|
+
const size = this.majorVersion === 3 ? low : high * 0x100000000 + low; // version 3 readers ignore the high 32 bits
|
|
322
|
+
if (size > MAX_STREAM_BYTES)
|
|
323
|
+
throw limit(`Stream '${name}' exceeds the stream policy.`);
|
|
324
|
+
return { name, type, left: u32(directory, e + 68), right: u32(directory, e + 72), child: u32(directory, e + 76), clsid: guidText(directory, e + 80), start: u32(directory, e + 116), size };
|
|
325
|
+
}
|
|
326
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type UnavailableAnimation } from './acs15.js';
|
|
2
|
+
import { IndexedImage, type RgbaImage } from './image.js';
|
|
3
|
+
import { type CharacterMetadata } from './metadata.js';
|
|
4
|
+
import type { Character } from './model.js';
|
|
5
|
+
import { WaveAudio } from './wave.js';
|
|
6
|
+
/**
|
|
7
|
+
* A character file opened for playback: the read-only character model plus on-demand decoding of single images and sounds. Nothing is
|
|
8
|
+
* decoded when the file is opened (ACS 1.5 streams are expanded once to read their layout and then released).
|
|
9
|
+
*/
|
|
10
|
+
export interface CharacterDocument {
|
|
11
|
+
readonly character: Character;
|
|
12
|
+
readonly metadata: CharacterMetadata;
|
|
13
|
+
/** Animations the file lists but cannot provide (damaged ACS 1.5 streams), by name. Empty for ACS 2.x. */
|
|
14
|
+
readonly unavailableAnimations: readonly UnavailableAnimation[];
|
|
15
|
+
/** True when `name` (ignoring case) is an unavailable animation. */
|
|
16
|
+
isUnavailable(name: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Image `index` as validated palette indices. Throws {@link AcsFormatError}: `image-index` for a missing image, an undecodable-image
|
|
19
|
+
* code (`compression`, `image-bounds`, `image-length`, `unsupported-image`, `palette`) or `image-limit` / `unsupported-region`.
|
|
20
|
+
*/
|
|
21
|
+
readImage(index: number): IndexedImage;
|
|
22
|
+
/** Image `index` as RGBA (key index transparent). */
|
|
23
|
+
readImageRgba(index: number): RgbaImage;
|
|
24
|
+
/** Sound `index`. Throws for a missing index (`sound-index`) and for undecodable sounds (`not-supported`, `invalid-argument`). */
|
|
25
|
+
readSound(index: number): WaveAudio;
|
|
26
|
+
}
|
|
27
|
+
/** The format suggested by the first bytes: `acs15` for a compound file, `acs2` for the ACS 2.x signature, otherwise null. */
|
|
28
|
+
export declare function detectFormat(head: Uint8Array): 'acs2' | 'acs15' | null;
|
|
29
|
+
/**
|
|
30
|
+
* Opens an ACS 2.x or ACS 1.5 character from its bytes (the array is kept, not copied; it must not be modified). Throws
|
|
31
|
+
* {@link AcsFormatError} with the code of the first failing check (ACS.md §2, ACS15.md §7).
|
|
32
|
+
*/
|
|
33
|
+
export declare function openCharacterDocument(bytes: Uint8Array): CharacterDocument;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { foldCase } from './binary.js';
|
|
2
|
+
import { readAcs2, MAX_FILE_BYTES } from './acs2-reader.js';
|
|
3
|
+
import { Acs15File } from './acs15.js';
|
|
4
|
+
import { hasCompoundFileSignature } from './compound-file.js';
|
|
5
|
+
import { AcsFormatError } from './errors.js';
|
|
6
|
+
import { checkDimensions, IndexedImage, indexedToRgba, MAX_IMAGES, parseImageRecord, validateIndices } from './image.js';
|
|
7
|
+
import { characterMetadata } from './metadata.js';
|
|
8
|
+
import { WaveAudio } from './wave.js';
|
|
9
|
+
class DocumentBase {
|
|
10
|
+
character;
|
|
11
|
+
unavailableAnimations;
|
|
12
|
+
metadata;
|
|
13
|
+
unavailableKeys;
|
|
14
|
+
constructor(character, unavailableAnimations) {
|
|
15
|
+
this.character = character;
|
|
16
|
+
this.unavailableAnimations = unavailableAnimations;
|
|
17
|
+
this.metadata = characterMetadata(character);
|
|
18
|
+
this.unavailableKeys = new Set(unavailableAnimations.map((u) => foldCase(u.name)));
|
|
19
|
+
}
|
|
20
|
+
isUnavailable(name) {
|
|
21
|
+
return this.unavailableKeys.has(foldCase(name));
|
|
22
|
+
}
|
|
23
|
+
readImageRgba(index) {
|
|
24
|
+
return indexedToRgba(this.readImage(index), this.character.palette, this.character.transparentIndex);
|
|
25
|
+
}
|
|
26
|
+
checkImageIndex(index) {
|
|
27
|
+
if (!Number.isInteger(index) || index < 0 || index >= this.character.imageCount)
|
|
28
|
+
throw new AcsFormatError('image-index', 'Missing image reference.');
|
|
29
|
+
}
|
|
30
|
+
checkSoundIndex(index) {
|
|
31
|
+
if (!Number.isInteger(index) || index < 0 || index >= this.character.soundCount)
|
|
32
|
+
throw new AcsFormatError('sound-index', 'Missing sound.');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
class Acs2Document extends DocumentBase {
|
|
36
|
+
bytes;
|
|
37
|
+
images;
|
|
38
|
+
sounds;
|
|
39
|
+
constructor(bytes) {
|
|
40
|
+
const file = readAcs2(bytes);
|
|
41
|
+
super(file.character, []);
|
|
42
|
+
this.bytes = bytes;
|
|
43
|
+
this.images = file.images;
|
|
44
|
+
this.sounds = file.sounds;
|
|
45
|
+
if (file.images.length > MAX_IMAGES)
|
|
46
|
+
throw new AcsFormatError('image-limit', 'Image count exceeds decode policy.');
|
|
47
|
+
checkDimensions(file.character.width, file.character.height);
|
|
48
|
+
}
|
|
49
|
+
readImage(index) {
|
|
50
|
+
this.checkImageIndex(index);
|
|
51
|
+
const block = this.images[index];
|
|
52
|
+
const image = parseImageRecord(this.bytes.subarray(block.offset, block.offset + block.size));
|
|
53
|
+
validateIndices(image, this.character.palette, this.character.transparentIndex);
|
|
54
|
+
return image;
|
|
55
|
+
}
|
|
56
|
+
readSound(index) {
|
|
57
|
+
this.checkSoundIndex(index);
|
|
58
|
+
const block = this.sounds[index];
|
|
59
|
+
return WaveAudio.read(this.bytes.subarray(block.offset, block.offset + block.size));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
class Acs15Document extends DocumentBase {
|
|
63
|
+
file;
|
|
64
|
+
constructor(file) {
|
|
65
|
+
super(file.character, file.unavailable);
|
|
66
|
+
this.file = file;
|
|
67
|
+
}
|
|
68
|
+
readImage(index) {
|
|
69
|
+
this.checkImageIndex(index);
|
|
70
|
+
const o = this.file.images[index];
|
|
71
|
+
checkDimensions(o.width, o.height);
|
|
72
|
+
const data = this.file.decodedStream(o.animation).slice(o.pixelOffset, o.pixelOffset + o.pixelLength);
|
|
73
|
+
const image = new IndexedImage(o.width, o.height, data);
|
|
74
|
+
validateIndices(image, this.character.palette, this.character.transparentIndex);
|
|
75
|
+
return image;
|
|
76
|
+
}
|
|
77
|
+
readSound(index) {
|
|
78
|
+
this.checkSoundIndex(index);
|
|
79
|
+
const o = this.file.sounds[index];
|
|
80
|
+
return WaveAudio.read(this.file.decodedStream(o.animation).slice(o.dataOffset, o.dataOffset + o.length));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** The format suggested by the first bytes: `acs15` for a compound file, `acs2` for the ACS 2.x signature, otherwise null. */
|
|
84
|
+
export function detectFormat(head) {
|
|
85
|
+
if (hasCompoundFileSignature(head))
|
|
86
|
+
return 'acs15';
|
|
87
|
+
if (head.length >= 4 && head[0] === 0xc3 && head[1] === 0xab && head[2] === 0xcd && head[3] === 0xab)
|
|
88
|
+
return 'acs2';
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Opens an ACS 2.x or ACS 1.5 character from its bytes (the array is kept, not copied; it must not be modified). Throws
|
|
93
|
+
* {@link AcsFormatError} with the code of the first failing check (ACS.md §2, ACS15.md §7).
|
|
94
|
+
*/
|
|
95
|
+
export function openCharacterDocument(bytes) {
|
|
96
|
+
if (bytes.length > MAX_FILE_BYTES)
|
|
97
|
+
throw new AcsFormatError('limit', 'File exceeds 256 MiB policy.');
|
|
98
|
+
return detectFormat(bytes) === 'acs15' ? new Acs15Document(new Acs15File(bytes)) : new Acs2Document(bytes);
|
|
99
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors with portable codes. Codes are normative (conformance codes of ACS.md §10, ACS15.md §7 and Runtime.md §4.2); message text
|
|
3
|
+
* is diagnostic only.
|
|
4
|
+
*/
|
|
5
|
+
export declare class CharacterRuntimeError extends Error {
|
|
6
|
+
readonly code: string;
|
|
7
|
+
constructor(code: string, message: string);
|
|
8
|
+
}
|
|
9
|
+
/** A character file, image record or compressed stream that cannot be read. */
|
|
10
|
+
export declare class AcsFormatError extends CharacterRuntimeError {
|
|
11
|
+
/**
|
|
12
|
+
* True for image codes that describe a damaged or unsupported image block: nothing is drawn for such an image, and it stops painting of
|
|
13
|
+
* the layers in front of it (Runtime.md §8).
|
|
14
|
+
*/
|
|
15
|
+
get isUndecodableImage(): boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Content that is valid but deliberately not supported (for example an audio codec that is not decoded). Code `not-supported`. */
|
|
18
|
+
export declare class NotSupportedError extends CharacterRuntimeError {
|
|
19
|
+
constructor(message: string);
|
|
20
|
+
}
|
|
21
|
+
/** A malformed argument or a malformed supported file (for example a damaged WAVE sound). Code `invalid-argument`. */
|
|
22
|
+
export declare class InvalidArgumentError extends CharacterRuntimeError {
|
|
23
|
+
constructor(message: string);
|
|
24
|
+
}
|
|
25
|
+
/** An operation on a disposed object. Code `disposed`. */
|
|
26
|
+
export declare class DisposedError extends CharacterRuntimeError {
|
|
27
|
+
constructor(message?: string);
|
|
28
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors with portable codes. Codes are normative (conformance codes of ACS.md §10, ACS15.md §7 and Runtime.md §4.2); message text
|
|
3
|
+
* is diagnostic only.
|
|
4
|
+
*/
|
|
5
|
+
export class CharacterRuntimeError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
constructor(code, message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.name = new.target.name;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** A character file, image record or compressed stream that cannot be read. */
|
|
14
|
+
export class AcsFormatError extends CharacterRuntimeError {
|
|
15
|
+
/**
|
|
16
|
+
* True for image codes that describe a damaged or unsupported image block: nothing is drawn for such an image, and it stops painting of
|
|
17
|
+
* the layers in front of it (Runtime.md §8).
|
|
18
|
+
*/
|
|
19
|
+
get isUndecodableImage() {
|
|
20
|
+
return UNDECODABLE_IMAGE_CODES.has(this.code);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const UNDECODABLE_IMAGE_CODES = new Set(['compression', 'image-bounds', 'image-length', 'unsupported-image', 'palette']);
|
|
24
|
+
/** Content that is valid but deliberately not supported (for example an audio codec that is not decoded). Code `not-supported`. */
|
|
25
|
+
export class NotSupportedError extends CharacterRuntimeError {
|
|
26
|
+
constructor(message) {
|
|
27
|
+
super('not-supported', message);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** A malformed argument or a malformed supported file (for example a damaged WAVE sound). Code `invalid-argument`. */
|
|
31
|
+
export class InvalidArgumentError extends CharacterRuntimeError {
|
|
32
|
+
constructor(message) {
|
|
33
|
+
super('invalid-argument', message);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** An operation on a disposed object. Code `disposed`. */
|
|
37
|
+
export class DisposedError extends CharacterRuntimeError {
|
|
38
|
+
constructor(message = 'The object has been disposed.') {
|
|
39
|
+
super('disposed', message);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Largest image or canvas side (ACS.md §10). */
|
|
2
|
+
export declare const MAX_DIMENSION = 2048;
|
|
3
|
+
/** Largest image or canvas in RGBA bytes (16 MiB). */
|
|
4
|
+
export declare const MAX_BITMAP_BYTES: number;
|
|
5
|
+
/** Most images in one character. */
|
|
6
|
+
export declare const MAX_IMAGES = 20000;
|
|
7
|
+
/** Most layers on one frame that playback accepts (checked for a request, not for a single composition). */
|
|
8
|
+
export declare const MAX_LAYERS_PER_FRAME = 1024;
|
|
9
|
+
/**
|
|
10
|
+
* A decoded image in its stored representation: palette indices, one byte per pixel, rows bottom-up, each padded to a multiple of four
|
|
11
|
+
* bytes (ACS.md §6.2). Read-only by contract.
|
|
12
|
+
*/
|
|
13
|
+
export declare class IndexedImage {
|
|
14
|
+
readonly width: number;
|
|
15
|
+
readonly height: number;
|
|
16
|
+
readonly indices: Uint8Array;
|
|
17
|
+
readonly stride: number;
|
|
18
|
+
constructor(width: number, height: number, indices: Uint8Array);
|
|
19
|
+
/** The palette index at visible (top-down) coordinates. */
|
|
20
|
+
at(x: number, y: number): number;
|
|
21
|
+
get byteLength(): number;
|
|
22
|
+
}
|
|
23
|
+
/** A straight-alpha RGBA image, rows top-down without padding. */
|
|
24
|
+
export interface RgbaImage {
|
|
25
|
+
readonly width: number;
|
|
26
|
+
readonly height: number;
|
|
27
|
+
readonly pixels: Uint8ClampedArray;
|
|
28
|
+
}
|
|
29
|
+
/** Expands indices to RGBA: the transparent index is (0, 0, 0, 0), every other index its palette color with alpha 255 (ACS.md §6.1). */
|
|
30
|
+
export declare function indexedToRgba(image: IndexedImage, palette: Uint32Array, transparent: number): RgbaImage;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { u16, u32 } from './binary.js';
|
|
2
|
+
import { AcsFormatError } from './errors.js';
|
|
3
|
+
import { decodeLz, MAX_DECODED_BYTES } from './lz.js';
|
|
4
|
+
/** Largest image or canvas side (ACS.md §10). */
|
|
5
|
+
export const MAX_DIMENSION = 2048;
|
|
6
|
+
/** Largest image or canvas in RGBA bytes (16 MiB). */
|
|
7
|
+
export const MAX_BITMAP_BYTES = 16 * 1024 * 1024;
|
|
8
|
+
/** Most images in one character. */
|
|
9
|
+
export const MAX_IMAGES = 20_000;
|
|
10
|
+
/** Most layers on one frame that playback accepts (checked for a request, not for a single composition). */
|
|
11
|
+
export const MAX_LAYERS_PER_FRAME = 1024;
|
|
12
|
+
/**
|
|
13
|
+
* A decoded image in its stored representation: palette indices, one byte per pixel, rows bottom-up, each padded to a multiple of four
|
|
14
|
+
* bytes (ACS.md §6.2). Read-only by contract.
|
|
15
|
+
*/
|
|
16
|
+
export class IndexedImage {
|
|
17
|
+
width;
|
|
18
|
+
height;
|
|
19
|
+
indices;
|
|
20
|
+
stride;
|
|
21
|
+
constructor(width, height, indices) {
|
|
22
|
+
this.width = width;
|
|
23
|
+
this.height = height;
|
|
24
|
+
this.indices = indices;
|
|
25
|
+
this.stride = (width + 3) & ~3;
|
|
26
|
+
}
|
|
27
|
+
/** The palette index at visible (top-down) coordinates. */
|
|
28
|
+
at(x, y) {
|
|
29
|
+
return this.indices[(this.height - 1 - y) * this.stride + x];
|
|
30
|
+
}
|
|
31
|
+
get byteLength() {
|
|
32
|
+
return this.indices.length;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** @internal */
|
|
36
|
+
export function checkDimensions(width, height) {
|
|
37
|
+
if (width < 1 || height < 1 || width > MAX_DIMENSION || height > MAX_DIMENSION || width * height * 4 > MAX_BITMAP_BYTES)
|
|
38
|
+
throw new AcsFormatError('image-limit', `Dimensions ${width}x${height} exceed decode policy or are empty.`);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @internal Parses an ACS 2.x image record (ACS.md §7) to its padded indices, in the normative check order (the palette check follows
|
|
42
|
+
* separately in {@link validateIndices}).
|
|
43
|
+
*/
|
|
44
|
+
export function parseImageRecord(record) {
|
|
45
|
+
if (record.length < 10)
|
|
46
|
+
throw new AcsFormatError('image-bounds', 'Image header is truncated.');
|
|
47
|
+
const flag = record[0], width = u16(record, 1), height = u16(record, 3), compression = record[5], dataLength = u32(record, 6);
|
|
48
|
+
if (flag !== 1)
|
|
49
|
+
throw new AcsFormatError('unsupported-image', `Unsupported/empty image flag ${flag}.`);
|
|
50
|
+
checkDimensions(width, height);
|
|
51
|
+
const expected = ((width + 3) & ~3) * height;
|
|
52
|
+
if (expected > MAX_DECODED_BYTES)
|
|
53
|
+
throw new AcsFormatError('image-limit', 'Indexed output exceeds decompressor policy.');
|
|
54
|
+
if (dataLength > record.length - 10)
|
|
55
|
+
throw new AcsFormatError('image-bounds', 'Image payload exceeds its declared asset block.');
|
|
56
|
+
const payload = record.subarray(10, 10 + dataLength);
|
|
57
|
+
if (compression === 0 && payload.length !== expected)
|
|
58
|
+
throw new AcsFormatError('image-length', 'Uncompressed scanlines do not match padded dimensions.');
|
|
59
|
+
let indices;
|
|
60
|
+
if (compression === 1)
|
|
61
|
+
indices = decodeLz(payload, expected);
|
|
62
|
+
else if (compression === 0)
|
|
63
|
+
indices = payload;
|
|
64
|
+
else
|
|
65
|
+
throw new AcsFormatError('unsupported-image', `Unknown compression flag ${compression}.`);
|
|
66
|
+
const tail = record.subarray(10 + dataLength);
|
|
67
|
+
// The auxiliary region suffix is never interpreted; only its envelope is checked.
|
|
68
|
+
if (tail.length > 0 && (tail.length < 8 || u32(tail, 0) > tail.length - 8))
|
|
69
|
+
throw new AcsFormatError('unsupported-region', 'Unrecognized auxiliary region envelope.');
|
|
70
|
+
return new IndexedImage(width, height, indices);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @internal Checks every visible pixel against the palette, top-down: an index that is neither the transparent index nor below the
|
|
74
|
+
* palette count makes the image undecodable (`palette`).
|
|
75
|
+
*/
|
|
76
|
+
export function validateIndices(image, palette, transparent) {
|
|
77
|
+
checkDimensions(image.width, image.height);
|
|
78
|
+
if (image.indices.length !== image.stride * image.height)
|
|
79
|
+
throw new AcsFormatError('image-length', 'Indexed scanline byte count mismatch.');
|
|
80
|
+
if (palette.length > 256)
|
|
81
|
+
throw new AcsFormatError('palette', 'Palette has more than 256 entries.');
|
|
82
|
+
if (palette.length === 256)
|
|
83
|
+
return;
|
|
84
|
+
const { width, height, stride, indices } = image;
|
|
85
|
+
for (let y = 0; y < height; y++) {
|
|
86
|
+
const row = (height - 1 - y) * stride;
|
|
87
|
+
for (let x = 0; x < width; x++) {
|
|
88
|
+
const i = indices[row + x];
|
|
89
|
+
if (i !== transparent && i >= palette.length)
|
|
90
|
+
throw new AcsFormatError('palette', `Pixel index ${i} is outside palette.`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** Expands indices to RGBA: the transparent index is (0, 0, 0, 0), every other index its palette color with alpha 255 (ACS.md §6.1). */
|
|
95
|
+
export function indexedToRgba(image, palette, transparent) {
|
|
96
|
+
validateIndices(image, palette, transparent);
|
|
97
|
+
const { width, height, stride, indices } = image;
|
|
98
|
+
const pixels = new Uint8ClampedArray(width * height * 4);
|
|
99
|
+
for (let y = 0; y < height; y++) {
|
|
100
|
+
const row = (height - 1 - y) * stride;
|
|
101
|
+
for (let x = 0; x < width; x++) {
|
|
102
|
+
const i = indices[row + x];
|
|
103
|
+
if (i === transparent)
|
|
104
|
+
continue;
|
|
105
|
+
const color = palette[i], at = (y * width + x) * 4;
|
|
106
|
+
pixels[at] = (color >>> 16) & 0xff;
|
|
107
|
+
pixels[at + 1] = (color >>> 8) & 0xff;
|
|
108
|
+
pixels[at + 2] = color & 0xff;
|
|
109
|
+
pixels[at + 3] = 255;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { width, height, pixels };
|
|
113
|
+
}
|