// Auto generated by Craby. DO NOT EDIT.
#import "CxxReactNativeNitroTorModule.hpp"
#import <ReactCommon/CxxTurboModuleUtils.h>
#include <string>

@interface ReactNativeNitroTorModuleProvider : NSObject
@end

@implementation ReactNativeNitroTorModuleProvider

+ (void)load {
  const char *cDataPath = [[self getDataPath] UTF8String];
  std::string dataPath(cDataPath);

  craby::reactnativenitrotor::modules::CxxReactNativeNitroTorModule::dataPath = dataPath;

  facebook::react::registerCxxModuleToGlobalModuleMap(
      craby::reactnativenitrotor::modules::CxxReactNativeNitroTorModule::kModuleName,
      [](std::shared_ptr<facebook::react::CallInvoker> jsInvoker) {
        return std::make_shared<craby::reactnativenitrotor::modules::CxxReactNativeNitroTorModule>(jsInvoker);
      });
}

+ (NSString *)getDataPath {
  NSString *appGroupID = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppGroupID"];
  NSString *dataPath = nil;

  if (appGroupID != nil) {
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSURL *containerURL = [fileManager containerURLForSecurityApplicationGroupIdentifier:appGroupID];

    if (containerURL == nil) {
      throw [NSException exceptionWithName:@"CrabyInitializationException"
                                    reason:[NSString stringWithFormat:@"Invalid AppGroup ID: %@", appGroupID]
                                  userInfo:nil];
      } else {
        dataPath = [containerURL path];
      }
  } else {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true);
    dataPath = [paths firstObject];
  }

  return dataPath;
}

@end
