//
//  RNUtils.h
//  RNInsider
//
//  Created by Heysem on 22.12.2025.
//  Copyright © 2025 Insider. All rights reserved.
//

#import <Foundation/Foundation.h>

#if __has_include(<InsiderMobile/Insider.h>)
#import <InsiderMobile/Insider.h>
#elif __has_include("Insider.h")
#import "Insider.h"
#endif

@interface RNUtils : NSObject

+ (nonnull InsiderEvent *)parseEventFromEventName:(nonnull NSString *)eventName
                                    andParameters:(nullable NSArray *)parameters;

+ (nonnull InsiderProduct *)parseProductFromRequiredFields:(nonnull NSDictionary *)requiredFields
                                         andOptionalFields:(nullable NSDictionary *)optionalFields
                                       andCustomParameters:(nullable NSArray *)customParameters;

+ (nonnull NSDictionary<NSString *, id> *)parseCustomParameters:(nonnull NSArray *)customParameters;

+ (nonnull NSArray<NSDictionary<NSString *, id> *> *)parseCustomParametersList:(nullable NSArray *)list;

+ (nonnull NSDictionary<NSString *, id> *)convertParametersForBridge:(nullable NSDictionary *)parameters;

+ (nonnull NSString *)mapAppCardsErrorCode:(nonnull NSError *)error;
+ (nonnull NSDictionary *)appCardsErrorToDictionary:(nonnull NSError *)error;

/// Maps the JS gender int (0 male, 1 female) to InsiderGender; any other value is Other.
+ (InsiderGender)genderFromInt:(int)gender;

/// Maps the JS dataType int (0 content, 1 element); `isValid` is NO for any other value.
+ (ContentOptimizerDataType)contentDataTypeFromInt:(int)dataType isValid:(nonnull BOOL *)isValid;

@end
