import { normalizeApplyPatchArgs } from './args-normalizer/index.js';
import { normalizeApplyPatchText, looksLikePatch } from './patch-text/normalize.js';
export { looksLikePatch, normalizeApplyPatchText };
const toJson = (value) => {
    try {
        return JSON.stringify(value ?? {});
    }
    catch {
        return '{}';
    }
};
export function validateApplyPatchArgs(argsString, rawArgs) {
    const normalized = normalizeApplyPatchArgs(argsString, rawArgs);
    if (normalized.ok === false) {
        return { ok: false, reason: normalized.reason };
    }
    return {
        ok: true,
        normalizedArgs: toJson({ patch: normalized.patchText, input: normalized.patchText })
    };
}
