"""CUT editor backend — aggregator.

The implementation lives in clipshelf.routers.editor_*:
    editor_projects   project CRUD, draft expiry, bundles
    editor_assets     local media library, framegrab/trim, peaks, soundboard
    editor_captions   whisper word captions
    editor_render     render queue (lossless + headless-Chrome engine), publish

Third-party content search/import is NOT core — it rides media_provider
plugins (see plugin_host) surfaced at /api/providers.

Renders drive the same preview engine the browser uses, via headless Chrome
(render_worker.js), so exports match the preview exactly. Cut-only projects
take a fast lossless stream-copy path.
"""
from fastapi import APIRouter, HTTPException

from clipshelf.routers import (editor_assets, editor_captions,
                             editor_projects, editor_render)
from clipshelf.routers.editor_common import resolve_media, slugify  # noqa: F401 — re-exports

router = APIRouter(tags=["editor"])
for _sub in (editor_projects.router, editor_assets.router,
             editor_captions.router, editor_render.router):
    router.include_router(_sub)


def start_workers():
    """Started from the app lifespan — no threads on import."""
    editor_projects.start()
    editor_assets.start()
    editor_render.start()


# ---------------------------------------------------------------- stubs
# Features the editor frontend still pings — answer harmlessly.
@router.get("/api/editor/reel/active")
def reel_active():
    return {"jobs": []}


@router.post("/api/editor/segment")
@router.post("/api/editor/segpreview")
def segment_stub():
    raise HTTPException(503, "subject cutout is not included (needs SAM2 + a CUDA GPU)")
