md-face-engine 1.1.2 → 1.1.4
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/dist/MartidermEngine-B8TASQtz.js +123 -0
- package/dist/MartidermEngine-Co30fWUU.cjs +4 -0
- package/dist/client-BJQU_Kcy.js +755 -0
- package/dist/client-G2U5YE6M.cjs +4 -0
- package/dist/client.cjs +1 -1
- package/dist/client.js +20 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/MartidermEngine-O4mYSfhg.cjs +0 -4
- package/dist/MartidermEngine-OvpT3v9z.js +0 -202
- package/dist/face_mesh-CA6iJyns.cjs +0 -18
- package/dist/face_mesh-Ctt6fZlf.js +0 -4207
- package/dist/index-Bdxo13gP.js +0 -420
- package/dist/index-DA_YlCTl.cjs +0 -1
|
@@ -0,0 +1,755 @@
|
|
|
1
|
+
import { useRef as j, useEffect as k, useState as x, useCallback as Y } from "react";
|
|
2
|
+
const q = {
|
|
3
|
+
smooth: { enabled: !0, radius: 4, passes: 2, opacity: 0.4 },
|
|
4
|
+
brightness: { enabled: !0, value: 0 },
|
|
5
|
+
contrast: { enabled: !0, value: 1 },
|
|
6
|
+
warmth: { enabled: !0, rPlus: 0, bMinus: 0, alpha: 0 }
|
|
7
|
+
};
|
|
8
|
+
class Q {
|
|
9
|
+
constructor(t = {}) {
|
|
10
|
+
this.storageKey = "martiderm_filter_configs", this.authKey = "martiderm_admin_auth", this.backupKey = "martiderm_config_backup", this.products = Array.isArray(t.products) ? t.products : [], this.init();
|
|
11
|
+
}
|
|
12
|
+
init() {
|
|
13
|
+
const t = this.loadConfigurations();
|
|
14
|
+
(!t || Object.keys(t).length === 0) && this.products.length > 0 && this.initializeDefaultConfigurations();
|
|
15
|
+
}
|
|
16
|
+
setProducts(t = []) {
|
|
17
|
+
this.products = Array.isArray(t) ? t : [];
|
|
18
|
+
const r = this.loadConfigurations();
|
|
19
|
+
(!r || Object.keys(r).length === 0) && this.products.length > 0 && this.initializeDefaultConfigurations();
|
|
20
|
+
}
|
|
21
|
+
initializeDefaultConfigurations() {
|
|
22
|
+
try {
|
|
23
|
+
const t = {};
|
|
24
|
+
this.products.forEach((r) => {
|
|
25
|
+
t[r.id] = this.generateProductConfig(r);
|
|
26
|
+
}), this.saveConfigurations(t);
|
|
27
|
+
} catch (t) {
|
|
28
|
+
console.error("Error inicializando configuraciones:", t);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
generateProductConfig(t = {}) {
|
|
32
|
+
return {
|
|
33
|
+
productId: t.id,
|
|
34
|
+
productName: t.name,
|
|
35
|
+
category: t.category,
|
|
36
|
+
filters: { ...q },
|
|
37
|
+
webglConfig: t.defaultWebglConfig ? { ...t.defaultWebglConfig } : {},
|
|
38
|
+
lastModified: (/* @__PURE__ */ new Date()).toISOString(),
|
|
39
|
+
version: "2.0"
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
getProductConfig(t) {
|
|
43
|
+
return this.loadConfigurations()[t] || null;
|
|
44
|
+
}
|
|
45
|
+
saveProductConfig(t, r) {
|
|
46
|
+
const o = this.loadConfigurations();
|
|
47
|
+
return o[t] = {
|
|
48
|
+
...r,
|
|
49
|
+
lastModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
50
|
+
}, this.saveConfigurations(o), !0;
|
|
51
|
+
}
|
|
52
|
+
getAllConfigurations() {
|
|
53
|
+
return this.loadConfigurations();
|
|
54
|
+
}
|
|
55
|
+
loadConfigurations() {
|
|
56
|
+
try {
|
|
57
|
+
const t = localStorage.getItem(this.storageKey);
|
|
58
|
+
return t ? JSON.parse(t) : {};
|
|
59
|
+
} catch (t) {
|
|
60
|
+
return console.error("Error cargando configuraciones:", t), {};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
saveConfigurations(t) {
|
|
64
|
+
try {
|
|
65
|
+
return localStorage.setItem(this.storageKey, JSON.stringify(t)), this.createBackup(t), !0;
|
|
66
|
+
} catch (r) {
|
|
67
|
+
return console.error("Error guardando configuraciones:", r), !1;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
createBackup(t = null) {
|
|
71
|
+
try {
|
|
72
|
+
const r = t || this.loadConfigurations(), o = {
|
|
73
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
74
|
+
configurations: r,
|
|
75
|
+
version: "2.0"
|
|
76
|
+
};
|
|
77
|
+
return localStorage.setItem(this.backupKey, JSON.stringify(o)), !0;
|
|
78
|
+
} catch (r) {
|
|
79
|
+
return console.error("Error creando backup:", r), !1;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
restoreFromBackup() {
|
|
83
|
+
try {
|
|
84
|
+
const t = localStorage.getItem(this.backupKey);
|
|
85
|
+
if (t) {
|
|
86
|
+
const r = JSON.parse(t);
|
|
87
|
+
return this.saveConfigurations(r.configurations), !0;
|
|
88
|
+
}
|
|
89
|
+
return !1;
|
|
90
|
+
} catch (t) {
|
|
91
|
+
return console.error("Error restaurando backup:", t), !1;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exportConfigurations() {
|
|
95
|
+
const t = this.loadConfigurations(), r = {
|
|
96
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
97
|
+
configurations: t,
|
|
98
|
+
version: "2.0"
|
|
99
|
+
};
|
|
100
|
+
return JSON.stringify(r, null, 2);
|
|
101
|
+
}
|
|
102
|
+
importConfigurations(t) {
|
|
103
|
+
try {
|
|
104
|
+
const r = JSON.parse(t);
|
|
105
|
+
return r.configurations ? (this.saveConfigurations(r.configurations), !0) : !1;
|
|
106
|
+
} catch (r) {
|
|
107
|
+
return console.error("Error importando configuraciones:", r), !1;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
resetToDefaults() {
|
|
111
|
+
try {
|
|
112
|
+
return localStorage.removeItem(this.storageKey), this.initializeDefaultConfigurations(), !0;
|
|
113
|
+
} catch (t) {
|
|
114
|
+
return console.error("Error reseteando configuraciones:", t), !1;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
isAuthenticated() {
|
|
118
|
+
try {
|
|
119
|
+
const t = localStorage.getItem(this.authKey);
|
|
120
|
+
if (!t) return !1;
|
|
121
|
+
const r = JSON.parse(t);
|
|
122
|
+
return !!(r != null && r.authenticated);
|
|
123
|
+
} catch {
|
|
124
|
+
return !1;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
authenticateAdmin(t, r) {
|
|
128
|
+
if (t === "admin" && r === "martiderm2024") {
|
|
129
|
+
const a = {
|
|
130
|
+
authenticated: !0,
|
|
131
|
+
username: t,
|
|
132
|
+
token: `adm-${Date.now()}`,
|
|
133
|
+
lastLogin: (/* @__PURE__ */ new Date()).toISOString()
|
|
134
|
+
};
|
|
135
|
+
return localStorage.setItem(this.authKey, JSON.stringify(a)), { success: !0, username: t };
|
|
136
|
+
}
|
|
137
|
+
return { success: !1, error: "Credenciales inválidas" };
|
|
138
|
+
}
|
|
139
|
+
getAuthenticatedUser() {
|
|
140
|
+
try {
|
|
141
|
+
const t = localStorage.getItem(this.authKey);
|
|
142
|
+
if (!t) return null;
|
|
143
|
+
const r = JSON.parse(t);
|
|
144
|
+
return r != null && r.authenticated ? { username: r.username } : null;
|
|
145
|
+
} catch {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
logout() {
|
|
150
|
+
try {
|
|
151
|
+
return localStorage.removeItem(this.authKey), !0;
|
|
152
|
+
} catch {
|
|
153
|
+
return !1;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exportConfiguration() {
|
|
157
|
+
return this.exportConfigurations();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const F = new Q();
|
|
161
|
+
function le(e) {
|
|
162
|
+
if (!e) throw new Error("Canvas WebGL inexistente");
|
|
163
|
+
const t = e.getContext("webgl", { premultipliedAlpha: !1, preserveDrawingBuffer: !0 }) || e.getContext("experimental-webgl");
|
|
164
|
+
if (!t) throw new Error("WebGL no disponible en este navegador");
|
|
165
|
+
return t;
|
|
166
|
+
}
|
|
167
|
+
function K(e, t, r) {
|
|
168
|
+
const o = e.createShader(t);
|
|
169
|
+
if (e.shaderSource(o, r), e.compileShader(o), !e.getShaderParameter(o, e.COMPILE_STATUS)) {
|
|
170
|
+
const n = e.getShaderInfoLog(o);
|
|
171
|
+
throw e.deleteShader(o), new Error(`Shader error: ${n}`);
|
|
172
|
+
}
|
|
173
|
+
return o;
|
|
174
|
+
}
|
|
175
|
+
function he(e, t, r) {
|
|
176
|
+
const o = K(e, e.VERTEX_SHADER, t), n = K(e, e.FRAGMENT_SHADER, r), a = e.createProgram();
|
|
177
|
+
if (e.attachShader(a, o), e.attachShader(a, n), e.linkProgram(a), !e.getProgramParameter(a, e.LINK_STATUS)) {
|
|
178
|
+
const s = e.getProgramInfoLog(a);
|
|
179
|
+
throw e.deleteProgram(a), new Error(`Program link error: ${s}`);
|
|
180
|
+
}
|
|
181
|
+
return a;
|
|
182
|
+
}
|
|
183
|
+
function de(e, t, r, o) {
|
|
184
|
+
const n = e.createTexture();
|
|
185
|
+
return e.bindTexture(e.TEXTURE_2D, n), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !0), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), o ? e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, o) : e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, t, r, 0, e.RGBA, e.UNSIGNED_BYTE, null), n;
|
|
186
|
+
}
|
|
187
|
+
function me(e, t) {
|
|
188
|
+
const r = e.createFramebuffer();
|
|
189
|
+
if (e.bindFramebuffer(e.FRAMEBUFFER, r), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, t, 0), e.checkFramebufferStatus(e.FRAMEBUFFER) !== e.FRAMEBUFFER_COMPLETE)
|
|
190
|
+
throw new Error("FBO incomplete");
|
|
191
|
+
return e.bindFramebuffer(e.FRAMEBUFFER, null), r;
|
|
192
|
+
}
|
|
193
|
+
function H(e, t, r) {
|
|
194
|
+
e.viewport(0, 0, t, r);
|
|
195
|
+
}
|
|
196
|
+
function be(e) {
|
|
197
|
+
const t = e.createBuffer();
|
|
198
|
+
e.bindBuffer(e.ARRAY_BUFFER, t);
|
|
199
|
+
const r = new Float32Array([-1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 1]);
|
|
200
|
+
e.bufferData(e.ARRAY_BUFFER, r, e.STATIC_DRAW);
|
|
201
|
+
const o = e.createBuffer();
|
|
202
|
+
e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, o);
|
|
203
|
+
const n = new Uint16Array([0, 1, 2, 2, 1, 3]);
|
|
204
|
+
return e.bufferData(e.ELEMENT_ARRAY_BUFFER, n, e.STATIC_DRAW), { vbo: t, ibo: o };
|
|
205
|
+
}
|
|
206
|
+
function Z(e) {
|
|
207
|
+
return e === "brightness" ? 1 : e === "spots" ? 2 : e === "acne" ? 3 : e === "firmness" ? 4 : 0;
|
|
208
|
+
}
|
|
209
|
+
const ge = [
|
|
210
|
+
"attribute vec2 a_pos;",
|
|
211
|
+
"attribute vec2 a_uv;",
|
|
212
|
+
"varying vec2 v_uv;",
|
|
213
|
+
"void main() {",
|
|
214
|
+
" v_uv = a_uv;",
|
|
215
|
+
" gl_Position = vec4(a_pos, 0.0, 1.0);",
|
|
216
|
+
"}"
|
|
217
|
+
].join(`
|
|
218
|
+
`), Ee = [
|
|
219
|
+
"precision mediump float;",
|
|
220
|
+
"varying vec2 v_uv;",
|
|
221
|
+
"uniform sampler2D u_tex;",
|
|
222
|
+
"uniform vec2 u_texel;",
|
|
223
|
+
"uniform vec2 u_dir;",
|
|
224
|
+
"uniform float u_sigma;",
|
|
225
|
+
"float gaussian(float x, float s) { return exp(-(x*x)/(2.0*s*s)); }",
|
|
226
|
+
"void main() {",
|
|
227
|
+
" vec2 stepDir = u_dir * u_sigma;",
|
|
228
|
+
" vec4 col = texture2D(u_tex, v_uv) * gaussian(0.0, 1.0);",
|
|
229
|
+
" float wsum = gaussian(0.0, 1.0);",
|
|
230
|
+
" for (int i = 1; i <= 4; i++) {",
|
|
231
|
+
" float f = float(i);",
|
|
232
|
+
" float w = gaussian(f, 1.0);",
|
|
233
|
+
" vec2 off = stepDir * f * u_texel;",
|
|
234
|
+
" col += texture2D(u_tex, v_uv + off) * w;",
|
|
235
|
+
" col += texture2D(u_tex, v_uv - off) * w;",
|
|
236
|
+
" wsum += 2.0 * w;",
|
|
237
|
+
" }",
|
|
238
|
+
" gl_FragColor = col / wsum;",
|
|
239
|
+
"}"
|
|
240
|
+
].join(`
|
|
241
|
+
`), pe = [
|
|
242
|
+
"precision mediump float;",
|
|
243
|
+
"varying vec2 v_uv;",
|
|
244
|
+
"uniform sampler2D u_orig;",
|
|
245
|
+
"uniform sampler2D u_blur;",
|
|
246
|
+
"uniform sampler2D u_mask;",
|
|
247
|
+
"uniform float u_intensity;",
|
|
248
|
+
"uniform float u_brightness;",
|
|
249
|
+
"uniform float u_contrast;",
|
|
250
|
+
"uniform float u_warmthR;",
|
|
251
|
+
"uniform float u_warmthB;",
|
|
252
|
+
"uniform float u_warmthAlpha;",
|
|
253
|
+
"uniform int u_filterType;",
|
|
254
|
+
"void main() {",
|
|
255
|
+
" vec4 o = texture2D(u_orig, v_uv);",
|
|
256
|
+
" vec4 b = texture2D(u_blur, v_uv);",
|
|
257
|
+
" float a = clamp(texture2D(u_mask, v_uv).a, 0.0, 1.0);",
|
|
258
|
+
" float m = a * u_intensity;",
|
|
259
|
+
" vec4 blended = mix(o, b, m);",
|
|
260
|
+
" blended.rgb += u_brightness * a;",
|
|
261
|
+
" blended.rgb = clamp(blended.rgb, 0.0, 1.0);",
|
|
262
|
+
" gl_FragColor = blended;",
|
|
263
|
+
"if (u_filterType == 2) {",
|
|
264
|
+
"vec3 smoothed = mix(o.rgb, b.rgb, m * 0.7);",
|
|
265
|
+
"float origLum = dot(o.rgb, vec3(0.299, 0.587, 0.114));",
|
|
266
|
+
"float smoothLum = dot(smoothed, vec3(0.299, 0.587, 0.114));",
|
|
267
|
+
"float darkness = max(0.0, smoothLum - origLum);",
|
|
268
|
+
"smoothed.rgb += vec3(darkness * 0.4) * m;",
|
|
269
|
+
"float targetLum = dot(smoothed, vec3(0.299, 0.587, 0.114));",
|
|
270
|
+
"vec3 uniformTone = vec3(targetLum * 1.02);",
|
|
271
|
+
"smoothed.rgb = mix(smoothed.rgb, uniformTone, m * 0.35);",
|
|
272
|
+
"float avgChannel = (smoothed.r + smoothed.g + smoothed.b) / 3.0;",
|
|
273
|
+
"smoothed.r = mix(smoothed.r, avgChannel, m * 0.25);",
|
|
274
|
+
"smoothed.g = mix(smoothed.g, avgChannel, m * 0.15);",
|
|
275
|
+
"smoothed.b = mix(smoothed.b, avgChannel, m * 0.15);",
|
|
276
|
+
"float gray = dot(smoothed, vec3(0.299, 0.587, 0.114));",
|
|
277
|
+
"smoothed.rgb = mix(vec3(gray), smoothed.rgb, 0.85);",
|
|
278
|
+
"smoothed.rgb = pow(smoothed.rgb, vec3(0.96));",
|
|
279
|
+
"smoothed.rgb += vec3(0.02) * m;",
|
|
280
|
+
"float finalGray = dot(smoothed, vec3(0.299, 0.587, 0.114));",
|
|
281
|
+
"finalGray = pow(finalGray, 0.88);",
|
|
282
|
+
"blended.rgb = vec3(finalGray);",
|
|
283
|
+
"blended.rgb = clamp(blended.rgb, 0.0, 1.0);",
|
|
284
|
+
"}",
|
|
285
|
+
"if (u_filterType == 3) {",
|
|
286
|
+
"float origLum = dot(o.rgb, vec3(0.299, 0.587, 0.114));",
|
|
287
|
+
"float blurLum = dot(b.rgb, vec3(0.299, 0.587, 0.114));",
|
|
288
|
+
"float detail = origLum - blurLum;",
|
|
289
|
+
"vec3 smoothed = mix(o.rgb, b.rgb, m * 0.85);",
|
|
290
|
+
"float detailAmount = 0.25 * (1.0 - m * 0.5);",
|
|
291
|
+
"smoothed.rgb += detail * detailAmount * sign(detail);",
|
|
292
|
+
"float avgColor = (smoothed.r + smoothed.g + smoothed.b) / 3.0;",
|
|
293
|
+
"smoothed.r = mix(smoothed.r, avgColor, m * 0.35);",
|
|
294
|
+
"smoothed.g = mix(smoothed.g, avgColor, m * 0.15);",
|
|
295
|
+
"smoothed.b = mix(smoothed.b, avgColor, m * 0.1);",
|
|
296
|
+
"smoothed.rgb = mix(smoothed.rgb, vec3(blurLum), m * 0.2);",
|
|
297
|
+
"smoothed.rgb += vec3(0.05) * m;",
|
|
298
|
+
"blended.rgb = clamp(smoothed, 0.0, 1.0);",
|
|
299
|
+
"vec2 texelSize = vec2(1.0) / vec2(1024.0, 1024.0);",
|
|
300
|
+
"vec3 avgNeighbor = vec3(0.0);",
|
|
301
|
+
"float weightSum = 0.0;",
|
|
302
|
+
"for(int dx = -1; dx <= 1; dx++) {",
|
|
303
|
+
"for(int dy = -1; dy <= 1; dy++) {",
|
|
304
|
+
"vec2 offset = vec2(float(dx), float(dy)) * texelSize * 2.0;",
|
|
305
|
+
"vec3 neighbor = texture2D(u_blur, v_uv + offset).rgb;",
|
|
306
|
+
"float colorDiff = length(neighbor - blended.rgb);",
|
|
307
|
+
"float weight = exp(-colorDiff * 5.0) * a;",
|
|
308
|
+
"avgNeighbor += neighbor * weight;",
|
|
309
|
+
"weightSum += weight;",
|
|
310
|
+
"}",
|
|
311
|
+
"}",
|
|
312
|
+
"if(weightSum > 0.01) {",
|
|
313
|
+
"vec3 bilateralSmooth = avgNeighbor / weightSum;",
|
|
314
|
+
"blended.rgb = mix(blended.rgb, bilateralSmooth, m * 0.3);",
|
|
315
|
+
"}",
|
|
316
|
+
"}",
|
|
317
|
+
"if (u_filterType == 4) {",
|
|
318
|
+
"float lift = 0.02 * u_intensity;",
|
|
319
|
+
"vec2 off = vec2(0.0, -lift);",
|
|
320
|
+
"vec4 lifted = texture2D(u_orig, v_uv + off * a);",
|
|
321
|
+
"blended.rgb = mix(blended.rgb, lifted.rgb, 0.5 * m);",
|
|
322
|
+
"blended.rgb = pow(blended.rgb, vec3(1.0/(1.0 - 0.06 * u_intensity)));",
|
|
323
|
+
"blended.rgb += vec3(0.02 * u_intensity * a);",
|
|
324
|
+
"blended.rgb = clamp(blended.rgb, 0.0, 1.0);",
|
|
325
|
+
"}",
|
|
326
|
+
"blended.rgb = ((blended.rgb - 0.5) * u_contrast) + 0.5;",
|
|
327
|
+
"vec3 warm = blended.rgb;",
|
|
328
|
+
"warm.r += u_warmthR / 255.0;",
|
|
329
|
+
"warm.b = max(0.0, warm.b - (u_warmthB / 255.0));",
|
|
330
|
+
"blended.rgb = mix(blended.rgb, clamp(warm, 0.0, 1.0), u_warmthAlpha);",
|
|
331
|
+
"gl_FragColor = blended;",
|
|
332
|
+
"}"
|
|
333
|
+
].join(`
|
|
334
|
+
`);
|
|
335
|
+
function X(e, t, r, o, n, a = "Error aplicando escala de grises") {
|
|
336
|
+
try {
|
|
337
|
+
const s = e.getImageData(t, r, o, n), i = s.data;
|
|
338
|
+
for (let c = 0; c < i.length; c += 4) {
|
|
339
|
+
const m = 0.299 * i[c] + 0.587 * i[c + 1] + 0.114 * i[c + 2];
|
|
340
|
+
i[c] = m, i[c + 1] = m, i[c + 2] = m;
|
|
341
|
+
}
|
|
342
|
+
e.putImageData(s, t, r);
|
|
343
|
+
} catch (s) {
|
|
344
|
+
console.error(a, s);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
function z(e, t, r, o = {}) {
|
|
348
|
+
const { isLicenseActive: n = !1, isDisplayMirrored: a = !1 } = o;
|
|
349
|
+
if (n || !e || !t || !r) return;
|
|
350
|
+
e.save(), a && (e.translate(t, 0), e.scale(-1, 1)), e.globalAlpha = 0.18, e.fillStyle = "#ffffff", e.font = `bold ${Math.max(16, Math.round(t * 0.035))}px sans-serif`, e.textAlign = "center", e.textBaseline = "middle", e.translate(t / 2, r / 2), e.rotate(-Math.PI / 7);
|
|
351
|
+
const s = Math.max(180, Math.round(t * 0.35)), i = Math.max(110, Math.round(r * 0.22));
|
|
352
|
+
for (let m = -r; m <= r; m += i)
|
|
353
|
+
for (let d = -t; d <= t; d += s)
|
|
354
|
+
e.fillText("ACTIVA LA LICENCIA", d, m);
|
|
355
|
+
e.rotate(Math.PI / 7), e.translate(-t / 2, -r / 2);
|
|
356
|
+
const c = Math.max(64, Math.round(r * 0.14));
|
|
357
|
+
e.globalAlpha = 0.78, e.fillStyle = "rgba(0, 0, 0, 0.55)", e.fillRect(0, r - c, t, c), e.globalAlpha = 0.95, e.fillStyle = "#ffffff", e.font = `bold ${Math.max(22, Math.round(t * 0.055))}px sans-serif`, e.fillText("ACTIVA LA LICENCIA", t / 2, r - c / 2), e.restore();
|
|
358
|
+
}
|
|
359
|
+
function J(e, t, r) {
|
|
360
|
+
const o = e.getAttribLocation(t, "a_pos"), n = e.getAttribLocation(t, "a_uv");
|
|
361
|
+
e.bindBuffer(e.ARRAY_BUFFER, r.vbo), e.enableVertexAttribArray(o), e.enableVertexAttribArray(n), e.vertexAttribPointer(o, 2, e.FLOAT, !1, 16, 0), e.vertexAttribPointer(n, 2, e.FLOAT, !1, 16, 8), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, r.ibo);
|
|
362
|
+
}
|
|
363
|
+
function $(e, t, r, o) {
|
|
364
|
+
e.bindFramebuffer(e.FRAMEBUFFER, t), H(e, r, o), e.clearColor(0, 0, 0, 0), e.clear(e.COLOR_BUFFER_BIT), e.drawElements(e.TRIANGLES, 6, e.UNSIGNED_SHORT, 0);
|
|
365
|
+
}
|
|
366
|
+
function we({
|
|
367
|
+
gl: e,
|
|
368
|
+
image: t,
|
|
369
|
+
imgSize: r,
|
|
370
|
+
programs: o,
|
|
371
|
+
quad: n,
|
|
372
|
+
textures: a,
|
|
373
|
+
framebuffers: s,
|
|
374
|
+
params: i,
|
|
375
|
+
canvases: c,
|
|
376
|
+
callbacks: m = {}
|
|
377
|
+
}) {
|
|
378
|
+
if (!e || !t) {
|
|
379
|
+
const b = c == null ? void 0 : c.outCanvas;
|
|
380
|
+
if (b && t) {
|
|
381
|
+
const _ = b.getContext("2d"), L = r == null ? void 0 : r.w, W = r == null ? void 0 : r.h;
|
|
382
|
+
_ && L && W && (_.clearRect(0, 0, L, W), _.drawImage(t, 0, 0, L, W));
|
|
383
|
+
}
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
const d = r == null ? void 0 : r.w, h = r == null ? void 0 : r.h;
|
|
387
|
+
if (!d || !h) return;
|
|
388
|
+
e.useProgram(o.blur), J(e, o.blur, n);
|
|
389
|
+
const U = e.getUniformLocation(o.blur, "u_texel"), P = e.getUniformLocation(o.blur, "u_dir"), M = e.getUniformLocation(o.blur, "u_sigma"), D = e.getUniformLocation(o.blur, "u_tex");
|
|
390
|
+
e.activeTexture(e.TEXTURE0), e.bindTexture(e.TEXTURE_2D, a.orig), e.uniform1i(D, 0), e.uniform2f(U, 1 / d, 1 / h), e.uniform2f(P, 1, 0), e.uniform1f(M, i.sigma), $(e, s.ping, d, h), e.activeTexture(e.TEXTURE0), e.bindTexture(e.TEXTURE_2D, a.ping), e.uniform1i(D, 0), e.uniform2f(U, 1 / d, 1 / h), e.uniform2f(P, 0, 1), e.uniform1f(M, i.sigma), $(e, s.pong, d, h), e.useProgram(o.compose), J(e, o.compose, n);
|
|
391
|
+
const T = e.getUniformLocation(o.compose, "u_orig"), w = e.getUniformLocation(o.compose, "u_blur"), g = e.getUniformLocation(o.compose, "u_mask"), E = e.getUniformLocation(o.compose, "u_intensity"), v = e.getUniformLocation(o.compose, "u_brightness"), A = e.getUniformLocation(o.compose, "u_contrast"), C = e.getUniformLocation(o.compose, "u_warmthR"), R = e.getUniformLocation(o.compose, "u_warmthB"), y = e.getUniformLocation(o.compose, "u_warmthAlpha"), S = e.getUniformLocation(o.compose, "u_filterType");
|
|
392
|
+
e.activeTexture(e.TEXTURE0), e.bindTexture(e.TEXTURE_2D, a.orig), e.uniform1i(T, 0), e.activeTexture(e.TEXTURE1), e.bindTexture(e.TEXTURE_2D, a.pong), e.uniform1i(w, 1), e.activeTexture(e.TEXTURE2), e.bindTexture(e.TEXTURE_2D, a.mask), e.uniform1i(g, 2), e.uniform1f(E, i.intensity), e.uniform1f(v, i.brightness), e.uniform1f(A, i.contrast), e.uniform1f(C, i.warmthR), e.uniform1f(R, i.warmthB), e.uniform1f(y, i.warmthA), e.uniform1i(S, Z(i.filterType)), typeof m.onConfigApplied == "function" && m.onConfigApplied({
|
|
393
|
+
intensity: i.intensity,
|
|
394
|
+
sigma: i.sigma,
|
|
395
|
+
brightness: i.brightness,
|
|
396
|
+
contrast: i.contrast,
|
|
397
|
+
warmthR: i.warmthR,
|
|
398
|
+
warmthB: i.warmthB,
|
|
399
|
+
warmthA: i.warmthA,
|
|
400
|
+
filterType: i.filterType
|
|
401
|
+
}), e.bindFramebuffer(e.FRAMEBUFFER, null), H(e, d, h), e.clearColor(0, 0, 0, 0), e.clear(e.COLOR_BUFFER_BIT), e.drawElements(e.TRIANGLES, 6, e.UNSIGNED_SHORT, 0);
|
|
402
|
+
const I = c.glCanvas, B = c.outCanvas, V = c.maskCanvas, u = B && B.getContext("2d");
|
|
403
|
+
if (u) {
|
|
404
|
+
if (e.finish(), u.clearRect(0, 0, d, h), i.view === "before")
|
|
405
|
+
u.drawImage(t, 0, 0, d, h), i.filterType === "spots" && X(u, 0, 0, d, h, 'Error aplicando escala de grises en "antes":');
|
|
406
|
+
else if (i.view === "after")
|
|
407
|
+
!!I && I.width && I.height ? u.drawImage(I, 0, 0, d, h) : u.drawImage(t, 0, 0, d, h);
|
|
408
|
+
else if (i.view === "mask")
|
|
409
|
+
u.fillStyle = "#000000", u.fillRect(0, 0, d, h), u.drawImage(V, 0, 0, d, h);
|
|
410
|
+
else {
|
|
411
|
+
const b = Math.max(0, Math.min(1, i.splitPos)) * d;
|
|
412
|
+
if (i.mirrored) {
|
|
413
|
+
b > 0 && u.drawImage(I, 0, 0, b, h, 0, 0, b, h);
|
|
414
|
+
const _ = d - b;
|
|
415
|
+
_ > 0 && (u.drawImage(t, b, 0, _, h, b, 0, _, h), i.filterType === "spots" && X(
|
|
416
|
+
u,
|
|
417
|
+
b,
|
|
418
|
+
0,
|
|
419
|
+
_,
|
|
420
|
+
h,
|
|
421
|
+
"Error aplicando B&N en split derecha (mirrored):"
|
|
422
|
+
));
|
|
423
|
+
} else {
|
|
424
|
+
b > 0 && (u.drawImage(t, 0, 0, b, h, 0, 0, b, h), i.filterType === "spots" && X(u, 0, 0, b, h, "Error aplicando B&N en split izquierda:"));
|
|
425
|
+
const _ = d - b;
|
|
426
|
+
_ > 0 && u.drawImage(I, b, 0, _, h, b, 0, _, h);
|
|
427
|
+
}
|
|
428
|
+
u.save(), u.strokeStyle = "rgba(255,255,255,0.9)", u.lineWidth = 2, u.beginPath(), u.moveTo(Math.floor(b), 0), u.lineTo(Math.floor(b), h), u.stroke(), u.fillStyle = "rgba(0,0,0,0.15)", u.beginPath(), u.arc(Math.floor(b) + 2, h / 2 + 2, 14, 0, Math.PI * 2), u.fill(), u.fillStyle = "#ffffff", u.beginPath(), u.arc(Math.floor(b), h / 2, 14, 0, Math.PI * 2), u.fill(), u.strokeStyle = "rgba(0,0,0,0.25)", u.lineWidth = 1, u.beginPath(), u.arc(Math.floor(b), h / 2, 14, 0, Math.PI * 2), u.stroke(), u.restore();
|
|
429
|
+
}
|
|
430
|
+
if (z(u, d, h, {
|
|
431
|
+
isLicenseActive: !!i.isLicenseActive,
|
|
432
|
+
isDisplayMirrored: !!i.isDisplayMirrored
|
|
433
|
+
}), typeof m.onProcessed == "function" && B) {
|
|
434
|
+
const b = B.toDataURL("image/jpeg", 0.92);
|
|
435
|
+
b && m.onProcessed(b);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
function ye(e) {
|
|
440
|
+
const t = j(null);
|
|
441
|
+
return k(() => {
|
|
442
|
+
let r = !1;
|
|
443
|
+
try {
|
|
444
|
+
if (t.current) return;
|
|
445
|
+
ue().then((o) => {
|
|
446
|
+
r || (t.current = o);
|
|
447
|
+
}).catch((o) => {
|
|
448
|
+
r || (console.warn("[md-face-engine] Landmark detector unavailable, using fallback mask.", o), t.current = null, typeof e == "function" && e(""));
|
|
449
|
+
});
|
|
450
|
+
} catch (o) {
|
|
451
|
+
console.warn("[md-face-engine] Landmark detector init failed, using fallback mask.", o), t.current = null, typeof e == "function" && e("");
|
|
452
|
+
}
|
|
453
|
+
return () => {
|
|
454
|
+
r = !0;
|
|
455
|
+
};
|
|
456
|
+
}, [e]), t;
|
|
457
|
+
}
|
|
458
|
+
const f = {
|
|
459
|
+
rightEyeUpper: [246, 161, 160, 159, 158, 157, 173],
|
|
460
|
+
rightEyeLower: [33, 7, 163, 144, 145, 153, 154, 155, 133],
|
|
461
|
+
leftEyeUpper: [466, 388, 387, 386, 385, 384, 398],
|
|
462
|
+
leftEyeLower: [263, 249, 390, 373, 374, 380, 381, 382, 362],
|
|
463
|
+
rightEyebrow: [70, 63, 105, 66, 107, 55, 65],
|
|
464
|
+
leftEyebrow: [300, 293, 334, 296, 336, 285, 295],
|
|
465
|
+
lipOutline: [61, 146, 91, 181, 84, 17, 314, 405, 321, 375, 291, 409, 270, 269, 267, 0, 37, 39, 40, 185],
|
|
466
|
+
faceOval: [10, 338, 297, 332, 284, 251, 389, 356, 454, 323, 361, 288, 397, 365, 379, 378, 400, 377, 152, 148, 176, 149, 150, 136, 172, 58, 132, 93, 234, 127, 162, 21, 54, 103, 67, 109],
|
|
467
|
+
forehead: [10, 338, 297, 332, 284, 251, 389, 356, 70, 63, 105, 66, 107, 336, 296, 334, 293, 300],
|
|
468
|
+
rightCheek: [50, 101, 100, 47, 117, 118, 119, 120, 121, 128, 129],
|
|
469
|
+
leftCheek: [280, 330, 329, 277, 346, 347, 348, 349, 350, 357, 358],
|
|
470
|
+
rightNasolabial: [36, 142, 126, 217, 174],
|
|
471
|
+
leftNasolabial: [266, 371, 355, 437, 399]
|
|
472
|
+
};
|
|
473
|
+
function O(e, t) {
|
|
474
|
+
let r = 0, o = 0;
|
|
475
|
+
return t.forEach((n) => {
|
|
476
|
+
r += e[n][0], o += e[n][1];
|
|
477
|
+
}), [r / t.length, o / t.length];
|
|
478
|
+
}
|
|
479
|
+
function N(e, t) {
|
|
480
|
+
let r = 1 / 0, o = 1 / 0, n = -1 / 0, a = -1 / 0;
|
|
481
|
+
return t.forEach((s) => {
|
|
482
|
+
const [i, c] = e[s];
|
|
483
|
+
r = Math.min(r, i), o = Math.min(o, c), n = Math.max(n, i), a = Math.max(a, c);
|
|
484
|
+
}), { x: r, y: o, width: n - r, height: a - o };
|
|
485
|
+
}
|
|
486
|
+
function l(e, t, r, o = 0.8, n = 1.5) {
|
|
487
|
+
const a = N(t, r), s = O(t, r), i = a.width * n, c = a.height * n, m = Math.max(i, c);
|
|
488
|
+
e.save(), e.translate(s[0], s[1]), e.scale(i / m, c / m);
|
|
489
|
+
const d = e.createRadialGradient(0, 0, m * 0.2, 0, 0, m);
|
|
490
|
+
d.addColorStop(0, `rgba(255, 255, 255, ${o})`), d.addColorStop(0.6, `rgba(255, 255, 255, ${o * 0.7})`), d.addColorStop(0.85, `rgba(255, 255, 255, ${o * 0.3})`), d.addColorStop(1, "rgba(255, 255, 255, 0)"), e.fillStyle = d, e.beginPath(), e.arc(0, 0, m, 0, Math.PI * 2), e.fill(), e.restore();
|
|
491
|
+
}
|
|
492
|
+
function p(e, t, r) {
|
|
493
|
+
e.globalCompositeOperation = "destination-out", e.beginPath(), r.forEach((o, n) => {
|
|
494
|
+
const [a, s] = t[o];
|
|
495
|
+
n === 0 ? e.moveTo(a, s) : e.lineTo(a, s);
|
|
496
|
+
}), e.closePath(), e.fillStyle = "rgba(255, 255, 255, 1)", e.fill(), e.globalCompositeOperation = "source-over";
|
|
497
|
+
}
|
|
498
|
+
function ee(e, t) {
|
|
499
|
+
e.globalCompositeOperation = "source-over", l(e, t, f.forehead, 0.85, 1.3), l(e, t, [6, 197, 195, 5, 168, 8, 9], 0.75, 1), l(e, t, [33, 133, 155, 154, 153, 145, 144, 163], 0.8, 1.4), l(e, t, [263, 362, 382, 381, 380, 374, 373, 390], 0.8, 1.4), l(e, t, [133, 155, 154, 153, 145, 144, 163, 7], 0.7, 1.2), l(e, t, [362, 382, 381, 380, 374, 373, 390, 249], 0.7, 1.2), l(e, t, f.rightNasolabial, 0.75, 1.5), l(e, t, f.leftNasolabial, 0.75, 1.5), l(e, t, [2, 98, 97, 99, 75, 60, 20, 242, 97, 98, 2, 327, 326, 328, 305, 290, 250, 462, 1, 10, 164, 393], 0.85, 1.4), l(e, t, [61, 146, 91, 181, 84, 17, 314, 405, 321, 375], 0.85, 1.6), l(e, t, [152, 377, 400, 378, 379, 365, 397, 288, 361], 0.65, 1.3), p(e, t, f.rightEyeUpper.concat(f.rightEyeLower)), p(e, t, f.leftEyeUpper.concat(f.leftEyeLower)), p(e, t, f.rightEyebrow), p(e, t, f.leftEyebrow), p(e, t, f.lipOutline);
|
|
500
|
+
}
|
|
501
|
+
function te(e, t) {
|
|
502
|
+
const r = O(t, f.faceOval), o = N(t, f.faceOval), n = o.width * 0.6, a = o.height * 0.7, s = Math.max(n, a);
|
|
503
|
+
e.save(), e.translate(r[0], r[1]), e.scale(n / s, a / s);
|
|
504
|
+
const i = e.createRadialGradient(0, 0, s * 0.3, 0, 0, s);
|
|
505
|
+
i.addColorStop(0, "rgba(255, 255, 255, 1)"), i.addColorStop(0.5, "rgba(255, 255, 255, 1)"), i.addColorStop(0.75, "rgba(255, 255, 255, 0.85)"), i.addColorStop(0.9, "rgba(255, 255, 255, 0.5)"), i.addColorStop(0.97, "rgba(255, 255, 255, 0.2)"), i.addColorStop(1, "rgba(255, 255, 255, 0)"), e.fillStyle = i, e.beginPath(), e.arc(0, 0, s, 0, Math.PI * 2), e.fill(), e.restore();
|
|
506
|
+
}
|
|
507
|
+
function re(e, t) {
|
|
508
|
+
const r = O(t, f.faceOval), o = N(t, f.faceOval), n = o.width * 0.72, a = o.height * 0.82, s = Math.max(n, a);
|
|
509
|
+
e.save(), e.translate(r[0], r[1]), e.scale(n / s, a / s);
|
|
510
|
+
const i = e.createRadialGradient(0, 0, s * 0.1, 0, 0, s);
|
|
511
|
+
i.addColorStop(0, "rgba(255, 255, 255, 0.95)"), i.addColorStop(0.6, "rgba(255, 255, 255, 0.92)"), i.addColorStop(0.8, "rgba(255, 255, 255, 0.7)"), i.addColorStop(0.92, "rgba(255, 255, 255, 0.4)"), i.addColorStop(1, "rgba(255, 255, 255, 0)"), e.fillStyle = i, e.beginPath(), e.arc(0, 0, s, 0, Math.PI * 2), e.fill(), e.restore(), l(e, t, f.forehead, 0.95, 1.3), l(e, t, f.rightCheek, 0.95, 1.4), l(e, t, f.leftCheek, 0.95, 1.4), l(e, t, [2, 98, 97, 99, 75, 60, 20, 242, 327, 326, 328, 305, 290, 250, 462], 0.9, 1.2), l(e, t, [205, 206, 207, 187, 123, 116, 111], 0.92, 1.2), l(e, t, [425, 426, 427, 411, 352, 345, 340], 0.92, 1.2), p(e, t, f.rightEyeUpper.concat(f.rightEyeLower)), p(e, t, f.leftEyeUpper.concat(f.leftEyeLower)), p(e, t, f.rightEyebrow), p(e, t, f.leftEyebrow), p(e, t, [61, 185, 40, 39, 37, 0, 267, 269, 270, 409, 291, 146, 91, 181, 84, 17, 314, 405, 321, 375]);
|
|
512
|
+
}
|
|
513
|
+
function oe(e, t) {
|
|
514
|
+
const r = O(t, f.faceOval), o = N(t, f.faceOval), n = o.width * 0.75, a = o.height * 0.85, s = Math.max(n, a);
|
|
515
|
+
e.save(), e.translate(r[0], r[1]), e.scale(n / s, a / s);
|
|
516
|
+
const i = e.createRadialGradient(0, 0, s * 0.15, 0, 0, s);
|
|
517
|
+
i.addColorStop(0, "rgba(255, 255, 255, 1)"), i.addColorStop(0.5, "rgba(255, 255, 255, 0.98)"), i.addColorStop(0.7, "rgba(255, 255, 255, 0.92)"), i.addColorStop(0.85, "rgba(255, 255, 255, 0.6)"), i.addColorStop(0.95, "rgba(255, 255, 255, 0.3)"), i.addColorStop(1, "rgba(255, 255, 255, 0)"), e.fillStyle = i, e.beginPath(), e.arc(0, 0, s, 0, Math.PI * 2), e.fill(), e.restore(), l(e, t, f.forehead, 1, 1.4), l(e, t, f.rightCheek, 1, 1.5), l(e, t, f.leftCheek, 1, 1.5), l(e, t, [6, 197, 195, 5, 4, 1, 19, 94, 2], 0.98, 1.3), l(e, t, [152, 377, 400, 378, 379, 365, 397, 288, 361, 323, 454, 93], 0.98, 1.4), l(e, t, [8, 9, 168, 6, 197, 195, 5], 0.95, 1), l(e, t, [218, 126, 142, 36, 205, 206], 0.95, 1.2), l(e, t, [438, 355, 371, 266, 425, 426], 0.95, 1.2), p(e, t, f.rightEyeUpper.concat(f.rightEyeLower)), p(e, t, f.leftEyeUpper.concat(f.leftEyeLower)), p(e, t, f.rightEyebrow), p(e, t, f.leftEyebrow), p(e, t, [61, 185, 40, 39, 37, 0, 267, 269, 270, 409, 291, 146, 91, 181, 84, 17, 314, 405, 321, 375]);
|
|
518
|
+
}
|
|
519
|
+
function ie(e, t) {
|
|
520
|
+
l(e, t, f.rightCheek, 0.95, 1.4), l(e, t, f.leftCheek, 0.95, 1.4), l(e, t, f.rightEyeUpper.concat([70, 63, 105, 66, 107]), 0.9, 1.1), l(e, t, f.leftEyeUpper.concat([300, 293, 334, 296, 336]), 0.9, 1.1), l(e, t, f.rightNasolabial, 0.8, 1.3), l(e, t, f.leftNasolabial, 0.8, 1.3), l(e, t, [205, 206, 207, 187, 123], 0.85, 1), l(e, t, [425, 426, 427, 411, 352], 0.85, 1), l(e, t, [172, 136, 150, 149, 176, 148], 0.75, 1.2), l(e, t, [397, 365, 379, 378, 400, 377], 0.75, 1.2), p(e, t, f.rightEyeUpper.concat(f.rightEyeLower)), p(e, t, f.leftEyeUpper.concat(f.leftEyeLower));
|
|
521
|
+
}
|
|
522
|
+
function ve({
|
|
523
|
+
image: e,
|
|
524
|
+
faceMeshRef: t,
|
|
525
|
+
maskCanvasRef: r,
|
|
526
|
+
filterType: o,
|
|
527
|
+
syncMaskToGPU: n,
|
|
528
|
+
renderGL: a,
|
|
529
|
+
minimal: s,
|
|
530
|
+
forceAfter: i,
|
|
531
|
+
setView: c,
|
|
532
|
+
setProcessing: m
|
|
533
|
+
}) {
|
|
534
|
+
const [d, h] = x(!1), [U, P] = x(!1), M = Y(
|
|
535
|
+
async (T) => new Promise((w, g) => {
|
|
536
|
+
const E = t.current;
|
|
537
|
+
if (!E) {
|
|
538
|
+
g(new Error("FaceMesh no inicializado"));
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
if (typeof E.onResults != "function" || typeof E.send != "function") {
|
|
542
|
+
g(new Error("FaceMesh inválido"));
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const v = document.createElement("canvas");
|
|
546
|
+
v.width = T.width, v.height = T.height;
|
|
547
|
+
const A = v.getContext("2d");
|
|
548
|
+
if (!A) {
|
|
549
|
+
g(new Error("No se pudo crear contexto temporal"));
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
A.drawImage(T, 0, 0);
|
|
553
|
+
let C = !1;
|
|
554
|
+
const R = window.setTimeout(() => {
|
|
555
|
+
C || (C = !0, g(new Error("Timeout en detección facial")));
|
|
556
|
+
}, 1800);
|
|
557
|
+
E.onResults((y) => {
|
|
558
|
+
C || (C = !0, window.clearTimeout(R), w(y));
|
|
559
|
+
}), Promise.resolve(E.send({ image: v })).catch((y) => {
|
|
560
|
+
C || (C = !0, window.clearTimeout(R), g(y));
|
|
561
|
+
});
|
|
562
|
+
}),
|
|
563
|
+
[t]
|
|
564
|
+
), D = Y(
|
|
565
|
+
async (T = 0) => {
|
|
566
|
+
if (!e) {
|
|
567
|
+
m(!1);
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
if (!t.current) {
|
|
571
|
+
try {
|
|
572
|
+
const w = r.current;
|
|
573
|
+
if (!w) {
|
|
574
|
+
m(!1);
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
const g = w.getContext("2d");
|
|
578
|
+
if (!g) {
|
|
579
|
+
m(!1);
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
g.clearRect(0, 0, w.width, w.height), g.fillStyle = "rgba(255,255,255,1)", g.fillRect(0, 0, w.width, w.height), n(), a();
|
|
583
|
+
} finally {
|
|
584
|
+
m(!1);
|
|
585
|
+
}
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
h(!0), m(!0);
|
|
589
|
+
try {
|
|
590
|
+
const w = await M(e);
|
|
591
|
+
if (!w.multiFaceLandmarks || w.multiFaceLandmarks.length === 0) {
|
|
592
|
+
if (T < 2) {
|
|
593
|
+
setTimeout(() => {
|
|
594
|
+
D(T + 1);
|
|
595
|
+
}, 500);
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
const y = r.current, S = y && y.getContext("2d");
|
|
599
|
+
S && (S.clearRect(0, 0, y.width, y.height), S.fillStyle = "rgba(255,255,255,1)", S.fillRect(0, 0, y.width, y.height)), n(), a();
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
const g = w.multiFaceLandmarks[0], E = r.current, v = E.getContext("2d");
|
|
603
|
+
v.clearRect(0, 0, E.width, E.height);
|
|
604
|
+
const A = E.width, C = E.height, R = g.map((y) => [y.x * A, y.y * C]);
|
|
605
|
+
o === "wrinkles" ? ee(v, R) : o === "firmness" ? ie(v, R) : o === "brightness" ? te(v, R) : o === "spots" ? re(v, R) : o === "acne" && oe(v, R), n(), !s && !i && c("split"), a(), P(!0);
|
|
606
|
+
} catch (w) {
|
|
607
|
+
console.error("Error en detección:", w);
|
|
608
|
+
const g = r.current, E = g && g.getContext("2d");
|
|
609
|
+
E && (E.clearRect(0, 0, g.width, g.height), E.fillStyle = "rgba(255,255,255,1)", E.fillRect(0, 0, g.width, g.height)), n(), a();
|
|
610
|
+
} finally {
|
|
611
|
+
h(!1), m(!1);
|
|
612
|
+
}
|
|
613
|
+
},
|
|
614
|
+
[
|
|
615
|
+
M,
|
|
616
|
+
t,
|
|
617
|
+
o,
|
|
618
|
+
i,
|
|
619
|
+
e,
|
|
620
|
+
r,
|
|
621
|
+
s,
|
|
622
|
+
a,
|
|
623
|
+
m,
|
|
624
|
+
c,
|
|
625
|
+
n
|
|
626
|
+
]
|
|
627
|
+
);
|
|
628
|
+
return { detectAndMaskFace: D, detectingFace: d, faceDetected: U };
|
|
629
|
+
}
|
|
630
|
+
function _e(e) {
|
|
631
|
+
const t = F.getProductConfig(e.id) || {}, r = e.filterType || t.webglConfig && t.webglConfig.filterType || "custom", o = e.defaultWebglConfig || {}, n = {
|
|
632
|
+
filterType: r,
|
|
633
|
+
intensity: e.defaultIntensity !== void 0 ? e.defaultIntensity : o.intensity ?? 0.5,
|
|
634
|
+
sigma: e.defaultSigma !== void 0 ? e.defaultSigma : o.sigma ?? 4,
|
|
635
|
+
brightness: e.defaultBrightness !== void 0 ? e.defaultBrightness : o.brightness ?? 0,
|
|
636
|
+
contrast: o.contrast ?? 1,
|
|
637
|
+
warmthR: o.warmthR ?? 0,
|
|
638
|
+
warmthB: o.warmthB ?? 0,
|
|
639
|
+
warmthA: o.warmthA ?? 0
|
|
640
|
+
}, a = t.webglConfig || {};
|
|
641
|
+
return { ...n, ...a, filterType: r };
|
|
642
|
+
}
|
|
643
|
+
const G = {
|
|
644
|
+
base: {
|
|
645
|
+
key: "base",
|
|
646
|
+
label: "Base",
|
|
647
|
+
defaults: { intensity: 0.5, sigma: 4, brightness: 0, contrast: 1, warmthR: 0, warmthB: 0, warmthA: 0 },
|
|
648
|
+
deep: {}
|
|
649
|
+
}
|
|
650
|
+
}, ne = ["base"];
|
|
651
|
+
function ae(e) {
|
|
652
|
+
return G[e] || null;
|
|
653
|
+
}
|
|
654
|
+
function se(e = {}) {
|
|
655
|
+
var a;
|
|
656
|
+
const t = F.getProductConfig(e.id) || {}, r = e.filterType || ((a = t.webglConfig) == null ? void 0 : a.filterType) || "custom", o = e.defaultWebglConfig || G.base.defaults, n = t.webglConfig || {};
|
|
657
|
+
return {
|
|
658
|
+
filterType: r,
|
|
659
|
+
intensity: e.defaultIntensity !== void 0 ? e.defaultIntensity : o.intensity ?? 0.5,
|
|
660
|
+
sigma: e.defaultSigma !== void 0 ? e.defaultSigma : o.sigma ?? 4,
|
|
661
|
+
brightness: e.defaultBrightness !== void 0 ? e.defaultBrightness : o.brightness ?? 0,
|
|
662
|
+
contrast: o.contrast ?? 1,
|
|
663
|
+
warmthR: o.warmthR ?? 0,
|
|
664
|
+
warmthB: o.warmthB ?? 0,
|
|
665
|
+
warmthA: o.warmthA ?? 0,
|
|
666
|
+
...n,
|
|
667
|
+
filterType: r
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
async function fe({ token: e, products: t = [] } = {}) {
|
|
671
|
+
if (!e)
|
|
672
|
+
throw new Error("Falta token de licencia para activar md-face-engine.");
|
|
673
|
+
const { default: r } = await import("./MartidermEngine-B8TASQtz.js"), o = new r();
|
|
674
|
+
await o.activate(e), o.assertActivated();
|
|
675
|
+
const n = o.getFilterConfigManager();
|
|
676
|
+
return Array.isArray(t) && n.setProducts(t), {
|
|
677
|
+
engine: o,
|
|
678
|
+
FILTERS: o.getFilterRegistry(),
|
|
679
|
+
FILTER_ORDER: o.getFilterOrder(),
|
|
680
|
+
getFilter: (a) => o.getFilter(a),
|
|
681
|
+
filterConfigManager: n,
|
|
682
|
+
buildWebglConfigForProduct: (a) => o.buildWebglConfigForProduct(a)
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
async function Ce({ token: e, products: t = [] } = {}) {
|
|
686
|
+
let r = null, o = null, n = !1;
|
|
687
|
+
if (e)
|
|
688
|
+
try {
|
|
689
|
+
r = await fe({ token: e, products: t }), n = !0;
|
|
690
|
+
} catch (a) {
|
|
691
|
+
o = a, n = !1;
|
|
692
|
+
}
|
|
693
|
+
return !r && Array.isArray(t) && typeof (F == null ? void 0 : F.setProducts) == "function" && F.setProducts(t), {
|
|
694
|
+
engine: (r == null ? void 0 : r.engine) || null,
|
|
695
|
+
FILTERS: (r == null ? void 0 : r.FILTERS) || G,
|
|
696
|
+
FILTER_ORDER: (r == null ? void 0 : r.FILTER_ORDER) || ne,
|
|
697
|
+
getFilter: (r == null ? void 0 : r.getFilter) || ae,
|
|
698
|
+
filterConfigManager: (r == null ? void 0 : r.filterConfigManager) || F,
|
|
699
|
+
buildWebglConfigForProduct: (r == null ? void 0 : r.buildWebglConfigForProduct) || se,
|
|
700
|
+
license: {
|
|
701
|
+
active: n,
|
|
702
|
+
error: o,
|
|
703
|
+
mode: n ? "licensed" : "unlicensed"
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
async function ue(e = {}) {
|
|
708
|
+
const t = e.locateFile || ((a) => `https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh@0.4.1633559619/${a}`), r = {
|
|
709
|
+
maxNumFaces: 1,
|
|
710
|
+
refineLandmarks: !0,
|
|
711
|
+
minDetectionConfidence: 0.5,
|
|
712
|
+
minTrackingConfidence: 0.5,
|
|
713
|
+
...e.detectorOptions || {}
|
|
714
|
+
};
|
|
715
|
+
let o = typeof window < "u" ? window.FaceMesh : void 0;
|
|
716
|
+
if (!o && typeof window < "u") {
|
|
717
|
+
const a = document.querySelector('script[data-md-face-mesh="1"]');
|
|
718
|
+
a ? window.FaceMesh || await new Promise((s, i) => {
|
|
719
|
+
a.addEventListener("load", s, { once: !0 }), a.addEventListener(
|
|
720
|
+
"error",
|
|
721
|
+
() => i(new Error("No se pudo cargar MediaPipe FaceMesh")),
|
|
722
|
+
{ once: !0 }
|
|
723
|
+
);
|
|
724
|
+
}) : await new Promise((s, i) => {
|
|
725
|
+
const c = document.createElement("script");
|
|
726
|
+
c.src = "https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh@0.4.1633559619/face_mesh.js", c.async = !0, c.dataset.mdFaceMesh = "1", c.onload = s, c.onerror = () => i(new Error("No se pudo cargar MediaPipe FaceMesh")), document.head.appendChild(c);
|
|
727
|
+
}), o = window.FaceMesh;
|
|
728
|
+
}
|
|
729
|
+
if (!o)
|
|
730
|
+
throw new Error("No se pudo inicializar el detector de landmarks");
|
|
731
|
+
const n = new o({ locateFile: t });
|
|
732
|
+
return n.setOptions(r), n;
|
|
733
|
+
}
|
|
734
|
+
export {
|
|
735
|
+
Ce as a,
|
|
736
|
+
_e as b,
|
|
737
|
+
fe as c,
|
|
738
|
+
X as d,
|
|
739
|
+
Ee as e,
|
|
740
|
+
F as f,
|
|
741
|
+
pe as g,
|
|
742
|
+
me as h,
|
|
743
|
+
le as i,
|
|
744
|
+
ue as j,
|
|
745
|
+
he as k,
|
|
746
|
+
de as l,
|
|
747
|
+
z as m,
|
|
748
|
+
Z as n,
|
|
749
|
+
be as o,
|
|
750
|
+
ye as p,
|
|
751
|
+
ge as q,
|
|
752
|
+
we as r,
|
|
753
|
+
H as s,
|
|
754
|
+
ve as u
|
|
755
|
+
};
|