akeyless-client-commons 1.0.180 → 1.0.182

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.
@@ -370,16 +370,7 @@ import { parsePhoneNumberFromString } from "libphonenumber-js";
370
370
  var local_israel_phone_format = function(international_number) {
371
371
  return international_number.replace("+972", "0");
372
372
  };
373
- // src/helpers/global.ts
374
- import { CountryOptions, LanguageOptions } from "akeyless-types-commons";
375
- import axios from "axios";
376
- import { isEqual } from "lodash";
377
- var renderOnce = function() {
378
- return true;
379
- };
380
- var propsAreEqual = function(prevProps, nextProps) {
381
- return isEqual(prevProps, nextProps);
382
- };
373
+ // src/helpers/permissions.ts
383
374
  var parsePermissions = function(object) {
384
375
  if (!(object === null || object === void 0 ? void 0 : object.features)) {
385
376
  return {};
@@ -401,19 +392,6 @@ var parsePermissions = function(object) {
401
392
  });
402
393
  return result;
403
394
  };
404
- var getLocationUrl = function(lng, lat) {
405
- return "https://www.google.com/maps?q=".concat(lat, ",").concat(lng);
406
- };
407
- var isNodeEnv = typeof process !== "undefined" && process.env;
408
- var _ref = {
409
- mode: isNodeEnv ? process.env.NEXT_PUBLIC_MODE : import.meta.env.VITE_MODE,
410
- isLocal: (isNodeEnv ? process.env.NEXT_PUBLIC_IS_LOCAL : import.meta.env.VITE_is_local) === "true"
411
- }, mode = _ref.mode, isLocal = _ref.isLocal;
412
- var getFixedNumber = function() {
413
- var number = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, fix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
414
- var sum_value = number % 1 === 0 ? number : number.toFixed(fix).replace(/\.?0+$/, "");
415
- return String(sum_value);
416
- };
417
395
  // src/helpers/firebase.ts
418
396
  var initApp = function() {
419
397
  var isNodeEnv2 = typeof process !== "undefined" && process.env;
@@ -558,7 +536,7 @@ var set_document = /*#__PURE__*/ function() {
558
536
  return _ref.apply(this, arguments);
559
537
  };
560
538
  }();
561
- var query_document2 = /*#__PURE__*/ function() {
539
+ var query_document = /*#__PURE__*/ function() {
562
540
  var _ref = _async_to_generator(function(collection_path, field_name, operator, value) {
563
541
  var ignore_log, q, query_snapshot, documents, error;
564
542
  var _arguments = arguments;
@@ -607,7 +585,7 @@ var query_document2 = /*#__PURE__*/ function() {
607
585
  }
608
586
  });
609
587
  });
610
- return function query_document2(collection_path, field_name, operator, value) {
588
+ return function query_document(collection_path, field_name, operator, value) {
611
589
  return _ref.apply(this, arguments);
612
590
  };
613
591
  }();
@@ -623,7 +601,7 @@ var getUserByPhone = /*#__PURE__*/ function() {
623
601
  ];
624
602
  return [
625
603
  4,
626
- query_document2("nx-users", "phone_number", "in", phones, true)
604
+ query_document("nx-users", "phone_number", "in", phones, true)
627
605
  ];
628
606
  case 1:
629
607
  return [
@@ -644,7 +622,7 @@ var getUserByEmail = /*#__PURE__*/ function() {
644
622
  case 0:
645
623
  return [
646
624
  4,
647
- query_document2("nx-users", "email", "==", email, true)
625
+ query_document("nx-users", "email", "==", email, true)
648
626
  ];
649
627
  case 1:
650
628
  return [
@@ -792,6 +770,29 @@ var validateUserStatusAndPermissions = function(user, app2) {
792
770
  }
793
771
  return userPermissions;
794
772
  };
773
+ // src/helpers/global.ts
774
+ import { CountryOptions, LanguageOptions } from "akeyless-types-commons";
775
+ import axios from "axios";
776
+ import { isEqual } from "lodash";
777
+ var renderOnce = function() {
778
+ return true;
779
+ };
780
+ var propsAreEqual = function(prevProps, nextProps) {
781
+ return isEqual(prevProps, nextProps);
782
+ };
783
+ var getLocationUrl = function(lng, lat) {
784
+ return "https://www.google.com/maps?q=".concat(lat, ",").concat(lng);
785
+ };
786
+ var isNodeEnv = typeof process !== "undefined" && process.env;
787
+ var _ref = {
788
+ mode: isNodeEnv ? process.env.NEXT_PUBLIC_MODE : import.meta.env.VITE_MODE,
789
+ isLocal: (isNodeEnv ? process.env.NEXT_PUBLIC_IS_LOCAL : import.meta.env.VITE_is_local) === "true"
790
+ }, mode = _ref.mode, isLocal = _ref.isLocal;
791
+ var getFixedNumber = function() {
792
+ var number = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, fix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
793
+ var sum_value = number % 1 === 0 ? number : number.toFixed(fix).replace(/\.?0+$/, "");
794
+ return String(sum_value);
795
+ };
795
796
  // src/helpers/forms.ts
796
797
  import XRegExp from "xregexp";
797
798
  var textRegex = XRegExp("[^\\p{L}\\s-]", "gu");
@@ -1,9 +1,10 @@
1
+ import * as akeyless_types_commons from 'akeyless-types-commons';
2
+ import { TObject, NxUser, CountryOptions, LanguageOptions, UserPermissionsObject, userPermissionsObjectValue, Client } from 'akeyless-types-commons';
1
3
  import { FirebaseApp } from 'firebase/app';
2
4
  import { FirebaseStorage } from 'firebase/storage';
3
5
  import { Auth, GoogleAuthProvider, User } from 'firebase/auth';
4
6
  import { AppCheck } from 'firebase/app-check';
5
7
  import { WhereFilterOp, Unsubscribe, Firestore, CollectionReference, DocumentData, Timestamp, DocumentSnapshot } from 'firebase/firestore';
6
- import { TObject, NxUser, CountryOptions, Client, LanguageOptions } from 'akeyless-types-commons';
7
8
  import React from 'react';
8
9
  import { ClassValue } from 'clsx';
9
10
 
@@ -147,23 +148,12 @@ declare const addAuditRecord: (action: string, entity: string, details: TObject<
147
148
  phone_number: string;
148
149
  };
149
150
  }>;
150
- declare const validateUserStatusAndPermissions: (user: NxUser, app: AppName) => TObject<TObject<boolean>>;
151
+ declare const validateUserStatusAndPermissions: (user: NxUser, app: AppName) => akeyless_types_commons.UserPermissionsObject;
151
152
 
152
153
  declare const calculateBearing: (startLat: any, startLng: any, endLat: any, endLng: any) => number;
153
154
  declare const renderOnce: () => boolean;
154
155
  declare const propsAreEqual: (prevProps: any, nextProps: any) => boolean;
155
156
  declare const getUserCountryByIp: () => Promise<CountryOptions>;
156
- declare const parsePermissions: (object: NxUser | Client) => TObject<TObject<boolean>>;
157
- interface InitializeUserPermissionsProps {
158
- phoneNumber?: string;
159
- email?: string;
160
- firstTimeArray: string[];
161
- getUpdatePermissions: (permissions: TObject<TObject<boolean>>) => void;
162
- }
163
- declare const initializeUserPermissions: ({ phoneNumber, email, firstTimeArray, getUpdatePermissions }: InitializeUserPermissionsProps) => Promise<{
164
- unsubscribe: () => void;
165
- permissions: TObject<TObject<boolean>>;
166
- }>;
167
157
  declare const userNameFormat: (user?: NxUser) => string;
168
158
  declare const multiStringFormat: (str1: string, str2?: string, str3?: string) => string;
169
159
  declare const getLocationUrl: (lng: number, lat: number) => string;
@@ -240,4 +230,17 @@ type Method = "GET" | "POST" | "PUT" | "DELETE";
240
230
  type ServerName = "devices" | "bi" | "call-center";
241
231
  declare const nx_api_call: (serverName: ServerName, method: Method, url: string, data?: TObject<any>) => Promise<any>;
242
232
 
243
- export { type ValidationType, addAuditRecord, addLoginAudit, add_document, addressRegex, akeylessOnlineDomain, app, appCheck, auth, baseDomain, biDomain, calculateBearing, callCenterDomain, carsRegex, chartsRegex, cleanNxSites, cn, collections, colorRegex, createSelectors, db, delete_document, devicesDomain, displayFormatPhoneNumber, emailRegex, extractAlertsData, extractBoardsData, extractCanbusData, extractCarsData, extractClientData, extractLocationData, extractSiteData, fire_base_TIME_TEMP, formatCarNumber, getAddressByGeo, getFixedNumber, getFormCheckboxValue, getFormElementValue, getLocationUrl, getUserByEmail, getUserByIdentifier, getUserByPhone, getUserCountryByIp, get_all_documents, get_document_by_id, get_international_phone_number, googleLoginProvider, handleChange, handleInvalid, handlePaste, initializeUserPermissions, international_israel_phone_format, isInternational, isInternationalIsraelPhone, isLocal, isNodeEnv, is_iccid, local_israel_phone_format, mode, multiStringFormat, numbersOnlyRegex, numbersRegex, nx_api_call, parseMultiSelectInput, parsePermissions, priceRegex, propsAreEqual, query_document, query_document_by_conditions, query_documents, query_documents_by_conditions, renderOnce, setFormElementValue, setState, set_document, simpleExtractData, snapshot, snapshotDocument, sort_by_timestamp, storage, textNumbersRegex, textRegex, timestamp_to_millis, timestamp_to_string, useLoginWithGoogle, useStoreValues, useValidation, userNameFormat, validateUserStatusAndPermissions };
233
+ declare const checkUserPermissions: <T extends keyof UserPermissionsObject>(userPermissions: UserPermissionsObject, entity: T, permissions?: userPermissionsObjectValue<T>[], mode?: "some" | "every") => boolean;
234
+ declare const parsePermissions: (object: NxUser | Client) => UserPermissionsObject;
235
+ interface InitializeUserPermissionsProps {
236
+ phoneNumber?: string;
237
+ email?: string;
238
+ firstTimeArray: string[];
239
+ getUpdatePermissions: (permissions: UserPermissionsObject) => void;
240
+ }
241
+ declare const initializeUserPermissions: ({ phoneNumber, email, firstTimeArray, getUpdatePermissions }: InitializeUserPermissionsProps) => Promise<{
242
+ unsubscribe: () => void;
243
+ permissions: UserPermissionsObject;
244
+ }>;
245
+
246
+ export { type ValidationType, addAuditRecord, addLoginAudit, add_document, addressRegex, akeylessOnlineDomain, app, appCheck, auth, baseDomain, biDomain, calculateBearing, callCenterDomain, carsRegex, chartsRegex, checkUserPermissions, cleanNxSites, cn, collections, colorRegex, createSelectors, db, delete_document, devicesDomain, displayFormatPhoneNumber, emailRegex, extractAlertsData, extractBoardsData, extractCanbusData, extractCarsData, extractClientData, extractLocationData, extractSiteData, fire_base_TIME_TEMP, formatCarNumber, getAddressByGeo, getFixedNumber, getFormCheckboxValue, getFormElementValue, getLocationUrl, getUserByEmail, getUserByIdentifier, getUserByPhone, getUserCountryByIp, get_all_documents, get_document_by_id, get_international_phone_number, googleLoginProvider, handleChange, handleInvalid, handlePaste, initializeUserPermissions, international_israel_phone_format, isInternational, isInternationalIsraelPhone, isLocal, isNodeEnv, is_iccid, local_israel_phone_format, mode, multiStringFormat, numbersOnlyRegex, numbersRegex, nx_api_call, parseMultiSelectInput, parsePermissions, priceRegex, propsAreEqual, query_document, query_document_by_conditions, query_documents, query_documents_by_conditions, renderOnce, setFormElementValue, setState, set_document, simpleExtractData, snapshot, snapshotDocument, sort_by_timestamp, storage, textNumbersRegex, textRegex, timestamp_to_millis, timestamp_to_string, useLoginWithGoogle, useStoreValues, useValidation, userNameFormat, validateUserStatusAndPermissions };
@@ -1,9 +1,10 @@
1
+ import * as akeyless_types_commons from 'akeyless-types-commons';
2
+ import { TObject, NxUser, CountryOptions, LanguageOptions, UserPermissionsObject, userPermissionsObjectValue, Client } from 'akeyless-types-commons';
1
3
  import { FirebaseApp } from 'firebase/app';
2
4
  import { FirebaseStorage } from 'firebase/storage';
3
5
  import { Auth, GoogleAuthProvider, User } from 'firebase/auth';
4
6
  import { AppCheck } from 'firebase/app-check';
5
7
  import { WhereFilterOp, Unsubscribe, Firestore, CollectionReference, DocumentData, Timestamp, DocumentSnapshot } from 'firebase/firestore';
6
- import { TObject, NxUser, CountryOptions, Client, LanguageOptions } from 'akeyless-types-commons';
7
8
  import React from 'react';
8
9
  import { ClassValue } from 'clsx';
9
10
 
@@ -147,23 +148,12 @@ declare const addAuditRecord: (action: string, entity: string, details: TObject<
147
148
  phone_number: string;
148
149
  };
149
150
  }>;
150
- declare const validateUserStatusAndPermissions: (user: NxUser, app: AppName) => TObject<TObject<boolean>>;
151
+ declare const validateUserStatusAndPermissions: (user: NxUser, app: AppName) => akeyless_types_commons.UserPermissionsObject;
151
152
 
152
153
  declare const calculateBearing: (startLat: any, startLng: any, endLat: any, endLng: any) => number;
153
154
  declare const renderOnce: () => boolean;
154
155
  declare const propsAreEqual: (prevProps: any, nextProps: any) => boolean;
155
156
  declare const getUserCountryByIp: () => Promise<CountryOptions>;
156
- declare const parsePermissions: (object: NxUser | Client) => TObject<TObject<boolean>>;
157
- interface InitializeUserPermissionsProps {
158
- phoneNumber?: string;
159
- email?: string;
160
- firstTimeArray: string[];
161
- getUpdatePermissions: (permissions: TObject<TObject<boolean>>) => void;
162
- }
163
- declare const initializeUserPermissions: ({ phoneNumber, email, firstTimeArray, getUpdatePermissions }: InitializeUserPermissionsProps) => Promise<{
164
- unsubscribe: () => void;
165
- permissions: TObject<TObject<boolean>>;
166
- }>;
167
157
  declare const userNameFormat: (user?: NxUser) => string;
168
158
  declare const multiStringFormat: (str1: string, str2?: string, str3?: string) => string;
169
159
  declare const getLocationUrl: (lng: number, lat: number) => string;
@@ -240,4 +230,17 @@ type Method = "GET" | "POST" | "PUT" | "DELETE";
240
230
  type ServerName = "devices" | "bi" | "call-center";
241
231
  declare const nx_api_call: (serverName: ServerName, method: Method, url: string, data?: TObject<any>) => Promise<any>;
242
232
 
243
- export { type ValidationType, addAuditRecord, addLoginAudit, add_document, addressRegex, akeylessOnlineDomain, app, appCheck, auth, baseDomain, biDomain, calculateBearing, callCenterDomain, carsRegex, chartsRegex, cleanNxSites, cn, collections, colorRegex, createSelectors, db, delete_document, devicesDomain, displayFormatPhoneNumber, emailRegex, extractAlertsData, extractBoardsData, extractCanbusData, extractCarsData, extractClientData, extractLocationData, extractSiteData, fire_base_TIME_TEMP, formatCarNumber, getAddressByGeo, getFixedNumber, getFormCheckboxValue, getFormElementValue, getLocationUrl, getUserByEmail, getUserByIdentifier, getUserByPhone, getUserCountryByIp, get_all_documents, get_document_by_id, get_international_phone_number, googleLoginProvider, handleChange, handleInvalid, handlePaste, initializeUserPermissions, international_israel_phone_format, isInternational, isInternationalIsraelPhone, isLocal, isNodeEnv, is_iccid, local_israel_phone_format, mode, multiStringFormat, numbersOnlyRegex, numbersRegex, nx_api_call, parseMultiSelectInput, parsePermissions, priceRegex, propsAreEqual, query_document, query_document_by_conditions, query_documents, query_documents_by_conditions, renderOnce, setFormElementValue, setState, set_document, simpleExtractData, snapshot, snapshotDocument, sort_by_timestamp, storage, textNumbersRegex, textRegex, timestamp_to_millis, timestamp_to_string, useLoginWithGoogle, useStoreValues, useValidation, userNameFormat, validateUserStatusAndPermissions };
233
+ declare const checkUserPermissions: <T extends keyof UserPermissionsObject>(userPermissions: UserPermissionsObject, entity: T, permissions?: userPermissionsObjectValue<T>[], mode?: "some" | "every") => boolean;
234
+ declare const parsePermissions: (object: NxUser | Client) => UserPermissionsObject;
235
+ interface InitializeUserPermissionsProps {
236
+ phoneNumber?: string;
237
+ email?: string;
238
+ firstTimeArray: string[];
239
+ getUpdatePermissions: (permissions: UserPermissionsObject) => void;
240
+ }
241
+ declare const initializeUserPermissions: ({ phoneNumber, email, firstTimeArray, getUpdatePermissions }: InitializeUserPermissionsProps) => Promise<{
242
+ unsubscribe: () => void;
243
+ permissions: UserPermissionsObject;
244
+ }>;
245
+
246
+ export { type ValidationType, addAuditRecord, addLoginAudit, add_document, addressRegex, akeylessOnlineDomain, app, appCheck, auth, baseDomain, biDomain, calculateBearing, callCenterDomain, carsRegex, chartsRegex, checkUserPermissions, cleanNxSites, cn, collections, colorRegex, createSelectors, db, delete_document, devicesDomain, displayFormatPhoneNumber, emailRegex, extractAlertsData, extractBoardsData, extractCanbusData, extractCarsData, extractClientData, extractLocationData, extractSiteData, fire_base_TIME_TEMP, formatCarNumber, getAddressByGeo, getFixedNumber, getFormCheckboxValue, getFormElementValue, getLocationUrl, getUserByEmail, getUserByIdentifier, getUserByPhone, getUserCountryByIp, get_all_documents, get_document_by_id, get_international_phone_number, googleLoginProvider, handleChange, handleInvalid, handlePaste, initializeUserPermissions, international_israel_phone_format, isInternational, isInternationalIsraelPhone, isLocal, isNodeEnv, is_iccid, local_israel_phone_format, mode, multiStringFormat, numbersOnlyRegex, numbersRegex, nx_api_call, parseMultiSelectInput, parsePermissions, priceRegex, propsAreEqual, query_document, query_document_by_conditions, query_documents, query_documents_by_conditions, renderOnce, setFormElementValue, setState, set_document, simpleExtractData, snapshot, snapshotDocument, sort_by_timestamp, storage, textNumbersRegex, textRegex, timestamp_to_millis, timestamp_to_string, useLoginWithGoogle, useStoreValues, useValidation, userNameFormat, validateUserStatusAndPermissions };
@@ -335,6 +335,9 @@ __export(index_exports, {
335
335
  chartsRegex: function() {
336
336
  return chartsRegex;
337
337
  },
338
+ checkUserPermissions: function() {
339
+ return checkUserPermissions;
340
+ },
338
341
  cleanNxSites: function() {
339
342
  return cleanNxSites;
340
343
  },
@@ -492,7 +495,7 @@ __export(index_exports, {
492
495
  return propsAreEqual;
493
496
  },
494
497
  query_document: function() {
495
- return query_document2;
498
+ return query_document;
496
499
  },
497
500
  query_document_by_conditions: function() {
498
501
  return query_document_by_conditions;
@@ -612,74 +615,24 @@ var is_iccid = function(number) {
612
615
  if (!number.startsWith("89")) return false;
613
616
  return true;
614
617
  };
615
- // src/helpers/global.ts
616
- var import_akeyless_types_commons = require("akeyless-types-commons");
617
- var import_axios = __toESM(require("axios"));
618
- var import_lodash = require("lodash");
619
- var import_meta = {};
620
- var calculateBearing = function(startLat, startLng, endLat, endLng) {
621
- if (startLat === endLat || startLng === endLng) {
622
- return 0;
618
+ // src/helpers/permissions.ts
619
+ var checkUserPermissions = function(userPermissions, entity, permissions, mode2) {
620
+ var userValues = userPermissions[entity];
621
+ if (!userValues) {
622
+ return false;
623
623
  }
624
- if (startLat === void 0 || startLng === void 0 || endLat === void 0 || endLng === void 0) {
625
- return 0;
624
+ if (!(permissions === null || permissions === void 0 ? void 0 : permissions.length)) {
625
+ return true;
626
626
  }
627
- var startLatRad = startLat * Math.PI / 180;
628
- var startLngRad = startLng * Math.PI / 180;
629
- var endLatRad = endLat * Math.PI / 180;
630
- var endLngRad = endLng * Math.PI / 180;
631
- var dLon = endLngRad - startLngRad;
632
- var y = Math.sin(dLon) * Math.cos(endLatRad);
633
- var x = Math.cos(startLatRad) * Math.sin(endLatRad) - Math.sin(startLatRad) * Math.cos(endLatRad) * Math.cos(dLon);
634
- var bearing = Math.atan2(y, x) * 180 / Math.PI;
635
- return (bearing + 360) % 360;
636
- };
637
- var renderOnce = function() {
638
- return true;
639
- };
640
- var propsAreEqual = function(prevProps, nextProps) {
641
- return (0, import_lodash.isEqual)(prevProps, nextProps);
642
- };
643
- var getUserCountryByIp = /*#__PURE__*/ function() {
644
- var _ref = _async_to_generator(function() {
645
- var response, error;
646
- return _ts_generator(this, function(_state) {
647
- switch(_state.label){
648
- case 0:
649
- _state.trys.push([
650
- 0,
651
- 2,
652
- ,
653
- 3
654
- ]);
655
- return [
656
- 4,
657
- import_axios.default.get("https://ipapi.co/json/")
658
- ];
659
- case 1:
660
- response = _state.sent();
661
- return [
662
- 2,
663
- (response.data.country_code || import_akeyless_types_commons.CountryOptions.IL).toLowerCase()
664
- ];
665
- case 2:
666
- error = _state.sent();
667
- console.error("Error fetching Country:", error);
668
- return [
669
- 2,
670
- import_akeyless_types_commons.CountryOptions.IL
671
- ];
672
- case 3:
673
- return [
674
- 2
675
- ];
676
- }
627
+ if (mode2 === "every") {
628
+ return permissions.every(function(permission) {
629
+ return userValues[permission];
677
630
  });
631
+ }
632
+ return permissions.some(function(permission) {
633
+ return userValues[permission];
678
634
  });
679
- return function getUserCountryByIp() {
680
- return _ref.apply(this, arguments);
681
- };
682
- }();
635
+ };
683
636
  var parsePermissions = function(object) {
684
637
  if (!(object === null || object === void 0 ? void 0 : object.features)) {
685
638
  return {};
@@ -778,93 +731,17 @@ var initializeUserPermissions = /*#__PURE__*/ function() {
778
731
  return _ref.apply(this, arguments);
779
732
  };
780
733
  }();
781
- var userNameFormat = function(user) {
782
- return "".concat((user === null || user === void 0 ? void 0 : user.first_name) || "", " ").concat((user === null || user === void 0 ? void 0 : user.last_name) || "").trim();
783
- };
784
- var multiStringFormat = function(str1, str2, str3) {
785
- return "".concat(str1, " ").concat(str2 || "", " ").concat(str3 || "").trim();
786
- };
787
- var getLocationUrl = function(lng, lat) {
788
- return "https://www.google.com/maps?q=".concat(lat, ",").concat(lng);
789
- };
790
- var isNodeEnv = typeof process !== "undefined" && process.env;
791
- var _ref = {
792
- mode: isNodeEnv ? process.env.NEXT_PUBLIC_MODE : import_meta.env.VITE_MODE,
793
- isLocal: (isNodeEnv ? process.env.NEXT_PUBLIC_IS_LOCAL : import_meta.env.VITE_is_local) === "true"
794
- }, mode = _ref.mode, isLocal = _ref.isLocal;
795
- var getFixedNumber = function() {
796
- var number = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, fix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
797
- var sum_value = number % 1 === 0 ? number : number.toFixed(fix).replace(/\.?0+$/, "");
798
- return String(sum_value);
799
- };
800
- var getAddressByGeo = /*#__PURE__*/ function() {
801
- var _ref = _async_to_generator(function(param, currentLanguage) {
802
- var lat, lng, language, apiKey, url, _response_data, response, error;
803
- return _ts_generator(this, function(_state) {
804
- switch(_state.label){
805
- case 0:
806
- lat = param.lat, lng = param.lng;
807
- language = currentLanguage === import_akeyless_types_commons.LanguageOptions.He ? "iw" : "en";
808
- apiKey = isNodeEnv ? process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY : import_meta.env.VITE_api_google_key;
809
- url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=".concat(lat, ",").concat(lng, "&key=").concat(apiKey, "&language=").concat(language);
810
- _state.label = 1;
811
- case 1:
812
- _state.trys.push([
813
- 1,
814
- 3,
815
- ,
816
- 4
817
- ]);
818
- return [
819
- 4,
820
- import_axios.default.get(url)
821
- ];
822
- case 2:
823
- response = _state.sent();
824
- if (response === null || response === void 0 ? void 0 : (_response_data = response.data) === null || _response_data === void 0 ? void 0 : _response_data.results[0]) {
825
- return [
826
- 2,
827
- response.data.results[0].formatted_address.slice(0, 35)
828
- ];
829
- } else {
830
- return [
831
- 2,
832
- "address not found"
833
- ];
834
- }
835
- return [
836
- 3,
837
- 4
838
- ];
839
- case 3:
840
- error = _state.sent();
841
- console.error("getAddressByGeo error:", error);
842
- return [
843
- 3,
844
- 4
845
- ];
846
- case 4:
847
- return [
848
- 2
849
- ];
850
- }
851
- });
852
- });
853
- return function getAddressByGeo(_, currentLanguage) {
854
- return _ref.apply(this, arguments);
855
- };
856
- }();
857
734
  // src/helpers/firebase.ts
858
- var import_meta2 = {};
735
+ var import_meta = {};
859
736
  var initApp = function() {
860
737
  var isNodeEnv2 = typeof process !== "undefined" && process.env;
861
738
  var firebaseConfig = {
862
- apiKey: isNodeEnv2 ? process.env.NEXT_PUBLIC_API_KEY : import_meta2.env.VITE_API_KEY,
863
- authDomain: isNodeEnv2 ? process.env.NEXT_PUBLIC_AUTH_DOMAIN : import_meta2.env.VITE_AUTH_DOMAIN,
864
- projectId: isNodeEnv2 ? process.env.NEXT_PUBLIC_PROJECT_ID : import_meta2.env.VITE_PROJECT_ID,
865
- storageBucket: isNodeEnv2 ? process.env.NEXT_PUBLIC_STORAGE_BUCKET : import_meta2.env.VITE_STORAGE_BUCKET,
866
- messagingSenderId: isNodeEnv2 ? process.env.NEXT_PUBLIC_MESSAGING_SENDER_ID : import_meta2.env.VITE_MESSAGING_SENDER_ID,
867
- appId: isNodeEnv2 ? process.env.NEXT_PUBLIC_APP_ID : import_meta2.env.VITE_APP_ID
739
+ apiKey: isNodeEnv2 ? process.env.NEXT_PUBLIC_API_KEY : import_meta.env.VITE_API_KEY,
740
+ authDomain: isNodeEnv2 ? process.env.NEXT_PUBLIC_AUTH_DOMAIN : import_meta.env.VITE_AUTH_DOMAIN,
741
+ projectId: isNodeEnv2 ? process.env.NEXT_PUBLIC_PROJECT_ID : import_meta.env.VITE_PROJECT_ID,
742
+ storageBucket: isNodeEnv2 ? process.env.NEXT_PUBLIC_STORAGE_BUCKET : import_meta.env.VITE_STORAGE_BUCKET,
743
+ messagingSenderId: isNodeEnv2 ? process.env.NEXT_PUBLIC_MESSAGING_SENDER_ID : import_meta.env.VITE_MESSAGING_SENDER_ID,
744
+ appId: isNodeEnv2 ? process.env.NEXT_PUBLIC_APP_ID : import_meta.env.VITE_APP_ID
868
745
  };
869
746
  try {
870
747
  var app2 = (0, import_app.initializeApp)(firebaseConfig);
@@ -873,7 +750,7 @@ var initApp = function() {
873
750
  var db2 = (0, import_firestore.getFirestore)(app2);
874
751
  var storage2 = (0, import_storage.getStorage)(app2);
875
752
  var googleLoginProvider2 = new import_auth.GoogleAuthProvider();
876
- var recaptchaSiteKey = isNodeEnv2 ? process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY : import_meta2.env.VITE_RECAPTCHA_SITE_KEY;
753
+ var recaptchaSiteKey = isNodeEnv2 ? process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY : import_meta.env.VITE_RECAPTCHA_SITE_KEY;
877
754
  var result = {
878
755
  db: db2,
879
756
  auth: auth2,
@@ -1274,7 +1151,7 @@ var delete_document = /*#__PURE__*/ function() {
1274
1151
  return _ref.apply(this, arguments);
1275
1152
  };
1276
1153
  }();
1277
- var query_document2 = /*#__PURE__*/ function() {
1154
+ var query_document = /*#__PURE__*/ function() {
1278
1155
  var _ref = _async_to_generator(function(collection_path, field_name, operator, value) {
1279
1156
  var ignore_log, q, query_snapshot, documents, error;
1280
1157
  var _arguments = arguments;
@@ -1323,7 +1200,7 @@ var query_document2 = /*#__PURE__*/ function() {
1323
1200
  }
1324
1201
  });
1325
1202
  });
1326
- return function query_document2(collection_path, field_name, operator, value) {
1203
+ return function query_document(collection_path, field_name, operator, value) {
1327
1204
  return _ref.apply(this, arguments);
1328
1205
  };
1329
1206
  }();
@@ -1698,7 +1575,7 @@ var getUserByPhone = /*#__PURE__*/ function() {
1698
1575
  ];
1699
1576
  return [
1700
1577
  4,
1701
- query_document2("nx-users", "phone_number", "in", phones, true)
1578
+ query_document("nx-users", "phone_number", "in", phones, true)
1702
1579
  ];
1703
1580
  case 1:
1704
1581
  return [
@@ -1719,7 +1596,7 @@ var getUserByEmail = /*#__PURE__*/ function() {
1719
1596
  case 0:
1720
1597
  return [
1721
1598
  4,
1722
- query_document2("nx-users", "email", "==", email, true)
1599
+ query_document("nx-users", "email", "==", email, true)
1723
1600
  ];
1724
1601
  case 1:
1725
1602
  return [
@@ -1867,6 +1744,150 @@ var validateUserStatusAndPermissions = function(user, app2) {
1867
1744
  }
1868
1745
  return userPermissions;
1869
1746
  };
1747
+ // src/helpers/global.ts
1748
+ var import_akeyless_types_commons = require("akeyless-types-commons");
1749
+ var import_axios = __toESM(require("axios"));
1750
+ var import_lodash = require("lodash");
1751
+ var import_meta2 = {};
1752
+ var calculateBearing = function(startLat, startLng, endLat, endLng) {
1753
+ if (startLat === endLat || startLng === endLng) {
1754
+ return 0;
1755
+ }
1756
+ if (startLat === void 0 || startLng === void 0 || endLat === void 0 || endLng === void 0) {
1757
+ return 0;
1758
+ }
1759
+ var startLatRad = startLat * Math.PI / 180;
1760
+ var startLngRad = startLng * Math.PI / 180;
1761
+ var endLatRad = endLat * Math.PI / 180;
1762
+ var endLngRad = endLng * Math.PI / 180;
1763
+ var dLon = endLngRad - startLngRad;
1764
+ var y = Math.sin(dLon) * Math.cos(endLatRad);
1765
+ var x = Math.cos(startLatRad) * Math.sin(endLatRad) - Math.sin(startLatRad) * Math.cos(endLatRad) * Math.cos(dLon);
1766
+ var bearing = Math.atan2(y, x) * 180 / Math.PI;
1767
+ return (bearing + 360) % 360;
1768
+ };
1769
+ var renderOnce = function() {
1770
+ return true;
1771
+ };
1772
+ var propsAreEqual = function(prevProps, nextProps) {
1773
+ return (0, import_lodash.isEqual)(prevProps, nextProps);
1774
+ };
1775
+ var getUserCountryByIp = /*#__PURE__*/ function() {
1776
+ var _ref = _async_to_generator(function() {
1777
+ var response, error;
1778
+ return _ts_generator(this, function(_state) {
1779
+ switch(_state.label){
1780
+ case 0:
1781
+ _state.trys.push([
1782
+ 0,
1783
+ 2,
1784
+ ,
1785
+ 3
1786
+ ]);
1787
+ return [
1788
+ 4,
1789
+ import_axios.default.get("https://ipapi.co/json/")
1790
+ ];
1791
+ case 1:
1792
+ response = _state.sent();
1793
+ return [
1794
+ 2,
1795
+ (response.data.country_code || import_akeyless_types_commons.CountryOptions.IL).toLowerCase()
1796
+ ];
1797
+ case 2:
1798
+ error = _state.sent();
1799
+ console.error("Error fetching Country:", error);
1800
+ return [
1801
+ 2,
1802
+ import_akeyless_types_commons.CountryOptions.IL
1803
+ ];
1804
+ case 3:
1805
+ return [
1806
+ 2
1807
+ ];
1808
+ }
1809
+ });
1810
+ });
1811
+ return function getUserCountryByIp() {
1812
+ return _ref.apply(this, arguments);
1813
+ };
1814
+ }();
1815
+ var userNameFormat = function(user) {
1816
+ return "".concat((user === null || user === void 0 ? void 0 : user.first_name) || "", " ").concat((user === null || user === void 0 ? void 0 : user.last_name) || "").trim();
1817
+ };
1818
+ var multiStringFormat = function(str1, str2, str3) {
1819
+ return "".concat(str1, " ").concat(str2 || "", " ").concat(str3 || "").trim();
1820
+ };
1821
+ var getLocationUrl = function(lng, lat) {
1822
+ return "https://www.google.com/maps?q=".concat(lat, ",").concat(lng);
1823
+ };
1824
+ var isNodeEnv = typeof process !== "undefined" && process.env;
1825
+ var _ref = {
1826
+ mode: isNodeEnv ? process.env.NEXT_PUBLIC_MODE : import_meta2.env.VITE_MODE,
1827
+ isLocal: (isNodeEnv ? process.env.NEXT_PUBLIC_IS_LOCAL : import_meta2.env.VITE_is_local) === "true"
1828
+ }, mode = _ref.mode, isLocal = _ref.isLocal;
1829
+ var getFixedNumber = function() {
1830
+ var number = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, fix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4;
1831
+ var sum_value = number % 1 === 0 ? number : number.toFixed(fix).replace(/\.?0+$/, "");
1832
+ return String(sum_value);
1833
+ };
1834
+ var getAddressByGeo = /*#__PURE__*/ function() {
1835
+ var _ref = _async_to_generator(function(param, currentLanguage) {
1836
+ var lat, lng, language, apiKey, url, _response_data, response, error;
1837
+ return _ts_generator(this, function(_state) {
1838
+ switch(_state.label){
1839
+ case 0:
1840
+ lat = param.lat, lng = param.lng;
1841
+ language = currentLanguage === import_akeyless_types_commons.LanguageOptions.He ? "iw" : "en";
1842
+ apiKey = isNodeEnv ? process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY : import_meta2.env.VITE_api_google_key;
1843
+ url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=".concat(lat, ",").concat(lng, "&key=").concat(apiKey, "&language=").concat(language);
1844
+ _state.label = 1;
1845
+ case 1:
1846
+ _state.trys.push([
1847
+ 1,
1848
+ 3,
1849
+ ,
1850
+ 4
1851
+ ]);
1852
+ return [
1853
+ 4,
1854
+ import_axios.default.get(url)
1855
+ ];
1856
+ case 2:
1857
+ response = _state.sent();
1858
+ if (response === null || response === void 0 ? void 0 : (_response_data = response.data) === null || _response_data === void 0 ? void 0 : _response_data.results[0]) {
1859
+ return [
1860
+ 2,
1861
+ response.data.results[0].formatted_address.slice(0, 35)
1862
+ ];
1863
+ } else {
1864
+ return [
1865
+ 2,
1866
+ "address not found"
1867
+ ];
1868
+ }
1869
+ return [
1870
+ 3,
1871
+ 4
1872
+ ];
1873
+ case 3:
1874
+ error = _state.sent();
1875
+ console.error("getAddressByGeo error:", error);
1876
+ return [
1877
+ 3,
1878
+ 4
1879
+ ];
1880
+ case 4:
1881
+ return [
1882
+ 2
1883
+ ];
1884
+ }
1885
+ });
1886
+ });
1887
+ return function getAddressByGeo(_, currentLanguage) {
1888
+ return _ref.apply(this, arguments);
1889
+ };
1890
+ }();
1870
1891
  // src/helpers/forms.ts
1871
1892
  var import_xregexp = __toESM(require("xregexp"));
1872
1893
  var textRegex = (0, import_xregexp.default)("[^\\p{L}\\s-]", "gu");
@@ -2150,6 +2171,7 @@ var nx_api_call = /*#__PURE__*/ function() {
2150
2171
  callCenterDomain: callCenterDomain,
2151
2172
  carsRegex: carsRegex,
2152
2173
  chartsRegex: chartsRegex,
2174
+ checkUserPermissions: checkUserPermissions,
2153
2175
  cleanNxSites: cleanNxSites,
2154
2176
  cn: cn,
2155
2177
  collections: collections,