import { html } from "https://esm.town/v/stevekrouse/html?v=5";
import { render } from "npm:preact-render-to-string";
type HandlerFunc = (req?: Request) => Response | Promise<Response>;
export function indieauth(handler: HandlerFunc, params: {
clientID: string;
}): HandlerFunc {
return (req) => {
return html(render(
<form action="https://indielogin.com/auth" method="get">
<label for="url">Web Address:</label>
<input id="url" type="text" name="me" placeholder="yourdomain.com" />
<p>
<button type="submit">Sign In</button>
</p>
<input type="hidden" name="client_id" value={params.clientID} />
<input type="hidden" name="redirect_uri" value={new URL("/redirect", params.clientID).toString()} />
<input type="hidden" name="state" value="jwiusuerujs" />
</form>,
));
};
}