from importlib.resources import files
from pathlib import Path

def Icon(name, style='outline'):
    """
    Retrieve the contents of an SVG icon file from the package.

    :param name: Icon base name (e.g., 'camera')
    :param style: 'outline' or 'filled' subfolder
    :return: SVG content string if found, otherwise None
    """
    name = name.lower()
    style = style.lower()
    folder = files(__package__).joinpath('icons', style)

    matches = sorted([f for f in folder.iterdir() if f.name.startswith(name) and f.name.endswith('.svg')])

    if matches:
        return matches[0].read_text(encoding='utf-8')
    return None

if __name__ == "__main__":
    svg = Icon('camera', 'outline')
    if svg:
        print("SVG content loaded:")
        print(svg)
    else:
        print("Icon not found.")
