"""
py2app setup for Mugi.app.
Build with: python setup.py py2app
Then run: open dist/Mugi.app
Or use: ./build_app.sh
"""
from setuptools import setup

# Bundle plist: required CFBundle keys + privacy usage descriptions from Info.plist
PLIST = {
    "CFBundleName": "Mugi",
    "CFBundleDisplayName": "Mugi",
    "CFBundleIdentifier": "com.mugi.app",
    "CFBundleVersion": "1.0.0",
    "CFBundleShortVersionString": "1.0.0",
    "CFBundleExecutable": "Mugi",
    "NSHighResolutionCapable": True,
    "NSMicrophoneUsageDescription": (
        "Mugi uses the microphone for voice input so you can speak your message instead of typing."
    ),
    "NSSpeechRecognitionUsageDescription": (
        "Mugi uses speech recognition to turn your voice into text in the chat input."
    ),
    "NSCalendarsUsageDescription": (
        "Mugi uses your calendar to show upcoming events and remind you before meetings."
    ),
}

APP = ["app_pyobjc2.py"]

OPTIONS = {
    "argv_emulation": False,
    "packages": [
        "core",
        "tools",
        "tools.ocr_backends",
        "utils",
        "messaging",
        "aiagent",
        "chat_storage",
        "persistence",
        "voice_input",
        "voice_output",
        "fastapi",
        "uvicorn",
        "starlette",
        "anyio",
        "openai",
        "langchain_core",
        "langchain_community",
        "httpx",
        "pydantic",
        "objc",
        "AppKit",
        "Foundation",
        "WebKit",
        "Quartz",
        "LocalAuthentication",
        "PyObjCTools",
        "Speech",
        "AVFoundation",
        "UserNotifications",
        "keyring",
        "keyring.backends",
        "keyring.backends.macOS",
    ],
    "includes": [
        "PyObjCTools",
        "PyObjCTools.AppHelper",
        "fastapi",
        "uvicorn",
        "uvicorn.logging",
        "uvicorn.loops",
        "uvicorn.loops.auto",
        "uvicorn.protocols",
        "uvicorn.protocols.http",
        "uvicorn.protocols.http.auto",
        "uvicorn.protocols.websockets",
        "uvicorn.protocols.websockets.auto",
        "uvicorn.lifespan",
        "uvicorn.lifespan.on",
        "starlette",
        "anyio",
        "openai",
        "langchain_core",
        "langchain_community",
        "httpx",
        "pydantic",
        "pydantic_core",
    ],
    "plist": PLIST,
    "iconfile": "mugi.icns",
}

setup(
    name="Mugi",
    app=APP,
    options={"py2app": OPTIONS},
)
