def paginate_list(items, page=1, page_size=50): """Paginate a list with 1-indexed pages. Returns (page_items, total).""" page = max(1, page) page_size = max(1, min(200, page_size)) total = len(items) start = (page - 1) * page_size end = start + page_size return items[start:end], total