import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults } from './../../../wayfinder'
/**
* @see \App\Http\Controllers\JobcardController::store
* @see app/Http/Controllers/JobcardController.php:887
* @route '/jobcards/recurring'
*/
export const store = (options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: store.url(options),
    method: 'post',
})

store.definition = {
    methods: ["post"],
    url: '/jobcards/recurring',
} satisfies RouteDefinition<["post"]>

/**
* @see \App\Http\Controllers\JobcardController::store
* @see app/Http/Controllers/JobcardController.php:887
* @route '/jobcards/recurring'
*/
store.url = (options?: RouteQueryOptions) => {
    return store.definition.url + queryParams(options)
}

/**
* @see \App\Http\Controllers\JobcardController::store
* @see app/Http/Controllers/JobcardController.php:887
* @route '/jobcards/recurring'
*/
store.post = (options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: store.url(options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\JobcardController::store
* @see app/Http/Controllers/JobcardController.php:887
* @route '/jobcards/recurring'
*/
const storeForm = (options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: store.url(options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\JobcardController::store
* @see app/Http/Controllers/JobcardController.php:887
* @route '/jobcards/recurring'
*/
storeForm.post = (options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: store.url(options),
    method: 'post',
})

store.form = storeForm

/**
* @see \App\Http\Controllers\JobcardController::destroy
* @see app/Http/Controllers/JobcardController.php:917
* @route '/jobcards/recurring/{recurringDocument}'
*/
export const destroy = (args: { recurringDocument: string | number } | [recurringDocument: string | number ] | string | number, options?: RouteQueryOptions): RouteDefinition<'delete'> => ({
    url: destroy.url(args, options),
    method: 'delete',
})

destroy.definition = {
    methods: ["delete"],
    url: '/jobcards/recurring/{recurringDocument}',
} satisfies RouteDefinition<["delete"]>

/**
* @see \App\Http\Controllers\JobcardController::destroy
* @see app/Http/Controllers/JobcardController.php:917
* @route '/jobcards/recurring/{recurringDocument}'
*/
destroy.url = (args: { recurringDocument: string | number } | [recurringDocument: string | number ] | string | number, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { recurringDocument: args }
    }

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

    args = applyUrlDefaults(args)

    const parsedArgs = {
        recurringDocument: args.recurringDocument,
    }

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

/**
* @see \App\Http\Controllers\JobcardController::destroy
* @see app/Http/Controllers/JobcardController.php:917
* @route '/jobcards/recurring/{recurringDocument}'
*/
destroy.delete = (args: { recurringDocument: string | number } | [recurringDocument: string | number ] | string | number, options?: RouteQueryOptions): RouteDefinition<'delete'> => ({
    url: destroy.url(args, options),
    method: 'delete',
})

/**
* @see \App\Http\Controllers\JobcardController::destroy
* @see app/Http/Controllers/JobcardController.php:917
* @route '/jobcards/recurring/{recurringDocument}'
*/
const destroyForm = (args: { recurringDocument: string | number } | [recurringDocument: string | number ] | string | number, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: destroy.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'DELETE',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'post',
})

/**
* @see \App\Http\Controllers\JobcardController::destroy
* @see app/Http/Controllers/JobcardController.php:917
* @route '/jobcards/recurring/{recurringDocument}'
*/
destroyForm.delete = (args: { recurringDocument: string | number } | [recurringDocument: string | number ] | string | number, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: destroy.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'DELETE',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'post',
})

destroy.form = destroyForm

const recurring = {
    store: Object.assign(store, store),
    destroy: Object.assign(destroy, destroy),
}

export default recurring