md-face-engine 1.1.0 → 1.1.1

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.
@@ -1,693 +0,0 @@
1
- "use strict";
2
- const wrinkles = {
3
- key: "wrinkles",
4
- label: "Arrugas",
5
- defaults: { intensity: 0.5, sigma: 4, brightness: 0 },
6
- deep: {
7
- smooth: { enabled: true, radius: 8, passes: 4, opacity: 0.7 },
8
- brightness: { enabled: true, value: 10 },
9
- contrast: { enabled: true, value: 1.03 },
10
- warmth: { enabled: true, rPlus: 8, bMinus: 5, alpha: 0.3 },
11
- toneUnify: { enabled: true, threshold: 12, mix: 0.4 },
12
- blemish: { enabled: true, microBlur: 3, alpha: 0.4 },
13
- contourLift: { enabled: true, lift: 0.06, shade: 0.04, feather: 20 }
14
- }
15
- };
16
- const brightness = {
17
- key: "brightness",
18
- label: "Luminosidad",
19
- defaults: { intensity: 0, sigma: 0, brightness: 0.07 },
20
- deep: {
21
- smooth: { enabled: true, radius: 5, passes: 3, opacity: 0.5 },
22
- brightness: { enabled: true, value: 18 },
23
- contrast: { enabled: true, value: 1.15 },
24
- warmth: { enabled: true, rPlus: 12, bMinus: 8, alpha: 0.45 },
25
- toneUnify: { enabled: true, threshold: 10, mix: 0.3 },
26
- blemish: { enabled: true, microBlur: 2, alpha: 0.3 },
27
- contourLift: { enabled: true, lift: 0.12, shade: 0.08, feather: 18 }
28
- }
29
- };
30
- const spots = {
31
- key: "spots",
32
- label: "Manchas/Tono",
33
- defaults: { intensity: 0.65, sigma: 5, brightness: 0.05 },
34
- deep: {
35
- smooth: { enabled: true, radius: 6, passes: 3, opacity: 0.6 },
36
- brightness: { enabled: true, value: 12 },
37
- contrast: { enabled: true, value: 1.08 },
38
- warmth: { enabled: true, rPlus: 7, bMinus: 4, alpha: 0.3 },
39
- toneUnify: { enabled: true, threshold: 8, mix: 0.6 },
40
- blemish: { enabled: true, microBlur: 4, alpha: 0.5 },
41
- contourLift: { enabled: true, lift: 0.08, shade: 0.06, feather: 16 }
42
- }
43
- };
44
- const acne = {
45
- key: "acne",
46
- label: "Acné",
47
- defaults: { intensity: 0.55, sigma: 3.4, brightness: 0.1 },
48
- deep: {
49
- smooth: { enabled: true, radius: 7, passes: 4, opacity: 0.65 },
50
- brightness: { enabled: true, value: 8 },
51
- contrast: { enabled: true, value: 1.02 },
52
- warmth: { enabled: true, rPlus: 6, bMinus: 3, alpha: 0.25 },
53
- toneUnify: { enabled: true, threshold: 10, mix: 0.5 },
54
- blemish: { enabled: true, microBlur: 5, alpha: 0.7 },
55
- contourLift: { enabled: true, lift: 0.06, shade: 0.04, feather: 20 }
56
- }
57
- };
58
- const firmness = {
59
- key: "firmness",
60
- label: "Firmeza",
61
- defaults: { intensity: 0.7, sigma: 2, brightness: 0 },
62
- deep: {
63
- smooth: { enabled: true, radius: 3, passes: 2, opacity: 0.3 },
64
- brightness: { enabled: true, value: 6 },
65
- contrast: { enabled: true, value: 1.12 },
66
- warmth: { enabled: true, rPlus: 5, bMinus: 3, alpha: 0.2 },
67
- toneUnify: { enabled: true, threshold: 18, mix: 0.2 },
68
- blemish: { enabled: false, microBlur: 1, alpha: 0.1 },
69
- contourLift: { enabled: true, lift: 0.15, shade: 0.12, feather: 12 }
70
- }
71
- };
72
- const FILTERS = {
73
- wrinkles,
74
- brightness,
75
- spots,
76
- acne,
77
- firmness
78
- };
79
- function getFilter(key) {
80
- return FILTERS[key] || null;
81
- }
82
- const FILTER_ORDER = ["wrinkles", "brightness", "spots", "acne", "firmness"];
83
- const DEFAULT_FILTER_CONFIG = {
84
- // 1) Arrugas → Suavizado de piel
85
- smooth: {
86
- enabled: true,
87
- intensity: 36,
88
- // referencia visual
89
- radius: 4,
90
- passes: 2,
91
- opacity: 0.4
92
- },
93
- // 2) Piel apagada → Brillo
94
- brightness: {
95
- enabled: true,
96
- intensity: 91,
97
- // referencia visual
98
- value: 8
99
- },
100
- // Ajuste de contraste general
101
- contrast: {
102
- enabled: true,
103
- intensity: 10,
104
- value: 1.05
105
- },
106
- // Tono cálido / glow
107
- warmth: {
108
- enabled: true,
109
- intensity: 20,
110
- rPlus: 6,
111
- bMinus: 4,
112
- alpha: 0.25
113
- },
114
- // 2) Manchas → Unificar tono
115
- toneUnify: {
116
- enabled: true,
117
- intensity: 65,
118
- // referencia visual
119
- threshold: 15,
120
- mix: 0.25
121
- },
122
- // 5) Acné → Reducir imperfecciones
123
- blemish: {
124
- enabled: true,
125
- intensity: 35,
126
- // referencia visual
127
- microBlur: 2,
128
- alpha: 0.25
129
- },
130
- // 3) Firmeza → Lifting y contouring
131
- contourLift: {
132
- enabled: true,
133
- intensity: 24,
134
- // referencia visual
135
- lift: 0.08,
136
- shade: 0.06,
137
- feather: 15
138
- },
139
- // Extras
140
- highlights: {
141
- enabled: false,
142
- intensity: 10
143
- },
144
- shadows: {
145
- enabled: false,
146
- intensity: 5
147
- }
148
- };
149
- const CONCERN_PRESETS = {
150
- arrugas: {
151
- smooth: { enabled: true, intensity: 36, radius: 6, passes: 3, opacity: 0.6 },
152
- contourLift: { enabled: true, intensity: 20, lift: 0.06, shade: 0.05, feather: 18 }
153
- },
154
- manchas: {
155
- toneUnify: { enabled: true, intensity: 65, threshold: 14, mix: 0.35 },
156
- brightness: { enabled: true, intensity: 20, value: 10 }
157
- },
158
- firmeza: {
159
- contourLift: { enabled: true, intensity: 24, lift: 0.08, shade: 0.06, feather: 20 },
160
- contrast: { enabled: true, intensity: 12, value: 1.07 }
161
- },
162
- luminosidad: {
163
- brightness: { enabled: true, intensity: 91, value: 12 },
164
- warmth: { enabled: true, intensity: 25, rPlus: 8, bMinus: 5, alpha: 0.3 }
165
- },
166
- acne: {
167
- blemish: { enabled: true, intensity: 35, microBlur: 3, alpha: 0.35 },
168
- toneUnify: { enabled: true, intensity: 40, threshold: 16, mix: 0.3 }
169
- }
170
- };
171
- const CATEGORY_PRESETS = {
172
- // Antiaging: foco en arrugas y firmeza
173
- antiaging: {
174
- smooth: { enabled: true, intensity: 36, radius: 6, passes: 3, opacity: 0.6 },
175
- contourLift: { enabled: true, intensity: 24, lift: 0.07, shade: 0.05, feather: 18 },
176
- brightness: { enabled: true, intensity: 20, value: 10 },
177
- warmth: { enabled: true, intensity: 22, rPlus: 7, bMinus: 5, alpha: 0.28 }
178
- },
179
- // Manchas / pigmentación: foco en unificar tono y luminosidad
180
- manchas: {
181
- toneUnify: { enabled: true, intensity: 65, threshold: 14, mix: 0.35 },
182
- brightness: { enabled: true, intensity: 25, value: 10 },
183
- warmth: { enabled: false }
184
- },
185
- // Hidratación: suavizado ligero y glow moderado
186
- hidratacion: {
187
- smooth: { enabled: true, intensity: 25, radius: 3, passes: 2, opacity: 0.35 },
188
- brightness: { enabled: true, intensity: 18, value: 8 },
189
- warmth: { enabled: true, intensity: 15, rPlus: 5, bMinus: 3, alpha: 0.2 }
190
- },
191
- // Acné: foco en reducción de imperfecciones y tono uniforme
192
- acne: {
193
- blemish: { enabled: true, intensity: 35, microBlur: 3, alpha: 0.35 },
194
- toneUnify: { enabled: true, intensity: 40, threshold: 16, mix: 0.3 },
195
- brightness: { enabled: false }
196
- }
197
- };
198
- class FilterConfigManager {
199
- constructor(options = {}) {
200
- this.storageKey = "martiderm_filter_configs";
201
- this.authKey = "martiderm_admin_auth";
202
- this.backupKey = "martiderm_config_backup";
203
- this.products = Array.isArray(options.products) ? options.products : [];
204
- this.init();
205
- }
206
- /**
207
- * Inicializa el gestor de configuraciones
208
- */
209
- init() {
210
- const savedConfigs = this.loadConfigurations();
211
- if ((!savedConfigs || Object.keys(savedConfigs).length === 0) && this.products.length > 0) {
212
- this.initializeDefaultConfigurations();
213
- }
214
- }
215
- setProducts(products = []) {
216
- this.products = Array.isArray(products) ? products : [];
217
- const savedConfigs = this.loadConfigurations();
218
- if ((!savedConfigs || Object.keys(savedConfigs).length === 0) && this.products.length > 0) {
219
- this.initializeDefaultConfigurations();
220
- }
221
- }
222
- /**
223
- * Inicializa configuraciones predeterminadas para todos los productos
224
- */
225
- initializeDefaultConfigurations() {
226
- try {
227
- const configs = {};
228
- this.products.forEach((product) => {
229
- configs[product.id] = this.generateProductConfig(product);
230
- });
231
- this.saveConfigurations(configs);
232
- } catch (error) {
233
- console.error("Error inicializando configuraciones:", error);
234
- }
235
- }
236
- /**
237
- * Genera configuración específica para un producto
238
- */
239
- generateProductConfig(product) {
240
- const baseConfig = { ...DEFAULT_FILTER_CONFIG };
241
- const categoryPreset = CATEGORY_PRESETS[product.category];
242
- if (categoryPreset) {
243
- Object.keys(categoryPreset).forEach((filterType) => {
244
- if (baseConfig[filterType]) {
245
- baseConfig[filterType] = {
246
- ...baseConfig[filterType],
247
- ...categoryPreset[filterType]
248
- };
249
- }
250
- });
251
- }
252
- if (product.targetConcerns && Array.isArray(product.targetConcerns)) {
253
- product.targetConcerns.forEach((concern) => {
254
- const preset = CONCERN_PRESETS[concern];
255
- if (preset) {
256
- Object.keys(preset).forEach((filterType) => {
257
- if (baseConfig[filterType]) {
258
- baseConfig[filterType] = {
259
- ...baseConfig[filterType],
260
- ...preset[filterType]
261
- };
262
- }
263
- });
264
- }
265
- });
266
- }
267
- return {
268
- productId: product.id,
269
- productName: product.name,
270
- category: product.category,
271
- filters: baseConfig,
272
- lastModified: (/* @__PURE__ */ new Date()).toISOString(),
273
- version: "1.0"
274
- };
275
- }
276
- /**
277
- * Obtiene la configuración de filtros para un producto específico
278
- */
279
- getProductConfig(productId) {
280
- const configs = this.loadConfigurations();
281
- return configs[productId] || null;
282
- }
283
- /**
284
- * Guarda la configuración de filtros para un producto
285
- */
286
- saveProductConfig(productId, config) {
287
- const configs = this.loadConfigurations();
288
- configs[productId] = {
289
- ...config,
290
- lastModified: (/* @__PURE__ */ new Date()).toISOString()
291
- };
292
- this.saveConfigurations(configs);
293
- return true;
294
- }
295
- /**
296
- * Obtiene todas las configuraciones
297
- */
298
- getAllConfigurations() {
299
- return this.loadConfigurations();
300
- }
301
- /**
302
- * Carga configuraciones desde localStorage
303
- */
304
- loadConfigurations() {
305
- try {
306
- const saved = localStorage.getItem(this.storageKey);
307
- return saved ? JSON.parse(saved) : {};
308
- } catch (error) {
309
- console.error("Error cargando configuraciones:", error);
310
- return {};
311
- }
312
- }
313
- /**
314
- * Guarda configuraciones en localStorage
315
- */
316
- saveConfigurations(configs) {
317
- try {
318
- localStorage.setItem(this.storageKey, JSON.stringify(configs));
319
- this.createBackup(configs);
320
- return true;
321
- } catch (error) {
322
- console.error("Error guardando configuraciones:", error);
323
- return false;
324
- }
325
- }
326
- /**
327
- * Crea un backup de las configuraciones
328
- */
329
- createBackup(configs = null) {
330
- try {
331
- const configsToBackup = configs || this.loadConfigurations();
332
- const backup = {
333
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
334
- configurations: configsToBackup,
335
- version: "1.0"
336
- };
337
- localStorage.setItem(this.backupKey, JSON.stringify(backup));
338
- return true;
339
- } catch (error) {
340
- console.error("Error creando backup:", error);
341
- return false;
342
- }
343
- }
344
- /**
345
- * Restaura configuraciones desde backup
346
- */
347
- restoreFromBackup() {
348
- try {
349
- const backup = localStorage.getItem(this.backupKey);
350
- if (backup) {
351
- const backupData = JSON.parse(backup);
352
- this.saveConfigurations(backupData.configurations);
353
- return true;
354
- }
355
- return false;
356
- } catch (error) {
357
- console.error("Error restaurando backup:", error);
358
- return false;
359
- }
360
- }
361
- /**
362
- * Exporta configuraciones para descarga
363
- */
364
- exportConfigurations() {
365
- const configs = this.loadConfigurations();
366
- const exportData = {
367
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
368
- configurations: configs,
369
- version: "1.0"
370
- };
371
- return JSON.stringify(exportData, null, 2);
372
- }
373
- /**
374
- * Importa configuraciones desde archivo
375
- */
376
- importConfigurations(jsonData) {
377
- try {
378
- const importData = JSON.parse(jsonData);
379
- if (importData.configurations) {
380
- this.saveConfigurations(importData.configurations);
381
- return true;
382
- }
383
- return false;
384
- } catch (error) {
385
- console.error("Error importando configuraciones:", error);
386
- return false;
387
- }
388
- }
389
- /**
390
- * Resetea configuraciones a valores predeterminados
391
- */
392
- resetToDefaults() {
393
- try {
394
- localStorage.removeItem(this.storageKey);
395
- this.initializeDefaultConfigurations();
396
- return true;
397
- } catch (error) {
398
- console.error("Error reseteando configuraciones:", error);
399
- return false;
400
- }
401
- }
402
- /**
403
- * Estado de autenticación del administrador
404
- */
405
- isAuthenticated() {
406
- try {
407
- const raw = localStorage.getItem(this.authKey);
408
- if (!raw) return false;
409
- const data = JSON.parse(raw);
410
- return !!(data == null ? void 0 : data.authenticated);
411
- } catch (e) {
412
- return false;
413
- }
414
- }
415
- /**
416
- * Autentica al administrador con credenciales simples de demo
417
- */
418
- authenticateAdmin(username, password) {
419
- const validUser = username === "admin";
420
- const validPass = password === "martiderm2024";
421
- if (validUser && validPass) {
422
- const session = {
423
- authenticated: true,
424
- username,
425
- token: `adm-${Date.now()}`,
426
- lastLogin: (/* @__PURE__ */ new Date()).toISOString()
427
- };
428
- localStorage.setItem(this.authKey, JSON.stringify(session));
429
- return { success: true, username };
430
- }
431
- return { success: false, error: "Credenciales inválidas" };
432
- }
433
- /**
434
- * Obtiene información del usuario autenticado
435
- */
436
- getAuthenticatedUser() {
437
- try {
438
- const raw = localStorage.getItem(this.authKey);
439
- if (!raw) return null;
440
- const data = JSON.parse(raw);
441
- if (data == null ? void 0 : data.authenticated) {
442
- return { username: data.username };
443
- }
444
- return null;
445
- } catch (e) {
446
- return null;
447
- }
448
- }
449
- /**
450
- * Cierra sesión del administrador
451
- */
452
- logout() {
453
- try {
454
- localStorage.removeItem(this.authKey);
455
- return true;
456
- } catch (e) {
457
- return false;
458
- }
459
- }
460
- /**
461
- * Compatibilidad: método singular usado por AdminPanel
462
- */
463
- exportConfiguration() {
464
- return this.exportConfigurations();
465
- }
466
- }
467
- const coreFilterConfigManager = new FilterConfigManager();
468
- function buildWebglConfigForProduct(product) {
469
- var _a, _b, _c, _d;
470
- const pc = coreFilterConfigManager.getProductConfig(product.id) || {};
471
- const lockedType = product.filterType || pc.webglConfig && pc.webglConfig.filterType || "wrinkles";
472
- const defaults = FILTERS[lockedType] && FILTERS[lockedType].defaults || { intensity: 0.5, sigma: 4, brightness: 0 };
473
- const deep = FILTERS[lockedType] && FILTERS[lockedType].deep || {};
474
- const base = {
475
- filterType: lockedType,
476
- intensity: product.defaultIntensity !== void 0 ? product.defaultIntensity : defaults.intensity,
477
- sigma: product.defaultSigma !== void 0 ? product.defaultSigma : defaults.sigma,
478
- brightness: product.defaultBrightness !== void 0 ? product.defaultBrightness : defaults.brightness,
479
- contrast: typeof ((_a = deep.contrast) == null ? void 0 : _a.value) === "number" ? deep.contrast.value : 1,
480
- warmthR: typeof ((_b = deep.warmth) == null ? void 0 : _b.rPlus) === "number" ? deep.warmth.rPlus : 0,
481
- warmthB: typeof ((_c = deep.warmth) == null ? void 0 : _c.bMinus) === "number" ? deep.warmth.bMinus : 0,
482
- warmthA: typeof ((_d = deep.warmth) == null ? void 0 : _d.alpha) === "number" ? deep.warmth.alpha : 0
483
- };
484
- const adminCfg = pc.webglConfig || {};
485
- return { ...base, ...adminCfg, filterType: lockedType };
486
- }
487
- const TOKEN_PREFIX = "mdfe2_";
488
- const PRODUCT_CODE = "md-face-engine";
489
- const LICENSE_PUBLIC_KEY_PEM = `-----BEGIN PUBLIC KEY-----
490
- MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW9CHbTVvVXcm09wZIj6GKGaq8ae1
491
- XGQAum9LBLgoT3+4q3xPc7W9KSw1z4xgfOByTi8OzdjbjEaF3VrHjzl05w==
492
- -----END PUBLIC KEY-----`;
493
- let publicKeyCache = null;
494
- function decodeBase64Url(value) {
495
- const normalized = value.replace(/-/g, "+").replace(/_/g, "/");
496
- const padded = normalized + "=".repeat((4 - normalized.length % 4) % 4);
497
- return atob(padded);
498
- }
499
- function decodeBase64UrlToBytes(value) {
500
- const bin = decodeBase64Url(value);
501
- const bytes = new Uint8Array(bin.length);
502
- for (let i = 0; i < bin.length; i += 1) {
503
- bytes[i] = bin.charCodeAt(i);
504
- }
505
- return bytes;
506
- }
507
- function pemToArrayBuffer(pem) {
508
- const b64 = pem.replace(/-----BEGIN PUBLIC KEY-----/g, "").replace(/-----END PUBLIC KEY-----/g, "").replace(/\s+/g, "");
509
- const raw = atob(b64);
510
- const bytes = new Uint8Array(raw.length);
511
- for (let i = 0; i < raw.length; i += 1) {
512
- bytes[i] = raw.charCodeAt(i);
513
- }
514
- return bytes.buffer;
515
- }
516
- async function importPublicKey(publicKeyPem = LICENSE_PUBLIC_KEY_PEM) {
517
- if (publicKeyPem === LICENSE_PUBLIC_KEY_PEM && publicKeyCache) {
518
- return publicKeyCache;
519
- }
520
- const keyData = pemToArrayBuffer(publicKeyPem);
521
- const key = await crypto.subtle.importKey(
522
- "spki",
523
- keyData,
524
- { name: "ECDSA", namedCurve: "P-256" },
525
- false,
526
- ["verify"]
527
- );
528
- if (publicKeyPem === LICENSE_PUBLIC_KEY_PEM) {
529
- publicKeyCache = key;
530
- }
531
- return key;
532
- }
533
- async function validateLicenseToken(token, options = {}) {
534
- const {
535
- now = Date.now(),
536
- publicKeyPem = LICENSE_PUBLIC_KEY_PEM,
537
- allowExpired = false
538
- } = options;
539
- if (!token || typeof token !== "string") {
540
- return { valid: false, reason: "Token vacío o inválido" };
541
- }
542
- if (!token.startsWith(TOKEN_PREFIX)) {
543
- return { valid: false, reason: "Prefijo de token inválido" };
544
- }
545
- const raw = token.slice(TOKEN_PREFIX.length);
546
- const parts = raw.split(".");
547
- if (parts.length !== 2) {
548
- return { valid: false, reason: "Formato de token inválido" };
549
- }
550
- const [payloadPart, signaturePart] = parts;
551
- let payload;
552
- try {
553
- payload = JSON.parse(decodeBase64Url(payloadPart));
554
- } catch (_err) {
555
- return { valid: false, reason: "Payload de licencia inválido" };
556
- }
557
- try {
558
- const key = await importPublicKey(publicKeyPem);
559
- const isValid = await crypto.subtle.verify(
560
- { name: "ECDSA", hash: "SHA-256" },
561
- key,
562
- decodeBase64UrlToBytes(signaturePart),
563
- new TextEncoder().encode(payloadPart)
564
- );
565
- if (!isValid) {
566
- return { valid: false, reason: "Firma de licencia inválida" };
567
- }
568
- } catch (_err) {
569
- return { valid: false, reason: "Error verificando firma de licencia" };
570
- }
571
- if (payload.productCode !== PRODUCT_CODE) {
572
- return { valid: false, reason: "Licencia de otro producto" };
573
- }
574
- if (!allowExpired && (typeof payload.exp !== "number" || payload.exp < now)) {
575
- return { valid: false, reason: "Licencia vencida", payload };
576
- }
577
- return { valid: true, reason: null, payload };
578
- }
579
- class MdFaceEngine {
580
- constructor() {
581
- this.license = null;
582
- this.activated = false;
583
- }
584
- async activate(token) {
585
- const result = await validateLicenseToken(token);
586
- if (!result.valid) {
587
- this.license = null;
588
- this.activated = false;
589
- throw new Error(`Licencia inválida: ${result.reason}`);
590
- }
591
- this.license = result.payload;
592
- this.activated = true;
593
- return result.payload;
594
- }
595
- isActivated() {
596
- return this.activated;
597
- }
598
- assertActivated() {
599
- if (!this.activated) {
600
- throw new Error("md-face-engine no está activado. Configura VITE_MD_FACE_ENGINE_TOKEN.");
601
- }
602
- }
603
- getLicense() {
604
- this.assertActivated();
605
- return this.license;
606
- }
607
- getProductCode() {
608
- return PRODUCT_CODE;
609
- }
610
- getFilterRegistry() {
611
- this.assertActivated();
612
- return FILTERS;
613
- }
614
- getFilterOrder() {
615
- this.assertActivated();
616
- return FILTER_ORDER;
617
- }
618
- getFilter(key) {
619
- this.assertActivated();
620
- return getFilter(key);
621
- }
622
- getFilterConfigManager() {
623
- this.assertActivated();
624
- return coreFilterConfigManager;
625
- }
626
- buildWebglConfigForProduct(product) {
627
- this.assertActivated();
628
- return buildWebglConfigForProduct(product);
629
- }
630
- }
631
- async function createMdFaceEngineClient({ token, products = [] } = {}) {
632
- if (!token) {
633
- throw new Error("Falta token de licencia para activar md-face-engine.");
634
- }
635
- const engine = new MdFaceEngine();
636
- await engine.activate(token);
637
- engine.assertActivated();
638
- const filterConfigManager = engine.getFilterConfigManager();
639
- if (Array.isArray(products)) {
640
- filterConfigManager.setProducts(products);
641
- }
642
- return {
643
- engine,
644
- FILTERS: engine.getFilterRegistry(),
645
- FILTER_ORDER: engine.getFilterOrder(),
646
- getFilter: (key) => engine.getFilter(key),
647
- filterConfigManager,
648
- buildWebglConfigForProduct: (product) => engine.buildWebglConfigForProduct(product)
649
- };
650
- }
651
- async function createMdFaceEngineRuntime({ token, products = [] } = {}) {
652
- let client = null;
653
- let licenseError = null;
654
- let isLicenseActive = false;
655
- if (token) {
656
- try {
657
- client = await createMdFaceEngineClient({ token, products });
658
- isLicenseActive = true;
659
- } catch (error) {
660
- licenseError = error;
661
- isLicenseActive = false;
662
- }
663
- }
664
- if (!client && Array.isArray(products) && typeof (coreFilterConfigManager == null ? void 0 : coreFilterConfigManager.setProducts) === "function") {
665
- coreFilterConfigManager.setProducts(products);
666
- }
667
- return {
668
- engine: (client == null ? void 0 : client.engine) || null,
669
- FILTERS: (client == null ? void 0 : client.FILTERS) || FILTERS,
670
- FILTER_ORDER: (client == null ? void 0 : client.FILTER_ORDER) || FILTER_ORDER,
671
- getFilter: (client == null ? void 0 : client.getFilter) || getFilter,
672
- filterConfigManager: (client == null ? void 0 : client.filterConfigManager) || coreFilterConfigManager,
673
- buildWebglConfigForProduct: (client == null ? void 0 : client.buildWebglConfigForProduct) || buildWebglConfigForProduct,
674
- license: {
675
- active: isLicenseActive,
676
- error: licenseError,
677
- mode: isLicenseActive ? "licensed" : "unlicensed"
678
- }
679
- };
680
- }
681
- exports.CATEGORY_PRESETS = CATEGORY_PRESETS;
682
- exports.DEFAULT_FILTER_CONFIG = DEFAULT_FILTER_CONFIG;
683
- exports.FILTERS = FILTERS;
684
- exports.FILTER_ORDER = FILTER_ORDER;
685
- exports.FilterConfigManager = FilterConfigManager;
686
- exports.MdFaceEngine = MdFaceEngine;
687
- exports.buildWebglConfigForProduct = buildWebglConfigForProduct;
688
- exports.coreFilterConfigManager = coreFilterConfigManager;
689
- exports.createMdFaceEngineClient = createMdFaceEngineClient;
690
- exports.createMdFaceEngineRuntime = createMdFaceEngineRuntime;
691
- exports.getFilter = getFilter;
692
- exports.validateLicenseToken = validateLicenseToken;
693
- //# sourceMappingURL=client-Com8umy4.cjs.map