akeyless-client-commons 1.1.70 → 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.
@@ -259,12 +259,12 @@ function _ts_generator(thisArg, body) {
259
259
  };
260
260
  }
261
261
  }
262
- import moment from "moment";
262
+ import moment2 from "moment";
263
263
  import { initializeApp } from "firebase/app";
264
264
  import { getStorage } from "firebase/storage";
265
265
  import { getAuth, GoogleAuthProvider, signInWithPopup } from "firebase/auth";
266
266
  import { initializeAppCheck, ReCaptchaEnterpriseProvider } from "firebase/app-check";
267
- import { addDoc, collection, deleteDoc, doc, getDoc, getDocs, query, setDoc, Timestamp, where, getFirestore, onSnapshot, orderBy } from "firebase/firestore";
267
+ import { addDoc, collection, deleteDoc, doc, getDoc, getDocs, query, setDoc, Timestamp as Timestamp2, where, getFirestore, onSnapshot, orderBy } from "firebase/firestore";
268
268
  // src/helpers/cars.ts
269
269
  var formatCarNumber = function(car_number) {
270
270
  var cn2 = car_number;
@@ -430,6 +430,134 @@ var initializeUserPermissions = /*#__PURE__*/ function() {
430
430
  }();
431
431
  // src/helpers/firebase.ts
432
432
  import { ref, getDownloadURL, uploadBytes } from "firebase/storage";
433
+ // src/helpers/time_helpers.ts
434
+ import { Timestamp } from "firebase/firestore";
435
+ import moment from "moment-timezone";
436
+ function timestamp_to_string(firebaseTimestamp, options) {
437
+ var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
438
+ var _ref = {
439
+ defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
440
+ 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",
441
+ 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",
442
+ tz: options === null || options === void 0 ? void 0 : options.tz,
443
+ debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
444
+ }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
445
+ var date;
446
+ switch(true){
447
+ case !firebaseTimestamp:
448
+ {
449
+ return defaultReturnedValue;
450
+ }
451
+ case _instanceof(firebaseTimestamp, Timestamp):
452
+ {
453
+ date = firebaseTimestamp.toDate();
454
+ break;
455
+ }
456
+ case _instanceof(firebaseTimestamp, Date):
457
+ {
458
+ date = firebaseTimestamp;
459
+ break;
460
+ }
461
+ case typeof firebaseTimestamp === "string":
462
+ {
463
+ var m = moment.utc(firebaseTimestamp, fromFormat);
464
+ switch(m.isValid()){
465
+ case true:
466
+ date = m.toDate();
467
+ break;
468
+ default:
469
+ return defaultReturnedValue;
470
+ }
471
+ break;
472
+ }
473
+ case !!firebaseTimestamp._seconds:
474
+ {
475
+ var ft = firebaseTimestamp;
476
+ var _ft__nanoseconds;
477
+ date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
478
+ break;
479
+ }
480
+ case !!firebaseTimestamp.seconds:
481
+ {
482
+ var ft1 = firebaseTimestamp;
483
+ date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
484
+ break;
485
+ }
486
+ default:
487
+ {
488
+ if (debug) {
489
+ console.error("Invalid timestamp format: ", firebaseTimestamp);
490
+ }
491
+ return defaultReturnedValue;
492
+ }
493
+ }
494
+ switch(Boolean(tz)){
495
+ case true:
496
+ return moment(date).tz(tz).format(format);
497
+ default:
498
+ return moment.utc(date).format(format);
499
+ }
500
+ }
501
+ function timestamp_to_millis(firebaseTimestamp, options) {
502
+ var _options_defaultReturnedValue, _options_fromFormat, _options_debug;
503
+ var _ref = {
504
+ defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : 0,
505
+ 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",
506
+ tz: options === null || options === void 0 ? void 0 : options.tz,
507
+ debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
508
+ }, defaultReturnedValue = _ref.defaultReturnedValue, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
509
+ switch(true){
510
+ case !firebaseTimestamp:
511
+ {
512
+ return defaultReturnedValue;
513
+ }
514
+ case _instanceof(firebaseTimestamp, Timestamp):
515
+ {
516
+ return firebaseTimestamp.toMillis();
517
+ }
518
+ case _instanceof(firebaseTimestamp, Date):
519
+ {
520
+ var ms = firebaseTimestamp.getTime();
521
+ return isNaN(ms) ? defaultReturnedValue : ms;
522
+ }
523
+ case typeof firebaseTimestamp === "string":
524
+ {
525
+ var m = tz ? moment.tz(firebaseTimestamp, fromFormat, tz) : moment.utc(firebaseTimestamp, fromFormat);
526
+ switch(m.isValid()){
527
+ case true:
528
+ return m.valueOf();
529
+ default:
530
+ return defaultReturnedValue;
531
+ }
532
+ }
533
+ case !!firebaseTimestamp._seconds:
534
+ {
535
+ var seconds = firebaseTimestamp._seconds;
536
+ var _firebaseTimestamp__nanoseconds;
537
+ var nanos = (_firebaseTimestamp__nanoseconds = firebaseTimestamp._nanoseconds) !== null && _firebaseTimestamp__nanoseconds !== void 0 ? _firebaseTimestamp__nanoseconds : 0;
538
+ return seconds * 1e3 + Math.floor(nanos / 1e6);
539
+ }
540
+ case !!firebaseTimestamp.seconds:
541
+ {
542
+ var seconds1 = firebaseTimestamp.seconds;
543
+ var _firebaseTimestamp_nanoseconds;
544
+ var nanos1 = (_firebaseTimestamp_nanoseconds = firebaseTimestamp.nanoseconds) !== null && _firebaseTimestamp_nanoseconds !== void 0 ? _firebaseTimestamp_nanoseconds : 0;
545
+ return seconds1 * 1e3 + Math.floor(nanos1 / 1e6);
546
+ }
547
+ default:
548
+ {
549
+ if (debug) {
550
+ console.error("Invalid timestamp format: ", firebaseTimestamp);
551
+ }
552
+ return defaultReturnedValue;
553
+ }
554
+ }
555
+ }
556
+ function sort_by_timestamp(a, b) {
557
+ var reverse = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
558
+ return reverse ? timestamp_to_millis(b) - timestamp_to_millis(a) : timestamp_to_millis(a) - timestamp_to_millis(b);
559
+ }
560
+ // src/helpers/firebase.ts
433
561
  var initApp = function() {
434
562
  var isNodeEnv2 = typeof process !== "undefined" && process.env;
435
563
  var firebaseConfig = {
@@ -520,13 +648,13 @@ var collections = {
520
648
  board_types: collection(db, "boardTypes"),
521
649
  charge_capacities: collection(db, "nx-charge-capacities")
522
650
  };
523
- var fire_base_TIME_TEMP = Timestamp.now;
651
+ var fire_base_TIME_TEMP = Timestamp2.now;
524
652
  var extractAlertsData = function(doc2) {
525
653
  var data = doc2.data();
526
654
  var car_number = data.car_number, timestamp = data.timestamp;
527
655
  return _object_spread_props(_object_spread({}, data), {
528
656
  timestamp_seconds: timestamp.seconds,
529
- timestamp_ui: moment.unix(timestamp.seconds).format("DD/MM/YY HH:mm"),
657
+ timestamp_ui: moment2.unix(timestamp.seconds).format("DD/MM/YY HH:mm"),
530
658
  car_number: formatCarNumber(car_number)
531
659
  });
532
660
  };
@@ -537,34 +665,26 @@ var simpleExtractData = function(doc2) {
537
665
  });
538
666
  };
539
667
  var extractSiteData = function(doc2) {
540
- var _data_updated, _data_created;
541
668
  var data = doc2.data();
542
- var dateUpdated = new Date(((_data_updated = data.updated) === null || _data_updated === void 0 ? void 0 : _data_updated.seconds) * 1e3 + data.updated.nanoseconds / 1e6);
543
- var dateCreated = new Date(((_data_created = data.created) === null || _data_created === void 0 ? void 0 : _data_created.seconds) * 1e3 + data.created.nanoseconds / 1e6);
544
669
  return _object_spread_props(_object_spread({}, data), {
545
670
  id: doc2.id,
546
- created: moment(dateCreated).format("DD.MM.YYYY - HH:mm"),
547
- updated: moment(dateUpdated).format("DD.MM.YYYY - HH:mm")
671
+ created: timestamp_to_string(data.created),
672
+ updated: timestamp_to_string(data.updated)
548
673
  });
549
674
  };
550
675
  var extractClientData = function(doc2) {
551
- var _data_updated, _data_created;
552
676
  var data = doc2.data();
553
- var dateUpdated = new Date(((_data_updated = data.updated) === null || _data_updated === void 0 ? void 0 : _data_updated.seconds) * 1e3 + data.updated.nanoseconds / 1e6);
554
- var dateCreated = new Date(((_data_created = data.created) === null || _data_created === void 0 ? void 0 : _data_created.seconds) * 1e3 + data.created.nanoseconds / 1e6);
555
677
  return _object_spread_props(_object_spread({}, data), {
556
678
  id: doc2.id,
557
- created: moment(dateCreated).format("HH:mm DD/MM/YY"),
558
- updated: moment(dateUpdated).format("HH:mm DD/MM/YY")
679
+ created: timestamp_to_string(data.created),
680
+ updated: timestamp_to_string(data.updated)
559
681
  });
560
682
  };
561
683
  var extractBoardsData = function(doc2) {
562
- var _data_uploaded;
563
684
  var data = doc2.data();
564
- var dateUploaded = typeof data.uploaded === "string" ? data.uploaded : moment.unix((_data_uploaded = data.uploaded) === null || _data_uploaded === void 0 ? void 0 : _data_uploaded.seconds).format("DD/MM/YY HH:mm");
565
685
  return _object_spread_props(_object_spread({}, data), {
566
686
  id: doc2.id,
567
- uploaded: dateUploaded
687
+ uploaded: timestamp_to_string(data.uploaded)
568
688
  });
569
689
  };
570
690
  var extractCarsData = function(doc2) {
@@ -598,7 +718,7 @@ var extractCanbusData = function(doc2) {
598
718
  newDate = new Date(data.timestamp.seconds * 1e3);
599
719
  }
600
720
  return _object_spread_props(_object_spread({}, data), {
601
- date_ui: newDate ? moment(newDate).format("DD/MM/YYYY - HH:mm") : "N/A"
721
+ date_ui: newDate ? moment2(newDate).format("DD/MM/YYYY - HH:mm") : "N/A"
602
722
  });
603
723
  };
604
724
  var extractLocationData = function(doc2) {
@@ -1952,133 +2072,6 @@ function cn() {
1952
2072
  }
1953
2073
  return twMerge(clsx(inputs));
1954
2074
  }
1955
- // src/helpers/time_helpers.ts
1956
- import { Timestamp as Timestamp2 } from "firebase/firestore";
1957
- import moment2 from "moment-timezone";
1958
- function timestamp_to_string(firebaseTimestamp, options) {
1959
- var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
1960
- var _ref = {
1961
- defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
1962
- 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",
1963
- 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",
1964
- tz: options === null || options === void 0 ? void 0 : options.tz,
1965
- debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
1966
- }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
1967
- var date;
1968
- switch(true){
1969
- case !firebaseTimestamp:
1970
- {
1971
- return defaultReturnedValue;
1972
- }
1973
- case _instanceof(firebaseTimestamp, Timestamp2):
1974
- {
1975
- date = firebaseTimestamp.toDate();
1976
- break;
1977
- }
1978
- case _instanceof(firebaseTimestamp, Date):
1979
- {
1980
- date = firebaseTimestamp;
1981
- break;
1982
- }
1983
- case typeof firebaseTimestamp === "string":
1984
- {
1985
- var m = moment2.utc(firebaseTimestamp, fromFormat);
1986
- switch(m.isValid()){
1987
- case true:
1988
- date = m.toDate();
1989
- break;
1990
- default:
1991
- return defaultReturnedValue;
1992
- }
1993
- break;
1994
- }
1995
- case !!firebaseTimestamp._seconds:
1996
- {
1997
- var ft = firebaseTimestamp;
1998
- var _ft__nanoseconds;
1999
- date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
2000
- break;
2001
- }
2002
- case !!firebaseTimestamp.seconds:
2003
- {
2004
- var ft1 = firebaseTimestamp;
2005
- date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
2006
- break;
2007
- }
2008
- default:
2009
- {
2010
- if (debug) {
2011
- console.error("Invalid timestamp format: ", firebaseTimestamp);
2012
- }
2013
- return defaultReturnedValue;
2014
- }
2015
- }
2016
- switch(Boolean(tz)){
2017
- case true:
2018
- return moment2(date).tz(tz).format(format);
2019
- default:
2020
- return moment2.utc(date).format(format);
2021
- }
2022
- }
2023
- function timestamp_to_millis(firebaseTimestamp, options) {
2024
- var _options_defaultReturnedValue, _options_fromFormat, _options_debug;
2025
- var _ref = {
2026
- defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : 0,
2027
- 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",
2028
- tz: options === null || options === void 0 ? void 0 : options.tz,
2029
- debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
2030
- }, defaultReturnedValue = _ref.defaultReturnedValue, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
2031
- switch(true){
2032
- case !firebaseTimestamp:
2033
- {
2034
- return defaultReturnedValue;
2035
- }
2036
- case _instanceof(firebaseTimestamp, Timestamp2):
2037
- {
2038
- return firebaseTimestamp.toMillis();
2039
- }
2040
- case _instanceof(firebaseTimestamp, Date):
2041
- {
2042
- var ms = firebaseTimestamp.getTime();
2043
- return isNaN(ms) ? defaultReturnedValue : ms;
2044
- }
2045
- case typeof firebaseTimestamp === "string":
2046
- {
2047
- var m = tz ? moment2.tz(firebaseTimestamp, fromFormat, tz) : moment2.utc(firebaseTimestamp, fromFormat);
2048
- switch(m.isValid()){
2049
- case true:
2050
- return m.valueOf();
2051
- default:
2052
- return defaultReturnedValue;
2053
- }
2054
- }
2055
- case !!firebaseTimestamp._seconds:
2056
- {
2057
- var seconds = firebaseTimestamp._seconds;
2058
- var _firebaseTimestamp__nanoseconds;
2059
- var nanos = (_firebaseTimestamp__nanoseconds = firebaseTimestamp._nanoseconds) !== null && _firebaseTimestamp__nanoseconds !== void 0 ? _firebaseTimestamp__nanoseconds : 0;
2060
- return seconds * 1e3 + Math.floor(nanos / 1e6);
2061
- }
2062
- case !!firebaseTimestamp.seconds:
2063
- {
2064
- var seconds1 = firebaseTimestamp.seconds;
2065
- var _firebaseTimestamp_nanoseconds;
2066
- var nanos1 = (_firebaseTimestamp_nanoseconds = firebaseTimestamp.nanoseconds) !== null && _firebaseTimestamp_nanoseconds !== void 0 ? _firebaseTimestamp_nanoseconds : 0;
2067
- return seconds1 * 1e3 + Math.floor(nanos1 / 1e6);
2068
- }
2069
- default:
2070
- {
2071
- if (debug) {
2072
- console.error("Invalid timestamp format: ", firebaseTimestamp);
2073
- }
2074
- return defaultReturnedValue;
2075
- }
2076
- }
2077
- }
2078
- function sort_by_timestamp(a, b) {
2079
- var reverse = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
2080
- return reverse ? timestamp_to_millis(b) - timestamp_to_millis(a) : timestamp_to_millis(a) - timestamp_to_millis(b);
2081
- }
2082
2075
  // src/helpers/api.ts
2083
2076
  import axios2 from "axios";
2084
2077
  var baseDomain = mode === "qa" ? "https://nx-api.xyz/api" : "https://nx-api.info/api";
@@ -2304,57 +2297,6 @@ var createAttachmentFromUrl = /*#__PURE__*/ function() {
2304
2297
  // src/helpers/socket.ts
2305
2298
  import { io } from "socket.io-client";
2306
2299
  var SESSION_STORAGE_KEY = "sessionId";
2307
- var safeSessionStorage = function() {
2308
- var memoryValue;
2309
- var canUseStorage = function() {
2310
- if (typeof window === "undefined") return false;
2311
- try {
2312
- var testKey = "".concat(SESSION_STORAGE_KEY, "_test");
2313
- window.localStorage.setItem(testKey, "1");
2314
- window.localStorage.removeItem(testKey);
2315
- return true;
2316
- } catch (error) {
2317
- console.warn("localStorage check failed, falling back to memory store", error);
2318
- return false;
2319
- }
2320
- };
2321
- var storageAvailable = canUseStorage();
2322
- return {
2323
- read: function read() {
2324
- if (!storageAvailable) {
2325
- return memoryValue;
2326
- }
2327
- try {
2328
- return window.localStorage.getItem(SESSION_STORAGE_KEY) || memoryValue;
2329
- } catch (error) {
2330
- console.warn("localStorage read failed, using memory store", error);
2331
- return memoryValue;
2332
- }
2333
- },
2334
- write: function write(value) {
2335
- memoryValue = value;
2336
- if (!storageAvailable || typeof value === "undefined") {
2337
- return;
2338
- }
2339
- try {
2340
- window.localStorage.setItem(SESSION_STORAGE_KEY, value);
2341
- } catch (error) {
2342
- console.warn("localStorage write failed, persisting in memory store", error);
2343
- }
2344
- },
2345
- clear: function clear() {
2346
- memoryValue = void 0;
2347
- if (!storageAvailable) {
2348
- return;
2349
- }
2350
- try {
2351
- window.localStorage.removeItem(SESSION_STORAGE_KEY);
2352
- } catch (error) {
2353
- console.warn("localStorage clear failed", error);
2354
- }
2355
- }
2356
- };
2357
- }();
2358
2300
  var SocketService = /*#__PURE__*/ function() {
2359
2301
  "use strict";
2360
2302
  function _SocketService() {
@@ -2375,7 +2317,7 @@ var SocketService = /*#__PURE__*/ function() {
2375
2317
  this.socket = io(socketUrl, {
2376
2318
  path: "/api/data-socket/connect",
2377
2319
  auth: function(cb) {
2378
- var sessionId = safeSessionStorage.read();
2320
+ var sessionId = localStorage.getItem(SESSION_STORAGE_KEY) || void 0;
2379
2321
  var token = _this.authToken;
2380
2322
  var authPayload = {};
2381
2323
  if (token) authPayload.token = token;
@@ -2417,7 +2359,7 @@ var SocketService = /*#__PURE__*/ function() {
2417
2359
  this.socket.on("session", function(param) {
2418
2360
  var session_id = param.session_id;
2419
2361
  if (session_id) {
2420
- safeSessionStorage.write(session_id);
2362
+ localStorage.setItem(SESSION_STORAGE_KEY, session_id);
2421
2363
  }
2422
2364
  });
2423
2365
  this.socket.on("connect_error", function(error) {
@@ -350,7 +350,7 @@ var import_app = require("firebase/app");
350
350
  var import_storage = require("firebase/storage");
351
351
  var import_auth = require("firebase/auth");
352
352
  var import_app_check = require("firebase/app-check");
353
- var import_firestore = require("firebase/firestore");
353
+ var import_firestore2 = require("firebase/firestore");
354
354
  var import_react = require("react");
355
355
  // src/helpers/phoneNumber.ts
356
356
  var import_libphonenumber_js = require("libphonenumber-js");
@@ -375,6 +375,10 @@ var checkUserPermissions = function(userPermissions, entity, permissions, mode2)
375
375
  checkUserPermissions({}, "dashboard", []);
376
376
  // src/helpers/firebase.ts
377
377
  var import_storage2 = require("firebase/storage");
378
+ // src/helpers/time_helpers.ts
379
+ var import_firestore = require("firebase/firestore");
380
+ var import_moment_timezone = __toESM(require("moment-timezone"));
381
+ // src/helpers/firebase.ts
378
382
  var import_meta = {};
379
383
  var initApp = function() {
380
384
  var isNodeEnv2 = typeof process !== "undefined" && process.env;
@@ -390,7 +394,7 @@ var initApp = function() {
390
394
  var app2 = (0, import_app.initializeApp)(firebaseConfig);
391
395
  var auth2 = (0, import_auth.getAuth)(app2);
392
396
  auth2.settings.appVerificationDisabledForTesting = false;
393
- var db2 = (0, import_firestore.getFirestore)(app2);
397
+ var db2 = (0, import_firestore2.getFirestore)(app2);
394
398
  var storage2 = (0, import_storage.getStorage)(app2);
395
399
  var googleLoginProvider2 = new import_auth.GoogleAuthProvider();
396
400
  var recaptchaSiteKey = isNodeEnv2 ? process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY : import_meta.env.VITE_RECAPTCHA_SITE_KEY;
@@ -415,33 +419,33 @@ var initApp = function() {
415
419
  };
416
420
  var _initApp = initApp(), db = _initApp.db, auth = _initApp.auth, storage = _initApp.storage, app = _initApp.app, appCheck = _initApp.appCheck, googleLoginProvider = _initApp.googleLoginProvider;
417
421
  var collections = {
418
- clients: (0, import_firestore.collection)(db, "nx-clients"),
419
- sites: (0, import_firestore.collection)(db, "nx-sites"),
420
- cars: (0, import_firestore.collection)(db, "units"),
421
- users: (0, import_firestore.collection)(db, "nx-users"),
422
- lastLocations: (0, import_firestore.collection)(db, "last_locations"),
423
- ermEvents: (0, import_firestore.collection)(db, "erm_events_general"),
424
- erm2Events: (0, import_firestore.collection)(db, "erm2_events_general"),
425
- ruptelaEvents: (0, import_firestore.collection)(db, "ruptela_events_general"),
426
- polygons: (0, import_firestore.collection)(db, "nx-polygons"),
427
- polygonEvents: (0, import_firestore.collection)(db, "polygon_events"),
428
- polygonCars: (0, import_firestore.collection)(db, "polygon_cars"),
429
- canbus: (0, import_firestore.collection)(db, "erm_canbus_parameters"),
430
- states: (0, import_firestore.collection)(db, "erm_states"),
431
- app_pro_commands_queue: (0, import_firestore.collection)(db, "app_pro_commands_queue"),
432
- trips: (0, import_firestore.collection)(db, "erm2_trip"),
433
- tripsDetails: (0, import_firestore.collection)(db, "erm2_trip_details"),
434
- audit: (0, import_firestore.collection)(db, "nx-audit"),
435
- nx_settings: (0, import_firestore.collection)(db, "nx-settings"),
436
- settings: (0, import_firestore.collection)(db, "settings"),
437
- translations: (0, import_firestore.collection)(db, "nx-translations"),
438
- nx_cars: (0, import_firestore.collection)(db, "nx-cars"),
439
- boards: (0, import_firestore.collection)(db, "boards"),
440
- protection_types: (0, import_firestore.collection)(db, "protectionTypes"),
441
- board_types: (0, import_firestore.collection)(db, "boardTypes"),
442
- charge_capacities: (0, import_firestore.collection)(db, "nx-charge-capacities")
422
+ clients: (0, import_firestore2.collection)(db, "nx-clients"),
423
+ sites: (0, import_firestore2.collection)(db, "nx-sites"),
424
+ cars: (0, import_firestore2.collection)(db, "units"),
425
+ users: (0, import_firestore2.collection)(db, "nx-users"),
426
+ lastLocations: (0, import_firestore2.collection)(db, "last_locations"),
427
+ ermEvents: (0, import_firestore2.collection)(db, "erm_events_general"),
428
+ erm2Events: (0, import_firestore2.collection)(db, "erm2_events_general"),
429
+ ruptelaEvents: (0, import_firestore2.collection)(db, "ruptela_events_general"),
430
+ polygons: (0, import_firestore2.collection)(db, "nx-polygons"),
431
+ polygonEvents: (0, import_firestore2.collection)(db, "polygon_events"),
432
+ polygonCars: (0, import_firestore2.collection)(db, "polygon_cars"),
433
+ canbus: (0, import_firestore2.collection)(db, "erm_canbus_parameters"),
434
+ states: (0, import_firestore2.collection)(db, "erm_states"),
435
+ app_pro_commands_queue: (0, import_firestore2.collection)(db, "app_pro_commands_queue"),
436
+ trips: (0, import_firestore2.collection)(db, "erm2_trip"),
437
+ tripsDetails: (0, import_firestore2.collection)(db, "erm2_trip_details"),
438
+ audit: (0, import_firestore2.collection)(db, "nx-audit"),
439
+ nx_settings: (0, import_firestore2.collection)(db, "nx-settings"),
440
+ settings: (0, import_firestore2.collection)(db, "settings"),
441
+ translations: (0, import_firestore2.collection)(db, "nx-translations"),
442
+ nx_cars: (0, import_firestore2.collection)(db, "nx-cars"),
443
+ boards: (0, import_firestore2.collection)(db, "boards"),
444
+ protection_types: (0, import_firestore2.collection)(db, "protectionTypes"),
445
+ board_types: (0, import_firestore2.collection)(db, "boardTypes"),
446
+ charge_capacities: (0, import_firestore2.collection)(db, "nx-charge-capacities")
443
447
  };
444
- var fire_base_TIME_TEMP = import_firestore.Timestamp.now;
448
+ var fire_base_TIME_TEMP = import_firestore2.Timestamp.now;
445
449
  var simpleExtractData = function(doc2) {
446
450
  var docData = doc2.data();
447
451
  return _object_spread_props(_object_spread({}, docData), {
@@ -460,10 +464,10 @@ var get_document_by_id = /*#__PURE__*/ function() {
460
464
  ,
461
465
  3
462
466
  ]);
463
- doc_ref = (0, import_firestore.doc)(db, collection_path, doc_id);
467
+ doc_ref = (0, import_firestore2.doc)(db, collection_path, doc_id);
464
468
  return [
465
469
  4,
466
- (0, import_firestore.getDoc)(doc_ref)
470
+ (0, import_firestore2.getDoc)(doc_ref)
467
471
  ];
468
472
  case 1:
469
473
  doc_snap = _state.sent();
@@ -506,18 +510,18 @@ var snapshot = function(config, snapshotsFirstTime, settings) {
506
510
  }
507
511
  };
508
512
  });
509
- var collectionRef = (0, import_firestore.collection)(db, config.collectionName);
513
+ var collectionRef = (0, import_firestore2.collection)(db, config.collectionName);
510
514
  if (config.conditions) {
511
515
  config.conditions.forEach(function(condition) {
512
- collectionRef = (0, import_firestore.query)(collectionRef, (0, import_firestore.where)(condition.field_name, condition.operator, condition.value));
516
+ collectionRef = (0, import_firestore2.query)(collectionRef, (0, import_firestore2.where)(condition.field_name, condition.operator, condition.value));
513
517
  });
514
518
  }
515
519
  if (config.orderBy) {
516
520
  config.orderBy.forEach(function(order) {
517
- collectionRef = (0, import_firestore.query)(collectionRef, (0, import_firestore.orderBy)(order.fieldName, order.direction));
521
+ collectionRef = (0, import_firestore2.query)(collectionRef, (0, import_firestore2.orderBy)(order.fieldName, order.direction));
518
522
  });
519
523
  }
520
- var unsubscribe = (0, import_firestore.onSnapshot)(collectionRef, function(snapshot3) {
524
+ var unsubscribe = (0, import_firestore2.onSnapshot)(collectionRef, function(snapshot3) {
521
525
  var firstTimeKey = JSON.stringify({
522
526
  collectionName: config.collectionName,
523
527
  conditions: config.conditions || [],
@@ -633,9 +637,6 @@ var chartsRegex = (0, import_xregexp.default)("[^\\p{L}0-9\\s.,_@!+-\\-]", "gu")
633
637
  // src/lib/utils.ts
634
638
  var import_clsx = require("clsx");
635
639
  var import_tailwind_merge = require("tailwind-merge");
636
- // src/helpers/time_helpers.ts
637
- var import_firestore2 = require("firebase/firestore");
638
- var import_moment_timezone = __toESM(require("moment-timezone"));
639
640
  // src/helpers/api.ts
640
641
  var import_axios2 = __toESM(require("axios"));
641
642
  var baseDomain = mode === "qa" ? "https://nx-api.xyz/api" : "https://nx-api.info/api";
@@ -652,57 +653,6 @@ var import_axios3 = __toESM(require("axios"));
652
653
  // src/helpers/socket.ts
653
654
  var import_socket = require("socket.io-client");
654
655
  var SESSION_STORAGE_KEY = "sessionId";
655
- var safeSessionStorage = function() {
656
- var memoryValue;
657
- var canUseStorage = function() {
658
- if (typeof window === "undefined") return false;
659
- try {
660
- var testKey = "".concat(SESSION_STORAGE_KEY, "_test");
661
- window.localStorage.setItem(testKey, "1");
662
- window.localStorage.removeItem(testKey);
663
- return true;
664
- } catch (error) {
665
- console.warn("localStorage check failed, falling back to memory store", error);
666
- return false;
667
- }
668
- };
669
- var storageAvailable = canUseStorage();
670
- return {
671
- read: function read() {
672
- if (!storageAvailable) {
673
- return memoryValue;
674
- }
675
- try {
676
- return window.localStorage.getItem(SESSION_STORAGE_KEY) || memoryValue;
677
- } catch (error) {
678
- console.warn("localStorage read failed, using memory store", error);
679
- return memoryValue;
680
- }
681
- },
682
- write: function write(value) {
683
- memoryValue = value;
684
- if (!storageAvailable || typeof value === "undefined") {
685
- return;
686
- }
687
- try {
688
- window.localStorage.setItem(SESSION_STORAGE_KEY, value);
689
- } catch (error) {
690
- console.warn("localStorage write failed, persisting in memory store", error);
691
- }
692
- },
693
- clear: function clear() {
694
- memoryValue = void 0;
695
- if (!storageAvailable) {
696
- return;
697
- }
698
- try {
699
- window.localStorage.removeItem(SESSION_STORAGE_KEY);
700
- } catch (error) {
701
- console.warn("localStorage clear failed", error);
702
- }
703
- }
704
- };
705
- }();
706
656
  var SocketService = /*#__PURE__*/ function() {
707
657
  "use strict";
708
658
  function _SocketService() {
@@ -723,7 +673,7 @@ var SocketService = /*#__PURE__*/ function() {
723
673
  this.socket = (0, import_socket.io)(socketUrl, {
724
674
  path: "/api/data-socket/connect",
725
675
  auth: function(cb) {
726
- var sessionId = safeSessionStorage.read();
676
+ var sessionId = localStorage.getItem(SESSION_STORAGE_KEY) || void 0;
727
677
  var token = _this.authToken;
728
678
  var authPayload = {};
729
679
  if (token) authPayload.token = token;
@@ -765,7 +715,7 @@ var SocketService = /*#__PURE__*/ function() {
765
715
  this.socket.on("session", function(param) {
766
716
  var session_id = param.session_id;
767
717
  if (session_id) {
768
- safeSessionStorage.write(session_id);
718
+ localStorage.setItem(SESSION_STORAGE_KEY, session_id);
769
719
  }
770
720
  });
771
721
  this.socket.on("connect_error", function(error) {