@idscan/idvc2 2.5.1 → 2.5.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.
@@ -1 +1,228 @@
1
- var __webpack_require__={};__webpack_require__.d=(e,a)=>{for(var o in a)__webpack_require__.o(a,o)&&!__webpack_require__.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:a[o]})},__webpack_require__.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a);var __webpack_exports__={};__webpack_require__.d(__webpack_exports__,{J3:()=>supportedLanguages,_2:()=>setTranslation,i0:()=>getTranslation});var supportedLanguages=["en","es"],labels={es:{errorCodes:{mrz:"MRZ no fue reconocido",barcode:"Advertencia: <br/>No se pudieron leer los datos del c\xf3digo de barras.<br/>Intenta tomar una imagen de mayor calidad.",heic:"El archivo HEIC est\xe1 da\xf1ado",fileTypeHeic:"Error de tipo de archivo. Solo se admiten los tipos de archivo JPEG, PNG y HEIC.",fileType:"Error de tipo de archivo. Solo se admiten los tipos de archivo JPEG y PNG.",disableStepFileUpload:"Se debe utilizar un dispositivo con una c\xe1mara para capturar esta imagen",notAllowedDocument:"Este tipo de documento no est\xe1 permitido",frontSide:"Advertencia: <br/>No se pudo leer la parte frontal del documento. <br/>Intenta tomar una imagen de mayor calidad",default:"Lo sentimos, pero algo sali\xf3 mal. Int\xe9ntalo de nuevo",CameraNotFound:"No se encontr\xf3 ninguna c\xe1mara en su dispositivo",CameraNotAllowed:"Se le ha denegado el permiso para acceder a la c\xe1mara",CameraNotAvailable:"La c\xe1mara no est\xe1 disponible en este momento",CameraInUse:"La c\xe1mara ya est\xe1 en uso",MediaDevicesNotSupported:"Tu navegador no es compatible",lowImageResolution:"La resoluci\xf3n de la imagen cargada es demasiado baja"},hintTexts:{front:"Coloque el anverso del documento",frontMRZ:"Haga zoom para capturar el c\xf3digo en la parte inferior",mrz:"Haga zoom para capturar el c\xf3digo en la parte posterior",capturing:"Coloque el anverso del documento",pdf:"Coloque el c\xf3digo de barras dentro del marco",back:"Da la vuelta a tu documento",barcode:"Coloque el c\xf3digo de barras dentro del marco",hold:"Sostener el **placeholder** lado del documento <br> dentro de la caja",dontSee:"No te veo",dontMove:"No te muevas",turnFaceLeft:"Gira la cara a la izquierda",turnFaceRight:"Gira la cara a la derecha",turnFaceUp:"Levanta tu cara",turnFaceDown:"Bajar la cara",faceCam:"Enfr\xe9ntate a la c\xe1mara",camAway:"Mover la c\xe1mara m\xe1s lejos",moveCenter:"Mover al centro",comeCloser:"Ac\xe9rcate",holdCamera:"Mant\xe9ngase firme, analizando el documento <br>"},keyErrors:["La clave de licencia ha caducado","Clave de licencia no v\xe1lida"],camera:{loading:"Carga",awaiting:"A la espera de la respuesta de la c\xe1mara"},general:{documentType:"Su Tipo de Documento es",selectDocumentTypeText:"Seleccionar Tipo de Documento",changeBtn:"Cambiar",correctBtn:"Corregir",cancelBtn:"Cancelar",doneBtn:"Hecho",closeBtn:"Cerrar",retakeBtn:"VOLVER",continueBtn:"CONTINUAR",submitBtn:"ENVIAR",resetAllStepsBtn:"Restablecer todos los pasos",btnUploader:"Cambiar a cargador manual",btnCamera:"Cambiar al modo de c\xe1mara",pressToUpdateText:"Pulse para actualizar",pressToUpdateTextSuccess:"Pulse para actualizar"},uploaderDescription:{textFront:"Haga clic aqu\xed para cargar el frente de su identificaci\xf3n",textBack:"Haga clic aqu\xed para cargar el reverso de una identificaci\xf3n",textFace:"Haga clic aqu\xed para cargar una foto de su rostro",textPdf:"Haga clic aqu\xed para cargar el reverso de una identificaci\xf3n",textMrz:"Haga clic aqu\xed para cargar una foto de su documento'",textFrontBack:"Aseg\xfarese de que su identificaci\xf3n llene toda la pantalla de la c\xe1mara con poco o ning\xfan fondo.",textPass:"Aseg\xfarese de que su identificaci\xf3n llene toda la pantalla de la c\xe1mara <br> con poco o ning\xfan fondo, y que se incluya el c\xf3digo MRZ completo",textFacePosition:"Coloque su rostro para ocupar toda la pantalla de la c\xe1mara con poco o ning\xfan fondo."},documentsTypes:{ID:"Licencia de Conducir",Passport:"Pasaporte",PassportCard:"Tarjeta de Pasaporte",GreenCard:"Tarjeta Verde o Autorizaci\xf3n de Empleo",InternationalId:"Identificaci\xf3n Internacional"},spinnerText:{warmup:{top:"La red neuronal se est\xe1 calentando",bottom:"La captura de documentos estar\xe1 lista para su uso en breve"}}},en:{errorCodes:{mrz:"MRZ not recognized",barcode:"Warning: <br/>Barcode data could not be read.<br/>Try taking a higher quality image.",heic:"HEIC file incorrupted",fileType:"Error file type. Only jpeg and png supported.",fileTypeHeic:"Error file type. Only jpeg, png and heic supported.",disableStepFileUpload:"A device with a camera must be used to capture this image",notAllowedDocument:"This document type is not allowed",frontSide:"Warning: <br/>Front of the document could not be read. <br/>Try taking a higher quality image",default:"We're sorry, but something went wrong. Please try again",CameraNotFound:"No camera was found on your device",CameraNotAllowed:"You have denied camera access permission",CameraNotAvailable:"Camera is not available at this moment",CameraInUse:"Camera is already in use",MediaDevicesNotSupported:"Your browser is not supported",lowImageResolution:"The resolution of the uploaded image is too low"},hintTexts:{front:"Position the front of the document",frontMRZ:"Zoom in to capture code at bottom",mrz:"Zoom in to capture code on back side",capturing:"Position the front of the document",pdf:"Position the barcode inside the frame",back:"Turn around your document",barcode:"Position the barcode inside the frame",hold:"Hold the **placeholder** side of the document <br> inside the box",dontSee:"I don't see you",dontMove:"Don't move",turnFaceLeft:"Turn your face left",turnFaceRight:"Turn your face right",turnFaceUp:"Turn your face up",turnFaceDown:"Turn your face down",faceCam:"Face the camera",camAway:"Move camera further away",moveCenter:"Move to the center",comeCloser:"Come closer",holdCamera:"Hold steady, analyzing document <br>"},keyErrors:["License Key has expired","Invalid License Key"],camera:{loading:"Loading",awaiting:"Awaiting camera response"},general:{documentType:"Your document type is",selectDocumentTypeText:"Select Document Type",changeBtn:"Change",correctBtn:"Correct",cancelBtn:"Cancel",doneBtn:"Done",closeBtn:"CLOSE",retakeBtn:"Retake",continueBtn:"CONTINUE",submitBtn:"SUBMIT",resetAllStepsBtn:"Reset all steps",btnUploader:"Switch to manual uploader",btnCamera:"Switch to camera mode",pressToUpdateText:"Press to update",pressToUpdateTextSuccess:"Press to update"},documentsTypes:{ID:"Driver's License",Passport:"Passport",PassportCard:"Passport Card",GreenCard:"Green Card or Employment Authorization",InternationalId:"International ID"},uploaderDescription:{textFront:"Click here to upload the front of your ID",textBack:"Click here to upload the back of your ID",textFace:"Click here to upload a photo of your face",textPdf:"Click here to upload the back of a ID",textMrz:"Click here to upload a photo of your document",textFrontBack:"Please make sure your ID fills up the entire <br> camera screen with little to no background.",textPass:"Please make sure your ID fills up the entire camera screen <br> with little to no background, and the full MRZ code is included.",textFacePosition:"Please position your face to take up <br> the full camera screen with little to no background."},spinnerText:{warmup:{top:"Neural network is warming up",bottom:"Document capture will be ready to use shortly"}}}},translation=labels.en,setTranslation=function(e){if(e){var a=e.toLowerCase(),o=Object.keys(labels).includes(a)?a:"en";translation=labels[o]}else translation=labels.en},getTranslation=function(e){return e?translation[e]:translation},__webpack_exports__getTranslation=__webpack_exports__.i0,__webpack_exports__setTranslation=__webpack_exports__._2,__webpack_exports__supportedLanguages=__webpack_exports__.J3;export{__webpack_exports__getTranslation as getTranslation,__webpack_exports__setTranslation as setTranslation,__webpack_exports__supportedLanguages as supportedLanguages};
1
+ /******/ // The require scope
2
+ /******/ var __webpack_require__ = {};
3
+ /******/
4
+ /************************************************************************/
5
+ /******/ /* webpack/runtime/define property getters */
6
+ /******/ (() => {
7
+ /******/ // define getter functions for harmony exports
8
+ /******/ __webpack_require__.d = (exports, definition) => {
9
+ /******/ for(var key in definition) {
10
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
11
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
12
+ /******/ }
13
+ /******/ }
14
+ /******/ };
15
+ /******/ })();
16
+ /******/
17
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
18
+ /******/ (() => {
19
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
20
+ /******/ })();
21
+ /******/
22
+ /************************************************************************/
23
+ var __webpack_exports__ = {};
24
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
25
+ /* harmony export */ "J3": () => (/* binding */ supportedLanguages),
26
+ /* harmony export */ "_2": () => (/* binding */ setTranslation),
27
+ /* harmony export */ "i0": () => (/* binding */ getTranslation)
28
+ /* harmony export */ });
29
+ var supportedLanguages = [
30
+ 'en',
31
+ 'es'
32
+ ];
33
+ var labels = {
34
+ es: {
35
+ errorCodes: {
36
+ mrz: 'MRZ no fue reconocido',
37
+ barcode: 'Advertencia: <br/>No se pudieron leer los datos del código de barras.<br/>Intenta tomar una imagen de mayor calidad.',
38
+ heic: 'El archivo HEIC está dañado',
39
+ fileTypeHeic: 'Error de tipo de archivo. Solo se admiten los tipos de archivo JPEG, PNG y HEIC.',
40
+ fileType: 'Error de tipo de archivo. Solo se admiten los tipos de archivo JPEG y PNG.',
41
+ disableStepFileUpload: 'Se debe utilizar un dispositivo con una cámara para capturar esta imagen',
42
+ notAllowedDocument: 'Este tipo de documento no está permitido',
43
+ frontSide: 'Advertencia: <br/>No se pudo leer la parte frontal del documento. <br/>Intenta tomar una imagen de mayor calidad',
44
+ default: 'Lo sentimos, pero algo salió mal. Inténtalo de nuevo',
45
+ CameraNotFound: 'No se encontró ninguna cámara en su dispositivo',
46
+ CameraNotAllowed: 'Se le ha denegado el permiso para acceder a la cámara',
47
+ CameraNotAvailable: 'La cámara no está disponible en este momento',
48
+ CameraInUse: 'La cámara ya está en uso',
49
+ MediaDevicesNotSupported: 'Tu navegador no es compatible',
50
+ lowImageResolution: 'La resolución de la imagen cargada es demasiado baja'
51
+ },
52
+ hintTexts: {
53
+ front: 'Coloque el anverso del documento',
54
+ frontMRZ: 'Haga zoom para capturar el código en la parte inferior',
55
+ mrz: 'Haga zoom para capturar el código en la parte posterior',
56
+ capturing: 'Coloque el anverso del documento',
57
+ pdf: 'Coloque el código de barras dentro del marco',
58
+ back: 'Da la vuelta a tu documento',
59
+ barcode: 'Coloque el código de barras dentro del marco',
60
+ hold: 'Sostener el **placeholder** lado del documento <br> dentro de la caja',
61
+ dontSee: 'No te veo',
62
+ dontMove: 'No te muevas',
63
+ turnFaceLeft: 'Gira la cara a la izquierda',
64
+ turnFaceRight: 'Gira la cara a la derecha',
65
+ turnFaceUp: 'Levanta tu cara',
66
+ turnFaceDown: 'Bajar la cara',
67
+ faceCam: 'Enfréntate a la cámara',
68
+ camAway: 'Mover la cámara más lejos',
69
+ moveCenter: 'Mover al centro',
70
+ comeCloser: 'Acércate',
71
+ holdCamera: 'Manténgase firme, analizando el documento <br>'
72
+ },
73
+ keyErrors: [
74
+ 'La clave de licencia ha caducado',
75
+ 'Clave de licencia no válida'
76
+ ],
77
+ camera: {
78
+ loading: 'Carga',
79
+ awaiting: 'A la espera de la respuesta de la cámara'
80
+ },
81
+ general: {
82
+ documentType: 'Su Tipo de Documento es',
83
+ selectDocumentTypeText: 'Seleccionar Tipo de Documento',
84
+ changeBtn: 'Cambiar',
85
+ correctBtn: 'Corregir',
86
+ cancelBtn: 'Cancelar',
87
+ doneBtn: 'Hecho',
88
+ closeBtn: 'Cerrar',
89
+ retakeBtn: 'VOLVER',
90
+ continueBtn: 'CONTINUAR',
91
+ submitBtn: 'ENVIAR',
92
+ resetAllStepsBtn: 'Restablecer todos los pasos',
93
+ btnUploader: 'Cambiar a cargador manual',
94
+ btnCamera: 'Cambiar al modo de cámara',
95
+ pressToUpdateText: 'Pulse para actualizar',
96
+ pressToUpdateTextSuccess: 'Pulse para actualizar'
97
+ },
98
+ uploaderDescription: {
99
+ textFront: 'Haga clic aquí para cargar el frente de su identificación',
100
+ textBack: 'Haga clic aquí para cargar el reverso de una identificación',
101
+ textFace: 'Haga clic aquí para cargar una foto de su rostro',
102
+ textPdf: 'Haga clic aquí para cargar el reverso de una identificación',
103
+ textMrz: 'Haga clic aquí para cargar una foto de su documento\'',
104
+ textFrontBack: 'Asegúrese de que su identificación llene toda la pantalla de la cámara con poco o ningún fondo.',
105
+ textPass: 'Asegúrese de que su identificación llene toda la pantalla de la cámara <br> con poco o ningún fondo, y que se incluya el código MRZ completo',
106
+ textFacePosition: 'Coloque su rostro para ocupar toda la pantalla de la cámara con poco o ningún fondo.'
107
+ },
108
+ documentsTypes: {
109
+ ID: 'Licencia de Conducir',
110
+ Passport: 'Pasaporte',
111
+ PassportCard: 'Tarjeta de Pasaporte',
112
+ GreenCard: 'Tarjeta Verde o Autorización de Empleo',
113
+ InternationalId: 'Identificación Internacional'
114
+ },
115
+ spinnerText: {
116
+ warmup: {
117
+ top: 'La red neuronal se está calentando',
118
+ bottom: 'La captura de documentos estará lista para su uso en breve'
119
+ }
120
+ }
121
+ },
122
+ en: {
123
+ errorCodes: {
124
+ mrz: 'MRZ not recognized',
125
+ barcode: 'Warning: <br/>Barcode data could not be read.<br/>Try taking a higher quality image.',
126
+ heic: 'HEIC file incorrupted',
127
+ fileType: 'Error file type. Only jpeg and png supported.',
128
+ fileTypeHeic: 'Error file type. Only jpeg, png and heic supported.',
129
+ disableStepFileUpload: 'A device with a camera must be used to capture this image',
130
+ notAllowedDocument: 'This document type is not allowed',
131
+ frontSide: 'Warning: <br/>Front of the document could not be read. <br/>Try taking a higher quality image',
132
+ default: 'We\'re sorry, but something went wrong. Please try again',
133
+ CameraNotFound: 'No camera was found on your device',
134
+ CameraNotAllowed: 'You have denied camera access permission',
135
+ CameraNotAvailable: 'Camera is not available at this moment',
136
+ CameraInUse: 'Camera is already in use',
137
+ MediaDevicesNotSupported: 'Your browser is not supported',
138
+ lowImageResolution: 'The resolution of the uploaded image is too low'
139
+ },
140
+ hintTexts: {
141
+ front: 'Position the front of the document',
142
+ frontMRZ: 'Zoom in to capture code at bottom',
143
+ mrz: 'Zoom in to capture code on back side',
144
+ capturing: 'Position the front of the document',
145
+ pdf: 'Position the barcode inside the frame',
146
+ back: 'Turn around your document',
147
+ barcode: 'Position the barcode inside the frame',
148
+ hold: 'Hold the **placeholder** side of the document <br> inside the box',
149
+ dontSee: 'I don\'t see you',
150
+ dontMove: 'Don\'t move',
151
+ turnFaceLeft: 'Turn your face left',
152
+ turnFaceRight: 'Turn your face right',
153
+ turnFaceUp: 'Turn your face up',
154
+ turnFaceDown: 'Turn your face down',
155
+ faceCam: 'Face the camera',
156
+ camAway: 'Move camera further away',
157
+ moveCenter: 'Move to the center',
158
+ comeCloser: 'Come closer',
159
+ holdCamera: 'Hold steady, analyzing document <br>'
160
+ },
161
+ keyErrors: [
162
+ 'License Key has expired',
163
+ 'Invalid License Key'
164
+ ],
165
+ camera: {
166
+ loading: 'Loading',
167
+ awaiting: 'Awaiting camera response'
168
+ },
169
+ general: {
170
+ documentType: 'Your document type is',
171
+ selectDocumentTypeText: 'Select Document Type',
172
+ changeBtn: 'Change',
173
+ correctBtn: 'Correct',
174
+ cancelBtn: 'Cancel',
175
+ doneBtn: 'Done',
176
+ closeBtn: 'CLOSE',
177
+ retakeBtn: 'Retake',
178
+ continueBtn: 'CONTINUE',
179
+ submitBtn: 'SUBMIT',
180
+ resetAllStepsBtn: 'Reset all steps',
181
+ btnUploader: 'Switch to manual uploader',
182
+ btnCamera: 'Switch to camera mode',
183
+ pressToUpdateText: 'Press to update',
184
+ pressToUpdateTextSuccess: 'Press to update'
185
+ },
186
+ documentsTypes: {
187
+ ID: "Driver\'s License",
188
+ Passport: 'Passport',
189
+ PassportCard: 'Passport Card',
190
+ GreenCard: 'Green Card or Employment Authorization',
191
+ InternationalId: 'International ID'
192
+ },
193
+ uploaderDescription: {
194
+ textFront: 'Click here to upload the front of your ID',
195
+ textBack: 'Click here to upload the back of your ID',
196
+ textFace: 'Click here to upload a photo of your face',
197
+ textPdf: 'Click here to upload the back of a ID',
198
+ textMrz: 'Click here to upload a photo of your document',
199
+ textFrontBack: 'Please make sure your ID fills up the entire <br> camera screen with little to no background.',
200
+ textPass: 'Please make sure your ID fills up the entire camera screen <br> with little to no background, and the full MRZ code is included.',
201
+ textFacePosition: 'Please position your face to take up <br> the full camera screen with little to no background.'
202
+ },
203
+ spinnerText: {
204
+ warmup: {
205
+ top: 'Neural network is warming up',
206
+ bottom: 'Document capture will be ready to use shortly'
207
+ }
208
+ }
209
+ }
210
+ };
211
+ var translation = labels.en;
212
+ var setTranslation = function(translationLang) {
213
+ if (translationLang) {
214
+ var lang = translationLang.toLowerCase();
215
+ var trnaslation = Object.keys(labels).includes(lang) ? lang : 'en';
216
+ translation = labels[trnaslation];
217
+ } else {
218
+ translation = labels.en;
219
+ }
220
+ };
221
+ var getTranslation = function(groupName) {
222
+ return groupName ? translation[groupName] : translation;
223
+ };
224
+
225
+ var __webpack_exports__getTranslation = __webpack_exports__.i0;
226
+ var __webpack_exports__setTranslation = __webpack_exports__._2;
227
+ var __webpack_exports__supportedLanguages = __webpack_exports__.J3;
228
+ export { __webpack_exports__getTranslation as getTranslation, __webpack_exports__setTranslation as setTranslation, __webpack_exports__supportedLanguages as supportedLanguages };
@@ -0,0 +1,216 @@
1
+ var __webpack_exports__ = {};
2
+
3
+ ;// CONCATENATED MODULE: ./src/helpers/image.ts
4
+ var generateFaceColorFromAngle = function(angle) {
5
+ var color = Math.abs(Math.trunc(255 - angle));
6
+ if (color > 200) color = 200;
7
+ if (color < 50) color = 50;
8
+ return "rgba(255,215,".concat(color.toString(), ",0.3)");
9
+ };
10
+ /**
11
+ *
12
+ * @param {ImageData} iData
13
+ * @param {number} threshold
14
+ * @return number[] - black and whited array;
15
+ */ var binarize = function(iData) {
16
+ var threshold = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 120;
17
+ var setColor = 1;
18
+ var len = iData.width * iData.height;
19
+ var result = new Uint8ClampedArray(len);
20
+ var i;
21
+ var red = 0;
22
+ var green = 0;
23
+ var blue = 0;
24
+ var gray = 0;
25
+ for(i = 0; i < len; i += 1){
26
+ // eslint-disable-next-line no-bitwise
27
+ var n = i << 2; // fast version of i * 4
28
+ red = iData.data[n + 0];
29
+ green = iData.data[n + 1];
30
+ blue = iData.data[n + 2];
31
+ // eslint-disable-next-line no-bitwise
32
+ gray = 77 * red + 151 * green + 28 * blue >> 8;
33
+ if (gray < threshold) {
34
+ result[i] = setColor;
35
+ }
36
+ }
37
+ return result;
38
+ };
39
+ var topPoint = function(position, width) {
40
+ return position - width;
41
+ };
42
+ var bottomPoint = function(position, width) {
43
+ return position + width;
44
+ };
45
+ var leftPoint = function(position, width) {
46
+ return position % width > 1 ? position - 1 : -1;
47
+ };
48
+ var rightPoint = function(position, width) {
49
+ return (position + 1) % width >= 0 ? position + 1 : -1;
50
+ };
51
+ var topLeftPoint = function(position, width) {
52
+ return leftPoint(topPoint(position, width), width);
53
+ };
54
+ var topRightPoint = function(position, width) {
55
+ return rightPoint(topPoint(position, width), width);
56
+ };
57
+ var bottomLeftPoint = function(position, width) {
58
+ return leftPoint(bottomPoint(position, width), width);
59
+ };
60
+ var bottomRightPoint = function(position, width) {
61
+ return rightPoint(bottomPoint(position, width), width);
62
+ };
63
+ var getNeigbors = function(position, width) {
64
+ return [
65
+ topLeftPoint,
66
+ topPoint,
67
+ topRightPoint,
68
+ rightPoint,
69
+ bottomRightPoint,
70
+ bottomPoint,
71
+ bottomLeftPoint,
72
+ leftPoint
73
+ ].map(function(fn) {
74
+ return fn(position, width);
75
+ });
76
+ };
77
+ var segmentize2 = function(binarizedImg, width) {
78
+ var queue = [];
79
+ var segments = [];
80
+ var imgLen = binarizedImg.length;
81
+ var segmentIdx = 0;
82
+ var pixelIdx;
83
+ var search = function() {
84
+ var isValidPixel = function(el) {
85
+ return el > 0 && binarizedImg[el] !== 0 && el < imgLen;
86
+ };
87
+ while(queue.length){
88
+ var centerPixelIdx = queue.pop();
89
+ if (!centerPixelIdx) break;
90
+ // eslint-disable-next-line no-param-reassign
91
+ binarizedImg[centerPixelIdx] = 0;
92
+ segments[segmentIdx].add(centerPixelIdx);
93
+ getNeigbors(centerPixelIdx, width).forEach(function(el) {
94
+ if (isValidPixel(el)) {
95
+ queue.push(el);
96
+ }
97
+ });
98
+ }
99
+ };
100
+ for(pixelIdx = 0; pixelIdx < imgLen; pixelIdx += 1){
101
+ // eslint-disable-next-line no-continue
102
+ if (binarizedImg[pixelIdx] === 0) continue;
103
+ segments[segmentIdx] = new Set();
104
+ queue.push(pixelIdx);
105
+ search();
106
+ segmentIdx += 1;
107
+ }
108
+ return segments;
109
+ };
110
+ var getResizedSizes = function(size, param) {
111
+ var baseWidth = param.baseWidth, baseHeight = param.baseHeight;
112
+ var width = size;
113
+ var height = size;
114
+ if (baseWidth > baseHeight) {
115
+ width = size;
116
+ height = width * baseHeight / baseWidth;
117
+ }
118
+ if (baseHeight > baseWidth) {
119
+ height = size;
120
+ width = height * baseWidth / baseHeight;
121
+ }
122
+ return {
123
+ width: Math.trunc(width),
124
+ height: Math.trunc(height)
125
+ };
126
+ };
127
+ var getCrop = function(src, dst) {
128
+ var srcWidth = src.width;
129
+ var srcHeight = src.height;
130
+ var aspectRatioSrc = srcWidth / srcHeight; // float
131
+ var aspectRatioDst = dst.width / dst.height; // float
132
+ var targetCrop = {
133
+ x: 0,
134
+ y: 0,
135
+ width: dst.width,
136
+ height: dst.height
137
+ };
138
+ if (aspectRatioSrc > aspectRatioDst) {
139
+ targetCrop.height = ~~(dst.width / aspectRatioSrc);
140
+ targetCrop.y = (dst.height - targetCrop.height) / 2;
141
+ } else {
142
+ targetCrop.width = ~~(targetCrop.height * aspectRatioSrc);
143
+ targetCrop.x = (dst.width - targetCrop.width) / 2;
144
+ }
145
+ return targetCrop;
146
+ };
147
+
148
+ ;// CONCATENATED MODULE: ./src/constatnts/imageProcessing.ts
149
+ var POINT_FILL_STYLE = 'rgba(255, 255, 255, 0.5)';
150
+ var POINT_STROKE_STYLE = 'rgba(255, 255, 255, 0)';
151
+ var SCALE_FACTOR = 0.3;
152
+
153
+ ;// CONCATENATED MODULE: ./src/workers/bubbleWorker.ts
154
+
155
+
156
+ var getColumn = function(d, w) {
157
+ return d % w;
158
+ };
159
+ var getRow = function(d, w) {
160
+ return Math.floor(d / w);
161
+ };
162
+ var createCoordFromPointIdx = function(pixelPosition, width) {
163
+ return [
164
+ getColumn(pixelPosition, width),
165
+ getRow(pixelPosition, width)
166
+ ];
167
+ };
168
+ var notNull = function(value) {
169
+ return value !== null && value !== undefined;
170
+ };
171
+ var coordinateSegment = function(param) {
172
+ var segments = param.segments, width = param.width, scaleWidth = param.scaleWidth, scaleHeight = param.scaleHeight;
173
+ var MIN_PERIMETER = 5;
174
+ var MAX_PERIMETER = 500;
175
+ return segments.map(function(segment) {
176
+ var minX = Number.MAX_VALUE; // ignoring case of empty list for conciseness
177
+ var minY = Number.MAX_VALUE;
178
+ var maxX = Number.MIN_VALUE;
179
+ var maxY = Number.MIN_VALUE;
180
+ segment.forEach(function(position) {
181
+ var coord = createCoordFromPointIdx(position, width);
182
+ if (coord[0] < minX) minX = coord[0];
183
+ if (coord[1] < minY) minY = coord[1];
184
+ if (coord[0] > maxX) maxX = coord[0];
185
+ if (coord[1] > maxY) maxY = coord[1];
186
+ });
187
+ var per = (maxX - minX) * (maxY - minY);
188
+ if (per > MIN_PERIMETER && per < MAX_PERIMETER) {
189
+ return {
190
+ perimeter: per,
191
+ x1: Math.trunc(minX / SCALE_FACTOR / scaleWidth),
192
+ y1: Math.trunc(minY / SCALE_FACTOR / scaleHeight),
193
+ x2: Math.trunc(maxX / SCALE_FACTOR / scaleWidth),
194
+ y2: Math.trunc(maxY / SCALE_FACTOR / scaleHeight)
195
+ };
196
+ }
197
+ return null;
198
+ }).filter(notNull);
199
+ };
200
+ var pointsProcess = function(iData, scaleWidth, scaleHeight) {
201
+ var bin = binarize(iData);
202
+ return coordinateSegment({
203
+ segments: segmentize2(bin, iData.width),
204
+ width: iData.width,
205
+ scaleWidth: scaleWidth,
206
+ scaleHeight: scaleHeight
207
+ });
208
+ };
209
+ onmessage = function(param) {
210
+ var data = param.data;
211
+ var segments = pointsProcess(data.iData, data.resizedToBorderScaleWidth, data.resizedToBorderScaleHeight);
212
+ postMessage({
213
+ segments: segments
214
+ });
215
+ };
216
+