//
//  GSNameParticle.h
//  GlyphsCore
//
//  Created by Georg Seifert on 22.05.26.
//  Copyright © 2026 schriftgestaltung.de. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <GlyphsCore/GSContainerProtocol.h>

@class GSInfoValue;

NS_ASSUME_NONNULL_BEGIN

@interface GSNameParticle : NSObject <GSItemProtocol> {
#pragma GSAutoCodeStart ivars

	NSMutableArray<GSInfoValue *> *_names;
	BOOL _active;
	CGFloat _internal;
	CGFloat _external;

#pragma GSAutoCodeEnd ivars
}

@property (readonly) BOOL isLeaf;

@property (strong, nonatomic) NSString *name;

#pragma GSAutoCodeStart methods

#pragma mark Names

/// The names.
@property (nonatomic, strong, null_resettable) NSMutableArray<GSInfoValue *> *names;

/** The number of names */
- (NSUInteger)countOfNames;

/** Returns object at idx in names

 @param idx The index
 @return the object at index
 */
- (nullable GSInfoValue *)objectInNamesAtIndex:(NSUInteger)idx;

/** Returns the index of name in names

 @param name the object
 @return the index of the object
 */
- (NSUInteger)indexOfObjectInNames:(nonnull GSInfoValue *)name;

/** Adds the name

 @param name the object to be added
 */
- (void)addName:(nonnull GSInfoValue *)name;

/** Inserts the name at index into names

 @param name The object to insert
 @param idx The index
 */
- (void)insertObject:(nonnull GSInfoValue *)name inNamesAtIndex:(NSUInteger)idx;

/** Removes the name

 @param name the object to be removed
 */
- (void)removeObjectFromNames:(nonnull GSInfoValue *)name;

/** Removes the name at idx

 @param idx The index
 */
- (void)removeObjectFromNamesAtIndex:(NSUInteger)idx;

/// The active.
@property (nonatomic) BOOL active;

/// The internal.
@property (nonatomic) CGFloat internal;

/// The external.
@property (nonatomic) CGFloat external;

@property (nonatomic, strong, nullable) NSNumber *internalValue;

@property (nonatomic, strong, nullable) NSNumber *externalValue;

#pragma mark UserData

/// @name UserData
/** Place to store data.

 Here it is possible to store something. Please use a unique key.
 The objects should be able to serialize to a plist. If they are not, they should return all infos to store in description (as String).
 */
@property (strong, nonatomic, nullable) NSDictionary *userData;


/**
 convenience accessor to get to the content of the userData dict

 @param key the key
 @return the data stored with key
 */
- (nullable NSObject *)userDataForKey:(nonnull NSString *)key;


/** Adds something to the fonts userData.

 This also triggers undo/document dirty state.

 @param value The object should be able to serialize to a plist. If they are not, they should return all infos to store in description (as String).
 @param key   Please use an unique key that gives some indication who put it there (e.g. prefix it with your name or project).
 */
- (void)setUserData:(nullable id)value forKey:(nonnull NSString *)key;


/** Removed the object with this key.

 @param key The key to remove
 */
- (void)removeUserDataForKey:(nonnull NSString *)key;

#pragma mark TempData
/**
 a  dictionary that stores data. It will not be written to disk.
 */
@property (nonatomic, strong, null_resettable) NSDictionary *tempData;

/**
 Adds key/value to tempData. Pass nil as value to remove previous set data

 @param value and object or nil
 @param key the key
 */
- (void)setTempData:(nullable id)value forKey:(nonnull NSString *)key;

/**
 return value for key in tempData

 @param key the key
 @return a value or nil
 */
- (nullable id)tempDataForKey:(nonnull NSString *)key;

#pragma GSAutoCodeEnd methods

@end

NS_ASSUME_NONNULL_END
