image-pii-redactor 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,967 @@
1
+ import { a as ir } from "./_commonjsHelpers-MdHo5S7N.js";
2
+ function ar(o, s) {
3
+ for (var t = 0; t < s.length; t++) {
4
+ const c = s[t];
5
+ if (typeof c != "string" && !Array.isArray(c)) {
6
+ for (const a in c)
7
+ if (a !== "default" && !(a in o)) {
8
+ const u = Object.getOwnPropertyDescriptor(c, a);
9
+ u && Object.defineProperty(o, a, u.get ? u : {
10
+ enumerable: !0,
11
+ get: () => c[a]
12
+ });
13
+ }
14
+ }
15
+ }
16
+ return Object.freeze(Object.defineProperty(o, Symbol.toStringTag, { value: "Module" }));
17
+ }
18
+ var ne = { exports: {} }, Ae;
19
+ function sr() {
20
+ return Ae || (Ae = 1, (function(o) {
21
+ var s = (function(t) {
22
+ var c = Object.prototype, a = c.hasOwnProperty, u = Object.defineProperty || function(r, e, n) {
23
+ r[e] = n.value;
24
+ }, h, v = typeof Symbol == "function" ? Symbol : {}, _ = v.iterator || "@@iterator", I = v.asyncIterator || "@@asyncIterator", q = v.toStringTag || "@@toStringTag";
25
+ function b(r, e, n) {
26
+ return Object.defineProperty(r, e, {
27
+ value: n,
28
+ enumerable: !0,
29
+ configurable: !0,
30
+ writable: !0
31
+ }), r[e];
32
+ }
33
+ try {
34
+ b({}, "");
35
+ } catch {
36
+ b = function(e, n, l) {
37
+ return e[n] = l;
38
+ };
39
+ }
40
+ function $(r, e, n, l) {
41
+ var i = e && e.prototype instanceof G ? e : G, p = Object.create(i.prototype), E = new J(l || []);
42
+ return u(p, "_invoke", { value: X(r, n, E) }), p;
43
+ }
44
+ t.wrap = $;
45
+ function C(r, e, n) {
46
+ try {
47
+ return { type: "normal", arg: r.call(e, n) };
48
+ } catch (l) {
49
+ return { type: "throw", arg: l };
50
+ }
51
+ }
52
+ var F = "suspendedStart", g = "suspendedYield", S = "executing", M = "completed", O = {};
53
+ function G() {
54
+ }
55
+ function y() {
56
+ }
57
+ function P() {
58
+ }
59
+ var Y = {};
60
+ b(Y, _, function() {
61
+ return this;
62
+ });
63
+ var K = Object.getPrototypeOf, W = K && K(K(V([])));
64
+ W && W !== c && a.call(W, _) && (Y = W);
65
+ var j = P.prototype = G.prototype = Object.create(Y);
66
+ y.prototype = P, u(j, "constructor", { value: P, configurable: !0 }), u(
67
+ P,
68
+ "constructor",
69
+ { value: y, configurable: !0 }
70
+ ), y.displayName = b(
71
+ P,
72
+ q,
73
+ "GeneratorFunction"
74
+ );
75
+ function H(r) {
76
+ ["next", "throw", "return"].forEach(function(e) {
77
+ b(r, e, function(n) {
78
+ return this._invoke(e, n);
79
+ });
80
+ });
81
+ }
82
+ t.isGeneratorFunction = function(r) {
83
+ var e = typeof r == "function" && r.constructor;
84
+ return e ? e === y || // For the native GeneratorFunction constructor, the best we can
85
+ // do is to check its .name property.
86
+ (e.displayName || e.name) === "GeneratorFunction" : !1;
87
+ }, t.mark = function(r) {
88
+ return Object.setPrototypeOf ? Object.setPrototypeOf(r, P) : (r.__proto__ = P, b(r, q, "GeneratorFunction")), r.prototype = Object.create(j), r;
89
+ }, t.awrap = function(r) {
90
+ return { __await: r };
91
+ };
92
+ function z(r, e) {
93
+ function n(p, E, m, A) {
94
+ var w = C(r[p], r, E);
95
+ if (w.type === "throw")
96
+ A(w.arg);
97
+ else {
98
+ var Z = w.arg, B = Z.value;
99
+ return B && typeof B == "object" && a.call(B, "__await") ? e.resolve(B.__await).then(function(D) {
100
+ n("next", D, m, A);
101
+ }, function(D) {
102
+ n("throw", D, m, A);
103
+ }) : e.resolve(B).then(function(D) {
104
+ Z.value = D, m(Z);
105
+ }, function(D) {
106
+ return n("throw", D, m, A);
107
+ });
108
+ }
109
+ }
110
+ var l;
111
+ function i(p, E) {
112
+ function m() {
113
+ return new e(function(A, w) {
114
+ n(p, E, A, w);
115
+ });
116
+ }
117
+ return l = // If enqueue has been called before, then we want to wait until
118
+ // all previous Promises have been resolved before calling invoke,
119
+ // so that results are always delivered in the correct order. If
120
+ // enqueue has not been called before, then it is important to
121
+ // call invoke immediately, without waiting on a callback to fire,
122
+ // so that the async generator function has the opportunity to do
123
+ // any necessary setup in a predictable way. This predictability
124
+ // is why the Promise constructor synchronously invokes its
125
+ // executor callback, and why async functions synchronously
126
+ // execute code before the first await. Since we implement simple
127
+ // async functions in terms of async generators, it is especially
128
+ // important to get this right, even though it requires care.
129
+ l ? l.then(
130
+ m,
131
+ // Avoid propagating failures to Promises returned by later
132
+ // invocations of the iterator.
133
+ m
134
+ ) : m();
135
+ }
136
+ u(this, "_invoke", { value: i });
137
+ }
138
+ H(z.prototype), b(z.prototype, I, function() {
139
+ return this;
140
+ }), t.AsyncIterator = z, t.async = function(r, e, n, l, i) {
141
+ i === void 0 && (i = Promise);
142
+ var p = new z(
143
+ $(r, e, n, l),
144
+ i
145
+ );
146
+ return t.isGeneratorFunction(e) ? p : p.next().then(function(E) {
147
+ return E.done ? E.value : p.next();
148
+ });
149
+ };
150
+ function X(r, e, n) {
151
+ var l = F;
152
+ return function(p, E) {
153
+ if (l === S)
154
+ throw new Error("Generator is already running");
155
+ if (l === M) {
156
+ if (p === "throw")
157
+ throw E;
158
+ return k();
159
+ }
160
+ for (n.method = p, n.arg = E; ; ) {
161
+ var m = n.delegate;
162
+ if (m) {
163
+ var A = x(m, n);
164
+ if (A) {
165
+ if (A === O) continue;
166
+ return A;
167
+ }
168
+ }
169
+ if (n.method === "next")
170
+ n.sent = n._sent = n.arg;
171
+ else if (n.method === "throw") {
172
+ if (l === F)
173
+ throw l = M, n.arg;
174
+ n.dispatchException(n.arg);
175
+ } else n.method === "return" && n.abrupt("return", n.arg);
176
+ l = S;
177
+ var w = C(r, e, n);
178
+ if (w.type === "normal") {
179
+ if (l = n.done ? M : g, w.arg === O)
180
+ continue;
181
+ return {
182
+ value: w.arg,
183
+ done: n.done
184
+ };
185
+ } else w.type === "throw" && (l = M, n.method = "throw", n.arg = w.arg);
186
+ }
187
+ };
188
+ }
189
+ function x(r, e) {
190
+ var n = e.method, l = r.iterator[n];
191
+ if (l === h)
192
+ return e.delegate = null, n === "throw" && r.iterator.return && (e.method = "return", e.arg = h, x(r, e), e.method === "throw") || n !== "return" && (e.method = "throw", e.arg = new TypeError(
193
+ "The iterator does not provide a '" + n + "' method"
194
+ )), O;
195
+ var i = C(l, r.iterator, e.arg);
196
+ if (i.type === "throw")
197
+ return e.method = "throw", e.arg = i.arg, e.delegate = null, O;
198
+ var p = i.arg;
199
+ if (!p)
200
+ return e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, O;
201
+ if (p.done)
202
+ e[r.resultName] = p.value, e.next = r.nextLoc, e.method !== "return" && (e.method = "next", e.arg = h);
203
+ else
204
+ return p;
205
+ return e.delegate = null, O;
206
+ }
207
+ H(j), b(j, q, "Generator"), b(j, _, function() {
208
+ return this;
209
+ }), b(j, "toString", function() {
210
+ return "[object Generator]";
211
+ });
212
+ function re(r) {
213
+ var e = { tryLoc: r[0] };
214
+ 1 in r && (e.catchLoc = r[1]), 2 in r && (e.finallyLoc = r[2], e.afterLoc = r[3]), this.tryEntries.push(e);
215
+ }
216
+ function N(r) {
217
+ var e = r.completion || {};
218
+ e.type = "normal", delete e.arg, r.completion = e;
219
+ }
220
+ function J(r) {
221
+ this.tryEntries = [{ tryLoc: "root" }], r.forEach(re, this), this.reset(!0);
222
+ }
223
+ t.keys = function(r) {
224
+ var e = Object(r), n = [];
225
+ for (var l in e)
226
+ n.push(l);
227
+ return n.reverse(), function i() {
228
+ for (; n.length; ) {
229
+ var p = n.pop();
230
+ if (p in e)
231
+ return i.value = p, i.done = !1, i;
232
+ }
233
+ return i.done = !0, i;
234
+ };
235
+ };
236
+ function V(r) {
237
+ if (r) {
238
+ var e = r[_];
239
+ if (e)
240
+ return e.call(r);
241
+ if (typeof r.next == "function")
242
+ return r;
243
+ if (!isNaN(r.length)) {
244
+ var n = -1, l = function i() {
245
+ for (; ++n < r.length; )
246
+ if (a.call(r, n))
247
+ return i.value = r[n], i.done = !1, i;
248
+ return i.value = h, i.done = !0, i;
249
+ };
250
+ return l.next = l;
251
+ }
252
+ }
253
+ return { next: k };
254
+ }
255
+ t.values = V;
256
+ function k() {
257
+ return { value: h, done: !0 };
258
+ }
259
+ return J.prototype = {
260
+ constructor: J,
261
+ reset: function(r) {
262
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = h, this.done = !1, this.delegate = null, this.method = "next", this.arg = h, this.tryEntries.forEach(N), !r)
263
+ for (var e in this)
264
+ e.charAt(0) === "t" && a.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = h);
265
+ },
266
+ stop: function() {
267
+ this.done = !0;
268
+ var r = this.tryEntries[0], e = r.completion;
269
+ if (e.type === "throw")
270
+ throw e.arg;
271
+ return this.rval;
272
+ },
273
+ dispatchException: function(r) {
274
+ if (this.done)
275
+ throw r;
276
+ var e = this;
277
+ function n(A, w) {
278
+ return p.type = "throw", p.arg = r, e.next = A, w && (e.method = "next", e.arg = h), !!w;
279
+ }
280
+ for (var l = this.tryEntries.length - 1; l >= 0; --l) {
281
+ var i = this.tryEntries[l], p = i.completion;
282
+ if (i.tryLoc === "root")
283
+ return n("end");
284
+ if (i.tryLoc <= this.prev) {
285
+ var E = a.call(i, "catchLoc"), m = a.call(i, "finallyLoc");
286
+ if (E && m) {
287
+ if (this.prev < i.catchLoc)
288
+ return n(i.catchLoc, !0);
289
+ if (this.prev < i.finallyLoc)
290
+ return n(i.finallyLoc);
291
+ } else if (E) {
292
+ if (this.prev < i.catchLoc)
293
+ return n(i.catchLoc, !0);
294
+ } else if (m) {
295
+ if (this.prev < i.finallyLoc)
296
+ return n(i.finallyLoc);
297
+ } else
298
+ throw new Error("try statement without catch or finally");
299
+ }
300
+ }
301
+ },
302
+ abrupt: function(r, e) {
303
+ for (var n = this.tryEntries.length - 1; n >= 0; --n) {
304
+ var l = this.tryEntries[n];
305
+ if (l.tryLoc <= this.prev && a.call(l, "finallyLoc") && this.prev < l.finallyLoc) {
306
+ var i = l;
307
+ break;
308
+ }
309
+ }
310
+ i && (r === "break" || r === "continue") && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
311
+ var p = i ? i.completion : {};
312
+ return p.type = r, p.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, O) : this.complete(p);
313
+ },
314
+ complete: function(r, e) {
315
+ if (r.type === "throw")
316
+ throw r.arg;
317
+ return r.type === "break" || r.type === "continue" ? this.next = r.arg : r.type === "return" ? (this.rval = this.arg = r.arg, this.method = "return", this.next = "end") : r.type === "normal" && e && (this.next = e), O;
318
+ },
319
+ finish: function(r) {
320
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
321
+ var n = this.tryEntries[e];
322
+ if (n.finallyLoc === r)
323
+ return this.complete(n.completion, n.afterLoc), N(n), O;
324
+ }
325
+ },
326
+ catch: function(r) {
327
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
328
+ var n = this.tryEntries[e];
329
+ if (n.tryLoc === r) {
330
+ var l = n.completion;
331
+ if (l.type === "throw") {
332
+ var i = l.arg;
333
+ N(n);
334
+ }
335
+ return i;
336
+ }
337
+ }
338
+ throw new Error("illegal catch attempt");
339
+ },
340
+ delegateYield: function(r, e, n) {
341
+ return this.delegate = {
342
+ iterator: V(r),
343
+ resultName: e,
344
+ nextLoc: n
345
+ }, this.method === "next" && (this.arg = h), O;
346
+ }
347
+ }, t;
348
+ })(
349
+ // If this script is executing as a CommonJS module, use module.exports
350
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
351
+ // object. Either way, the resulting object will be used to initialize
352
+ // the regeneratorRuntime variable at the top of this file.
353
+ o.exports
354
+ );
355
+ try {
356
+ regeneratorRuntime = s;
357
+ } catch {
358
+ typeof globalThis == "object" ? globalThis.regeneratorRuntime = s : Function("r", "regeneratorRuntime = r")(s);
359
+ }
360
+ })(ne)), ne.exports;
361
+ }
362
+ var oe, Te;
363
+ function be() {
364
+ return Te || (Te = 1, oe = (o, s) => `${o}-${s}-${Math.random().toString(16).slice(3, 8)}`), oe;
365
+ }
366
+ var ie, _e;
367
+ function Ze() {
368
+ if (_e) return ie;
369
+ _e = 1;
370
+ const o = be();
371
+ let s = 0;
372
+ return ie = ({
373
+ id: t,
374
+ action: c,
375
+ payload: a = {}
376
+ }) => {
377
+ let u = t;
378
+ return typeof u > "u" && (u = o("Job", s), s += 1), {
379
+ id: u,
380
+ action: c,
381
+ payload: a
382
+ };
383
+ }, ie;
384
+ }
385
+ var Q = {}, qe;
386
+ function ke() {
387
+ if (qe) return Q;
388
+ qe = 1;
389
+ let o = !1;
390
+ return Q.logging = o, Q.setLogging = (s) => {
391
+ o = s;
392
+ }, Q.log = (...s) => o ? console.log.apply(this, s) : null, Q;
393
+ }
394
+ var ae, Pe;
395
+ function ur() {
396
+ if (Pe) return ae;
397
+ Pe = 1;
398
+ const o = Ze(), { log: s } = ke(), t = be();
399
+ let c = 0;
400
+ return ae = () => {
401
+ const a = t("Scheduler", c), u = {}, h = {};
402
+ let v = [];
403
+ c += 1;
404
+ const _ = () => v.length, I = () => Object.keys(u).length, q = () => {
405
+ if (v.length !== 0) {
406
+ const g = Object.keys(u);
407
+ for (let S = 0; S < g.length; S += 1)
408
+ if (typeof h[g[S]] > "u") {
409
+ v[0](u[g[S]]);
410
+ break;
411
+ }
412
+ }
413
+ }, b = (g, S) => new Promise((M, O) => {
414
+ const G = o({ action: g, payload: S });
415
+ v.push(async (y) => {
416
+ v.shift(), h[y.id] = G;
417
+ try {
418
+ M(await y[g].apply(this, [...S, G.id]));
419
+ } catch (P) {
420
+ O(P);
421
+ } finally {
422
+ delete h[y.id], q();
423
+ }
424
+ }), s(`[${a}]: Add ${G.id} to JobQueue`), s(`[${a}]: JobQueue length=${v.length}`), q();
425
+ });
426
+ return {
427
+ addWorker: (g) => (u[g.id] = g, s(`[${a}]: Add ${g.id}`), s(`[${a}]: Number of workers=${I()}`), q(), g.id),
428
+ addJob: async (g, ...S) => {
429
+ if (I() === 0)
430
+ throw Error(`[${a}]: You need to have at least one worker before adding jobs`);
431
+ return b(g, S);
432
+ },
433
+ terminate: async () => {
434
+ Object.keys(u).forEach(async (g) => {
435
+ await u[g].terminate();
436
+ }), v = [];
437
+ },
438
+ getQueueLen: _,
439
+ getNumWorkers: I
440
+ };
441
+ }, ae;
442
+ }
443
+ function cr(o) {
444
+ throw new Error('Could not dynamically require "' + o + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
445
+ }
446
+ var se, Ie;
447
+ function lr() {
448
+ if (Ie) return se;
449
+ Ie = 1;
450
+ function o() {
451
+ return !!(typeof window < "u" && typeof window.process == "object" && window.process.type === "renderer" || typeof process < "u" && typeof process.versions == "object" && process.versions.electron || typeof navigator == "object" && typeof navigator.userAgent == "string" && navigator.userAgent.indexOf("Electron") >= 0);
452
+ }
453
+ return se = o, se;
454
+ }
455
+ var ue, Ne;
456
+ function fr() {
457
+ if (Ne) return ue;
458
+ Ne = 1;
459
+ const o = lr();
460
+ return ue = (s) => {
461
+ const t = {};
462
+ return typeof WorkerGlobalScope < "u" ? t.type = "webworker" : o() ? t.type = "electron" : typeof document == "object" ? t.type = "browser" : typeof process == "object" && typeof cr == "function" && (t.type = "node"), typeof s > "u" ? t : t[s];
463
+ }, ue;
464
+ }
465
+ var ce, Ce;
466
+ function dr() {
467
+ if (Ce) return ce;
468
+ Ce = 1;
469
+ const s = fr()("type") === "browser" ? (t) => new URL(t, window.location.href).href : (t) => t;
470
+ return ce = (t) => {
471
+ const c = { ...t };
472
+ return ["corePath", "workerPath", "langPath"].forEach((a) => {
473
+ t[a] && (c[a] = s(c[a]));
474
+ }), c;
475
+ }, ce;
476
+ }
477
+ var le, Me;
478
+ function hr() {
479
+ return Me || (Me = 1, le = (o) => {
480
+ const s = [], t = [], c = [], a = [], u = [];
481
+ return o.blocks && o.blocks.forEach((h) => {
482
+ h.paragraphs.forEach((v) => {
483
+ v.lines.forEach((_) => {
484
+ _.words.forEach((I) => {
485
+ I.symbols.forEach((q) => {
486
+ u.push({
487
+ ...q,
488
+ page: o,
489
+ block: h,
490
+ paragraph: v,
491
+ line: _,
492
+ word: I
493
+ });
494
+ }), a.push({
495
+ ...I,
496
+ page: o,
497
+ block: h,
498
+ paragraph: v,
499
+ line: _
500
+ });
501
+ }), c.push({
502
+ ..._,
503
+ page: o,
504
+ block: h,
505
+ paragraph: v
506
+ });
507
+ }), t.push({
508
+ ...v,
509
+ page: o,
510
+ block: h
511
+ });
512
+ }), s.push({
513
+ ...h,
514
+ page: o
515
+ });
516
+ }), {
517
+ ...o,
518
+ blocks: s,
519
+ paragraphs: t,
520
+ lines: c,
521
+ words: a,
522
+ symbols: u
523
+ };
524
+ }), le;
525
+ }
526
+ var fe, Ge;
527
+ function Qe() {
528
+ return Ge || (Ge = 1, fe = {
529
+ TESSERACT_ONLY: 0,
530
+ LSTM_ONLY: 1,
531
+ TESSERACT_LSTM_COMBINED: 2,
532
+ DEFAULT: 3
533
+ }), fe;
534
+ }
535
+ const pr = "5.1.1", vr = {
536
+ version: pr
537
+ };
538
+ var de, je;
539
+ function gr() {
540
+ return je || (je = 1, de = {
541
+ /*
542
+ * Use BlobURL for worker script by default
543
+ * TODO: remove this option
544
+ *
545
+ */
546
+ workerBlobURL: !0,
547
+ logger: () => {
548
+ }
549
+ }), de;
550
+ }
551
+ var he, De;
552
+ function yr() {
553
+ if (De) return he;
554
+ De = 1;
555
+ const o = vr.version;
556
+ return he = {
557
+ ...gr(),
558
+ workerPath: `https://cdn.jsdelivr.net/npm/tesseract.js@v${o}/dist/worker.min.js`
559
+ }, he;
560
+ }
561
+ var pe, Ue;
562
+ function wr() {
563
+ return Ue || (Ue = 1, pe = ({ workerPath: o, workerBlobURL: s }) => {
564
+ let t;
565
+ if (Blob && URL && s) {
566
+ const c = new Blob([`importScripts("${o}");`], {
567
+ type: "application/javascript"
568
+ });
569
+ t = new Worker(URL.createObjectURL(c));
570
+ } else
571
+ t = new Worker(o);
572
+ return t;
573
+ }), pe;
574
+ }
575
+ var ve, We;
576
+ function mr() {
577
+ return We || (We = 1, ve = (o) => {
578
+ o.terminate();
579
+ }), ve;
580
+ }
581
+ var ge, ze;
582
+ function Lr() {
583
+ return ze || (ze = 1, ge = (o, s) => {
584
+ o.onmessage = ({ data: t }) => {
585
+ s(t);
586
+ };
587
+ }), ge;
588
+ }
589
+ var ye, Fe;
590
+ function Er() {
591
+ return Fe || (Fe = 1, ye = async (o, s) => {
592
+ o.postMessage(s);
593
+ }), ye;
594
+ }
595
+ var we, Be;
596
+ function Sr() {
597
+ if (Be) return we;
598
+ Be = 1;
599
+ const o = (t) => new Promise((c, a) => {
600
+ const u = new FileReader();
601
+ u.onload = () => {
602
+ c(u.result);
603
+ }, u.onerror = ({ target: { error: { code: h } } }) => {
604
+ a(Error(`File could not be read! Code=${h}`));
605
+ }, u.readAsArrayBuffer(t);
606
+ }), s = async (t) => {
607
+ let c = t;
608
+ if (typeof t > "u")
609
+ return "undefined";
610
+ if (typeof t == "string")
611
+ /data:image\/([a-zA-Z]*);base64,([^"]*)/.test(t) ? c = atob(t.split(",")[1]).split("").map((a) => a.charCodeAt(0)) : c = await (await fetch(t)).arrayBuffer();
612
+ else if (typeof HTMLElement < "u" && t instanceof HTMLElement)
613
+ t.tagName === "IMG" && (c = await s(t.src)), t.tagName === "VIDEO" && (c = await s(t.poster)), t.tagName === "CANVAS" && await new Promise((a) => {
614
+ t.toBlob(async (u) => {
615
+ c = await o(u), a();
616
+ });
617
+ });
618
+ else if (typeof OffscreenCanvas < "u" && t instanceof OffscreenCanvas) {
619
+ const a = await t.convertToBlob();
620
+ c = await o(a);
621
+ } else (t instanceof File || t instanceof Blob) && (c = await o(t));
622
+ return new Uint8Array(c);
623
+ };
624
+ return we = s, we;
625
+ }
626
+ var me, $e;
627
+ function Or() {
628
+ if ($e) return me;
629
+ $e = 1;
630
+ const o = yr(), s = wr(), t = mr(), c = Lr(), a = Er(), u = Sr();
631
+ return me = {
632
+ defaultOptions: o,
633
+ spawnWorker: s,
634
+ terminateWorker: t,
635
+ onMessage: c,
636
+ send: a,
637
+ loadImage: u
638
+ }, me;
639
+ }
640
+ var Le, Ye;
641
+ function Xe() {
642
+ if (Ye) return Le;
643
+ Ye = 1;
644
+ const o = dr(), s = hr(), t = Ze(), { log: c } = ke(), a = be(), u = Qe(), {
645
+ defaultOptions: h,
646
+ spawnWorker: v,
647
+ terminateWorker: _,
648
+ onMessage: I,
649
+ loadImage: q,
650
+ send: b
651
+ } = Or();
652
+ let $ = 0;
653
+ return Le = async (C = "eng", F = u.LSTM_ONLY, g = {}, S = {}) => {
654
+ const M = a("Worker", $), {
655
+ logger: O,
656
+ errorHandler: G,
657
+ ...y
658
+ } = o({
659
+ ...h,
660
+ ...g
661
+ }), P = {}, Y = {}, K = typeof C == "string" ? C.split("+") : C;
662
+ let W = F, j = S;
663
+ const H = [u.DEFAULT, u.LSTM_ONLY].includes(F) && !y.legacyCore;
664
+ let z, X;
665
+ const x = new Promise((f, d) => {
666
+ X = f, z = d;
667
+ }), re = (f) => {
668
+ z(f.message);
669
+ };
670
+ let N = v(y);
671
+ N.onerror = re, $ += 1;
672
+ const J = (f, d) => {
673
+ P[f] = d;
674
+ }, V = (f, d) => {
675
+ Y[f] = d;
676
+ }, k = ({ id: f, action: d, payload: L }) => new Promise((T, R) => {
677
+ c(`[${M}]: Start ${f}, action=${d}`);
678
+ const U = `${d}-${f}`;
679
+ J(U, T), V(U, R), b(N, {
680
+ workerId: M,
681
+ jobId: f,
682
+ action: d,
683
+ payload: L
684
+ });
685
+ }), r = () => console.warn("`load` is depreciated and should be removed from code (workers now come pre-loaded)"), e = (f) => k(t({
686
+ id: f,
687
+ action: "load",
688
+ payload: { options: { lstmOnly: H, corePath: y.corePath, logging: y.logging } }
689
+ })), n = (f, d, L) => k(t({
690
+ id: L,
691
+ action: "FS",
692
+ payload: { method: "writeFile", args: [f, d] }
693
+ })), l = (f, d) => k(t({
694
+ id: d,
695
+ action: "FS",
696
+ payload: { method: "readFile", args: [f, { encoding: "utf8" }] }
697
+ })), i = (f, d) => k(t({
698
+ id: d,
699
+ action: "FS",
700
+ payload: { method: "unlink", args: [f] }
701
+ })), p = (f, d, L) => k(t({
702
+ id: L,
703
+ action: "FS",
704
+ payload: { method: f, args: d }
705
+ })), E = () => console.warn("`loadLanguage` is depreciated and should be removed from code (workers now come with language pre-loaded)"), m = (f, d) => k(t({
706
+ id: d,
707
+ action: "loadLanguage",
708
+ payload: {
709
+ langs: f,
710
+ options: {
711
+ langPath: y.langPath,
712
+ dataPath: y.dataPath,
713
+ cachePath: y.cachePath,
714
+ cacheMethod: y.cacheMethod,
715
+ gzip: y.gzip,
716
+ lstmOnly: [u.DEFAULT, u.LSTM_ONLY].includes(W) && !y.legacyLang
717
+ }
718
+ }
719
+ })), A = () => console.warn("`initialize` is depreciated and should be removed from code (workers now come pre-initialized)"), w = (f, d, L, T) => k(t({
720
+ id: T,
721
+ action: "initialize",
722
+ payload: { langs: f, oem: d, config: L }
723
+ })), Z = (f = "eng", d, L, T) => {
724
+ if (H && [u.TESSERACT_ONLY, u.TESSERACT_LSTM_COMBINED].includes(d)) throw Error("Legacy model requested but code missing.");
725
+ const R = d || W;
726
+ W = R;
727
+ const U = L || j;
728
+ j = U;
729
+ const te = (typeof f == "string" ? f.split("+") : f).filter((or) => !K.includes(or));
730
+ return K.push(...te), te.length > 0 ? m(te, T).then(() => w(f, R, U, T)) : w(f, R, U, T);
731
+ }, B = (f = {}, d) => k(t({
732
+ id: d,
733
+ action: "setParameters",
734
+ payload: { params: f }
735
+ })), D = async (f, d = {}, L = {
736
+ blocks: !0,
737
+ text: !0,
738
+ hocr: !0,
739
+ tsv: !0
740
+ }, T) => k(t({
741
+ id: T,
742
+ action: "recognize",
743
+ payload: { image: await q(f), options: d, output: L }
744
+ })), er = (f = "Tesseract OCR Result", d = !1, L) => (console.log("`getPDF` function is depreciated. `recognize` option `savePDF` should be used instead."), k(t({
745
+ id: L,
746
+ action: "getPDF",
747
+ payload: { title: f, textonly: d }
748
+ }))), rr = async (f, d) => {
749
+ if (H) throw Error("`worker.detect` requires Legacy model, which was not loaded.");
750
+ return k(t({
751
+ id: d,
752
+ action: "detect",
753
+ payload: { image: await q(f) }
754
+ }));
755
+ }, tr = async () => (N !== null && (_(N), N = null), Promise.resolve());
756
+ I(N, ({
757
+ workerId: f,
758
+ jobId: d,
759
+ status: L,
760
+ action: T,
761
+ data: R
762
+ }) => {
763
+ const U = `${T}-${d}`;
764
+ if (L === "resolve") {
765
+ c(`[${f}]: Complete ${d}`);
766
+ let ee = R;
767
+ T === "recognize" ? ee = s(R) : T === "getPDF" && (ee = Array.from({ ...R, length: Object.keys(R).length })), P[U]({ jobId: d, data: ee });
768
+ } else if (L === "reject")
769
+ if (Y[U](R), T === "load" && z(R), G)
770
+ G(R);
771
+ else
772
+ throw Error(R);
773
+ else L === "progress" && O({ ...R, userJobId: d });
774
+ });
775
+ const nr = {
776
+ id: M,
777
+ worker: N,
778
+ setResolve: J,
779
+ setReject: V,
780
+ load: r,
781
+ writeText: n,
782
+ readText: l,
783
+ removeFile: i,
784
+ FS: p,
785
+ loadLanguage: E,
786
+ initialize: A,
787
+ reinitialize: Z,
788
+ setParameters: B,
789
+ recognize: D,
790
+ getPDF: er,
791
+ detect: rr,
792
+ terminate: tr
793
+ };
794
+ return e().then(() => m(C)).then(() => w(C, F, S)).then(() => X(nr)).catch(() => {
795
+ }), x;
796
+ }, Le;
797
+ }
798
+ var Ee, Ke;
799
+ function Rr() {
800
+ if (Ke) return Ee;
801
+ Ke = 1;
802
+ const o = Xe();
803
+ return Ee = {
804
+ recognize: async (c, a, u) => {
805
+ const h = await o(a, 1, u);
806
+ return h.recognize(c).finally(async () => {
807
+ await h.terminate();
808
+ });
809
+ },
810
+ detect: async (c, a) => {
811
+ const u = await o("osd", 0, a);
812
+ return u.detect(c).finally(async () => {
813
+ await u.terminate();
814
+ });
815
+ }
816
+ }, Ee;
817
+ }
818
+ var Se, He;
819
+ function br() {
820
+ return He || (He = 1, Se = {
821
+ AFR: "afr",
822
+ AMH: "amh",
823
+ ARA: "ara",
824
+ ASM: "asm",
825
+ AZE: "aze",
826
+ AZE_CYRL: "aze_cyrl",
827
+ BEL: "bel",
828
+ BEN: "ben",
829
+ BOD: "bod",
830
+ BOS: "bos",
831
+ BUL: "bul",
832
+ CAT: "cat",
833
+ CEB: "ceb",
834
+ CES: "ces",
835
+ CHI_SIM: "chi_sim",
836
+ CHI_TRA: "chi_tra",
837
+ CHR: "chr",
838
+ CYM: "cym",
839
+ DAN: "dan",
840
+ DEU: "deu",
841
+ DZO: "dzo",
842
+ ELL: "ell",
843
+ ENG: "eng",
844
+ ENM: "enm",
845
+ EPO: "epo",
846
+ EST: "est",
847
+ EUS: "eus",
848
+ FAS: "fas",
849
+ FIN: "fin",
850
+ FRA: "fra",
851
+ FRK: "frk",
852
+ FRM: "frm",
853
+ GLE: "gle",
854
+ GLG: "glg",
855
+ GRC: "grc",
856
+ GUJ: "guj",
857
+ HAT: "hat",
858
+ HEB: "heb",
859
+ HIN: "hin",
860
+ HRV: "hrv",
861
+ HUN: "hun",
862
+ IKU: "iku",
863
+ IND: "ind",
864
+ ISL: "isl",
865
+ ITA: "ita",
866
+ ITA_OLD: "ita_old",
867
+ JAV: "jav",
868
+ JPN: "jpn",
869
+ KAN: "kan",
870
+ KAT: "kat",
871
+ KAT_OLD: "kat_old",
872
+ KAZ: "kaz",
873
+ KHM: "khm",
874
+ KIR: "kir",
875
+ KOR: "kor",
876
+ KUR: "kur",
877
+ LAO: "lao",
878
+ LAT: "lat",
879
+ LAV: "lav",
880
+ LIT: "lit",
881
+ MAL: "mal",
882
+ MAR: "mar",
883
+ MKD: "mkd",
884
+ MLT: "mlt",
885
+ MSA: "msa",
886
+ MYA: "mya",
887
+ NEP: "nep",
888
+ NLD: "nld",
889
+ NOR: "nor",
890
+ ORI: "ori",
891
+ PAN: "pan",
892
+ POL: "pol",
893
+ POR: "por",
894
+ PUS: "pus",
895
+ RON: "ron",
896
+ RUS: "rus",
897
+ SAN: "san",
898
+ SIN: "sin",
899
+ SLK: "slk",
900
+ SLV: "slv",
901
+ SPA: "spa",
902
+ SPA_OLD: "spa_old",
903
+ SQI: "sqi",
904
+ SRP: "srp",
905
+ SRP_LATN: "srp_latn",
906
+ SWA: "swa",
907
+ SWE: "swe",
908
+ SYR: "syr",
909
+ TAM: "tam",
910
+ TEL: "tel",
911
+ TGK: "tgk",
912
+ TGL: "tgl",
913
+ THA: "tha",
914
+ TIR: "tir",
915
+ TUR: "tur",
916
+ UIG: "uig",
917
+ UKR: "ukr",
918
+ URD: "urd",
919
+ UZB: "uzb",
920
+ UZB_CYRL: "uzb_cyrl",
921
+ VIE: "vie",
922
+ YID: "yid"
923
+ }), Se;
924
+ }
925
+ var Oe, Je;
926
+ function kr() {
927
+ return Je || (Je = 1, Oe = {
928
+ OSD_ONLY: "0",
929
+ AUTO_OSD: "1",
930
+ AUTO_ONLY: "2",
931
+ AUTO: "3",
932
+ SINGLE_COLUMN: "4",
933
+ SINGLE_BLOCK_VERT_TEXT: "5",
934
+ SINGLE_BLOCK: "6",
935
+ SINGLE_LINE: "7",
936
+ SINGLE_WORD: "8",
937
+ CIRCLE_WORD: "9",
938
+ SINGLE_CHAR: "10",
939
+ SPARSE_TEXT: "11",
940
+ SPARSE_TEXT_OSD: "12",
941
+ RAW_LINE: "13"
942
+ }), Oe;
943
+ }
944
+ var Re, Ve;
945
+ function Ar() {
946
+ if (Ve) return Re;
947
+ Ve = 1, sr();
948
+ const o = ur(), s = Xe(), t = Rr(), c = br(), a = Qe(), u = kr(), { setLogging: h } = ke();
949
+ return Re = {
950
+ languages: c,
951
+ OEM: a,
952
+ PSM: u,
953
+ createScheduler: o,
954
+ createWorker: s,
955
+ setLogging: h,
956
+ ...t
957
+ }, Re;
958
+ }
959
+ var xe = Ar();
960
+ const Tr = /* @__PURE__ */ ir(xe), qr = /* @__PURE__ */ ar({
961
+ __proto__: null,
962
+ default: Tr
963
+ }, [xe]);
964
+ export {
965
+ qr as i
966
+ };
967
+ //# sourceMappingURL=index-Br2RPwqy.js.map