pica 10.0.0 → 10.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/pica.cjs.d.ts +2 -1
- package/dist/pica.es.d.ts +2 -1
- package/dist/pica.js +215 -300
- package/dist/pica.js.map +1 -1
- package/dist/pica.min.js +1 -1
- package/dist/pica.min.js.map +1 -1
- package/dist/pica.min.mjs +1 -1
- package/dist/pica.min.mjs.map +1 -1
- package/dist/pica.mjs +215 -300
- package/dist/pica.mjs.map +1 -1
- package/dist/pica_main.js +214 -299
- package/dist/pica_main.js.map +1 -1
- package/dist/pica_main.mjs +214 -299
- package/dist/pica_main.mjs.map +1 -1
- package/dist/pica_worker.js +209 -294
- package/dist/pica_worker.js.map +1 -1
- package/package.json +24 -5
package/dist/pica.mjs
CHANGED
|
@@ -4,183 +4,105 @@ pica
|
|
|
4
4
|
https://github.com/nodeca/pica
|
|
5
5
|
|
|
6
6
|
*/
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
16
|
-
key = keys[i];
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
-
get: ((k) => from[k]).bind(null, key),
|
|
19
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
-
value: mod,
|
|
26
|
-
enumerable: true
|
|
27
|
-
}) : target, mod));
|
|
28
|
-
/*
|
|
29
|
-
object-assign
|
|
30
|
-
(c) Sindre Sorhus
|
|
31
|
-
@license MIT
|
|
32
|
-
*/
|
|
33
|
-
var require_object_assign = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
34
|
-
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
35
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
36
|
-
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
37
|
-
function toObject(val) {
|
|
38
|
-
if (val === null || val === void 0) throw new TypeError("Object.assign cannot be called with null or undefined");
|
|
39
|
-
return Object(val);
|
|
40
|
-
}
|
|
41
|
-
function shouldUseNative() {
|
|
42
|
-
try {
|
|
43
|
-
if (!Object.assign) return false;
|
|
44
|
-
var test1 = /* @__PURE__ */ new String("abc");
|
|
45
|
-
test1[5] = "de";
|
|
46
|
-
if (Object.getOwnPropertyNames(test1)[0] === "5") return false;
|
|
47
|
-
var test2 = {};
|
|
48
|
-
for (var i = 0; i < 10; i++) test2["_" + String.fromCharCode(i)] = i;
|
|
49
|
-
if (Object.getOwnPropertyNames(test2).map(function(n) {
|
|
50
|
-
return test2[n];
|
|
51
|
-
}).join("") !== "0123456789") return false;
|
|
52
|
-
var test3 = {};
|
|
53
|
-
"abcdefghijklmnopqrst".split("").forEach(function(letter) {
|
|
54
|
-
test3[letter] = letter;
|
|
55
|
-
});
|
|
56
|
-
if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") return false;
|
|
57
|
-
return true;
|
|
58
|
-
} catch (err) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
module.exports = shouldUseNative() ? Object.assign : function(target, source) {
|
|
63
|
-
var from;
|
|
64
|
-
var to = toObject(target);
|
|
65
|
-
var symbols;
|
|
66
|
-
for (var s = 1; s < arguments.length; s++) {
|
|
67
|
-
from = Object(arguments[s]);
|
|
68
|
-
for (var key in from) if (hasOwnProperty.call(from, key)) to[key] = from[key];
|
|
69
|
-
if (getOwnPropertySymbols) {
|
|
70
|
-
symbols = getOwnPropertySymbols(from);
|
|
71
|
-
for (var i = 0; i < symbols.length; i++) if (propIsEnumerable.call(from, symbols[i])) to[symbols[i]] = from[symbols[i]];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return to;
|
|
75
|
-
};
|
|
76
|
-
}));
|
|
77
|
-
var require_base64decode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
78
|
-
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
79
|
-
module.exports = function base64decode(str) {
|
|
80
|
-
var input = str.replace(/[\r\n=]/g, ""), max = input.length;
|
|
81
|
-
var out = new Uint8Array(max * 3 >> 2);
|
|
82
|
-
var bits = 0;
|
|
83
|
-
var ptr = 0;
|
|
84
|
-
for (var idx = 0; idx < max; idx++) {
|
|
85
|
-
if (idx % 4 === 0 && idx) {
|
|
86
|
-
out[ptr++] = bits >> 16 & 255;
|
|
87
|
-
out[ptr++] = bits >> 8 & 255;
|
|
88
|
-
out[ptr++] = bits & 255;
|
|
89
|
-
}
|
|
90
|
-
bits = bits << 6 | BASE64_MAP.indexOf(input.charAt(idx));
|
|
91
|
-
}
|
|
92
|
-
var tailbits = max % 4 * 6;
|
|
93
|
-
if (tailbits === 0) {
|
|
7
|
+
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
8
|
+
function base64decode(str) {
|
|
9
|
+
const input = str.replace(/[\r\n=]/g, ""), max = input.length;
|
|
10
|
+
const out = new Uint8Array(max * 3 >> 2);
|
|
11
|
+
let bits = 0;
|
|
12
|
+
let ptr = 0;
|
|
13
|
+
for (let idx = 0; idx < max; idx++) {
|
|
14
|
+
if (idx % 4 === 0 && idx) {
|
|
94
15
|
out[ptr++] = bits >> 16 & 255;
|
|
95
16
|
out[ptr++] = bits >> 8 & 255;
|
|
96
17
|
out[ptr++] = bits & 255;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
18
|
+
}
|
|
19
|
+
bits = bits << 6 | BASE64_MAP.indexOf(input.charAt(idx));
|
|
20
|
+
}
|
|
21
|
+
const tailbits = max % 4 * 6;
|
|
22
|
+
if (tailbits === 0) {
|
|
23
|
+
out[ptr++] = bits >> 16 & 255;
|
|
24
|
+
out[ptr++] = bits >> 8 & 255;
|
|
25
|
+
out[ptr++] = bits & 255;
|
|
26
|
+
} else if (tailbits === 18) {
|
|
27
|
+
out[ptr++] = bits >> 10 & 255;
|
|
28
|
+
out[ptr++] = bits >> 2 & 255;
|
|
29
|
+
} else if (tailbits === 12) out[ptr++] = bits >> 4 & 255;
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
var wa;
|
|
33
|
+
function hasWebAssembly() {
|
|
34
|
+
if (typeof wa !== "undefined") return wa;
|
|
35
|
+
wa = false;
|
|
36
|
+
if (typeof WebAssembly === "undefined") return wa;
|
|
37
|
+
try {
|
|
38
|
+
const bin = new Uint8Array([
|
|
39
|
+
0,
|
|
40
|
+
97,
|
|
41
|
+
115,
|
|
42
|
+
109,
|
|
43
|
+
1,
|
|
44
|
+
0,
|
|
45
|
+
0,
|
|
46
|
+
0,
|
|
47
|
+
1,
|
|
48
|
+
6,
|
|
49
|
+
1,
|
|
50
|
+
96,
|
|
51
|
+
1,
|
|
52
|
+
127,
|
|
53
|
+
1,
|
|
54
|
+
127,
|
|
55
|
+
3,
|
|
56
|
+
2,
|
|
57
|
+
1,
|
|
58
|
+
0,
|
|
59
|
+
5,
|
|
60
|
+
3,
|
|
61
|
+
1,
|
|
62
|
+
0,
|
|
63
|
+
1,
|
|
64
|
+
7,
|
|
65
|
+
8,
|
|
66
|
+
1,
|
|
67
|
+
4,
|
|
68
|
+
116,
|
|
69
|
+
101,
|
|
70
|
+
115,
|
|
71
|
+
116,
|
|
72
|
+
0,
|
|
73
|
+
0,
|
|
74
|
+
10,
|
|
75
|
+
16,
|
|
76
|
+
1,
|
|
77
|
+
14,
|
|
78
|
+
0,
|
|
79
|
+
32,
|
|
80
|
+
0,
|
|
81
|
+
65,
|
|
82
|
+
1,
|
|
83
|
+
54,
|
|
84
|
+
2,
|
|
85
|
+
0,
|
|
86
|
+
32,
|
|
87
|
+
0,
|
|
88
|
+
40,
|
|
89
|
+
2,
|
|
90
|
+
0,
|
|
91
|
+
11
|
|
92
|
+
]);
|
|
93
|
+
const module = new WebAssembly.Module(bin);
|
|
94
|
+
if (new WebAssembly.Instance(module, {}).exports.test(4) !== 0) wa = true;
|
|
170
95
|
return wa;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
function MultiMath(options) {
|
|
182
|
-
if (!(this instanceof MultiMath)) return new MultiMath(options);
|
|
183
|
-
var opts = assign({}, DEFAULT_OPTIONS, options || {});
|
|
96
|
+
} catch (__) {}
|
|
97
|
+
return wa;
|
|
98
|
+
}
|
|
99
|
+
var DEFAULT_OPTIONS = {
|
|
100
|
+
js: true,
|
|
101
|
+
wasm: true
|
|
102
|
+
};
|
|
103
|
+
var MultiMath = class {
|
|
104
|
+
constructor(options) {
|
|
105
|
+
const opts = Object.assign({}, DEFAULT_OPTIONS, options || {});
|
|
184
106
|
this.options = opts;
|
|
185
107
|
this.__cache = {};
|
|
186
108
|
this.__init_promise = null;
|
|
@@ -195,47 +117,45 @@ var require_multimath = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
195
117
|
]).buffer)[0] === 1;
|
|
196
118
|
if (!this.options.js && !this.options.wasm) throw new Error("mathlib: at least \"js\" or \"wasm\" should be enabled");
|
|
197
119
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
120
|
+
has_wasm() {
|
|
121
|
+
return hasWebAssembly();
|
|
122
|
+
}
|
|
123
|
+
use(module) {
|
|
124
|
+
this.__modules[module.name] = module;
|
|
125
|
+
if (this.options.wasm && this.has_wasm() && module.wasm_fn) this[module.name] = module.wasm_fn;
|
|
126
|
+
else this[module.name] = module.fn;
|
|
203
127
|
return this;
|
|
204
|
-
}
|
|
205
|
-
|
|
128
|
+
}
|
|
129
|
+
init() {
|
|
206
130
|
if (this.__init_promise) return this.__init_promise;
|
|
207
131
|
if (!this.options.js && this.options.wasm && !this.has_wasm()) return Promise.reject(/* @__PURE__ */ new Error("mathlib: only \"wasm\" was enabled, but it's not supported"));
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
self.__wasm[name] = m;
|
|
132
|
+
this.__init_promise = Promise.all(Object.keys(this.__modules).map((name) => {
|
|
133
|
+
const module = this.__modules[name];
|
|
134
|
+
if (!this.options.wasm || !this.has_wasm() || !module.wasm_fn) return null;
|
|
135
|
+
if (this.__wasm[name]) return null;
|
|
136
|
+
return WebAssembly.compile(base64decode(module.wasm_src)).then((m) => {
|
|
137
|
+
this.__wasm[name] = m;
|
|
215
138
|
});
|
|
216
|
-
})).then(
|
|
217
|
-
return self;
|
|
218
|
-
});
|
|
139
|
+
})).then(() => this);
|
|
219
140
|
return this.__init_promise;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
MultiMath.prototype.__reallocate = function mem_grow_to(bytes) {
|
|
141
|
+
}
|
|
142
|
+
__reallocate(bytes) {
|
|
223
143
|
if (!this.__memory) {
|
|
224
144
|
this.__memory = new WebAssembly.Memory({ initial: Math.ceil(bytes / (64 * 1024)) });
|
|
225
145
|
return this.__memory;
|
|
226
146
|
}
|
|
227
|
-
|
|
147
|
+
const mem_size = this.__memory.buffer.byteLength;
|
|
228
148
|
if (mem_size < bytes) this.__memory.grow(Math.ceil((bytes - mem_size) / (64 * 1024)));
|
|
229
149
|
return this.__memory;
|
|
230
|
-
}
|
|
231
|
-
|
|
150
|
+
}
|
|
151
|
+
__instance(name, memsize, env_extra) {
|
|
232
152
|
if (memsize) this.__reallocate(memsize);
|
|
233
153
|
if (!this.__wasm[name]) {
|
|
234
|
-
|
|
235
|
-
this.__wasm[name] = new WebAssembly.Module(
|
|
154
|
+
const module = this.__modules[name];
|
|
155
|
+
this.__wasm[name] = new WebAssembly.Module(base64decode(module.wasm_src));
|
|
236
156
|
}
|
|
237
157
|
if (!this.__cache[name]) {
|
|
238
|
-
|
|
158
|
+
const env_base = {
|
|
239
159
|
memoryBase: 0,
|
|
240
160
|
memory: this.__memory,
|
|
241
161
|
tableBase: 0,
|
|
@@ -244,100 +164,93 @@ var require_multimath = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
244
164
|
element: "anyfunc"
|
|
245
165
|
})
|
|
246
166
|
};
|
|
247
|
-
this.__cache[name] = new WebAssembly.Instance(this.__wasm[name], { env: assign(env_base, env_extra || {}) });
|
|
167
|
+
this.__cache[name] = new WebAssembly.Instance(this.__wasm[name], { env: Object.assign(env_base, env_extra || {}) });
|
|
248
168
|
}
|
|
249
169
|
return this.__cache[name];
|
|
250
|
-
}
|
|
251
|
-
|
|
170
|
+
}
|
|
171
|
+
__align(number, base) {
|
|
252
172
|
base = base || 8;
|
|
253
|
-
|
|
173
|
+
const reminder = number % base;
|
|
254
174
|
return number + (reminder ? base - reminder : 0);
|
|
255
|
-
};
|
|
256
|
-
module.exports = MultiMath;
|
|
257
|
-
}));
|
|
258
|
-
var require_mono16 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
259
|
-
var a0, a1, a2, a3, b1, b2, left_corner, right_corner;
|
|
260
|
-
function gaussCoef(sigma) {
|
|
261
|
-
if (sigma < .5) sigma = .5;
|
|
262
|
-
var a = Math.exp(.726 * .726) / sigma, g1 = Math.exp(-a), g2 = Math.exp(-2 * a), k = (1 - g1) * (1 - g1) / (1 + 2 * a * g1 - g2);
|
|
263
|
-
a0 = k;
|
|
264
|
-
a1 = k * (a - 1) * g1;
|
|
265
|
-
a2 = k * (a + 1) * g1;
|
|
266
|
-
a3 = -k * g2;
|
|
267
|
-
b1 = 2 * g1;
|
|
268
|
-
b2 = -g2;
|
|
269
|
-
left_corner = (a0 + a1) / (1 - b1 - b2);
|
|
270
|
-
right_corner = (a2 + a3) / (1 - b1 - b2);
|
|
271
|
-
return new Float32Array([
|
|
272
|
-
a0,
|
|
273
|
-
a1,
|
|
274
|
-
a2,
|
|
275
|
-
a3,
|
|
276
|
-
b1,
|
|
277
|
-
b2,
|
|
278
|
-
left_corner,
|
|
279
|
-
right_corner
|
|
280
|
-
]);
|
|
281
175
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
176
|
+
};
|
|
177
|
+
function gaussCoef(sigma) {
|
|
178
|
+
if (sigma < .5) sigma = .5;
|
|
179
|
+
const a = Math.exp(.726 * .726) / sigma, g1 = Math.exp(-a), g2 = Math.exp(-2 * a), k = (1 - g1) * (1 - g1) / (1 + 2 * a * g1 - g2);
|
|
180
|
+
const a0 = k;
|
|
181
|
+
const a1 = k * (a - 1) * g1;
|
|
182
|
+
const a2 = k * (a + 1) * g1;
|
|
183
|
+
const a3 = -k * g2;
|
|
184
|
+
const b1 = 2 * g1;
|
|
185
|
+
const b2 = -g2;
|
|
186
|
+
const left_corner = (a0 + a1) / (1 - b1 - b2);
|
|
187
|
+
const right_corner = (a2 + a3) / (1 - b1 - b2);
|
|
188
|
+
return new Float32Array([
|
|
189
|
+
a0,
|
|
190
|
+
a1,
|
|
191
|
+
a2,
|
|
192
|
+
a3,
|
|
193
|
+
b1,
|
|
194
|
+
b2,
|
|
195
|
+
left_corner,
|
|
196
|
+
right_corner
|
|
197
|
+
]);
|
|
198
|
+
}
|
|
199
|
+
function convolveMono16(src, out, line, coeff, width, height) {
|
|
200
|
+
let prev_src, curr_src, curr_out, prev_out, prev_prev_out;
|
|
201
|
+
let src_index, out_index, line_index;
|
|
202
|
+
let i, j;
|
|
203
|
+
let coeff_a0, coeff_a1, coeff_b1, coeff_b2;
|
|
204
|
+
for (i = 0; i < height; i++) {
|
|
205
|
+
src_index = i * width;
|
|
206
|
+
out_index = i;
|
|
207
|
+
line_index = 0;
|
|
208
|
+
prev_src = src[src_index];
|
|
209
|
+
prev_prev_out = prev_src * coeff[6];
|
|
210
|
+
prev_out = prev_prev_out;
|
|
211
|
+
coeff_a0 = coeff[0];
|
|
212
|
+
coeff_a1 = coeff[1];
|
|
213
|
+
coeff_b1 = coeff[4];
|
|
214
|
+
coeff_b2 = coeff[5];
|
|
215
|
+
for (j = 0; j < width; j++) {
|
|
216
|
+
curr_src = src[src_index];
|
|
217
|
+
curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;
|
|
218
|
+
prev_prev_out = prev_out;
|
|
219
|
+
prev_out = curr_out;
|
|
220
|
+
prev_src = curr_src;
|
|
221
|
+
line[line_index] = prev_out;
|
|
222
|
+
line_index++;
|
|
223
|
+
src_index++;
|
|
224
|
+
}
|
|
225
|
+
src_index--;
|
|
226
|
+
line_index--;
|
|
227
|
+
out_index += height * (width - 1);
|
|
228
|
+
prev_src = src[src_index];
|
|
229
|
+
prev_prev_out = prev_src * coeff[7];
|
|
230
|
+
prev_out = prev_prev_out;
|
|
231
|
+
curr_src = prev_src;
|
|
232
|
+
coeff_a0 = coeff[2];
|
|
233
|
+
coeff_a1 = coeff[3];
|
|
234
|
+
for (j = width - 1; j >= 0; j--) {
|
|
235
|
+
curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;
|
|
236
|
+
prev_prev_out = prev_out;
|
|
237
|
+
prev_out = curr_out;
|
|
238
|
+
prev_src = curr_src;
|
|
239
|
+
curr_src = src[src_index];
|
|
240
|
+
out[out_index] = line[line_index] + prev_out;
|
|
308
241
|
src_index--;
|
|
309
242
|
line_index--;
|
|
310
|
-
out_index
|
|
311
|
-
prev_src = src[src_index];
|
|
312
|
-
prev_prev_out = prev_src * coeff[7];
|
|
313
|
-
prev_out = prev_prev_out;
|
|
314
|
-
curr_src = prev_src;
|
|
315
|
-
coeff_a0 = coeff[2];
|
|
316
|
-
coeff_a1 = coeff[3];
|
|
317
|
-
for (j = width - 1; j >= 0; j--) {
|
|
318
|
-
curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;
|
|
319
|
-
prev_prev_out = prev_out;
|
|
320
|
-
prev_out = curr_out;
|
|
321
|
-
prev_src = curr_src;
|
|
322
|
-
curr_src = src[src_index];
|
|
323
|
-
out[out_index] = line[line_index] + prev_out;
|
|
324
|
-
src_index--;
|
|
325
|
-
line_index--;
|
|
326
|
-
out_index -= height;
|
|
327
|
-
}
|
|
243
|
+
out_index -= height;
|
|
328
244
|
}
|
|
329
245
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}));
|
|
339
|
-
var import_multimath = /* @__PURE__ */ __toESM(require_multimath());
|
|
340
|
-
var import_mono16 = /* @__PURE__ */ __toESM(require_mono16());
|
|
246
|
+
}
|
|
247
|
+
function blurMono16(src, width, height, radius) {
|
|
248
|
+
if (!radius) return;
|
|
249
|
+
const out = new Uint16Array(src.length), tmp_line = new Float32Array(Math.max(width, height));
|
|
250
|
+
const coeff = gaussCoef(radius);
|
|
251
|
+
convolveMono16(src, out, tmp_line, coeff, width, height, radius);
|
|
252
|
+
convolveMono16(out, src, tmp_line, coeff, height, width, radius);
|
|
253
|
+
}
|
|
341
254
|
function hsv_v16(img, width, height) {
|
|
342
255
|
const size = width * height;
|
|
343
256
|
const out = new Uint16Array(size);
|
|
@@ -358,7 +271,7 @@ function unsharp$1(img, width, height, amount, radius, threshold) {
|
|
|
358
271
|
if (radius > 2) radius = 2;
|
|
359
272
|
const brightness = hsv_v16(img, width, height);
|
|
360
273
|
const blured = new Uint16Array(brightness);
|
|
361
|
-
(
|
|
274
|
+
blurMono16(blured, width, height, radius);
|
|
362
275
|
const amountFp = amount / 100 * 4096 + .5 | 0;
|
|
363
276
|
const thresholdFp = threshold << 8;
|
|
364
277
|
const size = width * height;
|
|
@@ -785,7 +698,7 @@ var mm_resize_default = {
|
|
|
785
698
|
wasm_fn: resize_wasm,
|
|
786
699
|
wasm_src: "AGFzbQEAAAAADAZkeWxpbmsAAAAAAAEYA2AGf39/f39/AGAAAGAIf39/f39/f38AAg8BA2VudgZtZW1vcnkCAAADBwYBAAAAAAIGBgF/AEEACweUAQgRX193YXNtX2NhbGxfY3RvcnMAAAtjb252b2x2ZUhvcgABDGNvbnZvbHZlVmVydAACEmNvbnZvbHZlSG9yV2l0aFByZQADE2NvbnZvbHZlVmVydFdpdGhQcmUABApjb252b2x2ZUhWAAUMX19kc29faGFuZGxlAwAYX193YXNtX2FwcGx5X2RhdGFfcmVsb2NzAAAKyA4GAwABC4wDARB/AkAgA0UNACAERQ0AIANBAnQhFQNAQQAhE0EAIQsDQCALQQJqIQcCfyALQQF0IAVqIgYuAQIiC0UEQEEAIQhBACEGQQAhCUEAIQogBwwBCyASIAYuAQBqIQhBACEJQQAhCiALIRRBACEOIAchBkEAIQ8DQCAFIAZBAXRqLgEAIhAgACAIQQJ0aigCACIRQRh2bCAPaiEPIBFB/wFxIBBsIAlqIQkgEUEQdkH/AXEgEGwgDmohDiARQQh2Qf8BcSAQbCAKaiEKIAhBAWohCCAGQQFqIQYgFEEBayIUDQALIAlBB3UhCCAKQQd1IQYgDkEHdSEJIA9BB3UhCiAHIAtqCyELIAEgDEEBdCIHaiAIQQAgCEEAShs7AQAgASAHQQJyaiAGQQAgBkEAShs7AQAgASAHQQRyaiAJQQAgCUEAShs7AQAgASAHQQZyaiAKQQAgCkEAShs7AQAgDCAVaiEMIBNBAWoiEyAERw0ACyANQQFqIg0gAmwhEiANQQJ0IQwgAyANRw0ACwsL2gMBD38CQCADRQ0AIARFDQAgAkECdCEUA0AgCyEMQQAhE0EAIQIDQCACQQJqIQYCfyACQQF0IAVqIgcuAQIiAkUEQEEAIQhBACEHQQAhCkEAIQkgBgwBCyAHLgEAQQJ0IBJ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AIAshDEEAIRJBACEHA0AgB0ECaiEKAn8gB0EBdCAFaiICLgECIhNFBEBBACEIQQAhCUEAIQYgCiEHQQAMAQsgAi4BAEECdCARaiEJQQAhByATIQJBACENIAohBkEAIQ5BACEPA0AgBSAGQQF0ai4BACIIIAAgCUEBdCIQai8BAGwgB2ohByAAIBBBBnJqLwEAIAhsIA5qIQ4gACAQQQRyai8BACAIbCAPaiEPIAAgEEECcmovAQAgCGwgDWohDSAJQQRqIQkgBkEBaiEGIAJBAWsiAg0ACyAHQQd1IQggDUEHdSEJIA9BB3UhBiAKIBNqIQcgDkEHdQtBgEBrQQ51IgJB/wEgAkH/AUgbIgJBACACQQBKGyIKQf8BcQRAIAlB/wFsIAJtIQkgCEH/AWwgAm0hCCAGQf8BbCACbSEGCyABIAxBAnRqIAlBgEBrQQ51IgJB/wEgAkH/AUgbIgJBACACQQBKG0EIdEGA/gNxIAZBgEBrQQ51IgJB/wEgAkH/AUgbIgJBACACQQBKG0EQdEGAgPwHcSAKQRh0ciAIQYBAa0EOdSICQf8BIAJB/wFIGyICQQAgAkEAShtycjYCACADIAxqIQwgEkEBaiISIARHDQALIBQgC0EBaiILbCERIAMgC0cNAAsLC0AAIAcEQEEAIAIgAyAEIAUgABADIAJBACAEIAUgBiABEAQPC0EAIAIgAyAEIAUgABABIAJBACAEIAUgBiABEAIL"
|
|
787
700
|
};
|
|
788
|
-
var MathLib = class extends
|
|
701
|
+
var MathLib = class extends MultiMath {
|
|
789
702
|
constructor(requested_features) {
|
|
790
703
|
const __requested_features = requested_features || [];
|
|
791
704
|
const features = {
|
|
@@ -1052,13 +965,14 @@ var features = {
|
|
|
1052
965
|
};
|
|
1053
966
|
var checked = false;
|
|
1054
967
|
var checking = null;
|
|
968
|
+
var ctxOpts$1 = { willReadFrequently: true };
|
|
1055
969
|
function check_canvas() {
|
|
1056
970
|
if (typeof document === "undefined" || !document.createElement) return false;
|
|
1057
971
|
try {
|
|
1058
972
|
const canvas = document.createElement("canvas");
|
|
1059
973
|
canvas.width = 2;
|
|
1060
974
|
canvas.height = 1;
|
|
1061
|
-
const ctx = canvas.getContext("2d");
|
|
975
|
+
const ctx = canvas.getContext("2d", ctxOpts$1);
|
|
1062
976
|
let d = ctx.createImageData(2, 1);
|
|
1063
977
|
d.data[0] = 12;
|
|
1064
978
|
d.data[1] = 23;
|
|
@@ -1078,7 +992,7 @@ function check_canvas() {
|
|
|
1078
992
|
function check_offscreen_canvas() {
|
|
1079
993
|
if (typeof OffscreenCanvas === "undefined") return false;
|
|
1080
994
|
try {
|
|
1081
|
-
const ctx = new OffscreenCanvas(2, 1).getContext("2d");
|
|
995
|
+
const ctx = new OffscreenCanvas(2, 1).getContext("2d", ctxOpts$1);
|
|
1082
996
|
let d = ctx.createImageData(2, 1);
|
|
1083
997
|
d.data[0] = 12;
|
|
1084
998
|
d.data[1] = 23;
|
|
@@ -1117,7 +1031,7 @@ function check_bug_canvas_orientation_region_async() {
|
|
|
1117
1031
|
return createImageBitmap(new Blob([bytes], { type: "image/jpeg" })).then((bitmap) => {
|
|
1118
1032
|
const canvas = new OffscreenCanvas(1, 1);
|
|
1119
1033
|
try {
|
|
1120
|
-
const ctx = canvas.getContext("2d");
|
|
1034
|
+
const ctx = canvas.getContext("2d", ctxOpts$1);
|
|
1121
1035
|
ctx.drawImage(bitmap, 1, 1, 1, 1, 0, 0, 1, 1);
|
|
1122
1036
|
return ctx.getImageData(0, 0, 1, 1).data[0] < 240;
|
|
1123
1037
|
} finally {
|
|
@@ -1132,7 +1046,7 @@ function check_bug_canvas_orientation_region_async() {
|
|
|
1132
1046
|
const canvas = document.createElement("canvas");
|
|
1133
1047
|
canvas.width = 1;
|
|
1134
1048
|
canvas.height = 1;
|
|
1135
|
-
const ctx = canvas.getContext("2d");
|
|
1049
|
+
const ctx = canvas.getContext("2d", ctxOpts$1);
|
|
1136
1050
|
ctx.drawImage(image, 1, 1, 1, 1, 0, 0, 1, 1);
|
|
1137
1051
|
resolve(ctx.getImageData(0, 0, 1, 1).data[0] < 240);
|
|
1138
1052
|
} catch (__) {
|
|
@@ -1164,7 +1078,7 @@ function check_bug_image_bitmap_orientation_region_async() {
|
|
|
1164
1078
|
canvas.height = 1;
|
|
1165
1079
|
}
|
|
1166
1080
|
try {
|
|
1167
|
-
const ctx = canvas.getContext("2d");
|
|
1081
|
+
const ctx = canvas.getContext("2d", ctxOpts$1);
|
|
1168
1082
|
ctx.drawImage(bitmap, 0, 0);
|
|
1169
1083
|
return bitmap.width !== 1 || bitmap.height !== 1 || ctx.getImageData(0, 0, 1, 1).data[0] < 240;
|
|
1170
1084
|
} finally {
|
|
@@ -1189,7 +1103,7 @@ function check_cib_resize_async() {
|
|
|
1189
1103
|
canvas.height = SRC_SIZE;
|
|
1190
1104
|
} else if (features.offscreen_canvas || check_offscreen_canvas()) {
|
|
1191
1105
|
canvas = new OffscreenCanvas(SRC_SIZE, SRC_SIZE);
|
|
1192
|
-
canvas.getContext("2d").clearRect(0, 0, SRC_SIZE, SRC_SIZE);
|
|
1106
|
+
canvas.getContext("2d", ctxOpts$1).clearRect(0, 0, SRC_SIZE, SRC_SIZE);
|
|
1193
1107
|
} else return false;
|
|
1194
1108
|
return createImageBitmap(canvas, 0, 0, SRC_SIZE, SRC_SIZE, {
|
|
1195
1109
|
resizeWidth: DST_SIZE,
|
|
@@ -1258,7 +1172,7 @@ function _asyncToGenerator(n) {
|
|
|
1258
1172
|
});
|
|
1259
1173
|
};
|
|
1260
1174
|
}
|
|
1261
|
-
var WORKER_SRC = "/*!\n\npica\nhttps://github.com/nodeca/pica\n\n*/\n(function() {\n var __create = Object.create;\n var __defProp = Object.defineProperty;\n var __getOwnPropDesc = Object.getOwnPropertyDescriptor;\n var __getOwnPropNames = Object.getOwnPropertyNames;\n var __getProtoOf = Object.getPrototypeOf;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);\n var __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {\n key = keys[i];\n if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {\n get: ((k) => from[k]).bind(null, key),\n enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n });\n }\n return to;\n };\n var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", {\n value: mod,\n enumerable: true\n }) : target, mod));\n /*\n object-assign\n (c) Sindre Sorhus\n @license MIT\n */\n var require_object_assign = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n var getOwnPropertySymbols = Object.getOwnPropertySymbols;\n var hasOwnProperty = Object.prototype.hasOwnProperty;\n var propIsEnumerable = Object.prototype.propertyIsEnumerable;\n function toObject(val) {\n if (val === null || val === void 0) throw new TypeError(\"Object.assign cannot be called with null or undefined\");\n return Object(val);\n }\n function shouldUseNative() {\n try {\n if (!Object.assign) return false;\n var test1 = /* @__PURE__ */ new String(\"abc\");\n test1[5] = \"de\";\n if (Object.getOwnPropertyNames(test1)[0] === \"5\") return false;\n var test2 = {};\n for (var i = 0; i < 10; i++) test2[\"_\" + String.fromCharCode(i)] = i;\n if (Object.getOwnPropertyNames(test2).map(function(n) {\n return test2[n];\n }).join(\"\") !== \"0123456789\") return false;\n var test3 = {};\n \"abcdefghijklmnopqrst\".split(\"\").forEach(function(letter) {\n test3[letter] = letter;\n });\n if (Object.keys(Object.assign({}, test3)).join(\"\") !== \"abcdefghijklmnopqrst\") return false;\n return true;\n } catch (err) {\n return false;\n }\n }\n module.exports = shouldUseNative() ? Object.assign : function(target, source) {\n var from;\n var to = toObject(target);\n var symbols;\n for (var s = 1; s < arguments.length; s++) {\n from = Object(arguments[s]);\n for (var key in from) if (hasOwnProperty.call(from, key)) to[key] = from[key];\n if (getOwnPropertySymbols) {\n symbols = getOwnPropertySymbols(from);\n for (var i = 0; i < symbols.length; i++) if (propIsEnumerable.call(from, symbols[i])) to[symbols[i]] = from[symbols[i]];\n }\n }\n return to;\n };\n }));\n var require_base64decode = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n var BASE64_MAP = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n module.exports = function base64decode(str) {\n var input = str.replace(/[\\r\\n=]/g, \"\"), max = input.length;\n var out = new Uint8Array(max * 3 >> 2);\n var bits = 0;\n var ptr = 0;\n for (var idx = 0; idx < max; idx++) {\n if (idx % 4 === 0 && idx) {\n out[ptr++] = bits >> 16 & 255;\n out[ptr++] = bits >> 8 & 255;\n out[ptr++] = bits & 255;\n }\n bits = bits << 6 | BASE64_MAP.indexOf(input.charAt(idx));\n }\n var tailbits = max % 4 * 6;\n if (tailbits === 0) {\n out[ptr++] = bits >> 16 & 255;\n out[ptr++] = bits >> 8 & 255;\n out[ptr++] = bits & 255;\n } else if (tailbits === 18) {\n out[ptr++] = bits >> 10 & 255;\n out[ptr++] = bits >> 2 & 255;\n } else if (tailbits === 12) out[ptr++] = bits >> 4 & 255;\n return out;\n };\n }));\n var require_wa_detect = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n var wa;\n module.exports = function hasWebAssembly() {\n if (typeof wa !== \"undefined\") return wa;\n wa = false;\n if (typeof WebAssembly === \"undefined\") return wa;\n try {\n var bin = new Uint8Array([\n 0,\n 97,\n 115,\n 109,\n 1,\n 0,\n 0,\n 0,\n 1,\n 6,\n 1,\n 96,\n 1,\n 127,\n 1,\n 127,\n 3,\n 2,\n 1,\n 0,\n 5,\n 3,\n 1,\n 0,\n 1,\n 7,\n 8,\n 1,\n 4,\n 116,\n 101,\n 115,\n 116,\n 0,\n 0,\n 10,\n 16,\n 1,\n 14,\n 0,\n 32,\n 0,\n 65,\n 1,\n 54,\n 2,\n 0,\n 32,\n 0,\n 40,\n 2,\n 0,\n 11\n ]);\n var module$4 = new WebAssembly.Module(bin);\n if (new WebAssembly.Instance(module$4, {}).exports.test(4) !== 0) wa = true;\n return wa;\n } catch (__) {}\n return wa;\n };\n }));\n var require_multimath = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n var assign = require_object_assign();\n var base64decode = require_base64decode();\n var hasWebAssembly = require_wa_detect();\n var DEFAULT_OPTIONS = {\n js: true,\n wasm: true\n };\n function MultiMath(options) {\n if (!(this instanceof MultiMath)) return new MultiMath(options);\n var opts = assign({}, DEFAULT_OPTIONS, options || {});\n this.options = opts;\n this.__cache = {};\n this.__init_promise = null;\n this.__modules = opts.modules || {};\n this.__memory = null;\n this.__wasm = {};\n this.__isLE = new Uint32Array(new Uint8Array([\n 1,\n 0,\n 0,\n 0\n ]).buffer)[0] === 1;\n if (!this.options.js && !this.options.wasm) throw new Error(\"mathlib: at least \\\"js\\\" or \\\"wasm\\\" should be enabled\");\n }\n MultiMath.prototype.has_wasm = hasWebAssembly;\n MultiMath.prototype.use = function(module$1) {\n this.__modules[module$1.name] = module$1;\n if (this.options.wasm && this.has_wasm() && module$1.wasm_fn) this[module$1.name] = module$1.wasm_fn;\n else this[module$1.name] = module$1.fn;\n return this;\n };\n MultiMath.prototype.init = function() {\n if (this.__init_promise) return this.__init_promise;\n if (!this.options.js && this.options.wasm && !this.has_wasm()) return Promise.reject(/* @__PURE__ */ new Error(\"mathlib: only \\\"wasm\\\" was enabled, but it's not supported\"));\n var self = this;\n this.__init_promise = Promise.all(Object.keys(self.__modules).map(function(name) {\n var module$2 = self.__modules[name];\n if (!self.options.wasm || !self.has_wasm() || !module$2.wasm_fn) return null;\n if (self.__wasm[name]) return null;\n return WebAssembly.compile(self.__base64decode(module$2.wasm_src)).then(function(m) {\n self.__wasm[name] = m;\n });\n })).then(function() {\n return self;\n });\n return this.__init_promise;\n };\n MultiMath.prototype.__base64decode = base64decode;\n MultiMath.prototype.__reallocate = function mem_grow_to(bytes) {\n if (!this.__memory) {\n this.__memory = new WebAssembly.Memory({ initial: Math.ceil(bytes / (64 * 1024)) });\n return this.__memory;\n }\n var mem_size = this.__memory.buffer.byteLength;\n if (mem_size < bytes) this.__memory.grow(Math.ceil((bytes - mem_size) / (64 * 1024)));\n return this.__memory;\n };\n MultiMath.prototype.__instance = function instance(name, memsize, env_extra) {\n if (memsize) this.__reallocate(memsize);\n if (!this.__wasm[name]) {\n var module$3 = this.__modules[name];\n this.__wasm[name] = new WebAssembly.Module(this.__base64decode(module$3.wasm_src));\n }\n if (!this.__cache[name]) {\n var env_base = {\n memoryBase: 0,\n memory: this.__memory,\n tableBase: 0,\n table: new WebAssembly.Table({\n initial: 0,\n element: \"anyfunc\"\n })\n };\n this.__cache[name] = new WebAssembly.Instance(this.__wasm[name], { env: assign(env_base, env_extra || {}) });\n }\n return this.__cache[name];\n };\n MultiMath.prototype.__align = function align(number, base) {\n base = base || 8;\n var reminder = number % base;\n return number + (reminder ? base - reminder : 0);\n };\n module.exports = MultiMath;\n }));\n var require_mono16 = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n var a0, a1, a2, a3, b1, b2, left_corner, right_corner;\n function gaussCoef(sigma) {\n if (sigma < .5) sigma = .5;\n var a = Math.exp(.726 * .726) / sigma, g1 = Math.exp(-a), g2 = Math.exp(-2 * a), k = (1 - g1) * (1 - g1) / (1 + 2 * a * g1 - g2);\n a0 = k;\n a1 = k * (a - 1) * g1;\n a2 = k * (a + 1) * g1;\n a3 = -k * g2;\n b1 = 2 * g1;\n b2 = -g2;\n left_corner = (a0 + a1) / (1 - b1 - b2);\n right_corner = (a2 + a3) / (1 - b1 - b2);\n return new Float32Array([\n a0,\n a1,\n a2,\n a3,\n b1,\n b2,\n left_corner,\n right_corner\n ]);\n }\n function convolveMono16(src, out, line, coeff, width, height) {\n var prev_src, curr_src, curr_out, prev_out, prev_prev_out;\n var src_index, out_index, line_index;\n var i, j;\n var coeff_a0, coeff_a1, coeff_b1, coeff_b2;\n for (i = 0; i < height; i++) {\n src_index = i * width;\n out_index = i;\n line_index = 0;\n prev_src = src[src_index];\n prev_prev_out = prev_src * coeff[6];\n prev_out = prev_prev_out;\n coeff_a0 = coeff[0];\n coeff_a1 = coeff[1];\n coeff_b1 = coeff[4];\n coeff_b2 = coeff[5];\n for (j = 0; j < width; j++) {\n curr_src = src[src_index];\n curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;\n prev_prev_out = prev_out;\n prev_out = curr_out;\n prev_src = curr_src;\n line[line_index] = prev_out;\n line_index++;\n src_index++;\n }\n src_index--;\n line_index--;\n out_index += height * (width - 1);\n prev_src = src[src_index];\n prev_prev_out = prev_src * coeff[7];\n prev_out = prev_prev_out;\n curr_src = prev_src;\n coeff_a0 = coeff[2];\n coeff_a1 = coeff[3];\n for (j = width - 1; j >= 0; j--) {\n curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;\n prev_prev_out = prev_out;\n prev_out = curr_out;\n prev_src = curr_src;\n curr_src = src[src_index];\n out[out_index] = line[line_index] + prev_out;\n src_index--;\n line_index--;\n out_index -= height;\n }\n }\n }\n function blurMono16(src, width, height, radius) {\n if (!radius) return;\n var out = new Uint16Array(src.length), tmp_line = new Float32Array(Math.max(width, height));\n var coeff = gaussCoef(radius);\n convolveMono16(src, out, tmp_line, coeff, width, height, radius);\n convolveMono16(out, src, tmp_line, coeff, height, width, radius);\n }\n module.exports = blurMono16;\n }));\n var import_multimath = /* @__PURE__ */ __toESM(require_multimath());\n var import_mono16 = /* @__PURE__ */ __toESM(require_mono16());\n function hsv_v16(img, width, height) {\n const size = width * height;\n const out = new Uint16Array(size);\n let r, g, b, max;\n for (let i = 0; i < size; i++) {\n r = img[4 * i];\n g = img[4 * i + 1];\n b = img[4 * i + 2];\n max = r >= g && r >= b ? r : g >= b && g >= r ? g : b;\n out[i] = max << 8;\n }\n return out;\n }\n function unsharp$1(img, width, height, amount, radius, threshold) {\n let v1, v2, vmul;\n let diff, iTimes4;\n if (amount === 0 || radius < .5) return;\n if (radius > 2) radius = 2;\n const brightness = hsv_v16(img, width, height);\n const blured = new Uint16Array(brightness);\n (0, import_mono16.default)(blured, width, height, radius);\n const amountFp = amount / 100 * 4096 + .5 | 0;\n const thresholdFp = threshold << 8;\n const size = width * height;\n for (let i = 0; i < size; i++) {\n v1 = brightness[i];\n diff = v1 - blured[i];\n if (Math.abs(diff) >= thresholdFp) {\n v2 = v1 + (amountFp * diff + 2048 >> 12);\n v2 = v2 > 65280 ? 65280 : v2;\n v2 = v2 < 0 ? 0 : v2;\n v1 = v1 !== 0 ? v1 : 1;\n vmul = (v2 << 12) / v1 | 0;\n iTimes4 = i * 4;\n img[iTimes4] = img[iTimes4] * vmul + 2048 >> 12;\n img[iTimes4 + 1] = img[iTimes4 + 1] * vmul + 2048 >> 12;\n img[iTimes4 + 2] = img[iTimes4 + 2] * vmul + 2048 >> 12;\n }\n }\n }\n function unsharp(img, width, height, amount, radius, threshold) {\n if (amount === 0 || radius < .5) return;\n if (radius > 2) radius = 2;\n const pixels = width * height;\n const img_bytes_cnt = pixels * 4;\n const hsv_bytes_cnt = pixels * 2;\n const blur_bytes_cnt = pixels * 2;\n const blur_line_byte_cnt = Math.max(width, height) * 4;\n const blur_coeffs_byte_cnt = 32;\n const img_offset = 0;\n const hsv_offset = img_bytes_cnt;\n const blur_offset = hsv_offset + hsv_bytes_cnt;\n const blur_tmp_offset = blur_offset + blur_bytes_cnt;\n const blur_line_offset = blur_tmp_offset + blur_bytes_cnt;\n const blur_coeffs_offset = blur_line_offset + blur_line_byte_cnt;\n const instance = this.__instance(\"unsharp_mask\", img_bytes_cnt + hsv_bytes_cnt + blur_bytes_cnt * 2 + blur_line_byte_cnt + blur_coeffs_byte_cnt, { exp: Math.exp });\n const img32 = new Uint32Array(img.buffer);\n new Uint32Array(this.__memory.buffer).set(img32);\n let fn = instance.exports.hsv_v16 || instance.exports._hsv_v16;\n if (!fn) throw new Error(\"WASM hsv_v16 function is not available\");\n fn(img_offset, hsv_offset, width, height);\n fn = instance.exports.blurMono16 || instance.exports._blurMono16;\n if (!fn) throw new Error(\"WASM blurMono16 function is not available\");\n fn(hsv_offset, blur_offset, blur_tmp_offset, blur_line_offset, blur_coeffs_offset, width, height, radius);\n fn = instance.exports.unsharp || instance.exports._unsharp;\n if (!fn) throw new Error(\"WASM unsharp function is not available\");\n fn(img_offset, img_offset, hsv_offset, blur_offset, width, height, amount, threshold);\n img32.set(new Uint32Array(this.__memory.buffer, 0, pixels));\n }\n var mm_unsharp_mask_default = {\n name: \"unsharp_mask\",\n fn: unsharp$1,\n wasm_fn: unsharp,\n wasm_src: \"AGFzbQEAAAAADAZkeWxpbmsAAAAAAAE0B2AAAGAEf39/fwBgBn9/f39/fwBgCH9/f39/f39/AGAIf39/f39/f30AYAJ9fwBgAXwBfAIZAgNlbnYDZXhwAAYDZW52Bm1lbW9yeQIAAAMHBgAFAgQBAwYGAX8AQQALB4oBCBFfX3dhc21fY2FsbF9jdG9ycwABFl9fYnVpbGRfZ2F1c3NpYW5fY29lZnMAAg5fX2dhdXNzMTZfbGluZQADCmJsdXJNb25vMTYABAdoc3ZfdjE2AAUHdW5zaGFycAAGDF9fZHNvX2hhbmRsZQMAGF9fd2FzbV9hcHBseV9kYXRhX3JlbG9jcwABCsUMBgMAAQvWAQEHfCABRNuGukOCGvs/IAC7oyICRAAAAAAAAADAohAAIgW2jDgCFCABIAKaEAAiAyADoCIGtjgCECABRAAAAAAAAPA/IAOhIgQgBKIgAyACIAKgokQAAAAAAADwP6AgBaGjIgS2OAIAIAEgBSAEmqIiB7Y4AgwgASADIAJEAAAAAAAA8D+gIASioiIItjgCCCABIAMgAkQAAAAAAADwv6AgBKKiIgK2OAIEIAEgByAIoCAFRAAAAAAAAPA/IAahoCIDo7Y4AhwgASAEIAKgIAOjtjgCGAuGBQMGfwl8An0gAyoCDCEVIAMqAgghFiADKgIUuyERIAMqAhC7IRACQCAEQQFrIghBAEgiCQRAIAIhByAAIQYM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gCaAgCqO2OAIYIAYEQANAIAAgBSAIbEEBdGogAiAIQQF0aiADIAQgBSAGEAMgCEEBaiIIIAZHDQALCyAFRQ0AQQAhCANAIAIgBiAIbEEBdGogASAIQQF0aiADIAQgBiAFEAMgCEEBaiIIIAVHDQALCwtxAQN/IAIgA2wiBQRAA0AgASAAKAIAIgRBEHZB/wFxIgIgAiAEQQh2Qf8BcSIDIAMgBEH/AXEiBEkbIAIgA0sbIgYgBiAEIAIgBEsbIAMgBEsbQQh0OwEAIAFBAmohASAAQQRqIQAgBUEBayIFDQALCwuZAgIDfwF8IAQgBWwhBAJ/IAazQwAAgEWUQwAAyEKVu0QAAAAAAADgP6AiC5lEAAAAAAAA4EFjBEAgC6oMAQtBgICAgHgLIQUgBARAIAdBCHQhCUEAIQYDQCAJIAIgBkEBdCIHai8BACIBIAMgB2ovAQBrIgcgB0EfdSIIaiAIc00EQCAAIAZBAnQiCGoiCiAFIAdsQYAQakEMdSABaiIHQYD+AyAHQYD+A0gbIgdBACAHQQBKG0EMdCABQQEgARtuIgEgCi0AAGxBgBBqQQx2OgAAIAAgCEEBcmoiByABIActAABsQYAQakEMdjoAACAAIAhBAnJqIgcgASAHLQAAbEGAEGpBDHY6AAALIAZBAWoiBiAERw0ACwsL\"\n };\n var resize_filter_info_default = { filter: {\n box: {\n win: .5,\n fn(x) {\n if (x < 0) x = -x;\n return x < .5 ? 1 : 0;\n }\n },\n hamming: {\n win: 1,\n fn(x) {\n if (x < 0) x = -x;\n if (x >= 1) return 0;\n if (x < 1.1920929e-7) return 1;\n const xpi = x * Math.PI;\n return Math.sin(xpi) / xpi * (.54 + .46 * Math.cos(xpi / 1));\n }\n },\n lanczos2: {\n win: 2,\n fn(x) {\n if (x < 0) x = -x;\n if (x >= 2) return 0;\n if (x < 1.1920929e-7) return 1;\n const xpi = x * Math.PI;\n return Math.sin(xpi) / xpi * Math.sin(xpi / 2) / (xpi / 2);\n }\n },\n lanczos3: {\n win: 3,\n fn(x) {\n if (x < 0) x = -x;\n if (x >= 3) return 0;\n if (x < 1.1920929e-7) return 1;\n const xpi = x * Math.PI;\n return Math.sin(xpi) / xpi * Math.sin(xpi / 3) / (xpi / 3);\n }\n },\n mks2013: {\n win: 2.5,\n fn(x) {\n if (x < 0) x = -x;\n if (x >= 2.5) return 0;\n if (x >= 1.5) return -.125 * (x - 2.5) * (x - 2.5);\n if (x >= .5) return .25 * (4 * x * x - 11 * x + 7);\n return 1.0625 - 1.75 * x * x;\n }\n }\n } };\n var FIXED_FRAC_BITS = 14;\n function toFixedPoint(num) {\n return Math.round(num * ((1 << FIXED_FRAC_BITS) - 1));\n }\n function resizeFilterGen(filter, srcSize, destSize, scale, offset) {\n const filterFunction = resize_filter_info_default.filter[filter].fn;\n const scaleInverted = 1 / scale;\n const scaleClamped = Math.min(1, scale);\n const srcWindow = resize_filter_info_default.filter[filter].win / scaleClamped;\n let destPixel, srcPixel, srcFirst, srcLast, filterElementSize, floatFilter, fxpFilter, total, pxl, idx, floatVal, filterTotal, filterVal;\n let leftNotEmpty, rightNotEmpty, filterShift, filterSize;\n const maxFilterElementSize = Math.floor((srcWindow + 1) * 2);\n const packedFilter = new Int16Array((maxFilterElementSize + 2) * destSize);\n let packedFilterPtr = 0;\n const slowCopy = !packedFilter.subarray || !packedFilter.set;\n for (destPixel = 0; destPixel < destSize; destPixel++) {\n srcPixel = (destPixel + .5) * scaleInverted + offset;\n srcFirst = Math.max(0, Math.floor(srcPixel - srcWindow));\n srcLast = Math.min(srcSize - 1, Math.ceil(srcPixel + srcWindow));\n filterElementSize = srcLast - srcFirst + 1;\n floatFilter = new Float32Array(filterElementSize);\n fxpFilter = new Int16Array(filterElementSize);\n total = 0;\n for (pxl = srcFirst, idx = 0; pxl <= srcLast; pxl++, idx++) {\n floatVal = filterFunction((pxl + .5 - srcPixel) * scaleClamped);\n total += floatVal;\n floatFilter[idx] = floatVal;\n }\n filterTotal = 0;\n for (idx = 0; idx < floatFilter.length; idx++) {\n filterVal = floatFilter[idx] / total;\n filterTotal += filterVal;\n fxpFilter[idx] = toFixedPoint(filterVal);\n }\n fxpFilter[destSize >> 1] += toFixedPoint(1 - filterTotal);\n leftNotEmpty = 0;\n while (leftNotEmpty < fxpFilter.length && fxpFilter[leftNotEmpty] === 0) leftNotEmpty++;\n if (leftNotEmpty < fxpFilter.length) {\n rightNotEmpty = fxpFilter.length - 1;\n while (rightNotEmpty > 0 && fxpFilter[rightNotEmpty] === 0) rightNotEmpty--;\n filterShift = srcFirst + leftNotEmpty;\n filterSize = rightNotEmpty - leftNotEmpty + 1;\n packedFilter[packedFilterPtr++] = filterShift;\n packedFilter[packedFilterPtr++] = filterSize;\n if (!slowCopy) {\n packedFilter.set(fxpFilter.subarray(leftNotEmpty, rightNotEmpty + 1), packedFilterPtr);\n packedFilterPtr += filterSize;\n } else for (idx = leftNotEmpty; idx <= rightNotEmpty; idx++) packedFilter[packedFilterPtr++] = fxpFilter[idx];\n } else {\n packedFilter[packedFilterPtr++] = 0;\n packedFilter[packedFilterPtr++] = 0;\n }\n }\n return packedFilter;\n }\n function clampTo8(i) {\n return i < 0 ? 0 : i > 255 ? 255 : i;\n }\n function clampNegative(i) {\n return i >= 0 ? i : 0;\n }\n function convolveHor(src, dest, srcW, srcH, destW, filters) {\n let r, g, b, a;\n let filterPtr, filterShift, filterSize;\n let srcPtr, srcY, destX, filterVal;\n let srcOffset = 0, destOffset = 0;\n for (srcY = 0; srcY < srcH; srcY++) {\n filterPtr = 0;\n for (destX = 0; destX < destW; destX++) {\n filterShift = filters[filterPtr++];\n filterSize = filters[filterPtr++];\n srcPtr = srcOffset + filterShift * 4 | 0;\n r = g = b = a = 0;\n for (; filterSize > 0; filterSize--) {\n filterVal = filters[filterPtr++];\n a = a + filterVal * src[srcPtr + 3] | 0;\n b = b + filterVal * src[srcPtr + 2] | 0;\n g = g + filterVal * src[srcPtr + 1] | 0;\n r = r + filterVal * src[srcPtr] | 0;\n srcPtr = srcPtr + 4 | 0;\n }\n dest[destOffset + 3] = clampNegative(a >> 7);\n dest[destOffset + 2] = clampNegative(b >> 7);\n dest[destOffset + 1] = clampNegative(g >> 7);\n dest[destOffset] = clampNegative(r >> 7);\n destOffset = destOffset + srcH * 4 | 0;\n }\n destOffset = (srcY + 1) * 4 | 0;\n srcOffset = (srcY + 1) * srcW * 4 | 0;\n }\n }\n function convolveVert(src, dest, srcW, srcH, destW, filters) {\n let r, g, b, a;\n let filterPtr, filterShift, filterSize;\n let srcPtr, srcY, destX, filterVal;\n let srcOffset = 0, destOffset = 0;\n for (srcY = 0; srcY < srcH; srcY++) {\n filterPtr = 0;\n for (destX = 0; destX < destW; destX++) {\n filterShift = filters[filterPtr++];\n filterSize = filters[filterPtr++];\n srcPtr = srcOffset + filterShift * 4 | 0;\n r = g = b = a = 0;\n for (; filterSize > 0; filterSize--) {\n filterVal = filters[filterPtr++];\n a = a + filterVal * src[srcPtr + 3] | 0;\n b = b + filterVal * src[srcPtr + 2] | 0;\n g = g + filterVal * src[srcPtr + 1] | 0;\n r = r + filterVal * src[srcPtr] | 0;\n srcPtr = srcPtr + 4 | 0;\n }\n r >>= 7;\n g >>= 7;\n b >>= 7;\n a >>= 7;\n dest[destOffset + 3] = clampTo8(a + 8192 >> 14);\n dest[destOffset + 2] = clampTo8(b + 8192 >> 14);\n dest[destOffset + 1] = clampTo8(g + 8192 >> 14);\n dest[destOffset] = clampTo8(r + 8192 >> 14);\n destOffset = destOffset + srcH * 4 | 0;\n }\n destOffset = (srcY + 1) * 4 | 0;\n srcOffset = (srcY + 1) * srcW * 4 | 0;\n }\n }\n function convolveHorWithPre(src, dest, srcW, srcH, destW, filters) {\n let r, g, b, a, alpha;\n let filterPtr, filterShift, filterSize;\n let srcPtr, srcY, destX, filterVal;\n let srcOffset = 0, destOffset = 0;\n for (srcY = 0; srcY < srcH; srcY++) {\n filterPtr = 0;\n for (destX = 0; destX < destW; destX++) {\n filterShift = filters[filterPtr++];\n filterSize = filters[filterPtr++];\n srcPtr = srcOffset + filterShift * 4 | 0;\n r = g = b = a = 0;\n for (; filterSize > 0; filterSize--) {\n filterVal = filters[filterPtr++];\n alpha = src[srcPtr + 3];\n a = a + filterVal * alpha | 0;\n b = b + filterVal * src[srcPtr + 2] * alpha | 0;\n g = g + filterVal * src[srcPtr + 1] * alpha | 0;\n r = r + filterVal * src[srcPtr] * alpha | 0;\n srcPtr = srcPtr + 4 | 0;\n }\n b = b / 255 | 0;\n g = g / 255 | 0;\n r = r / 255 | 0;\n dest[destOffset + 3] = clampNegative(a >> 7);\n dest[destOffset + 2] = clampNegative(b >> 7);\n dest[destOffset + 1] = clampNegative(g >> 7);\n dest[destOffset] = clampNegative(r >> 7);\n destOffset = destOffset + srcH * 4 | 0;\n }\n destOffset = (srcY + 1) * 4 | 0;\n srcOffset = (srcY + 1) * srcW * 4 | 0;\n }\n }\n function convolveVertWithPre(src, dest, srcW, srcH, destW, filters) {\n let r, g, b, a;\n let filterPtr, filterShift, filterSize;\n let srcPtr, srcY, destX, filterVal;\n let srcOffset = 0, destOffset = 0;\n for (srcY = 0; srcY < srcH; srcY++) {\n filterPtr = 0;\n for (destX = 0; destX < destW; destX++) {\n filterShift = filters[filterPtr++];\n filterSize = filters[filterPtr++];\n srcPtr = srcOffset + filterShift * 4 | 0;\n r = g = b = a = 0;\n for (; filterSize > 0; filterSize--) {\n filterVal = filters[filterPtr++];\n a = a + filterVal * src[srcPtr + 3] | 0;\n b = b + filterVal * src[srcPtr + 2] | 0;\n g = g + filterVal * src[srcPtr + 1] | 0;\n r = r + filterVal * src[srcPtr] | 0;\n srcPtr = srcPtr + 4 | 0;\n }\n r >>= 7;\n g >>= 7;\n b >>= 7;\n a >>= 7;\n a = clampTo8(a + 8192 >> 14);\n if (a > 0) {\n r = r * 255 / a | 0;\n g = g * 255 / a | 0;\n b = b * 255 / a | 0;\n }\n dest[destOffset + 3] = a;\n dest[destOffset + 2] = clampTo8(b + 8192 >> 14);\n dest[destOffset + 1] = clampTo8(g + 8192 >> 14);\n dest[destOffset] = clampTo8(r + 8192 >> 14);\n destOffset = destOffset + srcH * 4 | 0;\n }\n destOffset = (srcY + 1) * 4 | 0;\n srcOffset = (srcY + 1) * srcW * 4 | 0;\n }\n }\n function hasAlpha$1(src, width, height) {\n let ptr = 3;\n const len = width * height * 4 | 0;\n while (ptr < len) {\n if (src[ptr] !== 255) return true;\n ptr = ptr + 4 | 0;\n }\n return false;\n }\n function resetAlpha$1(dst, width, height) {\n let ptr = 3;\n const len = width * height * 4 | 0;\n while (ptr < len) {\n dst[ptr] = 255;\n ptr = ptr + 4 | 0;\n }\n }\n function resize$1(options) {\n const src = options.src;\n const srcW = options.width;\n const srcH = options.height;\n const destW = options.toWidth;\n const destH = options.toHeight;\n const scaleX = options.scaleX || options.toWidth / options.width;\n const scaleY = options.scaleY || options.toHeight / options.height;\n const offsetX = options.offsetX || 0;\n const offsetY = options.offsetY || 0;\n const dest = options.dest || new Uint8Array(destW * destH * 4);\n const filter = typeof options.filter === \"undefined\" ? \"mks2013\" : options.filter;\n const filtersX = resizeFilterGen(filter, srcW, destW, scaleX, offsetX), filtersY = resizeFilterGen(filter, srcH, destH, scaleY, offsetY);\n const tmp = new Uint16Array(destW * srcH * 4);\n if (hasAlpha$1(src, srcW, srcH)) {\n convolveHorWithPre(src, tmp, srcW, srcH, destW, filtersX);\n convolveVertWithPre(tmp, dest, srcH, destW, destH, filtersY);\n } else {\n convolveHor(src, tmp, srcW, srcH, destW, filtersX);\n convolveVert(tmp, dest, srcH, destW, destH, filtersY);\n resetAlpha$1(dest, destW, destH);\n }\n return dest;\n }\n function hasAlpha(src, width, height) {\n let ptr = 3;\n const len = width * height * 4 | 0;\n while (ptr < len) {\n if (src[ptr] !== 255) return true;\n ptr = ptr + 4 | 0;\n }\n return false;\n }\n function resetAlpha(dst, width, height) {\n let ptr = 3;\n const len = width * height * 4 | 0;\n while (ptr < len) {\n dst[ptr] = 255;\n ptr = ptr + 4 | 0;\n }\n }\n function asUint8Array(src) {\n return new Uint8Array(src.buffer, 0, src.byteLength);\n }\n var IS_LE = true;\n try {\n IS_LE = new Uint32Array(new Uint8Array([\n 1,\n 0,\n 0,\n 0\n ]).buffer)[0] === 1;\n } catch (__) {}\n function copyInt16asLE(src, target, target_offset) {\n if (IS_LE) {\n target.set(asUint8Array(src), target_offset);\n return;\n }\n for (let ptr = target_offset, i = 0; i < src.length; i++) {\n const data = src[i];\n target[ptr++] = data & 255;\n target[ptr++] = data >> 8 & 255;\n }\n }\n function resize_wasm(options) {\n const src = options.src;\n const srcW = options.width;\n const srcH = options.height;\n const destW = options.toWidth;\n const destH = options.toHeight;\n const scaleX = options.scaleX || options.toWidth / options.width;\n const scaleY = options.scaleY || options.toHeight / options.height;\n const offsetX = options.offsetX || 0;\n const offsetY = options.offsetY || 0;\n const dest = options.dest || new Uint8Array(destW * destH * 4);\n const filter = typeof options.filter === \"undefined\" ? \"mks2013\" : options.filter;\n const filtersX = resizeFilterGen(filter, srcW, destW, scaleX, offsetX), filtersY = resizeFilterGen(filter, srcH, destH, scaleY, offsetY);\n const src_offset = 0;\n const src_size = Math.max(src.byteLength, dest.byteLength);\n const tmp_offset = this.__align(src_offset + src_size);\n const tmp_size = srcH * destW * 4 * 2;\n const filtersX_offset = this.__align(tmp_offset + tmp_size);\n const filtersY_offset = this.__align(filtersX_offset + filtersX.byteLength);\n const alloc_bytes = filtersY_offset + filtersY.byteLength;\n const instance = this.__instance(\"resize\", alloc_bytes);\n const mem = new Uint8Array(this.__memory.buffer);\n const mem32 = new Uint32Array(this.__memory.buffer);\n const src32 = new Uint32Array(src.buffer);\n mem32.set(src32);\n copyInt16asLE(filtersX, mem, filtersX_offset);\n copyInt16asLE(filtersY, mem, filtersY_offset);\n const fn = instance.exports.convolveHV || instance.exports._convolveHV;\n if (!fn) throw new Error(\"WASM resize function is not available\");\n if (hasAlpha(src, srcW, srcH)) fn(filtersX_offset, filtersY_offset, tmp_offset, srcW, srcH, destW, destH, 1);\n else {\n fn(filtersX_offset, filtersY_offset, tmp_offset, srcW, srcH, destW, destH, 0);\n resetAlpha(dest, destW, destH);\n }\n new Uint32Array(dest.buffer).set(new Uint32Array(this.__memory.buffer, 0, destH * destW));\n return dest;\n }\n var mm_resize_default = {\n name: \"resize\",\n fn: resize$1,\n wasm_fn: resize_wasm,\n wasm_src: \"AGFzbQEAAAAADAZkeWxpbmsAAAAAAAEYA2AGf39/f39/AGAAAGAIf39/f39/f38AAg8BA2VudgZtZW1vcnkCAAADBwYBAAAAAAIGBgF/AEEACweUAQgRX193YXNtX2NhbGxfY3RvcnMAAAtjb252b2x2ZUhvcgABDGNvbnZvbHZlVmVydAACEmNvbnZvbHZlSG9yV2l0aFByZQADE2NvbnZvbHZlVmVydFdpdGhQcmUABApjb252b2x2ZUhWAAUMX19kc29faGFuZGxlAwAYX193YXNtX2FwcGx5X2RhdGFfcmVsb2NzAAAKyA4GAwABC4wDARB/AkAgA0UNACAERQ0AIANBAnQhFQNAQQAhE0EAIQsDQCALQQJqIQcCfyALQQF0IAVqIgYuAQIiC0UEQEEAIQhBACEGQQAhCUEAIQogBwwBCyASIAYuAQBqIQhBACEJQQAhCiALIRRBACEOIAchBkEAIQ8DQCAFIAZBAXRqLgEAIhAgACAIQQJ0aigCACIRQRh2bCAPaiEPIBFB/wFxIBBsIAlqIQkgEUEQdkH/AXEgEGwgDmohDiARQQh2Qf8BcSAQbCAKaiEKIAhBAWohCCAGQQFqIQYgFEEBayIUDQALIAlBB3UhCCAKQQd1IQYgDkEHdSEJIA9BB3UhCiAHIAtqCyELIAEgDEEBdCIHaiAIQQAgCEEAShs7AQAgASAHQQJyaiAGQQAgBkEAShs7AQAgASAHQQRyaiAJQQAgCUEAShs7AQAgASAHQQZyaiAKQQAgCkEAShs7AQAgDCAVaiEMIBNBAWoiEyAERw0ACyANQQFqIg0gAmwhEiANQQJ0IQwgAyANRw0ACwsL2gMBD38CQCADRQ0AIARFDQAgAkECdCEUA0AgCyEMQQAhE0EAIQIDQCACQQJqIQYCfyACQQF0IAVqIgcuAQIiAk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AMgC0cNAAsLC4IEAQ9/AkAgA0UNACAERQ0AIAJBAnQhFANAIAshDEEAIRJBACEHA0AgB0ECaiEKAn8gB0EBdCAFaiICLgECIhNFBEBBACEIQQAhCUEAIQYgCiEHQQAMAQsgAi4BAEECdCARaiEJQQAhByATIQJBACENIAohBkEAIQ5BACEPA0AgBSAGQQF0ai4BACIIIAAgCUEBdCIQai8BAGwgB2ohByAAIBBBBnJqLwEAIAhsIA5qIQ4gACAQQQRyai8BACAIbCAPaiEPIAAgEEECcmovAQAgCGwgDWohDSAJQQRqIQkgBkEBaiEGIAJBAWsiAg0ACyAHQQd1IQggDUEHdSEJIA9BB3UhBiAKIBNqIQcgDkEHdQtBgEBrQQ51IgJB/wEgAkH/AUgbIgJBACACQQBKGyIKQf8BcQRAIAlB/wFsIAJtIQkgCEH/AWwgAm0hCCAGQf8BbCACbSEGCyABIAxBAnRqIAlBgEBrQQ51IgJB/wEgAkH/AUgbIgJBACACQQBKG0EIdEGA/gNxIAZBgEBrQQ51IgJB/wEgAkH/AUgbIgJBACACQQBKG0EQdEGAgPwHcSAKQRh0ciAIQYBAa0EOdSICQf8BIAJB/wFIGyICQQAgAkEAShtycjYCACADIAxqIQwgEkEBaiISIARHDQALIBQgC0EBaiILbCERIAMgC0cNAAsLC0AAIAcEQEEAIAIgAyAEIAUgABADIAJBACAEIAUgBiABEAQPC0EAIAIgAyAEIAUgABABIAJBACAEIAUgBiABEAIL\"\n };\n var MathLib = class extends import_multimath.default {\n constructor(requested_features) {\n const __requested_features = requested_features || [];\n const features = {\n js: __requested_features.indexOf(\"js\") >= 0,\n wasm: __requested_features.indexOf(\"wasm\") >= 0\n };\n super(features);\n this.features = {\n js: features.js,\n wasm: features.wasm && this.has_wasm()\n };\n this.use(mm_unsharp_mask_default);\n this.use(mm_resize_default);\n }\n resizeAndUnsharp(options) {\n const result = this.resize(options);\n if (options.unsharpAmount) this.unsharp_mask(result, options.toWidth, options.toHeight, options.unsharpAmount, options.unsharpRadius, options.unsharpThreshold);\n return result;\n }\n };\n var ORIENTED_JPEG_BASE64 = \"/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/4AAQskZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/wAALCAACAAMBAREA/8QAFAABAAAAAAAAAAAAAAAAAAAACf/EABsQAAMBAQADAAAAAAAAAAAAAAECAwQFABEx/9oACAEBAAA/AC06fW6va0ps7PT179E88MiV02arrCEkjGQZiSEnKc5ovxURVHoADz//2Q==\";\n var features = {\n canvas: false,\n offscreen_canvas: false,\n may_be_worker: false,\n create_image_bitmap: false,\n safari_put_image_data_fix: false,\n bug_canvas_orientation_region: true,\n bug_image_bitmap_orientation_region: true,\n cib_resize: false\n };\n var checked = false;\n var checking = null;\n function check_canvas() {\n if (typeof document === \"undefined\" || !document.createElement) return false;\n try {\n const canvas = document.createElement(\"canvas\");\n canvas.width = 2;\n canvas.height = 1;\n const ctx = canvas.getContext(\"2d\");\n let d = ctx.createImageData(2, 1);\n d.data[0] = 12;\n d.data[1] = 23;\n d.data[2] = 34;\n d.data[3] = 255;\n d.data[4] = 45;\n d.data[5] = 56;\n d.data[6] = 67;\n d.data[7] = 255;\n ctx.putImageData(d, 0, 0);\n d = ctx.getImageData(0, 0, 2, 1);\n return d.data[0] === 12 && d.data[1] === 23 && d.data[2] === 34 && d.data[3] === 255 && d.data[4] === 45 && d.data[5] === 56 && d.data[6] === 67 && d.data[7] === 255;\n } catch (__) {\n return false;\n }\n }\n function check_offscreen_canvas() {\n if (typeof OffscreenCanvas === \"undefined\") return false;\n try {\n const ctx = new OffscreenCanvas(2, 1).getContext(\"2d\");\n let d = ctx.createImageData(2, 1);\n d.data[0] = 12;\n d.data[1] = 23;\n d.data[2] = 34;\n d.data[3] = 255;\n d.data[4] = 45;\n d.data[5] = 56;\n d.data[6] = 67;\n d.data[7] = 255;\n ctx.putImageData(d, 0, 0);\n d = ctx.getImageData(0, 0, 2, 1);\n return d.data[0] === 12 && d.data[1] === 23 && d.data[2] === 34 && d.data[3] === 255 && d.data[4] === 45 && d.data[5] === 56 && d.data[6] === 67 && d.data[7] === 255;\n } catch (__) {\n return false;\n }\n }\n function check_create_image_bitmap() {\n return typeof createImageBitmap !== \"undefined\";\n }\n function check_may_be_worker() {\n return typeof Worker !== \"undefined\" && typeof URL !== \"undefined\" && !!URL.createObjectURL;\n }\n function check_safari_put_image_data_fix() {\n try {\n return !!(typeof navigator !== \"undefined\" && navigator.userAgent && navigator.userAgent.indexOf(\"Safari\") >= 0 && navigator.userAgent.indexOf(\"Chrome\") < 0);\n } catch (__) {\n return false;\n }\n }\n function check_bug_canvas_orientation_region_async() {\n return Promise.resolve().then(() => {\n if (check_offscreen_canvas() && check_create_image_bitmap() && typeof Blob !== \"undefined\" && typeof atob !== \"undefined\") {\n const binary = atob(ORIENTED_JPEG_BASE64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n return createImageBitmap(new Blob([bytes], { type: \"image/jpeg\" })).then((bitmap) => {\n const canvas = new OffscreenCanvas(1, 1);\n try {\n const ctx = canvas.getContext(\"2d\");\n ctx.drawImage(bitmap, 1, 1, 1, 1, 0, 0, 1, 1);\n return ctx.getImageData(0, 0, 1, 1).data[0] < 240;\n } finally {\n bitmap.close();\n }\n });\n }\n if (check_canvas() && typeof Image !== \"undefined\") return new Promise((resolve) => {\n const image = new Image();\n image.onload = () => {\n try {\n const canvas = document.createElement(\"canvas\");\n canvas.width = 1;\n canvas.height = 1;\n const ctx = canvas.getContext(\"2d\");\n ctx.drawImage(image, 1, 1, 1, 1, 0, 0, 1, 1);\n resolve(ctx.getImageData(0, 0, 1, 1).data[0] < 240);\n } catch (__) {\n resolve(true);\n }\n };\n image.onerror = () => resolve(true);\n image.src = `data:image/jpeg;base64,${ORIENTED_JPEG_BASE64}`;\n });\n return true;\n }).catch(() => true);\n }\n function check_bug_image_bitmap_orientation_region_async() {\n return Promise.resolve().then(() => {\n if (!features.create_image_bitmap && !check_create_image_bitmap()) return true;\n if (typeof Blob === \"undefined\" || typeof atob === \"undefined\") return true;\n const canOffscreenCanvas = check_offscreen_canvas();\n const canCanvas = check_canvas();\n if (!canOffscreenCanvas && !canCanvas) return true;\n const binary = atob(ORIENTED_JPEG_BASE64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n return createImageBitmap(new Blob([bytes], { type: \"image/jpeg\" })).then((imageBitmap) => createImageBitmap(imageBitmap, 1, 1, 1, 1).then((bitmap) => {\n let canvas;\n if (canOffscreenCanvas) canvas = new OffscreenCanvas(1, 1);\n else {\n canvas = document.createElement(\"canvas\");\n canvas.width = 1;\n canvas.height = 1;\n }\n try {\n const ctx = canvas.getContext(\"2d\");\n ctx.drawImage(bitmap, 0, 0);\n return bitmap.width !== 1 || bitmap.height !== 1 || ctx.getImageData(0, 0, 1, 1).data[0] < 240;\n } finally {\n imageBitmap.close();\n bitmap.close();\n }\n }, () => {\n imageBitmap.close();\n return true;\n }));\n }).catch(() => true);\n }\n function check_cib_resize_async() {\n return Promise.resolve().then(() => {\n if (!check_create_image_bitmap()) return false;\n const SRC_SIZE = 20;\n const DST_SIZE = 5;\n let canvas;\n if (features.canvas || check_canvas()) {\n canvas = document.createElement(\"canvas\");\n canvas.width = SRC_SIZE;\n canvas.height = SRC_SIZE;\n } else if (features.offscreen_canvas || check_offscreen_canvas()) {\n canvas = new OffscreenCanvas(SRC_SIZE, SRC_SIZE);\n canvas.getContext(\"2d\").clearRect(0, 0, SRC_SIZE, SRC_SIZE);\n } else return false;\n return createImageBitmap(canvas, 0, 0, SRC_SIZE, SRC_SIZE, {\n resizeWidth: DST_SIZE,\n resizeHeight: DST_SIZE,\n resizeQuality: \"high\"\n }).then((bitmap) => {\n const status = bitmap.width === DST_SIZE && !!bitmap.close;\n if (bitmap.close) bitmap.close();\n canvas = null;\n return status;\n });\n }).catch(() => false);\n }\n function get_supported_features() {\n if (checked) return Promise.resolve(Object.assign({}, features));\n if (checking) return checking.then(() => Object.assign({}, features));\n features.canvas = check_canvas();\n features.offscreen_canvas = check_offscreen_canvas();\n features.may_be_worker = check_may_be_worker();\n features.create_image_bitmap = check_create_image_bitmap();\n features.safari_put_image_data_fix = check_safari_put_image_data_fix();\n const bugCanvasOrientationRegion = check_bug_canvas_orientation_region_async().then((result) => {\n features.bug_canvas_orientation_region = result;\n }).catch(() => {});\n const bugImageBitmapOrientationRegion = check_bug_image_bitmap_orientation_region_async().then((result) => {\n features.bug_image_bitmap_orientation_region = result;\n }).catch(() => {});\n const cibResize = check_cib_resize_async().then((result) => {\n features.cib_resize = result;\n }).catch(() => {});\n checking = Promise.all([\n bugCanvasOrientationRegion,\n bugImageBitmapOrientationRegion,\n cibResize\n ]).then(() => {\n checked = true;\n checking = null;\n return Object.assign({}, features);\n }, (err) => {\n checking = null;\n throw err;\n });\n return checking;\n }\n var workerScope = self;\n var mathLib = null;\n function resize_math(data, tileJob) {\n if (!mathLib) mathLib = new MathLib(data.features);\n return mathLib.resizeAndUnsharp(tileJob);\n }\n function resizeBitmap(data, tileJob) {\n let srcCanvas = new OffscreenCanvas(tileJob.width, tileJob.height);\n const srcCtx = srcCanvas.getContext(\"2d\");\n srcCtx.drawImage(tileJob.src, 0, 0);\n const src = srcCtx.getImageData(0, 0, tileJob.width, tileJob.height).data;\n srcCanvas.width = srcCanvas.height = 0;\n srcCanvas = null;\n tileJob.src.close();\n const result = resize_math(data, {\n src,\n width: tileJob.width,\n height: tileJob.height,\n toWidth: tileJob.toWidth,\n toHeight: tileJob.toHeight,\n scaleX: tileJob.scaleX,\n scaleY: tileJob.scaleY,\n offsetX: tileJob.offsetX,\n offsetY: tileJob.offsetY,\n filter: tileJob.filter,\n unsharpAmount: tileJob.unsharpAmount,\n unsharpRadius: tileJob.unsharpRadius,\n unsharpThreshold: tileJob.unsharpThreshold\n });\n const canvas = new OffscreenCanvas(tileJob.toWidth, tileJob.toHeight);\n const ctx = canvas.getContext(\"2d\");\n const toImageData = ctx.createImageData(tileJob.toWidth, tileJob.toHeight);\n toImageData.data.set(result);\n ctx.putImageData(toImageData, 0, 0);\n const bitmap = canvas.transferToImageBitmap();\n workerScope.postMessage({\n kind: \"bitmap\",\n data: bitmap\n }, [bitmap]);\n }\n function resize(data) {\n if (data.job.kind === \"bitmap\") {\n resizeBitmap(data, data.job);\n return;\n }\n const result = resize_math(data, data.job);\n workerScope.postMessage({\n kind: \"array\",\n data: result\n }, [result.buffer]);\n }\n function handleMessage(data) {\n switch (data.method) {\n case \"get_supported_features\": return get_supported_features().then((result) => {\n workerScope.postMessage({ data: result });\n });\n case \"resize\":\n resize(data);\n return Promise.resolve();\n default: return Promise.reject(/* @__PURE__ */ new Error(`Unknown worker method: ${data.method}`));\n }\n }\n workerScope.onmessage = function(ev) {\n Promise.resolve().then(() => handleMessage(ev.data)).catch((err) => {\n workerScope.postMessage({ err });\n });\n };\n})();\n\n//# sourceURL=pica-inline-worker.js";
|
|
1175
|
+
var WORKER_SRC = "/*!\n\npica\nhttps://github.com/nodeca/pica\n\n*/\n!function(){var A;function t(A){const t=A.replace(/[\\r\\n=]/g,\"\"),e=t.length,n=new Uint8Array(3*e>>2);let a=0,i=0;for(let s=0;s<e;s++)s%4==0&&s&&(n[i++]=a>>16&255,n[i++]=a>>8&255,n[i++]=255&a),a=a<<6|\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\".indexOf(t.charAt(s));const r=e%4*6;return 0===r?(n[i++]=a>>16&255,n[i++]=a>>8&255,n[i++]=255&a):18===r?(n[i++]=a>>10&255,n[i++]=a>>2&255):12===r&&(n[i++]=a>>4&255),n}var e={js:!0,wasm:!0},n=class{constructor(A){const t=Object.assign({},e,A||{});if(this.options=t,this.__cache={},this.__init_promise=null,this.__modules=t.modules||{},this.__memory=null,this.__wasm={},this.__isLE=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0],!this.options.js&&!this.options.wasm)throw new Error('mathlib: at least \"js\" or \"wasm\" should be enabled')}has_wasm(){return function(){if(void 0!==A)return A;if(A=!1,\"undefined\"==typeof WebAssembly)return A;try{const t=new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]),e=new WebAssembly.Module(t);return 0!==new WebAssembly.Instance(e,{}).exports.test(4)&&(A=!0),A}catch(t){}return A}()}use(A){return this.__modules[A.name]=A,this.options.wasm&&this.has_wasm()&&A.wasm_fn?this[A.name]=A.wasm_fn:this[A.name]=A.fn,this}init(){return this.__init_promise?this.__init_promise:this.options.js||!this.options.wasm||this.has_wasm()?(this.__init_promise=Promise.all(Object.keys(this.__modules).map(A=>{const e=this.__modules[A];return this.options.wasm&&this.has_wasm()&&e.wasm_fn?this.__wasm[A]?null:WebAssembly.compile(t(e.wasm_src)).then(t=>{this.__wasm[A]=t}):null})).then(()=>this),this.__init_promise):Promise.reject(new Error('mathlib: only \"wasm\" was enabled, but it\\'s not supported'))}__reallocate(A){if(!this.__memory)return this.__memory=new WebAssembly.Memory({initial:Math.ceil(A/65536)}),this.__memory;const t=this.__memory.buffer.byteLength;return t<A&&this.__memory.grow(Math.ceil((A-t)/65536)),this.__memory}__instance(A,e,n){if(e&&this.__reallocate(e),!this.__wasm[A]){const e=this.__modules[A];this.__wasm[A]=new WebAssembly.Module(t(e.wasm_src))}if(!this.__cache[A]){const t={memoryBase:0,memory:this.__memory,tableBase:0,table:new WebAssembly.Table({initial:0,element:\"anyfunc\"})};this.__cache[A]=new WebAssembly.Instance(this.__wasm[A],{env:Object.assign(t,n||{})})}return this.__cache[A]}__align(A,t){const e=A%(t=t||8);return A+(e?t-e:0)}};function a(A,t,e,n,a,i){let r,s,o,g,I,h,B,Q,E,C,c,f,u,d;for(E=0;E<i;E++){for(h=E*a,B=E,Q=0,r=A[h],I=r*n[6],g=I,c=n[0],f=n[1],u=n[4],d=n[5],C=0;C<a;C++)s=A[h],o=s*c+r*f+g*u+I*d,I=g,g=o,r=s,e[Q]=g,Q++,h++;for(h--,Q--,B+=i*(a-1),r=A[h],I=r*n[7],g=I,s=r,c=n[2],f=n[3],C=a-1;C>=0;C--)o=s*c+r*f+g*u+I*d,I=g,g=o,r=s,s=A[h],t[B]=e[Q]+g,h--,Q--,B-=i}}function i(A,t,e,n){if(!n)return;const i=new Uint16Array(A.length),r=new Float32Array(Math.max(t,e)),s=function(A){A<.5&&(A=.5);const t=Math.exp(.527076)/A,e=Math.exp(-t),n=Math.exp(-2*t),a=(1-e)*(1-e)/(1+2*t*e-n),i=a*(t-1)*e,r=a*(t+1)*e,s=-a*n,o=2*e,g=-n;return new Float32Array([a,i,r,s,o,g,(a+i)/(1-o-g),(r+s)/(1-o-g)])}(n);a(A,i,r,s,t,e),a(i,A,r,s,e,t)}var r={name:\"unsharp_mask\",fn:function(A,t,e,n,a,r){let s,o,g,I,h;if(0===n||a<.5)return;a>2&&(a=2);const B=function(A,t,e){const n=t*e,a=new Uint16Array(n);let i,r,s,o;for(let g=0;g<n;g++)i=A[4*g],r=A[4*g+1],s=A[4*g+2],o=i>=r&&i>=s?i:r>=s&&r>=i?r:s,a[g]=o<<8;return a}(A,t,e),Q=new Uint16Array(B);i(Q,t,e,a);const E=n/100*4096+.5|0,C=r<<8,c=t*e;for(let i=0;i<c;i++)s=B[i],I=s-Q[i],Math.abs(I)>=C&&(o=s+(E*I+2048>>12),o=o>65280?65280:o,o=o<0?0:o,s=0!==s?s:1,g=(o<<12)/s|0,h=4*i,A[h]=A[h]*g+2048>>12,A[h+1]=A[h+1]*g+2048>>12,A[h+2]=A[h+2]*g+2048>>12)},wasm_fn:function(A,t,e,n,a,i){if(0===n||a<.5)return;a>2&&(a=2);const r=t*e,s=4*r,o=2*r,g=2*r,I=4*Math.max(t,e),h=s,B=h+o,Q=B+g,E=Q+g,C=E+I,c=this.__instance(\"unsharp_mask\",s+o+2*g+I+32,{exp:Math.exp}),f=new Uint32Array(A.buffer);new Uint32Array(this.__memory.buffer).set(f);let u=c.exports.hsv_v16||c.exports._hsv_v16;if(!u)throw new Error(\"WASM hsv_v16 function is not available\");if(u(0,h,t,e),u=c.exports.blurMono16||c.exports._blurMono16,!u)throw new Error(\"WASM blurMono16 function is not available\");if(u(h,B,Q,E,C,t,e,a),u=c.exports.unsharp||c.exports._unsharp,!u)throw new Error(\"WASM unsharp function is not available\");u(0,0,h,B,t,e,n,i),f.set(new Uint32Array(this.__memory.buffer,0,r))},wasm_src:\"AGFzbQEAAAAADAZkeWxpbmsAAAAAAAE0B2AAAGAEf39/fwBgBn9/f39/fwBgCH9/f39/f39/AGAIf39/f39/f30AYAJ9fwBgAXwBfAIZAgNlbnYDZXhwAAYDZW52Bm1lbW9yeQIAAAMHBgAFAgQBAwYGAX8AQQALB4oBCBFfX3dhc21fY2FsbF9jdG9ycwABFl9fYnVpbGRfZ2F1c3NpYW5fY29lZnMAAg5fX2dhdXNzMTZfbGluZQADCmJsdXJNb25vMTYABAdoc3ZfdjE2AAUHdW5zaGFycAAGDF9fZHNvX2hhbmRsZQMAGF9fd2FzbV9hcHBseV9kYXRhX3JlbG9jcwABCsUMBgMAAQvWAQEHfCABRNuGukOCGvs/IAC7oyICRAAAAAAAAADAohAAIgW2jDgCFCABIAKaEAAiAyADoCIGtjgCECABRAAAAAAAAPA/IAOhIgQgBKIgAyACIAKgokQAAAAAAADwP6AgBaGjIgS2OAIAIAEgBSAEmqIiB7Y4AgwgASADIAJEAAAAAAAA8D+gIASioiIItjgCCCABIAMgAkQAAAAAAADwv6AgBKKiIgK2OAIEIAEgByAIoCAFRAAAAAAAAPA/IAahoCIDo7Y4AhwgASAEIAKgIAOjtjgCGAuGBQMGfwl8An0gAyoCDCEVIAMqAgghFiADKgIUuyERIA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IA+gIAxEAAAAAAAA8D8gDaGgIgqjtjgCHCAEIAsgCaAgCqO2OAIYIAYEQANAIAAgBSAIbEEBdGogAiAIQQF0aiADIAQgBSAGEAMgCEEBaiIIIAZHDQALCyAFRQ0AQQAhCANAIAIgBiAIbEEBdGogASAIQQF0aiADIAQgBiAFEAMgCEEBaiIIIAVHDQALCwtxAQN/IAIgA2wiBQRAA0AgASAAKAIAIgRBEHZB/wFxIgIgAiAEQQh2Qf8BcSIDIAMgBEH/AXEiBEkbIAIgA0sbIgYgBiAEIAIgBEsbIAMgBEsbQQh0OwEAIAFBAmohASAAQQRqIQAgBUEBayIFDQALCwuZAgIDfwF8IAQgBWwhBAJ/IAazQwAAgEWUQwAAyEKVu0QAAAAAAADgP6AiC5lEAAAAAAAA4EFjBEAgC6oMAQtBgICAgHgLIQUgBARAIAdBCHQhCUEAIQYDQCAJIAIgBkEBdCIHai8BACIBIAMgB2ovAQBrIgcgB0EfdSIIaiAIc00EQCAAIAZBAnQiCGoiCiAFIAdsQYAQakEMdSABaiIHQYD+AyAHQYD+A0gbIgdBACAHQQBKG0EMdCABQQEgARtuIgEgCi0AAGxBgBBqQQx2OgAAIAAgCEEBcmoiByABIActAABsQYAQakEMdjoAACAAIAhBAnJqIgcgASAHLQAAbEGAEGpBDHY6AAALIAZBAWoiBiAERw0ACwsL\"},s={filter:{box:{win:.5,fn:A=>(A<0&&(A=-A),A<.5?1:0)},hamming:{win:1,fn(A){if(A<0&&(A=-A),A>=1)return 0;if(A<1.1920929e-7)return 1;const t=A*Math.PI;return Math.sin(t)/t*(.54+.46*Math.cos(t/1))}},lanczos2:{win:2,fn(A){if(A<0&&(A=-A),A>=2)return 0;if(A<1.1920929e-7)return 1;const t=A*Math.PI;return Math.sin(t)/t*Math.sin(t/2)/(t/2)}},lanczos3:{win:3,fn(A){if(A<0&&(A=-A),A>=3)return 0;if(A<1.1920929e-7)return 1;const t=A*Math.PI;return Math.sin(t)/t*Math.sin(t/3)/(t/3)}},mks2013:{win:2.5,fn:A=>(A<0&&(A=-A),A>=2.5?0:A>=1.5?-.125*(A-2.5)*(A-2.5):A>=.5?.25*(4*A*A-11*A+7):1.0625-1.75*A*A)}}};function o(A){return Math.round(16383*A)}function g(A,t,e,n,a){const i=s.filter[A].fn,r=1/n,g=Math.min(1,n),I=s.filter[A].win/g;let h,B,Q,E,C,c,f,u,d,m,l,w,y,_,b,D,M;const p=Math.floor(2*(I+1)),G=new Int16Array((p+2)*e);let U=0;const F=!G.subarray||!G.set;for(h=0;h<e;h++){for(B=(h+.5)*r+a,Q=Math.max(0,Math.floor(B-I)),E=Math.min(t-1,Math.ceil(B+I)),C=E-Q+1,c=new Float32Array(C),f=new Int16Array(C),u=0,d=Q,m=0;d<=E;d++,m++)l=i((d+.5-B)*g),u+=l,c[m]=l;for(w=0,m=0;m<c.length;m++)y=c[m]/u,w+=y,f[m]=o(y);for(f[e>>1]+=o(1-w),_=0;_<f.length&&0===f[_];)_++;if(_<f.length){for(b=f.length-1;b>0&&0===f[b];)b--;if(D=Q+_,M=b-_+1,G[U++]=D,G[U++]=M,F)for(m=_;m<=b;m++)G[U++]=f[m];else G.set(f.subarray(_,b+1),U),U+=M}else G[U++]=0,G[U++]=0}return G}function I(A){return A<0?0:A>255?255:A}function h(A){return A>=0?A:0}var B=!0;try{B=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0]}catch(G){}function Q(A,t,e){if(B)t.set(function(A){return new Uint8Array(A.buffer,0,A.byteLength)}(A),e);else for(let n=e,a=0;a<A.length;a++){const e=A[a];t[n++]=255&e,t[n++]=e>>8&255}}var E={name:\"resize\",fn:function(A){const t=A.src,e=A.width,n=A.height,a=A.toWidth,i=A.toHeight,r=A.scaleX||A.toWidth/A.width,s=A.scaleY||A.toHeight/A.height,o=A.offsetX||0,B=A.offsetY||0,Q=A.dest||new Uint8Array(a*i*4),E=void 0===A.filter?\"mks2013\":A.filter,C=g(E,e,a,r,o),c=g(E,n,i,s,B),f=new Uint16Array(a*n*4);return!function(A,t,e){let n=3;const a=t*e*4|0;for(;n<a;){if(255!==A[n])return!0;n=n+4|0}return!1}(t,e,n)?(function(A,t,e,n,a,i){let r,s,o,g,I,B,Q,E,C,c,f,u=0,d=0;for(C=0;C<n;C++){for(I=0,c=0;c<a;c++){for(B=i[I++],Q=i[I++],E=u+4*B|0,r=s=o=g=0;Q>0;Q--)f=i[I++],g=g+f*A[E+3]|0,o=o+f*A[E+2]|0,s=s+f*A[E+1]|0,r=r+f*A[E]|0,E=E+4|0;t[d+3]=h(g>>7),t[d+2]=h(o>>7),t[d+1]=h(s>>7),t[d]=h(r>>7),d=d+4*n|0}d=4*(C+1)|0,u=(C+1)*e*4|0}}(t,f,e,n,a,C),function(A,t,e,n,a,i){let r,s,o,g,h,B,Q,E,C,c,f,u=0,d=0;for(C=0;C<n;C++){for(h=0,c=0;c<a;c++){for(B=i[h++],Q=i[h++],E=u+4*B|0,r=s=o=g=0;Q>0;Q--)f=i[h++],g=g+f*A[E+3]|0,o=o+f*A[E+2]|0,s=s+f*A[E+1]|0,r=r+f*A[E]|0,E=E+4|0;r>>=7,s>>=7,o>>=7,g>>=7,t[d+3]=I(g+8192>>14),t[d+2]=I(o+8192>>14),t[d+1]=I(s+8192>>14),t[d]=I(r+8192>>14),d=d+4*n|0}d=4*(C+1)|0,u=(C+1)*e*4|0}}(f,Q,n,a,i,c),function(A,t,e){let n=3;const a=t*e*4|0;for(;n<a;)A[n]=255,n=n+4|0}(Q,a,i)):(function(A,t,e,n,a,i){let r,s,o,g,I,B,Q,E,C,c,f,u,d=0,m=0;for(c=0;c<n;c++){for(B=0,f=0;f<a;f++){for(Q=i[B++],E=i[B++],C=d+4*Q|0,r=s=o=g=0;E>0;E--)u=i[B++],I=A[C+3],g=g+u*I|0,o=o+u*A[C+2]*I|0,s=s+u*A[C+1]*I|0,r=r+u*A[C]*I|0,C=C+4|0;o=o/255|0,s=s/255|0,r=r/255|0,t[m+3]=h(g>>7),t[m+2]=h(o>>7),t[m+1]=h(s>>7),t[m]=h(r>>7),m=m+4*n|0}m=4*(c+1)|0,d=(c+1)*e*4|0}}(t,f,e,n,a,C),function(A,t,e,n,a,i){let r,s,o,g,h,B,Q,E,C,c,f,u=0,d=0;for(C=0;C<n;C++){for(h=0,c=0;c<a;c++){for(B=i[h++],Q=i[h++],E=u+4*B|0,r=s=o=g=0;Q>0;Q--)f=i[h++],g=g+f*A[E+3]|0,o=o+f*A[E+2]|0,s=s+f*A[E+1]|0,r=r+f*A[E]|0,E=E+4|0;r>>=7,s>>=7,o>>=7,g>>=7,g=I(g+8192>>14),g>0&&(r=255*r/g|0,s=255*s/g|0,o=255*o/g|0),t[d+3]=g,t[d+2]=I(o+8192>>14),t[d+1]=I(s+8192>>14),t[d]=I(r+8192>>14),d=d+4*n|0}d=4*(C+1)|0,u=(C+1)*e*4|0}}(f,Q,n,a,i,c)),Q},wasm_fn:function(A){const t=A.src,e=A.width,n=A.height,a=A.toWidth,i=A.toHeight,r=A.scaleX||A.toWidth/A.width,s=A.scaleY||A.toHeight/A.height,o=A.offsetX||0,I=A.offsetY||0,h=A.dest||new Uint8Array(a*i*4),B=void 0===A.filter?\"mks2013\":A.filter,E=g(B,e,a,r,o),C=g(B,n,i,s,I),c=Math.max(t.byteLength,h.byteLength),f=this.__align(0+c),u=n*a*4*2,d=this.__align(f+u),m=this.__align(d+E.byteLength),l=m+C.byteLength,w=this.__instance(\"resize\",l),y=new Uint8Array(this.__memory.buffer),_=new Uint32Array(this.__memory.buffer),b=new Uint32Array(t.buffer);_.set(b),Q(E,y,d),Q(C,y,m);const D=w.exports.convolveHV||w.exports._convolveHV;if(!D)throw new Error(\"WASM resize function is not available\");return!function(A,t,e){let n=3;const a=t*e*4|0;for(;n<a;){if(255!==A[n])return!0;n=n+4|0}return!1}(t,e,n)?(D(d,m,f,e,n,a,i,0),function(A,t,e){let n=3;const a=t*e*4|0;for(;n<a;)A[n]=255,n=n+4|0}(h,a,i)):D(d,m,f,e,n,a,i,1),new Uint32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QAhCUEAIQYgCiEHQQAMAQsgAi4BAEECdCARaiEJQQAhByATIQJBACENIAohBkEAIQ5BACEPA0AgBSAGQQF0ai4BACIIIAAgCUEBdCIQai8BAGwgB2ohByAAIBBBBnJqLwEAIAhsIA5qIQ4gACAQQQRyai8BACAIbCAPaiEPIAAgEEECcmovAQAgCGwgDWohDSAJQQRqIQkgBkEBaiEGIAJBAWsiAg0ACyAHQQd1IQggDUEHdSEJIA9BB3UhBiAKIBNqIQcgDkEHdQtBgEBrQQ51IgJB/wEgAkH/AUgbIgJBACACQQBKGyIKQf8BcQRAIAlB/wFsIAJtIQkgCEH/AWwgAm0hCCAGQf8BbCACbSEGCyABIAxBAnRqIAlBgEBrQQ51IgJB/wEgAkH/AUgbIgJBACACQQBKG0EIdEGA/gNxIAZBgEBrQQ51IgJB/wEgAkH/AUgbIgJBACACQQBKG0EQdEGAgPwHcSAKQRh0ciAIQYBAa0EOdSICQf8BIAJB/wFIGyICQQAgAkEAShtycjYCACADIAxqIQwgEkEBaiISIARHDQALIBQgC0EBaiILbCERIAMgC0cNAAsLC0AAIAcEQEEAIAIgAyAEIAUgABADIAJBACAEIAUgBiABEAQPC0EAIAIgAyAEIAUgABABIAJBACAEIAUgBiABEAIL\"},C=class extends n{constructor(A){const t=A||[],e={js:t.indexOf(\"js\")>=0,wasm:t.indexOf(\"wasm\")>=0};super(e),this.features={js:e.js,wasm:e.wasm&&this.has_wasm()},this.use(r),this.use(E)}resizeAndUnsharp(A){const t=this.resize(A);return A.unsharpAmount&&this.unsharp_mask(t,A.toWidth,A.toHeight,A.unsharpAmount,A.unsharpRadius,A.unsharpThreshold),t}},c=\"/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/4AAQskZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/wAALCAACAAMBAREA/8QAFAABAAAAAAAAAAAAAAAAAAAACf/EABsQAAMBAQADAAAAAAAAAAAAAAECAwQFABEx/9oACAEBAAA/AC06fW6va0ps7PT179E88MiV02arrCEkjGQZiSEnKc5ovxURVHoADz//2Q==\",f={canvas:!1,offscreen_canvas:!1,may_be_worker:!1,create_image_bitmap:!1,safari_put_image_data_fix:!1,bug_canvas_orientation_region:!0,bug_image_bitmap_orientation_region:!0,cib_resize:!1},u=!1,d=null,m={willReadFrequently:!0};function l(){if(\"undefined\"==typeof document||!document.createElement)return!1;try{const A=document.createElement(\"canvas\");A.width=2,A.height=1;const t=A.getContext(\"2d\",m);let e=t.createImageData(2,1);return e.data[0]=12,e.data[1]=23,e.data[2]=34,e.data[3]=255,e.data[4]=45,e.data[5]=56,e.data[6]=67,e.data[7]=255,t.putImageData(e,0,0),e=t.getImageData(0,0,2,1),12===e.data[0]&&23===e.data[1]&&34===e.data[2]&&255===e.data[3]&&45===e.data[4]&&56===e.data[5]&&67===e.data[6]&&255===e.data[7]}catch(G){return!1}}function w(){if(\"undefined\"==typeof OffscreenCanvas)return!1;try{const A=new OffscreenCanvas(2,1).getContext(\"2d\",m);let t=A.createImageData(2,1);return t.data[0]=12,t.data[1]=23,t.data[2]=34,t.data[3]=255,t.data[4]=45,t.data[5]=56,t.data[6]=67,t.data[7]=255,A.putImageData(t,0,0),t=A.getImageData(0,0,2,1),12===t.data[0]&&23===t.data[1]&&34===t.data[2]&&255===t.data[3]&&45===t.data[4]&&56===t.data[5]&&67===t.data[6]&&255===t.data[7]}catch(G){return!1}}function y(){return\"undefined\"!=typeof createImageBitmap}function _(){if(u)return Promise.resolve(Object.assign({},f));if(d)return d.then(()=>Object.assign({},f));f.canvas=l(),f.offscreen_canvas=w(),f.may_be_worker=\"undefined\"!=typeof Worker&&\"undefined\"!=typeof URL&&!!URL.createObjectURL,f.create_image_bitmap=y(),f.safari_put_image_data_fix=function(){try{return!!(\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf(\"Safari\")>=0&&navigator.userAgent.indexOf(\"Chrome\")<0)}catch(G){return!1}}();const A=Promise.resolve().then(()=>{if(w()&&y()&&\"undefined\"!=typeof Blob&&\"undefined\"!=typeof atob){const A=atob(c),t=new Uint8Array(A.length);for(let e=0;e<A.length;e++)t[e]=A.charCodeAt(e);return createImageBitmap(new Blob([t],{type:\"image/jpeg\"})).then(A=>{const t=new OffscreenCanvas(1,1);try{const e=t.getContext(\"2d\",m);return e.drawImage(A,1,1,1,1,0,0,1,1),e.getImageData(0,0,1,1).data[0]<240}finally{A.close()}})}return!l()||\"undefined\"==typeof Image||new Promise(A=>{const t=new Image;t.onload=()=>{try{const e=document.createElement(\"canvas\");e.width=1,e.height=1;const n=e.getContext(\"2d\",m);n.drawImage(t,1,1,1,1,0,0,1,1),A(n.getImageData(0,0,1,1).data[0]<240)}catch(G){A(!0)}},t.onerror=()=>A(!0),t.src=`data:image/jpeg;base64,${c}`})}).catch(()=>!0).then(A=>{f.bug_canvas_orientation_region=A}).catch(()=>{}),t=Promise.resolve().then(()=>{if(!f.create_image_bitmap&&!y())return!0;if(\"undefined\"==typeof Blob||\"undefined\"==typeof atob)return!0;const A=w(),t=l();if(!A&&!t)return!0;const e=atob(c),n=new Uint8Array(e.length);for(let a=0;a<e.length;a++)n[a]=e.charCodeAt(a);return createImageBitmap(new Blob([n],{type:\"image/jpeg\"})).then(t=>createImageBitmap(t,1,1,1,1).then(e=>{let n;A?n=new OffscreenCanvas(1,1):(n=document.createElement(\"canvas\"),n.width=1,n.height=1);try{const A=n.getContext(\"2d\",m);return A.drawImage(e,0,0),1!==e.width||1!==e.height||A.getImageData(0,0,1,1).data[0]<240}finally{t.close(),e.close()}},()=>(t.close(),!0)))}).catch(()=>!0).then(A=>{f.bug_image_bitmap_orientation_region=A}).catch(()=>{}),e=Promise.resolve().then(()=>{if(!y())return!1;const A=20;let t;if(f.canvas||l())t=document.createElement(\"canvas\"),t.width=A,t.height=A;else{if(!f.offscreen_canvas&&!w())return!1;t=new OffscreenCanvas(A,A),t.getContext(\"2d\",m).clearRect(0,0,A,A)}return createImageBitmap(t,0,0,A,A,{resizeWidth:5,resizeHeight:5,resizeQuality:\"high\"}).then(A=>{const e=5===A.width&&!!A.close;return A.close&&A.close(),t=null,e})}).catch(()=>!1).then(A=>{f.cib_resize=A}).catch(()=>{});return d=Promise.all([A,t,e]).then(()=>(u=!0,d=null,Object.assign({},f)),A=>{throw d=null,A})}var b=self,D=null;function M(A,t){return D||(D=new C(A.features)),D.resizeAndUnsharp(t)}function p(A){if(\"bitmap\"===A.job.kind)return void function(A,t){let e=new OffscreenCanvas(t.width,t.height);const n={willReadFrequently:!0},a=e.getContext(\"2d\",n);a.drawImage(t.src,0,0);const i=a.getImageData(0,0,t.width,t.height).data;e.width=e.height=0,e=null,t.src.close();const r=M(A,{src:i,width:t.width,height:t.height,toWidth:t.toWidth,toHeight:t.toHeight,scaleX:t.scaleX,scaleY:t.scaleY,offsetX:t.offsetX,offsetY:t.offsetY,filter:t.filter,unsharpAmount:t.unsharpAmount,unsharpRadius:t.unsharpRadius,unsharpThreshold:t.unsharpThreshold}),s=new OffscreenCanvas(t.toWidth,t.toHeight),o=s.getContext(\"2d\",n),g=o.createImageData(t.toWidth,t.toHeight);g.data.set(r),o.putImageData(g,0,0);const I=s.transferToImageBitmap();b.postMessage({kind:\"bitmap\",data:I},[I])}(A,A.job);const t=M(A,A.job);b.postMessage({kind:\"array\",data:t},[t.buffer])}b.onmessage=function(A){Promise.resolve().then(()=>function(A){switch(A.method){case\"get_supported_features\":return _().then(A=>{b.postMessage({data:A})});case\"resize\":return p(A),Promise.resolve();default:return Promise.reject(new Error(`Unknown worker method: ${A.method}`))}}(A.data)).catch(A=>{b.postMessage({err:A})})}}();\n//# sourceURL=pica-inline-worker.js";
|
|
1262
1176
|
var concurrency = 1;
|
|
1263
1177
|
if (typeof navigator !== "undefined") concurrency = Math.min(navigator.hardwareConcurrency || 1, 4);
|
|
1264
1178
|
var DEFAULT_PICA_OPTS = {
|
|
@@ -1277,6 +1191,7 @@ var DEFAULT_RESIZE_OPTS = {
|
|
|
1277
1191
|
unsharpRadius: 0,
|
|
1278
1192
|
unsharpThreshold: 0
|
|
1279
1193
|
};
|
|
1194
|
+
var ctxOpts = { willReadFrequently: true };
|
|
1280
1195
|
var Pica = class {
|
|
1281
1196
|
constructor(options) {
|
|
1282
1197
|
_defineProperty(this, "options", void 0);
|
|
@@ -1435,7 +1350,7 @@ var Pica = class {
|
|
|
1435
1350
|
if (this.resize_features.ww && this.capabilities.ww_offscreen_canvas) {
|
|
1436
1351
|
this.debug("Create tile imageBitmap");
|
|
1437
1352
|
const tileCanvas = this.createCanvas(tile.width, tile.height, { preferOffscreen: true });
|
|
1438
|
-
tileCanvas.getContext("2d").drawImage(stageEnv.srcImageBitmap || from, tile.x, tile.y, tile.width, tile.height, 0, 0, tile.width, tile.height);
|
|
1353
|
+
tileCanvas.getContext("2d", ctxOpts).drawImage(stageEnv.srcImageBitmap || from, tile.x, tile.y, tile.width, tile.height, 0, 0, tile.width, tile.height);
|
|
1439
1354
|
if (!("transferToImageBitmap" in tileCanvas)) throw new Error("Pica: offscreen canvas is not available for worker transfer");
|
|
1440
1355
|
return Object.assign({}, extractTo, {
|
|
1441
1356
|
kind: "bitmap",
|
|
@@ -1443,7 +1358,7 @@ var Pica = class {
|
|
|
1443
1358
|
});
|
|
1444
1359
|
}
|
|
1445
1360
|
if (isCanvas(from)) {
|
|
1446
|
-
if (!stageEnv.srcCtx) stageEnv.srcCtx = from.getContext("2d");
|
|
1361
|
+
if (!stageEnv.srcCtx) stageEnv.srcCtx = from.getContext("2d", ctxOpts);
|
|
1447
1362
|
this.debug("Get tile pixel data");
|
|
1448
1363
|
return Object.assign({}, extractTo, {
|
|
1449
1364
|
kind: "array",
|
|
@@ -1452,7 +1367,7 @@ var Pica = class {
|
|
|
1452
1367
|
}
|
|
1453
1368
|
this.debug("Draw tile imageBitmap/image to temporary canvas");
|
|
1454
1369
|
const tmpCanvas = this.createCanvas(tile.width, tile.height, { preferOffscreen: true });
|
|
1455
|
-
const tmpCtx = tmpCanvas.getContext("2d");
|
|
1370
|
+
const tmpCtx = tmpCanvas.getContext("2d", ctxOpts);
|
|
1456
1371
|
tmpCtx.globalCompositeOperation = "copy";
|
|
1457
1372
|
tmpCtx.drawImage(stageEnv.srcImageBitmap || from, tile.x, tile.y, tile.width, tile.height, 0, 0, tile.width, tile.height);
|
|
1458
1373
|
this.debug("Get tile pixel data");
|
|
@@ -1509,7 +1424,7 @@ var Pica = class {
|
|
|
1509
1424
|
return _this3.__landTileData(tile, result, stageEnv);
|
|
1510
1425
|
}));
|
|
1511
1426
|
yield Promise.resolve();
|
|
1512
|
-
stageEnv.toCtx = to.getContext("2d");
|
|
1427
|
+
stageEnv.toCtx = to.getContext("2d", ctxOpts);
|
|
1513
1428
|
if (isCanvas(from)) {} else if (isImageBitmap(from)) {
|
|
1514
1429
|
stageEnv.srcImageBitmap = from;
|
|
1515
1430
|
stageEnv.isImageBitmapReused = true;
|
|
@@ -1589,7 +1504,7 @@ var Pica = class {
|
|
|
1589
1504
|
var _this5 = this;
|
|
1590
1505
|
return _asyncToGenerator(function* () {
|
|
1591
1506
|
var _utils$filter_to_cib_;
|
|
1592
|
-
let toCtx = to.getContext("2d");
|
|
1507
|
+
let toCtx = to.getContext("2d", ctxOpts);
|
|
1593
1508
|
_this5.debug("Resize via createImageBitmap()");
|
|
1594
1509
|
const imageBitmap = yield createImageBitmap(from, {
|
|
1595
1510
|
resizeWidth: resizeParams.toWidth,
|
|
@@ -1606,7 +1521,7 @@ var Pica = class {
|
|
|
1606
1521
|
}
|
|
1607
1522
|
_this5.debug("Unsharp result");
|
|
1608
1523
|
let tmpCanvas = _this5.createCanvas(resizeParams.toWidth, resizeParams.toHeight);
|
|
1609
|
-
let tmpCtx = tmpCanvas.getContext("2d");
|
|
1524
|
+
let tmpCtx = tmpCanvas.getContext("2d", ctxOpts);
|
|
1610
1525
|
tmpCtx.drawImage(imageBitmap, 0, 0);
|
|
1611
1526
|
imageBitmap.close();
|
|
1612
1527
|
let iData = tmpCtx.getImageData(0, 0, resizeParams.toWidth, resizeParams.toHeight);
|
|
@@ -1657,7 +1572,7 @@ var Pica = class {
|
|
|
1657
1572
|
if (ctx.canceled) return ctx.cancelToken;
|
|
1658
1573
|
if (_this6.capabilities.bug_image_bitmap_orientation_region && (isImage(from) || isImageBitmap(from))) {
|
|
1659
1574
|
const tmpCanvas = _this6.createCanvas(resizeParams.width, resizeParams.height);
|
|
1660
|
-
tmpCanvas.getContext("2d").drawImage(from, 0, 0);
|
|
1575
|
+
tmpCanvas.getContext("2d", ctxOpts).drawImage(from, 0, 0);
|
|
1661
1576
|
from = tmpCanvas;
|
|
1662
1577
|
}
|
|
1663
1578
|
if (_this6.resize_features.cib) {
|