akeyless-client-commons 1.1.69 → 1.1.71

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.
@@ -644,7 +644,7 @@ var import_app = require("firebase/app");
644
644
  var import_storage = require("firebase/storage");
645
645
  var import_auth = require("firebase/auth");
646
646
  var import_app_check = require("firebase/app-check");
647
- var import_firestore = require("firebase/firestore");
647
+ var import_firestore2 = require("firebase/firestore");
648
648
  // src/helpers/cars.ts
649
649
  var formatCarNumber = function(car_number) {
650
650
  var cn2 = car_number;
@@ -810,6 +810,134 @@ var initializeUserPermissions = /*#__PURE__*/ function() {
810
810
  }();
811
811
  // src/helpers/firebase.ts
812
812
  var import_storage2 = require("firebase/storage");
813
+ // src/helpers/time_helpers.ts
814
+ var import_firestore = require("firebase/firestore");
815
+ var import_moment_timezone = __toESM(require("moment-timezone"));
816
+ function timestamp_to_string(firebaseTimestamp, options) {
817
+ var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
818
+ var _ref = {
819
+ defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
820
+ format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "DD/MM/YYYY HH:mm:ss",
821
+ fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
822
+ tz: options === null || options === void 0 ? void 0 : options.tz,
823
+ debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
824
+ }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
825
+ var date;
826
+ switch(true){
827
+ case !firebaseTimestamp:
828
+ {
829
+ return defaultReturnedValue;
830
+ }
831
+ case _instanceof(firebaseTimestamp, import_firestore.Timestamp):
832
+ {
833
+ date = firebaseTimestamp.toDate();
834
+ break;
835
+ }
836
+ case _instanceof(firebaseTimestamp, Date):
837
+ {
838
+ date = firebaseTimestamp;
839
+ break;
840
+ }
841
+ case typeof firebaseTimestamp === "string":
842
+ {
843
+ var m = import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
844
+ switch(m.isValid()){
845
+ case true:
846
+ date = m.toDate();
847
+ break;
848
+ default:
849
+ return defaultReturnedValue;
850
+ }
851
+ break;
852
+ }
853
+ case !!firebaseTimestamp._seconds:
854
+ {
855
+ var ft = firebaseTimestamp;
856
+ var _ft__nanoseconds;
857
+ date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
858
+ break;
859
+ }
860
+ case !!firebaseTimestamp.seconds:
861
+ {
862
+ var ft1 = firebaseTimestamp;
863
+ date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
864
+ break;
865
+ }
866
+ default:
867
+ {
868
+ if (debug) {
869
+ console.error("Invalid timestamp format: ", firebaseTimestamp);
870
+ }
871
+ return defaultReturnedValue;
872
+ }
873
+ }
874
+ switch(Boolean(tz)){
875
+ case true:
876
+ return (0, import_moment_timezone.default)(date).tz(tz).format(format);
877
+ default:
878
+ return import_moment_timezone.default.utc(date).format(format);
879
+ }
880
+ }
881
+ function timestamp_to_millis(firebaseTimestamp, options) {
882
+ var _options_defaultReturnedValue, _options_fromFormat, _options_debug;
883
+ var _ref = {
884
+ defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : 0,
885
+ fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
886
+ tz: options === null || options === void 0 ? void 0 : options.tz,
887
+ debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
888
+ }, defaultReturnedValue = _ref.defaultReturnedValue, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
889
+ switch(true){
890
+ case !firebaseTimestamp:
891
+ {
892
+ return defaultReturnedValue;
893
+ }
894
+ case _instanceof(firebaseTimestamp, import_firestore.Timestamp):
895
+ {
896
+ return firebaseTimestamp.toMillis();
897
+ }
898
+ case _instanceof(firebaseTimestamp, Date):
899
+ {
900
+ var ms = firebaseTimestamp.getTime();
901
+ return isNaN(ms) ? defaultReturnedValue : ms;
902
+ }
903
+ case typeof firebaseTimestamp === "string":
904
+ {
905
+ var m = tz ? import_moment_timezone.default.tz(firebaseTimestamp, fromFormat, tz) : import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
906
+ switch(m.isValid()){
907
+ case true:
908
+ return m.valueOf();
909
+ default:
910
+ return defaultReturnedValue;
911
+ }
912
+ }
913
+ case !!firebaseTimestamp._seconds:
914
+ {
915
+ var seconds = firebaseTimestamp._seconds;
916
+ var _firebaseTimestamp__nanoseconds;
917
+ var nanos = (_firebaseTimestamp__nanoseconds = firebaseTimestamp._nanoseconds) !== null && _firebaseTimestamp__nanoseconds !== void 0 ? _firebaseTimestamp__nanoseconds : 0;
918
+ return seconds * 1e3 + Math.floor(nanos / 1e6);
919
+ }
920
+ case !!firebaseTimestamp.seconds:
921
+ {
922
+ var seconds1 = firebaseTimestamp.seconds;
923
+ var _firebaseTimestamp_nanoseconds;
924
+ var nanos1 = (_firebaseTimestamp_nanoseconds = firebaseTimestamp.nanoseconds) !== null && _firebaseTimestamp_nanoseconds !== void 0 ? _firebaseTimestamp_nanoseconds : 0;
925
+ return seconds1 * 1e3 + Math.floor(nanos1 / 1e6);
926
+ }
927
+ default:
928
+ {
929
+ if (debug) {
930
+ console.error("Invalid timestamp format: ", firebaseTimestamp);
931
+ }
932
+ return defaultReturnedValue;
933
+ }
934
+ }
935
+ }
936
+ function sort_by_timestamp(a, b) {
937
+ var reverse = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
938
+ return reverse ? timestamp_to_millis(b) - timestamp_to_millis(a) : timestamp_to_millis(a) - timestamp_to_millis(b);
939
+ }
940
+ // src/helpers/firebase.ts
813
941
  var import_meta = {};
814
942
  var initApp = function() {
815
943
  var isNodeEnv2 = typeof process !== "undefined" && process.env;
@@ -825,7 +953,7 @@ var initApp = function() {
825
953
  var app2 = (0, import_app.initializeApp)(firebaseConfig);
826
954
  var auth2 = (0, import_auth.getAuth)(app2);
827
955
  auth2.settings.appVerificationDisabledForTesting = false;
828
- var db2 = (0, import_firestore.getFirestore)(app2);
956
+ var db2 = (0, import_firestore2.getFirestore)(app2);
829
957
  var storage2 = (0, import_storage.getStorage)(app2);
830
958
  var googleLoginProvider2 = new import_auth.GoogleAuthProvider();
831
959
  var recaptchaSiteKey = isNodeEnv2 ? process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY : import_meta.env.VITE_RECAPTCHA_SITE_KEY;
@@ -875,33 +1003,33 @@ var useLoginWithGoogle = function() {
875
1003
  return signInWithGoogle;
876
1004
  };
877
1005
  var collections = {
878
- clients: (0, import_firestore.collection)(db, "nx-clients"),
879
- sites: (0, import_firestore.collection)(db, "nx-sites"),
880
- cars: (0, import_firestore.collection)(db, "units"),
881
- users: (0, import_firestore.collection)(db, "nx-users"),
882
- lastLocations: (0, import_firestore.collection)(db, "last_locations"),
883
- ermEvents: (0, import_firestore.collection)(db, "erm_events_general"),
884
- erm2Events: (0, import_firestore.collection)(db, "erm2_events_general"),
885
- ruptelaEvents: (0, import_firestore.collection)(db, "ruptela_events_general"),
886
- polygons: (0, import_firestore.collection)(db, "nx-polygons"),
887
- polygonEvents: (0, import_firestore.collection)(db, "polygon_events"),
888
- polygonCars: (0, import_firestore.collection)(db, "polygon_cars"),
889
- canbus: (0, import_firestore.collection)(db, "erm_canbus_parameters"),
890
- states: (0, import_firestore.collection)(db, "erm_states"),
891
- app_pro_commands_queue: (0, import_firestore.collection)(db, "app_pro_commands_queue"),
892
- trips: (0, import_firestore.collection)(db, "erm2_trip"),
893
- tripsDetails: (0, import_firestore.collection)(db, "erm2_trip_details"),
894
- audit: (0, import_firestore.collection)(db, "nx-audit"),
895
- nx_settings: (0, import_firestore.collection)(db, "nx-settings"),
896
- settings: (0, import_firestore.collection)(db, "settings"),
897
- translations: (0, import_firestore.collection)(db, "nx-translations"),
898
- nx_cars: (0, import_firestore.collection)(db, "nx-cars"),
899
- boards: (0, import_firestore.collection)(db, "boards"),
900
- protection_types: (0, import_firestore.collection)(db, "protectionTypes"),
901
- board_types: (0, import_firestore.collection)(db, "boardTypes"),
902
- charge_capacities: (0, import_firestore.collection)(db, "nx-charge-capacities")
1006
+ clients: (0, import_firestore2.collection)(db, "nx-clients"),
1007
+ sites: (0, import_firestore2.collection)(db, "nx-sites"),
1008
+ cars: (0, import_firestore2.collection)(db, "units"),
1009
+ users: (0, import_firestore2.collection)(db, "nx-users"),
1010
+ lastLocations: (0, import_firestore2.collection)(db, "last_locations"),
1011
+ ermEvents: (0, import_firestore2.collection)(db, "erm_events_general"),
1012
+ erm2Events: (0, import_firestore2.collection)(db, "erm2_events_general"),
1013
+ ruptelaEvents: (0, import_firestore2.collection)(db, "ruptela_events_general"),
1014
+ polygons: (0, import_firestore2.collection)(db, "nx-polygons"),
1015
+ polygonEvents: (0, import_firestore2.collection)(db, "polygon_events"),
1016
+ polygonCars: (0, import_firestore2.collection)(db, "polygon_cars"),
1017
+ canbus: (0, import_firestore2.collection)(db, "erm_canbus_parameters"),
1018
+ states: (0, import_firestore2.collection)(db, "erm_states"),
1019
+ app_pro_commands_queue: (0, import_firestore2.collection)(db, "app_pro_commands_queue"),
1020
+ trips: (0, import_firestore2.collection)(db, "erm2_trip"),
1021
+ tripsDetails: (0, import_firestore2.collection)(db, "erm2_trip_details"),
1022
+ audit: (0, import_firestore2.collection)(db, "nx-audit"),
1023
+ nx_settings: (0, import_firestore2.collection)(db, "nx-settings"),
1024
+ settings: (0, import_firestore2.collection)(db, "settings"),
1025
+ translations: (0, import_firestore2.collection)(db, "nx-translations"),
1026
+ nx_cars: (0, import_firestore2.collection)(db, "nx-cars"),
1027
+ boards: (0, import_firestore2.collection)(db, "boards"),
1028
+ protection_types: (0, import_firestore2.collection)(db, "protectionTypes"),
1029
+ board_types: (0, import_firestore2.collection)(db, "boardTypes"),
1030
+ charge_capacities: (0, import_firestore2.collection)(db, "nx-charge-capacities")
903
1031
  };
904
- var fire_base_TIME_TEMP = import_firestore.Timestamp.now;
1032
+ var fire_base_TIME_TEMP = import_firestore2.Timestamp.now;
905
1033
  var extractAlertsData = function(doc2) {
906
1034
  var data = doc2.data();
907
1035
  var car_number = data.car_number, timestamp = data.timestamp;
@@ -918,34 +1046,26 @@ var simpleExtractData = function(doc2) {
918
1046
  });
919
1047
  };
920
1048
  var extractSiteData = function(doc2) {
921
- var _data_updated, _data_created;
922
1049
  var data = doc2.data();
923
- var dateUpdated = new Date(((_data_updated = data.updated) === null || _data_updated === void 0 ? void 0 : _data_updated.seconds) * 1e3 + data.updated.nanoseconds / 1e6);
924
- var dateCreated = new Date(((_data_created = data.created) === null || _data_created === void 0 ? void 0 : _data_created.seconds) * 1e3 + data.created.nanoseconds / 1e6);
925
1050
  return _object_spread_props(_object_spread({}, data), {
926
1051
  id: doc2.id,
927
- created: (0, import_moment.default)(dateCreated).format("DD.MM.YYYY - HH:mm"),
928
- updated: (0, import_moment.default)(dateUpdated).format("DD.MM.YYYY - HH:mm")
1052
+ created: timestamp_to_string(data.created),
1053
+ updated: timestamp_to_string(data.updated)
929
1054
  });
930
1055
  };
931
1056
  var extractClientData = function(doc2) {
932
- var _data_updated, _data_created;
933
1057
  var data = doc2.data();
934
- var dateUpdated = new Date(((_data_updated = data.updated) === null || _data_updated === void 0 ? void 0 : _data_updated.seconds) * 1e3 + data.updated.nanoseconds / 1e6);
935
- var dateCreated = new Date(((_data_created = data.created) === null || _data_created === void 0 ? void 0 : _data_created.seconds) * 1e3 + data.created.nanoseconds / 1e6);
936
1058
  return _object_spread_props(_object_spread({}, data), {
937
1059
  id: doc2.id,
938
- created: (0, import_moment.default)(dateCreated).format("HH:mm DD/MM/YY"),
939
- updated: (0, import_moment.default)(dateUpdated).format("HH:mm DD/MM/YY")
1060
+ created: timestamp_to_string(data.created),
1061
+ updated: timestamp_to_string(data.updated)
940
1062
  });
941
1063
  };
942
1064
  var extractBoardsData = function(doc2) {
943
- var _data_uploaded;
944
1065
  var data = doc2.data();
945
- var dateUploaded = typeof data.uploaded === "string" ? data.uploaded : import_moment.default.unix((_data_uploaded = data.uploaded) === null || _data_uploaded === void 0 ? void 0 : _data_uploaded.seconds).format("DD/MM/YY HH:mm");
946
1066
  return _object_spread_props(_object_spread({}, data), {
947
1067
  id: doc2.id,
948
- uploaded: dateUploaded
1068
+ uploaded: timestamp_to_string(data.uploaded)
949
1069
  });
950
1070
  };
951
1071
  var extractCarsData = function(doc2) {
@@ -1009,7 +1129,7 @@ var get_all_documents = /*#__PURE__*/ function() {
1009
1129
  ]);
1010
1130
  return [
1011
1131
  4,
1012
- (0, import_firestore.getDocs)((0, import_firestore.collection)(db, collection_path))
1132
+ (0, import_firestore2.getDocs)((0, import_firestore2.collection)(db, collection_path))
1013
1133
  ];
1014
1134
  case 1:
1015
1135
  snapshot2 = _state.sent();
@@ -1049,10 +1169,10 @@ var get_document_by_id = /*#__PURE__*/ function() {
1049
1169
  ,
1050
1170
  3
1051
1171
  ]);
1052
- doc_ref = (0, import_firestore.doc)(db, collection_path, doc_id);
1172
+ doc_ref = (0, import_firestore2.doc)(db, collection_path, doc_id);
1053
1173
  return [
1054
1174
  4,
1055
- (0, import_firestore.getDoc)(doc_ref)
1175
+ (0, import_firestore2.getDoc)(doc_ref)
1056
1176
  ];
1057
1177
  case 1:
1058
1178
  doc_snap = _state.sent();
@@ -1093,10 +1213,10 @@ var set_document = /*#__PURE__*/ function() {
1093
1213
  ,
1094
1214
  3
1095
1215
  ]);
1096
- doc_ref = (0, import_firestore.doc)(db, collection_path, doc_id);
1216
+ doc_ref = (0, import_firestore2.doc)(db, collection_path, doc_id);
1097
1217
  return [
1098
1218
  4,
1099
- (0, import_firestore.setDoc)(doc_ref, data, {
1219
+ (0, import_firestore2.setDoc)(doc_ref, data, {
1100
1220
  merge: true
1101
1221
  })
1102
1222
  ];
@@ -1143,10 +1263,10 @@ var add_document = /*#__PURE__*/ function() {
1143
1263
  ,
1144
1264
  6
1145
1265
  ]);
1146
- col_ref = (0, import_firestore.collection)(db, collection_path);
1266
+ col_ref = (0, import_firestore2.collection)(db, collection_path);
1147
1267
  return [
1148
1268
  4,
1149
- (0, import_firestore.addDoc)(col_ref, data)
1269
+ (0, import_firestore2.addDoc)(col_ref, data)
1150
1270
  ];
1151
1271
  case 2:
1152
1272
  doc_ref = _state.sent();
@@ -1156,7 +1276,7 @@ var add_document = /*#__PURE__*/ function() {
1156
1276
  ];
1157
1277
  return [
1158
1278
  4,
1159
- (0, import_firestore.setDoc)(doc_ref, _object_spread_props(_object_spread({}, data), {
1279
+ (0, import_firestore2.setDoc)(doc_ref, _object_spread_props(_object_spread({}, data), {
1160
1280
  id: doc_ref.id
1161
1281
  }), {
1162
1282
  merge: true
@@ -1200,10 +1320,10 @@ var delete_document = /*#__PURE__*/ function() {
1200
1320
  ,
1201
1321
  3
1202
1322
  ]);
1203
- doc_ref = (0, import_firestore.doc)(db, collection_path, doc_id);
1323
+ doc_ref = (0, import_firestore2.doc)(db, collection_path, doc_id);
1204
1324
  return [
1205
1325
  4,
1206
- (0, import_firestore.deleteDoc)(doc_ref)
1326
+ (0, import_firestore2.deleteDoc)(doc_ref)
1207
1327
  ];
1208
1328
  case 1:
1209
1329
  _state.sent();
@@ -1245,10 +1365,10 @@ var query_document = /*#__PURE__*/ function() {
1245
1365
  ,
1246
1366
  4
1247
1367
  ]);
1248
- q = (0, import_firestore.query)((0, import_firestore.collection)(db, collection_path), (0, import_firestore.where)(field_name, operator, value));
1368
+ q = (0, import_firestore2.query)((0, import_firestore2.collection)(db, collection_path), (0, import_firestore2.where)(field_name, operator, value));
1249
1369
  return [
1250
1370
  4,
1251
- (0, import_firestore.getDocs)(q)
1371
+ (0, import_firestore2.getDocs)(q)
1252
1372
  ];
1253
1373
  case 2:
1254
1374
  query_snapshot = _state.sent();
@@ -1294,10 +1414,10 @@ var query_documents = /*#__PURE__*/ function() {
1294
1414
  ,
1295
1415
  3
1296
1416
  ]);
1297
- q = (0, import_firestore.query)((0, import_firestore.collection)(db, collection_path), (0, import_firestore.where)(field_name, operator, value));
1417
+ q = (0, import_firestore2.query)((0, import_firestore2.collection)(db, collection_path), (0, import_firestore2.where)(field_name, operator, value));
1298
1418
  return [
1299
1419
  4,
1300
- (0, import_firestore.getDocs)(q)
1420
+ (0, import_firestore2.getDocs)(q)
1301
1421
  ];
1302
1422
  case 1:
1303
1423
  query_snapshot = _state.sent();
@@ -1338,13 +1458,13 @@ var query_documents_by_conditions = /*#__PURE__*/ function() {
1338
1458
  ,
1339
1459
  3
1340
1460
  ]);
1341
- db_query = (0, import_firestore.collection)(db, collection_path);
1461
+ db_query = (0, import_firestore2.collection)(db, collection_path);
1342
1462
  where_conditions.forEach(function(condition) {
1343
- db_query = (0, import_firestore.query)(db_query, (0, import_firestore.where)(condition.field_name, condition.operator, condition.value));
1463
+ db_query = (0, import_firestore2.query)(db_query, (0, import_firestore2.where)(condition.field_name, condition.operator, condition.value));
1344
1464
  });
1345
1465
  return [
1346
1466
  4,
1347
- (0, import_firestore.getDocs)(db_query)
1467
+ (0, import_firestore2.getDocs)(db_query)
1348
1468
  ];
1349
1469
  case 1:
1350
1470
  query_snapshot = _state.sent();
@@ -1385,13 +1505,13 @@ var query_document_by_conditions = /*#__PURE__*/ function() {
1385
1505
  ,
1386
1506
  3
1387
1507
  ]);
1388
- db_query = (0, import_firestore.collection)(db, collection_path);
1508
+ db_query = (0, import_firestore2.collection)(db, collection_path);
1389
1509
  where_conditions.forEach(function(condition) {
1390
- db_query = (0, import_firestore.query)(db_query, (0, import_firestore.where)(condition.field_name, condition.operator, condition.value));
1510
+ db_query = (0, import_firestore2.query)(db_query, (0, import_firestore2.where)(condition.field_name, condition.operator, condition.value));
1391
1511
  });
1392
1512
  return [
1393
1513
  4,
1394
- (0, import_firestore.getDocs)(db_query)
1514
+ (0, import_firestore2.getDocs)(db_query)
1395
1515
  ];
1396
1516
  case 1:
1397
1517
  query_snapshot = _state.sent();
@@ -1437,18 +1557,18 @@ var snapshot = function(config, snapshotsFirstTime, settings) {
1437
1557
  }
1438
1558
  };
1439
1559
  });
1440
- var collectionRef = (0, import_firestore.collection)(db, config.collectionName);
1560
+ var collectionRef = (0, import_firestore2.collection)(db, config.collectionName);
1441
1561
  if (config.conditions) {
1442
1562
  config.conditions.forEach(function(condition) {
1443
- collectionRef = (0, import_firestore.query)(collectionRef, (0, import_firestore.where)(condition.field_name, condition.operator, condition.value));
1563
+ collectionRef = (0, import_firestore2.query)(collectionRef, (0, import_firestore2.where)(condition.field_name, condition.operator, condition.value));
1444
1564
  });
1445
1565
  }
1446
1566
  if (config.orderBy) {
1447
1567
  config.orderBy.forEach(function(order) {
1448
- collectionRef = (0, import_firestore.query)(collectionRef, (0, import_firestore.orderBy)(order.fieldName, order.direction));
1568
+ collectionRef = (0, import_firestore2.query)(collectionRef, (0, import_firestore2.orderBy)(order.fieldName, order.direction));
1449
1569
  });
1450
1570
  }
1451
- var unsubscribe = (0, import_firestore.onSnapshot)(collectionRef, function(snapshot2) {
1571
+ var unsubscribe = (0, import_firestore2.onSnapshot)(collectionRef, function(snapshot2) {
1452
1572
  var firstTimeKey = JSON.stringify({
1453
1573
  collectionName: config.collectionName,
1454
1574
  conditions: config.conditions || [],
@@ -1511,8 +1631,8 @@ var snapshotDocument = function(config, snapshotsFirstTime) {
1511
1631
  }
1512
1632
  };
1513
1633
  });
1514
- var documentRef = (0, import_firestore.doc)(db, config.collectionName, config.documentId);
1515
- var unsubscribe = (0, import_firestore.onSnapshot)(documentRef, function(docSnapshot) {
1634
+ var documentRef = (0, import_firestore2.doc)(db, config.collectionName, config.documentId);
1635
+ var unsubscribe = (0, import_firestore2.onSnapshot)(documentRef, function(docSnapshot) {
1516
1636
  if (!snapshotsFirstTime.includes(config.collectionName)) {
1517
1637
  snapshotsFirstTime.push(config.collectionName);
1518
1638
  if (docSnapshot.exists()) {
@@ -1776,7 +1896,7 @@ var addAuditRecord = /*#__PURE__*/ function() {
1776
1896
  ,
1777
1897
  3
1778
1898
  ]);
1779
- ref2 = (0, import_firestore.doc)(collections.audit);
1899
+ ref2 = (0, import_firestore2.doc)(collections.audit);
1780
1900
  data = {
1781
1901
  action: action,
1782
1902
  entity: entity,
@@ -1791,7 +1911,7 @@ var addAuditRecord = /*#__PURE__*/ function() {
1791
1911
  };
1792
1912
  return [
1793
1913
  4,
1794
- (0, import_firestore.setDoc)(ref2, _object_spread_props(_object_spread({}, data), {
1914
+ (0, import_firestore2.setDoc)(ref2, _object_spread_props(_object_spread({}, data), {
1795
1915
  datetime: fire_base_TIME_TEMP()
1796
1916
  }))
1797
1917
  ];
@@ -2334,133 +2454,6 @@ function cn() {
2334
2454
  }
2335
2455
  return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
2336
2456
  }
2337
- // src/helpers/time_helpers.ts
2338
- var import_firestore2 = require("firebase/firestore");
2339
- var import_moment_timezone = __toESM(require("moment-timezone"));
2340
- function timestamp_to_string(firebaseTimestamp, options) {
2341
- var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
2342
- var _ref = {
2343
- defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
2344
- format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "DD/MM/YYYY HH:mm:ss",
2345
- fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
2346
- tz: options === null || options === void 0 ? void 0 : options.tz,
2347
- debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
2348
- }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
2349
- var date;
2350
- switch(true){
2351
- case !firebaseTimestamp:
2352
- {
2353
- return defaultReturnedValue;
2354
- }
2355
- case _instanceof(firebaseTimestamp, import_firestore2.Timestamp):
2356
- {
2357
- date = firebaseTimestamp.toDate();
2358
- break;
2359
- }
2360
- case _instanceof(firebaseTimestamp, Date):
2361
- {
2362
- date = firebaseTimestamp;
2363
- break;
2364
- }
2365
- case typeof firebaseTimestamp === "string":
2366
- {
2367
- var m = import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
2368
- switch(m.isValid()){
2369
- case true:
2370
- date = m.toDate();
2371
- break;
2372
- default:
2373
- return defaultReturnedValue;
2374
- }
2375
- break;
2376
- }
2377
- case !!firebaseTimestamp._seconds:
2378
- {
2379
- var ft = firebaseTimestamp;
2380
- var _ft__nanoseconds;
2381
- date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
2382
- break;
2383
- }
2384
- case !!firebaseTimestamp.seconds:
2385
- {
2386
- var ft1 = firebaseTimestamp;
2387
- date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
2388
- break;
2389
- }
2390
- default:
2391
- {
2392
- if (debug) {
2393
- console.error("Invalid timestamp format: ", firebaseTimestamp);
2394
- }
2395
- return defaultReturnedValue;
2396
- }
2397
- }
2398
- switch(Boolean(tz)){
2399
- case true:
2400
- return (0, import_moment_timezone.default)(date).tz(tz).format(format);
2401
- default:
2402
- return import_moment_timezone.default.utc(date).format(format);
2403
- }
2404
- }
2405
- function timestamp_to_millis(firebaseTimestamp, options) {
2406
- var _options_defaultReturnedValue, _options_fromFormat, _options_debug;
2407
- var _ref = {
2408
- defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : 0,
2409
- fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
2410
- tz: options === null || options === void 0 ? void 0 : options.tz,
2411
- debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
2412
- }, defaultReturnedValue = _ref.defaultReturnedValue, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
2413
- switch(true){
2414
- case !firebaseTimestamp:
2415
- {
2416
- return defaultReturnedValue;
2417
- }
2418
- case _instanceof(firebaseTimestamp, import_firestore2.Timestamp):
2419
- {
2420
- return firebaseTimestamp.toMillis();
2421
- }
2422
- case _instanceof(firebaseTimestamp, Date):
2423
- {
2424
- var ms = firebaseTimestamp.getTime();
2425
- return isNaN(ms) ? defaultReturnedValue : ms;
2426
- }
2427
- case typeof firebaseTimestamp === "string":
2428
- {
2429
- var m = tz ? import_moment_timezone.default.tz(firebaseTimestamp, fromFormat, tz) : import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
2430
- switch(m.isValid()){
2431
- case true:
2432
- return m.valueOf();
2433
- default:
2434
- return defaultReturnedValue;
2435
- }
2436
- }
2437
- case !!firebaseTimestamp._seconds:
2438
- {
2439
- var seconds = firebaseTimestamp._seconds;
2440
- var _firebaseTimestamp__nanoseconds;
2441
- var nanos = (_firebaseTimestamp__nanoseconds = firebaseTimestamp._nanoseconds) !== null && _firebaseTimestamp__nanoseconds !== void 0 ? _firebaseTimestamp__nanoseconds : 0;
2442
- return seconds * 1e3 + Math.floor(nanos / 1e6);
2443
- }
2444
- case !!firebaseTimestamp.seconds:
2445
- {
2446
- var seconds1 = firebaseTimestamp.seconds;
2447
- var _firebaseTimestamp_nanoseconds;
2448
- var nanos1 = (_firebaseTimestamp_nanoseconds = firebaseTimestamp.nanoseconds) !== null && _firebaseTimestamp_nanoseconds !== void 0 ? _firebaseTimestamp_nanoseconds : 0;
2449
- return seconds1 * 1e3 + Math.floor(nanos1 / 1e6);
2450
- }
2451
- default:
2452
- {
2453
- if (debug) {
2454
- console.error("Invalid timestamp format: ", firebaseTimestamp);
2455
- }
2456
- return defaultReturnedValue;
2457
- }
2458
- }
2459
- }
2460
- function sort_by_timestamp(a, b) {
2461
- var reverse = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
2462
- return reverse ? timestamp_to_millis(b) - timestamp_to_millis(a) : timestamp_to_millis(a) - timestamp_to_millis(b);
2463
- }
2464
2457
  // src/helpers/api.ts
2465
2458
  var import_axios2 = __toESM(require("axios"));
2466
2459
  var baseDomain = mode === "qa" ? "https://nx-api.xyz/api" : "https://nx-api.info/api";