@agentdocumentformat/cli 0.7.2

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.
Files changed (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -0
  3. package/dist/adf.mjs +162 -0
  4. package/dist/chunks/APEv2Parser-2CNNHMXV.mjs +22 -0
  5. package/dist/chunks/AiffParser-7BR4RL6G.mjs +162 -0
  6. package/dist/chunks/App-L5L37JI5.mjs +16747 -0
  7. package/dist/chunks/AsfParser-VVRSLFOM.mjs +538 -0
  8. package/dist/chunks/DsdiffParser-CMD4AX7A.mjs +156 -0
  9. package/dist/chunks/DsfParser-UOGZDS2M.mjs +94 -0
  10. package/dist/chunks/FlacParser-HB3T3CD4.mjs +23 -0
  11. package/dist/chunks/MP4Parser-66HBRUSX.mjs +973 -0
  12. package/dist/chunks/MatroskaParser-J3HUIMEW.mjs +579 -0
  13. package/dist/chunks/MpegParser-YW6LIUEW.mjs +442 -0
  14. package/dist/chunks/MusepackParser-PAUSXP7D.mjs +252 -0
  15. package/dist/chunks/OggParser-NUBV3GWC.mjs +359 -0
  16. package/dist/chunks/WavPackParser-WQAGT7TC.mjs +171 -0
  17. package/dist/chunks/WaveParser-EWLQVDX4.mjs +238 -0
  18. package/dist/chunks/adf-schema-JRU2BTOG.mjs +62 -0
  19. package/dist/chunks/build-QF5W473T.mjs +60 -0
  20. package/dist/chunks/chatgpt-subscription-BQGWYZXE.mjs +23 -0
  21. package/dist/chunks/chunk-2DIECGFL.mjs +6 -0
  22. package/dist/chunks/chunk-2NAP2ZF7.mjs +60 -0
  23. package/dist/chunks/chunk-3AT7IIP7.mjs +25696 -0
  24. package/dist/chunks/chunk-3GNIDM53.mjs +35 -0
  25. package/dist/chunks/chunk-3M4ZPOA3.mjs +1477 -0
  26. package/dist/chunks/chunk-4MQPTCXY.mjs +510 -0
  27. package/dist/chunks/chunk-5PO5PKRV.mjs +366 -0
  28. package/dist/chunks/chunk-5QU5VY7N.mjs +52 -0
  29. package/dist/chunks/chunk-5W7KES6P.mjs +436 -0
  30. package/dist/chunks/chunk-62NE4LG4.mjs +61 -0
  31. package/dist/chunks/chunk-64OKE4X3.mjs +45 -0
  32. package/dist/chunks/chunk-6GJ4QHRI.mjs +1278 -0
  33. package/dist/chunks/chunk-6VQEXLE2.mjs +144 -0
  34. package/dist/chunks/chunk-6XUV6EK6.mjs +41 -0
  35. package/dist/chunks/chunk-776TSXEP.mjs +43 -0
  36. package/dist/chunks/chunk-7CV2SA3H.mjs +285 -0
  37. package/dist/chunks/chunk-7MTRVW2U.mjs +3103 -0
  38. package/dist/chunks/chunk-7N2R2VCG.mjs +1434 -0
  39. package/dist/chunks/chunk-7T2YMTWL.mjs +374 -0
  40. package/dist/chunks/chunk-7XYNI52E.mjs +149 -0
  41. package/dist/chunks/chunk-APHX6HSV.mjs +7731 -0
  42. package/dist/chunks/chunk-APRU6PHC.mjs +40 -0
  43. package/dist/chunks/chunk-AUYKRQPJ.mjs +499 -0
  44. package/dist/chunks/chunk-DXWDD5XJ.mjs +136 -0
  45. package/dist/chunks/chunk-EWL5FG4I.mjs +39 -0
  46. package/dist/chunks/chunk-EYX2YLJW.mjs +117 -0
  47. package/dist/chunks/chunk-F5ELW46V.mjs +27 -0
  48. package/dist/chunks/chunk-G426FACA.mjs +49 -0
  49. package/dist/chunks/chunk-GEKSJHIV.mjs +2472 -0
  50. package/dist/chunks/chunk-HBUENVQL.mjs +570 -0
  51. package/dist/chunks/chunk-HPVFJYXR.mjs +112 -0
  52. package/dist/chunks/chunk-HWLWPXQ7.mjs +721 -0
  53. package/dist/chunks/chunk-I2HJYHFT.mjs +665 -0
  54. package/dist/chunks/chunk-I3UYSITV.mjs +68 -0
  55. package/dist/chunks/chunk-IC4JDZCI.mjs +3864 -0
  56. package/dist/chunks/chunk-IHDDCZBS.mjs +112 -0
  57. package/dist/chunks/chunk-IIGMZHQQ.mjs +10416 -0
  58. package/dist/chunks/chunk-KWFOS5WC.mjs +41 -0
  59. package/dist/chunks/chunk-LAZIXV2F.mjs +5290 -0
  60. package/dist/chunks/chunk-LFMB4PAA.mjs +10814 -0
  61. package/dist/chunks/chunk-M2RX3S2T.mjs +49 -0
  62. package/dist/chunks/chunk-M3WPIJYM.mjs +65 -0
  63. package/dist/chunks/chunk-NBTUWMGP.mjs +263 -0
  64. package/dist/chunks/chunk-NGK6PVSF.mjs +2676 -0
  65. package/dist/chunks/chunk-NZ7JTHEO.mjs +85 -0
  66. package/dist/chunks/chunk-OQN33RGQ.mjs +52 -0
  67. package/dist/chunks/chunk-RIX34QHC.mjs +2935 -0
  68. package/dist/chunks/chunk-SGUTYISF.mjs +16 -0
  69. package/dist/chunks/chunk-SLJ5L7PY.mjs +1473 -0
  70. package/dist/chunks/chunk-SLUKGXKH.mjs +68 -0
  71. package/dist/chunks/chunk-TMT32MXT.mjs +419 -0
  72. package/dist/chunks/chunk-UYY5M2PB.mjs +151 -0
  73. package/dist/chunks/chunk-VAUOM3IN.mjs +298 -0
  74. package/dist/chunks/chunk-VMHTYDH4.mjs +172 -0
  75. package/dist/chunks/chunk-VZS54AA5.mjs +200 -0
  76. package/dist/chunks/chunk-WFQUVXML.mjs +295 -0
  77. package/dist/chunks/chunk-X34PDRUH.mjs +809 -0
  78. package/dist/chunks/chunk-XNPZBLYL.mjs +33 -0
  79. package/dist/chunks/chunk-XX7OSWTO.mjs +157 -0
  80. package/dist/chunks/chunk-XYTWGHFS.mjs +600 -0
  81. package/dist/chunks/chunk-XYV3VCIX.mjs +336 -0
  82. package/dist/chunks/chunk-Y5ZLKFLE.mjs +1469 -0
  83. package/dist/chunks/chunk-ZJKXHM4Q.mjs +230 -0
  84. package/dist/chunks/cli-TCMBNZF6.mjs +1030 -0
  85. package/dist/chunks/commands-DTEKM4ZL.mjs +20 -0
  86. package/dist/chunks/daemon-ZC3FZ2P4.mjs +112449 -0
  87. package/dist/chunks/daemon-control-WDX7PMTC.mjs +300 -0
  88. package/dist/chunks/daemon-token-WRSULP7G.mjs +23 -0
  89. package/dist/chunks/devtools-H7CI2ZVG.mjs +85 -0
  90. package/dist/chunks/discord-IWDQJA7A.mjs +70588 -0
  91. package/dist/chunks/dist-C57KYFS2.mjs +4952 -0
  92. package/dist/chunks/dist-I3XBAGDL.mjs +11 -0
  93. package/dist/chunks/email-V4Q4VJON.mjs +58679 -0
  94. package/dist/chunks/environment-NX277MQG.mjs +15 -0
  95. package/dist/chunks/grok-subscription-4PYX7TBF.mjs +19 -0
  96. package/dist/chunks/layout-EPJQNFAI.mjs +22 -0
  97. package/dist/chunks/lib-N7FCZWKH.mjs +4038 -0
  98. package/dist/chunks/open-OTQDGDH5.mjs +36 -0
  99. package/dist/chunks/parser-JVY2PWSM.mjs +19 -0
  100. package/dist/chunks/pipeline-executor-BHBSJX2K.mjs +19 -0
  101. package/dist/chunks/react-IUIDQ5LX.mjs +11 -0
  102. package/dist/chunks/screen-54BUTYCW.mjs +27 -0
  103. package/dist/chunks/slack-3L5QTDZX.mjs +8113 -0
  104. package/dist/chunks/store-WR7TZJZS.mjs +32 -0
  105. package/dist/chunks/telegram-5ISVFBV3.mjs +14918 -0
  106. package/dist/chunks/terminal-O5WO7C5U.mjs +48 -0
  107. package/dist/chunks/theme-NORU4J74.mjs +20 -0
  108. package/dist/chunks/themes-F2FKU7CP.mjs +23 -0
  109. package/dist/chunks/token-6G3HCMNX.mjs +54 -0
  110. package/dist/chunks/token-util-UXYSDQIW.mjs +12 -0
  111. package/dist/chunks/tui-ODVYUIMT.mjs +197 -0
  112. package/dist/chunks/welcome-XHXFV7SH.mjs +32 -0
  113. package/dist/chunks/whatsapp-XSAMNGPJ.mjs +85412 -0
  114. package/dist/chunks/xterm-headless-YF53XWXE.mjs +3353 -0
  115. package/package.json +53 -0
  116. package/resources/wasm/coreutils.LICENSE +18 -0
  117. package/resources/wasm/coreutils.wasm +0 -0
@@ -0,0 +1,374 @@
1
+ import { createRequire as __adfCreateRequire } from 'node:module';
2
+ import { fileURLToPath as __adfFileURLToPath } from 'node:url';
3
+ import { dirname as __adfDirname } from 'node:path';
4
+ const require = __adfCreateRequire(import.meta.url);
5
+ const __filename = __adfFileURLToPath(import.meta.url);
6
+ const __dirname = __adfDirname(__filename);
7
+ import {
8
+ AbstractID3Parser
9
+ } from "./chunk-62NE4LG4.mjs";
10
+ import {
11
+ AttachedPictureType
12
+ } from "./chunk-DXWDD5XJ.mjs";
13
+ import {
14
+ FourCcToken
15
+ } from "./chunk-NBTUWMGP.mjs";
16
+ import {
17
+ getBit,
18
+ getBitAllignedNumber
19
+ } from "./chunk-XX7OSWTO.mjs";
20
+ import {
21
+ StringType,
22
+ UINT16_BE,
23
+ UINT24_BE,
24
+ UINT32_BE,
25
+ UINT32_LE,
26
+ UINT8,
27
+ Uint8ArrayType,
28
+ makeUnexpectedFileContentError,
29
+ textDecode
30
+ } from "./chunk-I2HJYHFT.mjs";
31
+ import {
32
+ require_src
33
+ } from "./chunk-AUYKRQPJ.mjs";
34
+ import {
35
+ __toESM
36
+ } from "./chunk-M2RX3S2T.mjs";
37
+
38
+ // node_modules/music-metadata/lib/flac/FlacParser.js
39
+ var import_debug2 = __toESM(require_src(), 1);
40
+
41
+ // node_modules/music-metadata/lib/ogg/vorbis/Vorbis.js
42
+ var VorbisPictureToken = class _VorbisPictureToken {
43
+ static fromBase64(base64str) {
44
+ return _VorbisPictureToken.fromBuffer(Uint8Array.from(atob(base64str), (c) => c.charCodeAt(0)));
45
+ }
46
+ static fromBuffer(buffer) {
47
+ return new _VorbisPictureToken(buffer.length).get(buffer, 0);
48
+ }
49
+ constructor(len) {
50
+ this.len = len;
51
+ }
52
+ get(buffer, offset) {
53
+ let type = AttachedPictureType[UINT32_BE.get(buffer, offset)];
54
+ offset += 4;
55
+ let mimeLen = UINT32_BE.get(buffer, offset);
56
+ offset += 4;
57
+ let format = new StringType(mimeLen, "utf-8").get(buffer, offset);
58
+ offset += mimeLen;
59
+ let descLen = UINT32_BE.get(buffer, offset);
60
+ offset += 4;
61
+ let description = new StringType(descLen, "utf-8").get(buffer, offset);
62
+ offset += descLen;
63
+ let width = UINT32_BE.get(buffer, offset);
64
+ offset += 4;
65
+ let height = UINT32_BE.get(buffer, offset);
66
+ offset += 4;
67
+ let colour_depth = UINT32_BE.get(buffer, offset);
68
+ offset += 4;
69
+ let indexed_color = UINT32_BE.get(buffer, offset);
70
+ offset += 4;
71
+ let picDataLen = UINT32_BE.get(buffer, offset);
72
+ offset += 4;
73
+ let data = buffer.slice(offset, offset + picDataLen);
74
+ return {
75
+ type,
76
+ format,
77
+ description,
78
+ width,
79
+ height,
80
+ colour_depth,
81
+ indexed_color,
82
+ data
83
+ };
84
+ }
85
+ }, CommonHeader = {
86
+ len: 7,
87
+ get: (buf, off) => ({
88
+ packetType: UINT8.get(buf, off),
89
+ vorbis: new StringType(6, "ascii").get(buf, off + 1)
90
+ })
91
+ }, IdentificationHeader = {
92
+ len: 23,
93
+ get: (uint8Array, off) => ({
94
+ version: UINT32_LE.get(uint8Array, off + 0),
95
+ channelMode: UINT8.get(uint8Array, off + 4),
96
+ sampleRate: UINT32_LE.get(uint8Array, off + 5),
97
+ bitrateMax: UINT32_LE.get(uint8Array, off + 9),
98
+ bitrateNominal: UINT32_LE.get(uint8Array, off + 13),
99
+ bitrateMin: UINT32_LE.get(uint8Array, off + 17)
100
+ })
101
+ };
102
+
103
+ // node_modules/music-metadata/lib/ogg/vorbis/VorbisStream.js
104
+ var import_debug = __toESM(require_src(), 1);
105
+
106
+ // node_modules/music-metadata/lib/ogg/vorbis/VorbisDecoder.js
107
+ var VorbisDecoder = class {
108
+ constructor(data, offset) {
109
+ this.data = data, this.offset = offset;
110
+ }
111
+ readInt32() {
112
+ let value = UINT32_LE.get(this.data, this.offset);
113
+ return this.offset += 4, value;
114
+ }
115
+ readStringUtf8() {
116
+ let len = this.readInt32(), value = textDecode(this.data.subarray(this.offset, this.offset + len), "utf-8");
117
+ return this.offset += len, value;
118
+ }
119
+ parseUserComment() {
120
+ let offset0 = this.offset, v = this.readStringUtf8(), idx = v.indexOf("=");
121
+ return {
122
+ key: v.substring(0, idx).toUpperCase(),
123
+ value: v.substring(idx + 1),
124
+ len: this.offset - offset0
125
+ };
126
+ }
127
+ };
128
+
129
+ // node_modules/music-metadata/lib/ogg/vorbis/VorbisStream.js
130
+ var debug = (0, import_debug.default)("music-metadata:parser:ogg:vorbis1"), VorbisContentError = class extends makeUnexpectedFileContentError("Vorbis") {
131
+ }, VorbisStream = class _VorbisStream {
132
+ constructor(metadata, options) {
133
+ this.pageSegments = [], this.durationOnLastPage = !0, this.metadata = metadata, this.options = options;
134
+ }
135
+ /**
136
+ * Vorbis 1 parser
137
+ * @param header Ogg Page Header
138
+ * @param pageData Page data
139
+ */
140
+ async parsePage(header, pageData) {
141
+ if (this.lastPageHeader = header, header.headerType.firstPage)
142
+ this.parseFirstPage(header, pageData);
143
+ else {
144
+ if (header.headerType.continued) {
145
+ if (this.pageSegments.length === 0)
146
+ throw new VorbisContentError("Cannot continue on previous page");
147
+ this.pageSegments.push(pageData);
148
+ }
149
+ if (header.headerType.lastPage || !header.headerType.continued) {
150
+ if (this.pageSegments.length > 0) {
151
+ let fullPage = _VorbisStream.mergeUint8Arrays(this.pageSegments);
152
+ await this.parseFullPage(fullPage);
153
+ }
154
+ this.pageSegments = header.headerType.lastPage ? [] : [pageData];
155
+ }
156
+ }
157
+ }
158
+ static mergeUint8Arrays(arrays) {
159
+ let totalSize = arrays.reduce((acc, e) => acc + e.length, 0), merged = new Uint8Array(totalSize);
160
+ return arrays.forEach((array, i, _arrays) => {
161
+ let offset = _arrays.slice(0, i).reduce((acc, e) => acc + e.length, 0);
162
+ merged.set(array, offset);
163
+ }), merged;
164
+ }
165
+ async flush() {
166
+ await this.parseFullPage(_VorbisStream.mergeUint8Arrays(this.pageSegments));
167
+ }
168
+ async parseUserComment(pageData, offset) {
169
+ let tag = new VorbisDecoder(pageData, offset).parseUserComment();
170
+ return await this.addTag(tag.key, tag.value), tag.len;
171
+ }
172
+ async addTag(id, value) {
173
+ if (id === "METADATA_BLOCK_PICTURE" && typeof value == "string") {
174
+ if (this.options.skipCovers) {
175
+ debug("Ignore picture");
176
+ return;
177
+ }
178
+ value = VorbisPictureToken.fromBase64(value), debug(`Push picture: id=${id}, format=${value.format}`);
179
+ } else
180
+ debug(`Push tag: id=${id}, value=${value}`);
181
+ await this.metadata.addTag("vorbis", id, value);
182
+ }
183
+ calculateDuration(enfOfStream) {
184
+ this.lastPageHeader && (enfOfStream || this.lastPageHeader.headerType.lastPage) && this.metadata.format.sampleRate && this.lastPageHeader.absoluteGranulePosition >= 0 && (this.metadata.setFormat("numberOfSamples", this.lastPageHeader.absoluteGranulePosition), this.metadata.setFormat("duration", this.lastPageHeader.absoluteGranulePosition / this.metadata.format.sampleRate));
185
+ }
186
+ /**
187
+ * Parse first Ogg/Vorbis page
188
+ * @param _header
189
+ * @param pageData
190
+ */
191
+ parseFirstPage(_header, pageData) {
192
+ this.metadata.setFormat("codec", "Vorbis I"), this.metadata.setFormat("hasAudio", !0), debug("Parse first page");
193
+ let commonHeader = CommonHeader.get(pageData, 0);
194
+ if (commonHeader.vorbis !== "vorbis")
195
+ throw new VorbisContentError("Metadata does not look like Vorbis");
196
+ if (commonHeader.packetType === 1) {
197
+ let idHeader = IdentificationHeader.get(pageData, CommonHeader.len);
198
+ this.metadata.setFormat("sampleRate", idHeader.sampleRate), this.metadata.setFormat("bitrate", idHeader.bitrateNominal), this.metadata.setFormat("numberOfChannels", idHeader.channelMode), debug("sample-rate=%s[hz], bitrate=%s[b/s], channel-mode=%s", idHeader.sampleRate, idHeader.bitrateNominal, idHeader.channelMode);
199
+ } else
200
+ throw new VorbisContentError("First Ogg page should be type 1: the identification header");
201
+ }
202
+ async parseFullPage(pageData) {
203
+ let commonHeader = CommonHeader.get(pageData, 0);
204
+ switch (debug("Parse full page: type=%s, byteLength=%s", commonHeader.packetType, pageData.byteLength), commonHeader.packetType) {
205
+ case 3:
206
+ return this.parseUserCommentList(pageData, CommonHeader.len);
207
+ case 1:
208
+ // type 1: the identification header
209
+ case 5:
210
+ break;
211
+ }
212
+ }
213
+ /**
214
+ * Ref: https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-840005.2
215
+ */
216
+ async parseUserCommentList(pageData, offset) {
217
+ let strLen = UINT32_LE.get(pageData, offset);
218
+ offset += 4, offset += strLen;
219
+ let userCommentListLength = UINT32_LE.get(pageData, offset);
220
+ for (offset += 4; userCommentListLength-- > 0; )
221
+ offset += await this.parseUserComment(pageData, offset);
222
+ }
223
+ };
224
+
225
+ // node_modules/music-metadata/lib/flac/FlacToken.js
226
+ var BlockType = {
227
+ STREAMINFO: 0,
228
+ // STREAMINFO
229
+ PADDING: 1,
230
+ // PADDING
231
+ APPLICATION: 2,
232
+ // APPLICATION
233
+ SEEKTABLE: 3,
234
+ // SEEKTABLE
235
+ VORBIS_COMMENT: 4,
236
+ // VORBIS_COMMENT
237
+ CUESHEET: 5,
238
+ // CUESHEET
239
+ PICTURE: 6
240
+ // PICTURE
241
+ }, BlockHeader = {
242
+ len: 4,
243
+ get: (buf, off) => ({
244
+ lastBlock: getBit(buf, off, 7),
245
+ type: getBitAllignedNumber(buf, off, 1, 7),
246
+ length: UINT24_BE.get(buf, off + 1)
247
+ })
248
+ }, BlockStreamInfo = {
249
+ len: 34,
250
+ get: (buf, off) => ({
251
+ // The minimum block size (in samples) used in the stream.
252
+ minimumBlockSize: UINT16_BE.get(buf, off),
253
+ // The maximum block size (in samples) used in the stream.
254
+ // (Minimum blocksize == maximum blocksize) implies a fixed-blocksize stream.
255
+ maximumBlockSize: UINT16_BE.get(buf, off + 2) / 1e3,
256
+ // The minimum frame size (in bytes) used in the stream.
257
+ // May be 0 to imply the value is not known.
258
+ minimumFrameSize: UINT24_BE.get(buf, off + 4),
259
+ // The maximum frame size (in bytes) used in the stream.
260
+ // May be 0 to imply the value is not known.
261
+ maximumFrameSize: UINT24_BE.get(buf, off + 7),
262
+ // Sample rate in Hz. Though 20 bits are available,
263
+ // the maximum sample rate is limited by the structure of frame headers to 655350Hz.
264
+ // Also, a value of 0 is invalid.
265
+ sampleRate: UINT24_BE.get(buf, off + 10) >> 4,
266
+ // probably slower: sampleRate: common.getBitAllignedNumber(buf, off + 10, 0, 20),
267
+ // (number of channels)-1. FLAC supports from 1 to 8 channels
268
+ channels: getBitAllignedNumber(buf, off + 12, 4, 3) + 1,
269
+ // bits per sample)-1.
270
+ // FLAC supports from 4 to 32 bits per sample. Currently the reference encoder and decoders only support up to 24 bits per sample.
271
+ bitsPerSample: getBitAllignedNumber(buf, off + 12, 7, 5) + 1,
272
+ // Total samples in stream.
273
+ // 'Samples' means inter-channel sample, i.e. one second of 44.1Khz audio will have 44100 samples regardless of the number of channels.
274
+ // A value of zero here means the number of total samples is unknown.
275
+ totalSamples: getBitAllignedNumber(buf, off + 13, 4, 36),
276
+ // the MD5 hash of the file (see notes for usage... it's a littly tricky)
277
+ fileMD5: new Uint8ArrayType(16).get(buf, off + 18)
278
+ })
279
+ };
280
+
281
+ // node_modules/music-metadata/lib/flac/FlacParser.js
282
+ var debug2 = (0, import_debug2.default)("music-metadata:parser:FLAC"), FlacContentError = class extends makeUnexpectedFileContentError("FLAC") {
283
+ }, FlacParser = class extends AbstractID3Parser {
284
+ constructor() {
285
+ super(...arguments), this.vorbisParser = new VorbisStream(this.metadata, this.options);
286
+ }
287
+ async postId3v2Parse() {
288
+ if ((await this.tokenizer.readToken(FourCcToken)).toString() !== "fLaC")
289
+ throw new FlacContentError("Invalid FLAC preamble");
290
+ let blockHeader;
291
+ do
292
+ blockHeader = await this.tokenizer.readToken(BlockHeader), await this.parseDataBlock(blockHeader);
293
+ while (!blockHeader.lastBlock);
294
+ if (this.tokenizer.fileInfo.size && this.metadata.format.duration) {
295
+ let dataSize = this.tokenizer.fileInfo.size - this.tokenizer.position;
296
+ this.metadata.setFormat("bitrate", 8 * dataSize / this.metadata.format.duration);
297
+ }
298
+ }
299
+ async parseDataBlock(blockHeader) {
300
+ switch (debug2(`blockHeader type=${blockHeader.type}, length=${blockHeader.length}`), blockHeader.type) {
301
+ case BlockType.STREAMINFO:
302
+ return this.readBlockStreamInfo(blockHeader.length);
303
+ case BlockType.PADDING:
304
+ break;
305
+ case BlockType.APPLICATION:
306
+ break;
307
+ case BlockType.SEEKTABLE:
308
+ break;
309
+ case BlockType.VORBIS_COMMENT:
310
+ return this.readComment(blockHeader.length);
311
+ case BlockType.CUESHEET:
312
+ break;
313
+ case BlockType.PICTURE:
314
+ await this.parsePicture(blockHeader.length);
315
+ return;
316
+ default:
317
+ this.metadata.addWarning(`Unknown block type: ${blockHeader.type}`);
318
+ }
319
+ return this.tokenizer.ignore(blockHeader.length).then();
320
+ }
321
+ /**
322
+ * Parse STREAMINFO
323
+ */
324
+ async readBlockStreamInfo(dataLen) {
325
+ if (dataLen !== BlockStreamInfo.len)
326
+ throw new FlacContentError("Unexpected block-stream-info length");
327
+ let streamInfo = await this.tokenizer.readToken(BlockStreamInfo);
328
+ this.metadata.setFormat("container", "FLAC"), this.processsStreamInfo(streamInfo);
329
+ }
330
+ /**
331
+ * Parse STREAMINFO
332
+ */
333
+ processsStreamInfo(streamInfo) {
334
+ this.metadata.setFormat("codec", "FLAC"), this.metadata.setFormat("hasAudio", !0), this.metadata.setFormat("lossless", !0), this.metadata.setFormat("numberOfChannels", streamInfo.channels), this.metadata.setFormat("bitsPerSample", streamInfo.bitsPerSample), this.metadata.setFormat("sampleRate", streamInfo.sampleRate), streamInfo.totalSamples > 0 && this.metadata.setFormat("duration", streamInfo.totalSamples / streamInfo.sampleRate);
335
+ }
336
+ /**
337
+ * Read VORBIS_COMMENT from tokenizer
338
+ * Ref: https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-640004.2.3
339
+ */
340
+ async readComment(dataLen) {
341
+ let data = await this.tokenizer.readToken(new Uint8ArrayType(dataLen));
342
+ return this.parseComment(data);
343
+ }
344
+ /**
345
+ * Parse VORBIS_COMMENT
346
+ * Ref: https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-640004.2.3
347
+ */
348
+ async parseComment(data) {
349
+ let decoder = new VorbisDecoder(data, 0), vendor = decoder.readStringUtf8();
350
+ vendor.length > 0 && this.metadata.setFormat("tool", vendor);
351
+ let commentListLength = decoder.readInt32(), tags = new Array(commentListLength);
352
+ for (let i = 0; i < commentListLength; i++)
353
+ tags[i] = decoder.parseUserComment();
354
+ await Promise.all(tags.map((tag) => (tag.key === "ENCODER" && this.metadata.setFormat("tool", tag.value), this.addTag(tag.key, tag.value))));
355
+ }
356
+ async parsePicture(dataLen) {
357
+ return this.options.skipCovers ? this.tokenizer.ignore(dataLen) : this.addPictureTag(await this.tokenizer.readToken(new VorbisPictureToken(dataLen)));
358
+ }
359
+ addPictureTag(picture) {
360
+ return this.addTag("METADATA_BLOCK_PICTURE", picture);
361
+ }
362
+ addTag(id, value) {
363
+ return this.vorbisParser.addTag(id, value);
364
+ }
365
+ };
366
+
367
+ export {
368
+ VorbisPictureToken,
369
+ VorbisStream,
370
+ BlockType,
371
+ BlockHeader,
372
+ BlockStreamInfo,
373
+ FlacParser
374
+ };
@@ -0,0 +1,149 @@
1
+ import { createRequire as __adfCreateRequire } from 'node:module';
2
+ import { fileURLToPath as __adfFileURLToPath } from 'node:url';
3
+ import { dirname as __adfDirname } from 'node:path';
4
+ const require = __adfCreateRequire(import.meta.url);
5
+ const __filename = __adfFileURLToPath(import.meta.url);
6
+ const __dirname = __adfDirname(__filename);
7
+ import {
8
+ require_react
9
+ } from "./chunk-6GJ4QHRI.mjs";
10
+ import {
11
+ __toESM
12
+ } from "./chunk-M2RX3S2T.mjs";
13
+
14
+ // src/main/tui/app/terminal.ts
15
+ var import_react = __toESM(require_react(), 1), MOUSE_ON = "\x1B[?1002h\x1B[?1006h", MOUSE_OFF = "\x1B[?1006l\x1B[?1002l\x1B[?1000l", ALT_SCROLL_ON = "\x1B[?1007h", ALT_SCROLL_OFF = "\x1B[?1007l", KITTY_ON = /\u001b\[>\d+u/, KITTY_OFF = "\x1B[<u", caps = { kitty: !1, shiftEnterSeen: !1, shiftEnterForced: !1, mouseWanted: !1, mouseActive: !1, altScrollActive: !1, altScreen: !1 }, listeners = /* @__PURE__ */ new Set(), out = null, rawMode = !1, writeTap = null, lastRaw = "";
16
+ function setWriteTap(tap) {
17
+ writeTap = tap;
18
+ }
19
+ function writeTerminal(data) {
20
+ if (!out) return !1;
21
+ try {
22
+ out.write(data);
23
+ } catch {
24
+ return !1;
25
+ }
26
+ return !0;
27
+ }
28
+ function noteRawInput(data) {
29
+ lastRaw = data;
30
+ }
31
+ function lastRawInput() {
32
+ return lastRaw;
33
+ }
34
+ function superArrow(raw = lastRaw) {
35
+ let m = /^\u001b\[1;(\d+)([CD])$/.exec(raw);
36
+ return !m || (Number(m[1]) - 1 & 8) === 0 ? null : m[2] === "D" ? "left" : "right";
37
+ }
38
+ function set(patch) {
39
+ let next = { ...caps, ...patch };
40
+ if (!Object.keys(patch).every((k) => next[k] === caps[k])) {
41
+ caps = next;
42
+ for (let listener of listeners) listener();
43
+ }
44
+ }
45
+ function terminalCaps() {
46
+ return caps;
47
+ }
48
+ function useTerminalCaps() {
49
+ return (0, import_react.useSyncExternalStore)(
50
+ (listener) => (listeners.add(listener), () => {
51
+ listeners.delete(listener);
52
+ }),
53
+ () => caps,
54
+ () => caps
55
+ );
56
+ }
57
+ function shiftEnterWorks(c = caps) {
58
+ return c.kitty || c.shiftEnterSeen || c.shiftEnterForced;
59
+ }
60
+ function newlineKey(c = caps) {
61
+ return shiftEnterWorks(c) ? "shift+enter" : "alt+enter";
62
+ }
63
+ function noteShiftEnter() {
64
+ caps.shiftEnterSeen || set({ shiftEnterSeen: !0 });
65
+ }
66
+ function syncMouse() {
67
+ if (!out) return;
68
+ let live = caps.altScreen && rawMode, mouse = caps.mouseWanted && live, altScroll = !caps.mouseWanted && live, seq = "";
69
+ if (mouse !== caps.mouseActive && (seq += mouse ? MOUSE_ON : MOUSE_OFF), altScroll !== caps.altScrollActive && (seq += altScroll ? ALT_SCROLL_ON : ALT_SCROLL_OFF), !!seq) {
70
+ try {
71
+ out.write(seq);
72
+ } catch {
73
+ }
74
+ set({ mouseActive: mouse, altScrollActive: altScroll });
75
+ }
76
+ }
77
+ function setMouseWanted(on) {
78
+ set({ mouseWanted: on }), syncMouse();
79
+ }
80
+ function installTerminalModes(options) {
81
+ let { stdin, stdout } = options;
82
+ out = { write: (data) => originalWrite(data) }, caps = { kitty: !1, shiftEnterSeen: !1, shiftEnterForced: !!options.shiftEnterForced, mouseWanted: options.mouse, mouseActive: !1, altScrollActive: !1, altScreen: options.altScreen }, rawMode = !1;
83
+ let originalWrite = stdout.write.bind(stdout), patchedWrite = (data, ...rest) => {
84
+ typeof data == "string" && data.includes("\x1B[") && (data.includes(KITTY_OFF) ? set({ kitty: !1 }) : KITTY_ON.test(data) && set({ kitty: !0 }));
85
+ let result = originalWrite(data, ...rest);
86
+ if (writeTap)
87
+ try {
88
+ writeTap(typeof data == "string" ? data : Buffer.from(data).toString("utf8"));
89
+ } catch {
90
+ }
91
+ return result;
92
+ };
93
+ stdout.write = patchedWrite;
94
+ let originalSetRawMode = typeof stdin.setRawMode == "function" ? stdin.setRawMode.bind(stdin) : null;
95
+ originalSetRawMode && (stdin.setRawMode = (on) => {
96
+ on || (rawMode = !1, syncMouse());
97
+ let result = originalSetRawMode(on);
98
+ return on && (rawMode = !0, syncMouse()), result;
99
+ });
100
+ let restore = () => (caps.mouseActive ? MOUSE_OFF : "") + (caps.altScrollActive ? ALT_SCROLL_OFF : ""), onExit = () => {
101
+ let seq = restore();
102
+ if (seq)
103
+ try {
104
+ originalWrite(seq);
105
+ } catch {
106
+ }
107
+ };
108
+ return process.on("exit", onExit), () => {
109
+ process.off("exit", onExit);
110
+ let seq = restore();
111
+ if (seq)
112
+ try {
113
+ originalWrite(seq);
114
+ } catch {
115
+ }
116
+ stdout.write = originalWrite, originalSetRawMode && (stdin.setRawMode = originalSetRawMode), rawMode = !1, out = null, set({ mouseActive: !1, altScrollActive: !1, kitty: !1 });
117
+ };
118
+ }
119
+ var SGR_MOUSE = /^\u001b?\[<(\d+);(\d+);(\d+)([Mm])$/;
120
+ function parseMouse(input) {
121
+ let match = SGR_MOUSE.exec(input);
122
+ if (!match) return null;
123
+ let code = Number(match[1]), x = Math.max(0, Number(match[2]) - 1), y = Math.max(0, Number(match[3]) - 1), mods = { shift: (code & 4) !== 0, alt: (code & 8) !== 0, ctrl: (code & 16) !== 0 }, base = code & -29;
124
+ return base >= 64 && base < 128 ? { kind: "wheel", delta: base === 64 ? -1 : base === 65 ? 1 : 0, button: -1, x, y, ...mods } : base & 32 ? { kind: "drag", delta: 0, button: base & 3, x, y, ...mods } : { kind: match[4] === "m" ? "release" : "press", delta: 0, button: base & 3, x, y, ...mods };
125
+ }
126
+ function isMouseGarbage(input) {
127
+ return /^\u001b?\[<\d+;\d+;\d+[Mm]/.test(input);
128
+ }
129
+
130
+ export {
131
+ MOUSE_ON,
132
+ MOUSE_OFF,
133
+ ALT_SCROLL_ON,
134
+ ALT_SCROLL_OFF,
135
+ setWriteTap,
136
+ writeTerminal,
137
+ noteRawInput,
138
+ lastRawInput,
139
+ superArrow,
140
+ terminalCaps,
141
+ useTerminalCaps,
142
+ shiftEnterWorks,
143
+ newlineKey,
144
+ noteShiftEnter,
145
+ setMouseWanted,
146
+ installTerminalModes,
147
+ parseMouse,
148
+ isMouseGarbage
149
+ };