import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults } from './../../wayfinder'
/**
* @see \App\Http\Controllers\LegalDocumentController::show
* @see app/Http/Controllers/LegalDocumentController.php:12
* @route '/documentos-legales/{legalDocument}'
*/
export const show = (args: { legalDocument: string | { key: string } } | [legalDocument: string | { key: string } ] | string | { key: string }, options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: show.url(args, options),
    method: 'get',
})

show.definition = {
    methods: ["get","head"],
    url: '/documentos-legales/{legalDocument}',
} satisfies RouteDefinition<["get","head"]>

/**
* @see \App\Http\Controllers\LegalDocumentController::show
* @see app/Http/Controllers/LegalDocumentController.php:12
* @route '/documentos-legales/{legalDocument}'
*/
show.url = (args: { legalDocument: string | { key: string } } | [legalDocument: string | { key: string } ] | string | { key: string }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { legalDocument: args }
    }

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

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

    args = applyUrlDefaults(args)

    const parsedArgs = {
        legalDocument: typeof args.legalDocument === 'object'
        ? args.legalDocument.key
        : args.legalDocument,
    }

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

/**
* @see \App\Http\Controllers\LegalDocumentController::show
* @see app/Http/Controllers/LegalDocumentController.php:12
* @route '/documentos-legales/{legalDocument}'
*/
show.get = (args: { legalDocument: string | { key: string } } | [legalDocument: string | { key: string } ] | string | { key: string }, options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: show.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\LegalDocumentController::show
* @see app/Http/Controllers/LegalDocumentController.php:12
* @route '/documentos-legales/{legalDocument}'
*/
show.head = (args: { legalDocument: string | { key: string } } | [legalDocument: string | { key: string } ] | string | { key: string }, options?: RouteQueryOptions): RouteDefinition<'head'> => ({
    url: show.url(args, options),
    method: 'head',
})

/**
* @see \App\Http\Controllers\LegalDocumentController::show
* @see app/Http/Controllers/LegalDocumentController.php:12
* @route '/documentos-legales/{legalDocument}'
*/
const showForm = (args: { legalDocument: string | { key: string } } | [legalDocument: string | { key: string } ] | string | { key: string }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: show.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\LegalDocumentController::show
* @see app/Http/Controllers/LegalDocumentController.php:12
* @route '/documentos-legales/{legalDocument}'
*/
showForm.get = (args: { legalDocument: string | { key: string } } | [legalDocument: string | { key: string } ] | string | { key: string }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: show.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\LegalDocumentController::show
* @see app/Http/Controllers/LegalDocumentController.php:12
* @route '/documentos-legales/{legalDocument}'
*/
showForm.head = (args: { legalDocument: string | { key: string } } | [legalDocument: string | { key: string } ] | string | { key: string }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: show.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'HEAD',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'get',
})

show.form = showForm

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

export default legalDocuments