@jaak.ai/stamps 1.0.0 → 2.0.0-beta.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.
Files changed (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +531 -457
  3. package/dist/cjs/index-DGM9-FNg.js +1402 -0
  4. package/dist/cjs/index-DGM9-FNg.js.map +1 -0
  5. package/dist/cjs/index.cjs.js +3 -0
  6. package/dist/cjs/index.cjs.js.map +1 -0
  7. package/dist/cjs/jaak-stamps-webcomponent.cjs.js +27 -0
  8. package/dist/cjs/jaak-stamps-webcomponent.cjs.js.map +1 -0
  9. package/dist/cjs/jaak-stamps.cjs.entry.js +1060 -0
  10. package/dist/cjs/jaak-stamps.cjs.entry.js.map +1 -0
  11. package/dist/cjs/jaak-stamps.entry.cjs.js.map +1 -0
  12. package/dist/cjs/loader.cjs.js +8 -15
  13. package/dist/cjs/loader.cjs.js.map +1 -0
  14. package/dist/collection/collection-manifest.json +3 -22
  15. package/dist/collection/components/my-component/my-component.css +530 -0
  16. package/dist/collection/components/my-component/my-component.js +1357 -0
  17. package/dist/collection/components/my-component/my-component.js.map +1 -0
  18. package/dist/collection/index.js +2 -1
  19. package/dist/collection/index.js.map +1 -0
  20. package/dist/collection/utils/utils.js +4 -0
  21. package/dist/collection/utils/utils.js.map +1 -0
  22. package/dist/components/index.d.ts +33 -0
  23. package/dist/components/index.js +1195 -0
  24. package/dist/components/index.js.map +1 -0
  25. package/dist/components/jaak-stamps.d.ts +11 -0
  26. package/dist/components/jaak-stamps.js +1109 -0
  27. package/dist/components/jaak-stamps.js.map +1 -0
  28. package/dist/esm/index-DqoVMnc7.js +1393 -0
  29. package/dist/esm/index-DqoVMnc7.js.map +1 -0
  30. package/dist/esm/index.js +3 -0
  31. package/dist/esm/index.js.map +1 -0
  32. package/dist/esm/jaak-stamps-webcomponent.js +23 -0
  33. package/dist/esm/jaak-stamps-webcomponent.js.map +1 -0
  34. package/dist/esm/jaak-stamps.entry.js +1058 -0
  35. package/dist/esm/jaak-stamps.entry.js.map +1 -0
  36. package/dist/esm/loader.js +9 -14
  37. package/dist/esm/loader.js.map +1 -0
  38. package/dist/jaak-stamps-webcomponent/index.esm.js +2 -0
  39. package/dist/jaak-stamps-webcomponent/index.esm.js.map +1 -0
  40. package/dist/jaak-stamps-webcomponent/jaak-stamps-webcomponent.esm.js +2 -0
  41. package/dist/jaak-stamps-webcomponent/jaak-stamps-webcomponent.esm.js.map +1 -0
  42. package/dist/jaak-stamps-webcomponent/jaak-stamps.entry.esm.js.map +1 -0
  43. package/dist/jaak-stamps-webcomponent/loader.esm.js.map +1 -0
  44. package/dist/jaak-stamps-webcomponent/p-DqoVMnc7.js +3 -0
  45. package/dist/jaak-stamps-webcomponent/p-DqoVMnc7.js.map +1 -0
  46. package/dist/jaak-stamps-webcomponent/p-f1172b06.entry.js +2 -0
  47. package/dist/jaak-stamps-webcomponent/p-f1172b06.entry.js.map +1 -0
  48. package/dist/types/components/my-component/my-component.d.ts +131 -0
  49. package/dist/types/components.d.ts +62 -1370
  50. package/dist/types/index.d.ts +10 -1
  51. package/dist/types/stencil-public-runtime.d.ts +93 -28
  52. package/dist/types/utils/utils.d.ts +1 -0
  53. package/loader/cdn.js +1 -3
  54. package/loader/index.cjs.js +1 -3
  55. package/loader/index.d.ts +5 -2
  56. package/loader/index.es2017.js +1 -3
  57. package/loader/index.js +1 -3
  58. package/package.json +22 -26
  59. package/dist/cjs/document-detector_19.cjs.entry.js +0 -8630
  60. package/dist/cjs/index-5e4e5e7d.js +0 -1685
  61. package/dist/cjs/mb-tooltip.cjs.entry.js +0 -26
  62. package/dist/cjs/stamps.cjs.js +0 -23
  63. package/dist/collection/components/document-detector/document-detector.css +0 -156
  64. package/dist/collection/components/document-detector/document-detector.js +0 -504
  65. package/dist/collection/components/shared/mb-api-process-status/mb-api-process-status.css +0 -360
  66. package/dist/collection/components/shared/mb-api-process-status/mb-api-process-status.js +0 -124
  67. package/dist/collection/components/shared/mb-button/mb-button.css +0 -95
  68. package/dist/collection/components/shared/mb-button/mb-button.js +0 -201
  69. package/dist/collection/components/shared/mb-button-classic/mb-button-classic.css +0 -100
  70. package/dist/collection/components/shared/mb-button-classic/mb-button-classic.js +0 -130
  71. package/dist/collection/components/shared/mb-camera-experience/mb-camera-experience.css +0 -740
  72. package/dist/collection/components/shared/mb-camera-experience/mb-camera-experience.js +0 -827
  73. package/dist/collection/components/shared/mb-camera-experience/mb-camera-experience.utils.js +0 -55
  74. package/dist/collection/components/shared/mb-camera-selection/mb-camera-selection.css +0 -124
  75. package/dist/collection/components/shared/mb-camera-selection/mb-camera-selection.js +0 -194
  76. package/dist/collection/components/shared/mb-camera-toolbar/mb-camera-toolbar.css +0 -80
  77. package/dist/collection/components/shared/mb-camera-toolbar/mb-camera-toolbar.js +0 -275
  78. package/dist/collection/components/shared/mb-completed/mb-completed.css +0 -17
  79. package/dist/collection/components/shared/mb-completed/mb-completed.js +0 -48
  80. package/dist/collection/components/shared/mb-component/mb-component.css +0 -321
  81. package/dist/collection/components/shared/mb-component/mb-component.js +0 -2294
  82. package/dist/collection/components/shared/mb-component/mb-component.utils.js +0 -14
  83. package/dist/collection/components/shared/mb-container/mb-container.css +0 -7
  84. package/dist/collection/components/shared/mb-container/mb-container.js +0 -23
  85. package/dist/collection/components/shared/mb-feedback/mb-feedback.css +0 -36
  86. package/dist/collection/components/shared/mb-feedback/mb-feedback.js +0 -91
  87. package/dist/collection/components/shared/mb-feedback/mb-feedback.utils.js +0 -11
  88. package/dist/collection/components/shared/mb-help/mb-help.css +0 -191
  89. package/dist/collection/components/shared/mb-help/mb-help.js +0 -409
  90. package/dist/collection/components/shared/mb-help/mb-help.model.js +0 -5
  91. package/dist/collection/components/shared/mb-image-box/mb-image-box.css +0 -78
  92. package/dist/collection/components/shared/mb-image-box/mb-image-box.js +0 -150
  93. package/dist/collection/components/shared/mb-modal/mb-modal.css +0 -106
  94. package/dist/collection/components/shared/mb-modal/mb-modal.js +0 -239
  95. package/dist/collection/components/shared/mb-overlay/mb-overlay.css +0 -46
  96. package/dist/collection/components/shared/mb-overlay/mb-overlay.js +0 -76
  97. package/dist/collection/components/shared/mb-progress-tracker/mb-progress-tracker.css +0 -24
  98. package/dist/collection/components/shared/mb-progress-tracker/mb-progress-tracker.js +0 -80
  99. package/dist/collection/components/shared/mb-screen/mb-screen.css +0 -19
  100. package/dist/collection/components/shared/mb-screen/mb-screen.js +0 -48
  101. package/dist/collection/components/shared/mb-spinner/mb-spinner.css +0 -30
  102. package/dist/collection/components/shared/mb-spinner/mb-spinner.js +0 -67
  103. package/dist/collection/components/shared/mb-tooltip/mb-tooltip.css +0 -62
  104. package/dist/collection/components/shared/mb-tooltip/mb-tooltip.js +0 -150
  105. package/dist/collection/components/shared/mb-tooltip-advanced/mb-tooltip-advanced.css +0 -91
  106. package/dist/collection/components/shared/mb-tooltip-advanced/mb-tooltip-advanced.js +0 -96
  107. package/dist/collection/utils/data-structures.js +0 -189
  108. package/dist/collection/utils/device.helpers.js +0 -37
  109. package/dist/collection/utils/error-structures.js +0 -47
  110. package/dist/collection/utils/generic.helpers.js +0 -82
  111. package/dist/collection/utils/sdk.service.js +0 -943
  112. package/dist/collection/utils/state-lifter.js +0 -3
  113. package/dist/collection/utils/status.document-detector.js +0 -15
  114. package/dist/collection/utils/translation.service.js +0 -97
  115. package/dist/esm/document-detector_19.entry.js +0 -8608
  116. package/dist/esm/index-dc740acb.js +0 -1656
  117. package/dist/esm/mb-tooltip.entry.js +0 -22
  118. package/dist/esm/polyfills/core-js.js +0 -11
  119. package/dist/esm/polyfills/css-shim.js +0 -1
  120. package/dist/esm/polyfills/dom.js +0 -79
  121. package/dist/esm/polyfills/es5-html-element.js +0 -1
  122. package/dist/esm/polyfills/index.js +0 -34
  123. package/dist/esm/polyfills/system.js +0 -6
  124. package/dist/esm/stamps.js +0 -18
  125. package/dist/stamps/index.esm.js +0 -0
  126. package/dist/stamps/p-7f07a434.js +0 -2
  127. package/dist/stamps/p-ae1d9117.entry.js +0 -9
  128. package/dist/stamps/p-ec3f5972.entry.js +0 -1
  129. package/dist/stamps/stamps.esm.js +0 -1
  130. package/dist/types/components/document-detector/document-detector.d.ts +0 -103
  131. package/dist/types/components/shared/mb-api-process-status/mb-api-process-status.d.ts +0 -30
  132. package/dist/types/components/shared/mb-button/mb-button.d.ts +0 -41
  133. package/dist/types/components/shared/mb-button-classic/mb-button-classic.d.ts +0 -27
  134. package/dist/types/components/shared/mb-camera-experience/mb-camera-experience.d.ts +0 -141
  135. package/dist/types/components/shared/mb-camera-experience/mb-camera-experience.utils.d.ts +0 -3
  136. package/dist/types/components/shared/mb-camera-selection/mb-camera-selection.d.ts +0 -33
  137. package/dist/types/components/shared/mb-camera-toolbar/mb-camera-toolbar.d.ts +0 -54
  138. package/dist/types/components/shared/mb-completed/mb-completed.d.ts +0 -12
  139. package/dist/types/components/shared/mb-component/mb-component.d.ts +0 -310
  140. package/dist/types/components/shared/mb-component/mb-component.utils.d.ts +0 -3
  141. package/dist/types/components/shared/mb-container/mb-container.d.ts +0 -8
  142. package/dist/types/components/shared/mb-feedback/mb-feedback.d.ts +0 -19
  143. package/dist/types/components/shared/mb-feedback/mb-feedback.utils.d.ts +0 -2
  144. package/dist/types/components/shared/mb-help/mb-help.d.ts +0 -66
  145. package/dist/types/components/shared/mb-help/mb-help.model.d.ts +0 -9
  146. package/dist/types/components/shared/mb-image-box/mb-image-box.d.ts +0 -35
  147. package/dist/types/components/shared/mb-modal/mb-modal.d.ts +0 -53
  148. package/dist/types/components/shared/mb-overlay/mb-overlay.d.ts +0 -17
  149. package/dist/types/components/shared/mb-progress-tracker/mb-progress-tracker.d.ts +0 -19
  150. package/dist/types/components/shared/mb-screen/mb-screen.d.ts +0 -12
  151. package/dist/types/components/shared/mb-spinner/mb-spinner.d.ts +0 -16
  152. package/dist/types/components/shared/mb-tooltip/mb-tooltip.d.ts +0 -10
  153. package/dist/types/components/shared/mb-tooltip-advanced/mb-tooltip-advanced.d.ts +0 -7
  154. package/dist/types/utils/data-structures.d.ts +0 -264
  155. package/dist/types/utils/device.helpers.d.ts +0 -7
  156. package/dist/types/utils/error-structures.d.ts +0 -44
  157. package/dist/types/utils/generic.helpers.d.ts +0 -21
  158. package/dist/types/utils/sdk.service.d.ts +0 -52
  159. package/dist/types/utils/state-lifter.d.ts +0 -3
  160. package/dist/types/utils/status.document-detector.d.ts +0 -14
  161. package/dist/types/utils/translation.service.d.ts +0 -77
  162. package/loader/package.json +0 -11
@@ -0,0 +1,1357 @@
1
+ import { h } from "@stencil/core";
2
+ export class JaakStamps {
3
+ el;
4
+ debug = false;
5
+ alignmentTolerance = 10; // Tolerancia en píxeles para considerar un lado alineado (escalado para 320x320)
6
+ maskSize = 90; // Porcentaje del video que ocupará la máscara (default 90%)
7
+ cropMargin = 0; // Margen en píxeles para el recorte del documento (default 0)
8
+ useDocumentClassification = false; // Habilita la clasificación automática de documentos para determinar si solicitar reverso
9
+ captureCompleted;
10
+ isReady;
11
+ isVideoActive = false;
12
+ statusMessage = 'Presione el botón para activar la cámara';
13
+ statusColor = '#aaa';
14
+ bestScore = 0;
15
+ capturedFullFrame = null;
16
+ capturedCroppedId = null;
17
+ capturedBackFullFrame = null;
18
+ capturedBackCroppedId = null;
19
+ captureStep = 'front';
20
+ isCapturing = false;
21
+ showFlipAnimation = false;
22
+ showSuccessAnimation = false;
23
+ shouldMirrorVideo = true;
24
+ sideAlignment = {
25
+ top: false,
26
+ right: false,
27
+ bottom: false,
28
+ left: false
29
+ };
30
+ isDetectionPaused = false;
31
+ isLoading = false;
32
+ isModelPreloaded = false;
33
+ isMaskReady = false;
34
+ videoRef;
35
+ canvasRef;
36
+ session;
37
+ startTime;
38
+ videoStream;
39
+ animationId;
40
+ hasScreenshotTaken = false;
41
+ lastDetectedBox;
42
+ mobileNetSession;
43
+ mobileNetClassMap;
44
+ // Performance optimization properties
45
+ frameSkipCounter = 0;
46
+ FRAME_SKIP = 2; // Process every 3rd frame (reduces CPU by ~66%)
47
+ consecutiveFailures = 0;
48
+ MAX_FAILURES = 30; // 0.5 seconds without detection
49
+ lastInferenceTime = 0;
50
+ MIN_INFERENCE_INTERVAL = 50; // Minimum 50ms between inferences
51
+ // Canvas pooling for memory optimization
52
+ preprocessCanvas;
53
+ preprocessCtx;
54
+ captureCanvas;
55
+ captureCtx;
56
+ MODEL_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/ddmyp-v1.onnx";
57
+ MOBILENET_MODEL_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/cdmmp-v1.onnx";
58
+ MOBILENET_CLASSES_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/cdmmp-v1.json";
59
+ INPUT_SIZE = 320;
60
+ CONFIDENCE_THRESHOLD = 0.6;
61
+ // ISO/IEC 7810 ID-1 standard dimensions (85.60mm x 53.98mm)
62
+ ID1_ASPECT_RATIO = 85.60 / 53.98; // 1.5863320574...
63
+ debugLog(...args) {
64
+ if (this.debug) {
65
+ console.log(...args);
66
+ }
67
+ }
68
+ validateMaskSize() {
69
+ if (this.maskSize < 50 || this.maskSize > 100) {
70
+ console.warn(`maskSize debe estar entre 50 y 100. Valor actual: ${this.maskSize}. Usando valor por defecto: 90`);
71
+ this.maskSize = 90;
72
+ }
73
+ }
74
+ validateCropMargin() {
75
+ if (this.cropMargin < 0 || this.cropMargin > 100) {
76
+ console.warn(`cropMargin debe estar entre 0 y 100. Valor actual: ${this.cropMargin}. Usando valor por defecto: 0`);
77
+ this.cropMargin = 0;
78
+ }
79
+ }
80
+ emitReadyEvent() {
81
+ const isDocumentReady = !!window.ort && this.isModelPreloaded;
82
+ this.isReady.emit(isDocumentReady);
83
+ this.debugLog('🟢 isReady event emitted:', isDocumentReady);
84
+ }
85
+ isRearCamera(stream) {
86
+ const videoTrack = stream.getVideoTracks()[0];
87
+ if (!videoTrack)
88
+ return false;
89
+ const settings = videoTrack.getSettings();
90
+ return settings.facingMode === 'environment';
91
+ }
92
+ async componentDidLoad() {
93
+ this.validateMaskSize();
94
+ this.validateCropMargin();
95
+ if (!window.ort) {
96
+ const script = document.createElement('script');
97
+ script.src = 'https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.min.js';
98
+ document.head.appendChild(script);
99
+ // Wait for ONNX runtime to load before emitting ready event
100
+ script.onload = () => {
101
+ this.emitReadyEvent();
102
+ };
103
+ }
104
+ else {
105
+ // ONNX runtime already loaded
106
+ this.emitReadyEvent();
107
+ }
108
+ // Initialize canvas pool for better performance
109
+ this.initializeCanvasPool();
110
+ this.setupResizeObserver();
111
+ }
112
+ setupResizeObserver() {
113
+ if ('ResizeObserver' in window && this.canvasRef) {
114
+ const resizeObserver = new ResizeObserver(() => {
115
+ this.handleResize();
116
+ });
117
+ resizeObserver.observe(this.canvasRef.parentElement);
118
+ }
119
+ }
120
+ handleResize() {
121
+ if (this.canvasRef) {
122
+ const container = this.canvasRef.parentElement;
123
+ const rect = container.getBoundingClientRect();
124
+ // Set canvas size to match container
125
+ this.canvasRef.width = rect.width;
126
+ this.canvasRef.height = rect.height;
127
+ // Update mask positioning based on container and video dimensions
128
+ this.updateMaskDimensions(rect);
129
+ this.debugLog('📐 Canvas resized:', { width: rect.width, height: rect.height });
130
+ }
131
+ }
132
+ updateMaskDimensions(containerRect) {
133
+ if (!this.videoRef)
134
+ return;
135
+ const videoWidth = this.videoRef.videoWidth;
136
+ const videoHeight = this.videoRef.videoHeight;
137
+ if (videoWidth === 0 || videoHeight === 0)
138
+ return;
139
+ // Calculate video aspect ratio and container aspect ratio
140
+ const videoAspectRatio = videoWidth / videoHeight;
141
+ const containerAspectRatio = containerRect.width / containerRect.height;
142
+ // Determine how video fits in container (letterboxed or pillarboxed)
143
+ let displayedVideoWidth, displayedVideoHeight;
144
+ let videoOffsetX = 0, videoOffsetY = 0;
145
+ if (videoAspectRatio > containerAspectRatio) {
146
+ // Video is wider - letterboxed (black bars top/bottom)
147
+ displayedVideoWidth = containerRect.width;
148
+ displayedVideoHeight = containerRect.width / videoAspectRatio;
149
+ videoOffsetY = (containerRect.height - displayedVideoHeight) / 2;
150
+ }
151
+ else {
152
+ // Video is taller - pillarboxed (black bars left/right)
153
+ displayedVideoHeight = containerRect.height;
154
+ displayedVideoWidth = containerRect.height * videoAspectRatio;
155
+ videoOffsetX = (containerRect.width - displayedVideoWidth) / 2;
156
+ }
157
+ // Calculate maximum possible mask size while preserving exact ID-1 aspect ratio
158
+ // Determine the limiting dimension based on video orientation and ID-1 proportions
159
+ // Calculate what would be the max width if limited by video height
160
+ const maxWidthByHeight = displayedVideoHeight * this.ID1_ASPECT_RATIO;
161
+ let maskWidthInVideo, maskHeightInVideo;
162
+ const sizeRatio = this.maskSize / 100;
163
+ if (maxWidthByHeight <= displayedVideoWidth) {
164
+ // Video height is the limiting factor
165
+ maskHeightInVideo = displayedVideoHeight * sizeRatio;
166
+ maskWidthInVideo = maskHeightInVideo * this.ID1_ASPECT_RATIO;
167
+ }
168
+ else {
169
+ // Video width is the limiting factor
170
+ maskWidthInVideo = displayedVideoWidth * sizeRatio;
171
+ maskHeightInVideo = maskWidthInVideo / this.ID1_ASPECT_RATIO;
172
+ }
173
+ // Convert to percentages of the container
174
+ const maskWidthPercent = (maskWidthInVideo / containerRect.width) * 100;
175
+ const maskHeightPercent = (maskHeightInVideo / containerRect.height) * 100;
176
+ // Calculate the center position of the displayed video area
177
+ const videoCenterX = videoOffsetX + (displayedVideoWidth / 2);
178
+ const videoCenterY = videoOffsetY + (displayedVideoHeight / 2);
179
+ // Convert to percentages of the container
180
+ const videoCenterXPercent = (videoCenterX / containerRect.width) * 100;
181
+ const videoCenterYPercent = (videoCenterY / containerRect.height) * 100;
182
+ // Update CSS custom properties for mask sizing and positioning
183
+ this.el.style.setProperty('--mask-width', `${maskWidthPercent}%`);
184
+ this.el.style.setProperty('--mask-height', `${maskHeightPercent}%`);
185
+ this.el.style.setProperty('--mask-center-x', `${videoCenterXPercent}%`);
186
+ this.el.style.setProperty('--mask-center-y', `${videoCenterYPercent}%`);
187
+ // Mark mask as ready now that dimensions are calculated
188
+ this.isMaskReady = true;
189
+ this.debugLog('🎯 Mask dimensions updated:', {
190
+ video: { width: videoWidth, height: videoHeight },
191
+ displayed: { width: displayedVideoWidth, height: displayedVideoHeight },
192
+ mask: { widthPercent: maskWidthPercent, heightPercent: maskHeightPercent },
193
+ center: { x: videoCenterXPercent, y: videoCenterYPercent },
194
+ offset: { x: videoOffsetX, y: videoOffsetY }
195
+ });
196
+ }
197
+ initializeCanvasPool() {
198
+ // Preprocess canvas - reused for every inference
199
+ this.preprocessCanvas = document.createElement('canvas');
200
+ this.preprocessCanvas.width = this.INPUT_SIZE;
201
+ this.preprocessCanvas.height = this.INPUT_SIZE;
202
+ this.preprocessCtx = this.preprocessCanvas.getContext('2d', {
203
+ alpha: false, // No transparency needed
204
+ willReadFrequently: true // Optimize for frequent getImageData calls
205
+ });
206
+ // Capture canvas - reused for screenshots
207
+ this.captureCanvas = document.createElement('canvas');
208
+ this.captureCtx = this.captureCanvas.getContext('2d', {
209
+ alpha: false
210
+ });
211
+ this.debugLog('🎨 Canvas pool initialized for performance');
212
+ }
213
+ disconnectedCallback() {
214
+ this.cleanup();
215
+ }
216
+ async getCapturedImages() {
217
+ if (this.captureStep !== 'completed') {
218
+ throw new Error('El proceso de captura no ha sido completado');
219
+ }
220
+ return {
221
+ front: {
222
+ fullFrame: this.capturedFullFrame,
223
+ cropped: this.capturedCroppedId
224
+ },
225
+ back: {
226
+ fullFrame: this.capturedBackFullFrame,
227
+ cropped: this.capturedBackCroppedId
228
+ },
229
+ metadata: {
230
+ hasBackCapture: !!(this.capturedBackFullFrame && this.capturedBackCroppedId),
231
+ totalImages: (this.capturedBackFullFrame && this.capturedBackCroppedId) ? 4 : 2
232
+ }
233
+ };
234
+ }
235
+ async isProcessCompleted() {
236
+ return this.captureStep === 'completed';
237
+ }
238
+ async startCapture() {
239
+ await this.startDetection();
240
+ }
241
+ async stopCapture() {
242
+ this.exitSession();
243
+ }
244
+ async resetCapture() {
245
+ this.resetDetection();
246
+ }
247
+ async getStatus() {
248
+ return {
249
+ isVideoActive: this.isVideoActive,
250
+ captureStep: this.captureStep,
251
+ statusMessage: this.statusMessage,
252
+ hasImages: !!(this.capturedFullFrame || this.capturedBackFullFrame),
253
+ isProcessCompleted: this.captureStep === 'completed',
254
+ isModelPreloaded: this.isModelPreloaded
255
+ };
256
+ }
257
+ async preloadModel() {
258
+ if (this.isModelPreloaded || this.session) {
259
+ this.debugLog('🚀 Model already preloaded or session exists');
260
+ return { success: true, message: 'Model already loaded' };
261
+ }
262
+ try {
263
+ this.isLoading = true;
264
+ this.statusMessage = "Precargando modelos...";
265
+ this.statusColor = "#007bff";
266
+ const modelPath = this.MODEL_PATH;
267
+ this.debugLog('🤖 Preloading detection model:', modelPath);
268
+ // Configure ONNX Runtime with device-specific optimizations
269
+ const sessionOptions = this.getSessionOptions();
270
+ this.session = await window.ort.InferenceSession.create(modelPath, sessionOptions);
271
+ // Preload MobileNet model and classes only if classification is enabled
272
+ if (this.useDocumentClassification) {
273
+ await this.loadMobileNetModel();
274
+ }
275
+ this.isModelPreloaded = true;
276
+ this.isLoading = false;
277
+ this.statusMessage = "Modelos precargados. Listo para comenzar detección";
278
+ this.statusColor = "#28a745";
279
+ this.emitReadyEvent();
280
+ this.debugLog('✅ Models preloaded successfully');
281
+ return { success: true, message: 'Models preloaded successfully' };
282
+ }
283
+ catch (error) {
284
+ this.debugLog('❌ Error preloading models:', error);
285
+ this.isLoading = false;
286
+ this.statusMessage = "Error al precargar los modelos";
287
+ this.statusColor = "#ff6b6b";
288
+ return { success: false, error: error.message };
289
+ }
290
+ }
291
+ async skipBackCapture() {
292
+ if (this.captureStep === 'back' && this.capturedFullFrame) {
293
+ this.completeProcess(true);
294
+ }
295
+ }
296
+ async loadMobileNetModel() {
297
+ try {
298
+ this.debugLog('🤖 Loading MobileNet model...');
299
+ // Load class map
300
+ const classResponse = await fetch(this.MOBILENET_CLASSES_PATH);
301
+ if (!classResponse.ok) {
302
+ throw new Error(`Failed to load class map: ${this.MOBILENET_CLASSES_PATH}`);
303
+ }
304
+ this.mobileNetClassMap = await classResponse.json();
305
+ this.debugLog('📋 MobileNet classes loaded:', this.mobileNetClassMap);
306
+ // Load model
307
+ const sessionOptions = this.getSessionOptions();
308
+ this.mobileNetSession = await window.ort.InferenceSession.create(this.MOBILENET_MODEL_PATH, sessionOptions);
309
+ this.debugLog('✅ MobileNet model loaded successfully');
310
+ }
311
+ catch (error) {
312
+ this.debugLog('❌ Error loading MobileNet model:', error);
313
+ throw error;
314
+ }
315
+ }
316
+ preprocessMobileNet(canvas) {
317
+ // Create a temporary canvas for MobileNet preprocessing (224x224)
318
+ const tempCanvas = document.createElement('canvas');
319
+ tempCanvas.width = 224;
320
+ tempCanvas.height = 224;
321
+ const tempCtx = tempCanvas.getContext('2d');
322
+ // Draw the cropped image onto the 224x224 canvas
323
+ tempCtx.drawImage(canvas, 0, 0, 224, 224);
324
+ // Get image data and preprocess for MobileNet
325
+ const imageData = tempCtx.getImageData(0, 0, 224, 224);
326
+ const data = imageData.data;
327
+ const hw = 224 * 224;
328
+ const arr = new Float32Array(3 * hw);
329
+ // Normalize pixels: (pixel/255 - 0.5) / 0.5 = (pixel - 127.5) / 127.5
330
+ for (let i = 0; i < hw; i++) {
331
+ arr[i] = (data[i * 4 + 0] / 255 - 0.5) / 0.5; // R
332
+ arr[hw + i] = (data[i * 4 + 1] / 255 - 0.5) / 0.5; // G
333
+ arr[2 * hw + i] = (data[i * 4 + 2] / 255 - 0.5) / 0.5; // B
334
+ }
335
+ return new window.ort.Tensor('float32', arr, [1, 3, 224, 224]);
336
+ }
337
+ async classifyDocument(canvas) {
338
+ if (!this.mobileNetSession || !this.mobileNetClassMap) {
339
+ this.debugLog('⚠️ MobileNet model not loaded');
340
+ return null;
341
+ }
342
+ try {
343
+ this.debugLog('🔍 Classifying document...');
344
+ // Preprocess image for MobileNet
345
+ const inputTensor = this.preprocessMobileNet(canvas);
346
+ // Run inference
347
+ const feeds = { input: inputTensor };
348
+ const results = await this.mobileNetSession.run(feeds);
349
+ const output = results[Object.keys(results)[0]].data;
350
+ // Find the class with highest confidence
351
+ const maxIdx = output.reduce((bestIdx, val, idx, arr) => val > arr[bestIdx] ? idx : bestIdx, 0);
352
+ const confidence = output[maxIdx];
353
+ const className = this.mobileNetClassMap[maxIdx.toString()] || "unknown";
354
+ this.debugLog('📄 Document classification result:', {
355
+ class: className,
356
+ confidence: confidence.toFixed(3),
357
+ classIndex: maxIdx
358
+ });
359
+ return {
360
+ class: className,
361
+ confidence: confidence,
362
+ classIndex: maxIdx
363
+ };
364
+ }
365
+ catch (error) {
366
+ this.debugLog('❌ Error classifying document:', error);
367
+ return null;
368
+ }
369
+ }
370
+ cleanup() {
371
+ if (this.animationId) {
372
+ cancelAnimationFrame(this.animationId);
373
+ }
374
+ if (this.videoStream) {
375
+ this.videoStream.getTracks().forEach(track => track.stop());
376
+ }
377
+ // Limpiar canvas en cleanup general
378
+ if (this.canvasRef) {
379
+ const ctx = this.canvasRef.getContext("2d");
380
+ if (ctx) {
381
+ ctx.clearRect(0, 0, this.canvasRef.width, this.canvasRef.height);
382
+ }
383
+ }
384
+ // OPTIMIZATION: Clean up canvas pool
385
+ this.cleanupCanvasPool();
386
+ }
387
+ cleanupCanvasPool() {
388
+ // Release canvas references for garbage collection
389
+ if (this.preprocessCanvas) {
390
+ this.preprocessCtx = undefined;
391
+ this.preprocessCanvas = undefined;
392
+ }
393
+ if (this.captureCanvas) {
394
+ this.captureCtx = undefined;
395
+ this.captureCanvas = undefined;
396
+ }
397
+ // Disposed ONNX sessions
398
+ if (this.session) {
399
+ this.session.release?.();
400
+ this.session = undefined;
401
+ }
402
+ if (this.mobileNetSession) {
403
+ this.mobileNetSession.release?.();
404
+ this.mobileNetSession = undefined;
405
+ }
406
+ this.mobileNetClassMap = undefined;
407
+ this.isModelPreloaded = false;
408
+ this.debugLog('🧹 Canvas pool cleaned up');
409
+ }
410
+ async getMaxResolution() {
411
+ try {
412
+ // Primero obtén un stream básico para acceder a las capacidades
413
+ const tempStream = await navigator.mediaDevices.getUserMedia({
414
+ video: { facingMode: "environment" }
415
+ });
416
+ const videoTrack = tempStream.getVideoTracks()[0];
417
+ const capabilities = videoTrack.getCapabilities();
418
+ // Detener el stream temporal
419
+ tempStream.getTracks().forEach(track => track.stop());
420
+ // Construir restricciones con resolución optimizada para tablets
421
+ const constraints = {
422
+ facingMode: "environment"
423
+ };
424
+ if (capabilities.width && capabilities.height) {
425
+ // Limitar resolución máxima para tablets para evitar problemas de rendimiento
426
+ const maxWidth = Math.min(capabilities.width.max, 1920);
427
+ const maxHeight = Math.min(capabilities.height.max, 1080);
428
+ // Para tablets, usar resolución moderada en lugar de máxima
429
+ const isTablet = /iPad|Android/i.test(navigator.userAgent) && window.innerWidth >= 768;
430
+ if (isTablet) {
431
+ constraints.width = { ideal: Math.min(maxWidth, 1280) };
432
+ constraints.height = { ideal: Math.min(maxHeight, 720) };
433
+ }
434
+ else {
435
+ constraints.width = { ideal: maxWidth };
436
+ constraints.height = { ideal: maxHeight };
437
+ }
438
+ this.debugLog('📐 Resolution capabilities:', {
439
+ maxWidth: capabilities.width.max,
440
+ maxHeight: capabilities.height.max,
441
+ selectedWidth: constraints.width.ideal,
442
+ selectedHeight: constraints.height.ideal,
443
+ isTablet
444
+ });
445
+ }
446
+ return constraints;
447
+ }
448
+ catch (err) {
449
+ this.debugLog('⚠️ Could not get capabilities, using fallback');
450
+ // Fallback optimizado para tablets
451
+ const isTablet = /iPad|Android/i.test(navigator.userAgent) && window.innerWidth >= 768;
452
+ return {
453
+ facingMode: "environment",
454
+ width: { ideal: isTablet ? 1280 : 1920 },
455
+ height: { ideal: isTablet ? 720 : 1080 }
456
+ };
457
+ }
458
+ }
459
+ async setupCamera() {
460
+ try {
461
+ const constraints = await this.getMaxResolution();
462
+ const stream = await navigator.mediaDevices.getUserMedia({
463
+ video: constraints,
464
+ audio: false
465
+ });
466
+ if (this.videoRef) {
467
+ this.videoRef.srcObject = stream;
468
+ this.videoStream = stream;
469
+ // Determine if video should be mirrored
470
+ const isRear = this.isRearCamera(stream);
471
+ this.shouldMirrorVideo = !isRear;
472
+ this.debugLog('📹 Rear camera:', isRear);
473
+ this.debugLog('🪞 Should mirror video:', this.shouldMirrorVideo);
474
+ return new Promise((resolve) => {
475
+ this.videoRef.onloadedmetadata = async () => {
476
+ await this.videoRef.play();
477
+ this.isVideoActive = true;
478
+ // Update mask dimensions once video is loaded
479
+ if (this.canvasRef) {
480
+ const container = this.canvasRef.parentElement;
481
+ const rect = container.getBoundingClientRect();
482
+ this.updateMaskDimensions(rect);
483
+ }
484
+ resolve();
485
+ };
486
+ });
487
+ }
488
+ }
489
+ catch (err) {
490
+ this.debugLog("❌ No se pudo acceder a la cámara:", err);
491
+ this.statusMessage = "Error: No se pudo acceder a la cámara.";
492
+ this.statusColor = "#ff6b6b";
493
+ }
494
+ }
495
+ preprocess(video) {
496
+ // OPTIMIZATION: Reuse canvas instead of creating new ones
497
+ if (!this.preprocessCanvas || !this.preprocessCtx) {
498
+ this.initializeCanvasPool();
499
+ }
500
+ // Clear and redraw on reused canvas
501
+ this.preprocessCtx.clearRect(0, 0, this.INPUT_SIZE, this.INPUT_SIZE);
502
+ this.preprocessCtx.drawImage(video, 0, 0, this.INPUT_SIZE, this.INPUT_SIZE);
503
+ const imageData = this.preprocessCtx.getImageData(0, 0, this.INPUT_SIZE, this.INPUT_SIZE);
504
+ const [R, G, B] = [[], [], []];
505
+ const { data } = imageData;
506
+ // Optimized pixel processing
507
+ for (let i = 0; i < data.length; i += 4) {
508
+ R.push(data[i] / 255);
509
+ G.push(data[i + 1] / 255);
510
+ B.push(data[i + 2] / 255);
511
+ }
512
+ const transposedData = new Float32Array(R.concat(G, B));
513
+ return new window.ort.Tensor("float32", transposedData, [1, 3, this.INPUT_SIZE, this.INPUT_SIZE]);
514
+ }
515
+ getSessionOptions() {
516
+ return {
517
+ executionProviders: [
518
+ // Try WebGL first for GPU acceleration, fallback to WASM
519
+ 'webgl',
520
+ 'wasm'
521
+ ],
522
+ graphOptimizationLevel: 'all', // Maximum optimization
523
+ logSeverityLevel: this.debug ? 2 : 4, // Reduce logging overhead in production
524
+ logVerbosityLevel: 0,
525
+ enableCpuMemArena: true,
526
+ enableMemPattern: true,
527
+ executionMode: 'parallel',
528
+ interOpNumThreads: 2,
529
+ intraOpNumThreads: 2,
530
+ };
531
+ }
532
+ async startDetection() {
533
+ try {
534
+ // Check if model is already preloaded
535
+ if (!this.session) {
536
+ this.isLoading = true;
537
+ this.statusMessage = "Cargando modelos...";
538
+ this.statusColor = "#007bff";
539
+ const modelPath = this.MODEL_PATH;
540
+ this.debugLog('🤖 Loading detection model:', modelPath);
541
+ const sessionOptions = this.getSessionOptions();
542
+ this.session = await window.ort.InferenceSession.create(modelPath, sessionOptions);
543
+ // Load MobileNet model if classification is enabled and not already loaded
544
+ if (this.useDocumentClassification && !this.mobileNetSession) {
545
+ await this.loadMobileNetModel();
546
+ }
547
+ this.isModelPreloaded = true;
548
+ this.emitReadyEvent();
549
+ }
550
+ else {
551
+ this.debugLog('🚀 Using preloaded models');
552
+ this.statusMessage = "Usando modelos precargados...";
553
+ this.statusColor = "#007bff";
554
+ }
555
+ this.statusMessage = "Configurando cámara...";
556
+ await this.setupCamera();
557
+ this.startTime = Date.now();
558
+ this.isLoading = false;
559
+ this.detectFrame();
560
+ }
561
+ catch (err) {
562
+ this.debugLog("Error al inicializar:", err);
563
+ this.statusMessage = "Error al inicializar el detector";
564
+ this.statusColor = "#ff6b6b";
565
+ this.isLoading = false;
566
+ }
567
+ }
568
+ async detectFrame() {
569
+ try {
570
+ if (!this.videoRef || !this.canvasRef || !this.session)
571
+ return;
572
+ // Pausar detección si está marcado como pausado
573
+ if (this.isDetectionPaused) {
574
+ // Solo continuar el bucle sin procesar detección
575
+ if (this.captureStep !== 'completed') {
576
+ this.animationId = requestAnimationFrame(() => this.detectFrame());
577
+ }
578
+ return;
579
+ }
580
+ // OPTIMIZATION 1: Frame skipping for performance
581
+ this.frameSkipCounter++;
582
+ if (this.frameSkipCounter <= this.FRAME_SKIP) {
583
+ if (this.captureStep !== 'completed') {
584
+ this.animationId = requestAnimationFrame(() => this.detectFrame());
585
+ }
586
+ return;
587
+ }
588
+ this.frameSkipCounter = 0;
589
+ // OPTIMIZATION 2: Throttle inference based on time
590
+ const currentTime = Date.now();
591
+ if (currentTime - this.lastInferenceTime < this.MIN_INFERENCE_INTERVAL) {
592
+ if (this.captureStep !== 'completed') {
593
+ this.animationId = requestAnimationFrame(() => this.detectFrame());
594
+ }
595
+ return;
596
+ }
597
+ this.lastInferenceTime = currentTime;
598
+ const ctx = this.canvasRef.getContext("2d");
599
+ const inputTensor = this.preprocess(this.videoRef);
600
+ const feeds = { [this.session.inputNames[0]]: inputTensor };
601
+ const results = await this.session.run(feeds);
602
+ const output = results[this.session.outputNames[0]].data;
603
+ const finalBoxes = [];
604
+ for (let i = 0; i < output.length; i += 6) {
605
+ const [x1, y1, x2, y2, score, classId] = output.slice(i, i + 6);
606
+ if (score > this.CONFIDENCE_THRESHOLD) {
607
+ finalBoxes.push({ x: x1, y: y1, w: x2 - x1, h: y2 - y1, score, classId });
608
+ if (this.startTime && Date.now() - this.startTime < 5000) {
609
+ const currentBox = { x: x1, y: y1, w: x2 - x1, h: y2 - y1, score };
610
+ const isWellPositioned = this.isCardInFrame(currentBox);
611
+ const effectiveScore = isWellPositioned ? score * 1.2 : score;
612
+ if (effectiveScore > this.bestScore) {
613
+ this.bestScore = effectiveScore;
614
+ }
615
+ }
616
+ }
617
+ }
618
+ // OPTIMIZATION 3: Adaptive frame rate based on detection success
619
+ if (finalBoxes.length === 0) {
620
+ this.consecutiveFailures++;
621
+ }
622
+ else {
623
+ this.consecutiveFailures = 0;
624
+ }
625
+ ctx.clearRect(0, 0, this.canvasRef.width, this.canvasRef.height);
626
+ if (this.debug) {
627
+ this.drawDetections(ctx, finalBoxes);
628
+ }
629
+ this.updateGuidanceStatus(finalBoxes);
630
+ this.updateMaskColor(finalBoxes);
631
+ // Solo continuar si no hemos completado el proceso
632
+ if (this.captureStep !== 'completed') {
633
+ // OPTIMIZATION 4: Reduce frame rate when no detection for better battery life
634
+ if (this.consecutiveFailures > this.MAX_FAILURES) {
635
+ // Reduce to ~5fps when no detection for 0.5 seconds
636
+ setTimeout(() => this.detectFrame(), 200);
637
+ }
638
+ else {
639
+ this.animationId = requestAnimationFrame(() => this.detectFrame());
640
+ }
641
+ }
642
+ }
643
+ catch (e) {
644
+ this.debugLog("Error en inferencia:", e);
645
+ // Solo continuar si no hemos completado el proceso
646
+ if (this.captureStep !== 'completed') {
647
+ // On error, wait longer before retrying
648
+ setTimeout(() => this.detectFrame(), 100);
649
+ }
650
+ }
651
+ }
652
+ isCardInFrame(box) {
653
+ const cardCenterX = box.x + box.w / 2;
654
+ const cardCenterY = box.y + box.h / 2;
655
+ const frameCenterX = this.INPUT_SIZE / 2;
656
+ const frameCenterY = this.INPUT_SIZE / 2;
657
+ const toleranceX = 40;
658
+ const toleranceY = 30;
659
+ const isCentered = Math.abs(cardCenterX - frameCenterX) < toleranceX &&
660
+ Math.abs(cardCenterY - frameCenterY) < toleranceY;
661
+ const isGoodSize = box.w > 150 && box.w < 300 && box.h > 90 && box.h < 200;
662
+ return isCentered && isGoodSize;
663
+ }
664
+ checkSideAlignment(box) {
665
+ if (!this.videoRef)
666
+ return { top: false, right: false, bottom: false, left: false };
667
+ // Get video dimensions to calculate actual mask boundaries in model space
668
+ const videoWidth = this.videoRef.videoWidth;
669
+ const videoHeight = this.videoRef.videoHeight;
670
+ if (videoWidth === 0 || videoHeight === 0) {
671
+ return { top: false, right: false, bottom: false, left: false };
672
+ }
673
+ // Calculate video aspect ratio
674
+ const videoAspectRatio = videoWidth / videoHeight;
675
+ // The model sees video stretched to 320x320, but we need to calculate where
676
+ // the mask should be in this distorted space to match the visual mask
677
+ // In the visual display, we calculate mask size based on the limiting dimension
678
+ // We need to replicate this logic but account for the distortion in model space
679
+ // Calculate the "display" dimensions (what the visual mask calculations use)
680
+ const containerAspectRatio = 1; // Assume square container for simplicity
681
+ let displayedVideoWidth, displayedVideoHeight;
682
+ if (videoAspectRatio > containerAspectRatio) {
683
+ // Video is wider - letterboxed in display
684
+ displayedVideoWidth = this.INPUT_SIZE;
685
+ displayedVideoHeight = this.INPUT_SIZE / videoAspectRatio;
686
+ }
687
+ else {
688
+ // Video is taller - pillarboxed in display
689
+ displayedVideoHeight = this.INPUT_SIZE;
690
+ displayedVideoWidth = this.INPUT_SIZE * videoAspectRatio;
691
+ }
692
+ // Calculate mask dimensions using the same logic as updateMaskDimensions
693
+ const maxWidthByHeight = displayedVideoHeight * this.ID1_ASPECT_RATIO;
694
+ let visualMaskWidth, visualMaskHeight;
695
+ const sizeRatio = this.maskSize / 100;
696
+ if (maxWidthByHeight <= displayedVideoWidth) {
697
+ // Video height is the limiting factor
698
+ visualMaskHeight = displayedVideoHeight * sizeRatio;
699
+ visualMaskWidth = visualMaskHeight * this.ID1_ASPECT_RATIO;
700
+ }
701
+ else {
702
+ // Video width is the limiting factor
703
+ visualMaskWidth = displayedVideoWidth * sizeRatio;
704
+ visualMaskHeight = visualMaskWidth / this.ID1_ASPECT_RATIO;
705
+ }
706
+ // Now map these visual mask dimensions to the distorted model space
707
+ // The model stretches video to 320x320, so we need to apply the inverse transformation
708
+ const modelMaskWidth = visualMaskWidth * (this.INPUT_SIZE / displayedVideoWidth);
709
+ const modelMaskHeight = visualMaskHeight * (this.INPUT_SIZE / displayedVideoHeight);
710
+ // Calculate mask boundaries in model coordinate system (always centered in 320x320)
711
+ const maskCenterX = this.INPUT_SIZE / 2;
712
+ const maskCenterY = this.INPUT_SIZE / 2;
713
+ const maskLeft = maskCenterX - (modelMaskWidth / 2);
714
+ const maskRight = maskCenterX + (modelMaskWidth / 2);
715
+ const maskTop = maskCenterY - (modelMaskHeight / 2);
716
+ const maskBottom = maskCenterY + (modelMaskHeight / 2);
717
+ // Obtener las coordenadas del documento detectado
718
+ let docLeft = box.x;
719
+ let docRight = box.x + box.w;
720
+ const docTop = box.y;
721
+ const docBottom = box.y + box.h;
722
+ // Si el video está en modo mirror, invertir las coordenadas horizontales
723
+ if (this.shouldMirrorVideo) {
724
+ const originalDocLeft = docLeft;
725
+ const originalDocRight = docRight;
726
+ docLeft = this.INPUT_SIZE - originalDocRight;
727
+ docRight = this.INPUT_SIZE - originalDocLeft;
728
+ }
729
+ // Tolerancia para considerar que un lado está alineado (en píxeles)
730
+ const tolerance = this.alignmentTolerance;
731
+ return {
732
+ top: Math.abs(docTop - maskTop) <= tolerance,
733
+ right: Math.abs(docRight - maskRight) <= tolerance,
734
+ bottom: Math.abs(docBottom - maskBottom) <= tolerance,
735
+ left: Math.abs(docLeft - maskLeft) <= tolerance
736
+ };
737
+ }
738
+ areAllSidesAligned(alignment) {
739
+ return alignment.top && alignment.right && alignment.bottom && alignment.left;
740
+ }
741
+ updateMaskColor(boxes) {
742
+ const cardOutline = this.el.shadowRoot?.querySelector('.card-outline');
743
+ const corners = this.el.shadowRoot?.querySelectorAll('.corner');
744
+ const topSide = this.el.shadowRoot?.querySelector('.side-top');
745
+ const rightSide = this.el.shadowRoot?.querySelector('.side-right');
746
+ const bottomSide = this.el.shadowRoot?.querySelector('.side-bottom');
747
+ const leftSide = this.el.shadowRoot?.querySelector('.side-left');
748
+ let bestBox = null;
749
+ let currentAlignment = { top: false, right: false, bottom: false, left: false };
750
+ if (boxes.length > 0) {
751
+ bestBox = boxes.reduce((best, current) => current.score > best.score ? current : best);
752
+ currentAlignment = this.checkSideAlignment(bestBox);
753
+ this.sideAlignment = currentAlignment;
754
+ }
755
+ else {
756
+ // Reset alignment when no detection
757
+ this.sideAlignment = { top: false, right: false, bottom: false, left: false };
758
+ }
759
+ // Actualizar colores de cada lado individualmente
760
+ topSide?.classList.toggle('aligned', currentAlignment.top);
761
+ rightSide?.classList.toggle('aligned', currentAlignment.right);
762
+ bottomSide?.classList.toggle('aligned', currentAlignment.bottom);
763
+ leftSide?.classList.toggle('aligned', currentAlignment.left);
764
+ // Verificar si todos los lados están alineados
765
+ const allSidesAligned = this.areAllSidesAligned(currentAlignment);
766
+ if (allSidesAligned && bestBox) {
767
+ cardOutline?.classList.add('perfect-match');
768
+ corners?.forEach(corner => corner.classList.add('perfect-match'));
769
+ if (!this.hasScreenshotTaken) {
770
+ this.lastDetectedBox = bestBox;
771
+ this.takeScreenshot().catch(error => {
772
+ this.debugLog('❌ Error taking screenshot:', error);
773
+ });
774
+ this.hasScreenshotTaken = true;
775
+ // Reset para permitir segunda captura
776
+ setTimeout(() => {
777
+ this.hasScreenshotTaken = false;
778
+ }, 2000);
779
+ }
780
+ }
781
+ else {
782
+ cardOutline?.classList.remove('perfect-match');
783
+ corners?.forEach(corner => corner.classList.remove('perfect-match'));
784
+ }
785
+ }
786
+ updateGuidanceStatus(boxes) {
787
+ if (boxes.length === 0) {
788
+ this.statusMessage = "Posicione la identificación dentro del marco";
789
+ this.statusColor = "#ff6b6b";
790
+ }
791
+ else {
792
+ const bestBox = boxes.reduce((best, current) => current.score > best.score ? current : best);
793
+ const alignment = this.checkSideAlignment(bestBox);
794
+ const alignedSides = [alignment.top, alignment.right, alignment.bottom, alignment.left].filter(Boolean).length;
795
+ const allSidesAligned = this.areAllSidesAligned(alignment);
796
+ if (allSidesAligned) {
797
+ this.statusMessage = "Identificación perfectamente alineada. Mantenga inmóvil";
798
+ this.statusColor = "#00ff00";
799
+ }
800
+ else if (alignedSides > 0) {
801
+ this.statusMessage = `Alinee los lados restantes (${alignedSides}/4 lados correctos)`;
802
+ this.statusColor = "#ffb366";
803
+ }
804
+ else if (bestBox.w < 150) {
805
+ this.statusMessage = "Identificación detectada. Acerque al marco";
806
+ this.statusColor = "#ffb366";
807
+ }
808
+ else {
809
+ this.statusMessage = "Identificación detectada. Alinee con el marco";
810
+ this.statusColor = "#ffb366";
811
+ }
812
+ }
813
+ }
814
+ drawDetections(ctx, boxes) {
815
+ if (!this.videoRef)
816
+ return;
817
+ // Get video and container dimensions
818
+ const videoWidth = this.videoRef.videoWidth;
819
+ const videoHeight = this.videoRef.videoHeight;
820
+ const containerWidth = this.canvasRef.width;
821
+ const containerHeight = this.canvasRef.height;
822
+ if (videoWidth === 0 || videoHeight === 0)
823
+ return;
824
+ // Calculate video aspect ratio and container aspect ratio
825
+ const videoAspectRatio = videoWidth / videoHeight;
826
+ const containerAspectRatio = containerWidth / containerHeight;
827
+ // Determine how video fits in container (same logic as updateMaskDimensions)
828
+ let displayedVideoWidth, displayedVideoHeight;
829
+ let videoOffsetX = 0, videoOffsetY = 0;
830
+ if (videoAspectRatio > containerAspectRatio) {
831
+ // Video is wider - letterboxed (black bars top/bottom)
832
+ displayedVideoWidth = containerWidth;
833
+ displayedVideoHeight = containerWidth / videoAspectRatio;
834
+ videoOffsetY = (containerHeight - displayedVideoHeight) / 2;
835
+ }
836
+ else {
837
+ // Video is taller - pillarboxed (black bars left/right)
838
+ displayedVideoHeight = containerHeight;
839
+ displayedVideoWidth = containerHeight * videoAspectRatio;
840
+ videoOffsetX = (containerWidth - displayedVideoWidth) / 2;
841
+ }
842
+ // Scale factor from model coordinates (320x320) to displayed video area
843
+ const scaleX = displayedVideoWidth / this.INPUT_SIZE;
844
+ const scaleY = displayedVideoHeight / this.INPUT_SIZE;
845
+ boxes.forEach(det => {
846
+ // Convert model coordinates to displayed video coordinates
847
+ const x = det.x * scaleX + videoOffsetX;
848
+ const y = det.y * scaleY + videoOffsetY;
849
+ const w = det.w * scaleX;
850
+ const h = det.h * scaleY;
851
+ ctx.strokeStyle = "#32406C";
852
+ ctx.lineWidth = 2;
853
+ ctx.strokeRect(x, y, w, h);
854
+ });
855
+ }
856
+ async takeScreenshot() {
857
+ if (!this.videoRef || !this.lastDetectedBox)
858
+ return;
859
+ // Activar animación
860
+ this.triggerCaptureAnimation();
861
+ // OPTIMIZATION: Reuse capture canvas for full frame
862
+ if (!this.captureCanvas || !this.captureCtx) {
863
+ this.initializeCanvasPool();
864
+ }
865
+ // Resize reused canvas for full frame
866
+ this.captureCanvas.width = this.videoRef.videoWidth;
867
+ this.captureCanvas.height = this.videoRef.videoHeight;
868
+ this.captureCtx.drawImage(this.videoRef, 0, 0, this.captureCanvas.width, this.captureCanvas.height);
869
+ // Calcular las coordenadas de recorte basadas en la detección
870
+ const scaleX = this.videoRef.videoWidth / this.INPUT_SIZE;
871
+ const scaleY = this.videoRef.videoHeight / this.INPUT_SIZE;
872
+ const cropX = Math.max(0, (this.lastDetectedBox.x * scaleX) - this.cropMargin);
873
+ const cropY = Math.max(0, (this.lastDetectedBox.y * scaleY) - this.cropMargin);
874
+ const cropWidth = Math.min((this.lastDetectedBox.w * scaleX) + (2 * this.cropMargin), this.videoRef.videoWidth - cropX);
875
+ const cropHeight = Math.min((this.lastDetectedBox.h * scaleY) + (2 * this.cropMargin), this.videoRef.videoHeight - cropY);
876
+ // OPTIMIZATION: Create temporary canvas only for cropped version
877
+ // (We reuse main capture canvas for full frame)
878
+ const croppedCanvas = document.createElement('canvas');
879
+ croppedCanvas.width = cropWidth;
880
+ croppedCanvas.height = cropHeight;
881
+ const croppedCtx = croppedCanvas.getContext('2d', { alpha: false });
882
+ // Recortar la identificación del frame completo
883
+ croppedCtx.drawImage(this.videoRef, cropX, cropY, cropWidth, cropHeight, // Área de origen
884
+ 0, 0, cropWidth, cropHeight // Área de destino
885
+ );
886
+ if (this.captureStep === 'front') {
887
+ // Captura del frente usando canvas reutilizado
888
+ this.capturedFullFrame = this.captureCanvas.toDataURL('image/png');
889
+ this.capturedCroppedId = croppedCanvas.toDataURL('image/png');
890
+ // Check if document classification is enabled
891
+ if (this.useDocumentClassification) {
892
+ // Load MobileNet model if not loaded yet (lazy loading)
893
+ if (!this.mobileNetSession) {
894
+ try {
895
+ await this.loadMobileNetModel();
896
+ }
897
+ catch (error) {
898
+ this.debugLog('⚠️ Failed to load classification model, continuing without classification:', error);
899
+ }
900
+ }
901
+ // Classify the cropped document if model is available
902
+ if (this.mobileNetSession) {
903
+ const classification = await this.classifyDocument(croppedCanvas);
904
+ if (classification && classification.class === 'passport') {
905
+ // If it's a passport, skip back capture since passports don't have a back side
906
+ this.debugLog('📄 Passport detected - skipping back capture');
907
+ this.completeProcess(true);
908
+ return;
909
+ }
910
+ }
911
+ }
912
+ // For other IDs, continue with normal flow (back capture)
913
+ this.captureStep = 'back';
914
+ this.statusMessage = "Voltee la identificación y muestre la parte trasera";
915
+ this.statusColor = "#007bff";
916
+ // Pausar detección durante la animación de giro
917
+ this.isDetectionPaused = true;
918
+ // Mostrar animación de giro después de la captura
919
+ setTimeout(() => {
920
+ this.showFlipAnimation = true;
921
+ setTimeout(() => {
922
+ this.showFlipAnimation = false;
923
+ // Reanudar detección después de que termine la animación
924
+ this.isDetectionPaused = false;
925
+ }, 3000);
926
+ }, 800);
927
+ this.debugLog('📸 FRENTE capturado. Esperando trasera...');
928
+ }
929
+ else if (this.captureStep === 'back') {
930
+ // Captura de la trasera usando canvas reutilizado
931
+ this.capturedBackFullFrame = this.captureCanvas.toDataURL('image/png');
932
+ this.capturedBackCroppedId = croppedCanvas.toDataURL('image/png');
933
+ this.completeProcess(false);
934
+ this.debugLog('📸 TRASERA capturada. Proceso completado. Detector detenido. Imágenes emitidas.');
935
+ }
936
+ }
937
+ triggerCaptureAnimation() {
938
+ this.isCapturing = true;
939
+ // Agregar clase de animación al marco
940
+ const cardOutline = this.el.shadowRoot?.querySelector('.card-outline');
941
+ cardOutline?.classList.add('capturing');
942
+ // Limpiar animación después de que termine
943
+ setTimeout(() => {
944
+ this.isCapturing = false;
945
+ cardOutline?.classList.remove('capturing');
946
+ }, 600);
947
+ }
948
+ stopDetection() {
949
+ if (this.animationId) {
950
+ cancelAnimationFrame(this.animationId);
951
+ this.animationId = undefined;
952
+ }
953
+ // Limpiar canvas para eliminar cualquier detección visual residual
954
+ if (this.canvasRef) {
955
+ const ctx = this.canvasRef.getContext("2d");
956
+ ctx.clearRect(0, 0, this.canvasRef.width, this.canvasRef.height);
957
+ }
958
+ this.debugLog('🛑 Detector de identificación detenido');
959
+ }
960
+ resetDetection() {
961
+ this.bestScore = 0;
962
+ this.startTime = Date.now();
963
+ this.statusMessage = "Sistema reiniciado. Posicione la identificación";
964
+ this.statusColor = "#aaa";
965
+ this.hasScreenshotTaken = false;
966
+ this.capturedFullFrame = null;
967
+ this.capturedCroppedId = null;
968
+ this.capturedBackFullFrame = null;
969
+ this.capturedBackCroppedId = null;
970
+ this.captureStep = 'front';
971
+ this.isCapturing = false;
972
+ this.showFlipAnimation = false;
973
+ this.showSuccessAnimation = false;
974
+ this.isDetectionPaused = false;
975
+ this.isLoading = false;
976
+ this.lastDetectedBox = undefined;
977
+ this.isModelPreloaded = false;
978
+ // Reset performance counters
979
+ this.frameSkipCounter = 0;
980
+ this.consecutiveFailures = 0;
981
+ this.lastInferenceTime = 0;
982
+ if (this.canvasRef) {
983
+ const ctx = this.canvasRef.getContext("2d");
984
+ ctx.clearRect(0, 0, this.canvasRef.width, this.canvasRef.height);
985
+ }
986
+ // Reiniciar el detector si estaba funcionando
987
+ if (this.isVideoActive && this.session) {
988
+ this.detectFrame();
989
+ }
990
+ }
991
+ completeProcess(skippedBack = false) {
992
+ this.captureStep = 'completed';
993
+ this.statusMessage = skippedBack ?
994
+ "Proceso completado (solo frente capturado)" :
995
+ "Proceso de captura completado exitosamente";
996
+ this.statusColor = "#28a745";
997
+ // Detener el detector
998
+ this.stopDetection();
999
+ // Emitir evento con las imágenes capturadas
1000
+ const capturedImages = {
1001
+ front: {
1002
+ fullFrame: this.capturedFullFrame,
1003
+ cropped: this.capturedCroppedId
1004
+ },
1005
+ back: {
1006
+ fullFrame: this.capturedBackFullFrame,
1007
+ cropped: this.capturedBackCroppedId
1008
+ },
1009
+ timestamp: new Date().toISOString(),
1010
+ metadata: {
1011
+ totalImages: skippedBack ? 2 : 4,
1012
+ processCompleted: true,
1013
+ backCaptureSkipped: skippedBack
1014
+ }
1015
+ };
1016
+ this.captureCompleted.emit(capturedImages);
1017
+ // Mostrar animación de éxito después de la captura
1018
+ setTimeout(() => {
1019
+ this.showSuccessAnimation = true;
1020
+ setTimeout(() => {
1021
+ this.showSuccessAnimation = false;
1022
+ }, 3000);
1023
+ }, 800);
1024
+ }
1025
+ exitSession() {
1026
+ if (this.videoStream) {
1027
+ this.videoStream.getTracks().forEach(track => track.stop());
1028
+ this.videoStream = undefined;
1029
+ this.isVideoActive = false;
1030
+ this.statusMessage = "Sesión finalizada.";
1031
+ this.statusColor = "#aaa";
1032
+ }
1033
+ this.isLoading = false;
1034
+ // Limpiar canvas al finalizar sesión
1035
+ if (this.canvasRef) {
1036
+ const ctx = this.canvasRef.getContext("2d");
1037
+ ctx.clearRect(0, 0, this.canvasRef.width, this.canvasRef.height);
1038
+ }
1039
+ this.cleanup();
1040
+ }
1041
+ render() {
1042
+ return (h("div", { key: '42591479495df221b101555198a23288d7d765b0', class: "detector-container" }, h("div", { key: '2b9ab48572aa2fb5542b8a8dc1b70a0f2a6eca89', class: "video-container" }, h("video", { key: 'b9e84f2eb67fa6f7f158e19b90871a1eebee624b', ref: el => this.videoRef = el, autoplay: true, muted: true, playsinline: true, class: this.shouldMirrorVideo ? 'mirror' : '', style: { display: this.isVideoActive ? 'block' : 'none' } }), h("canvas", { key: 'a82fc4826e220e696799b07b3510456f174a6628', ref: el => this.canvasRef = el, class: this.shouldMirrorVideo ? 'mirror' : '' }), this.isMaskReady && (h("div", { key: '9b3b838f99030e3dfa760fa0dd7c89ff24f26ed9', class: "overlay-mask" }, h("div", { key: 'f6a3b1ac2f12c1fb081f6b5eb853e627040396f4', class: "card-outline" }, h("div", { key: '6626259249ac5e0fd6ba665ab802af1ac2f9fc17', class: "side side-top" }), h("div", { key: '7a3195c96b2406b40b122f4267c2a251614cdede', class: "side side-right" }), h("div", { key: 'ece78305cfb083ada1d44de1d7d5226730879cc3', class: "side side-bottom" }), h("div", { key: '107468c583bbb01dd46c36c096e49be8e0b574ba', class: "side side-left" }), h("div", { key: 'c590f13b80c5e37c0ac0c68cfc2e2904b4345ebc', class: "corner corner-tl" }), h("div", { key: 'ab1e5aab179068ad1bc7b58ef3628d9618a877a8', class: "corner corner-tr" }), h("div", { key: '3a1db6cf1105bd3a2dfe7d4b998e79f6e40625ec', class: "corner corner-bl" }), h("div", { key: '5f9bc4e4557e5539335894160dccbaa2a6d6ac2d', class: "corner corner-br" }), !this.showFlipAnimation && !this.showSuccessAnimation && (h("div", { key: '8226d6721b0ae800f935e978a93113bd3b99656a', class: "guide-text" }, this.statusMessage))), this.captureStep === 'back' && !this.showFlipAnimation && !this.showSuccessAnimation && (h("button", { key: '16cec7ca4a80ba0db1ace768826da17063eddb3e', class: "skip-button", onClick: () => this.skipBackCapture(), type: "button" }, "Saltar reverso")))), this.isCapturing && (h("div", { key: 'bfdca0059eb50d37a77e8e43ef963ba7ed953edf', class: "capture-animation" })), this.showFlipAnimation && (h("div", { key: 'a1ad4b4f884d7d9f6090f148ddd6df19250073dd', class: "flip-animation" }, h("div", { key: 'e159ce385824dc049a6e9409d3747105c6f0a08e', class: "id-card-icon" }), h("div", { key: '6fcff650a3c7fdb16f8d327750e06055b9a93d0d', class: "flip-text" }, "\u00A1Voltea tu identificaci\u00F3n!"))), this.showSuccessAnimation && (h("div", { key: 'c4b76ecb19c65969676e5156689c2c0b1c9a584e', class: "success-animation" }, h("div", { key: '12203a8fe7ee878089b3dda1d1142cde5489eed0', class: "check-icon" }), h("div", { key: 'a2d41c8944873d33106994b8d56c3ee1ee1ae9fc', class: "success-text" }, "\u00A1Proceso completado!"))), this.isLoading && (h("div", { key: 'a155cd999fa40c35fa7b391cde7c1026edb250a7', class: "loading-overlay" }, h("div", { key: 'ccba76c5d4a472158c28bc564ba95bd65829b58d', class: "loading-spinner" }), h("div", { key: '23168f9bdcf4e993539288ff5703acaed13bb16a', class: "loading-text" }, this.statusMessage))), h("div", { key: '0107b82ad19726c1bab131e17892a46b04e08cfd', class: "watermark" }, h("img", { key: 'ad8831a6f77fa61805f22e3a27f5c5619ac1cc0e', src: "https://storage.googleapis.com/jaak-static/commons/powered-by-jaak.png", alt: "Powered by Jaak" })))));
1043
+ }
1044
+ static get is() { return "jaak-stamps"; }
1045
+ static get encapsulation() { return "shadow"; }
1046
+ static get originalStyleUrls() {
1047
+ return {
1048
+ "$": ["my-component.css"]
1049
+ };
1050
+ }
1051
+ static get styleUrls() {
1052
+ return {
1053
+ "$": ["my-component.css"]
1054
+ };
1055
+ }
1056
+ static get properties() {
1057
+ return {
1058
+ "debug": {
1059
+ "type": "boolean",
1060
+ "attribute": "debug",
1061
+ "mutable": false,
1062
+ "complexType": {
1063
+ "original": "boolean",
1064
+ "resolved": "boolean",
1065
+ "references": {}
1066
+ },
1067
+ "required": false,
1068
+ "optional": false,
1069
+ "docs": {
1070
+ "tags": [],
1071
+ "text": ""
1072
+ },
1073
+ "getter": false,
1074
+ "setter": false,
1075
+ "reflect": false,
1076
+ "defaultValue": "false"
1077
+ },
1078
+ "alignmentTolerance": {
1079
+ "type": "number",
1080
+ "attribute": "alignment-tolerance",
1081
+ "mutable": false,
1082
+ "complexType": {
1083
+ "original": "number",
1084
+ "resolved": "number",
1085
+ "references": {}
1086
+ },
1087
+ "required": false,
1088
+ "optional": false,
1089
+ "docs": {
1090
+ "tags": [],
1091
+ "text": ""
1092
+ },
1093
+ "getter": false,
1094
+ "setter": false,
1095
+ "reflect": false,
1096
+ "defaultValue": "10"
1097
+ },
1098
+ "maskSize": {
1099
+ "type": "number",
1100
+ "attribute": "mask-size",
1101
+ "mutable": false,
1102
+ "complexType": {
1103
+ "original": "number",
1104
+ "resolved": "number",
1105
+ "references": {}
1106
+ },
1107
+ "required": false,
1108
+ "optional": false,
1109
+ "docs": {
1110
+ "tags": [],
1111
+ "text": ""
1112
+ },
1113
+ "getter": false,
1114
+ "setter": false,
1115
+ "reflect": false,
1116
+ "defaultValue": "90"
1117
+ },
1118
+ "cropMargin": {
1119
+ "type": "number",
1120
+ "attribute": "crop-margin",
1121
+ "mutable": false,
1122
+ "complexType": {
1123
+ "original": "number",
1124
+ "resolved": "number",
1125
+ "references": {}
1126
+ },
1127
+ "required": false,
1128
+ "optional": false,
1129
+ "docs": {
1130
+ "tags": [],
1131
+ "text": ""
1132
+ },
1133
+ "getter": false,
1134
+ "setter": false,
1135
+ "reflect": false,
1136
+ "defaultValue": "0"
1137
+ },
1138
+ "useDocumentClassification": {
1139
+ "type": "boolean",
1140
+ "attribute": "use-document-classification",
1141
+ "mutable": false,
1142
+ "complexType": {
1143
+ "original": "boolean",
1144
+ "resolved": "boolean",
1145
+ "references": {}
1146
+ },
1147
+ "required": false,
1148
+ "optional": false,
1149
+ "docs": {
1150
+ "tags": [],
1151
+ "text": ""
1152
+ },
1153
+ "getter": false,
1154
+ "setter": false,
1155
+ "reflect": false,
1156
+ "defaultValue": "false"
1157
+ }
1158
+ };
1159
+ }
1160
+ static get states() {
1161
+ return {
1162
+ "isVideoActive": {},
1163
+ "statusMessage": {},
1164
+ "statusColor": {},
1165
+ "bestScore": {},
1166
+ "capturedFullFrame": {},
1167
+ "capturedCroppedId": {},
1168
+ "capturedBackFullFrame": {},
1169
+ "capturedBackCroppedId": {},
1170
+ "captureStep": {},
1171
+ "isCapturing": {},
1172
+ "showFlipAnimation": {},
1173
+ "showSuccessAnimation": {},
1174
+ "shouldMirrorVideo": {},
1175
+ "sideAlignment": {},
1176
+ "isDetectionPaused": {},
1177
+ "isLoading": {},
1178
+ "isModelPreloaded": {},
1179
+ "isMaskReady": {}
1180
+ };
1181
+ }
1182
+ static get events() {
1183
+ return [{
1184
+ "method": "captureCompleted",
1185
+ "name": "captureCompleted",
1186
+ "bubbles": true,
1187
+ "cancelable": true,
1188
+ "composed": true,
1189
+ "docs": {
1190
+ "tags": [],
1191
+ "text": ""
1192
+ },
1193
+ "complexType": {
1194
+ "original": "any",
1195
+ "resolved": "any",
1196
+ "references": {}
1197
+ }
1198
+ }, {
1199
+ "method": "isReady",
1200
+ "name": "isReady",
1201
+ "bubbles": true,
1202
+ "cancelable": true,
1203
+ "composed": true,
1204
+ "docs": {
1205
+ "tags": [],
1206
+ "text": ""
1207
+ },
1208
+ "complexType": {
1209
+ "original": "boolean",
1210
+ "resolved": "boolean",
1211
+ "references": {}
1212
+ }
1213
+ }];
1214
+ }
1215
+ static get methods() {
1216
+ return {
1217
+ "getCapturedImages": {
1218
+ "complexType": {
1219
+ "signature": "() => Promise<{ front: { fullFrame: string; cropped: string; }; back: { fullFrame: string; cropped: string; }; metadata: { hasBackCapture: boolean; totalImages: number; }; }>",
1220
+ "parameters": [],
1221
+ "references": {
1222
+ "Promise": {
1223
+ "location": "global",
1224
+ "id": "global::Promise"
1225
+ }
1226
+ },
1227
+ "return": "Promise<{ front: { fullFrame: string; cropped: string; }; back: { fullFrame: string; cropped: string; }; metadata: { hasBackCapture: boolean; totalImages: number; }; }>"
1228
+ },
1229
+ "docs": {
1230
+ "text": "",
1231
+ "tags": []
1232
+ }
1233
+ },
1234
+ "isProcessCompleted": {
1235
+ "complexType": {
1236
+ "signature": "() => Promise<boolean>",
1237
+ "parameters": [],
1238
+ "references": {
1239
+ "Promise": {
1240
+ "location": "global",
1241
+ "id": "global::Promise"
1242
+ }
1243
+ },
1244
+ "return": "Promise<boolean>"
1245
+ },
1246
+ "docs": {
1247
+ "text": "",
1248
+ "tags": []
1249
+ }
1250
+ },
1251
+ "startCapture": {
1252
+ "complexType": {
1253
+ "signature": "() => Promise<void>",
1254
+ "parameters": [],
1255
+ "references": {
1256
+ "Promise": {
1257
+ "location": "global",
1258
+ "id": "global::Promise"
1259
+ }
1260
+ },
1261
+ "return": "Promise<void>"
1262
+ },
1263
+ "docs": {
1264
+ "text": "",
1265
+ "tags": []
1266
+ }
1267
+ },
1268
+ "stopCapture": {
1269
+ "complexType": {
1270
+ "signature": "() => Promise<void>",
1271
+ "parameters": [],
1272
+ "references": {
1273
+ "Promise": {
1274
+ "location": "global",
1275
+ "id": "global::Promise"
1276
+ }
1277
+ },
1278
+ "return": "Promise<void>"
1279
+ },
1280
+ "docs": {
1281
+ "text": "",
1282
+ "tags": []
1283
+ }
1284
+ },
1285
+ "resetCapture": {
1286
+ "complexType": {
1287
+ "signature": "() => Promise<void>",
1288
+ "parameters": [],
1289
+ "references": {
1290
+ "Promise": {
1291
+ "location": "global",
1292
+ "id": "global::Promise"
1293
+ }
1294
+ },
1295
+ "return": "Promise<void>"
1296
+ },
1297
+ "docs": {
1298
+ "text": "",
1299
+ "tags": []
1300
+ }
1301
+ },
1302
+ "getStatus": {
1303
+ "complexType": {
1304
+ "signature": "() => Promise<{ isVideoActive: boolean; captureStep: \"front\" | \"back\" | \"completed\"; statusMessage: string; hasImages: boolean; isProcessCompleted: boolean; isModelPreloaded: boolean; }>",
1305
+ "parameters": [],
1306
+ "references": {
1307
+ "Promise": {
1308
+ "location": "global",
1309
+ "id": "global::Promise"
1310
+ }
1311
+ },
1312
+ "return": "Promise<{ isVideoActive: boolean; captureStep: \"front\" | \"back\" | \"completed\"; statusMessage: string; hasImages: boolean; isProcessCompleted: boolean; isModelPreloaded: boolean; }>"
1313
+ },
1314
+ "docs": {
1315
+ "text": "",
1316
+ "tags": []
1317
+ }
1318
+ },
1319
+ "preloadModel": {
1320
+ "complexType": {
1321
+ "signature": "() => Promise<{ success: boolean; message: string; error?: undefined; } | { success: boolean; error: any; message?: undefined; }>",
1322
+ "parameters": [],
1323
+ "references": {
1324
+ "Promise": {
1325
+ "location": "global",
1326
+ "id": "global::Promise"
1327
+ }
1328
+ },
1329
+ "return": "Promise<{ success: boolean; message: string; error?: undefined; } | { success: boolean; error: any; message?: undefined; }>"
1330
+ },
1331
+ "docs": {
1332
+ "text": "",
1333
+ "tags": []
1334
+ }
1335
+ },
1336
+ "skipBackCapture": {
1337
+ "complexType": {
1338
+ "signature": "() => Promise<void>",
1339
+ "parameters": [],
1340
+ "references": {
1341
+ "Promise": {
1342
+ "location": "global",
1343
+ "id": "global::Promise"
1344
+ }
1345
+ },
1346
+ "return": "Promise<void>"
1347
+ },
1348
+ "docs": {
1349
+ "text": "",
1350
+ "tags": []
1351
+ }
1352
+ }
1353
+ };
1354
+ }
1355
+ static get elementRef() { return "el"; }
1356
+ }
1357
+ //# sourceMappingURL=my-component.js.map