#import "RNZoomVideoSdkShareAction.h"
#import "RCTConvert+RNZoomVideoSdk.h"

@implementation RNZoomVideoSdkShareAction

+ (NSDictionary *)mapShareAction: (ZoomVideoSDKShareAction *) shareAction {
    @try {
        if (shareAction == nil) {
            return @{};
        }
        NSDictionary *shareActionData = @{
                @"shareSourceId": @([shareAction getShareSourceId]),
                @"shareStatus": [[RCTConvert ZoomVideoSDKReceiveSharingStatusValuesReversed] objectForKey: @([shareAction getShareStatus])],
                @"subscribeFailReason": [[RCTConvert ZoomVideoSDKSubscribeFailReasonValuesReversed] objectForKey: @([shareAction getSubscribeFailReason])],
                @"isAnnotationPrivilegeEnabled": @([shareAction isAnnotationPrivilegeEnabled]),
                @"shareType": [[RCTConvert ZoomVideoSDKShareTypeValuesReversed] objectForKey: @([shareAction getShareType])],
        };
        return shareActionData;
    }
    @catch (NSException *e) {
        return @{};
    }
}

+ (NSMutableArray *) mapShareActionArray: (NSArray <ZoomVideoSDKShareAction*>*)shareActionArray {
    NSMutableArray *mappedShareActionArray = [NSMutableArray array];

    @try {
        [shareActionArray enumerateObjectsUsingBlock:^(ZoomVideoSDKShareAction * _Nonnull shareAction, NSUInteger idx, BOOL * _Nonnull stop) {
            [mappedShareActionArray addObject: [RNZoomVideoSdkShareAction mapShareAction: shareAction]];
        }];
    }
    @finally {
        return mappedShareActionArray;
    }
}

@end
