import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults } from './../../../wayfinder'
/**
* @see \App\Http\Controllers\RegisteredUsersController::index
* @see app/Http/Controllers/RegisteredUsersController.php:61
* @route '/registered-users/registered'
*/
export const index = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: index.url(options),
    method: 'get',
})

index.definition = {
    methods: ["get","head"],
    url: '/registered-users/registered',
} satisfies RouteDefinition<["get","head"]>

/**
* @see \App\Http\Controllers\RegisteredUsersController::index
* @see app/Http/Controllers/RegisteredUsersController.php:61
* @route '/registered-users/registered'
*/
index.url = (options?: RouteQueryOptions) => {
    return index.definition.url + queryParams(options)
}

/**
* @see \App\Http\Controllers\RegisteredUsersController::index
* @see app/Http/Controllers/RegisteredUsersController.php:61
* @route '/registered-users/registered'
*/
index.get = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: index.url(options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\RegisteredUsersController::index
* @see app/Http/Controllers/RegisteredUsersController.php:61
* @route '/registered-users/registered'
*/
index.head = (options?: RouteQueryOptions): RouteDefinition<'head'> => ({
    url: index.url(options),
    method: 'head',
})

/**
* @see \App\Http\Controllers\RegisteredUsersController::index
* @see app/Http/Controllers/RegisteredUsersController.php:61
* @route '/registered-users/registered'
*/
const indexForm = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: index.url(options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\RegisteredUsersController::index
* @see app/Http/Controllers/RegisteredUsersController.php:61
* @route '/registered-users/registered'
*/
indexForm.get = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: index.url(options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\RegisteredUsersController::index
* @see app/Http/Controllers/RegisteredUsersController.php:61
* @route '/registered-users/registered'
*/
indexForm.head = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: index.url({
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'HEAD',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'get',
})

index.form = indexForm

/**
* @see \App\Http\Controllers\RegisteredUsersController::show
* @see app/Http/Controllers/RegisteredUsersController.php:116
* @route '/registered-users/registered/{user}'
*/
export const show = (args: { user: string | number | { id: string | number } } | [user: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: show.url(args, options),
    method: 'get',
})

show.definition = {
    methods: ["get","head"],
    url: '/registered-users/registered/{user}',
} satisfies RouteDefinition<["get","head"]>

/**
* @see \App\Http\Controllers\RegisteredUsersController::show
* @see app/Http/Controllers/RegisteredUsersController.php:116
* @route '/registered-users/registered/{user}'
*/
show.url = (args: { user: string | number | { id: string | number } } | [user: string | number | { id: string | number } ] | string | number | { id: string | 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 show.definition.url
            .replace('{user}', parsedArgs.user.toString())
            .replace(/\/+$/, '') + queryParams(options)
}

/**
* @see \App\Http\Controllers\RegisteredUsersController::show
* @see app/Http/Controllers/RegisteredUsersController.php:116
* @route '/registered-users/registered/{user}'
*/
show.get = (args: { user: string | number | { id: string | number } } | [user: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: show.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\RegisteredUsersController::show
* @see app/Http/Controllers/RegisteredUsersController.php:116
* @route '/registered-users/registered/{user}'
*/
show.head = (args: { user: string | number | { id: string | number } } | [user: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'head'> => ({
    url: show.url(args, options),
    method: 'head',
})

/**
* @see \App\Http\Controllers\RegisteredUsersController::show
* @see app/Http/Controllers/RegisteredUsersController.php:116
* @route '/registered-users/registered/{user}'
*/
const showForm = (args: { user: string | number | { id: string | number } } | [user: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: show.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\RegisteredUsersController::show
* @see app/Http/Controllers/RegisteredUsersController.php:116
* @route '/registered-users/registered/{user}'
*/
showForm.get = (args: { user: string | number | { id: string | number } } | [user: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: show.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\RegisteredUsersController::show
* @see app/Http/Controllers/RegisteredUsersController.php:116
* @route '/registered-users/registered/{user}'
*/
showForm.head = (args: { user: string | number | { id: string | number } } | [user: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: show.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'HEAD',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'get',
})

show.form = showForm

const registered = {
    index: Object.assign(index, index),
    show: Object.assign(show, show),
}

export default registered