#ifndef RCT_NEW_ARCH_ENABLED

#import "BasePaperComponent.h"

// MARK: - Card-specific Manager

@interface RCTCardManager : RCTBasePaperComponentManager
@end

@implementation RCTCardManager

RCT_EXPORT_MODULE(CardPaper);

- (instancetype)init
{
    return [super initWithComponentType:RCTCheckoutComponentTypeCard];
}

RCT_EXPORT_VIEW_PROPERTY(config, NSDictionary);
RCT_EXPORT_VIEW_PROPERTY(onDimensionsChanged, RCTBubblingEventBlock);

RCT_EXPORT_METHOD(submit:(nonnull NSNumber *)reactTag) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTBasePaperComponent *> *viewRegistry) {
        RCTBasePaperComponent *view = viewRegistry[reactTag];
        if (view && [view isKindOfClass:[RCTBasePaperComponent class]]) {
            [view submit];
        }
    }];
}

RCT_EXPORT_METHOD(tokenize:(nonnull NSNumber *)reactTag) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTBasePaperComponent *> *viewRegistry) {
        RCTBasePaperComponent *view = viewRegistry[reactTag];
        if (view && [view isKindOfClass:[RCTBasePaperComponent class]]) {
            [view tokenize];
        }
    }];
}

@end

#endif
