# Path: clearly/utils/logo.py
# CLEARLY_LOGO = r'''
#         __                __
#   _____/ /__  ____ ______/ /_  __
#  / ___/ / _ \/ __ `/ ___/ / / / /
# / /__/ /  __/ /_/ / /  / / /_/ /
# \___/_/\___/\__,_/_/  /_/\__, /
#                         /____/
# '''
# SYSTEMS_LOGO = dict(
#     client=r'''
#       ___          __ 
#  ____/ (_)__ ___  / /_
# / __/ / / -_) _ \/ __/
# \__/_/_/\__/_//_/\__/ 
# ''',
#     server=r'''
#  ___ ___ _____  _____ ____
# (_-</ -_) __/ |/ / -_) __/
# \__/\__/_/  |___/\__/_/   
# ''',
# )
# def render(system: str) -> str:
# 
# Path: clearly/utils/colors.py
# class Colors:
#     BLUE = color_factory('\033[94m')
#     GREEN = color_factory('\033[92m')
#     YELLOW = color_factory('\033[93m')
#     RED = color_factory('\033[91m')
#     MAGENTA = color_factory('\033[95m')
#     CYAN = color_factory('\033[96m')
#     ORANGE = color_factory('\033[38;5;208m')
# 
#     BOLD = color_factory('\033[1m')
#     DIM = color_factory('\033[2m')
# 
#     BLUE_BOLD, BLUE_DIM = BLUE.mix(BOLD, DIM)
#     GREEN_BOLD, GREEN_DIM = GREEN.mix(BOLD, DIM)
#     YELLOW_BOLD, YELLOW_DIM = YELLOW.mix(BOLD, DIM)
#     RED_BOLD, RED_DIM = RED.mix(BOLD, DIM)
#     MAGENTA_BOLD, MAGENTA_DIM = MAGENTA.mix(BOLD, DIM)
#     CYAN_BOLD, CYAN_DIM = CYAN.mix(BOLD, DIM)
#     ORANGE_BOLD, ORANGE_DIM = ORANGE.mix(BOLD, DIM)


import logging
import click
    import IPython
from typing import Optional
from .utils import logo
from .utils.colors import Colors
    from clearly.server import ClearlyServer
    from clearly.client import ClearlyClient, ModeTask, ModeWorker
    from traitlets.config.loader import Config
    BROKER: The broker being used by celery, like "amqp://localhost".
    """
    _setup_logging(debug)
    logger.info('\n%s\n', logo.render('server'))
    clearly_server = ClearlyServer(broker, backend, max_tasks, max_workers)
    clearly_server.start_server(port, blocking=True)


@clearly.command()
@click.argument('host', type=str, required=False)
@click.argument('port', type=int, required=False)
@click.option('--debug', help='Enables debug info', is_flag=True)
def client(**kwargs):
    """Start a REPL shell, with an already configured Clearly Client `clearlycli`.

    \b
    HOST: The host where Clearly Server is running, default localhost
    PORT: The port where Clearly Server is running, default 12223
    """
    share = dict(
        clearlycli=ClearlyClient(**{k: v for k, v in kwargs.items() if v}),
        ModeTask=ModeTask, ModeWorker=ModeWorker,
    )

    # the first option was bpython, but unfortunately it is broken...
    # https://github.com/bpython/bpython/issues/758
    # from bpython import embed
    # embed(dict(clearlycli=clearlycli))

    c = Config()

# Path: clearly/utils/logo.py
# CLEARLY_LOGO = r'''
#         __                __
#   _____/ /__  ____ ______/ /_  __
#  / ___/ / _ \/ __ `/ ___/ / / / /
# / /__/ /  __/ /_/ / /  / / /_/ /
# \___/_/\___/\__,_/_/  /_/\__, /
#                         /____/
# '''
# SYSTEMS_LOGO = dict(
#     client=r'''
#       ___          __ 
#  ____/ (_)__ ___  / /_
# / __/ / / -_) _ \/ __/
# \__/_/_/\__/_//_/\__/ 
# ''',
#     server=r'''
#  ___ ___ _____  _____ ____
# (_-</ -_) __/ |/ / -_) __/
# \__/\__/_/  |___/\__/_/   
# ''',
# )
# def render(system: str) -> str:
# 
# Path: clearly/utils/colors.py
# class Colors:
#     BLUE = color_factory('\033[94m')
#     GREEN = color_factory('\033[92m')
#     YELLOW = color_factory('\033[93m')
#     RED = color_factory('\033[91m')
#     MAGENTA = color_factory('\033[95m')
#     CYAN = color_factory('\033[96m')
#     ORANGE = color_factory('\033[38;5;208m')
# 
#     BOLD = color_factory('\033[1m')
#     DIM = color_factory('\033[2m')
# 
#     BLUE_BOLD, BLUE_DIM = BLUE.mix(BOLD, DIM)
#     GREEN_BOLD, GREEN_DIM = GREEN.mix(BOLD, DIM)
#     YELLOW_BOLD, YELLOW_DIM = YELLOW.mix(BOLD, DIM)
#     RED_BOLD, RED_DIM = RED.mix(BOLD, DIM)
#     MAGENTA_BOLD, MAGENTA_DIM = MAGENTA.mix(BOLD, DIM)
#     CYAN_BOLD, CYAN_DIM = CYAN.mix(BOLD, DIM)
#     ORANGE_BOLD, ORANGE_DIM = ORANGE.mix(BOLD, DIM)


# Path: clearly/command_line.py
import logging
import click
    import IPython
from typing import Optional
from .utils import logo
from .utils.colors import Colors
    from clearly.server import ClearlyServer
    from clearly.client import ClearlyClient, ModeTask, ModeWorker
    from traitlets.config.loader import Config

    BROKER: The broker being used by celery, like "amqp://localhost".
    """
    _setup_logging(debug)
    logger.info('\n%s\n', logo.render('server'))
    clearly_server = ClearlyServer(broker, backend, max_tasks, max_workers)
    clearly_server.start_server(port, blocking=True)


@clearly.command()
@click.argument('host', type=str, required=False)
@click.argument('port', type=int, required=False)
@click.option('--debug', help='Enables debug info', is_flag=True)
def client(**kwargs):
    """Start a REPL shell, with an already configured Clearly Client `clearlycli`.

    \b
    HOST: The host where Clearly Server is running, default localhost
    PORT: The port where Clearly Server is running, default 12223
    """
    share = dict(
        clearlycli=ClearlyClient(**{k: v for k, v in kwargs.items() if v}),
        ModeTask=ModeTask, ModeWorker=ModeWorker,
    )

    # the first option was bpython, but unfortunately it is broken...
    # https://github.com/bpython/bpython/issues/758
    # from bpython import embed
    # embed(dict(clearlycli=clearlycli))

    c = Config()

    c.TerminalInteractiveShell.banner1 = logo.render('client') + '\n'