"""
transpiler/infrastructure/sdk_metadata.py — Metadata for Roblox SDK types.
"""

SDK_METADATA = {
    "Vector3": {
        "properties": ["X", "Y", "Z", "Magnitude", "Unit"],
        "methods": ["new", "Lerp", "Dot", "Cross", "FuzzyEq"]
    },
    "Vector2": {
        "properties": ["X", "Y", "Magnitude", "Unit"],
        "methods": ["new", "Lerp", "Dot", "Cross"]
    },
    "CFrame": {
        "properties": ["Position", "X", "Y", "Z", "Rotation", "RightVector", "UpVector", "LookVector"],
        "methods": ["new", "Angles", "fromEulerAnglesXYZ", "fromEulerAnglesYXZ", "fromMatrix", "Lerp", "Inverse", "ToWorldSpace", "ToObjectSpace", "PointToWorldSpace", "PointToObjectSpace"]
    },
    "Instance": {
        "properties": ["Name", "Parent", "ClassName", "Archivable"],
        "methods": ["new", "Destroy", "Clone", "IsA", "FindFirstChild", "WaitForChild", "GetChildren", "GetDescendants"]
    },
    "Part": {
        "bases": ["Instance"],
        "properties": ["Position", "Orientation", "Size", "Color", "Material", "Transparency", "CanCollide", "Anchored"],
        "methods": []
    },
    "Workspace": {
        "bases": ["Instance"],
        "properties": ["CurrentCamera", "Terrain"],
        "methods": ["Raycast"]
    }
}

def get_members(type_name: str) -> dict:
    meta = SDK_METADATA.get(type_name, {})
    all_props = set(meta.get("properties", []))
    all_meths = set(meta.get("methods", []))
    
    for base in meta.get("bases", []):
        base_meta = get_members(base)
        all_props.update(base_meta.get("properties", []))
        all_meths.update(base_meta.get("methods", []))
        
    return {"properties": list(all_props), "methods": list(all_meths)}

SDK_GLOBALS = [
    "game", "Workspace", "script", "print", "warn", "error", "type", "tostring", "tonumber",
    "math", "table", "string", "task", "coroutine", "debug", "utf8", "os",
    "Vector3", "Vector2", "CFrame", "Color3", "UDim", "UDim2", "Rect", "Instance", "Ray", "Region3",
    "spawn", "delay", "wait", "tick", "time"
]
