#import "QuickMd5.h"
#import <React/RCTBridge+Private.h>
#import <React/RCTUtils.h>

@implementation QuickMd5

@synthesize bridge = _bridge;
@synthesize methodQueue = _methodQueue;

RCT_EXPORT_MODULE()

+ (BOOL)requiresMainQueueSetup {
  return YES;
}

- (void)setBridge:(RCTBridge *)bridge
{
  _bridge = bridge;
  _setBridgeOnMainQueue = RCTIsMainQueue();

  RCTCxxBridge *cxxBridge = (RCTCxxBridge *)self.bridge;
  if (!cxxBridge.runtime) {
    return;
  }

  [bridge dispatchBlock:^{
    installMd5(*(facebook::jsi::Runtime *)cxxBridge.runtime);
  } queue:RCTJSThread];
}

- (void)invalidate {
  cleanupMd5();
}

@end
