"use strict";
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
  return typeof document === 'undefined'
    ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
    : (document.currentScript && document.currentScript.src) ||
      new URL('main.js', document.baseURI).href;
})();
;
exports.ids = ["225"];
exports.modules = {
"../../node_modules/.pnpm/@yume-chan+adb-server-node-tcp@2.5.2/node_modules/@yume-chan/adb-server-node-tcp/esm/index.js"(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
__webpack_require__.d(__webpack_exports__, {
  AdbServerNodeTcpConnector: () => (AdbServerNodeTcpConnector)
});
/* import */ var net__rspack_import_0 = __webpack_require__("net");
/* import */ var _yume_chan_stream_extra__rspack_import_1 = __webpack_require__("../../node_modules/.pnpm/@yume-chan+stream-extra@2.1.0/node_modules/@yume-chan/stream-extra/esm/push-readable.js");
/* import */ var _yume_chan_stream_extra__rspack_import_2 = __webpack_require__("../../node_modules/.pnpm/@yume-chan+stream-extra@2.1.0/node_modules/@yume-chan/stream-extra/esm/try-close.js");
/* import */ var _yume_chan_stream_extra__rspack_import_3 = __webpack_require__("../../node_modules/.pnpm/@yume-chan+stream-extra@2.1.0/node_modules/@yume-chan/stream-extra/esm/maybe-consumable/writable.js");


function nodeSocketToConnection(socket) {
    socket.setNoDelay(true);
    const closed = new Promise((resolve) => {
        socket.on("close", resolve);
    });
    return {
        readable: new _yume_chan_stream_extra__rspack_import_1/* .PushReadableStream */.F((controller) => {
            // eslint-disable-next-line @typescript-eslint/no-misused-promises
            socket.on("data", async (data) => {
                if (controller.abortSignal.aborted) {
                    return;
                }
                socket.pause();
                await controller.enqueue(data);
                socket.resume();
            });
            socket.on("end", () => {
                (0,_yume_chan_stream_extra__rspack_import_2/* .tryClose */.i)(controller);
            });
        }),
        writable: new _yume_chan_stream_extra__rspack_import_3/* .MaybeConsumableWritableStream */.g({
            write: (chunk) => {
                return new Promise((resolve, reject) => {
                    socket.write(chunk, (err) => {
                        if (err) {
                            reject(err);
                        }
                        else {
                            resolve();
                        }
                    });
                });
            },
        }),
        get closed() {
            return closed;
        },
        close() {
            socket.end();
        },
    };
}
/**
 * An `AdbServerClient.ServerConnector` implementation for Node.js.
 */
class AdbServerNodeTcpConnector {
    spec;
    #listeners = new Map();
    constructor(spec) {
        this.spec = spec;
    }
    async connect({ unref, signal } = { unref: false }) {
        const socket = new net__rspack_import_0.Socket({ signal: signal });
        if (unref) {
            socket.unref();
        }
        socket.connect(this.spec);
        await new Promise((resolve, reject) => {
            socket.once("connect", resolve);
            socket.once("error", reject);
        });
        return nodeSocketToConnection(socket);
    }
    async addReverseTunnel(handler, address) {
        // eslint-disable-next-line @typescript-eslint/no-misused-promises
        const server = new net__rspack_import_0.Server(async (socket) => {
            const connection = nodeSocketToConnection(socket);
            try {
                await handler({
                    service: address,
                    readable: connection.readable,
                    writable: connection.writable,
                    get closed() {
                        return connection.closed;
                    },
                    async close() {
                        await connection.close();
                    },
                });
            }
            catch {
                socket.end();
            }
        });
        if (address) {
            const url = new URL(address);
            if (url.protocol === "tcp:") {
                server.listen(Number.parseInt(url.port, 10), url.hostname);
            }
            else if (url.protocol === "unix:") {
                server.listen(url.pathname);
            }
            else {
                throw new TypeError(`Unsupported protocol ${url.protocol}`);
            }
        }
        else {
            server.listen();
        }
        await new Promise((resolve, reject) => {
            server.on("listening", () => resolve());
            server.on("error", (e) => reject(e));
        });
        if (!address) {
            const info = server.address();
            address = `tcp:${info.port}`;
        }
        this.#listeners.set(address, server);
        return address;
    }
    removeReverseTunnel(address) {
        const server = this.#listeners.get(address);
        if (!server) {
            return;
        }
        server.close();
        this.#listeners.delete(address);
    }
    clearReverseTunnels() {
        for (const server of this.#listeners.values()) {
            server.close();
        }
        this.#listeners.clear();
    }
}
//# sourceMappingURL=index.js.map

},
"../../node_modules/.pnpm/@yume-chan+stream-extra@2.1.0/node_modules/@yume-chan/stream-extra/esm/maybe-consumable/utils.js"(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
__webpack_require__.d(__webpack_exports__, {
  W: () => (tryConsume)
});
/* import */ var _consumable_js__rspack_import_0 = __webpack_require__("../../node_modules/.pnpm/@yume-chan+stream-extra@2.1.0/node_modules/@yume-chan/stream-extra/esm/consumable.js");

function getValue(value) {
    return value instanceof Consumable ? value.value : value;
}
function tryConsume(value, callback) {
    if (value instanceof _consumable_js__rspack_import_0/* .Consumable */.G) {
        return value.tryConsume(callback);
    }
    else {
        return callback(value);
    }
}
//# sourceMappingURL=utils.js.map

},
"../../node_modules/.pnpm/@yume-chan+stream-extra@2.1.0/node_modules/@yume-chan/stream-extra/esm/maybe-consumable/writable.js"(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
__webpack_require__.d(__webpack_exports__, {
  g: () => (MaybeConsumableWritableStream)
});
/* import */ var _consumable_js__rspack_import_1 = __webpack_require__("../../node_modules/.pnpm/@yume-chan+stream-extra@2.1.0/node_modules/@yume-chan/stream-extra/esm/consumable.js");
/* import */ var _stream_js__rspack_import_0 = __webpack_require__("../../node_modules/.pnpm/@yume-chan+stream-extra@2.1.0/node_modules/@yume-chan/stream-extra/esm/stream.js");
/* import */ var _utils_js__rspack_import_2 = __webpack_require__("../../node_modules/.pnpm/@yume-chan+stream-extra@2.1.0/node_modules/@yume-chan/stream-extra/esm/maybe-consumable/utils.js");



class MaybeConsumableWritableStream extends _stream_js__rspack_import_0/* .WritableStream */.ho {
    constructor(sink, strategy) {
        let wrappedStrategy;
        if (strategy) {
            wrappedStrategy = {};
            if ("highWaterMark" in strategy) {
                wrappedStrategy.highWaterMark = strategy.highWaterMark;
            }
            if ("size" in strategy) {
                wrappedStrategy.size = (chunk) => {
                    return strategy.size(chunk instanceof _consumable_js__rspack_import_1/* .Consumable */.G ? chunk.value : chunk);
                };
            }
        }
        super({
            start(controller) {
                return sink.start?.(controller);
            },
            write(chunk, controller) {
                return (0,_utils_js__rspack_import_2/* .tryConsume */.W)(chunk, (chunk) => sink.write?.(chunk, controller));
            },
            abort(reason) {
                return sink.abort?.(reason);
            },
            close() {
                return sink.close?.();
            },
        }, wrappedStrategy);
    }
}
//# sourceMappingURL=writable.js.map

},

};
;