import { queryParams, type RouteQueryOptions, type RouteDefinition, applyUrlDefaults } from './../../../../wayfinder'
/**
* @see \App\Http\Controllers\LocationController::index
 * @see app/Http/Controllers/LocationController.php:18
 * @route '/locations'
 */
export const index = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: index.url(options),
    method: 'get',
})

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

/**
* @see \App\Http\Controllers\LocationController::index
 * @see app/Http/Controllers/LocationController.php:18
 * @route '/locations'
 */
index.url = (options?: RouteQueryOptions) => {
    return index.definition.url + queryParams(options)
}

/**
* @see \App\Http\Controllers\LocationController::index
 * @see app/Http/Controllers/LocationController.php:18
 * @route '/locations'
 */
index.get = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: index.url(options),
    method: 'get',
})
/**
* @see \App\Http\Controllers\LocationController::index
 * @see app/Http/Controllers/LocationController.php:18
 * @route '/locations'
 */
index.head = (options?: RouteQueryOptions): RouteDefinition<'head'> => ({
    url: index.url(options),
    method: 'head',
})

/**
* @see \App\Http\Controllers\LocationController::storeBranch
 * @see app/Http/Controllers/LocationController.php:38
 * @route '/locations/branches'
 */
export const storeBranch = (options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: storeBranch.url(options),
    method: 'post',
})

storeBranch.definition = {
    methods: ["post"],
    url: '/locations/branches',
} satisfies RouteDefinition<["post"]>

/**
* @see \App\Http\Controllers\LocationController::storeBranch
 * @see app/Http/Controllers/LocationController.php:38
 * @route '/locations/branches'
 */
storeBranch.url = (options?: RouteQueryOptions) => {
    return storeBranch.definition.url + queryParams(options)
}

/**
* @see \App\Http\Controllers\LocationController::storeBranch
 * @see app/Http/Controllers/LocationController.php:38
 * @route '/locations/branches'
 */
storeBranch.post = (options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: storeBranch.url(options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\LocationController::storeWarehouse
 * @see app/Http/Controllers/LocationController.php:62
 * @route '/locations/branches/{branchId}/warehouses'
 */
export const storeWarehouse = (args: { branchId: string | number } | [branchId: string | number ] | string | number, options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: storeWarehouse.url(args, options),
    method: 'post',
})

storeWarehouse.definition = {
    methods: ["post"],
    url: '/locations/branches/{branchId}/warehouses',
} satisfies RouteDefinition<["post"]>

/**
* @see \App\Http\Controllers\LocationController::storeWarehouse
 * @see app/Http/Controllers/LocationController.php:62
 * @route '/locations/branches/{branchId}/warehouses'
 */
storeWarehouse.url = (args: { branchId: string | number } | [branchId: string | number ] | string | number, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { branchId: args }
    }

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

    args = applyUrlDefaults(args)

    const parsedArgs = {
                        branchId: args.branchId,
                }

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

/**
* @see \App\Http\Controllers\LocationController::storeWarehouse
 * @see app/Http/Controllers/LocationController.php:62
 * @route '/locations/branches/{branchId}/warehouses'
 */
storeWarehouse.post = (args: { branchId: string | number } | [branchId: string | number ] | string | number, options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: storeWarehouse.url(args, options),
    method: 'post',
})
const LocationController = { index, storeBranch, storeWarehouse }

export default LocationController