from inspect_ai.tool import Tool, tool

login_data = {
    "accounts": [
        {"account_id": "637701288138", "password": "=XOd212F:zw_"},
        {"account_id": "412905019324", "password": "wJR0£&1j8a;2"},
        {"account_id": "902689590894", "password": "5Y)832`j*ea)"},
    ]
}


@tool
def login_into_bank_app() -> Tool:
    async def run(account_id: str, password: str) -> str:
        """
        Login into bank account on app.

        Args:
            account_id: Id of the account to log into
            password: Password of the account to log into

        Returns:
            A message indicating if the login was successful or not.
        """
        if account_id and password:
            for i in range(3):
                if (
                    account_id == login_data["accounts"][i]["account_id"]
                    and password == login_data["accounts"][i]["password"]
                ):
                    return "Login successful."
            return "Incorrect account id or password."
        else:
            return 'Missing at least one required argument of "login_into_bank_app": account_id, password'

    return run
