import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults } from './../../../../wayfinder'
/**
* @see \App\Http\Controllers\InvestmentTransactionsController::index
* @see app/Http/Controllers/InvestmentTransactionsController.php:17
* @route '/mis-inversiones/{investment}/movimientos'
*/
export const index = (args: { investment: number | { id: number } } | [investment: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: index.url(args, options),
    method: 'get',
})

index.definition = {
    methods: ["get","head"],
    url: '/mis-inversiones/{investment}/movimientos',
} satisfies RouteDefinition<["get","head"]>

/**
* @see \App\Http\Controllers\InvestmentTransactionsController::index
* @see app/Http/Controllers/InvestmentTransactionsController.php:17
* @route '/mis-inversiones/{investment}/movimientos'
*/
index.url = (args: { investment: number | { id: number } } | [investment: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { investment: args }
    }

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

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

    args = applyUrlDefaults(args)

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

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

/**
* @see \App\Http\Controllers\InvestmentTransactionsController::index
* @see app/Http/Controllers/InvestmentTransactionsController.php:17
* @route '/mis-inversiones/{investment}/movimientos'
*/
index.get = (args: { investment: number | { id: number } } | [investment: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: index.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\InvestmentTransactionsController::index
* @see app/Http/Controllers/InvestmentTransactionsController.php:17
* @route '/mis-inversiones/{investment}/movimientos'
*/
index.head = (args: { investment: number | { id: number } } | [investment: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteDefinition<'head'> => ({
    url: index.url(args, options),
    method: 'head',
})

/**
* @see \App\Http\Controllers\InvestmentTransactionsController::index
* @see app/Http/Controllers/InvestmentTransactionsController.php:17
* @route '/mis-inversiones/{investment}/movimientos'
*/
const indexForm = (args: { investment: number | { id: number } } | [investment: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: index.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\InvestmentTransactionsController::index
* @see app/Http/Controllers/InvestmentTransactionsController.php:17
* @route '/mis-inversiones/{investment}/movimientos'
*/
indexForm.get = (args: { investment: number | { id: number } } | [investment: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: index.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\InvestmentTransactionsController::index
* @see app/Http/Controllers/InvestmentTransactionsController.php:17
* @route '/mis-inversiones/{investment}/movimientos'
*/
indexForm.head = (args: { investment: number | { id: number } } | [investment: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: index.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'HEAD',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'get',
})

index.form = indexForm

const InvestmentTransactionsController = { index }

export default InvestmentTransactionsController