@eternalheart/react-file-preview 1.3.10 → 1.3.11

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 (114) hide show
  1. package/lib/RequestContext.d.ts +1 -1
  2. package/lib/RequestContext.d.ts.map +1 -1
  3. package/lib/chunks/RendererError-BH6fzLrN.mjs +15 -0
  4. package/lib/chunks/RendererError-BH6fzLrN.mjs.map +1 -0
  5. package/lib/chunks/avifLoader-BP3fgcMm-BnpxLhxp.mjs +56 -0
  6. package/lib/chunks/avifLoader-BP3fgcMm-BnpxLhxp.mjs.map +1 -0
  7. package/lib/chunks/heicLoader-CH_raQNn-1fBLaICM.mjs +37 -0
  8. package/lib/chunks/heicLoader-CH_raQNn-1fBLaICM.mjs.map +1 -0
  9. package/lib/chunks/index-B57rEPin.mjs +54 -0
  10. package/lib/chunks/index-B57rEPin.mjs.map +1 -0
  11. package/lib/chunks/index-BCuRRLYt.mjs +222 -0
  12. package/lib/chunks/index-BCuRRLYt.mjs.map +1 -0
  13. package/lib/chunks/{index-DSAXdrgU.mjs → index-BJ6vTNxc.mjs} +76 -75
  14. package/lib/chunks/index-BJ6vTNxc.mjs.map +1 -0
  15. package/lib/chunks/{index-C5YHI0Zs.mjs → index-BYdqrqnR.mjs} +52 -51
  16. package/lib/chunks/index-BYdqrqnR.mjs.map +1 -0
  17. package/lib/chunks/index-BiyghBxu.mjs +136 -0
  18. package/lib/chunks/index-BiyghBxu.mjs.map +1 -0
  19. package/lib/chunks/{index-CwmZQ-JO.mjs → index-C8CyS_sj.mjs} +67 -64
  20. package/lib/chunks/index-C8CyS_sj.mjs.map +1 -0
  21. package/lib/chunks/index-C8OrFLd5.mjs +594 -0
  22. package/lib/chunks/index-C8OrFLd5.mjs.map +1 -0
  23. package/lib/chunks/{index-DveR0rOk.mjs → index-CCkHAeLh.mjs} +41 -38
  24. package/lib/chunks/index-CCkHAeLh.mjs.map +1 -0
  25. package/lib/chunks/index-CdmkF0CO.mjs +105 -0
  26. package/lib/chunks/index-CdmkF0CO.mjs.map +1 -0
  27. package/lib/chunks/index-CuAALtwC.mjs +2299 -0
  28. package/lib/chunks/index-CuAALtwC.mjs.map +1 -0
  29. package/lib/chunks/index-D660ENHx.mjs +114 -0
  30. package/lib/chunks/index-D660ENHx.mjs.map +1 -0
  31. package/lib/chunks/{index-DN8BQIqo.mjs → index-DBEG73K1.mjs} +79 -78
  32. package/lib/chunks/index-DBEG73K1.mjs.map +1 -0
  33. package/lib/chunks/index-DaFlk9dd.mjs +13097 -0
  34. package/lib/chunks/index-DaFlk9dd.mjs.map +1 -0
  35. package/lib/chunks/index-_mP0FkqE.mjs +113 -0
  36. package/lib/chunks/index-_mP0FkqE.mjs.map +1 -0
  37. package/lib/chunks/{index-tecGXW2S.mjs → index-nLTQXCV7.mjs} +85 -83
  38. package/lib/chunks/index-nLTQXCV7.mjs.map +1 -0
  39. package/lib/chunks/index-nVblatyi.mjs +55 -0
  40. package/lib/chunks/index-nVblatyi.mjs.map +1 -0
  41. package/lib/chunks/{index-DPpUj8Yy.mjs → index-ow-nGpuu.mjs} +99 -98
  42. package/lib/chunks/index-ow-nGpuu.mjs.map +1 -0
  43. package/lib/chunks/index-qOC5xQyK.mjs +96 -0
  44. package/lib/chunks/index-qOC5xQyK.mjs.map +1 -0
  45. package/lib/chunks/index-rUfsiVR8.mjs +12335 -0
  46. package/lib/chunks/index-rUfsiVR8.mjs.map +1 -0
  47. package/lib/chunks/jp2Loader-Bn-qPMbD-Bn-qPMbD.mjs +122 -0
  48. package/lib/chunks/jp2Loader-Bn-qPMbD-Bn-qPMbD.mjs.map +1 -0
  49. package/lib/chunks/psdLoader-Doxw3mWm-DVOGFSlh.mjs +73 -0
  50. package/lib/chunks/psdLoader-Doxw3mWm-DVOGFSlh.mjs.map +1 -0
  51. package/lib/chunks/rawLoader-0mLvxCNp-CJmERiK7.mjs +82 -0
  52. package/lib/chunks/rawLoader-0mLvxCNp-CJmERiK7.mjs.map +1 -0
  53. package/lib/chunks/tiffLoader-CTFKVLqJ-B84NfwhR.mjs +60 -0
  54. package/lib/chunks/tiffLoader-CTFKVLqJ-B84NfwhR.mjs.map +1 -0
  55. package/lib/chunks/{useShikiHighlight-DHFYu0BU.mjs → useShikiHighlight-ClbUXJ2p.mjs} +2 -2
  56. package/lib/chunks/{useShikiHighlight-DHFYu0BU.mjs.map → useShikiHighlight-ClbUXJ2p.mjs.map} +1 -1
  57. package/lib/index.cjs +31 -22
  58. package/lib/index.cjs.map +1 -1
  59. package/lib/index.css +1 -1
  60. package/lib/index.mjs +8 -8
  61. package/lib/renderers/Audio/index.d.ts.map +1 -1
  62. package/lib/renderers/Csv/index.d.ts.map +1 -1
  63. package/lib/renderers/Docx/index.d.ts.map +1 -1
  64. package/lib/renderers/Epub/index.d.ts.map +1 -1
  65. package/lib/renderers/Font/index.d.ts.map +1 -1
  66. package/lib/renderers/Image/index.d.ts +2 -0
  67. package/lib/renderers/Image/index.d.ts.map +1 -1
  68. package/lib/renderers/Json/index.d.ts.map +1 -1
  69. package/lib/renderers/Markdown/index.d.ts.map +1 -1
  70. package/lib/renderers/Mobi/index.d.ts.map +1 -1
  71. package/lib/renderers/Msg/index.d.ts.map +1 -1
  72. package/lib/renderers/Pdf/index.d.ts.map +1 -1
  73. package/lib/renderers/Pptx/index.d.ts.map +1 -1
  74. package/lib/renderers/RendererError.d.ts +8 -0
  75. package/lib/renderers/RendererError.d.ts.map +1 -0
  76. package/lib/renderers/Subtitle/index.d.ts.map +1 -1
  77. package/lib/renderers/Text/index.d.ts.map +1 -1
  78. package/lib/renderers/Video/index.d.ts +1 -0
  79. package/lib/renderers/Video/index.d.ts.map +1 -1
  80. package/lib/renderers/Xlsx/index.d.ts.map +1 -1
  81. package/lib/renderers/Xml/index.d.ts.map +1 -1
  82. package/lib/renderers/Zip/index.d.ts.map +1 -1
  83. package/package.json +13 -5
  84. package/lib/chunks/index-B0JUZ5rS.mjs +0 -110
  85. package/lib/chunks/index-B0JUZ5rS.mjs.map +0 -1
  86. package/lib/chunks/index-BAYc4aBz.mjs +0 -129
  87. package/lib/chunks/index-BAYc4aBz.mjs.map +0 -1
  88. package/lib/chunks/index-BOQJNL71.mjs +0 -103
  89. package/lib/chunks/index-BOQJNL71.mjs.map +0 -1
  90. package/lib/chunks/index-BkU8rK-0.mjs +0 -51
  91. package/lib/chunks/index-BkU8rK-0.mjs.map +0 -1
  92. package/lib/chunks/index-BnDoXBnH.mjs +0 -257
  93. package/lib/chunks/index-BnDoXBnH.mjs.map +0 -1
  94. package/lib/chunks/index-C5YHI0Zs.mjs.map +0 -1
  95. package/lib/chunks/index-CGNWXFy3.mjs +0 -2081
  96. package/lib/chunks/index-CGNWXFy3.mjs.map +0 -1
  97. package/lib/chunks/index-CwmZQ-JO.mjs.map +0 -1
  98. package/lib/chunks/index-CzflrElZ.mjs +0 -52
  99. package/lib/chunks/index-CzflrElZ.mjs.map +0 -1
  100. package/lib/chunks/index-CztCCF7q.mjs +0 -116
  101. package/lib/chunks/index-CztCCF7q.mjs.map +0 -1
  102. package/lib/chunks/index-DKEcGewg.mjs +0 -96
  103. package/lib/chunks/index-DKEcGewg.mjs.map +0 -1
  104. package/lib/chunks/index-DN8BQIqo.mjs.map +0 -1
  105. package/lib/chunks/index-DPpUj8Yy.mjs.map +0 -1
  106. package/lib/chunks/index-DSAXdrgU.mjs.map +0 -1
  107. package/lib/chunks/index-DveR0rOk.mjs.map +0 -1
  108. package/lib/chunks/index-QfO-sASN.mjs +0 -152
  109. package/lib/chunks/index-QfO-sASN.mjs.map +0 -1
  110. package/lib/chunks/index-h9bO9wmq.mjs +0 -99
  111. package/lib/chunks/index-h9bO9wmq.mjs.map +0 -1
  112. package/lib/chunks/index-mvSVNKlQ.mjs +0 -228
  113. package/lib/chunks/index-mvSVNKlQ.mjs.map +0 -1
  114. package/lib/chunks/index-tecGXW2S.mjs.map +0 -1
@@ -0,0 +1,2299 @@
1
+ import { jsx as p, jsxs as T, Fragment as je } from "react/jsx-runtime";
2
+ import Pe, { useMemo as H, useContext as K, createContext as pt, useState as F, useRef as B, useEffect as L, lazy as R, useCallback as P, Suspense as Te } from "react";
3
+ import { createPortal as ze } from "react-dom";
4
+ import { motion as ot, AnimatePresence as Se } from "framer-motion";
5
+ import { ZoomOut as Jt, ZoomIn as Yt, Scan as Ee, RotateCcw as Le, RotateCw as We, RefreshCw as Qt, List as te, ChevronLeft as ft, ChevronRight as ct, Minimize2 as ee, Maximize2 as oe, WrapText as $e, Code as re, Eye as ne, FileQuestion as De, Download as ae, X as Ae } from "lucide-react";
6
+ import Ue from "jszip";
7
+ import * as Oe from "pdfjs-dist/build/pdf.mjs";
8
+ const Ie = "1.3.11", Ve = {
9
+ version: Ie
10
+ }, vr = [
11
+ "image",
12
+ "pdf",
13
+ "docx",
14
+ "xlsx",
15
+ "pptx",
16
+ "msg",
17
+ "epub",
18
+ "mobi",
19
+ "video",
20
+ "audio",
21
+ "markdown",
22
+ "json",
23
+ "csv",
24
+ "xml",
25
+ "subtitle",
26
+ "zip",
27
+ "text",
28
+ "font"
29
+ ];
30
+ function Ze(t) {
31
+ try {
32
+ const e = new URL(t).pathname.split("/").pop() || "file";
33
+ return decodeURIComponent(e);
34
+ } catch {
35
+ const e = t.split("/").pop() || "file";
36
+ return decodeURIComponent(e);
37
+ }
38
+ }
39
+ function at(t) {
40
+ var e;
41
+ const o = ((e = t.split(".").pop()) == null ? void 0 : e.toLowerCase()) || "";
42
+ return {
43
+ // 图片
44
+ jpg: "image/jpeg",
45
+ jpeg: "image/jpeg",
46
+ png: "image/png",
47
+ gif: "image/gif",
48
+ webp: "image/webp",
49
+ svg: "image/svg+xml",
50
+ bmp: "image/bmp",
51
+ ico: "image/x-icon",
52
+ // 视频
53
+ mp4: "video/mp4",
54
+ webm: "video/webm",
55
+ ogg: "video/ogg",
56
+ ogv: "video/ogg",
57
+ mov: "video/quicktime",
58
+ avi: "video/x-msvideo",
59
+ mkv: "video/x-matroska",
60
+ m4v: "video/x-m4v",
61
+ "3gp": "video/3gpp",
62
+ flv: "video/x-flv",
63
+ // 音频
64
+ mp3: "audio/mpeg",
65
+ wav: "audio/wav",
66
+ m4a: "audio/mp4",
67
+ aac: "audio/aac",
68
+ flac: "audio/flac",
69
+ // 文档
70
+ pdf: "application/pdf",
71
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
72
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
73
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
74
+ ppt: "application/vnd.ms-powerpoint",
75
+ msg: "application/vnd.ms-outlook",
76
+ mobi: "application/x-mobipocket-ebook",
77
+ azw: "application/vnd.amazon.ebook",
78
+ azw3: "application/vnd.amazon.ebook",
79
+ kf8: "application/vnd.amazon.ebook",
80
+ // 文本
81
+ txt: "text/plain",
82
+ md: "text/markdown",
83
+ markdown: "text/markdown",
84
+ json: "application/json",
85
+ xml: "application/xml",
86
+ html: "text/html",
87
+ css: "text/css",
88
+ js: "text/javascript",
89
+ ts: "text/typescript",
90
+ jsx: "text/javascript",
91
+ tsx: "text/typescript",
92
+ py: "text/x-python",
93
+ java: "text/x-java",
94
+ cpp: "text/x-c++src",
95
+ c: "text/x-csrc",
96
+ cs: "text/x-csharp",
97
+ php: "text/x-php",
98
+ rb: "text/x-ruby",
99
+ go: "text/x-go",
100
+ rs: "text/x-rust",
101
+ yaml: "text/yaml",
102
+ yml: "text/yaml",
103
+ toml: "text/toml",
104
+ ini: "text/plain",
105
+ env: "text/plain",
106
+ diff: "text/x-diff",
107
+ patch: "text/x-diff",
108
+ log: "text/plain",
109
+ csv: "text/csv",
110
+ tsv: "text/tab-separated-values",
111
+ srt: "application/x-subrip",
112
+ vtt: "text/vtt",
113
+ zip: "application/zip"
114
+ }[o] || "application/octet-stream";
115
+ }
116
+ function Be(t, e = 0) {
117
+ if (t instanceof File)
118
+ return {
119
+ id: `file-${Date.now()}-${e}`,
120
+ name: t.name,
121
+ url: URL.createObjectURL(t),
122
+ type: t.type || at(t.name),
123
+ size: t.size
124
+ };
125
+ if (typeof t == "string") {
126
+ const o = Ze(t);
127
+ return {
128
+ id: `url-${Date.now()}-${e}`,
129
+ name: o,
130
+ url: t,
131
+ type: at(o)
132
+ };
133
+ }
134
+ return {
135
+ id: t.id || `link-${Date.now()}-${e}`,
136
+ name: t.name,
137
+ url: t.url,
138
+ type: t.type || at(t.name),
139
+ size: t.size
140
+ };
141
+ }
142
+ function He(t) {
143
+ return t.map((e, o) => Be(e, o));
144
+ }
145
+ function qe(t) {
146
+ var e;
147
+ const o = ((e = t.name.split(".").pop()) == null ? void 0 : e.toLowerCase()) || "", r = t.type.toLowerCase();
148
+ if (r.startsWith("image/") || [
149
+ "jpg",
150
+ "jpeg",
151
+ "png",
152
+ "gif",
153
+ "webp",
154
+ "svg",
155
+ "bmp",
156
+ "ico",
157
+ // 高级图片格式
158
+ "heic",
159
+ "heif",
160
+ "avif",
161
+ "tif",
162
+ "tiff",
163
+ // RAW 格式
164
+ "cr2",
165
+ "nef",
166
+ "arw",
167
+ "dng",
168
+ "raf",
169
+ "orf",
170
+ // 其他专业格式
171
+ "psd",
172
+ "jp2",
173
+ "jpx",
174
+ "j2k"
175
+ ].includes(o))
176
+ return "image";
177
+ if (r.includes("pdf") || o === "pdf")
178
+ return "pdf";
179
+ if (r.includes("wordprocessingml") || o === "docx")
180
+ return "docx";
181
+ if (r.includes("spreadsheetml") || o === "xlsx")
182
+ return "xlsx";
183
+ if (r.includes("presentationml") || o === "pptx" || o === "ppt")
184
+ return "pptx";
185
+ if (r.includes("ms-outlook") || o === "msg")
186
+ return "msg";
187
+ if (r.includes("epub") || o === "epub")
188
+ return "epub";
189
+ if (["mobi", "azw", "azw3", "kf8"].includes(o) || r === "application/x-mobipocket-ebook" || r === "application/vnd.amazon.ebook")
190
+ return "mobi";
191
+ if (["csv", "tsv"].includes(o) || r === "text/csv" || r === "text/tab-separated-values")
192
+ return "csv";
193
+ if (o === "xml" || r === "application/xml" || r === "text/xml")
194
+ return "xml";
195
+ if (["srt", "vtt", "lrc", "elrc", "ass", "ssa", "ttml", "dfxp"].includes(o) || r === "text/vtt" || r === "application/x-subrip" || r === "application/ttml+xml")
196
+ return "subtitle";
197
+ if (o === "zip" || r === "application/zip" || r === "application/x-zip-compressed")
198
+ return "zip";
199
+ if (["ttf", "otf", "woff", "woff2"].includes(o) || r.startsWith("font/") || r === "application/font-woff" || r === "application/font-woff2" || r === "application/x-font-ttf" || r === "application/x-font-otf" || r === "application/font-sfnt")
200
+ return "font";
201
+ if (r.startsWith("video/") || ["mp4", "webm", "ogg", "ogv", "mov", "avi", "mkv", "m4v", "3gp", "flv"].includes(o))
202
+ return "video";
203
+ if (r.startsWith("audio/") || ["mp3", "wav", "ogg", "m4a", "flac", "aac"].includes(o))
204
+ return "audio";
205
+ if (o === "md" || o === "markdown")
206
+ return "markdown";
207
+ if (r === "application/json" || o === "json" || o === "jsonc")
208
+ return "json";
209
+ const a = [
210
+ "txt",
211
+ "log",
212
+ "lock",
213
+ "js",
214
+ "jsx",
215
+ "ts",
216
+ "tsx",
217
+ "py",
218
+ "java",
219
+ "cpp",
220
+ "c",
221
+ "h",
222
+ "cs",
223
+ "php",
224
+ "rb",
225
+ "go",
226
+ "mod",
227
+ "rs",
228
+ "swift",
229
+ "kt",
230
+ "lua",
231
+ "vim",
232
+ "html",
233
+ "css",
234
+ "scss",
235
+ "sass",
236
+ "less",
237
+ "yaml",
238
+ "yml",
239
+ "toml",
240
+ "ini",
241
+ "conf",
242
+ "env",
243
+ "diff",
244
+ "patch",
245
+ "sh",
246
+ "bash",
247
+ "zsh",
248
+ "sql"
249
+ ];
250
+ return r.startsWith("text/") || a.includes(o) ? "text" : "unsupported";
251
+ }
252
+ function xr(t) {
253
+ var e;
254
+ const o = ((e = t.split(".").pop()) == null ? void 0 : e.toLowerCase()) || "";
255
+ return {
256
+ js: "javascript",
257
+ jsx: "jsx",
258
+ ts: "typescript",
259
+ tsx: "tsx",
260
+ py: "python",
261
+ java: "java",
262
+ cpp: "cpp",
263
+ c: "c",
264
+ cs: "csharp",
265
+ php: "php",
266
+ rb: "ruby",
267
+ go: "go",
268
+ mod: "go",
269
+ rs: "rust",
270
+ swift: "swift",
271
+ kt: "kotlin",
272
+ lua: "lua",
273
+ vim: "vim",
274
+ scala: "scala",
275
+ sh: "bash",
276
+ bash: "bash",
277
+ zsh: "bash",
278
+ json: "json",
279
+ jsonc: "json",
280
+ xml: "xml",
281
+ html: "html",
282
+ css: "css",
283
+ scss: "scss",
284
+ sass: "sass",
285
+ less: "less",
286
+ sql: "sql",
287
+ yaml: "yaml",
288
+ yml: "yaml",
289
+ toml: "toml",
290
+ ini: "ini",
291
+ env: "bash",
292
+ conf: "nginx",
293
+ diff: "diff",
294
+ patch: "diff",
295
+ log: "log",
296
+ md: "markdown",
297
+ txt: "text"
298
+ }[o] || "text";
299
+ }
300
+ function Ge(t) {
301
+ return t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / (1024 * 1024)).toFixed(1)} MB`;
302
+ }
303
+ function yr(t) {
304
+ var e;
305
+ return (((e = t.split(".").pop()) == null ? void 0 : e.toLowerCase()) || "") === "tsv" ? " " : ",";
306
+ }
307
+ function Fr(t, e = {}) {
308
+ const o = e.delimiter ?? ",", r = e.firstRowAsHeader ?? !0, a = [];
309
+ let n = [], i = "", s = !1, l = 0;
310
+ const f = t.length;
311
+ for (; l < f; ) {
312
+ const u = t[l];
313
+ if (s) {
314
+ if (u === '"') {
315
+ if (t[l + 1] === '"') {
316
+ i += '"', l += 2;
317
+ continue;
318
+ }
319
+ s = !1, l += 1;
320
+ continue;
321
+ }
322
+ i += u, l += 1;
323
+ continue;
324
+ }
325
+ if (u === '"') {
326
+ s = !0, l += 1;
327
+ continue;
328
+ }
329
+ if (u === o) {
330
+ n.push(i), i = "", l += 1;
331
+ continue;
332
+ }
333
+ if (u === "\r") {
334
+ t[l + 1] === `
335
+ ` && (l += 1), n.push(i), a.push(n), n = [], i = "", l += 1;
336
+ continue;
337
+ }
338
+ if (u === `
339
+ `) {
340
+ n.push(i), a.push(n), n = [], i = "", l += 1;
341
+ continue;
342
+ }
343
+ i += u, l += 1;
344
+ }
345
+ for ((i.length > 0 || n.length > 0) && (n.push(i), a.push(n)); a.length > 0; ) {
346
+ const u = a[a.length - 1];
347
+ if (u.length === 1 && u[0] === "")
348
+ a.pop();
349
+ else
350
+ break;
351
+ }
352
+ let c = [], d = a;
353
+ r && a.length > 0 && (c = a[0], d = a.slice(1));
354
+ const m = Math.max(
355
+ c.length,
356
+ ...d.map((u) => u.length),
357
+ 0
358
+ );
359
+ for (const u of d)
360
+ for (; u.length < m; ) u.push("");
361
+ return {
362
+ header: c,
363
+ rows: d,
364
+ columnCount: m,
365
+ delimiter: o
366
+ };
367
+ }
368
+ function Xe(t) {
369
+ const e = t instanceof Uint8Array ? t : new Uint8Array(t);
370
+ if (e.length >= 3 && e[0] === 239 && e[1] === 187 && e[2] === 191)
371
+ return new TextDecoder("utf-8").decode(e);
372
+ if (e.length >= 2 && e[0] === 255 && e[1] === 254)
373
+ return new TextDecoder("utf-16le").decode(e);
374
+ if (e.length >= 2 && e[0] === 254 && e[1] === 255)
375
+ return new TextDecoder("utf-16be").decode(e);
376
+ try {
377
+ return new TextDecoder("utf-8", { fatal: !0 }).decode(e);
378
+ } catch {
379
+ }
380
+ try {
381
+ return new TextDecoder("gbk").decode(e);
382
+ } catch {
383
+ }
384
+ return new TextDecoder("utf-8", { fatal: !1 }).decode(e);
385
+ }
386
+ async function _r(t, e) {
387
+ const o = !!e && ("fetcher" in e || "init" in e || "signal" in e), r = o ? e.fetcher ?? fetch : fetch, a = o ? e.signal : void 0, n = o ? e.init : e, i = a ? { ...n, signal: a } : n, s = await r(t, i);
388
+ if (!s.ok) throw new Error(`请求失败: ${s.status}`);
389
+ const l = await s.arrayBuffer();
390
+ return Xe(l);
391
+ }
392
+ async function Ke(t, e) {
393
+ if (t)
394
+ return typeof t == "function" ? await t(e) : t;
395
+ }
396
+ function Je(t, e) {
397
+ if (!t && !e) return;
398
+ if (!t) return e;
399
+ if (!e) return t;
400
+ const o = new Headers(t.headers || {});
401
+ return e.headers && new Headers(e.headers).forEach((r, a) => {
402
+ o.set(a, r);
403
+ }), {
404
+ ...t,
405
+ ...e,
406
+ headers: o
407
+ };
408
+ }
409
+ function Ye(t) {
410
+ const e = (t == null ? void 0 : t.requestHandler) ?? ((r, a) => fetch(r, a)), o = t == null ? void 0 : t.requestInit;
411
+ return async (r, a) => {
412
+ const n = await Ke(o, r), i = Je(n, a);
413
+ return e(r, i);
414
+ };
415
+ }
416
+ async function Qe(t, e = fetch, o) {
417
+ const r = await e(t, o);
418
+ if (!r.ok) throw new Error(`请求失败: ${r.status}`);
419
+ const a = await r.blob();
420
+ return URL.createObjectURL(a);
421
+ }
422
+ async function to(t, e, o = fetch, r) {
423
+ const a = await o(t, r);
424
+ if (!a.ok) throw new Error(`请求失败: ${a.status}`);
425
+ const n = await a.blob(), i = URL.createObjectURL(n);
426
+ try {
427
+ const s = document.createElement("a");
428
+ s.href = i, s.download = e, s.style.display = "none", document.body.appendChild(s), s.click(), document.body.removeChild(s);
429
+ } finally {
430
+ setTimeout(() => URL.revokeObjectURL(i), 1e3);
431
+ }
432
+ }
433
+ function Zt(t) {
434
+ const e = t.trim().replace(",", "."), o = e.split(":").map((r) => r.trim());
435
+ if (o.length === 3) {
436
+ const [r, a, n] = o;
437
+ return Number(r) * 3600 + Number(a) * 60 + Number(n);
438
+ }
439
+ if (o.length === 2) {
440
+ const [r, a] = o;
441
+ return Number(r) * 60 + Number(a);
442
+ }
443
+ return Number(e) || 0;
444
+ }
445
+ function kr(t) {
446
+ if (!isFinite(t) || t < 0) return "00:00:00.000";
447
+ const e = Math.floor(t * 1e3), o = e % 1e3, r = Math.floor(e / 1e3) % 60, a = Math.floor(e / 6e4) % 60, n = Math.floor(e / 36e5), i = (s, l = 2) => s.toString().padStart(l, "0");
448
+ return `${i(n)}:${i(a)}:${i(r)}.${i(o, 3)}`;
449
+ }
450
+ const Bt = /(\d{1,2}:)?\d{1,2}:\d{1,2}[.,]\d{1,3}\s*-->\s*(\d{1,2}:)?\d{1,2}:\d{1,2}[.,]\d{1,3}/, eo = /^\s*\[\d{1,2}:\d{1,2}(?:[.:]\d{1,3})?\]/;
451
+ function oo(t) {
452
+ const e = t.replace(/^\uFEFF/, "").trimStart();
453
+ return /^WEBVTT/.test(e) ? "vtt" : /^<\?xml/i.test(e) || /<tt\b[^>]*>/i.test(e) ? "ttml" : /^\[Script Info\]/im.test(e) || /^Dialogue:/m.test(e) ? /ScriptType:\s*v4\.00\s*$/im.test(e) ? "ssa" : "ass" : eo.test(e) || /^\[(ti|ar|al|au|by|length|offset|re|ve):/im.test(e) ? /<\d{1,2}:\d{1,2}(?:[.:]\d{1,3})?>/.test(e) ? "elrc" : "lrc" : "srt";
454
+ }
455
+ function Ht(t, e) {
456
+ const o = t.replace(/\r\n?/g, `
457
+ `).replace(/^\uFEFF/, "").split(`
458
+ `), r = [];
459
+ let a, n = 0;
460
+ if (e === "vtt") {
461
+ const i = [];
462
+ for (; n < o.length && o[n].trim() !== ""; )
463
+ i.push(o[n]), n++;
464
+ for (a = i.join(`
465
+ `); n < o.length && o[n].trim() === ""; ) n++;
466
+ }
467
+ for (; n < o.length; ) {
468
+ for (; n < o.length && o[n].trim() === ""; ) n++;
469
+ if (n >= o.length) break;
470
+ let i, s = null;
471
+ if (Bt.test(o[n]))
472
+ s = o[n], n++;
473
+ else if (i = o[n].trim() || void 0, n++, n < o.length && Bt.test(o[n]))
474
+ s = o[n], n++;
475
+ else
476
+ continue;
477
+ if (!s) continue;
478
+ const l = s.match(/([\d:.,]+)\s*-->\s*([\d:.,]+)/);
479
+ if (!l) continue;
480
+ const f = Zt(l[1]), c = Zt(l[2]), d = [];
481
+ for (; n < o.length && o[n].trim() !== ""; )
482
+ d.push(o[n]), n++;
483
+ r.push({ id: i, start: f, end: c, text: d.join(`
484
+ `) });
485
+ }
486
+ return { format: e, cues: r, header: a };
487
+ }
488
+ function lt(t, e, o) {
489
+ const r = Number(t), a = Number(e);
490
+ let n = 0;
491
+ if (o) {
492
+ const i = (o + "000").slice(0, 3);
493
+ n = Number(i);
494
+ }
495
+ return r * 60 + a + n / 1e3;
496
+ }
497
+ function ie(t, e) {
498
+ const o = /^\[(ti|ar|al|au|by|length|offset|re|ve):(.*)\]$/i.exec(t.trim());
499
+ if (!o) return !1;
500
+ const r = o[1].toLowerCase(), a = o[2].trim();
501
+ if (e.metadata[r] = a, r === "offset") {
502
+ const n = Number(a);
503
+ isNaN(n) || (e.offsetMs = n);
504
+ }
505
+ return !0;
506
+ }
507
+ function ro(t) {
508
+ const e = t.replace(/\r\n?/g, `
509
+ `).replace(/^\uFEFF/, "").split(`
510
+ `), o = { metadata: {}, offsetMs: 0 }, r = /\[(\d{1,2}):(\d{1,2})(?:[.:](\d{1,3}))?\]/g, a = [];
511
+ for (const i of e) {
512
+ const s = i.trim();
513
+ if (!s || ie(s, o)) continue;
514
+ const l = [];
515
+ let f = 0;
516
+ r.lastIndex = 0;
517
+ let c;
518
+ for (; (c = r.exec(s)) !== null && c.index === f; )
519
+ l.push(lt(c[1], c[2], c[3])), f = c.index + c[0].length;
520
+ if (l.length === 0) continue;
521
+ const d = s.slice(f).trim();
522
+ for (const m of l)
523
+ a.push({ start: m, text: d });
524
+ }
525
+ a.sort((i, s) => i.start - s.start);
526
+ const n = o.offsetMs / 1e3;
527
+ return { format: "lrc", cues: a.map((i, s) => {
528
+ const l = Math.max(0, i.start - n), f = a[s + 1], c = f ? Math.max(l, f.start - n) : l + 5;
529
+ return { start: l, end: c, text: i.text };
530
+ }), metadata: o.metadata };
531
+ }
532
+ function no(t) {
533
+ const e = t.replace(/\r\n?/g, `
534
+ `).replace(/^\uFEFF/, "").split(`
535
+ `), o = { metadata: {}, offsetMs: 0 }, r = /\[(\d{1,2}):(\d{1,2})(?:[.:](\d{1,3}))?\]/g, a = /<(\d{1,2}):(\d{1,2})(?:[.:](\d{1,3}))?>/g, n = [];
536
+ for (const s of e) {
537
+ const l = s.trim();
538
+ if (!l || ie(l, o)) continue;
539
+ const f = [];
540
+ let c = 0;
541
+ r.lastIndex = 0;
542
+ let d;
543
+ for (; (d = r.exec(l)) !== null && d.index === c; )
544
+ f.push(lt(d[1], d[2], d[3])), c = d.index + d[0].length;
545
+ if (f.length === 0) continue;
546
+ const m = l.slice(c);
547
+ for (const u of f)
548
+ n.push({ start: u, raw: m });
549
+ }
550
+ n.sort((s, l) => s.start - l.start);
551
+ const i = o.offsetMs / 1e3;
552
+ return { format: "elrc", cues: n.map((s, l) => {
553
+ const f = [];
554
+ let c = "", d = 0, m = null;
555
+ a.lastIndex = 0;
556
+ let u;
557
+ for (; (u = a.exec(s.raw)) !== null; ) {
558
+ const j = s.raw.slice(d, u.index);
559
+ m !== null && j && f.push({ start: Math.max(0, m - i), text: j }), c += j, m = lt(u[1], u[2], u[3]), d = u.index + u[0].length;
560
+ }
561
+ const w = s.raw.slice(d);
562
+ m !== null && w && f.push({ start: Math.max(0, m - i), text: w }), c += w;
563
+ const C = Math.max(0, s.start - i), x = n[l + 1], _ = x ? Math.max(C, x.start - i) : C + 5;
564
+ return {
565
+ start: C,
566
+ end: _,
567
+ text: c.trim(),
568
+ words: f.length ? f : void 0
569
+ };
570
+ }), metadata: o.metadata };
571
+ }
572
+ function qt(t) {
573
+ const e = t.trim().split(":");
574
+ return e.length !== 3 ? 0 : Number(e[0]) * 3600 + Number(e[1]) * 60 + Number(e[2].replace(",", "."));
575
+ }
576
+ function Gt(t, e) {
577
+ const o = t.replace(/\r\n?/g, `
578
+ `).replace(/^\uFEFF/, "").split(`
579
+ `);
580
+ let r = "", a = [];
581
+ const n = [], i = [];
582
+ for (const s of o) {
583
+ const l = s.replace(/\s+$/, ""), f = l.trim(), c = /^\[([^\]]+)\]\s*$/.exec(f);
584
+ if (c) {
585
+ r = c[1].toLowerCase(), i.push(l);
586
+ continue;
587
+ }
588
+ if (r !== "events") {
589
+ i.push(l);
590
+ continue;
591
+ }
592
+ const d = /^Format:\s*(.+)$/i.exec(f);
593
+ if (d) {
594
+ a = d[1].split(",").map((y) => y.trim());
595
+ continue;
596
+ }
597
+ const m = /^(Dialogue|Comment):\s*(.+)$/i.exec(f);
598
+ if (!m || m[1].toLowerCase() === "comment" || a.length === 0) continue;
599
+ const u = a.length, w = m[2].split(","), C = w.slice(0, u - 1), x = w.slice(u - 1).join(","), _ = {};
600
+ a.forEach((y, E) => {
601
+ _[y] = E === u - 1 ? x : C[E] ?? "";
602
+ });
603
+ const j = qt(_.Start || ""), k = qt(_.End || ""), M = (_.Text || "").replace(/\\N/g, `
604
+ `).replace(/\\n/g, `
605
+ `).replace(/\\h/g, " ").replace(/\{[^}]*\}/g, "");
606
+ n.push({ start: j, end: k, text: M, style: _.Style });
607
+ }
608
+ return n.sort((s, l) => s.start - l.start), {
609
+ format: e,
610
+ cues: n,
611
+ header: i.join(`
612
+ `).trim() || void 0
613
+ };
614
+ }
615
+ function q(t) {
616
+ const e = t.trim();
617
+ if (!e) return 0;
618
+ const o = /^(\d+(?:\.\d+)?)(h|m|s|ms|f|t)$/i.exec(e);
619
+ if (o) {
620
+ const a = Number(o[1]), n = o[2].toLowerCase();
621
+ return n === "h" ? a * 3600 : n === "m" ? a * 60 : n === "ms" ? a / 1e3 : a;
622
+ }
623
+ const r = e.split(":");
624
+ return r.length === 3 ? Number(r[0]) * 3600 + Number(r[1]) * 60 + Number(r[2]) : r.length === 2 ? Number(r[0]) * 60 + Number(r[1]) : Number(e) || 0;
625
+ }
626
+ function ao(t) {
627
+ return t.replace(/&#x([0-9a-fA-F]+);/g, (e, o) => String.fromCharCode(parseInt(o, 16))).replace(/&#(\d+);/g, (e, o) => String.fromCharCode(Number(o))).replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&");
628
+ }
629
+ function io(t) {
630
+ var e, o, r;
631
+ const a = [], n = /<(?:[\w-]+:)?p\b([^>]*)>([\s\S]*?)<\/(?:[\w-]+:)?p\s*>/gi;
632
+ let i;
633
+ for (; (i = n.exec(t)) !== null; ) {
634
+ const s = i[1], l = i[2], f = ((e = /\bbegin\s*=\s*["']([^"']+)["']/i.exec(s)) == null ? void 0 : e[1]) || "", c = ((o = /\bend\s*=\s*["']([^"']+)["']/i.exec(s)) == null ? void 0 : o[1]) || "", d = ((r = /\bdur\s*=\s*["']([^"']+)["']/i.exec(s)) == null ? void 0 : r[1]) || "", m = q(f);
635
+ let u;
636
+ c ? u = q(c) : d ? u = m + q(d) : u = m + 5;
637
+ const w = ao(
638
+ l.replace(/<(?:[\w-]+:)?br\s*\/?>/gi, `
639
+ `).replace(/<[^>]+>/g, "")
640
+ ).replace(/[ \t]+/g, " ").replace(/\n /g, `
641
+ `).trim();
642
+ (w || m || u) && a.push({ start: m, end: u, text: w });
643
+ }
644
+ return a.sort((s, l) => s.start - l.start), { format: "ttml", cues: a };
645
+ }
646
+ function so(t) {
647
+ const e = t.replace(/^\uFEFF/, "");
648
+ if (typeof DOMParser < "u") {
649
+ const o = new DOMParser().parseFromString(e, "application/xml");
650
+ if (o.getElementsByTagName("parsererror").length === 0) {
651
+ const r = o.getElementsByTagNameNS ? o.getElementsByTagNameNS("*", "p") : o.getElementsByTagName("p");
652
+ if (r.length > 0) {
653
+ const a = [];
654
+ for (let n = 0; n < r.length; n++) {
655
+ const i = r[n], s = i.getAttribute("begin") || "", l = i.getAttribute("end") || "", f = i.getAttribute("dur") || "", c = q(s);
656
+ let d;
657
+ l ? d = q(l) : f ? d = c + q(f) : d = c + 5;
658
+ let m = "";
659
+ i.childNodes.forEach((w) => {
660
+ if (w.nodeType === 3)
661
+ m += w.nodeValue || "";
662
+ else if (w.nodeType === 1) {
663
+ const C = w;
664
+ (C.localName || C.tagName).toLowerCase() === "br" ? m += `
665
+ ` : m += C.textContent || "";
666
+ }
667
+ });
668
+ const u = m.replace(/[ \t]+/g, " ").replace(/\n /g, `
669
+ `).trim();
670
+ (u || c || d) && a.push({ start: c, end: d, text: u });
671
+ }
672
+ return a.sort((n, i) => n.start - i.start), { format: "ttml", cues: a };
673
+ }
674
+ }
675
+ }
676
+ return io(e);
677
+ }
678
+ function Cr(t, e) {
679
+ switch (e ?? oo(t)) {
680
+ case "lrc":
681
+ return ro(t);
682
+ case "elrc":
683
+ return no(t);
684
+ case "ass":
685
+ return Gt(t, "ass");
686
+ case "ssa":
687
+ return Gt(t, "ssa");
688
+ case "ttml":
689
+ return so(t);
690
+ case "vtt":
691
+ return Ht(t, "vtt");
692
+ case "srt":
693
+ default:
694
+ return Ht(t, "srt");
695
+ }
696
+ }
697
+ async function Nr(t) {
698
+ return Ue.loadAsync(t);
699
+ }
700
+ function Rr(t) {
701
+ const e = [];
702
+ return t.forEach((o, r) => {
703
+ var a;
704
+ const n = r.dir, i = n && !o.endsWith("/") ? o + "/" : o, s = n ? i.replace(/\/$/, "") : i, l = s.lastIndexOf("/"), f = l >= 0 ? s.slice(l + 1) : s, c = l >= 0 ? s.slice(0, l) : "", d = n ? 0 : ((a = r._data) == null ? void 0 : a.uncompressedSize) ?? 0;
705
+ e.push({
706
+ path: i,
707
+ name: f,
708
+ dir: c,
709
+ isDir: n,
710
+ size: d,
711
+ date: r.date
712
+ });
713
+ }), e;
714
+ }
715
+ function Mr(t) {
716
+ const e = { name: "", path: "", isDir: !0, children: [], size: 0 }, o = /* @__PURE__ */ new Map();
717
+ o.set("", e);
718
+ const r = (n) => {
719
+ if (o.has(n)) return o.get(n);
720
+ const i = n.split("/").filter(Boolean);
721
+ let s = e, l = "";
722
+ for (const f of i) {
723
+ l = l ? `${l}/${f}` : f;
724
+ let c = o.get(l);
725
+ c || (c = { name: f, path: l + "/", isDir: !0, children: [], size: 0 }, s.children.push(c), o.set(l, c)), s = c;
726
+ }
727
+ return s;
728
+ };
729
+ for (const n of t) {
730
+ if (n.isDir) {
731
+ r(n.path.replace(/\/$/, ""));
732
+ continue;
733
+ }
734
+ r(n.dir).children.push({
735
+ name: n.name,
736
+ path: n.path,
737
+ isDir: !1,
738
+ size: n.size
739
+ });
740
+ }
741
+ const a = (n) => {
742
+ if (n.children) {
743
+ n.children.sort((i, s) => i.isDir !== s.isDir ? i.isDir ? -1 : 1 : i.name.localeCompare(s.name));
744
+ for (const i of n.children) a(i);
745
+ }
746
+ };
747
+ return a(e), e;
748
+ }
749
+ async function jr(t, e, o) {
750
+ const r = t.file(e);
751
+ if (!r) throw new Error(`ZIP entry not found: ${e}`);
752
+ const a = await r.async("arraybuffer");
753
+ return new Blob([a], o ? { type: o } : void 0);
754
+ }
755
+ function lo(t) {
756
+ return t ? t.startsWith("#") ? t : t.length === 8 ? "#" + t.substring(2) : t.length === 6 ? "#" + t : "#000000" : "#000000";
757
+ }
758
+ const po = [
759
+ "FFFFFF",
760
+ "000000",
761
+ "E7E6E6",
762
+ "44546A",
763
+ "4472C4",
764
+ "ED7D31",
765
+ "A5A5A5",
766
+ "FFC000",
767
+ "5B9BD5",
768
+ "70AD47"
769
+ ], fo = [
770
+ "000000",
771
+ "FFFFFF",
772
+ "FF0000",
773
+ "00FF00",
774
+ "0000FF",
775
+ "FFFF00",
776
+ "FF00FF",
777
+ "00FFFF",
778
+ "000000",
779
+ "FFFFFF",
780
+ "FF0000",
781
+ "00FF00",
782
+ "0000FF",
783
+ "FFFF00",
784
+ "FF00FF",
785
+ "00FFFF",
786
+ "800000",
787
+ "008000",
788
+ "000080",
789
+ "808000",
790
+ "800080",
791
+ "008080",
792
+ "C0C0C0",
793
+ "808080",
794
+ "9999FF",
795
+ "993366",
796
+ "FFFFCC",
797
+ "CCFFFF",
798
+ "660066",
799
+ "FF8080",
800
+ "0066CC",
801
+ "CCCCFF",
802
+ "000080",
803
+ "FF00FF",
804
+ "FFFF00",
805
+ "00FFFF",
806
+ "800080",
807
+ "800000",
808
+ "008080",
809
+ "0000FF",
810
+ "00CCFF",
811
+ "CCFFFF",
812
+ "CCFFCC",
813
+ "FFFF99",
814
+ "99CCFF",
815
+ "FF99CC",
816
+ "CC99FF",
817
+ "FFCC99",
818
+ "3366FF",
819
+ "33CCCC",
820
+ "99CC00",
821
+ "FFCC00",
822
+ "FF9900",
823
+ "FF6600",
824
+ "666699",
825
+ "969696",
826
+ "003366",
827
+ "339966",
828
+ "003300",
829
+ "333300",
830
+ "993300",
831
+ "993366",
832
+ "333399",
833
+ "333333"
834
+ ];
835
+ function co(t, e) {
836
+ const o = parseInt(t.substring(0, 2), 16), r = parseInt(t.substring(2, 4), 16), a = parseInt(t.substring(4, 6), 16), n = (f) => e < 0 ? Math.round(f * (1 + e)) : Math.round(f + (255 - f) * e), i = Math.min(255, Math.max(0, n(o))), s = Math.min(255, Math.max(0, n(r))), l = Math.min(255, Math.max(0, n(a)));
837
+ return i.toString(16).padStart(2, "0") + s.toString(16).padStart(2, "0") + l.toString(16).padStart(2, "0");
838
+ }
839
+ function uo(t) {
840
+ if (t && t.type === "pattern" && t.pattern === "solid") {
841
+ const e = t.fgColor;
842
+ if (e)
843
+ return dt(e);
844
+ }
845
+ }
846
+ function dt(t) {
847
+ if (t) {
848
+ if ("argb" in t && typeof t.argb == "string" && t.argb)
849
+ return lo(t.argb);
850
+ if ("theme" in t && typeof t.theme == "number") {
851
+ const e = po[t.theme] || "000000", o = "tint" in t && typeof t.tint == "number" ? t.tint : 0;
852
+ return "#" + (o !== 0 ? co(e, o) : e);
853
+ }
854
+ if ("indexed" in t && typeof t.indexed == "number") {
855
+ const e = fo[t.indexed];
856
+ if (e) return "#" + e;
857
+ }
858
+ }
859
+ }
860
+ function mo(t) {
861
+ if (!t || !t.style) return;
862
+ const e = dt(t.color) || "#000000";
863
+ return [t.style, e];
864
+ }
865
+ function ho(t) {
866
+ const e = {};
867
+ let o = !1;
868
+ if (t.font) {
869
+ const a = t.font;
870
+ if ((a.name || a.size || a.bold || a.italic) && (o = !0, e.font = {}, a.name && (e.font.name = a.name), a.size && (e.font.size = a.size), a.bold && (e.font.bold = !0), a.italic && (e.font.italic = !0)), a.color) {
871
+ const n = dt(a.color);
872
+ n && (o = !0, e.color = n);
873
+ }
874
+ a.underline && (o = !0, e.underline = !0), a.strike && (o = !0, e.strike = !0);
875
+ }
876
+ const r = uo(t.fill);
877
+ if (r && (o = !0, e.bgcolor = r), t.alignment) {
878
+ const a = t.alignment;
879
+ a.horizontal && (o = !0, e.align = a.horizontal), a.vertical && (o = !0, e.valign = a.vertical), a.wrapText && (o = !0, e.textwrap = !0);
880
+ }
881
+ if (t.border) {
882
+ const a = {};
883
+ let n = !1;
884
+ const i = ["top", "bottom", "left", "right"];
885
+ for (const s of i) {
886
+ const l = mo(t.border[s]);
887
+ l && (a[s] = l, n = !0);
888
+ }
889
+ n && (o = !0, e.border = a);
890
+ }
891
+ return o ? e : null;
892
+ }
893
+ function go(t) {
894
+ return JSON.stringify(t);
895
+ }
896
+ function bo(t, e, o) {
897
+ const r = ho(t);
898
+ if (!r) return -1;
899
+ const a = go(r), n = o.get(a);
900
+ if (n !== void 0) return n;
901
+ const i = e.length;
902
+ return e.push(r), o.set(a, i), i;
903
+ }
904
+ function wo(t) {
905
+ const e = t.value;
906
+ if (e == null) return "";
907
+ if (typeof e == "string") return e;
908
+ if (typeof e == "number") return String(e);
909
+ if (typeof e == "boolean") return e ? "TRUE" : "FALSE";
910
+ if (e instanceof Date)
911
+ return e.toLocaleDateString();
912
+ if (typeof e == "object" && "formula" in e) {
913
+ const o = e.result;
914
+ return o != null ? String(o) : "";
915
+ }
916
+ return typeof e == "object" && "richText" in e ? e.richText.map((o) => o.text).join("") : typeof e == "object" && "hyperlink" in e ? e.text || "" : typeof e == "object" && "error" in e ? String(e.error) : String(e);
917
+ }
918
+ function vo(t) {
919
+ const e = t.split(":"), o = Xt(e[0]), r = e[1] ? Xt(e[1]) : o;
920
+ return {
921
+ top: o.row,
922
+ left: o.col,
923
+ bottom: r.row,
924
+ right: r.col
925
+ };
926
+ }
927
+ function Xt(t) {
928
+ const e = t.match(/^([A-Z]+)(\d+)$/);
929
+ if (!e) return { row: 1, col: 1 };
930
+ const o = e[1], r = parseInt(e[2], 10);
931
+ let a = 0;
932
+ for (let n = 0; n < o.length; n++)
933
+ a = a * 26 + (o.charCodeAt(n) - 64);
934
+ return { row: r, col: a };
935
+ }
936
+ function Pr(t) {
937
+ const e = [];
938
+ return t.eachSheet((o) => {
939
+ const r = [], a = /* @__PURE__ */ new Map(), n = [], i = {}, s = {}, l = o.columnCount;
940
+ for (let m = 1; m <= l; m++) {
941
+ const u = o.getColumn(m);
942
+ u.width && (s[String(m - 1)] = { width: Math.round(u.width * 7.5) });
943
+ }
944
+ s.len = Math.max(l, 26);
945
+ const f = /* @__PURE__ */ new Map(), c = o.model, d = (c == null ? void 0 : c.merges) || [];
946
+ for (const m of d) {
947
+ n.push(m);
948
+ const { top: u, left: w, bottom: C, right: x } = vo(m), _ = C - u, j = x - w;
949
+ f.set(`${u - 1},${w - 1}`, [_, j]);
950
+ }
951
+ o.eachRow({ includeEmpty: !0 }, (m, u) => {
952
+ const w = u - 1, C = {};
953
+ m.eachCell({ includeEmpty: !1 }, (_, j) => {
954
+ const k = j - 1;
955
+ if (_.isMerged && _.master !== _) return;
956
+ const M = wo(_), y = bo(_, r, a), E = { text: M };
957
+ y !== -1 && (E.style = y);
958
+ const W = `${w},${k}`;
959
+ f.has(W) && (E.merge = f.get(W)), C[String(k)] = E;
960
+ });
961
+ const x = { cells: C };
962
+ m.height && (x.height = Math.round(m.height * 1.333)), i[String(w)] = x;
963
+ }), e.push({
964
+ name: o.name,
965
+ styles: r,
966
+ merges: n,
967
+ rows: i,
968
+ cols: s
969
+ });
970
+ }), e;
971
+ }
972
+ function Tr(t, e, o = "Sheet1") {
973
+ const r = t.length > 0, a = r ? [{ font: { bold: !0 } }] : [], n = {};
974
+ if (r) {
975
+ const s = {};
976
+ t.forEach((l, f) => {
977
+ s[String(f)] = { text: l, style: 0 };
978
+ }), n[0] = { cells: s };
979
+ }
980
+ const i = r ? 1 : 0;
981
+ return e.forEach((s, l) => {
982
+ const f = {};
983
+ s.forEach((c, d) => {
984
+ c !== void 0 && c !== "" && (f[String(d)] = { text: c });
985
+ }), n[String(l + i)] = { cells: f };
986
+ }), [{ name: o, styles: a, rows: n }];
987
+ }
988
+ function xo(t, e) {
989
+ var o;
990
+ if (typeof window > "u") return;
991
+ const r = (t == null ? void 0 : t.version) || ((o = t == null ? void 0 : t.GlobalWorkerOptions) == null ? void 0 : o.version) || "", {
992
+ workerSrc: a = `https://unpkg.com/pdfjs-dist@${r}/build/pdf.worker.min.mjs`,
993
+ cMapUrl: n = `https://unpkg.com/pdfjs-dist@${r}/cmaps/`,
994
+ cMapPacked: i = !0
995
+ } = e || {};
996
+ t.GlobalWorkerOptions && (t.GlobalWorkerOptions.workerSrc = a, t.GlobalWorkerOptions.cMapUrl = n, t.GlobalWorkerOptions.cMapPacked = i);
997
+ }
998
+ const yo = {
999
+ // ─────── common ───────
1000
+ "common.download": "下载",
1001
+ "common.close": "关闭",
1002
+ "common.loading": "加载中",
1003
+ "common.unknown_error": "未知错误",
1004
+ "common.unsupported_preview": "不支持预览此文件类型 ({type})",
1005
+ // ─────── toolbar ───────
1006
+ "toolbar.zoom_in": "放大",
1007
+ "toolbar.zoom_out": "缩小",
1008
+ "toolbar.rotate_left": "向左旋转",
1009
+ "toolbar.rotate_right": "向右旋转",
1010
+ "toolbar.reset": "复原",
1011
+ "toolbar.fit_to_window": "适应窗口",
1012
+ "toolbar.original_size": "原始尺寸",
1013
+ "toolbar.toc": "目录",
1014
+ "toolbar.prev_page": "上一页",
1015
+ "toolbar.next_page": "下一页",
1016
+ "toolbar.full_width": "全屏宽度",
1017
+ "toolbar.normal_width": "正常宽度",
1018
+ "toolbar.wrap_on": "自动换行",
1019
+ "toolbar.wrap_off": "不换行",
1020
+ "toolbar.source": "源码",
1021
+ "toolbar.preview": "预览",
1022
+ // ─────── image ───────
1023
+ "image.load_failed": "图片加载失败",
1024
+ "image.decode_failed": "图片解码失败",
1025
+ // ─────── pdf ───────
1026
+ "pdf.load_failed": "PDF 文件加载失败",
1027
+ // ─────── docx ───────
1028
+ "docx.parse_failed": "Word 文档解析失败",
1029
+ // ─────── xlsx ───────
1030
+ "xlsx.loading": "加载 Excel 中...",
1031
+ "xlsx.load_failed": "Excel 加载失败",
1032
+ "xlsx.parse_failed": "Excel 文件解析失败",
1033
+ "xlsx.not_found": "Excel 文件不存在",
1034
+ // ─────── pptx ───────
1035
+ "pptx.loading": "加载 PPT 中...",
1036
+ "pptx.load_failed": "PPT 加载失败",
1037
+ "pptx.parse_failed": "PPT 文件解析失败",
1038
+ "pptx.not_found": "PPT 文件不存在",
1039
+ "pptx.invalid_format": "PPT 文件格式错误或已损坏",
1040
+ "pptx.no_pages": "PPT 文件无有效页面",
1041
+ "pptx.timeout": "加载超时,请检查网络或稍后重试",
1042
+ // ─────── msg ───────
1043
+ "msg.parse_failed": "Outlook 邮件解析失败",
1044
+ "msg.parse_failed_short": "邮件解析失败",
1045
+ "msg.empty_body": "(无邮件正文)",
1046
+ // ─────── epub ───────
1047
+ "epub.load_failed": "EPUB 文件加载失败",
1048
+ // ─────── mobi ───────
1049
+ "mobi.load_failed": "电子书加载失败,文件可能已损坏或带有 DRM 保护",
1050
+ // ─────── video ───────
1051
+ "video.loading": "加载视频中...",
1052
+ "video.load_failed": "视频加载失败",
1053
+ "video.load_failed_with_error": "视频加载失败: {error}",
1054
+ "video.format_not_supported": "浏览器不支持 {format} 格式,建议转换为 MP4/WebM 格式",
1055
+ "video.unsupported_title": "该视频格式无法在浏览器中直接播放",
1056
+ "video.unsupported_detail": "{format} 是浏览器原生不支持的容器/编码(常见于 AVI / WMV / FLV 及部分 MKV)。请下载到本地播放器观看,或转换为 MP4(H.264 + AAC)。",
1057
+ "video.codec_not_supported_detail": "视频或音频编码 {codecs} 浏览器无法解码。请转换为 MP4(H.264 + AAC)后再预览。",
1058
+ // ─────── audio (aria-label) ───────
1059
+ "audio.aria.play": "播放",
1060
+ "audio.aria.pause": "暂停",
1061
+ "audio.aria.forward_10": "前进 10 秒",
1062
+ "audio.aria.backward_10": "后退 10 秒",
1063
+ "audio.aria.mute": "静音",
1064
+ "audio.aria.unmute": "取消静音",
1065
+ "audio.aria.loop_on": "开启循环",
1066
+ "audio.aria.loop_off": "关闭循环",
1067
+ "audio.aria.progress": "播放进度",
1068
+ "audio.aria.volume": "音量",
1069
+ // ─────── markdown ───────
1070
+ "markdown.load_failed": "Markdown 文件加载失败",
1071
+ "markdown.copy_code": "复制代码",
1072
+ "markdown.copied": "已复制",
1073
+ // ─────── json ───────
1074
+ "json.load_failed": "JSON 文件加载失败",
1075
+ "json.items": "items",
1076
+ "json.keys": "keys",
1077
+ // ─────── csv ───────
1078
+ "csv.loading": "加载 CSV 中...",
1079
+ "csv.load_failed": "CSV 文件加载失败",
1080
+ "csv.parse_failed": "CSV 解析失败",
1081
+ // ─────── xml ───────
1082
+ "xml.load_failed": "XML 文件加载失败",
1083
+ // ─────── subtitle / lyric ───────
1084
+ "subtitle.load_failed": "字幕文件加载失败",
1085
+ "subtitle.parse_failed": "字幕解析失败",
1086
+ "subtitle.lines": "lines",
1087
+ "subtitle.cues": "cues",
1088
+ "subtitle.meta.title": "标题",
1089
+ "subtitle.meta.artist": "艺术家",
1090
+ "subtitle.meta.album": "专辑",
1091
+ "subtitle.meta.author": "作者",
1092
+ "subtitle.meta.by": "制作",
1093
+ "subtitle.meta.length": "时长",
1094
+ "subtitle.meta.offset": "偏移",
1095
+ "subtitle.meta.editor": "编辑器",
1096
+ "subtitle.meta.version": "版本",
1097
+ // ─────── zip ───────
1098
+ "zip.load_failed": "ZIP 文件加载失败",
1099
+ "zip.parse_failed": "ZIP 解析失败",
1100
+ // ─────── text ───────
1101
+ "text.load_failed": "文本文件加载失败",
1102
+ // ─────── font ───────
1103
+ "font.loading": "加载字体中...",
1104
+ "font.load_failed": "字体文件加载失败",
1105
+ "font.parse_failed": "字体解析失败",
1106
+ "font.metadata_loading": "解析元数据中...",
1107
+ "font.metadata_unavailable": "元数据不可用",
1108
+ "font.meta.family": "字体家族",
1109
+ "font.meta.subfamily": "子系列",
1110
+ "font.meta.version": "版本",
1111
+ "font.meta.designer": "设计师",
1112
+ "font.meta.glyphs": "字形数量",
1113
+ "font.meta.format": "格式",
1114
+ "font.sample_text_placeholder": "输入自定义文本..."
1115
+ }, Fo = {
1116
+ // ─────── common ───────
1117
+ "common.download": "Download",
1118
+ "common.close": "Close",
1119
+ "common.loading": "Loading",
1120
+ "common.unknown_error": "Unknown error",
1121
+ "common.unsupported_preview": "Preview not supported for this file type ({type})",
1122
+ // ─────── toolbar ───────
1123
+ "toolbar.zoom_in": "Zoom in",
1124
+ "toolbar.zoom_out": "Zoom out",
1125
+ "toolbar.rotate_left": "Rotate left",
1126
+ "toolbar.rotate_right": "Rotate right",
1127
+ "toolbar.reset": "Reset",
1128
+ "toolbar.fit_to_window": "Fit to window",
1129
+ "toolbar.original_size": "Original size",
1130
+ "toolbar.toc": "Table of contents",
1131
+ "toolbar.prev_page": "Previous page",
1132
+ "toolbar.next_page": "Next page",
1133
+ "toolbar.full_width": "Full width",
1134
+ "toolbar.normal_width": "Normal width",
1135
+ "toolbar.wrap_on": "Word wrap",
1136
+ "toolbar.wrap_off": "No wrap",
1137
+ "toolbar.source": "Source",
1138
+ "toolbar.preview": "Preview",
1139
+ // ─────── image ───────
1140
+ "image.load_failed": "Failed to load image",
1141
+ "image.decode_failed": "Failed to decode image",
1142
+ // ─────── pdf ───────
1143
+ "pdf.load_failed": "Failed to load PDF",
1144
+ // ─────── docx ───────
1145
+ "docx.parse_failed": "Failed to parse Word document",
1146
+ // ─────── xlsx ───────
1147
+ "xlsx.loading": "Loading Excel...",
1148
+ "xlsx.load_failed": "Failed to load Excel",
1149
+ "xlsx.parse_failed": "Failed to parse Excel file",
1150
+ "xlsx.not_found": "Excel file not found",
1151
+ // ─────── pptx ───────
1152
+ "pptx.loading": "Loading PPT...",
1153
+ "pptx.load_failed": "Failed to load PPT",
1154
+ "pptx.parse_failed": "Failed to parse PPT file",
1155
+ "pptx.not_found": "PPT file not found",
1156
+ "pptx.invalid_format": "PPT file format is invalid or corrupted",
1157
+ "pptx.no_pages": "PPT file has no valid pages",
1158
+ "pptx.timeout": "Loading timed out, please check your network and retry",
1159
+ // ─────── msg ───────
1160
+ "msg.parse_failed": "Failed to parse Outlook message",
1161
+ "msg.parse_failed_short": "Failed to parse message",
1162
+ "msg.empty_body": "(No message body)",
1163
+ // ─────── epub ───────
1164
+ "epub.load_failed": "Failed to load EPUB",
1165
+ // ─────── mobi ───────
1166
+ "mobi.load_failed": "Failed to load ebook — file may be corrupted or DRM-protected",
1167
+ // ─────── video ───────
1168
+ "video.loading": "Loading video...",
1169
+ "video.load_failed": "Failed to load video",
1170
+ "video.load_failed_with_error": "Failed to load video: {error}",
1171
+ "video.format_not_supported": "Browser does not support {format} format. Please convert to MP4/WebM",
1172
+ "video.unsupported_title": "This video format cannot be played in the browser",
1173
+ "video.unsupported_detail": "{format} is a container/codec that browsers do not natively support (typical for AVI / WMV / FLV and some MKV files). Please download and play it in a local player, or convert to MP4 (H.264 + AAC).",
1174
+ "video.codec_not_supported_detail": "The video or audio codec ({codecs}) cannot be decoded by the browser. Please convert to MP4 (H.264 + AAC) before previewing.",
1175
+ // ─────── audio (aria-label) ───────
1176
+ "audio.aria.play": "Play",
1177
+ "audio.aria.pause": "Pause",
1178
+ "audio.aria.forward_10": "Forward 10 seconds",
1179
+ "audio.aria.backward_10": "Back 10 seconds",
1180
+ "audio.aria.mute": "Mute",
1181
+ "audio.aria.unmute": "Unmute",
1182
+ "audio.aria.loop_on": "Enable loop",
1183
+ "audio.aria.loop_off": "Disable loop",
1184
+ "audio.aria.progress": "Playback progress",
1185
+ "audio.aria.volume": "Volume",
1186
+ // ─────── markdown ───────
1187
+ "markdown.load_failed": "Failed to load Markdown",
1188
+ "markdown.copy_code": "Copy code",
1189
+ "markdown.copied": "Copied",
1190
+ // ─────── json ───────
1191
+ "json.load_failed": "Failed to load JSON",
1192
+ "json.items": "items",
1193
+ "json.keys": "keys",
1194
+ // ─────── csv ───────
1195
+ "csv.loading": "Loading CSV...",
1196
+ "csv.load_failed": "Failed to load CSV",
1197
+ "csv.parse_failed": "Failed to parse CSV",
1198
+ // ─────── xml ───────
1199
+ "xml.load_failed": "Failed to load XML",
1200
+ // ─────── subtitle / lyric ───────
1201
+ "subtitle.load_failed": "Failed to load subtitle",
1202
+ "subtitle.parse_failed": "Failed to parse subtitle",
1203
+ "subtitle.lines": "lines",
1204
+ "subtitle.cues": "cues",
1205
+ "subtitle.meta.title": "Title",
1206
+ "subtitle.meta.artist": "Artist",
1207
+ "subtitle.meta.album": "Album",
1208
+ "subtitle.meta.author": "Author",
1209
+ "subtitle.meta.by": "By",
1210
+ "subtitle.meta.length": "Length",
1211
+ "subtitle.meta.offset": "Offset",
1212
+ "subtitle.meta.editor": "Editor",
1213
+ "subtitle.meta.version": "Version",
1214
+ // ─────── zip ───────
1215
+ "zip.load_failed": "Failed to load ZIP",
1216
+ "zip.parse_failed": "Failed to parse ZIP",
1217
+ // ─────── text ───────
1218
+ "text.load_failed": "Failed to load text file",
1219
+ // ─────── font ───────
1220
+ "font.loading": "Loading font...",
1221
+ "font.load_failed": "Failed to load font",
1222
+ "font.parse_failed": "Failed to parse font",
1223
+ "font.metadata_loading": "Parsing metadata...",
1224
+ "font.metadata_unavailable": "Metadata unavailable",
1225
+ "font.meta.family": "Family",
1226
+ "font.meta.subfamily": "Subfamily",
1227
+ "font.meta.version": "Version",
1228
+ "font.meta.designer": "Designer",
1229
+ "font.meta.glyphs": "Glyphs",
1230
+ "font.meta.format": "Format",
1231
+ "font.sample_text_placeholder": "Type custom text..."
1232
+ }, et = {
1233
+ "zh-CN": yo,
1234
+ "en-US": Fo
1235
+ }, _o = /\{(\w+)\}/g;
1236
+ function ko(t, e) {
1237
+ return e ? t.replace(_o, (o, r) => {
1238
+ const a = e[r];
1239
+ return a === void 0 ? `{${r}}` : String(a);
1240
+ }) : t;
1241
+ }
1242
+ function ut(t) {
1243
+ var e;
1244
+ const o = t.fallbackLocale ?? "zh-CN", r = et[t.locale] ?? et[o] ?? et["zh-CN"], a = (e = t.messages) == null ? void 0 : e[t.locale], n = a ? { ...r, ...a } : r, i = et["zh-CN"];
1245
+ return (s, l) => {
1246
+ const f = n[s] ?? i[s] ?? s;
1247
+ return ko(f, l);
1248
+ };
1249
+ }
1250
+ const Co = {
1251
+ // 标准图片格式
1252
+ jpg: "image/jpeg",
1253
+ jpeg: "image/jpeg",
1254
+ png: "image/png",
1255
+ gif: "image/gif",
1256
+ webp: "image/webp",
1257
+ svg: "image/svg+xml",
1258
+ bmp: "image/bmp",
1259
+ ico: "image/x-icon",
1260
+ // 高级图片格式
1261
+ heic: "image/heic",
1262
+ heif: "image/heif",
1263
+ avif: "image/avif",
1264
+ tif: "image/tiff",
1265
+ tiff: "image/tiff",
1266
+ // RAW 格式
1267
+ cr2: "image/x-canon-cr2",
1268
+ nef: "image/x-nikon-nef",
1269
+ arw: "image/x-sony-arw",
1270
+ dng: "image/x-adobe-dng",
1271
+ raf: "image/x-fuji-raf",
1272
+ orf: "image/x-olympus-orf",
1273
+ // 其他专业格式
1274
+ psd: "image/vnd.adobe.photoshop",
1275
+ jp2: "image/jp2",
1276
+ jpx: "image/jpx",
1277
+ j2k: "image/jp2",
1278
+ // 文档格式
1279
+ pdf: "application/pdf",
1280
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
1281
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
1282
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
1283
+ ppt: "application/vnd.ms-powerpoint",
1284
+ // 其他
1285
+ msg: "application/vnd.ms-outlook",
1286
+ epub: "application/epub+zip",
1287
+ mobi: "application/x-mobipocket-ebook",
1288
+ azw: "application/vnd.amazon.ebook",
1289
+ azw3: "application/vnd.amazon.ebook",
1290
+ kf8: "application/vnd.amazon.ebook",
1291
+ csv: "text/csv",
1292
+ tsv: "text/tab-separated-values",
1293
+ xml: "application/xml",
1294
+ json: "application/json",
1295
+ md: "text/markdown",
1296
+ markdown: "text/markdown",
1297
+ txt: "text/plain",
1298
+ zip: "application/zip",
1299
+ // 字体
1300
+ ttf: "font/ttf",
1301
+ otf: "font/otf",
1302
+ woff: "font/woff",
1303
+ woff2: "font/woff2",
1304
+ // 视频
1305
+ mp4: "video/mp4",
1306
+ webm: "video/webm",
1307
+ ogg: "video/ogg",
1308
+ ogv: "video/ogg",
1309
+ mov: "video/quicktime",
1310
+ avi: "video/x-msvideo",
1311
+ mkv: "video/x-matroska",
1312
+ m4v: "video/mp4",
1313
+ "3gp": "video/3gpp",
1314
+ flv: "video/x-flv",
1315
+ // 音频
1316
+ mp3: "audio/mpeg",
1317
+ wav: "audio/wav",
1318
+ m4a: "audio/mp4",
1319
+ flac: "audio/flac",
1320
+ aac: "audio/aac",
1321
+ // 字幕
1322
+ srt: "application/x-subrip",
1323
+ vtt: "text/vtt",
1324
+ lrc: "application/x-lrc",
1325
+ elrc: "application/x-lrc",
1326
+ ass: "text/x-ssa",
1327
+ ssa: "text/x-ssa",
1328
+ ttml: "application/ttml+xml",
1329
+ dfxp: "application/ttml+xml"
1330
+ };
1331
+ function No(t) {
1332
+ const e = t.toLowerCase();
1333
+ return Co[e] || "application/octet-stream";
1334
+ }
1335
+ function Ro(t) {
1336
+ var e;
1337
+ const o = ((e = t.split(".").pop()) == null ? void 0 : e.toLowerCase()) || "";
1338
+ return No(o);
1339
+ }
1340
+ function Mo(t) {
1341
+ return [
1342
+ "image/heic",
1343
+ "image/heif",
1344
+ "image/avif",
1345
+ "image/tiff",
1346
+ "image/x-canon-cr2",
1347
+ "image/x-nikon-nef",
1348
+ "image/x-sony-arw",
1349
+ "image/x-adobe-dng",
1350
+ "image/x-fuji-raf",
1351
+ "image/x-olympus-orf",
1352
+ "image/vnd.adobe.photoshop",
1353
+ "image/jp2",
1354
+ "image/jpx"
1355
+ ].includes(t);
1356
+ }
1357
+ const it = /* @__PURE__ */ new Map();
1358
+ async function zr(t) {
1359
+ if (it.has(t))
1360
+ return it.get(t);
1361
+ if (!Mo(t))
1362
+ return null;
1363
+ try {
1364
+ let e = null;
1365
+ return t === "image/heic" || t === "image/heif" ? e = (await import("./heicLoader-CH_raQNn-1fBLaICM.mjs")).default : t === "image/avif" ? e = (await import("./avifLoader-BP3fgcMm-BnpxLhxp.mjs")).default : t === "image/tiff" ? e = (await import("./tiffLoader-CTFKVLqJ-B84NfwhR.mjs")).default : t === "image/x-canon-cr2" || t === "image/x-nikon-nef" || t === "image/x-sony-arw" || t === "image/x-adobe-dng" || t === "image/x-fuji-raf" || t === "image/x-olympus-orf" ? e = (await import("./rawLoader-0mLvxCNp-CJmERiK7.mjs")).default : t === "image/vnd.adobe.photoshop" ? e = (await import("./psdLoader-Doxw3mWm-DVOGFSlh.mjs")).default : (t === "image/jp2" || t === "image/jpx") && (e = (await import("./jp2Loader-Bn-qPMbD-Bn-qPMbD.mjs")).default), e && it.set(t, e), e;
1366
+ } catch (e) {
1367
+ return console.warn(`Failed to load image decoder for ${t}:`, e), null;
1368
+ }
1369
+ }
1370
+ async function Sr(t) {
1371
+ if (t.type && t.type !== "application/octet-stream")
1372
+ return t.type;
1373
+ const e = Ro(t.name);
1374
+ if (e !== "application/octet-stream")
1375
+ return e;
1376
+ if (t instanceof Blob || t instanceof File) {
1377
+ const o = await jo(t);
1378
+ if (o !== "application/octet-stream")
1379
+ return o;
1380
+ }
1381
+ return "application/octet-stream";
1382
+ }
1383
+ async function jo(t) {
1384
+ try {
1385
+ const e = new Uint8Array(await t.slice(0, 12).arrayBuffer());
1386
+ if (e[4] === 102 && e[5] === 116 && e[6] === 121 && e[7] === 112) {
1387
+ const o = String.fromCharCode(...e.slice(8, 12));
1388
+ if (o === "heic" || o === "heix" || o === "mif1")
1389
+ return "image/heic";
1390
+ }
1391
+ if (e[0] === 73 && e[1] === 73 && e[2] === 42 && e[3] === 0 || e[0] === 77 && e[1] === 77 && e[2] === 0 && e[3] === 42)
1392
+ return "image/tiff";
1393
+ if (e[4] === 102 && e[5] === 116 && e[6] === 121 && e[7] === 112 && String.fromCharCode(...e.slice(8, 12)) === "avif")
1394
+ return "image/avif";
1395
+ if (e[0] === 56 && e[1] === 66 && e[2] === 80 && e[3] === 83)
1396
+ return "image/vnd.adobe.photoshop";
1397
+ if (e[0] === 255 && e[1] === 79 && e[2] === 255 && e[3] === 81)
1398
+ return "image/jp2";
1399
+ } catch (e) {
1400
+ console.warn("Failed to detect image format by magic number:", e);
1401
+ }
1402
+ return "application/octet-stream";
1403
+ }
1404
+ const mt = pt(null), Po = ({
1405
+ locale: t = "zh-CN",
1406
+ messages: e,
1407
+ children: o
1408
+ }) => {
1409
+ const r = H(() => {
1410
+ const a = ut({ locale: t, messages: e });
1411
+ return { locale: t, t: a };
1412
+ }, [t, e]);
1413
+ return /* @__PURE__ */ p(mt.Provider, { value: r, children: o });
1414
+ };
1415
+ let st = null;
1416
+ function To() {
1417
+ return st || (st = ut({ locale: "zh-CN" })), st;
1418
+ }
1419
+ function se() {
1420
+ const t = K(mt);
1421
+ return (t == null ? void 0 : t.t) ?? To();
1422
+ }
1423
+ function Er() {
1424
+ const t = K(mt);
1425
+ return (t == null ? void 0 : t.locale) ?? "zh-CN";
1426
+ }
1427
+ const le = pt(null), zo = ({ theme: t, children: e }) => /* @__PURE__ */ p(le.Provider, { value: t, children: e });
1428
+ function Lr() {
1429
+ return K(le) ?? "dark";
1430
+ }
1431
+ const So = ({ className: t }) => /* @__PURE__ */ p(
1432
+ "svg",
1433
+ {
1434
+ xmlns: "http://www.w3.org/2000/svg",
1435
+ viewBox: "0 0 24 24",
1436
+ fill: "none",
1437
+ stroke: "currentColor",
1438
+ strokeWidth: "2",
1439
+ strokeLinecap: "round",
1440
+ strokeLinejoin: "round",
1441
+ className: t,
1442
+ children: /* @__PURE__ */ p("text", { x: "12", y: "17.5", textAnchor: "middle", fontSize: "20", fontWeight: "bold", fill: "currentColor", stroke: "none", children: "1:1" })
1443
+ }
1444
+ );
1445
+ function Eo(t) {
1446
+ return [
1447
+ {
1448
+ items: [
1449
+ { type: "button", icon: /* @__PURE__ */ p(Jt, { className: "rfp-w-4 rfp-h-4" }), tooltip: t.t("toolbar.zoom_out"), action: t.onZoomOut, disabled: t.zoom <= 0.01 },
1450
+ { type: "text", content: `${Math.round(t.zoom * 100)}%`, minWidth: "3rem" },
1451
+ { type: "button", icon: /* @__PURE__ */ p(Yt, { className: "rfp-w-4 rfp-h-4" }), tooltip: t.t("toolbar.zoom_in"), action: t.onZoomIn, disabled: t.zoom >= 10 }
1452
+ ]
1453
+ },
1454
+ {
1455
+ items: [
1456
+ { type: "button", icon: /* @__PURE__ */ p(Ee, { className: "rfp-w-4 rfp-h-4" }), tooltip: t.t("toolbar.fit_to_window"), action: t.onFitToWidth },
1457
+ { type: "button", icon: /* @__PURE__ */ p(So, { className: "rfp-w-4 rfp-h-4" }), tooltip: t.t("toolbar.original_size"), action: t.onOriginalSize }
1458
+ ]
1459
+ },
1460
+ {
1461
+ items: [
1462
+ { type: "button", icon: /* @__PURE__ */ p(Le, { className: "rfp-w-4 rfp-h-4" }), tooltip: t.t("toolbar.rotate_left"), action: t.onRotateLeft },
1463
+ { type: "button", icon: /* @__PURE__ */ p(We, { className: "rfp-w-4 rfp-h-4" }), tooltip: t.t("toolbar.rotate_right"), action: t.onRotateRight }
1464
+ ]
1465
+ },
1466
+ {
1467
+ items: [
1468
+ { type: "button", icon: /* @__PURE__ */ p(Qt, { className: "rfp-w-4 rfp-h-4" }), tooltip: t.t("toolbar.reset"), action: t.onReset }
1469
+ ]
1470
+ }
1471
+ ];
1472
+ }
1473
+ function Lo(t) {
1474
+ return [
1475
+ {
1476
+ items: [
1477
+ { type: "button", icon: /* @__PURE__ */ p(Jt, { className: "rfp-w-4 rfp-h-4" }), tooltip: t.t("toolbar.zoom_out"), action: t.onZoomOut, disabled: t.zoom <= 0.01 },
1478
+ { type: "text", content: `${Math.round(t.zoom * 100)}%`, minWidth: "3rem" },
1479
+ { type: "button", icon: /* @__PURE__ */ p(Yt, { className: "rfp-w-4 rfp-h-4" }), tooltip: t.t("toolbar.zoom_in"), action: t.onZoomIn, disabled: t.zoom >= 10 }
1480
+ ]
1481
+ },
1482
+ {
1483
+ items: [
1484
+ { type: "button", icon: /* @__PURE__ */ p(Qt, { className: "rfp-w-4 rfp-h-4" }), tooltip: t.t("toolbar.reset"), action: t.onReset }
1485
+ ]
1486
+ }
1487
+ ];
1488
+ }
1489
+ function Wo(t) {
1490
+ return [
1491
+ {
1492
+ items: [
1493
+ { type: "button", icon: /* @__PURE__ */ p(te, { className: "rfp-w-4 rfp-h-4" }), tooltip: t.t("toolbar.toc"), action: () => {
1494
+ var e;
1495
+ return (e = t.epubRef.current) == null ? void 0 : e.toggleToc();
1496
+ } }
1497
+ ]
1498
+ },
1499
+ {
1500
+ items: [
1501
+ { type: "button", icon: /* @__PURE__ */ p(ft, { className: "rfp-w-4 rfp-h-4" }), tooltip: t.t("toolbar.prev_page"), action: () => {
1502
+ var e;
1503
+ return (e = t.epubRef.current) == null ? void 0 : e.prevPage();
1504
+ } },
1505
+ { type: "text", content: `${t.current} / ${t.total}`, minWidth: "4rem" },
1506
+ { type: "button", icon: /* @__PURE__ */ p(ct, { className: "rfp-w-4 rfp-h-4" }), tooltip: t.t("toolbar.next_page"), action: () => {
1507
+ var e;
1508
+ return (e = t.epubRef.current) == null ? void 0 : e.nextPage();
1509
+ } }
1510
+ ]
1511
+ },
1512
+ {
1513
+ items: [
1514
+ {
1515
+ type: "button",
1516
+ icon: t.fullWidth ? /* @__PURE__ */ p(ee, { className: "rfp-w-4 rfp-h-4" }) : /* @__PURE__ */ p(oe, { className: "rfp-w-4 rfp-h-4" }),
1517
+ tooltip: t.fullWidth ? t.t("toolbar.normal_width") : t.t("toolbar.full_width"),
1518
+ action: () => {
1519
+ var e;
1520
+ return (e = t.epubRef.current) == null ? void 0 : e.toggleFullWidth();
1521
+ }
1522
+ }
1523
+ ]
1524
+ }
1525
+ ];
1526
+ }
1527
+ function $o(t) {
1528
+ return [
1529
+ {
1530
+ items: [
1531
+ {
1532
+ type: "button",
1533
+ icon: /* @__PURE__ */ p(te, { className: "rfp-w-4 rfp-h-4" }),
1534
+ tooltip: t.t("toolbar.toc"),
1535
+ action: () => {
1536
+ var e;
1537
+ return (e = t.mobiRef.current) == null ? void 0 : e.toggleToc();
1538
+ }
1539
+ }
1540
+ ]
1541
+ },
1542
+ {
1543
+ items: [
1544
+ {
1545
+ type: "button",
1546
+ icon: /* @__PURE__ */ p(ft, { className: "rfp-w-4 rfp-h-4" }),
1547
+ tooltip: t.t("toolbar.prev_page"),
1548
+ action: () => {
1549
+ var e;
1550
+ return (e = t.mobiRef.current) == null ? void 0 : e.prevPage();
1551
+ }
1552
+ },
1553
+ {
1554
+ type: "text",
1555
+ content: `${t.current} / ${t.total}`,
1556
+ minWidth: "4rem"
1557
+ },
1558
+ {
1559
+ type: "button",
1560
+ icon: /* @__PURE__ */ p(ct, { className: "rfp-w-4 rfp-h-4" }),
1561
+ tooltip: t.t("toolbar.next_page"),
1562
+ action: () => {
1563
+ var e;
1564
+ return (e = t.mobiRef.current) == null ? void 0 : e.nextPage();
1565
+ }
1566
+ }
1567
+ ]
1568
+ },
1569
+ {
1570
+ items: [
1571
+ {
1572
+ type: "button",
1573
+ icon: t.fullWidth ? /* @__PURE__ */ p(ee, { className: "rfp-w-4 rfp-h-4" }) : /* @__PURE__ */ p(oe, { className: "rfp-w-4 rfp-h-4" }),
1574
+ tooltip: t.fullWidth ? t.t("toolbar.normal_width") : t.t("toolbar.full_width"),
1575
+ action: () => {
1576
+ var e;
1577
+ return (e = t.mobiRef.current) == null ? void 0 : e.toggleFullWidth();
1578
+ }
1579
+ }
1580
+ ]
1581
+ }
1582
+ ];
1583
+ }
1584
+ function Do({ stats: t }) {
1585
+ return t ? [
1586
+ {
1587
+ items: [
1588
+ {
1589
+ type: "text",
1590
+ content: `${t.files} files · ${t.dirs} dirs · ${Ge(t.size)}`,
1591
+ minWidth: "10rem"
1592
+ }
1593
+ ]
1594
+ }
1595
+ ] : [];
1596
+ }
1597
+ function Ao(t) {
1598
+ const e = [
1599
+ {
1600
+ items: [
1601
+ {
1602
+ type: "button",
1603
+ icon: /* @__PURE__ */ p($e, { className: "rfp-w-4 rfp-h-4" }),
1604
+ tooltip: t.wordWrap ? t.t("toolbar.wrap_off") : t.t("toolbar.wrap_on"),
1605
+ action: t.onToggleWrap
1606
+ }
1607
+ ]
1608
+ }
1609
+ ];
1610
+ return t.isHtml && e.push({
1611
+ items: [
1612
+ {
1613
+ type: "button",
1614
+ icon: t.htmlPreview ? /* @__PURE__ */ p(re, { className: "rfp-w-4 rfp-h-4" }) : /* @__PURE__ */ p(ne, { className: "rfp-w-4 rfp-h-4" }),
1615
+ tooltip: t.htmlPreview ? t.t("toolbar.source") : t.t("toolbar.preview"),
1616
+ action: t.onToggleHtmlPreview
1617
+ }
1618
+ ]
1619
+ }), e;
1620
+ }
1621
+ function Uo(t) {
1622
+ return [
1623
+ {
1624
+ items: [
1625
+ {
1626
+ type: "button",
1627
+ icon: t.viewMode === "preview" ? /* @__PURE__ */ p(re, { className: "rfp-w-4 rfp-h-4" }) : /* @__PURE__ */ p(ne, { className: "rfp-w-4 rfp-h-4" }),
1628
+ tooltip: t.viewMode === "preview" ? t.t("toolbar.source") : t.t("toolbar.preview"),
1629
+ action: t.onToggleViewMode
1630
+ }
1631
+ ]
1632
+ }
1633
+ ];
1634
+ }
1635
+ const Oo = {
1636
+ fetcher: (t, e) => fetch(t, e)
1637
+ }, ht = pt(Oo), Io = ({
1638
+ requestInit: t,
1639
+ requestHandler: e,
1640
+ shouldFetchAsBlob: o,
1641
+ children: r
1642
+ }) => {
1643
+ const a = H(
1644
+ () => ({
1645
+ fetcher: Ye({ requestInit: t, requestHandler: e }),
1646
+ shouldFetchAsBlob: o
1647
+ }),
1648
+ [t, e, o]
1649
+ );
1650
+ return /* @__PURE__ */ p(ht.Provider, { value: a, children: r });
1651
+ };
1652
+ function Vo() {
1653
+ return K(ht).fetcher;
1654
+ }
1655
+ function Zo(t) {
1656
+ const { fetcher: e, shouldFetchAsBlob: o } = K(ht), r = !!(t && (o != null && o(t))), [a, n] = F(""), i = B(null);
1657
+ return L(() => {
1658
+ if (!t || !r) {
1659
+ i.current && (URL.revokeObjectURL(i.current), i.current = null), n("");
1660
+ return;
1661
+ }
1662
+ let s = !1;
1663
+ return n(""), Qe(t.url, e).then((l) => {
1664
+ if (s) {
1665
+ URL.revokeObjectURL(l);
1666
+ return;
1667
+ }
1668
+ i.current && URL.revokeObjectURL(i.current), i.current = l, n(l);
1669
+ }).catch((l) => {
1670
+ s || (console.error("[file-preview] resolve blob url failed:", l), n(t.url));
1671
+ }), () => {
1672
+ s = !0;
1673
+ };
1674
+ }, [t == null ? void 0 : t.id, t == null ? void 0 : t.url, r, e]), L(() => () => {
1675
+ i.current && (URL.revokeObjectURL(i.current), i.current = null);
1676
+ }, []), t ? r ? a : t.url : "";
1677
+ }
1678
+ const Bo = R(
1679
+ () => import("./index-BCuRRLYt.mjs").then((t) => ({ default: t.ImageRenderer }))
1680
+ ), Ho = R(
1681
+ () => import("./index-BYdqrqnR.mjs").then((t) => ({ default: t.PdfRenderer }))
1682
+ ), qo = R(
1683
+ () => import("./index-CdmkF0CO.mjs").then((t) => ({ default: t.DocxRenderer }))
1684
+ ), Go = R(
1685
+ () => import("./index-_mP0FkqE.mjs").then((t) => ({ default: t.XlsxRenderer }))
1686
+ ), Xo = R(
1687
+ () => import("./index-BiyghBxu.mjs").then((t) => ({ default: t.PptxRenderer }))
1688
+ ), Ko = R(
1689
+ () => import("./index-DaFlk9dd.mjs").then((t) => ({ default: t.MsgRenderer }))
1690
+ ), Jo = R(
1691
+ () => import("./index-BJ6vTNxc.mjs").then((t) => ({ default: t.EpubRenderer }))
1692
+ ), Yo = R(
1693
+ () => import("./index-DBEG73K1.mjs").then((t) => ({ default: t.MobiRenderer }))
1694
+ ), Qo = R(
1695
+ () => import("./index-D660ENHx.mjs").then((t) => ({ default: t.VideoRenderer }))
1696
+ ), tr = R(
1697
+ () => import("./index-ow-nGpuu.mjs").then((t) => ({ default: t.AudioRenderer }))
1698
+ ), er = R(
1699
+ () => import("./index-C8CyS_sj.mjs").then((t) => ({ default: t.MarkdownRenderer }))
1700
+ ), or = R(
1701
+ () => import("./index-C8OrFLd5.mjs").then((t) => ({ default: t.JsonRenderer }))
1702
+ ), rr = R(
1703
+ () => import("./index-qOC5xQyK.mjs").then((t) => ({ default: t.CsvRenderer }))
1704
+ ), nr = R(
1705
+ () => import("./index-B57rEPin.mjs").then((t) => ({ default: t.XmlRenderer }))
1706
+ ), ar = R(
1707
+ () => import("./index-CCkHAeLh.mjs").then((t) => ({ default: t.SubtitleRenderer }))
1708
+ ), ir = R(
1709
+ () => import("./index-nLTQXCV7.mjs").then((t) => ({ default: t.ZipRenderer }))
1710
+ ), sr = R(
1711
+ () => import("./index-nVblatyi.mjs").then((t) => ({ default: t.TextRenderer }))
1712
+ ), lr = R(
1713
+ () => import("./index-rUfsiVR8.mjs").then((t) => ({ default: t.FontRenderer }))
1714
+ ), Kt = ({
1715
+ fileName: t,
1716
+ fileType: e,
1717
+ onDownload: o
1718
+ }) => {
1719
+ const r = se();
1720
+ return /* @__PURE__ */ T("div", { className: "rfp-flex rfp-flex-col rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-p-8 rfp-gap-6", children: [
1721
+ /* @__PURE__ */ p("div", { className: "rfp-w-32 rfp-h-32 rfp-rounded-full rfp-bg-surface-2 rfp-flex rfp-items-center rfp-justify-center", children: /* @__PURE__ */ p(De, { className: "rfp-w-16 rfp-h-16 rfp-text-fg-secondary" }) }),
1722
+ /* @__PURE__ */ T("div", { className: "rfp-text-fg-primary rfp-text-center", children: [
1723
+ /* @__PURE__ */ p("p", { className: "rfp-text-xl rfp-font-medium rfp-mb-2", children: t }),
1724
+ /* @__PURE__ */ p("p", { className: "rfp-text-fg-secondary", children: r("common.unsupported_preview", { type: e }) })
1725
+ ] }),
1726
+ /* @__PURE__ */ T(
1727
+ "button",
1728
+ {
1729
+ onClick: o,
1730
+ className: "rfp-flex rfp-items-center rfp-gap-2 rfp-px-6 rfp-py-3 rfp-bg-surface-2 hover:rfp-bg-surface-3 rfp-backdrop-blur-sm rfp-rounded-lg rfp-text-fg-primary rfp-font-medium rfp-transition-all",
1731
+ children: [
1732
+ /* @__PURE__ */ p(ae, { className: "rfp-w-5 rfp-h-5" }),
1733
+ r("common.download")
1734
+ ]
1735
+ }
1736
+ )
1737
+ ] });
1738
+ }, pr = () => {
1739
+ const t = se();
1740
+ return /* @__PURE__ */ p("div", { className: "rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-text-fg-muted", children: /* @__PURE__ */ T("div", { className: "rfp-flex rfp-flex-col rfp-items-center rfp-gap-3", children: [
1741
+ /* @__PURE__ */ p("div", { className: "rfp-w-8 rfp-h-8 rfp-rounded-full rfp-border-2 rfp-border-fg-muted rfp-border-t-transparent rfp-animate-spin" }),
1742
+ /* @__PURE__ */ p("span", { className: "rfp-text-sm", children: t("common.loading") ?? "Loading..." })
1743
+ ] }) });
1744
+ }, fr = 3, gt = (t) => {
1745
+ const { requestInit: e, requestHandler: o, shouldFetchAsBlob: r } = t;
1746
+ return /* @__PURE__ */ p(
1747
+ Io,
1748
+ {
1749
+ requestInit: e,
1750
+ requestHandler: o,
1751
+ shouldFetchAsBlob: r,
1752
+ children: /* @__PURE__ */ p(cr, { ...t })
1753
+ }
1754
+ );
1755
+ }, cr = ({
1756
+ files: t,
1757
+ currentIndex: e,
1758
+ onNavigate: o,
1759
+ customRenderers: r = [],
1760
+ mode: a = "modal",
1761
+ onClose: n,
1762
+ zipNestingDepth: i = 0,
1763
+ locale: s = "zh-CN",
1764
+ messages: l,
1765
+ headless: f = !1,
1766
+ theme: c = "dark",
1767
+ onCustomEvent: d,
1768
+ onDownload: m,
1769
+ // 以下三项已由外层 RequestProvider 消费,Inner 内不再直接使用
1770
+ requestInit: u,
1771
+ requestHandler: w,
1772
+ shouldFetchAsBlob: C
1773
+ }) => {
1774
+ const x = H(
1775
+ () => ut({ locale: s, messages: l }),
1776
+ [s, l]
1777
+ ), [_, j] = F(
1778
+ () => typeof window < "u" ? window.matchMedia("(prefers-color-scheme: dark)").matches : !0
1779
+ );
1780
+ L(() => {
1781
+ if (c !== "auto") return;
1782
+ const h = window.matchMedia("(prefers-color-scheme: dark)"), v = (z) => j(z.matches);
1783
+ return h.addEventListener("change", v), () => h.removeEventListener("change", v);
1784
+ }, [c]);
1785
+ const k = c === "auto" ? _ ? "dark" : "light" : c, [M, y] = F(1), [E, W] = F(0), [pe, bt] = F(1), [, wt] = F(1), [O, rt] = F(0), [I, vt] = F(0), [fe, J] = F(0), D = B(null), xt = B(null), yt = B(null), [ce, Ft] = F(0), [de, _t] = F(0), [ue, kt] = F(!1), Ct = B(null), [me, Nt] = F(0), [he, Rt] = F(0), [ge, Mt] = F(!1), [be, jt] = F(null), [Pt, Tt] = F(!0), [zt, St] = F(!1), [Et, Lt] = F("preview"), [V, G] = F(!0), A = B(null), we = 2e3, Y = P(() => {
1786
+ G(!0), A.current && clearTimeout(A.current), A.current = window.setTimeout(() => {
1787
+ G(!1);
1788
+ }, we);
1789
+ }, []), ve = P(() => {
1790
+ Y();
1791
+ }, [Y]), $ = H(() => He(t), [t]), g = $[e], N = Zo(g), Z = H(() => g ? r.find((h) => h.test(g)) : null, [g, r]), b = g ? qe(g) : "unsupported", Wt = P(
1792
+ (h, v) => {
1793
+ g && (d == null || d({ name: h, payload: v, file: g }));
1794
+ },
1795
+ [g, d]
1796
+ ), $t = H(
1797
+ () => ({
1798
+ emit: Wt,
1799
+ t: x,
1800
+ theme: k,
1801
+ locale: s
1802
+ }),
1803
+ [Wt, x, k, s]
1804
+ );
1805
+ L(() => {
1806
+ y(1), W(0), bt(1), wt(1), rt(0), vt(0), J(0), G(!0), Ft(0), _t(0), kt(!1), Nt(0), Rt(0), Mt(!1), jt(null), Tt(!0), St(!1), Lt("preview"), A.current && clearTimeout(A.current);
1807
+ }, [e]), L(() => {
1808
+ if (b === "image" && O > 0 && I > 0 && D.current) {
1809
+ const h = D.current.clientWidth, v = D.current.clientHeight, z = h / O, S = v / I, X = Math.min(z, S);
1810
+ y(Math.max(0.01, Math.min(10, X)));
1811
+ }
1812
+ }, [b, O, I]), L(() => ($.length > 1 && Y(), () => {
1813
+ A.current && clearTimeout(A.current);
1814
+ }), [$.length, Y]), L(() => {
1815
+ const h = (v) => {
1816
+ v.key === "Escape" && a === "modal" ? n == null || n() : v.key === "ArrowLeft" && e > 0 ? o == null || o(e - 1) : v.key === "ArrowRight" && e < $.length - 1 && (o == null || o(e + 1));
1817
+ };
1818
+ if (a === "modal")
1819
+ return window.addEventListener("keydown", h), () => window.removeEventListener("keydown", h);
1820
+ {
1821
+ const v = xt.current;
1822
+ return v ? (v.addEventListener("keydown", h), () => v.removeEventListener("keydown", h)) : void 0;
1823
+ }
1824
+ }, [a, e, $.length, n, o]);
1825
+ const Dt = P(() => {
1826
+ y((h) => Math.min(h + 0.1, 10));
1827
+ }, []), At = P(() => {
1828
+ y((h) => Math.max(h - 0.1, 0.01));
1829
+ }, []), xe = P(() => {
1830
+ W((h) => h + 90);
1831
+ }, []), ye = P(() => {
1832
+ W((h) => h - 90);
1833
+ }, []), Fe = P(() => {
1834
+ if (D.current && O > 0 && I > 0) {
1835
+ const h = D.current.clientWidth, v = D.current.clientHeight, z = h / O, S = v / I, X = Math.min(z, S);
1836
+ y(Math.max(0.01, Math.min(10, X)));
1837
+ } else
1838
+ y(1);
1839
+ W(0), J((h) => h + 1);
1840
+ }, [O, I]), _e = P(() => {
1841
+ y(1), W(0), J((h) => h + 1);
1842
+ }, []), ke = P((h) => {
1843
+ y(h);
1844
+ }, []), Ut = P(() => {
1845
+ y(1), W(0), J((h) => h + 1);
1846
+ }, []), Ot = Vo(), nt = P(async () => {
1847
+ if (g) {
1848
+ if (m) {
1849
+ await m(g);
1850
+ return;
1851
+ }
1852
+ try {
1853
+ await to(g.url, g.name, Ot);
1854
+ } catch (h) {
1855
+ console.error("[file-preview] download failed:", h);
1856
+ }
1857
+ }
1858
+ }, [g, m, Ot]), Ce = P((h, v) => {
1859
+ Ft(h), _t(v);
1860
+ }, []), Ne = P((h, v) => {
1861
+ Nt(h), Rt(v);
1862
+ }, []), Re = P((h) => {
1863
+ jt(h);
1864
+ }, []);
1865
+ if (!g) return null;
1866
+ const Me = a === "modal" && !!n, Q = (() => {
1867
+ var h, v;
1868
+ if (Z)
1869
+ return ((h = Z.getToolbarGroups) == null ? void 0 : h.call(Z, g, $t)) ?? [];
1870
+ if (b === "image")
1871
+ return Eo({
1872
+ zoom: M,
1873
+ onZoomIn: Dt,
1874
+ onZoomOut: At,
1875
+ onFitToWidth: Fe,
1876
+ onOriginalSize: _e,
1877
+ onRotateLeft: ye,
1878
+ onRotateRight: xe,
1879
+ onReset: Ut,
1880
+ t: x
1881
+ });
1882
+ if (b === "pdf")
1883
+ return Lo({
1884
+ zoom: M,
1885
+ onZoomIn: Dt,
1886
+ onZoomOut: At,
1887
+ onReset: Ut,
1888
+ t: x
1889
+ });
1890
+ if (b === "epub")
1891
+ return Wo({
1892
+ epubRef: yt,
1893
+ current: ce,
1894
+ total: de,
1895
+ fullWidth: ue,
1896
+ t: x
1897
+ });
1898
+ if (b === "mobi")
1899
+ return $o({
1900
+ mobiRef: Ct,
1901
+ current: me,
1902
+ total: he,
1903
+ fullWidth: ge,
1904
+ t: x
1905
+ });
1906
+ if (b === "zip")
1907
+ return Do({ stats: be });
1908
+ if (b === "text") {
1909
+ const z = ((v = g.name.split(".").pop()) == null ? void 0 : v.toLowerCase()) || "";
1910
+ return Ao({
1911
+ wordWrap: Pt,
1912
+ onToggleWrap: () => Tt((S) => !S),
1913
+ isHtml: z === "html" || z === "htm",
1914
+ htmlPreview: zt,
1915
+ onToggleHtmlPreview: () => St((S) => !S),
1916
+ t: x
1917
+ });
1918
+ }
1919
+ return b === "markdown" ? Uo({
1920
+ viewMode: Et,
1921
+ onToggleViewMode: () => Lt((z) => z === "preview" ? "source" : "preview"),
1922
+ t: x
1923
+ }) : [];
1924
+ })(), It = [
1925
+ {
1926
+ items: [
1927
+ { type: "button", icon: /* @__PURE__ */ p(ae, { className: "rfp-w-4 rfp-h-4" }), tooltip: x("common.download"), action: nt }
1928
+ ]
1929
+ },
1930
+ ...Me ? [{
1931
+ items: [
1932
+ { type: "button", icon: /* @__PURE__ */ p(Ae, { className: "rfp-w-4 rfp-h-4" }), tooltip: x("common.close"), action: n }
1933
+ ]
1934
+ }] : []
1935
+ ], tt = (h, v) => h.map((z, S, X) => /* @__PURE__ */ T(Pe.Fragment, { children: [
1936
+ z.items.map(
1937
+ (U, Vt) => U.type === "button" ? /* @__PURE__ */ p(
1938
+ dr,
1939
+ {
1940
+ icon: U.icon,
1941
+ label: U.tooltip,
1942
+ onClick: U.action,
1943
+ disabled: U.disabled
1944
+ },
1945
+ `${S}-${Vt}`
1946
+ ) : /* @__PURE__ */ p(
1947
+ "span",
1948
+ {
1949
+ className: "rfp-text-xs rfp-text-center rfp-font-medium rfp-tabular-nums rfp-text-fg-tertiary",
1950
+ style: { minWidth: U.minWidth || "auto" },
1951
+ children: U.content
1952
+ },
1953
+ `${S}-${Vt}`
1954
+ )
1955
+ ),
1956
+ S < X.length - 1 && /* @__PURE__ */ p("div", { className: `rfp-w-px rfp-h-4 rfp-bg-divide ${v}` })
1957
+ ] }, S));
1958
+ return /* @__PURE__ */ p(Po, { locale: s, messages: l, children: /* @__PURE__ */ p(zo, { theme: k, children: /* @__PURE__ */ T(
1959
+ "div",
1960
+ {
1961
+ ref: xt,
1962
+ tabIndex: a === "embed" ? 0 : -1,
1963
+ "data-theme": k,
1964
+ className: "rfp-relative rfp-w-full rfp-h-full rfp-flex rfp-flex-col rfp-overflow-hidden rfp-outline-none",
1965
+ children: [
1966
+ !f && /* @__PURE__ */ T(
1967
+ ot.div,
1968
+ {
1969
+ initial: { opacity: 0 },
1970
+ animate: { opacity: 1 },
1971
+ exit: { opacity: 0 },
1972
+ className: "rfp-flex-shrink-0 rfp-z-10 rfp-backdrop-blur-md rfp-border-b rfp-bg-surface-toolbar rfp-border-line",
1973
+ style: { paddingTop: "env(safe-area-inset-top, 0px)" },
1974
+ children: [
1975
+ /* @__PURE__ */ T("div", { className: "rfp-flex rfp-items-center rfp-justify-between rfp-px-3 md:rfp-px-5 rfp-py-1.5 md:rfp-py-2.5", children: [
1976
+ /* @__PURE__ */ T("div", { className: "rfp-flex rfp-items-center rfp-flex-1 rfp-min-w-0 rfp-mr-2 md:rfp-mr-3", children: [
1977
+ /* @__PURE__ */ p("h2", { className: "rfp-font-medium rfp-text-xs md:rfp-text-sm rfp-truncate rfp-text-fg-primary", children: g.name }),
1978
+ /* @__PURE__ */ T("span", { className: "rfp-text-xs rfp-ml-2 rfp-flex-shrink-0 rfp-text-fg-muted", children: [
1979
+ e + 1,
1980
+ "/",
1981
+ $.length
1982
+ ] })
1983
+ ] }),
1984
+ /* @__PURE__ */ p("div", { className: "rfp-flex rfp-items-center rfp-gap-1 md:rfp-hidden rfp-flex-shrink-0", children: tt(It, "rfp-mx-0.5") }),
1985
+ /* @__PURE__ */ T("div", { className: "rfp-hidden md:rfp-flex rfp-items-center rfp-gap-1 rfp-flex-shrink-0", children: [
1986
+ tt(Q, "rfp-mx-1"),
1987
+ Q.length > 0 && /* @__PURE__ */ p("div", { className: "rfp-w-px rfp-h-4 rfp-mx-1 rfp-bg-divide" }),
1988
+ tt(It, "rfp-mx-1")
1989
+ ] })
1990
+ ] }),
1991
+ Q.length > 0 && /* @__PURE__ */ p("div", { className: "rfp-flex rfp-items-center rfp-gap-1 rfp-px-3 rfp-pb-1.5 rfp-overflow-x-auto scrollbar-hide md:rfp-hidden", children: tt(Q, "rfp-mx-0.5") })
1992
+ ]
1993
+ }
1994
+ ),
1995
+ /* @__PURE__ */ p(
1996
+ "div",
1997
+ {
1998
+ ref: D,
1999
+ className: "rfp-flex-1 rfp-flex rfp-items-center rfp-justify-center rfp-overflow-auto",
2000
+ onMouseMove: ve,
2001
+ children: Z ? Z.render(g, $t) : /* @__PURE__ */ T(Te, { fallback: /* @__PURE__ */ p(pr, {}), children: [
2002
+ b === "image" && /* @__PURE__ */ p(
2003
+ Bo,
2004
+ {
2005
+ url: N,
2006
+ zoom: M,
2007
+ rotation: E,
2008
+ resetKey: fe,
2009
+ fileSize: g.size,
2010
+ file: g,
2011
+ onZoomChange: ke,
2012
+ onNaturalWidthChange: rt,
2013
+ onNaturalHeightChange: vt
2014
+ }
2015
+ ),
2016
+ b === "pdf" && /* @__PURE__ */ p(
2017
+ Ho,
2018
+ {
2019
+ url: N,
2020
+ zoom: M,
2021
+ currentPage: pe,
2022
+ onPageChange: bt,
2023
+ onTotalPagesChange: wt,
2024
+ onPageWidthChange: rt
2025
+ }
2026
+ ),
2027
+ b === "docx" && /* @__PURE__ */ p(qo, { url: N }),
2028
+ b === "xlsx" && /* @__PURE__ */ p(Go, { url: N }),
2029
+ b === "pptx" && /* @__PURE__ */ p(Xo, { url: N }),
2030
+ b === "msg" && /* @__PURE__ */ p(Ko, { url: N }),
2031
+ b === "epub" && /* @__PURE__ */ p(
2032
+ Jo,
2033
+ {
2034
+ ref: yt,
2035
+ url: N,
2036
+ onChapterChange: Ce,
2037
+ onFullWidthChange: kt
2038
+ }
2039
+ ),
2040
+ b === "mobi" && /* @__PURE__ */ p(
2041
+ Yo,
2042
+ {
2043
+ ref: Ct,
2044
+ url: N,
2045
+ onChapterChange: Ne,
2046
+ onFullWidthChange: Mt
2047
+ }
2048
+ ),
2049
+ b === "video" && /* @__PURE__ */ p(Qo, { url: N, fileName: g.name }),
2050
+ b === "audio" && /* @__PURE__ */ p(tr, { url: N, fileName: g.name }),
2051
+ b === "markdown" && /* @__PURE__ */ p(er, { url: N, viewMode: Et }),
2052
+ b === "json" && /* @__PURE__ */ p(or, { url: N, fileName: g.name }),
2053
+ b === "csv" && /* @__PURE__ */ p(rr, { url: N, fileName: g.name }),
2054
+ b === "xml" && /* @__PURE__ */ p(nr, { url: N, fileName: g.name }),
2055
+ b === "subtitle" && /* @__PURE__ */ p(ar, { url: N, fileName: g.name }),
2056
+ b === "zip" && (i >= fr ? /* @__PURE__ */ p(
2057
+ Kt,
2058
+ {
2059
+ fileName: g.name,
2060
+ fileType: g.type,
2061
+ onDownload: nt
2062
+ }
2063
+ ) : /* @__PURE__ */ p(ir, { url: N, onStatsChange: Re, nestingDepth: i })),
2064
+ b === "text" && /* @__PURE__ */ p(
2065
+ sr,
2066
+ {
2067
+ url: N,
2068
+ fileName: g.name,
2069
+ wordWrap: Pt,
2070
+ htmlPreview: zt
2071
+ }
2072
+ ),
2073
+ b === "font" && /* @__PURE__ */ p(lr, { url: N }),
2074
+ b === "unsupported" && /* @__PURE__ */ p(
2075
+ Kt,
2076
+ {
2077
+ fileName: g.name,
2078
+ fileType: g.type,
2079
+ onDownload: nt
2080
+ }
2081
+ )
2082
+ ] }, g.url)
2083
+ }
2084
+ ),
2085
+ !f && $.length > 1 && /* @__PURE__ */ T(je, { children: [
2086
+ e > 0 && /* @__PURE__ */ p(
2087
+ ot.button,
2088
+ {
2089
+ initial: { opacity: 0 },
2090
+ animate: { opacity: V ? 1 : 0, x: V ? 0 : -20 },
2091
+ transition: { duration: 0.2 },
2092
+ onClick: () => o == null ? void 0 : o(e - 1),
2093
+ onMouseEnter: () => G(!0),
2094
+ style: { pointerEvents: V ? "auto" : "none" },
2095
+ className: "rfp-absolute rfp-z-20 rfp-left-2 md:rfp-left-4 rfp-top-1/2 -rfp-translate-y-1/2 rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-rounded-full rfp-backdrop-blur-xl rfp-border rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors rfp-shadow-2xl rfp-bg-surface-nav rfp-border-line hover:rfp-bg-surface-nav-hover rfp-text-fg-primary",
2096
+ children: /* @__PURE__ */ p(ft, { className: "rfp-w-5 rfp-h-5 md:rfp-w-6 md:rfp-h-6" })
2097
+ }
2098
+ ),
2099
+ e < $.length - 1 && /* @__PURE__ */ p(
2100
+ ot.button,
2101
+ {
2102
+ initial: { opacity: 0 },
2103
+ animate: { opacity: V ? 1 : 0, x: V ? 0 : 20 },
2104
+ transition: { duration: 0.2 },
2105
+ onClick: () => o == null ? void 0 : o(e + 1),
2106
+ onMouseEnter: () => G(!0),
2107
+ style: { pointerEvents: V ? "auto" : "none" },
2108
+ className: "rfp-absolute rfp-z-20 rfp-right-2 md:rfp-right-4 rfp-top-1/2 -rfp-translate-y-1/2 rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-rounded-full rfp-backdrop-blur-xl rfp-border rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors rfp-shadow-2xl rfp-bg-surface-nav rfp-border-line hover:rfp-bg-surface-nav-hover rfp-text-fg-primary",
2109
+ children: /* @__PURE__ */ p(ct, { className: "rfp-w-5 rfp-h-5 md:rfp-w-6 md:rfp-h-6" })
2110
+ }
2111
+ )
2112
+ ] })
2113
+ ]
2114
+ }
2115
+ ) }) });
2116
+ }, dr = ({ icon: t, label: e, onClick: o, disabled: r }) => /* @__PURE__ */ T(
2117
+ "button",
2118
+ {
2119
+ onClick: o,
2120
+ disabled: r,
2121
+ className: `rfp-relative rfp-group rfp-p-2 md:rfp-p-1.5 rfp-rounded-md rfp-transition-all rfp-select-none ${r ? "rfp-text-fg-disabled rfp-cursor-not-allowed" : "rfp-text-fg-primary hover:rfp-bg-surface-2 active:rfp-bg-surface-3"}`,
2122
+ children: [
2123
+ t,
2124
+ /* @__PURE__ */ T("span", { className: "rfp-absolute rfp-left-1/2 -rfp-translate-x-1/2 rfp-top-full rfp-mt-1.5 rfp-px-2 rfp-py-1 rfp-text-xs rfp-rounded rfp-whitespace-nowrap rfp-pointer-events-none rfp-opacity-0 rfp-invisible group-hover:rfp-opacity-100 group-hover:rfp-visible rfp-transition-opacity rfp-duration-200 rfp-z-50 rfp-bg-fg-primary rfp-text-fg-inverse", children: [
2125
+ /* @__PURE__ */ p("span", { className: "rfp-absolute rfp-left-1/2 -rfp-translate-x-1/2 -rfp-top-1 rfp-w-2 rfp-h-2 rfp-rotate-45 rfp-bg-fg-primary" }),
2126
+ /* @__PURE__ */ p("span", { className: "rfp-relative", children: e })
2127
+ ] })
2128
+ ]
2129
+ }
2130
+ ), Wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2131
+ __proto__: null,
2132
+ FilePreviewContent: gt
2133
+ }, Symbol.toStringTag, { value: "Module" })), $r = ({
2134
+ files: t,
2135
+ currentIndex: e,
2136
+ isOpen: o,
2137
+ onClose: r,
2138
+ onNavigate: a,
2139
+ customRenderers: n = [],
2140
+ locale: i,
2141
+ messages: s,
2142
+ headless: l,
2143
+ theme: f = "dark",
2144
+ onCustomEvent: c,
2145
+ requestInit: d,
2146
+ requestHandler: m,
2147
+ shouldFetchAsBlob: u,
2148
+ onDownload: w
2149
+ }) => {
2150
+ const [C, x] = F(
2151
+ () => typeof window < "u" ? window.matchMedia("(prefers-color-scheme: dark)").matches : !0
2152
+ );
2153
+ L(() => {
2154
+ if (f !== "auto") return;
2155
+ const k = window.matchMedia("(prefers-color-scheme: dark)"), M = (y) => x(y.matches);
2156
+ return k.addEventListener("change", M), () => k.removeEventListener("change", M);
2157
+ }, [f]);
2158
+ const _ = f === "auto" ? C ? "dark" : "light" : f;
2159
+ if (L(() => {
2160
+ if (o) {
2161
+ const k = document.body.style.overflow, M = document.body.style.paddingRight, y = window.innerWidth - document.documentElement.clientWidth;
2162
+ return document.body.style.overflow = "hidden", y > 0 && (document.body.style.paddingRight = `${y}px`), () => {
2163
+ document.body.style.overflow = k, document.body.style.paddingRight = M;
2164
+ };
2165
+ }
2166
+ }, [o]), !o) return null;
2167
+ const j = /* @__PURE__ */ p("div", { className: "rfp-root", "data-theme": _, children: /* @__PURE__ */ p(Se, { children: o && /* @__PURE__ */ p(
2168
+ ot.div,
2169
+ {
2170
+ initial: { opacity: 0 },
2171
+ animate: { opacity: 1 },
2172
+ exit: { opacity: 0 },
2173
+ className: "rfp-fixed rfp-inset-0 rfp-z-[9999] rfp-flex rfp-items-center rfp-justify-center rfp-backdrop-blur-md rfp-overflow-hidden rfp-bg-surface-overlay",
2174
+ onClick: r,
2175
+ onWheel: (k) => k.stopPropagation(),
2176
+ children: /* @__PURE__ */ p(
2177
+ "div",
2178
+ {
2179
+ className: "rfp-relative rfp-w-full rfp-h-full",
2180
+ onClick: (k) => k.stopPropagation(),
2181
+ children: /* @__PURE__ */ p(
2182
+ gt,
2183
+ {
2184
+ mode: "modal",
2185
+ files: t,
2186
+ currentIndex: e,
2187
+ onClose: r,
2188
+ onNavigate: a,
2189
+ customRenderers: n,
2190
+ locale: i,
2191
+ messages: s,
2192
+ headless: l,
2193
+ theme: f,
2194
+ onCustomEvent: c,
2195
+ requestInit: d,
2196
+ requestHandler: m,
2197
+ shouldFetchAsBlob: u,
2198
+ onDownload: w
2199
+ }
2200
+ )
2201
+ }
2202
+ )
2203
+ }
2204
+ ) }) });
2205
+ return ze(j, document.body);
2206
+ }, Dr = ({
2207
+ files: t,
2208
+ currentIndex: e = 0,
2209
+ onNavigate: o,
2210
+ customRenderers: r = [],
2211
+ width: a = "100%",
2212
+ height: n = "100%",
2213
+ className: i,
2214
+ style: s,
2215
+ locale: l,
2216
+ messages: f,
2217
+ headless: c,
2218
+ theme: d = "dark",
2219
+ onCustomEvent: m,
2220
+ requestInit: u,
2221
+ requestHandler: w,
2222
+ shouldFetchAsBlob: C,
2223
+ onDownload: x
2224
+ }) => {
2225
+ const [_, j] = F(
2226
+ () => typeof window < "u" ? window.matchMedia("(prefers-color-scheme: dark)").matches : !0
2227
+ );
2228
+ L(() => {
2229
+ if (d !== "auto") return;
2230
+ const M = window.matchMedia("(prefers-color-scheme: dark)"), y = (E) => j(E.matches);
2231
+ return M.addEventListener("change", y), () => M.removeEventListener("change", y);
2232
+ }, [d]);
2233
+ const k = d === "auto" ? _ ? "dark" : "light" : d;
2234
+ return /* @__PURE__ */ p(
2235
+ "div",
2236
+ {
2237
+ className: `rfp-root ${i ?? ""}`,
2238
+ style: { width: a, height: n, ...s },
2239
+ "data-theme": k,
2240
+ children: /* @__PURE__ */ p("div", { className: "rfp-relative rfp-w-full rfp-h-full rfp-overflow-hidden rfp-bg-surface-overlay", children: /* @__PURE__ */ p(
2241
+ gt,
2242
+ {
2243
+ mode: "embed",
2244
+ files: t,
2245
+ currentIndex: e,
2246
+ onNavigate: o,
2247
+ customRenderers: r,
2248
+ locale: l,
2249
+ messages: f,
2250
+ headless: c,
2251
+ theme: d,
2252
+ onCustomEvent: m,
2253
+ requestInit: u,
2254
+ requestHandler: w,
2255
+ shouldFetchAsBlob: C,
2256
+ onDownload: x
2257
+ }
2258
+ ) })
2259
+ }
2260
+ );
2261
+ };
2262
+ function Ar(t) {
2263
+ xo(Oe, t);
2264
+ }
2265
+ const Ur = Ve.version;
2266
+ export {
2267
+ Mr as A,
2268
+ Be as B,
2269
+ Ge as C,
2270
+ Rr as D,
2271
+ _r as E,
2272
+ qe as F,
2273
+ Sr as G,
2274
+ Pr as I,
2275
+ Po as L,
2276
+ yr as M,
2277
+ kr as N,
2278
+ Cr as P,
2279
+ jr as R,
2280
+ Fr as S,
2281
+ Tr as U,
2282
+ Ur as V,
2283
+ Vo as a,
2284
+ Lr as b,
2285
+ at as c,
2286
+ gt as d,
2287
+ Dr as e,
2288
+ $r as f,
2289
+ Ar as g,
2290
+ Er as h,
2291
+ Wr as i,
2292
+ Nr as j,
2293
+ zr as q,
2294
+ se as u,
2295
+ vr as v,
2296
+ He as w,
2297
+ xr as y
2298
+ };
2299
+ //# sourceMappingURL=index-CuAALtwC.mjs.map