from dataclasses import dataclass
from typing import Any

from fasthtml import serve
from fasthtml.components import *

from myfasthtml.controls.helpers import mk
from myfasthtml.core.bindings import Binding
from myfasthtml.core.utils import debug_routes
from myfasthtml.myfastapp import create_app

app, rt = create_app(protect_routes=False)


@dataclass
class Data:
  value: Any = "Hello World"


data = Data()


@rt("/")
def get():
  return Div(
    mk.mk(Textarea(name="input_name"), binding=Binding(data, attr="value").htmx(trigger="input changed")),
    mk.mk(Label("Text"), binding=Binding(data, attr="value"))
  )


if __name__ == "__main__":
  debug_routes(app)
  serve(port=5002)
