import logging
import secrets

import dash_bootstrap_components as dbc
from dash import html
from dash_extensions.enrich import DashProxy, MultiplexerTransform
import flask
from map_page import layout

logger = logging.getLogger(__name__)

# We just use a simple secret key for the moment

SECRET_KEY = secrets.token_hex(24)


def init_app():
    app = DashProxy(
        __name__,
        server=flask.Flask(__name__),
        suppress_callback_exceptions=True,
        external_stylesheets=[
            dbc.themes.BOOTSTRAP,
            dbc.icons.FONT_AWESOME,
            "https://fonts.googleapis.com/css?family=Comfortaa",
        ],
        transforms=[MultiplexerTransform()]
    )

    server = app.server

    # Set app config
    server.config.update(
        SECRET_KEY=SECRET_KEY,
    )

    app.title = "Hestia X Stonewater"

    # Define the layout
    app.layout = layout()
    app._favicon = "favico.ico"

    return app


app = init_app()
