@newview/file-ui 1.1.62 → 1.1.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 1.1.63
2
+ 1、附件查看中pdf增加EmbedPDF查看器
3
+
1
4
  ## 1.1.62
2
5
  1、构件选择组件增加字段
3
6
 
@@ -0,0 +1,448 @@
1
+ import { f as ft, x as on, c as cn, y as Bn, I as It } from "./index-8bb88267.js";
2
+ const o = "TaskQueue", a = "Queue";
3
+ var u = ((e) => (e[e.CRITICAL = 3] = "CRITICAL", e[e.HIGH = 2] = "HIGH", e[e.MEDIUM = 1] = "MEDIUM", e[e.LOW = 0] = "LOW", e))(u || {});
4
+ class s {
5
+ constructor(t = {}) {
6
+ this.queue = [], this.running = 0, this.resultTasks = /* @__PURE__ */ new Map(), this.idleListeners = /* @__PURE__ */ new Set();
7
+ const { concurrency: r = 1, comparator: n, ranker: i, onIdle: o2, maxQueueSize: a2, autoStart: u2 = true, logger: s2 } = t;
8
+ this.logger = s2 ?? new ft(), this.opts = { concurrency: Math.max(1, r), comparator: n, ranker: i, onIdle: o2 ?? (() => {
9
+ }), maxQueueSize: a2 ?? Number.POSITIVE_INFINITY, autoStart: u2 };
10
+ }
11
+ setComparator(e) {
12
+ this.opts.comparator = e;
13
+ }
14
+ setRanker(e) {
15
+ this.opts.ranker = e;
16
+ }
17
+ size() {
18
+ return this.queue.length;
19
+ }
20
+ inFlight() {
21
+ return this.running;
22
+ }
23
+ isIdle() {
24
+ return 0 === this.queue.length && 0 === this.running;
25
+ }
26
+ async drain() {
27
+ this.isIdle() || await new Promise((e) => {
28
+ const t = () => {
29
+ this.isIdle() && (this.offIdle(t), e());
30
+ };
31
+ this.onIdle(t);
32
+ });
33
+ }
34
+ notifyIdle() {
35
+ this.isIdle() && ([...this.idleListeners].forEach((e) => e()), this.idleListeners.clear(), this.opts.onIdle());
36
+ }
37
+ onIdle(e) {
38
+ this.idleListeners.add(e);
39
+ }
40
+ offIdle(e) {
41
+ this.idleListeners.delete(e);
42
+ }
43
+ enqueue(e, r = {}) {
44
+ const n = this.generateId(), i = r.priority ?? 1, u2 = new It();
45
+ if (this.queue.length >= this.opts.maxQueueSize) {
46
+ const e2 = new Error("Queue is full (maxQueueSize reached).");
47
+ return u2.reject(e2), u2;
48
+ }
49
+ this.resultTasks.set(n, u2);
50
+ const s2 = { id: n, priority: i, meta: r.meta ?? e.meta, executeFactory: e.execute };
51
+ this.queue.push(s2), this.logger.debug(o, a, `Task enqueued: ${n} | Priority: ${i} | Running: ${this.running} | Queued: ${this.queue.length}`);
52
+ const c2 = u2.abort.bind(u2);
53
+ return u2.abort = (e2) => {
54
+ this.logger.debug(o, a, `Task aborted: ${n}`), this.cancel(n), c2(e2);
55
+ }, this.opts.autoStart && this.process(true === r.fifo), u2;
56
+ }
57
+ cancel(e) {
58
+ const t = this.queue.length;
59
+ this.queue = this.queue.filter((t2) => t2.id !== e || (t2.cancelled = true, false)), this.resultTasks.delete(e), t !== this.queue.length && (this.logger.debug(o, a, `Task cancelled and removed: ${e}`), this.kick());
60
+ }
61
+ kick() {
62
+ queueMicrotask(() => this.process());
63
+ }
64
+ async process(e = false) {
65
+ for (this.logger.debug(o, a, `process() called | Running: ${this.running} | Concurrency: ${this.opts.concurrency} | Queued: ${this.queue.length}`); this.running < this.opts.concurrency && this.queue.length > 0; ) {
66
+ this.logger.debug(o, a, `Starting new task | Running: ${this.running} | Queued: ${this.queue.length}`), e || this.sortQueue();
67
+ const t = this.queue.shift();
68
+ if (t.cancelled) {
69
+ this.logger.debug(o, a, `Skipping cancelled task: ${t.id}`);
70
+ continue;
71
+ }
72
+ const r = this.resultTasks.get(t.id);
73
+ r && (this.running++, (async () => {
74
+ let e2 = null;
75
+ try {
76
+ if (e2 = t.executeFactory(), !e2)
77
+ throw new Error("Task factory returned null/undefined");
78
+ e2.wait((e3) => {
79
+ 0 === r.state.stage && r.resolve(e3);
80
+ }, (e3) => {
81
+ 0 === r.state.stage && ("abort" === e3.type ? r.abort(e3.reason) : r.reject(e3.reason));
82
+ }), e2.onProgress((e3) => {
83
+ r.progress(e3);
84
+ }), await e2.toPromise();
85
+ } catch (e3) {
86
+ 0 === r.state.stage && r.reject(e3);
87
+ } finally {
88
+ this.resultTasks.delete(t.id), this.running--, this.logger.debug(o, a, `Task completed: ${t.id} | Running: ${this.running} | Queued: ${this.queue.length}`), this.isIdle() ? this.notifyIdle() : this.queue.length > 0 && this.kick();
89
+ }
90
+ })().catch((e2) => {
91
+ this.logger.error(o, a, "Unhandled error in task execution wrapper:", e2), this.running = Math.max(0, this.running - 1), this.isIdle() ? this.notifyIdle() : this.queue.length > 0 && this.kick();
92
+ }));
93
+ }
94
+ }
95
+ sortQueue() {
96
+ const { comparator: e, ranker: t } = this.opts;
97
+ if (e)
98
+ return void this.queue.sort(e);
99
+ const r = /* @__PURE__ */ new Map(), n = (e2) => t ? (r.has(e2.id) || r.set(e2.id, t(e2)), r.get(e2.id)) : this.defaultRank(e2);
100
+ this.queue.sort((e2, t2) => {
101
+ if (e2.priority !== t2.priority)
102
+ return t2.priority - e2.priority;
103
+ const r2 = n(e2), i = n(t2);
104
+ return r2 !== i ? i - r2 : this.extractTime(e2.id) - this.extractTime(t2.id);
105
+ });
106
+ }
107
+ defaultRank(e) {
108
+ return 0;
109
+ }
110
+ generateId() {
111
+ return "undefined" != typeof crypto && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
112
+ }
113
+ extractTime(e) {
114
+ const t = Number(e.split("-")[0]);
115
+ return Number.isFinite(t) ? t : 0;
116
+ }
117
+ }
118
+ const c = "PdfEngine", d = "Orchestrator";
119
+ class h {
120
+ constructor(t, r) {
121
+ this.executor = t, this.logger = r.logger ?? new ft(), this.options = { imageConverter: r.imageConverter, fetcher: r.fetcher ?? ("undefined" != typeof fetch ? (e, t2) => fetch(e, t2) : void 0), logger: this.logger }, this.workerQueue = new s({ concurrency: 1, autoStart: true, logger: this.logger }), this.logger.debug(c, d, "PdfEngine orchestrator created");
122
+ }
123
+ chunkArray(e, t) {
124
+ const r = [];
125
+ for (let n = 0; n < e.length; n += t)
126
+ r.push(e.slice(n, n + t));
127
+ return r;
128
+ }
129
+ isSupport(e) {
130
+ const n = new It();
131
+ return n.resolve([on.Create, on.Read, on.Update, on.Delete]), n;
132
+ }
133
+ destroy() {
134
+ var e, r;
135
+ const i = new It();
136
+ try {
137
+ this.executor.destroy(), null == (r = (e = this.options.imageConverter).destroy) || r.call(e), i.resolve(true);
138
+ } catch (e2) {
139
+ i.reject({ code: cn.Unknown, message: String(e2) });
140
+ }
141
+ return i;
142
+ }
143
+ openDocumentUrl(e, r) {
144
+ const i = new It();
145
+ return (async () => {
146
+ try {
147
+ if (!this.options.fetcher)
148
+ throw new Error("Fetcher is not set");
149
+ const t = await this.options.fetcher(e.url, null == r ? void 0 : r.requestOptions), n = await t.arrayBuffer(), o2 = { id: e.id, content: n };
150
+ this.openDocumentBuffer(o2, { password: null == r ? void 0 : r.password, normalizeRotation: null == r ? void 0 : r.normalizeRotation }).wait((e2) => i.resolve(e2), (e2) => i.fail(e2));
151
+ } catch (e2) {
152
+ i.reject({ code: cn.Unknown, message: String(e2) });
153
+ }
154
+ })(), i;
155
+ }
156
+ openDocumentBuffer(e, t) {
157
+ return this.workerQueue.enqueue({ execute: () => this.executor.openDocumentBuffer(e, t), meta: { docId: e.id, operation: "openDocumentBuffer" } }, { priority: u.CRITICAL });
158
+ }
159
+ getMetadata(e) {
160
+ return this.workerQueue.enqueue({ execute: () => this.executor.getMetadata(e), meta: { docId: e.id, operation: "getMetadata" } }, { priority: u.MEDIUM });
161
+ }
162
+ setMetadata(e, t) {
163
+ return this.workerQueue.enqueue({ execute: () => this.executor.setMetadata(e, t), meta: { docId: e.id, operation: "setMetadata" } }, { priority: u.MEDIUM });
164
+ }
165
+ getDocPermissions(e) {
166
+ return this.workerQueue.enqueue({ execute: () => this.executor.getDocPermissions(e), meta: { docId: e.id, operation: "getDocPermissions" } }, { priority: u.MEDIUM });
167
+ }
168
+ getDocUserPermissions(e) {
169
+ return this.workerQueue.enqueue({ execute: () => this.executor.getDocUserPermissions(e), meta: { docId: e.id, operation: "getDocUserPermissions" } }, { priority: u.MEDIUM });
170
+ }
171
+ getSignatures(e) {
172
+ return this.workerQueue.enqueue({ execute: () => this.executor.getSignatures(e), meta: { docId: e.id, operation: "getSignatures" } }, { priority: u.MEDIUM });
173
+ }
174
+ getBookmarks(e) {
175
+ return this.workerQueue.enqueue({ execute: () => this.executor.getBookmarks(e), meta: { docId: e.id, operation: "getBookmarks" } }, { priority: u.MEDIUM });
176
+ }
177
+ setBookmarks(e, t) {
178
+ return this.workerQueue.enqueue({ execute: () => this.executor.setBookmarks(e, t), meta: { docId: e.id, operation: "setBookmarks" } }, { priority: u.MEDIUM });
179
+ }
180
+ deleteBookmarks(e) {
181
+ return this.workerQueue.enqueue({ execute: () => this.executor.deleteBookmarks(e), meta: { docId: e.id, operation: "deleteBookmarks" } }, { priority: u.MEDIUM });
182
+ }
183
+ renderPage(e, t, r) {
184
+ return this.renderWithEncoding(() => this.executor.renderPageRaw(e, t, r), r, e.id, t.index, u.CRITICAL);
185
+ }
186
+ renderPageRect(e, t, r, n) {
187
+ return this.renderWithEncoding(() => this.executor.renderPageRect(e, t, r, n), n, e.id, t.index, u.HIGH);
188
+ }
189
+ renderPageRaw(e, t, r) {
190
+ return this.workerQueue.enqueue({ execute: () => this.executor.renderPageRaw(e, t, r), meta: { docId: e.id, pageIndex: t.index, operation: "renderPageRaw" } }, { priority: u.HIGH });
191
+ }
192
+ renderPageRectRaw(e, t, r, n) {
193
+ return this.workerQueue.enqueue({ execute: () => this.executor.renderPageRect(e, t, r, n), meta: { docId: e.id, pageIndex: t.index, operation: "renderPageRectRaw" } }, { priority: u.HIGH });
194
+ }
195
+ renderThumbnail(e, t, r) {
196
+ return this.renderWithEncoding(() => this.executor.renderThumbnailRaw(e, t, r), r, e.id, t.index, u.MEDIUM);
197
+ }
198
+ renderPageAnnotation(e, t, r, n) {
199
+ return this.renderWithEncoding(() => this.executor.renderPageAnnotationRaw(e, t, r, n), n, e.id, t.index, u.MEDIUM);
200
+ }
201
+ renderPageAnnotations(e, r, n) {
202
+ const i = new It(), o2 = this.workerQueue.enqueue({ execute: () => this.executor.renderPageAnnotationsRaw(e, r, n), meta: { docId: e.id, pageIndex: r.index, operation: "renderPageAnnotationsRaw" } }, { priority: u.MEDIUM }), a2 = i.abort.bind(i);
203
+ return i.abort = (e2) => {
204
+ o2.abort(e2), a2(e2);
205
+ }, o2.wait((e2) => {
206
+ 0 === i.state.stage && this.encodeAppearanceMap(e2, n, i);
207
+ }, (e2) => {
208
+ 0 === i.state.stage && i.fail(e2);
209
+ }), i;
210
+ }
211
+ renderPageAnnotationsRaw(e, t, r) {
212
+ return this.workerQueue.enqueue({ execute: () => this.executor.renderPageAnnotationsRaw(e, t, r), meta: { docId: e.id, pageIndex: t.index, operation: "renderPageAnnotationsRaw" } }, { priority: u.MEDIUM });
213
+ }
214
+ renderWithEncoding(e, r, n, i, o2 = u.CRITICAL) {
215
+ const a2 = new It(), s2 = this.workerQueue.enqueue({ execute: () => e(), meta: { docId: n, pageIndex: i, operation: "render" } }, { priority: o2 }), c2 = a2.abort.bind(a2);
216
+ return a2.abort = (e2) => {
217
+ s2.abort(e2), c2(e2);
218
+ }, s2.wait((e2) => {
219
+ 0 === a2.state.stage && this.encodeImage(e2, r, a2);
220
+ }, (e2) => {
221
+ 0 === a2.state.stage && a2.fail(e2);
222
+ }), a2;
223
+ }
224
+ encodeImage(e, t, r) {
225
+ const i = (null == t ? void 0 : t.imageType) ?? "image/png", o2 = null == t ? void 0 : t.quality, a2 = { data: new Uint8ClampedArray(e.data), width: e.width, height: e.height };
226
+ this.options.imageConverter(() => a2, i, o2).then((e2) => r.resolve(e2)).catch((e2) => r.reject({ code: cn.Unknown, message: String(e2) }));
227
+ }
228
+ encodeAppearanceMap(e, t, r) {
229
+ const i = (null == t ? void 0 : t.imageType) ?? "image/png", o2 = null == t ? void 0 : t.imageQuality, a2 = (e2) => {
230
+ const t2 = { data: new Uint8ClampedArray(e2.data), width: e2.width, height: e2.height };
231
+ return this.options.imageConverter(() => t2, i, o2);
232
+ }, u2 = [], s2 = {}, c2 = ["normal", "rollover", "down"];
233
+ for (const [t2, r2] of Object.entries(e)) {
234
+ const e2 = {};
235
+ s2[t2] = e2;
236
+ for (const t3 of c2) {
237
+ const n = r2[t3];
238
+ n && u2.push(a2(n.data).then((r3) => {
239
+ e2[t3] = { data: r3, rect: n.rect };
240
+ }));
241
+ }
242
+ }
243
+ Promise.all(u2).then(() => {
244
+ 0 === r.state.stage && r.resolve(s2);
245
+ }).catch((e2) => {
246
+ 0 === r.state.stage && r.reject({ code: cn.Unknown, message: String(e2) });
247
+ });
248
+ }
249
+ getPageAnnotations(e, t) {
250
+ return this.workerQueue.enqueue({ execute: () => this.executor.getPageAnnotations(e, t), meta: { docId: e.id, pageIndex: t.index, operation: "getPageAnnotations" } }, { priority: u.MEDIUM });
251
+ }
252
+ createPageAnnotation(e, t, r, n) {
253
+ return this.workerQueue.enqueue({ execute: () => this.executor.createPageAnnotation(e, t, r, n), meta: { docId: e.id, pageIndex: t.index, operation: "createPageAnnotation" } }, { priority: u.MEDIUM });
254
+ }
255
+ updatePageAnnotation(e, t, r, n) {
256
+ return this.workerQueue.enqueue({ execute: () => this.executor.updatePageAnnotation(e, t, r, n), meta: { docId: e.id, pageIndex: t.index, operation: "updatePageAnnotation" } }, { priority: u.MEDIUM });
257
+ }
258
+ removePageAnnotation(e, t, r) {
259
+ return this.workerQueue.enqueue({ execute: () => this.executor.removePageAnnotation(e, t, r), meta: { docId: e.id, pageIndex: t.index, operation: "removePageAnnotation" } }, { priority: u.MEDIUM });
260
+ }
261
+ getAllAnnotations(e) {
262
+ const t = this.chunkArray(e.pages, 500);
263
+ this.logger.debug(c, d, `getAllAnnotations: ${e.pages.length} pages in ${t.length} chunks`);
264
+ const r = new Bn({ aggregate: (e2) => Object.assign({}, ...e2) });
265
+ return t.forEach((t2, n) => {
266
+ const i = this.workerQueue.enqueue({ execute: () => this.executor.getAnnotationsBatch(e, t2), meta: { docId: e.id, operation: "getAnnotationsBatch", chunkSize: t2.length } }, { priority: u.LOW });
267
+ i.onProgress((e2) => {
268
+ r.progress({ page: e2.pageIndex, result: e2.result });
269
+ }), r.addChild(i, n);
270
+ }), r.finalize(), r;
271
+ }
272
+ getPageTextRects(e, t) {
273
+ return this.workerQueue.enqueue({ execute: () => this.executor.getPageTextRects(e, t), meta: { docId: e.id, pageIndex: t.index, operation: "getPageTextRects" } }, { priority: u.MEDIUM });
274
+ }
275
+ searchAllPages(e, t, r) {
276
+ const n = Array.isArray(null == r ? void 0 : r.flags) ? r.flags.reduce((e2, t2) => e2 | t2, 0) : (null == r ? void 0 : r.flags) ?? 0, o2 = this.chunkArray(e.pages, 25);
277
+ this.logger.debug(c, d, `searchAllPages: ${e.pages.length} pages in ${o2.length} chunks`);
278
+ const a2 = new Bn({ aggregate: (e2) => {
279
+ const t2 = e2.flatMap((e3) => Object.values(e3).flat());
280
+ return { results: t2, total: t2.length };
281
+ } });
282
+ return o2.forEach((r2, i) => {
283
+ const o3 = this.workerQueue.enqueue({ execute: () => this.executor.searchBatch(e, r2, t, n), meta: { docId: e.id, operation: "searchBatch", chunkSize: r2.length } }, { priority: u.LOW });
284
+ o3.onProgress((e2) => {
285
+ a2.progress({ page: e2.pageIndex, results: e2.result });
286
+ }), a2.addChild(o3, i);
287
+ }), a2.finalize(), a2;
288
+ }
289
+ getAttachments(e) {
290
+ return this.workerQueue.enqueue({ execute: () => this.executor.getAttachments(e), meta: { docId: e.id, operation: "getAttachments" } }, { priority: u.MEDIUM });
291
+ }
292
+ addAttachment(e, t) {
293
+ return this.workerQueue.enqueue({ execute: () => this.executor.addAttachment(e, t), meta: { docId: e.id, operation: "addAttachment" } }, { priority: u.MEDIUM });
294
+ }
295
+ removeAttachment(e, t) {
296
+ return this.workerQueue.enqueue({ execute: () => this.executor.removeAttachment(e, t), meta: { docId: e.id, operation: "removeAttachment" } }, { priority: u.MEDIUM });
297
+ }
298
+ readAttachmentContent(e, t) {
299
+ return this.workerQueue.enqueue({ execute: () => this.executor.readAttachmentContent(e, t), meta: { docId: e.id, operation: "readAttachmentContent" } }, { priority: u.MEDIUM });
300
+ }
301
+ getDocumentJavaScriptActions(e) {
302
+ return this.workerQueue.enqueue({ execute: () => this.executor.getDocumentJavaScriptActions(e), meta: { docId: e.id, operation: "getDocumentJavaScriptActions" } }, { priority: u.MEDIUM });
303
+ }
304
+ getPageAnnoWidgets(e, t) {
305
+ return this.workerQueue.enqueue({ execute: () => this.executor.getPageAnnoWidgets(e, t), meta: { docId: e.id, pageIndex: t.index, operation: "getPageAnnoWidgets" } }, { priority: u.MEDIUM });
306
+ }
307
+ getPageWidgetJavaScriptActions(e, t) {
308
+ return this.workerQueue.enqueue({ execute: () => this.executor.getPageWidgetJavaScriptActions(e, t), meta: { docId: e.id, pageIndex: t.index, operation: "getPageWidgetJavaScriptActions" } }, { priority: u.MEDIUM });
309
+ }
310
+ setFormFieldValue(e, t, r, n) {
311
+ return this.workerQueue.enqueue({ execute: () => this.executor.setFormFieldValue(e, t, r, n), meta: { docId: e.id, pageIndex: t.index, operation: "setFormFieldValue" } }, { priority: u.MEDIUM });
312
+ }
313
+ setFormFieldState(e, t, r, n) {
314
+ return this.workerQueue.enqueue({ execute: () => this.executor.setFormFieldState(e, t, r, n), meta: { docId: e.id, pageIndex: t.index, operation: "setFormFieldState" } }, { priority: u.MEDIUM });
315
+ }
316
+ renameWidgetField(e, t, r, n) {
317
+ return this.workerQueue.enqueue({ execute: () => this.executor.renameWidgetField(e, t, r, n), meta: { docId: e.id, pageIndex: t.index, operation: "renameWidgetField" } }, { priority: u.MEDIUM });
318
+ }
319
+ shareWidgetField(e, t, r, n, i) {
320
+ return this.workerQueue.enqueue({ execute: () => this.executor.shareWidgetField(e, t, r, n, i), meta: { docId: e.id, pageIndex: t.index, operation: "shareWidgetField" } }, { priority: u.MEDIUM });
321
+ }
322
+ regenerateWidgetAppearances(e, t, r) {
323
+ return this.workerQueue.enqueue({ execute: () => this.executor.regenerateWidgetAppearances(e, t, r), meta: { docId: e.id, pageIndex: t.index, operation: "regenerateWidgetAppearances" } }, { priority: u.MEDIUM });
324
+ }
325
+ flattenPage(e, t, r) {
326
+ return this.workerQueue.enqueue({ execute: () => this.executor.flattenPage(e, t, r), meta: { docId: e.id, pageIndex: t.index, operation: "flattenPage" } }, { priority: u.MEDIUM });
327
+ }
328
+ extractPages(e, t) {
329
+ return this.workerQueue.enqueue({ execute: () => this.executor.extractPages(e, t), meta: { docId: e.id, pageIndexes: t, operation: "extractPages" } }, { priority: u.MEDIUM });
330
+ }
331
+ createDocument(e) {
332
+ return this.workerQueue.enqueue({ execute: () => this.executor.createDocument(e), meta: { docId: e, operation: "createDocument" } }, { priority: u.MEDIUM });
333
+ }
334
+ importPages(e, t, r, n) {
335
+ return this.workerQueue.enqueue({ execute: () => this.executor.importPages(e, t, r, n), meta: { docId: e.id, operation: "importPages" } }, { priority: u.MEDIUM });
336
+ }
337
+ deletePage(e, t) {
338
+ return this.workerQueue.enqueue({ execute: () => this.executor.deletePage(e, t), meta: { docId: e.id, operation: "deletePage" } }, { priority: u.MEDIUM });
339
+ }
340
+ extractText(e, t) {
341
+ return this.workerQueue.enqueue({ execute: () => this.executor.extractText(e, t), meta: { docId: e.id, pageIndexes: t, operation: "extractText" } }, { priority: u.MEDIUM });
342
+ }
343
+ redactTextInRects(e, t, r, n) {
344
+ return this.workerQueue.enqueue({ execute: () => this.executor.redactTextInRects(e, t, r, n), meta: { docId: e.id, pageIndex: t.index, operation: "redactTextInRects" } }, { priority: u.MEDIUM });
345
+ }
346
+ applyRedaction(e, t, r) {
347
+ return this.workerQueue.enqueue({ execute: () => this.executor.applyRedaction(e, t, r), meta: { docId: e.id, pageIndex: t.index, operation: "applyRedaction" } }, { priority: u.MEDIUM });
348
+ }
349
+ applyAllRedactions(e, t) {
350
+ return this.workerQueue.enqueue({ execute: () => this.executor.applyAllRedactions(e, t), meta: { docId: e.id, pageIndex: t.index, operation: "applyAllRedactions" } }, { priority: u.MEDIUM });
351
+ }
352
+ flattenAnnotation(e, t, r) {
353
+ return this.workerQueue.enqueue({ execute: () => this.executor.flattenAnnotation(e, t, r), meta: { docId: e.id, pageIndex: t.index, operation: "flattenAnnotation" } }, { priority: u.MEDIUM });
354
+ }
355
+ exportAnnotationAppearanceAsPdf(e, t, r) {
356
+ return this.workerQueue.enqueue({ execute: () => this.executor.exportAnnotationAppearanceAsPdf(e, t, r), meta: { docId: e.id, pageIndex: t.index, operation: "exportAnnotationAppearanceAsPdf" } }, { priority: u.MEDIUM });
357
+ }
358
+ exportAnnotationsAppearanceAsPdf(e, t, r) {
359
+ return this.workerQueue.enqueue({ execute: () => this.executor.exportAnnotationsAppearanceAsPdf(e, t, r), meta: { docId: e.id, pageIndex: t.index, operation: "exportAnnotationsAppearanceAsPdf" } }, { priority: u.MEDIUM });
360
+ }
361
+ getTextSlices(e, t) {
362
+ return this.workerQueue.enqueue({ execute: () => this.executor.getTextSlices(e, t), meta: { docId: e.id, slices: t, operation: "getTextSlices" } }, { priority: u.MEDIUM });
363
+ }
364
+ getPageGlyphs(e, t) {
365
+ return this.workerQueue.enqueue({ execute: () => this.executor.getPageGlyphs(e, t), meta: { docId: e.id, pageIndex: t.index, operation: "getPageGlyphs" } }, { priority: u.MEDIUM });
366
+ }
367
+ getPageGeometry(e, t) {
368
+ return this.workerQueue.enqueue({ execute: () => this.executor.getPageGeometry(e, t), meta: { docId: e.id, pageIndex: t.index, operation: "getPageGeometry" } }, { priority: u.MEDIUM });
369
+ }
370
+ getPageTextRuns(e, t) {
371
+ return this.workerQueue.enqueue({ execute: () => this.executor.getPageTextRuns(e, t), meta: { docId: e.id, pageIndex: t.index, operation: "getPageTextRuns" } }, { priority: u.MEDIUM });
372
+ }
373
+ merge(e) {
374
+ return this.workerQueue.enqueue({ execute: () => this.executor.merge(e), meta: { docId: e.map((e2) => e2.id).join(","), operation: "merge" } }, { priority: u.MEDIUM });
375
+ }
376
+ mergePages(e) {
377
+ return this.workerQueue.enqueue({ execute: () => this.executor.mergePages(e), meta: { docId: e.map((e2) => e2.docId).join(","), operation: "mergePages" } }, { priority: u.MEDIUM });
378
+ }
379
+ preparePrintDocument(e, t) {
380
+ return this.workerQueue.enqueue({ execute: () => this.executor.preparePrintDocument(e, t), meta: { docId: e.id, operation: "preparePrintDocument" } }, { priority: u.MEDIUM });
381
+ }
382
+ saveAsCopy(e) {
383
+ return this.workerQueue.enqueue({ execute: () => this.executor.saveAsCopy(e), meta: { docId: e.id, operation: "saveAsCopy" } }, { priority: u.MEDIUM });
384
+ }
385
+ closeDocument(e) {
386
+ return this.workerQueue.enqueue({ execute: () => this.executor.closeDocument(e), meta: { docId: e.id, operation: "closeDocument" } }, { priority: u.MEDIUM });
387
+ }
388
+ closeAllDocuments() {
389
+ return this.workerQueue.enqueue({ execute: () => this.executor.closeAllDocuments(), meta: { operation: "closeAllDocuments" } }, { priority: u.MEDIUM });
390
+ }
391
+ setDocumentEncryption(e, t, r, n) {
392
+ return this.workerQueue.enqueue({ execute: () => this.executor.setDocumentEncryption(e, t, r, n), meta: { docId: e.id, operation: "setDocumentEncryption" } }, { priority: u.MEDIUM });
393
+ }
394
+ removeEncryption(e) {
395
+ return this.workerQueue.enqueue({ execute: () => this.executor.removeEncryption(e), meta: { docId: e.id, operation: "removeEncryption" } }, { priority: u.MEDIUM });
396
+ }
397
+ unlockOwnerPermissions(e, t) {
398
+ return this.workerQueue.enqueue({ execute: () => this.executor.unlockOwnerPermissions(e, t), meta: { docId: e.id, operation: "unlockOwnerPermissions" } }, { priority: u.MEDIUM });
399
+ }
400
+ isEncrypted(e) {
401
+ return this.workerQueue.enqueue({ execute: () => this.executor.isEncrypted(e), meta: { docId: e.id, operation: "isEncrypted" } }, { priority: u.MEDIUM });
402
+ }
403
+ isOwnerUnlocked(e) {
404
+ return this.workerQueue.enqueue({ execute: () => this.executor.isOwnerUnlocked(e), meta: { docId: e.id, operation: "isOwnerUnlocked" } }, { priority: u.MEDIUM });
405
+ }
406
+ }
407
+ function g(e, t, r) {
408
+ const n = t * r * 4, i = (e2) => [255 & e2, e2 >>> 8 & 255, e2 >>> 16 & 255, e2 >>> 24 & 255], o2 = new Uint8Array([66, 77, ...i(66 + n), 0, 0, 0, 0, 66, 0, 0, 0, 40, 0, 0, 0, ...i(t), ...i(-r), 1, 0, 32, 0, 3, 0, 0, 0, ...i(n), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 255, 0, 0, 0, 0, 255, 0]);
409
+ return new Blob([o2, new Uint8Array(e.buffer, e.byteOffset, e.byteLength)], { type: "image/bmp" });
410
+ }
411
+ class p extends Error {
412
+ constructor(e) {
413
+ super(e), this.name = "ImageConverterError";
414
+ }
415
+ }
416
+ const l = (e, t = "image/png", r) => {
417
+ const n = e();
418
+ if ("image/bmp" === t)
419
+ return Promise.resolve(g(n.data, n.width, n.height));
420
+ if ("undefined" == typeof document)
421
+ return Promise.reject(new p("document is not available. This converter requires a browser environment."));
422
+ const i = new ImageData(n.data, n.width, n.height);
423
+ return new Promise((e2, n2) => {
424
+ const o2 = document.createElement("canvas");
425
+ o2.width = i.width, o2.height = i.height, o2.getContext("2d").putImageData(i, 0, 0), o2.toBlob((t2) => {
426
+ t2 ? e2(t2) : n2(new p("Canvas toBlob returned null"));
427
+ }, t, r);
428
+ });
429
+ };
430
+ function x(e) {
431
+ const t = async (t2, r = "image/png", n) => {
432
+ const i = t2();
433
+ if ("image/bmp" === r)
434
+ return g(i.data, i.width, i.height);
435
+ try {
436
+ const t3 = new Uint8ClampedArray(i.data);
437
+ return await e.encode({ data: t3, width: i.width, height: i.height }, r, n);
438
+ } catch (e2) {
439
+ return console.warn("Worker encoding failed, falling back to main-thread Canvas:", e2), l(t2, r, n);
440
+ }
441
+ };
442
+ return t.destroy = () => e.destroy(), t;
443
+ }
444
+ export {
445
+ h,
446
+ l,
447
+ x
448
+ };