import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults } from './../../../../../../wayfinder'
/**
* @see \App\Http\Controllers\Api\V1\MessagingController::index
* @see app/Http/Controllers/Api/V1/MessagingController.php:15
* @route '/api/v1/messages/conversations'
*/
export const index = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: index.url(options),
    method: 'get',
})

index.definition = {
    methods: ["get","head"],
    url: '/api/v1/messages/conversations',
} satisfies RouteDefinition<["get","head"]>

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::index
* @see app/Http/Controllers/Api/V1/MessagingController.php:15
* @route '/api/v1/messages/conversations'
*/
index.url = (options?: RouteQueryOptions) => {
    return index.definition.url + queryParams(options)
}

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::index
* @see app/Http/Controllers/Api/V1/MessagingController.php:15
* @route '/api/v1/messages/conversations'
*/
index.get = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: index.url(options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::index
* @see app/Http/Controllers/Api/V1/MessagingController.php:15
* @route '/api/v1/messages/conversations'
*/
index.head = (options?: RouteQueryOptions): RouteDefinition<'head'> => ({
    url: index.url(options),
    method: 'head',
})

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::index
* @see app/Http/Controllers/Api/V1/MessagingController.php:15
* @route '/api/v1/messages/conversations'
*/
const indexForm = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: index.url(options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::index
* @see app/Http/Controllers/Api/V1/MessagingController.php:15
* @route '/api/v1/messages/conversations'
*/
indexForm.get = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: index.url(options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::index
* @see app/Http/Controllers/Api/V1/MessagingController.php:15
* @route '/api/v1/messages/conversations'
*/
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\Api\V1\MessagingController::storeConversation
* @see app/Http/Controllers/Api/V1/MessagingController.php:30
* @route '/api/v1/messages/conversations'
*/
export const storeConversation = (options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: storeConversation.url(options),
    method: 'post',
})

storeConversation.definition = {
    methods: ["post"],
    url: '/api/v1/messages/conversations',
} satisfies RouteDefinition<["post"]>

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::storeConversation
* @see app/Http/Controllers/Api/V1/MessagingController.php:30
* @route '/api/v1/messages/conversations'
*/
storeConversation.url = (options?: RouteQueryOptions) => {
    return storeConversation.definition.url + queryParams(options)
}

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::storeConversation
* @see app/Http/Controllers/Api/V1/MessagingController.php:30
* @route '/api/v1/messages/conversations'
*/
storeConversation.post = (options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: storeConversation.url(options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::storeConversation
* @see app/Http/Controllers/Api/V1/MessagingController.php:30
* @route '/api/v1/messages/conversations'
*/
const storeConversationForm = (options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: storeConversation.url(options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::storeConversation
* @see app/Http/Controllers/Api/V1/MessagingController.php:30
* @route '/api/v1/messages/conversations'
*/
storeConversationForm.post = (options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: storeConversation.url(options),
    method: 'post',
})

storeConversation.form = storeConversationForm

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::show
* @see app/Http/Controllers/Api/V1/MessagingController.php:61
* @route '/api/v1/messages/conversations/{conversation}'
*/
export const show = (args: { conversation: string | number | { id: string | number } } | [conversation: 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: '/api/v1/messages/conversations/{conversation}',
} satisfies RouteDefinition<["get","head"]>

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::show
* @see app/Http/Controllers/Api/V1/MessagingController.php:61
* @route '/api/v1/messages/conversations/{conversation}'
*/
show.url = (args: { conversation: string | number | { id: string | number } } | [conversation: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { conversation: args }
    }

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

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

    args = applyUrlDefaults(args)

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

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

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::show
* @see app/Http/Controllers/Api/V1/MessagingController.php:61
* @route '/api/v1/messages/conversations/{conversation}'
*/
show.get = (args: { conversation: string | number | { id: string | number } } | [conversation: 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\Api\V1\MessagingController::show
* @see app/Http/Controllers/Api/V1/MessagingController.php:61
* @route '/api/v1/messages/conversations/{conversation}'
*/
show.head = (args: { conversation: string | number | { id: string | number } } | [conversation: 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\Api\V1\MessagingController::show
* @see app/Http/Controllers/Api/V1/MessagingController.php:61
* @route '/api/v1/messages/conversations/{conversation}'
*/
const showForm = (args: { conversation: string | number | { id: string | number } } | [conversation: 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\Api\V1\MessagingController::show
* @see app/Http/Controllers/Api/V1/MessagingController.php:61
* @route '/api/v1/messages/conversations/{conversation}'
*/
showForm.get = (args: { conversation: string | number | { id: string | number } } | [conversation: 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\Api\V1\MessagingController::show
* @see app/Http/Controllers/Api/V1/MessagingController.php:61
* @route '/api/v1/messages/conversations/{conversation}'
*/
showForm.head = (args: { conversation: string | number | { id: string | number } } | [conversation: 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

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::storeMessage
* @see app/Http/Controllers/Api/V1/MessagingController.php:70
* @route '/api/v1/messages/conversations/{conversation}/messages'
*/
export const storeMessage = (args: { conversation: string | number | { id: string | number } } | [conversation: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: storeMessage.url(args, options),
    method: 'post',
})

storeMessage.definition = {
    methods: ["post"],
    url: '/api/v1/messages/conversations/{conversation}/messages',
} satisfies RouteDefinition<["post"]>

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::storeMessage
* @see app/Http/Controllers/Api/V1/MessagingController.php:70
* @route '/api/v1/messages/conversations/{conversation}/messages'
*/
storeMessage.url = (args: { conversation: string | number | { id: string | number } } | [conversation: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { conversation: args }
    }

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

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

    args = applyUrlDefaults(args)

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

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

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::storeMessage
* @see app/Http/Controllers/Api/V1/MessagingController.php:70
* @route '/api/v1/messages/conversations/{conversation}/messages'
*/
storeMessage.post = (args: { conversation: string | number | { id: string | number } } | [conversation: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: storeMessage.url(args, options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::storeMessage
* @see app/Http/Controllers/Api/V1/MessagingController.php:70
* @route '/api/v1/messages/conversations/{conversation}/messages'
*/
const storeMessageForm = (args: { conversation: string | number | { id: string | number } } | [conversation: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: storeMessage.url(args, options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::storeMessage
* @see app/Http/Controllers/Api/V1/MessagingController.php:70
* @route '/api/v1/messages/conversations/{conversation}/messages'
*/
storeMessageForm.post = (args: { conversation: string | number | { id: string | number } } | [conversation: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: storeMessage.url(args, options),
    method: 'post',
})

storeMessage.form = storeMessageForm

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::markRead
* @see app/Http/Controllers/Api/V1/MessagingController.php:90
* @route '/api/v1/messages/conversations/{conversation}/read'
*/
export const markRead = (args: { conversation: string | number | { id: string | number } } | [conversation: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'patch'> => ({
    url: markRead.url(args, options),
    method: 'patch',
})

markRead.definition = {
    methods: ["patch"],
    url: '/api/v1/messages/conversations/{conversation}/read',
} satisfies RouteDefinition<["patch"]>

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::markRead
* @see app/Http/Controllers/Api/V1/MessagingController.php:90
* @route '/api/v1/messages/conversations/{conversation}/read'
*/
markRead.url = (args: { conversation: string | number | { id: string | number } } | [conversation: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { conversation: args }
    }

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

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

    args = applyUrlDefaults(args)

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

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

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::markRead
* @see app/Http/Controllers/Api/V1/MessagingController.php:90
* @route '/api/v1/messages/conversations/{conversation}/read'
*/
markRead.patch = (args: { conversation: string | number | { id: string | number } } | [conversation: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'patch'> => ({
    url: markRead.url(args, options),
    method: 'patch',
})

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::markRead
* @see app/Http/Controllers/Api/V1/MessagingController.php:90
* @route '/api/v1/messages/conversations/{conversation}/read'
*/
const markReadForm = (args: { conversation: string | number | { id: string | number } } | [conversation: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: markRead.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'PATCH',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Api\V1\MessagingController::markRead
* @see app/Http/Controllers/Api/V1/MessagingController.php:90
* @route '/api/v1/messages/conversations/{conversation}/read'
*/
markReadForm.patch = (args: { conversation: string | number | { id: string | number } } | [conversation: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: markRead.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'PATCH',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'post',
})

markRead.form = markReadForm

const MessagingController = { index, storeConversation, show, storeMessage, markRead }

export default MessagingController