import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults } from './../../../../wayfinder'
/**
* @see \App\Http\Controllers\Admin\AdminUserDirectoryController::preview
* @see app/Http/Controllers/Admin/AdminUserDirectoryController.php:504
* @route '/admin/usuarios/{user}/consolidar-balance/preview'
*/
export const preview = (args: { user: number | { id: number } } | [user: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: preview.url(args, options),
    method: 'get',
})

preview.definition = {
    methods: ["get","head"],
    url: '/admin/usuarios/{user}/consolidar-balance/preview',
} satisfies RouteDefinition<["get","head"]>

/**
* @see \App\Http\Controllers\Admin\AdminUserDirectoryController::preview
* @see app/Http/Controllers/Admin/AdminUserDirectoryController.php:504
* @route '/admin/usuarios/{user}/consolidar-balance/preview'
*/
preview.url = (args: { user: number | { id: number } } | [user: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { user: args }
    }

    if (typeof args === 'object' && !Array.isArray(args) && 'id' in args) {
        args = { user: args.id }
    }

    if (Array.isArray(args)) {
        args = {
            user: args[0],
        }
    }

    args = applyUrlDefaults(args)

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

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

/**
* @see \App\Http\Controllers\Admin\AdminUserDirectoryController::preview
* @see app/Http/Controllers/Admin/AdminUserDirectoryController.php:504
* @route '/admin/usuarios/{user}/consolidar-balance/preview'
*/
preview.get = (args: { user: number | { id: number } } | [user: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: preview.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\Admin\AdminUserDirectoryController::preview
* @see app/Http/Controllers/Admin/AdminUserDirectoryController.php:504
* @route '/admin/usuarios/{user}/consolidar-balance/preview'
*/
preview.head = (args: { user: number | { id: number } } | [user: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteDefinition<'head'> => ({
    url: preview.url(args, options),
    method: 'head',
})

/**
* @see \App\Http\Controllers\Admin\AdminUserDirectoryController::preview
* @see app/Http/Controllers/Admin/AdminUserDirectoryController.php:504
* @route '/admin/usuarios/{user}/consolidar-balance/preview'
*/
const previewForm = (args: { user: number | { id: number } } | [user: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: preview.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\Admin\AdminUserDirectoryController::preview
* @see app/Http/Controllers/Admin/AdminUserDirectoryController.php:504
* @route '/admin/usuarios/{user}/consolidar-balance/preview'
*/
previewForm.get = (args: { user: number | { id: number } } | [user: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: preview.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\Admin\AdminUserDirectoryController::preview
* @see app/Http/Controllers/Admin/AdminUserDirectoryController.php:504
* @route '/admin/usuarios/{user}/consolidar-balance/preview'
*/
previewForm.head = (args: { user: number | { id: number } } | [user: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: preview.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'HEAD',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'get',
})

preview.form = previewForm

const consolidateBalance = {
    preview: Object.assign(preview, preview),
}

export default consolidateBalance