var MockRouter = /** @class */ (function () {
    function MockRouter() {
        this._routes = [];
    }
    Object.defineProperty(MockRouter.prototype, "routes", {
        //     constructor() {
        //         this._routes = [];
        //     }
        get: function () {
            return this._routes;
        },
        enumerable: true,
        configurable: true
    });
    MockRouter.prototype.findRoute = function (request) {
        var candidates = this._routes.filter(function (r) { return 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 
    // }
    MockRouter.prototype.addRoute = function (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: predicate,
            adapter: 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;
    // }
    MockRouter.prototype.clearRoutes = function () {
        this._routes = [];
        return this;
    };
    return MockRouter;
}());
export { MockRouter };
// /**
//  * @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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9jay1yb3V0ZXIuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AaW90aXplL3RhcC90ZXN0aW5nLyIsInNvdXJjZXMiOl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