import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults } from './../../../../../wayfinder'
/**
* @see \App\Http\Controllers\Admin\PlaygroundStreamController::__invoke
* @see app/Http/Controllers/Admin/PlaygroundStreamController.php:59
* @route '/app/agents/{agent}/playground/stream'
*/
const PlaygroundStreamController = (args: { agent: string | number | { id: string | number } } | [agent: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: PlaygroundStreamController.url(args, options),
    method: 'post',
})

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

/**
* @see \App\Http\Controllers\Admin\PlaygroundStreamController::__invoke
* @see app/Http/Controllers/Admin/PlaygroundStreamController.php:59
* @route '/app/agents/{agent}/playground/stream'
*/
PlaygroundStreamController.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 PlaygroundStreamController.definition.url
            .replace('{agent}', parsedArgs.agent.toString())
            .replace(/\/+$/, '') + queryParams(options)
}

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

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

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

PlaygroundStreamController.form = PlaygroundStreamControllerForm

export default PlaygroundStreamController