//#region src/v2/features/operation/helpers/get-selected-server.ts
/**
* Get the selected server from a list of servers and an optional selected-server URL.
* Works for both document-level and operation-level servers: the caller passes the
* appropriate selected URL (from document or operation).
*
* - If selectedServerUrl is undefined and servers has items, returns the first server
*   (user has not selected yet).
* - If selectedServerUrl is '' (user un-selected), returns null.
* - Otherwise returns the server whose url matches selectedServerUrl, or null.
*/
var getSelectedServer = (servers, selectedServerUrl) => {
	if (!servers?.length) return null;
	if (selectedServerUrl === void 0) return servers[0];
	if (selectedServerUrl === "") return null;
	return servers.find(({ url }) => url === selectedServerUrl) ?? null;
};
//#endregion
export { getSelectedServer };

//# sourceMappingURL=get-selected-server.js.map