import re
import json
from pdfminer.high_level import extract_text


TOC_PATH = "contents.pdf"


def parse_pdf_toc(pdf_path: str) -> list[str]:
    # using pdfminer (imported above), extract all lines of the pdf that are
    # lecture topics (lecture topics start below the table of contents header).
    # return a list of topics.

    return topics


def load_database() -> dict:
    try:
        # load json file "database.json" if it exists
    except FileNotFoundError:
        # parse pdf using parse_pdf_toc
        # create a dict from the topics with
        # keys: id numbers of topics and
        # values: a list [topic string, bool (initialized as false)]
        # write that database to database.json

    return database


def write_database(database: dict) -> None:
    # write database to database.json


def list_all_topics(database: dict) -> str:
    # extract all topics from database
    # construct a string with format
    # topic id :: topic string :: understood: yes/no
    return out


def list_not_understood(database: dict) -> str:
    # list all topics that are not understood
    # format
    # topic id :: topic_string
    return out


def toggle_topic_state(database: dict, topic_num: int) -> dict:
    # update the database with the selected topics understood status toggled
    return database


def main():
    welcome_str = """Great that you want to keep up with the lecture! What do you want to do next?

    (1) List all topics
    (2) Overview over work ahead
    (3) Toggle the 'understood' state of a topic
    """
    welcome_ans = input(welcome_str)

    # process the choice and perform required logic. If the choice is unknown 
    # display an error message and let the user try again.


if __name__ == "__main__":
    main()