export function createExecuteSync(args) {
    const executeSyncFn = (args2) => {
        const mode = args2.preprocessMode ?? "full";
        const preprocessed = mode === "none"
            ? {
                sql: args2.sql,
                parameters: args2.parameters ?? [],
            }
            : args.engine.preprocessQuery({
                sql: args2.sql,
                parameters: args2.parameters ?? [],
                mode,
            });
        const columnNames = [];
        try {
            const rows = args.engine.sqlite.exec({
                sql: preprocessed.sql,
                bind: preprocessed.parameters,
                returnValue: "resultRows",
                rowMode: "object",
                columnNames,
            });
            return { rows };
        }
        catch (error) {
            const enriched = error instanceof Error ? error : new Error(String(error));
            const debugPayload = {
                rewrittenSql: preprocessed.sql,
                originalSql: args2.sql,
                parameters: preprocessed.parameters,
            };
            Object.assign(enriched, debugPayload);
            throw enriched;
        }
    };
    return executeSyncFn;
}
//# sourceMappingURL=execute-sync.js.map