from typing import Tuple


def find_line_col(text: str, offset: int) -> Tuple[int, int]:
    """
    Returns the line and column corresponding to an offset in a given text.

    Args:
        text: The text to search.
        offset: The 0-based character offset. The function will essentially look for the position of the character
            at ``text[offset]``. It can also be equal to ``len(text)`` in which case the function will report the
            position of a potential character after the last character in the text.

    Returns:
        A (line, column) tuple corresponding to `offset`. The line and column are 1-based.

    Notes:

    - The offset, line and column all refer to character, not byte, offsets.
    - This only handles input where the lines are separated by a single ``\\n`` character.
    - If ``text[offset]`` is a newline, its reported column will be 1 more than the position of the last character in the
      line. Thus, for a file of 80-column text, the column may be 81.
    - If `offset` is ``len(text)``, the virtual character is placed either:

      - One column to the right of the last character in the last line, if it does not end with a newline
      - On the first column of the next line number, if it does

    - The function is not particularly optimized for working with huge data and cannot use a prebuilt line index, etc.
      It is meant for one-off analyses such as when building an exception text for a syntax error in a config file.
    """

    if (offset < 0) or (offset > len(text)):
        raise IndexError(f"Offset {offset} lies outside text of length {len(text)}")

    cur_line_no = 1
    cur_line_start = 0

    while cur_line_start < len(text):
        cur_line_end = text.find('\n', cur_line_start)
        if cur_line_end == -1:
            cur_line_end = len(text) - 1

        if offset <= cur_line_end:
            break

        cur_line_no += 1
        cur_line_start = cur_line_end + 1

    return cur_line_no, 1 + offset - cur_line_start