export class MockRouter {
    constructor() {
        this._routes = [];
    }
    //     constructor() {
    //         this._routes = [];
    //     }
    get routes() {
        return this._routes;
    }
    findRoute(request) {
        const candidates = this._routes.filter(r => r.predicate(request));
        if (candidates.length === 0) {
            return undefined;
        }
        else {
            return candidates[0].adapter(request);
        }
    }
    // addRoutes(map: RouteMapping) {
    //     // throw new Error('Method not implemented.');
    //     // TODO 
    // }
    addRoute(predicate, adapter) {
        // var filter: Predicate<Command>;
        // if (typeof left === 'string') {
        //     left = Util.parseApiRequestString(left);
        // }
        // if (left instanceof ApiRequest) {
        //     filter = new EqualRequestFilter(left);
        // } else if (left instanceof RegExp) {
        //     filter = new RegExpFilter(left);
        // } else if (typeof left === 'function') {
        //     filter = {
        //         test: left
        //     };
        // } else {
        //     filter = left as Predicate<Command>;
        // }
        // var adapter: ResponseAdapter<T>;
        // if (right instanceof ResponseImpl) {
        //     adapter = new (class Tmp implements ResponseAdapter<T> {
        //         public adapt(command: Command) {
        //             return right;
        //         }
        //     })();
        // } else if (right instanceof Uint8Array) {
        //     adapter = new (class Tmp implements ResponseAdapter<T> {
        //         public adapt(command: Command) {
        //             return new ResponseImpl<T>(right);
        //         }
        //     })();
        // } else if (typeof right === 'function') {
        //     adapter = {
        //         adapt: right
        //     };
        // } else {
        //     adapter = right as ResponseAdapter<T>;
        // }
        this._routes.push({
            predicate,
            adapter
        });
        return this;
    }
    //     /**
    //      * Mapping a command (represented as a string with format "<request-type> <path> [data]"
    //      * ie: GET /3//3 0xABCD or POST /1024//0 0xtest
    //      *
    //      * TapResponse must either be:
    //      *  - an hexadecimal data represented as a string (0xABCD)
    //      *  - An object with a coreRet and a body
    //      *  - A Uint8Array
    //      */
    // addRoutes(map: { [key: string]: RouteType }): this {
    //     for (const pathString in map) {
    //         const info = map[pathString];
    //         const command: Command = Util.parseApiRequestString(pathString);
    //         let response;
    //         if (info instanceof Uint8Array) {
    //             response = new ResponseImpl(info);
    //         } else if (info instanceof ResponseImpl) {
    //             response = info;
    //         } else if (typeof info === 'number') {
    //             response = ResponseImpl.create(info);
    //         } else if (typeof info === 'string') {
    //             response = new ResponseImpl(
    //                 hexStringToBuffer(info)
    //             );
    //         } else if (typeof info === 'object') {
    //             const codeRet: number = (info as RouteTypeObject).codeRet;
    //             response = new ResponseImpl(
    //                 KaitaiStreamWriter.mergeArrays(
    //                     Uint8Array.from([codeRet]),
    //                     (info as RouteTypeObject).body || new Uint8Array(0)
    //                 )
    //             );
    //         } else {
    //             throw new Error(
    //                 `Invalid response type ${typeof info} with value: ${JSON.stringify(
    //                     info
    //                 )}`
    //             );
    //         }
    //         debug(TAG, `\t- Add map ${command} -> ${response}`);
    //         this.addRoute(command, response);
    //     }
    //     return this;
    // }
    clearRoutes() {
        this._routes = [];
        return this;
    }
}
// /**
//  * @deprecated in favor of {@link #addRoute}
//  */
// public mapResponse<T>(
//     left:
//         | FilterFunction<TapRequestFrame>
//         | Predicate<TapRequestFrame>
//         | TapRequestFrame,
//     right:
//         | ResponseAdapterFunction<T>
//         | ResponseAdapter<T>
//         | TapResponse<T>
//         | Uint8Array
// ): this {
//     return this.addRoute(left, right);
// }
// public addRoute<T>(
//     left:
//         | FilterFunction<TapRequestFrame>
//         | Predicate<TapRequestFrame>
//         | TapRequestFrame,
//     right:
//         | ResponseAdapterFunction<T>
//         | ResponseAdapter<T>
//         | TapResponse<T>
//         | Uint8Array
// ): this {
//     this.router.addRoute(left, right);
//     return this;
// }
// //     public Configuration getConfiguration() {
// //     return configuration;
// // }
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9jay1yb3V0ZXIuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AaW90aXplL3RhcC90ZXN0aW5nLyIsInNvdXJjZXMiOlsibW9jay9tb2NrLXJvdXRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFJQSxNQUFNLE9BQU8sVUFBVTtJQUF2QjtRQUNJLFlBQU8sR0FBcUYsRUFBRSxDQUFD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