#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTEventEmitter.h>



@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"AwesomeProject3";
  // You can add your custom initial props in the dictionary below.
  // They will be passed down to the ViewController used by React Native.
  self.initialProps = @{};
  
  
//  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
//    RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"App" initialProperties:nil];
//
//
//  [self callReactNativeMethodWithBridge:bridge];
//
//   return YES;


//  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
//
//     // Create a root view for the React Native app
//     RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"CancelEvent" initialProperties:nil];

  // Set the root view's background color if needed
//      rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
//
//      // Create and configure the window
//      UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
//      UIViewController *rootViewController = [[UIViewController alloc] init];
//      rootViewController.view = rootView;
//      window.rootViewController = rootViewController;
//      [window makeKeyAndVisible];
//      self.window = window;
  
 
  
//  SwiftComponentManager *module = [[SwiftComponentManager alloc] init];
//      [bridge registerModule:module];


  
 // [bridge.moduleClasses addObject:[SwiftComponentManager class]];
    
  
  //[bridge registerModuleClass:[SwiftComponentManager class]];
   
 // [SwiftComponentManager registerWithBridge:bridge];
  
//  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
//                                                       moduleName:@"MyApp"
//                                                initialProperties:nil
//                                                    launchOptions:launchOptions];
  // bridge = rootView.bridge;
  
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

- (void)callReactNativeMethodWithBridge:(RCTBridge *)bridge {
  RCTEventEmitter *eventEmitter = [bridge moduleForClass:RCTEventEmitter.class];
  if (eventEmitter) {
    [eventEmitter sendEventWithName:@"CancelEvent" body:@{@"CancelEvent": @"CancelEvent"}];
  }
}


- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
///
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
/// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`.
- (BOOL)concurrentRootEnabled
{
  return true;
}

@end
