@jvsoft/utils 0.0.13-alpha.1 → 0.0.13-alpha.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 (119) hide show
  1. package/classes/data-model.d.ts +25 -0
  2. package/fesm2022/jvsoft-utils-src-functions.mjs +1109 -0
  3. package/fesm2022/jvsoft-utils-src-functions.mjs.map +1 -0
  4. package/fesm2022/jvsoft-utils-src-interfaces.mjs +6 -0
  5. package/fesm2022/jvsoft-utils-src-interfaces.mjs.map +1 -0
  6. package/fesm2022/jvsoft-utils-src-pipes.mjs +290 -0
  7. package/fesm2022/jvsoft-utils-src-pipes.mjs.map +1 -0
  8. package/fesm2022/jvsoft-utils.mjs +1526 -0
  9. package/fesm2022/jvsoft-utils.mjs.map +1 -0
  10. package/functions/base64.d.ts +2 -0
  11. package/functions/browser.d.ts +1 -0
  12. package/functions/crypto-js.d.ts +2 -0
  13. package/functions/date.d.ts +3 -0
  14. package/functions/email.d.ts +2 -0
  15. package/functions/file.d.ts +10 -0
  16. package/functions/forms.d.ts +10 -0
  17. package/functions/http-client.d.ts +2 -0
  18. package/functions/index.d.ts +1 -0
  19. package/functions/local-storage.d.ts +29 -0
  20. package/functions/mat-form-controls/autocomplete.d.ts +21 -0
  21. package/functions/mat-form-controls/index.d.ts +2 -0
  22. package/functions/number.d.ts +1 -0
  23. package/functions/object-transformation.d.ts +2 -0
  24. package/functions/objects-arrays.d.ts +37 -0
  25. package/functions/public-api.d.ts +16 -0
  26. package/functions/string.d.ts +1 -0
  27. package/functions/sweetalert.d.ts +5 -0
  28. package/functions/utiles.d.ts +1 -0
  29. package/index.d.ts +5 -0
  30. package/{src/interfaces/datos.ts → interfaces/datos.d.ts} +1 -2
  31. package/interfaces/index.d.ts +1 -0
  32. package/interfaces/public-api.d.ts +1 -0
  33. package/package.json +25 -2
  34. package/pipes/data-en-lista.pipe.d.ts +8 -0
  35. package/pipes/date-diff-string.pipe.d.ts +17 -0
  36. package/pipes/filtro.pipe.d.ts +18 -0
  37. package/pipes/form-control-is-required.pipe.d.ts +9 -0
  38. package/pipes/index.d.ts +1 -0
  39. package/pipes/json-parse.pipe.d.ts +7 -0
  40. package/pipes/no-sanitize.pipe.d.ts +10 -0
  41. package/pipes/public-api.d.ts +8 -0
  42. package/pipes/tipo-valor-funcion.pipe.d.ts +9 -0
  43. package/pipes/zero-fill.pipe.d.ts +8 -0
  44. package/public-api.d.ts +4 -0
  45. package/src/functions/base64.d.ts +2 -0
  46. package/src/functions/browser.d.ts +1 -0
  47. package/src/functions/crypto-js.d.ts +2 -0
  48. package/src/functions/date.d.ts +3 -0
  49. package/src/functions/email.d.ts +2 -0
  50. package/src/functions/file.d.ts +10 -0
  51. package/src/functions/forms.d.ts +10 -0
  52. package/src/functions/http-client.d.ts +2 -0
  53. package/src/functions/index.d.ts +5 -0
  54. package/src/functions/local-storage.d.ts +29 -0
  55. package/src/functions/mat-form-controls/autocomplete.d.ts +21 -0
  56. package/src/functions/mat-form-controls/index.d.ts +2 -0
  57. package/src/functions/number.d.ts +1 -0
  58. package/src/functions/object-transformation.d.ts +2 -0
  59. package/src/functions/objects-arrays.d.ts +37 -0
  60. package/src/functions/public-api.d.ts +16 -0
  61. package/src/functions/string.d.ts +1 -0
  62. package/src/functions/sweetalert.d.ts +5 -0
  63. package/src/functions/utiles.d.ts +1 -0
  64. package/src/interfaces/datos.d.ts +4 -0
  65. package/src/interfaces/index.d.ts +5 -0
  66. package/src/interfaces/public-api.d.ts +1 -0
  67. package/src/pipes/data-en-lista.pipe.d.ts +8 -0
  68. package/src/pipes/date-diff-string.pipe.d.ts +17 -0
  69. package/src/pipes/filtro.pipe.d.ts +18 -0
  70. package/src/pipes/form-control-is-required.pipe.d.ts +9 -0
  71. package/src/pipes/index.d.ts +5 -0
  72. package/src/pipes/json-parse.pipe.d.ts +7 -0
  73. package/src/pipes/no-sanitize.pipe.d.ts +10 -0
  74. package/src/pipes/public-api.d.ts +8 -0
  75. package/src/pipes/tipo-valor-funcion.pipe.d.ts +9 -0
  76. package/src/pipes/zero-fill.pipe.d.ts +8 -0
  77. package/CHANGELOG.md +0 -13
  78. package/ng-package.json +0 -7
  79. package/src/classes/data-model.ts +0 -150
  80. package/src/functions/base64.ts +0 -8
  81. package/src/functions/browser.ts +0 -20
  82. package/src/functions/crypto-js.ts +0 -29
  83. package/src/functions/date.ts +0 -23
  84. package/src/functions/email.ts +0 -17
  85. package/src/functions/file.ts +0 -138
  86. package/src/functions/forms.ts +0 -145
  87. package/src/functions/http-client.ts +0 -110
  88. package/src/functions/index.ts +0 -1
  89. package/src/functions/local-storage.ts +0 -102
  90. package/src/functions/mat-form-controls/autocomplete.ts +0 -275
  91. package/src/functions/mat-form-controls/index.ts +0 -6
  92. package/src/functions/ng-package.json +0 -5
  93. package/src/functions/number.ts +0 -3
  94. package/src/functions/object-transformation.ts +0 -37
  95. package/src/functions/objects-arrays.ts +0 -243
  96. package/src/functions/public-api.ts +0 -19
  97. package/src/functions/string.ts +0 -9
  98. package/src/functions/sweetalert.ts +0 -95
  99. package/src/functions/utiles.ts +0 -20
  100. package/src/interfaces/index.ts +0 -1
  101. package/src/interfaces/ng-package.json +0 -5
  102. package/src/interfaces/otros.ts +0 -0
  103. package/src/interfaces/public-api.ts +0 -3
  104. package/src/interfaces/routes.ts +0 -42
  105. package/src/pipes/data-en-lista.pipe.ts +0 -40
  106. package/src/pipes/date-diff-string.pipe.ts +0 -117
  107. package/src/pipes/filtro.pipe.ts +0 -64
  108. package/src/pipes/form-control-is-required.pipe.ts +0 -17
  109. package/src/pipes/index.ts +0 -1
  110. package/src/pipes/json-parse.pipe.ts +0 -18
  111. package/src/pipes/ng-package.json +0 -5
  112. package/src/pipes/no-sanitize.pipe.ts +0 -12
  113. package/src/pipes/public-api.ts +0 -10
  114. package/src/pipes/tipo-valor-funcion.pipe.ts +0 -23
  115. package/src/pipes/zero-fill.pipe.ts +0 -19
  116. package/src/public-api.ts +0 -12
  117. package/tsconfig.lib.json +0 -17
  118. package/tsconfig.lib.prod.json +0 -11
  119. package/tsconfig.spec.json +0 -15
@@ -0,0 +1,1526 @@
1
+ import { Validators, FormGroup, FormControl, FormArray } from '@angular/forms';
2
+ import { untilDestroyed } from '@ngneat/until-destroy';
3
+ import { startWith, debounceTime, tap, isObservable, switchMap, of, finalize } from 'rxjs';
4
+ import { map } from 'rxjs/operators';
5
+ import { Buffer } from 'buffer';
6
+ import CryptoJS from 'crypto-js';
7
+ import { formatDate } from '@angular/common';
8
+ import { saveAs } from 'file-saver';
9
+ import { ReactiveFormConfig } from '@rxweb/reactive-form-validators';
10
+ import swal from 'sweetalert2';
11
+ import moment from 'moment';
12
+ import { jwtDecode } from 'jwt-decode';
13
+ import * as i0 from '@angular/core';
14
+ import { Pipe } from '@angular/core';
15
+ import * as i1 from '@angular/platform-browser';
16
+
17
+ function deepMerge(source, target) {
18
+ // Crea un clon profundo sin usar JSON.parse(JSON.stringify)
19
+ let cloneSource = deepClone(source);
20
+ if (typeof target !== 'object' || target === null) {
21
+ return target;
22
+ }
23
+ if (typeof cloneSource !== 'object' || cloneSource === null) {
24
+ cloneSource = Array.isArray(target) ? [] : {};
25
+ }
26
+ for (const key of Object.keys(target)) {
27
+ const targetValue = target[key];
28
+ const sourceValue = cloneSource[key];
29
+ if (typeof targetValue === 'object' && targetValue !== null && !Array.isArray(targetValue)) {
30
+ cloneSource[key] = deepMerge(sourceValue, targetValue);
31
+ }
32
+ else {
33
+ cloneSource[key] = targetValue;
34
+ }
35
+ }
36
+ return cloneSource; // Retorna el clon y no modifica el original
37
+ }
38
+ // Función de clonación profunda que maneja funciones, fechas y otros tipos especiales
39
+ function deepClone(obj) {
40
+ if (obj === null || typeof obj !== 'object') {
41
+ return obj; // Devuelve el valor si no es un objeto
42
+ }
43
+ // Manejar instancias de Date
44
+ if (obj instanceof Date) {
45
+ return new Date(obj.getTime());
46
+ }
47
+ // Manejar funciones devolviendo una copia directa
48
+ if (typeof obj === 'function') {
49
+ return obj.bind({}); // Devuelve una copia de la función enlazada a un contexto vacío
50
+ }
51
+ // Crear un nuevo objeto o array
52
+ const clonedObj = Array.isArray(obj) ? [] : {};
53
+ // Clonar recursivamente las propiedades del objeto
54
+ for (const key in obj) {
55
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
56
+ clonedObj[key] = deepClone(obj[key]);
57
+ }
58
+ }
59
+ return clonedObj;
60
+ }
61
+ /**
62
+ * Busca un elemento en un array o jerarquía de objetos según un campo y valor especificado.
63
+ *
64
+ * @returns El elemento encontrado o undefined si no existe.
65
+ */
66
+ function buscarPorCampo(datosFn) {
67
+ for (const item of datosFn.items) {
68
+ // Verifica si el campo coincide con el valor
69
+ if (item[datosFn.campo] === datosFn.valor) {
70
+ return item;
71
+ }
72
+ // Verifica si hay un campo hijo y si es un array
73
+ if (datosFn.campoHijo && item[datosFn.campoHijo] && Array.isArray(item[datosFn.campoHijo])) {
74
+ // Realiza la búsqueda recursiva en el campo hijo
75
+ const encontrado = buscarPorCampo({
76
+ items: item[datosFn.campoHijo], // Asegura el tipo correcto
77
+ campo: datosFn.campo,
78
+ valor: datosFn.valor,
79
+ campoHijo: datosFn.campoHijo,
80
+ });
81
+ // Si se encuentra el valor en el campo hijo, retorna el resultado
82
+ if (encontrado) {
83
+ return encontrado;
84
+ }
85
+ }
86
+ }
87
+ // Si no se encuentra nada, retorna undefined
88
+ return undefined;
89
+ }
90
+ function sumarPropiedades(item, campos) {
91
+ const datosSumar = campos.map(campo => (item[campo] * 1));
92
+ return datosSumar.reduce((a, b) => a + b, 0);
93
+ }
94
+ function esNumero(value) {
95
+ return !isNaN(Number(value));
96
+ }
97
+ function sumarObjetos(arrayObjetos, campos) {
98
+ return arrayObjetos.reduce((accumulator, item) => {
99
+ campos.forEach(campo => {
100
+ const valor = Number(item[campo]);
101
+ if (!isNaN(valor)) {
102
+ accumulator[campo] = (accumulator[campo] ?? 0) + valor;
103
+ }
104
+ });
105
+ return accumulator;
106
+ }, {});
107
+ }
108
+ function getUniqueValues(array) {
109
+ return array.filter((currentValue, index, arr) => (arr.indexOf(currentValue) === index));
110
+ }
111
+ function getUniqueValuesByProperty(objetos, campo) {
112
+ const objetosUnicos = {};
113
+ objetos.forEach(objeto => {
114
+ // Verificar si el objeto tiene el campo especificado
115
+ // @ts-ignore
116
+ if (objeto.hasOwnProperty(campo)) {
117
+ // @ts-ignore
118
+ const valorCampo = objeto[campo];
119
+ // Utilizar el valor del campo como clave en un objeto para asegurar que no haya duplicados
120
+ objetosUnicos[valorCampo] = objeto;
121
+ }
122
+ });
123
+ // Convertir el objeto de claves únicas de vuelta a una lista de objetos
124
+ return Object.values(objetosUnicos);
125
+ }
126
+ function ordenarArray(array, numeros = false, sentido = 'ASC') {
127
+ if (numeros) {
128
+ if (sentido != 'ASC') {
129
+ return array.sort((a, b) => b - a);
130
+ }
131
+ return array.sort((a, b) => a - b);
132
+ }
133
+ return array.sort((a, b) => (a > b) ? 1 : ((b > a) ? -1 : 0));
134
+ }
135
+ function ordenarPorPropiedad(objData, propiedad, /**@deprecated*/ numeros = false) {
136
+ return ordenarPorPropiedades(objData, { propiedades: [propiedad], direcciones: ['asc'] });
137
+ }
138
+ function ordenarPorPropiedades(arr, options) {
139
+ const { propiedades, direcciones = [] } = options;
140
+ const orden = direcciones.map(d => d === 'desc' ? -1 : 1);
141
+ return [...arr].sort((a, b) => {
142
+ return propiedades.reduce((acc, propiedad, index) => {
143
+ if (acc !== 0)
144
+ return acc; // Si ya hay diferencia, no seguir comparando
145
+ const aValue = a[propiedad];
146
+ const bValue = b[propiedad];
147
+ if (typeof aValue === 'string' && typeof bValue === 'string') {
148
+ return aValue.localeCompare(bValue) * orden[index]; // 🔹 Comparación alfabética
149
+ }
150
+ if (typeof aValue === 'number' && typeof bValue === 'number') {
151
+ return (aValue - bValue) * orden[index]; // 🔹 Comparación numérica
152
+ }
153
+ return 0; // En caso de valores no comparables
154
+ }, 0);
155
+ });
156
+ }
157
+ function groupBy(array, key) {
158
+ const keyFn = key instanceof Function ? key : (obj) => obj[key];
159
+ return array.reduce((objectsByKeyValue, obj) => {
160
+ const value = keyFn(obj);
161
+ objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
162
+ return objectsByKeyValue;
163
+ }, {});
164
+ }
165
+ function nestGroupsBy(arr, properties) {
166
+ const fnGroupBy = (conversions, property2) => {
167
+ return conversions.reduce((acc, obj) => {
168
+ const key = obj[property2];
169
+ if (!acc[key]) {
170
+ acc[key] = [];
171
+ }
172
+ acc[key].push(obj);
173
+ return acc;
174
+ }, {});
175
+ };
176
+ properties = Array.from(properties);
177
+ if (properties.length === 1) {
178
+ return fnGroupBy(arr, properties[0]);
179
+ }
180
+ const property = properties.shift();
181
+ const grouped = fnGroupBy(arr, property);
182
+ Object.keys(grouped).forEach(key => {
183
+ grouped[key] = nestGroupsBy(grouped[key], Array.from(properties));
184
+ });
185
+ return grouped;
186
+ }
187
+ /**
188
+ * Obtiene un valor de un objeto usando una ruta de propiedad anidada.
189
+ *
190
+ * @param obj - Objeto de entrada.
191
+ * @param path - Ruta en formato punto (ej: "cliente.orden").
192
+ * @returns El valor encontrado o undefined si no existe.
193
+ */
194
+ function getValueByPath(obj, path) {
195
+ return path.split('.').reduce((acc, key) => acc?.[key], obj);
196
+ }
197
+ /**
198
+ * Retorna el valor máximo del campo especificado (incluso anidado) en un arreglo de objetos.
199
+ *
200
+ * @param data - Lista de objetos a procesar.
201
+ * @param campo - Nombre del campo a evaluar, puede ser anidado (ej. "campo.orden").
202
+ * @param incrementar - Si es true, retorna el valor máximo + 1. Por defecto es true.
203
+ * @returns El valor máximo encontrado, posiblemente incrementado.
204
+ */
205
+ function obtenerUltimoOrden(data, campo, incrementar = true) {
206
+ const max = data.reduce((mayor, item) => {
207
+ const valor = Number(getValueByPath(item, campo)) || 0;
208
+ return valor > mayor ? valor : mayor;
209
+ }, 0);
210
+ return incrementar ? max + 1 : max;
211
+ }
212
+
213
+ function mostrarValorEnBusqueda(campos, idxSel) {
214
+ const impDataMostrar = () => {
215
+ let vD;
216
+ if (campos.campoId == '*object*' || campos.campoId == '*objeto*') {
217
+ console.log(campos);
218
+ vD = campos.lista.find((x) => JSON.stringify(x).trim() == JSON.stringify(idxSel).trim());
219
+ console.log(vD);
220
+ }
221
+ else {
222
+ vD = campos.lista.find((x) => x[campos.campoId] == idxSel);
223
+ }
224
+ if (!vD && campos.opcExtra) {
225
+ console.log('eval ', campos.opcExtra);
226
+ if (campos.campoId == '*object*' || campos.campoId == '*objeto*') {
227
+ console.log(campos);
228
+ vD = campos.opcExtra.find((x) => JSON.stringify(x).trim() == JSON.stringify(idxSel).trim());
229
+ console.log(vD);
230
+ }
231
+ else {
232
+ vD = campos.opcExtra.find((x) => x[campos.campoId] == idxSel);
233
+ }
234
+ }
235
+ if (vD) {
236
+ let txtFinal = '';
237
+ if (Array.isArray(campos.campoValue)) {
238
+ campos.campoValue.forEach((vCampo, idx) => {
239
+ txtFinal += (vD[vCampo] ?? '');
240
+ if (idx < campos.campoValue.length - 1) {
241
+ txtFinal += ' - ';
242
+ }
243
+ });
244
+ }
245
+ else {
246
+ txtFinal = vD[campos.campoValue] ?? '';
247
+ }
248
+ return txtFinal.trim();
249
+ }
250
+ else {
251
+ console.log('ASSSSS ----- SSSS ');
252
+ }
253
+ return '';
254
+ };
255
+ if (esNumero(idxSel)) {
256
+ if (idxSel > 0 && campos.lista?.length > 0) {
257
+ return impDataMostrar();
258
+ }
259
+ else if (idxSel && typeof idxSel == 'object') {
260
+ return impDataMostrar();
261
+ }
262
+ }
263
+ else {
264
+ if (campos.lista?.length > 0) {
265
+ return impDataMostrar();
266
+ }
267
+ }
268
+ return '';
269
+ }
270
+ function changeSelectData(objThis, dataFiltro) {
271
+ objThis['filtrados'][dataFiltro.variableResultado] = dataFiltro.formControl.valueChanges.pipe(untilDestroyed(objThis)).pipe(startWith(''), map(value => {
272
+ const varN = dataFiltro.data;
273
+ if (varN) {
274
+ if (value) {
275
+ return varN.map(x => x).filter(dat => {
276
+ if (Array.isArray(dataFiltro.campoBuscar)) {
277
+ let encontrado = false;
278
+ for (const vCampo of dataFiltro.campoBuscar) {
279
+ // console.log(vCampo, value, dat[vCampo]);
280
+ if (isNaN(Number(value))) {
281
+ // NO ES NUMERO
282
+ if (value && dat[vCampo] && dat[vCampo].toLowerCase().includes(value?.toString().toLowerCase())) {
283
+ encontrado = true;
284
+ break;
285
+ }
286
+ }
287
+ else {
288
+ if (value && dat[vCampo] && dat[vCampo].toString().includes(value?.toString())) {
289
+ encontrado = true;
290
+ break;
291
+ }
292
+ }
293
+ }
294
+ return encontrado;
295
+ }
296
+ else {
297
+ if (isNaN(Number(value))) {
298
+ return dat[dataFiltro.campoBuscar].toLowerCase().includes(value?.toString().toLowerCase());
299
+ }
300
+ else {
301
+ return dat[dataFiltro.campoBuscar].toString().includes(value?.toString());
302
+ }
303
+ }
304
+ });
305
+ }
306
+ return varN;
307
+ }
308
+ return false;
309
+ }));
310
+ }
311
+ function changeSelect(control, formControl, tipo, campoBuscar, campoFiltro = null) {
312
+ // console.log(formControl);
313
+ // const formGroup = formControl.parent.controls;
314
+ // console.warn( Object.keys(formGroup).find(name => formControl === formGroup[name]) || null );
315
+ if (!campoFiltro) {
316
+ campoFiltro = tipo;
317
+ }
318
+ control['filtrados'][campoFiltro ?? '__'] = formControl.valueChanges.pipe(untilDestroyed(control)).pipe(startWith(''), map(value => {
319
+ // console.warn(value);
320
+ const partes = tipo.split('.');
321
+ let varN;
322
+ if (control['dataServidor']) {
323
+ varN = (partes.length > 1) ? control['dataServidor'][partes[0]][partes[1]] : control['dataServidor'][tipo];
324
+ }
325
+ else if (control['dataServidorSuscripcion']) {
326
+ varN = control['dataServidorSuscripcion'][tipo].getValue();
327
+ }
328
+ if (varN) {
329
+ if (value) {
330
+ return varN.map((x) => x).filter((dat) => {
331
+ if (Array.isArray(campoBuscar)) {
332
+ let encontrado = false;
333
+ for (const vCampo of campoBuscar) {
334
+ // console.log(vCampo, value, dat[vCampo]);
335
+ if (isNaN(Number(value))) {
336
+ // NO ES NUMERO
337
+ if (value && dat[vCampo] && dat[vCampo].toLowerCase().includes(value?.toString().toLowerCase())) {
338
+ encontrado = true;
339
+ break;
340
+ }
341
+ }
342
+ else {
343
+ if (value && dat[vCampo] && dat[vCampo].toString().includes(value?.toString())) {
344
+ encontrado = true;
345
+ break;
346
+ }
347
+ }
348
+ }
349
+ return encontrado;
350
+ }
351
+ else {
352
+ if (isNaN(Number(value))) {
353
+ return dat[campoBuscar].toLowerCase().includes(value?.toString().toLowerCase());
354
+ }
355
+ else {
356
+ return dat[campoBuscar].toString().includes(value?.toString());
357
+ }
358
+ }
359
+ });
360
+ }
361
+ return varN;
362
+ }
363
+ return false;
364
+ }));
365
+ }
366
+ function changeSelectDataApi(objThis, dataFiltro) {
367
+ if (!dataFiltro.variableResultado) {
368
+ dataFiltro.variableResultado = dataFiltro.tipoReq;
369
+ }
370
+ const idFiltrado = dataFiltro.variableResultado;
371
+ dataFiltro.formControl.valueChanges.pipe(debounceTime(500), tap(() => {
372
+ objThis.filtrados[dataFiltro.variableResultado + 'tmp'] = isObservable(objThis.filtrados[idFiltrado]) ? [] : objThis.filtrados[idFiltrado] || [];
373
+ if (objThis.filtrados[idFiltrado] !== objThis.filtrados[idFiltrado + 'tmp']) {
374
+ objThis.filtrados[idFiltrado] = [];
375
+ }
376
+ objThis.isLoading = true;
377
+ }), switchMap(value => {
378
+ if (dataFiltro.campoId) {
379
+ const busquedaActual2 = objThis.filtrados[idFiltrado + 'tmp'].findIndex((item) => item[dataFiltro.campoId ?? '--'] === value);
380
+ if (busquedaActual2 >= 0) {
381
+ return of({ [dataFiltro.tipoReq]: objThis.filtrados[idFiltrado + 'tmp'] });
382
+ }
383
+ }
384
+ return !value || value.length < (dataFiltro.minLength ?? 3) ? [] : (dataFiltro.queryService.getDataMethod('GET', dataFiltro.tipoReq, {
385
+ ...(dataFiltro.dataExtra ?? {}),
386
+ ...(dataFiltro.dataExtraVariable ? Object.fromEntries(dataFiltro.dataExtraVariable.map((objData) => [objData.campo, objData.ctrlValue.value])) : {}),
387
+ txtBuscar: value,
388
+ }, dataFiltro.anonimo).pipe(finalize(() => objThis.isLoading = false)));
389
+ })).subscribe((data) => {
390
+ objThis.filtrados[idFiltrado] = data[dataFiltro.tipoReq] ?? [];
391
+ });
392
+ }
393
+ function changeSelectApi(control, queryService, formControl, tipo, dataExtra = {}, dataExtraVariable = null, minLength = 1, anonimo = false) {
394
+ formControl.valueChanges.pipe(debounceTime(500), tap((value) => {
395
+ control['filtrados'][tipo + 'tmp'] = isObservable(control['filtrados'][tipo]) ? [] : control['filtrados'][tipo];
396
+ if (control['filtrados'][tipo] != control['filtrados'][tipo + 'tmp']) {
397
+ control['filtrados'][tipo] = [];
398
+ }
399
+ control['isLoading'] = true;
400
+ }), switchMap(value => {
401
+ const formGroup = formControl.parent?.controls;
402
+ const nombreControl = Object.keys(formGroup).find(name => formControl === formGroup[name]) || null;
403
+ if (nombreControl && control['filtrados'][tipo + 'tmp'] && control['filtrados'][tipo + 'tmp'].length > 0) {
404
+ const busquedaActual = control['filtrados'][tipo + 'tmp'].findIndex((item) => item[nombreControl] == value);
405
+ if (busquedaActual >= 0) {
406
+ const vRet = {};
407
+ vRet[tipo] = control['filtrados'][tipo + 'tmp'];
408
+ control['isLoading'] = false;
409
+ return of(vRet);
410
+ }
411
+ }
412
+ if (!value || value.length < minLength) {
413
+ return [];
414
+ }
415
+ const dataExtraVariableData = {};
416
+ if (dataExtraVariable) {
417
+ // @ts-ignore
418
+ for (const objData of dataExtraVariable) {
419
+ dataExtraVariableData[objData.campo] = objData.ctrlValue.value;
420
+ }
421
+ }
422
+ return queryService.getDataMethod('GET', tipo, { ...dataExtra, ...dataExtraVariableData, ...{ txtBuscar: value } }, anonimo).pipe(finalize(() => {
423
+ control['isLoading'] = false;
424
+ }));
425
+ })).subscribe((data) => {
426
+ if (data[tipo] == undefined) {
427
+ control['filtrados'][tipo] = [];
428
+ }
429
+ else {
430
+ control['filtrados'][tipo] = data[tipo];
431
+ }
432
+ });
433
+ }
434
+
435
+ function seleccionarTextoInput(event) {
436
+ event.target.select();
437
+ }
438
+
439
+ function b64Encode(val) {
440
+ return Buffer.from(val, 'binary').toString('base64');
441
+ }
442
+ function b64Decode(val) {
443
+ return Buffer.from(val, 'base64').toString('binary');
444
+ }
445
+
446
+ function getBrowserName() {
447
+ const agent = window.navigator.userAgent.toLowerCase();
448
+ switch (true) {
449
+ case agent.indexOf('edge') > -1:
450
+ return 'edge';
451
+ case agent.indexOf('opr') > -1 && !!window.opr:
452
+ return 'opera';
453
+ case agent.indexOf('chrome') > -1 && !!window.chrome:
454
+ return 'chrome';
455
+ case agent.indexOf('trident') > -1:
456
+ return 'ie';
457
+ case agent.indexOf('firefox') > -1:
458
+ return 'firefox';
459
+ case agent.indexOf('safari') > -1:
460
+ return 'safari';
461
+ default:
462
+ return 'other';
463
+ }
464
+ }
465
+
466
+ // import * as CryptoJS from 'crypto-js';
467
+ // var CryptoJS = require("crypto-js");
468
+ // Clave secreta (debe ser de 16, 24 o 32 caracteres)
469
+ const secretKey = CryptoJS.enc.Utf8.parse('JVSoftSecret@20615178350');
470
+ const iv = CryptoJS.enc.Utf8.parse('AnSalHuaJVSoft07'); // Debe ser de 16 bytes
471
+ // Función para encriptar texto
472
+ function encriptar(text) {
473
+ const encrypted = CryptoJS.AES.encrypt(text, secretKey, {
474
+ iv: iv,
475
+ mode: CryptoJS.mode.CBC,
476
+ padding: CryptoJS.pad.Pkcs7,
477
+ });
478
+ return encrypted.toString(); // Texto cifrado en Base64
479
+ }
480
+ // Función para desencriptar texto
481
+ function desencriptar(ciphertext) {
482
+ const decrypted = CryptoJS.AES.decrypt(ciphertext, secretKey, {
483
+ iv: iv,
484
+ mode: CryptoJS.mode.CBC,
485
+ padding: CryptoJS.pad.Pkcs7,
486
+ });
487
+ return decrypted.toString(CryptoJS.enc.Utf8);
488
+ }
489
+
490
+ function formatearFechaFormato(val, format = 'dd/MM/yyyy') {
491
+ return val ? formatDate(val, format, 'es-PE') : '';
492
+ }
493
+ function formatearFecha(val, hora = '00:00:00') {
494
+ if (val) {
495
+ if (val.length <= 10) {
496
+ val = val + ' ' + hora;
497
+ }
498
+ return new Date(val);
499
+ }
500
+ return val;
501
+ }
502
+ function formatearFechaCadena(fecha) {
503
+ const year = parseInt(fecha.substring(0, 4), 10);
504
+ const month = parseInt(fecha.substring(4, 6), 10) - 1;
505
+ const day = parseInt(fecha.substring(6, 8), 10);
506
+ return new Date(year, month, day);
507
+ }
508
+
509
+ function maskEmail(email) {
510
+ const [user, domain] = email.split("@");
511
+ if (user.length <= 2) {
512
+ return `${user[0]}***@${domain}`; // 🔹 Si el usuario es muy corto, no se oculta nada
513
+ }
514
+ if (user.length <= 4) {
515
+ return `${user[0]}***${user.slice(-1)}@${domain}`; // 🔹 Muestra 1 al inicio y 1 al final
516
+ }
517
+ return `${user.slice(0, 2)}***${user.slice(-2)}@${domain}`; // 🔹 Muestra 2 al inicio y 2 al final
518
+ }
519
+ function isEmail(email) {
520
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
521
+ }
522
+
523
+ const mimeTypes = {
524
+ // Imágenes
525
+ 'jpg': 'image/jpeg',
526
+ 'jpeg': 'image/jpeg',
527
+ 'png': 'image/png',
528
+ 'gif': 'image/gif',
529
+ 'webp': 'image/webp',
530
+ 'svg': 'image/svg+xml',
531
+ 'ico': 'image/x-icon',
532
+ 'bmp': 'image/bmp',
533
+ // Documentos
534
+ 'pdf': 'application/pdf',
535
+ 'doc': 'application/msword',
536
+ 'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
537
+ 'xls': 'application/vnd.ms-excel',
538
+ 'xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
539
+ 'ppt': 'application/vnd.ms-powerpoint',
540
+ 'pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
541
+ 'txt': 'text/plain',
542
+ 'csv': 'text/csv',
543
+ 'json': 'application/json',
544
+ 'xml': 'application/xml',
545
+ 'html': 'text/html',
546
+ // Audio
547
+ 'mp3': 'audio/mpeg',
548
+ 'wav': 'audio/wav',
549
+ 'ogg': 'audio/ogg',
550
+ 'm4a': 'audio/mp4',
551
+ // Video
552
+ 'mp4': 'video/mp4',
553
+ 'avi': 'video/x-msvideo',
554
+ 'mov': 'video/quicktime',
555
+ 'wmv': 'video/x-ms-wmv',
556
+ 'flv': 'video/x-flv',
557
+ 'webm': 'video/webm',
558
+ 'mkv': 'video/x-matroska',
559
+ // Archivos comprimidos
560
+ 'zip': 'application/zip',
561
+ 'rar': 'application/vnd.rar',
562
+ '7z': 'application/x-7z-compressed',
563
+ 'tar': 'application/x-tar',
564
+ 'gz': 'application/gzip',
565
+ 'bz2': 'application/x-bzip2',
566
+ // Otros formatos
567
+ 'js': 'application/javascript',
568
+ 'css': 'text/css',
569
+ 'ts': 'application/typescript',
570
+ 'md': 'text/markdown',
571
+ 'exe': 'application/octet-stream',
572
+ 'eot': 'application/vnd.ms-fontobject',
573
+ 'woff': 'font/woff',
574
+ 'woff2': 'font/woff2',
575
+ 'ttf': 'font/ttf',
576
+ 'otf': 'font/otf',
577
+ };
578
+ function obtenerMimeType(nombreArchivo) {
579
+ const extension = nombreArchivo.split('.').pop()?.toLowerCase();
580
+ return extension ? mimeTypes[extension] || 'application/octet-stream' : null;
581
+ }
582
+ function sanitizarNombreArchivo(nombre, reemplazo = '_') {
583
+ // 1. Quitar caracteres no válidos para nombres de archivo
584
+ const nombreSanitizado = nombre.replace(/[\/\\:*?"<>|]/g, reemplazo);
585
+ // 2. Reemplazar espacios múltiples o al inicio/final
586
+ const nombreLimpio = nombreSanitizado.trim().replace(/\s+/g, reemplazo);
587
+ // 3. Asegurar longitud máxima (opcional, aquí 255 caracteres)
588
+ return nombreLimpio.substring(0, 255);
589
+ }
590
+ function getDataArchivoFromPath(value, conTimeStamp = false) {
591
+ const partesPath = value.split('/');
592
+ const nombreCompleto = partesPath[partesPath.length - 1];
593
+ let timeStamp = 1;
594
+ let nombreSinTimeStamp = nombreCompleto;
595
+ const partesNombre = nombreCompleto.split('-');
596
+ if (partesNombre.length > 1) {
597
+ timeStamp = partesNombre[0] * 1;
598
+ partesNombre.shift();
599
+ nombreSinTimeStamp = partesNombre.join('-');
600
+ }
601
+ if (conTimeStamp) {
602
+ return {
603
+ nombre: nombreCompleto,
604
+ extension: nombreCompleto.split('.').pop(),
605
+ d: timeStamp,
606
+ fechaSubida: timeStamp ? new Date(timeStamp * 1000) : '',
607
+ };
608
+ }
609
+ return {
610
+ nombre: nombreSinTimeStamp,
611
+ extension: nombreSinTimeStamp.split('.').pop(),
612
+ d: timeStamp,
613
+ fechaSubida: timeStamp ? new Date(timeStamp * 1000) : '',
614
+ };
615
+ }
616
+ function convertirBytes(valor, unidadSalida = null, incluirUnidad = true) {
617
+ const unidades = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
618
+ const indiceEntrada = unidadSalida ? unidades.indexOf(unidadSalida) : 0;
619
+ if (indiceEntrada === -1) {
620
+ // Unidad de entrada no válida
621
+ return null;
622
+ }
623
+ let indiceActual = indiceEntrada;
624
+ let resultado = valor;
625
+ let cont = 0;
626
+ while (cont < 6 && (indiceActual < unidades.length - 1) && (resultado >= 1024)) {
627
+ resultado /= 1024;
628
+ indiceActual++;
629
+ }
630
+ if (incluirUnidad) {
631
+ return `${resultado.toFixed(2)} ${unidades[indiceActual]}`;
632
+ }
633
+ return resultado;
634
+ }
635
+ function downLoadFileStream(data, type, nombreArchivo) {
636
+ const blob = new Blob([data], { type });
637
+ saveAs(blob, nombreArchivo);
638
+ }
639
+
640
+ function establecerQuitarRequired(formulario, establecer = [], quitar = [], camposDisabled = []) {
641
+ establecer.forEach((control) => {
642
+ if (!formulario.get(control)?.hasValidator(Validators.required)) {
643
+ formulario.get(control)?.addValidators([Validators.required]);
644
+ formulario.get(control)?.enable();
645
+ formulario.get(control)?.updateValueAndValidity();
646
+ }
647
+ });
648
+ const deshabilitar = (strControl) => {
649
+ if (camposDisabled == 'todos') {
650
+ formulario.get(strControl)?.disable();
651
+ console.log(strControl);
652
+ }
653
+ else {
654
+ if (camposDisabled.includes(strControl)) {
655
+ formulario.get(strControl)?.disable();
656
+ }
657
+ }
658
+ };
659
+ quitar.forEach(control => {
660
+ if (formulario.get(control)?.hasValidator(Validators.required)) {
661
+ formulario.get(control)?.removeValidators([Validators.required]);
662
+ formulario.get(control)?.updateValueAndValidity();
663
+ }
664
+ deshabilitar(control);
665
+ });
666
+ }
667
+ function getFormValidationErrors(form) {
668
+ const result = [];
669
+ Object.keys(form.controls).forEach(key => {
670
+ const formProperty = form.get(key);
671
+ if (formProperty instanceof FormGroup) {
672
+ result.push(...getFormValidationErrors(formProperty));
673
+ }
674
+ const controlErrors = formProperty?.errors;
675
+ if (controlErrors) {
676
+ Object.keys(controlErrors).forEach(keyError => {
677
+ result.push({
678
+ control: key,
679
+ error: keyError,
680
+ value: controlErrors[keyError]
681
+ });
682
+ });
683
+ }
684
+ });
685
+ return result;
686
+ }
687
+ function mensajesErrorFormControl(control) {
688
+ if (!control || !control.errors || !control.touched)
689
+ return '';
690
+ ReactiveFormConfig.set({
691
+ // RxwebValidators
692
+ validationMessage: {
693
+ required: 'Es requerido',
694
+ numeric: 'Debe ser numérico valido',
695
+ // minLength: 'minimum length is {{1}}',
696
+ // maxLength: 'allowed max length is {{1}}',
697
+ },
698
+ });
699
+ const errorMessages = {
700
+ required: 'Es requerido',
701
+ numeric: 'Debe ser numérico válido',
702
+ min: `Valor mínimo permitido: ${control.errors['min']?.min}`,
703
+ minValue: 'Debe ser positivo',
704
+ minlength: `Mínimo ${control.errors['minlength']?.requiredLength} caracteres.`,
705
+ maxlength: `Caracteres ${control.errors['maxlength']?.actualLength}/${control.errors['maxlength']?.requiredLength}`,
706
+ email: 'No se cumple con el formato de Correo Electrónico',
707
+ isNumeric: 'Debe seleccionar una opción',
708
+ hasNumber: 'Se requiere al menos un número',
709
+ hasCapitalCase: 'Se requiere al menos una mayúscula',
710
+ hasSmallCase: 'Se requiere al menos una minúscula',
711
+ hasSpecialCharacters: 'Se requiere al menos un carácter especial',
712
+ NoPassswordMatch: 'La contraseña no coincide',
713
+ itemSelected: 'Debe seleccionar una opción de la lista',
714
+ inputMask: 'El formato ingresado no es válido',
715
+ };
716
+ // Devuelve el primer mensaje de error encontrado
717
+ for (const errorKey of Object.keys(control.errors)) {
718
+ if (errorMessages[errorKey]) {
719
+ return errorMessages[errorKey];
720
+ }
721
+ }
722
+ // Si el error tiene un mensaje personalizado, usarlo
723
+ return control.errors[Object.keys(control.errors)[0]]?.message || '';
724
+ }
725
+ function toFormData(formValue) {
726
+ const formData = new FormData();
727
+ Object.keys(formValue).forEach((key) => {
728
+ const value = formValue[key];
729
+ if (value === null || value === undefined) {
730
+ return; // Ignorar valores nulos o indefinidos
731
+ }
732
+ if (Array.isArray(value)) {
733
+ value.forEach((item, index) => {
734
+ if (typeof item === 'object' && item !== null) {
735
+ if ('file' in item) {
736
+ formData.append(`${key}[${index}]`, item.file);
737
+ }
738
+ else {
739
+ formData.append(`${key}[${index}]`, JSON.stringify(item));
740
+ }
741
+ }
742
+ else {
743
+ formData.append(`${key}[${index}]`, item.toString());
744
+ }
745
+ });
746
+ }
747
+ else if (typeof value === 'object') {
748
+ // Si es un objeto (pero no un array), convertirlo a JSON
749
+ formData.append(key, JSON.stringify(value));
750
+ }
751
+ else {
752
+ // Para valores primitivos (string, number, boolean)
753
+ formData.append(key, value.toString());
754
+ }
755
+ });
756
+ return formData;
757
+ }
758
+ function markAsTouchedWithoutEmitEvent(control) {
759
+ if (control instanceof FormControl) {
760
+ control.markAsTouched({ onlySelf: true });
761
+ control.updateValueAndValidity({ emitEvent: false });
762
+ }
763
+ else if (control instanceof FormGroup || control instanceof FormArray) {
764
+ Object.values(control.controls).forEach(childControl => {
765
+ markAsTouchedWithoutEmitEvent(childControl);
766
+ });
767
+ control.updateValueAndValidity({ emitEvent: false });
768
+ }
769
+ }
770
+
771
+ function mensajeAlerta(tipo, titulo, mensaje, opciones) {
772
+ opciones = {
773
+ ...{
774
+ heightAuto: false,
775
+ title: titulo,
776
+ html: mensaje,
777
+ icon: tipo,
778
+ confirmButtonText: 'Aceptar',
779
+ // customClass: {
780
+ // confirmButton: 'btn btn-lg btn-outline-success mx-2',
781
+ // cancelButton: 'btn btn-lg btn-outline-dark mx-2'
782
+ // },
783
+ // buttonsStyling: false
784
+ },
785
+ ...opciones
786
+ };
787
+ return swal.fire(opciones);
788
+ }
789
+ function mensajeTimer(tipo, titulo, mensaje, milisegundos = 3000, showLoading = true, opciones) {
790
+ let timerInterval;
791
+ opciones = {
792
+ ...{
793
+ heightAuto: false,
794
+ title: titulo,
795
+ html: mensaje + '<br> Se cerrará en <strong> X </strong> segundos.',
796
+ icon: tipo,
797
+ timer: milisegundos,
798
+ showCancelButton: false,
799
+ showConfirmButton: false,
800
+ willOpen: () => {
801
+ if (showLoading) {
802
+ swal.showLoading();
803
+ }
804
+ timerInterval = setInterval(() => {
805
+ const impr = Math.ceil(((swal.getTimerLeft() ?? 1) / 1000));
806
+ if (swal.getHtmlContainer()) {
807
+ // @ts-ignore
808
+ swal.getHtmlContainer().querySelector('strong').textContent = String(impr);
809
+ }
810
+ }, 100);
811
+ },
812
+ willClose: () => {
813
+ clearInterval(timerInterval);
814
+ }
815
+ },
816
+ ...opciones
817
+ };
818
+ return swal.fire(opciones);
819
+ }
820
+ // @ts-ignore
821
+ function mensajeConfirmacion(tipo, titulo, mensaje, opciones) {
822
+ opciones = {
823
+ ...{
824
+ heightAuto: false,
825
+ title: titulo,
826
+ html: mensaje,
827
+ icon: tipo,
828
+ showCancelButton: true,
829
+ // confirmButtonColor: '#3f51b5',
830
+ // cancelButtonColor: '#ffffff',
831
+ confirmButtonText: 'Confirmar',
832
+ cancelButtonText: 'Cancelar',
833
+ reverseButtons: true,
834
+ // customClass: {
835
+ // confirmButton: 'btn btn-lg btn-outline-success mx-2',
836
+ // cancelButton: 'btn btn-lg btn-outline-dark mx-2'
837
+ // },
838
+ // buttonsStyling: false
839
+ },
840
+ ...opciones
841
+ };
842
+ return swal.fire(opciones);
843
+ }
844
+ function mensajeToast(tipo, titulo, mensaje, opciones) {
845
+ opciones = {
846
+ ...{
847
+ heightAuto: false,
848
+ title: titulo,
849
+ html: mensaje,
850
+ icon: tipo,
851
+ confirmButtonText: 'Aceptar',
852
+ toast: true,
853
+ position: 'top-end',
854
+ showConfirmButton: false,
855
+ timer: 3000,
856
+ timerProgressBar: true,
857
+ },
858
+ ...opciones
859
+ };
860
+ return swal.fire(opciones);
861
+ }
862
+
863
+ function mensajesDeError(error, toast = false) {
864
+ let msg;
865
+ if (error.error && error.error instanceof ArrayBuffer) {
866
+ const msgArrayBuffer = (arrayBuffer) => {
867
+ try {
868
+ const mensajeError = JSON.parse(new TextDecoder("utf-8").decode(arrayBuffer));
869
+ return mensajeError.message || 'Error desconocido';
870
+ }
871
+ catch (parseError) {
872
+ console.error('Error al analizar la respuesta JSON:', parseError);
873
+ return 'Error al analizar la respuesta JSON';
874
+ }
875
+ };
876
+ msg = msgArrayBuffer(error.error);
877
+ }
878
+ else {
879
+ switch (error.status) {
880
+ case 0:
881
+ // msg = error.message;
882
+ msg = 'El servidor no responde, verifica tu conexion a la red';
883
+ console.log(error);
884
+ break;
885
+ case 401:
886
+ if (error.error && typeof error.error == 'object') {
887
+ if (error.error.message) {
888
+ msg = error.error.message;
889
+ }
890
+ else if (error.error.error) {
891
+ msg = error.error.error;
892
+ }
893
+ else {
894
+ msg = JSON.stringify(error.error);
895
+ console.log(error);
896
+ }
897
+ }
898
+ else if (error.error && typeof error.error == 'string') {
899
+ msg = error.error;
900
+ }
901
+ else {
902
+ msg = 'Acceso no autorizado';
903
+ console.log(error);
904
+ }
905
+ break;
906
+ case 422:
907
+ let strEr = '';
908
+ console.log(typeof error.error.errors);
909
+ console.log(error.error.errors);
910
+ if (error.error.errors) {
911
+ Object.keys(error.error.errors).forEach(o => {
912
+ strEr += '<li>' + error.error.errors[o][0] + '</li>';
913
+ });
914
+ msg = (error.error.message ?? '') + '<ul>' + strEr + '</ul>';
915
+ }
916
+ else if (error.error.error) {
917
+ msg = error.error.msg;
918
+ }
919
+ break;
920
+ case 429:
921
+ case 400:
922
+ case 500:
923
+ case 503:
924
+ msg = error.error.message;
925
+ break;
926
+ case 504:
927
+ msg = 'No se puede conectar al servidor. Comprueba tu conexion a la red - ' + error.statusText;
928
+ break;
929
+ default:
930
+ msg = error?.error?.message ?? 'Error de Sistema';
931
+ console.log(error);
932
+ break;
933
+ }
934
+ }
935
+ if (!msg) {
936
+ msg = error.statusText ?? 'Error inesperado o datos inexistentes.';
937
+ }
938
+ let tituloFinal = 'Error!';
939
+ let mensajeFinal;
940
+ if (msg.includes('Hmac::doVerify')) {
941
+ console.log(error, msg);
942
+ return;
943
+ }
944
+ else if (msg == 'Server Error') {
945
+ console.log(error, msg);
946
+ return;
947
+ }
948
+ else if (msg.includes('[IMSSP]')) {
949
+ mensajeFinal = 'Error en consulta de registros.';
950
+ }
951
+ else if (msg.includes('Tiempo de espera de la')) {
952
+ mensajeFinal = 'Hubo un error en la solicitud de datos, por favor actualice (SHIFT + F5)';
953
+ }
954
+ else {
955
+ mensajeFinal = msg;
956
+ }
957
+ if (toast) {
958
+ mensajeToast('error', tituloFinal, mensajeFinal);
959
+ }
960
+ else {
961
+ mensajeAlerta('error', tituloFinal, mensajeFinal);
962
+ }
963
+ throw new Error(mensajeFinal);
964
+ }
965
+
966
+ let dataSessionStorageKey = {
967
+ tokenStringKey: 'JVSoftTkn',
968
+ changePasswordKey: 'chPwd',
969
+ logoUrl: 'logo_url',
970
+ logoLogin: 'login-logo',
971
+ backgroundLogin: 'login-background',
972
+ favicon: 'favicon',
973
+ darkMode: 'darkMode',
974
+ serverTimestamp: 'srvtmstp',
975
+ apiDataKey: 'reqDt',
976
+ };
977
+ let localStorageKeys = dataSessionStorageKey;
978
+ function inicializarVariablesSessionStorage(datSesion) {
979
+ dataSessionStorageKey = datSesion;
980
+ }
981
+ function setJwtTokenData(data) {
982
+ localStorage.setItem(dataSessionStorageKey.tokenStringKey, data);
983
+ }
984
+ function jwtTokenData(key = dataSessionStorageKey.tokenStringKey) {
985
+ const tokenObj = localStorage.getItem(key);
986
+ try {
987
+ return JSON.parse(tokenObj);
988
+ }
989
+ catch (error) {
990
+ return null;
991
+ }
992
+ }
993
+ function jwtToken(key = dataSessionStorageKey.tokenStringKey) {
994
+ const varJwtTokenData = jwtTokenData(key);
995
+ if (varJwtTokenData) {
996
+ return varJwtTokenData.access_token;
997
+ }
998
+ return '';
999
+ }
1000
+ function jwtTokenExpiracion(key = dataSessionStorageKey.tokenStringKey) {
1001
+ const jwtStr = jwtToken(key);
1002
+ if (!jwtStr)
1003
+ return null;
1004
+ try {
1005
+ const decodedToken = jwtDecode(jwtStr);
1006
+ return decodedToken.exp ? decodedToken.exp * 1000 : null; // Convertir a milisegundos
1007
+ }
1008
+ catch (e) {
1009
+ return null;
1010
+ }
1011
+ }
1012
+ function jwtTokenExpiracionFaltante() {
1013
+ return Math.abs(moment().diff(jwtTokenExpiracion(), 'seconds'));
1014
+ }
1015
+ function setCambiarPwd(accion = true) {
1016
+ localStorage.setItem(dataSessionStorageKey.changePasswordKey, (accion ? 1 : 0).toString());
1017
+ }
1018
+ function getCambiarPwd() {
1019
+ const frmCambioPwd = localStorage.getItem(dataSessionStorageKey.changePasswordKey);
1020
+ if (!frmCambioPwd) {
1021
+ return null;
1022
+ }
1023
+ return frmCambioPwd == '1';
1024
+ }
1025
+ function delLocalStorage(keyElim = [
1026
+ dataSessionStorageKey.tokenStringKey,
1027
+ dataSessionStorageKey.changePasswordKey,
1028
+ dataSessionStorageKey.apiDataKey,
1029
+ ]) {
1030
+ keyElim.forEach(key => {
1031
+ localStorage.removeItem(key);
1032
+ });
1033
+ }
1034
+ function getLocalStorage(key) {
1035
+ return localStorage.getItem(key);
1036
+ }
1037
+ function setLocalStorage(key, value = '') {
1038
+ localStorage.setItem(key, value.toString());
1039
+ }
1040
+
1041
+ function roundToDecimal(number, decimal) {
1042
+ return parseFloat(number.toFixed(decimal));
1043
+ }
1044
+
1045
+ function objectPropertiesToType(formFields) {
1046
+ Object.keys(formFields).filter(control => !!formFields[control]).forEach(control => {
1047
+ if (/^dt[a-zA-Z]+/.test(control)) {
1048
+ formFields[control] = formatDate(formFields[control], 'yyyy-MM-dd HH:mm', 'es-PE');
1049
+ }
1050
+ else if (control.startsWith('d')) {
1051
+ formFields[control] = formatearFecha(formFields[control]);
1052
+ }
1053
+ else if (control.startsWith('n')) {
1054
+ formFields[control] = Number(formFields[control]);
1055
+ }
1056
+ });
1057
+ return formFields;
1058
+ }
1059
+ function objectPropertiesBoolean(formFields, retorno = 'boolean') {
1060
+ Object.keys(formFields).forEach(control => {
1061
+ const valRetorno = (ctrl) => {
1062
+ switch (retorno) {
1063
+ case 'boolean':
1064
+ formFields[ctrl] = formFields[ctrl] == 1;
1065
+ break;
1066
+ case 'bit':
1067
+ formFields[ctrl] = formFields[ctrl] ? 1 : 0;
1068
+ break;
1069
+ }
1070
+ };
1071
+ if (control.charAt(0) == 'b' || (control.charAt(0) == 'i' && control.indexOf('Estado') !== -1)) {
1072
+ valRetorno(control);
1073
+ }
1074
+ });
1075
+ return formFields;
1076
+ }
1077
+
1078
+ function generateRandomString(length) {
1079
+ let result = '';
1080
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
1081
+ const charactersLength = characters.length;
1082
+ for (let i = 0; i < length; i++) {
1083
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
1084
+ }
1085
+ return result;
1086
+ }
1087
+
1088
+ function verificarRUC(ruc) {
1089
+ const f = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
1090
+ const rucArray = ruc.split('');
1091
+ const nArray = f.map((item, idx) => {
1092
+ return item * parseFloat(rucArray[idx]);
1093
+ });
1094
+ const suma = nArray.reduce((a, b) => a + b, 0);
1095
+ const residuo = suma % 11;
1096
+ const residuo2 = 11 - residuo;
1097
+ // @residuo=CONVERT(Integer,Right(CONVERT(VarChar,@residuo),1))
1098
+ const residuo3 = residuo2.toString().charAt(residuo2.toString().length - 1);
1099
+ const ultimoCaracter = ruc.toString().charAt(ruc.toString().length - 1);
1100
+ if (residuo3 == ultimoCaracter) {
1101
+ return true;
1102
+ }
1103
+ mensajeAlerta('error', 'Datos No válidos', ' El número de RUC no es válido');
1104
+ return false;
1105
+ }
1106
+
1107
+ class DataModel {
1108
+ modelosChk = {}; // Usar any para valores dinámicos
1109
+ checkbox;
1110
+ constructor() {
1111
+ this.checkbox = new ForCheckboxModel(this);
1112
+ }
1113
+ generarId(row, campoValor, separador = '') {
1114
+ if (typeof campoValor == 'string') {
1115
+ campoValor = [campoValor];
1116
+ }
1117
+ return campoValor.map(data => row[data]).join(separador);
1118
+ }
1119
+ // Agrega controles al objeto modelosChk
1120
+ agregarControles(lista, idLista, limpiar = true, campoValor = null, campoValorSeparador = '') {
1121
+ if (limpiar) {
1122
+ this.modelosChk = {};
1123
+ }
1124
+ const asignarValor = (dat, idLista, campoValor, key) => {
1125
+ if (!key) {
1126
+ key = dat[idLista] + (campoValor.includes('.') ? '' : `.${campoValor}`);
1127
+ }
1128
+ const mat = campoValor.match(/^([in])[A-Z][a-zA-Z]+/);
1129
+ if (mat) {
1130
+ this.modelosChk[key] = dat[campoValor] * 1;
1131
+ }
1132
+ else {
1133
+ this.modelosChk[key] = dat[campoValor];
1134
+ }
1135
+ };
1136
+ lista.forEach(dat => {
1137
+ if (campoValor === null) {
1138
+ // Caso 1: Sin campoValor, se asigna false
1139
+ this.modelosChk[dat[idLista]] = false;
1140
+ }
1141
+ else if (typeof campoValor === 'string') {
1142
+ // Caso 2: campoValor es un string
1143
+ asignarValor(dat, idLista, campoValor, dat[idLista]);
1144
+ }
1145
+ else if (campoValorSeparador) {
1146
+ const idStr = this.generarId(dat, campoValor, campoValorSeparador);
1147
+ // Caso 2: campoValor es un string
1148
+ asignarValor(dat, idLista, '.', idStr);
1149
+ }
1150
+ else {
1151
+ // Caso 3: campoValor es un array de strings
1152
+ campoValor.forEach(data => asignarValor(dat, idLista, data));
1153
+ }
1154
+ });
1155
+ }
1156
+ // Establece el estado de un índice
1157
+ setState(idx, state) {
1158
+ this.modelosChk[idx] = state;
1159
+ }
1160
+ // Obtiene el estado de un índice
1161
+ getState(idx) {
1162
+ return this.modelosChk[idx];
1163
+ }
1164
+ getDataMultiple(idx) {
1165
+ const camposMod = Object.keys(this.modelosChk).filter(key => key.split('.')[0] == idx);
1166
+ const vRet = {};
1167
+ camposMod.forEach(key => {
1168
+ vRet[key.split('.')[1]] = this.modelosChk[key];
1169
+ });
1170
+ return vRet;
1171
+ }
1172
+ // Genera una lista basada en el estado de los índices
1173
+ generarLista(tipoRetorno = null, esCampoNumerico = false) {
1174
+ const strLista = [];
1175
+ const objLista = {};
1176
+ Object.keys(this.modelosChk).forEach(key => {
1177
+ if ((esCampoNumerico && esNumero(this.modelosChk[key])) ||
1178
+ (this.modelosChk[key])) {
1179
+ strLista.push(key);
1180
+ objLista[key] = this.modelosChk[key];
1181
+ }
1182
+ });
1183
+ if (tipoRetorno === 'array') {
1184
+ return strLista;
1185
+ }
1186
+ if (tipoRetorno === 'object') {
1187
+ return objLista;
1188
+ }
1189
+ return strLista.join(',');
1190
+ }
1191
+ generarFormGroupFromModelosChk(tipo) {
1192
+ const formGroupObj = {};
1193
+ let validadores = [];
1194
+ if (tipo == 'number') {
1195
+ validadores = [
1196
+ Validators.required,
1197
+ Validators.min(1)
1198
+ ];
1199
+ }
1200
+ Object.keys(this.modelosChk).forEach(key => {
1201
+ formGroupObj[key] = new FormControl(this.modelosChk[key], validadores);
1202
+ });
1203
+ return new FormGroup(formGroupObj);
1204
+ // return this.formBuilder.group(formGroupObj);
1205
+ }
1206
+ }
1207
+ class ForCheckboxModel {
1208
+ modeloCheck;
1209
+ constructor(modeloCheck) {
1210
+ this.modeloCheck = modeloCheck;
1211
+ }
1212
+ get cantidadActivos() {
1213
+ return Object.values(this.modeloCheck.modelosChk).filter(Boolean).length;
1214
+ }
1215
+ get existenActivados() {
1216
+ return this.cantidadActivos > 0;
1217
+ }
1218
+ get todosActivos() {
1219
+ const total = Object.keys(this.modeloCheck.modelosChk).length;
1220
+ const activos = this.cantidadActivos;
1221
+ return activos > 0 && total === activos;
1222
+ }
1223
+ get algunosActivos() {
1224
+ const total = Object.keys(this.modeloCheck.modelosChk).length;
1225
+ const activos = this.cantidadActivos;
1226
+ return activos > 0 && total !== activos;
1227
+ }
1228
+ establecerTodos(activo) {
1229
+ Object.keys(this.modeloCheck.modelosChk).forEach(idx => this.modeloCheck.modelosChk[idx] = activo);
1230
+ }
1231
+ }
1232
+
1233
+ class DataEnListaPipe {
1234
+ transform(coleccion, idBuscar, dato) {
1235
+ if (coleccion) {
1236
+ if (Array.isArray(idBuscar)) {
1237
+ return coleccion.find(item => {
1238
+ const arrCoincide = [];
1239
+ idBuscar.forEach((campo, idx) => {
1240
+ // @ts-ignore
1241
+ arrCoincide.push((item[campo] == dato[idx]));
1242
+ });
1243
+ return arrCoincide.every(e => e === true);
1244
+ });
1245
+ }
1246
+ // @ts-ignore
1247
+ return coleccion.find(item => item[idBuscar] == dato);
1248
+ }
1249
+ return null;
1250
+ }
1251
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DataEnListaPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1252
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: DataEnListaPipe, isStandalone: true, name: "dataEnLista" });
1253
+ }
1254
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DataEnListaPipe, decorators: [{
1255
+ type: Pipe,
1256
+ args: [{
1257
+ name: 'dataEnLista',
1258
+ }]
1259
+ }] });
1260
+ function dataEnLista(coleccion, idBuscar, dato) {
1261
+ return new DataEnListaPipe().transform(coleccion, idBuscar, dato);
1262
+ }
1263
+
1264
+ class DateDiffStringPipe {
1265
+ transform(startingDate, endingDate) {
1266
+ let startDate = new Date(startingDate);
1267
+ // user not pass endingDate then set current date as end date.
1268
+ if (!endingDate) {
1269
+ endingDate = new Date();
1270
+ }
1271
+ let endDate = new Date(endingDate);
1272
+ // chack start date and end date and base on condication alter date.
1273
+ if (startDate > endDate) {
1274
+ const swap = startDate;
1275
+ startDate = endDate;
1276
+ endDate = swap;
1277
+ }
1278
+ const disgregado = this.separarMilisegundos(endDate.getTime() - startDate.getTime());
1279
+ // console.log(disgregado);
1280
+ const formatearATexto = (arrayToFill, campo, texto, textoPlural = 's') => {
1281
+ if (campo > 0) {
1282
+ arrayToFill.push(campo + ' ' + texto + (campo > 1 ? textoPlural : ''));
1283
+ }
1284
+ return arrayToFill;
1285
+ };
1286
+ let arrDFinal = [];
1287
+ arrDFinal = formatearATexto(arrDFinal, disgregado.years, 'año');
1288
+ arrDFinal = formatearATexto(arrDFinal, disgregado.months, 'mes', 'es');
1289
+ arrDFinal = formatearATexto(arrDFinal, disgregado.weeks, 'semana');
1290
+ arrDFinal = formatearATexto(arrDFinal, disgregado.days, 'día');
1291
+ arrDFinal = formatearATexto(arrDFinal, disgregado.hours, 'hora');
1292
+ arrDFinal = formatearATexto(arrDFinal, disgregado.minutes, 'minuto');
1293
+ arrDFinal = formatearATexto(arrDFinal, disgregado.seconds, 'segundo');
1294
+ if (arrDFinal.length > 3) {
1295
+ arrDFinal.splice(3);
1296
+ arrDFinal.splice(-1, 0, 'y');
1297
+ }
1298
+ else {
1299
+ if (arrDFinal.length > 1) {
1300
+ arrDFinal.splice(-1, 0, 'y');
1301
+ }
1302
+ }
1303
+ return arrDFinal.join(' ');
1304
+ }
1305
+ separarMilisegundos(milisegundos) {
1306
+ const todoEnSegundos = milisegundos / 1000;
1307
+ let secsUsed = 0;
1308
+ const years = Math.floor(todoEnSegundos / 31536000);
1309
+ if (years > 0) {
1310
+ secsUsed += (years * 31536000);
1311
+ }
1312
+ const months = Math.floor((todoEnSegundos - secsUsed) / 2628288);
1313
+ if (months > 0) {
1314
+ secsUsed += (months * 2628288);
1315
+ }
1316
+ const weeks = Math.floor((todoEnSegundos - secsUsed) / 604800);
1317
+ if (weeks > 0) {
1318
+ secsUsed += (weeks * 604800);
1319
+ }
1320
+ const days = Math.floor((todoEnSegundos - secsUsed) / 86400);
1321
+ if (days > 0) {
1322
+ secsUsed += (days * 86400);
1323
+ }
1324
+ const hours = Math.floor((todoEnSegundos - secsUsed) / 3600);
1325
+ if (hours > 0) {
1326
+ secsUsed += (hours * 3600);
1327
+ }
1328
+ const minutes = Math.floor((todoEnSegundos - secsUsed) / 60);
1329
+ if (minutes > 0) {
1330
+ secsUsed += (minutes * 60);
1331
+ }
1332
+ const seconds = Math.round(todoEnSegundos - secsUsed);
1333
+ return {
1334
+ years,
1335
+ months,
1336
+ weeks,
1337
+ days,
1338
+ hours,
1339
+ minutes,
1340
+ seconds,
1341
+ };
1342
+ }
1343
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DateDiffStringPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1344
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: DateDiffStringPipe, isStandalone: true, name: "dateDiffString" });
1345
+ }
1346
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: DateDiffStringPipe, decorators: [{
1347
+ type: Pipe,
1348
+ args: [{
1349
+ name: 'dateDiffString',
1350
+ pure: true
1351
+ }]
1352
+ }] });
1353
+ function dateDiffString(startingDate, endingDate) {
1354
+ return new DateDiffStringPipe().transform(startingDate, endingDate);
1355
+ }
1356
+
1357
+ class FiltroPipe {
1358
+ transform(items, opcionesBusqueda) {
1359
+ if (!items || !Array.isArray(items))
1360
+ return [];
1361
+ if (!opcionesBusqueda.texto || opcionesBusqueda.texto.length < (opcionesBusqueda.longitudMinima ?? 1))
1362
+ return items;
1363
+ const normalize = (() => {
1364
+ const from = 'ÃÀÁÄÂÈÉËÊÌÍÏÎÒÓÖÔÙÚÜÛãàáäâèéëêìíïîòóöôùúüûÑñÇç';
1365
+ const to = 'AAAAAEEEEIIIIOOOOUUUUaaaaaeeeeiiiioooouuuunncc';
1366
+ const mapping = {};
1367
+ for (let i = 0; i < from.length; i++) {
1368
+ mapping[from[i]] = to[i];
1369
+ }
1370
+ return (str) => {
1371
+ return str.split('').map(c => mapping[c] || c).join('');
1372
+ };
1373
+ })();
1374
+ const textoNormalizado = normalize(opcionesBusqueda.texto.toLowerCase());
1375
+ return items.filter(item => {
1376
+ // 🔹 Manejo de `mostrarObligado`
1377
+ if (opcionesBusqueda.mostrarObligado) {
1378
+ const { campo, items: obligados } = opcionesBusqueda.mostrarObligado;
1379
+ if (obligados.includes(item[campo]))
1380
+ return true;
1381
+ }
1382
+ // 🔹 Manejo de `campo`
1383
+ if (opcionesBusqueda.campo) {
1384
+ if (Array.isArray(opcionesBusqueda.campo)) {
1385
+ return opcionesBusqueda.campo.some(campo => {
1386
+ const valor = item[campo];
1387
+ return valor ? normalize(valor.toLowerCase()).includes(textoNormalizado) : false;
1388
+ });
1389
+ }
1390
+ else {
1391
+ const valor = item[opcionesBusqueda.campo];
1392
+ return valor ? normalize(valor.toLowerCase()).includes(textoNormalizado) : false;
1393
+ }
1394
+ }
1395
+ return false;
1396
+ });
1397
+ }
1398
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: FiltroPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1399
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: FiltroPipe, isStandalone: true, name: "filtro" });
1400
+ }
1401
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: FiltroPipe, decorators: [{
1402
+ type: Pipe,
1403
+ args: [{
1404
+ name: 'filtro'
1405
+ }]
1406
+ }] });
1407
+
1408
+ class FormControlIsRequiredPipe {
1409
+ transform(formControl, ...args) {
1410
+ if (!formControl) {
1411
+ return false;
1412
+ }
1413
+ return formControl.hasValidator(Validators.required);
1414
+ }
1415
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: FormControlIsRequiredPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1416
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: FormControlIsRequiredPipe, isStandalone: true, name: "formControlIsRequired" });
1417
+ }
1418
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: FormControlIsRequiredPipe, decorators: [{
1419
+ type: Pipe,
1420
+ args: [{
1421
+ name: 'formControlIsRequired'
1422
+ }]
1423
+ }] });
1424
+ function formControlIsRequired(formControl) {
1425
+ return new FormControlIsRequiredPipe().transform(formControl);
1426
+ }
1427
+
1428
+ class JsonParsePipe {
1429
+ transform(value, ...args) {
1430
+ if (!value) {
1431
+ return [];
1432
+ }
1433
+ try {
1434
+ return JSON.parse(value);
1435
+ }
1436
+ catch (e) {
1437
+ console.warn('La cadena "' + value + '" no es JSON');
1438
+ return [];
1439
+ }
1440
+ }
1441
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: JsonParsePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1442
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: JsonParsePipe, isStandalone: true, name: "jsonParse" });
1443
+ }
1444
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: JsonParsePipe, decorators: [{
1445
+ type: Pipe,
1446
+ args: [{
1447
+ name: 'jsonParse'
1448
+ }]
1449
+ }] });
1450
+
1451
+ class NoSanitizePipe {
1452
+ domSanitizer;
1453
+ constructor(domSanitizer) {
1454
+ this.domSanitizer = domSanitizer;
1455
+ }
1456
+ transform(html) {
1457
+ return this.domSanitizer.bypassSecurityTrustHtml(html);
1458
+ }
1459
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NoSanitizePipe, deps: [{ token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
1460
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: NoSanitizePipe, isStandalone: true, name: "noSanitize" });
1461
+ }
1462
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NoSanitizePipe, decorators: [{
1463
+ type: Pipe,
1464
+ args: [{ name: 'noSanitize' }]
1465
+ }], ctorParameters: () => [{ type: i1.DomSanitizer }] });
1466
+
1467
+ class TipoValorFuncionPipe {
1468
+ transform(datoParam, defaultValue, ...param) {
1469
+ if (datoParam === undefined || datoParam === null) {
1470
+ return defaultValue;
1471
+ }
1472
+ if (typeof datoParam === 'function') {
1473
+ return datoParam(...param);
1474
+ }
1475
+ return datoParam;
1476
+ }
1477
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: TipoValorFuncionPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1478
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: TipoValorFuncionPipe, isStandalone: true, name: "tipoValorFuncion" });
1479
+ }
1480
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: TipoValorFuncionPipe, decorators: [{
1481
+ type: Pipe,
1482
+ args: [{
1483
+ name: 'tipoValorFuncion',
1484
+ standalone: true, // Para usarlo en standalone components
1485
+ }]
1486
+ }] });
1487
+ function tipoValorFuncion(datoParam, defaultValue, ...param) {
1488
+ return new TipoValorFuncionPipe().transform(datoParam, defaultValue, ...param);
1489
+ }
1490
+
1491
+ class ZeroFillPipe {
1492
+ transform(value, digitos, ...args) {
1493
+ let s = value + '';
1494
+ while (s.length < digitos) {
1495
+ s = '0' + s;
1496
+ }
1497
+ return s;
1498
+ }
1499
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ZeroFillPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1500
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.14", ngImport: i0, type: ZeroFillPipe, isStandalone: true, name: "zeroFill" });
1501
+ }
1502
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ZeroFillPipe, decorators: [{
1503
+ type: Pipe,
1504
+ args: [{
1505
+ name: 'zeroFill',
1506
+ }]
1507
+ }] });
1508
+ function zeroFill(value, digitos, ...args) {
1509
+ return new ZeroFillPipe().transform(value, digitos, args);
1510
+ }
1511
+
1512
+ // export * from './otros';
1513
+
1514
+ /*
1515
+ * Public API Surface of utils
1516
+ */
1517
+ // export * from './functions/common.function';
1518
+ // export * from './lib/utils.component';
1519
+ // export * from './lib/utils.service';
1520
+
1521
+ /**
1522
+ * Generated bundle index. Do not edit.
1523
+ */
1524
+
1525
+ export { DataEnListaPipe, DataModel, DateDiffStringPipe, FiltroPipe, FormControlIsRequiredPipe, JsonParsePipe, NoSanitizePipe, TipoValorFuncionPipe, ZeroFillPipe, b64Decode, b64Encode, buscarPorCampo, changeSelect, changeSelectApi, changeSelectData, changeSelectDataApi, convertirBytes, dataEnLista, dateDiffString, deepClone, deepMerge, delLocalStorage, desencriptar, downLoadFileStream, encriptar, esNumero, establecerQuitarRequired, formControlIsRequired, formatearFecha, formatearFechaCadena, formatearFechaFormato, generateRandomString, getBrowserName, getCambiarPwd, getDataArchivoFromPath, getFormValidationErrors, getLocalStorage, getUniqueValues, getUniqueValuesByProperty, groupBy, inicializarVariablesSessionStorage, isEmail, jwtToken, jwtTokenData, jwtTokenExpiracion, jwtTokenExpiracionFaltante, localStorageKeys, markAsTouchedWithoutEmitEvent, maskEmail, mensajeAlerta, mensajeConfirmacion, mensajeTimer, mensajeToast, mensajesDeError, mensajesErrorFormControl, mostrarValorEnBusqueda, nestGroupsBy, objectPropertiesBoolean, objectPropertiesToType, obtenerMimeType, obtenerUltimoOrden, ordenarArray, ordenarPorPropiedad, ordenarPorPropiedades, roundToDecimal, sanitizarNombreArchivo, seleccionarTextoInput, setCambiarPwd, setJwtTokenData, setLocalStorage, sumarObjetos, sumarPropiedades, tipoValorFuncion, toFormData, verificarRUC, zeroFill };
1526
+ //# sourceMappingURL=jvsoft-utils.mjs.map