//
//  GSPluginHandler.h
//  GlyphsApp
//
//  Created by Georg Seifert on 07.10.25.
//  Copyright © 2025 schriftgestaltung.de. All rights reserved.
//

#import <GlyphsApp/GlyphsFileFormatProtocol.h>
#import <GlyphsApp/GlyphsToolProtocol.h>

NS_ASSUME_NONNULL_BEGIN

#ifndef GLYPHS_VIEWER
@class PluginManager;
#endif
@protocol GlyphsPlugin;

BOOL GSFileIsUnderQuarantine(NSString *path);

@interface GSPluginHandler : NSObject

+ (instancetype)sharedHandler;

/// Array of classes conforming to the `GlyphsPlugin` protocol.
@property (strong) NSMutableArray<Class> *pluginClasses;
/// Array of classes conforming to the `GlyphsFileFormat` protocol.
@property (strong) NSMutableArray<Class> *fileFormatClasses;
/// Array of classes conforming to the `GlyphsTool` protocol.
@property (strong) NSMutableArray<Class> *toolClasses;
/// Array of classes conforming to the `GlyphsPalette` protocol.
@property (strong) NSMutableArray<Class> *paletteClasses;
/// Array of classes conforming to the `GlyphsFilter` protocol.
@property (strong) NSMutableArray<Class> *filterClasses;
#if !defined(GLYPHS_LITE)
@property (strong) NSMutableArray<Class> *reporterClasses;
#endif
/// Maps plugin class names to their respective bundles. There might be multiple class names pointing to the same bundle.
@property (strong) NSMutableDictionary<NSString *, NSBundle *> *pluginBundlesRename;

@property (readonly, nonatomic) NSArray<NSObject<GlyphsPlugin> *> *pluginInstances;
@property (readonly, nonatomic) NSMutableArray *fileTypes;
@property (readonly, nonatomic) NSArray<NSObject<GlyphsFileFormat> *> *fileFormatInstances;
@property (strong, nonatomic) NSArray<NSBundle *> *customPluginBundles;

@property (nonatomic, retain) NSDictionary *pluginFileTypes;

@property (nonatomic, assign) BOOL ignoreUserPlugins;

- (nullable PluginManager *)pluginManager;

- (nullable NSObject<GlyphsPlugin> *)pluginForClassName:(NSString *)className;

@property (class, nonatomic) BOOL compatibility;

+ (NSMutableArray <GlyphsTool> *)instantiateTools:(NSArray<Class> *)classes;

+ (void)sortToolInstances:(NSMutableArray *)tools;

@end

NS_ASSUME_NONNULL_END
