//
//  MVMCoreUIMoleculeMappingObject.h
//  MVMCoreUI
//
//  Created by Scott Pfeil on 2/11/19.
//  Copyright © 2019 Verizon Wireless. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
@class MVMCoreUIDelegateObject;
@class MVMCoreLoadObject;
@class MVMCoreErrorObject;

@interface MVMCoreUIMoleculeMappingObject : NSObject

/// Maps molecule name to class.
@property (nonnull, strong, nonatomic) NSMutableDictionary <NSString *, Class> *moleculeMapping;

/// Returns the shared instance
+ (nullable instancetype)sharedMappingObject;

/// Returns the molecule class.
- (nullable Class)getMoleculeClassWithJSON:(nonnull NSDictionary *)json;

#pragma mark - Molecule Creation

/// Creates the molecule for the molecule json.
- (nullable UIView <MVMCoreUIMoleculeViewProtocol>*)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject;

/// Creates the molecule for the molecule json. Also checks if the molecule needs to be constrained for a stack/list style situation.
- (nullable UIView <MVMCoreUIMoleculeViewProtocol>*)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject constrainIfNeeded:(BOOL)constrainIfNeeded;

#pragma mark - Convenience

+ (nullable NSArray <NSString *>*)getRequiredModulesForJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject error:(MVMCoreErrorObject *_Nullable *_Nullable)error;
+ (void)addRequiredModulesForJSON:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject moduleList:(nullable NSMutableArray <NSDictionary *>*)moduleList errorList:(nullable NSMutableArray <MVMCoreErrorObject *>*)errorList;

@end
