import { jsx as _jsx } from "react/jsx-runtime";
/**
 * @copyright Sister Software
 * @license AGPL-3.0
 * @author Teffen Ellis, et al.
 */
import { Spinner } from "@inkjs/ui";
import { Text } from "ink";
import { createAddressParser, createDiagnosticReport } from "mailwoman";
import { useEffect, useState } from "react";
import zod from "zod";
const ArgumentsSchema = zod.array(zod.string().describe("A formatted postal address"));
export { ArgumentsSchema as args };
const DebugCommand = ({ args }) => {
    const [output, setOutput] = useState();
    const [error, setError] = useState();
    useEffect(() => {
        const parser = createAddressParser();
        parser
            .parse(args[0], { verbose: true })
            .then(createDiagnosticReport)
            .then(setOutput)
            .catch((err) => setError(err.message));
        return;
    }, [args]);
    if (error) {
        return _jsx(Text, { color: "red", children: error });
    }
    if (!output) {
        return _jsx(Spinner, {});
    }
    return _jsx(Text, { children: output });
};
export default DebugCommand;
//# sourceMappingURL=debug.js.map