#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/// `qianapp://` 协议解析结果(不可变值对象)。
///
/// **协议形态**:`qianapp://<custom-path>?flowId=...&action=...&result=...&from=tencent_ess&<extras>`
///
/// **设计要点**:
/// - **不**包含 `errorCode` / `errorMsg`(如有则落入 ``extras``)
/// - `action` / `result` **保持 String** 不转 enum,空字符串与未知值原样保留
/// - 重复 query key 取首个,与 H5 团队约定一致
@interface TQSignResult : NSObject <NSCopying>

/// 原始 `qianapp://` URL 字面量
@property (nonatomic, copy, readonly) NSString *rawUrl;

/// host + path,例 `callback/sign`
@property (nonatomic, copy, readonly) NSString *customPath;

/// 流程 ID;协议未给则为空字符串
@property (nonatomic, copy, readonly) NSString *flowId;

/// 动作类型(String 直透,未识别值原样透出)。已知值见 ``TQSignAction``。
@property (nonatomic, copy, readonly) NSString *action;

/// 结果状态(String 直透,未识别值原样透出)。已知值见 ``TQSignResultStatus``。
@property (nonatomic, copy, readonly) NSString *result;

/// 来源标识,通常为 `tencent_ess`
@property (nonatomic, copy, readonly) NSString *from;

/// 客户自定义 query 透传(已剔除 4 个 recognized field)。
/// 重复 key 保留首个,UTF-8 percent-decoded。
@property (nonatomic, copy, readonly) NSDictionary<NSString *, NSString *> *extras;

- (instancetype)initWithRawUrl:(NSString *)rawUrl
                    customPath:(NSString *)customPath
                        flowId:(NSString *)flowId
                        action:(NSString *)action
                        result:(NSString *)result
                          from:(NSString *)from
                        extras:(NSDictionary<NSString *, NSString *> *)extras NS_DESIGNATED_INITIALIZER;

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

/// 全空 fallback,用于非法 URL 解析失败场景。
+ (TQSignResult *)empty;

@end

NS_ASSUME_NONNULL_END
