// Copyright (c) 2025-2026 Rocky Software Inc.
// All rights reserved.
//
// This file is part of the RockyGuard library and is distributed under
// the terms of the RockyGuard Library Software License Agreement. See
// docs/RockyGuard_License_Agreement.pdf in the distribution.
//
// No part of this file may be copied, modified, or distributed except
// as expressly permitted by the license agreement.

#pragma once

#include "types.h"
#include <map>
#include <string>
#include <vector>

namespace rockyguard {

struct ROCKYGUARD_API License {
    std::string license_id;
    std::string licensee;
    std::string product;
    std::string version_range;
    LicenseType type = LicenseType::NodeLocked;

    // Node-locked: individual component hashes separated by '|'
    std::string hardware_fingerprint;
    int fingerprint_match_threshold = 2;

    std::string issued_at;   // ISO 8601
    std::string expires_at;  // ISO 8601 or "permanent"
    int grace_period_days = 0;

    // Floating
    int max_concurrent_users = 0;

    std::vector<std::string> features;
    std::map<std::string, std::string> metadata;

    static License from_json(const std::string& json_str);
    std::string to_json() const;

    bool is_expired() const;
    bool is_in_grace_period() const;
    int grace_days_remaining() const;
    bool has_feature(const std::string& feature) const;
};

} // namespace rockyguard
