import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults } from './../../../../../wayfinder'
/**
* @see \App\Http\Controllers\Admin\PlaygroundController::show
* @see app/Http/Controllers/Admin/PlaygroundController.php:19
* @route '/app/agents/{agent}/playground'
*/
export const show = (args: { agent: string | number | { id: string | number } } | [agent: 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: '/app/agents/{agent}/playground',
} satisfies RouteDefinition<["get","head"]>

/**
* @see \App\Http\Controllers\Admin\PlaygroundController::show
* @see app/Http/Controllers/Admin/PlaygroundController.php:19
* @route '/app/agents/{agent}/playground'
*/
show.url = (args: { agent: string | number | { id: string | number } } | [agent: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { agent: args }
    }

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

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

    args = applyUrlDefaults(args)

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

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

/**
* @see \App\Http\Controllers\Admin\PlaygroundController::show
* @see app/Http/Controllers/Admin/PlaygroundController.php:19
* @route '/app/agents/{agent}/playground'
*/
show.get = (args: { agent: string | number | { id: string | number } } | [agent: 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\Admin\PlaygroundController::show
* @see app/Http/Controllers/Admin/PlaygroundController.php:19
* @route '/app/agents/{agent}/playground'
*/
show.head = (args: { agent: string | number | { id: string | number } } | [agent: 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\Admin\PlaygroundController::show
* @see app/Http/Controllers/Admin/PlaygroundController.php:19
* @route '/app/agents/{agent}/playground'
*/
const showForm = (args: { agent: string | number | { id: string | number } } | [agent: 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\Admin\PlaygroundController::show
* @see app/Http/Controllers/Admin/PlaygroundController.php:19
* @route '/app/agents/{agent}/playground'
*/
showForm.get = (args: { agent: string | number | { id: string | number } } | [agent: 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\Admin\PlaygroundController::show
* @see app/Http/Controllers/Admin/PlaygroundController.php:19
* @route '/app/agents/{agent}/playground'
*/
showForm.head = (args: { agent: string | number | { id: string | number } } | [agent: 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\Admin\PlaygroundController::send
* @see app/Http/Controllers/Admin/PlaygroundController.php:57
* @route '/app/agents/{agent}/playground'
*/
export const send = (args: { agent: string | number | { id: string | number } } | [agent: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: send.url(args, options),
    method: 'post',
})

send.definition = {
    methods: ["post"],
    url: '/app/agents/{agent}/playground',
} satisfies RouteDefinition<["post"]>

/**
* @see \App\Http\Controllers\Admin\PlaygroundController::send
* @see app/Http/Controllers/Admin/PlaygroundController.php:57
* @route '/app/agents/{agent}/playground'
*/
send.url = (args: { agent: string | number | { id: string | number } } | [agent: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { agent: args }
    }

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

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

    args = applyUrlDefaults(args)

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

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

/**
* @see \App\Http\Controllers\Admin\PlaygroundController::send
* @see app/Http/Controllers/Admin/PlaygroundController.php:57
* @route '/app/agents/{agent}/playground'
*/
send.post = (args: { agent: string | number | { id: string | number } } | [agent: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: send.url(args, options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Admin\PlaygroundController::send
* @see app/Http/Controllers/Admin/PlaygroundController.php:57
* @route '/app/agents/{agent}/playground'
*/
const sendForm = (args: { agent: string | number | { id: string | number } } | [agent: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: send.url(args, options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Admin\PlaygroundController::send
* @see app/Http/Controllers/Admin/PlaygroundController.php:57
* @route '/app/agents/{agent}/playground'
*/
sendForm.post = (args: { agent: string | number | { id: string | number } } | [agent: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: send.url(args, options),
    method: 'post',
})

send.form = sendForm

/**
* @see \App\Http\Controllers\Admin\PlaygroundController::reset
* @see app/Http/Controllers/Admin/PlaygroundController.php:101
* @route '/app/agents/{agent}/playground/reset'
*/
export const reset = (args: { agent: string | number | { id: string | number } } | [agent: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: reset.url(args, options),
    method: 'post',
})

reset.definition = {
    methods: ["post"],
    url: '/app/agents/{agent}/playground/reset',
} satisfies RouteDefinition<["post"]>

/**
* @see \App\Http\Controllers\Admin\PlaygroundController::reset
* @see app/Http/Controllers/Admin/PlaygroundController.php:101
* @route '/app/agents/{agent}/playground/reset'
*/
reset.url = (args: { agent: string | number | { id: string | number } } | [agent: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { agent: args }
    }

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

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

    args = applyUrlDefaults(args)

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

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

/**
* @see \App\Http\Controllers\Admin\PlaygroundController::reset
* @see app/Http/Controllers/Admin/PlaygroundController.php:101
* @route '/app/agents/{agent}/playground/reset'
*/
reset.post = (args: { agent: string | number | { id: string | number } } | [agent: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: reset.url(args, options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Admin\PlaygroundController::reset
* @see app/Http/Controllers/Admin/PlaygroundController.php:101
* @route '/app/agents/{agent}/playground/reset'
*/
const resetForm = (args: { agent: string | number | { id: string | number } } | [agent: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: reset.url(args, options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Admin\PlaygroundController::reset
* @see app/Http/Controllers/Admin/PlaygroundController.php:101
* @route '/app/agents/{agent}/playground/reset'
*/
resetForm.post = (args: { agent: string | number | { id: string | number } } | [agent: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: reset.url(args, options),
    method: 'post',
})

reset.form = resetForm

const PlaygroundController = { show, send, reset }

export default PlaygroundController