import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults } from './../../../../wayfinder'
/**
* @see \App\Http\Controllers\Admin\AdminDebugController::revert
* @see app/Http/Controllers/Admin/AdminDebugController.php:168
* @route '/admin/debug/usuarios/{user}/balance-manual/{transaction}/revertir'
*/
export const revert = (args: { user: number | { id: number }, transaction: number | { id: number } } | [user: number | { id: number }, transaction: number | { id: number } ], options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: revert.url(args, options),
    method: 'post',
})

revert.definition = {
    methods: ["post"],
    url: '/admin/debug/usuarios/{user}/balance-manual/{transaction}/revertir',
} satisfies RouteDefinition<["post"]>

/**
* @see \App\Http\Controllers\Admin\AdminDebugController::revert
* @see app/Http/Controllers/Admin/AdminDebugController.php:168
* @route '/admin/debug/usuarios/{user}/balance-manual/{transaction}/revertir'
*/
revert.url = (args: { user: number | { id: number }, transaction: number | { id: number } } | [user: number | { id: number }, transaction: number | { id: number } ], options?: RouteQueryOptions) => {
    if (Array.isArray(args)) {
        args = {
            user: args[0],
            transaction: args[1],
        }
    }

    args = applyUrlDefaults(args)

    const parsedArgs = {
        user: typeof args.user === 'object'
        ? args.user.id
        : args.user,
        transaction: typeof args.transaction === 'object'
        ? args.transaction.id
        : args.transaction,
    }

    return revert.definition.url
            .replace('{user}', parsedArgs.user.toString())
            .replace('{transaction}', parsedArgs.transaction.toString())
            .replace(/\/+$/, '') + queryParams(options)
}

/**
* @see \App\Http\Controllers\Admin\AdminDebugController::revert
* @see app/Http/Controllers/Admin/AdminDebugController.php:168
* @route '/admin/debug/usuarios/{user}/balance-manual/{transaction}/revertir'
*/
revert.post = (args: { user: number | { id: number }, transaction: number | { id: number } } | [user: number | { id: number }, transaction: number | { id: number } ], options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: revert.url(args, options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Admin\AdminDebugController::revert
* @see app/Http/Controllers/Admin/AdminDebugController.php:168
* @route '/admin/debug/usuarios/{user}/balance-manual/{transaction}/revertir'
*/
const revertForm = (args: { user: number | { id: number }, transaction: number | { id: number } } | [user: number | { id: number }, transaction: number | { id: number } ], options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: revert.url(args, options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Admin\AdminDebugController::revert
* @see app/Http/Controllers/Admin/AdminDebugController.php:168
* @route '/admin/debug/usuarios/{user}/balance-manual/{transaction}/revertir'
*/
revertForm.post = (args: { user: number | { id: number }, transaction: number | { id: number } } | [user: number | { id: number }, transaction: number | { id: number } ], options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: revert.url(args, options),
    method: 'post',
})

revert.form = revertForm

const manualBalance = {
    revert: Object.assign(revert, revert),
}

export default manualBalance