"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_primordials_object = require('../../primordials/object.js');

//#region src/external-tools/jre/asset-names.ts
/**
* @file Adoptium API platform-arch → asset-query mappings. Adoptium's REST
*   endpoint (`api.adoptium.net/v3/assets/...`) filters available JRE/JDK
*   binaries by:
*
*   - `os`: 'mac' | 'linux' | 'alpine-linux' | 'windows'
*   - `architecture`: 'x64' | 'aarch64' | 'arm' | 'x86'
*   - `image_type`: 'jre' | 'jdk' We carry the full mapping so socket-cli can
*     request the right binary for the user's machine without hardcoding query
*     strings at every callsite. Adoptium does not ship Windows ARM64 builds
*     for all LTS versions; Java 21 is the first major release with full
*     coverage. Callers targeting older majors should fall back to bundling or
*     detect unavailability and surface a clear error.
*/
/**
* Platform-arch string (matches `getPlatformArch` output) → `{ os, architecture
* }` query for Adoptium.
*/
const ADOPTIUM_QUERY_MAP = require_primordials_object.ObjectFreeze({
	__proto__: null,
	"darwin-arm64": require_primordials_object.ObjectFreeze({
		__proto__: null,
		os: "mac",
		architecture: "aarch64"
	}),
	"darwin-x64": require_primordials_object.ObjectFreeze({
		__proto__: null,
		os: "mac",
		architecture: "x64"
	}),
	"linux-arm64": require_primordials_object.ObjectFreeze({
		__proto__: null,
		os: "linux",
		architecture: "aarch64"
	}),
	"linux-arm64-musl": require_primordials_object.ObjectFreeze({
		__proto__: null,
		os: "alpine-linux",
		architecture: "aarch64"
	}),
	"linux-x64": require_primordials_object.ObjectFreeze({
		__proto__: null,
		os: "linux",
		architecture: "x64"
	}),
	"linux-x64-musl": require_primordials_object.ObjectFreeze({
		__proto__: null,
		os: "alpine-linux",
		architecture: "x64"
	}),
	"win-arm64": require_primordials_object.ObjectFreeze({
		__proto__: null,
		os: "windows",
		architecture: "aarch64"
	}),
	"win-x64": require_primordials_object.ObjectFreeze({
		__proto__: null,
		os: "windows",
		architecture: "x64"
	})
});
/**
* Build the `latest-binary` download URL on Adoptium's API. Hitting the URL
* with a normal HTTP GET returns the JRE/JDK archive bytes (`tar.gz` on
* macOS/Linux, `zip` on Windows). The URL is stable for a given `{version,
* releaseType}` combination — Adoptium serves the newest patch release behind
* it.
*
* Returns `undefined` when no Adoptium build exists for the requested
* platform-arch; the caller should surface an installable error rather than
* blindly fetching a 404.
*
* Reference: https://adoptium.net/temurin/releases/?package=jre.
*
* @example
*   ;```typescript
*   const url = getAdoptiumDownloadUrl({
*     version: 21,
*     platformArch: 'darwin-arm64',
*   })
*   // → 'https://api.adoptium.net/v3/binary/latest/21/ga/mac/aarch64/jre/hotspot/normal/eclipse'
*
*   // Hand to downloadAndExtractTool:
*   await downloadAndExtractTool({
*     url: url!,
*     name: 'adoptium-jre-21-darwin-arm64',
*     extractedDir: cacheDir,
*     extractOptions: { strip: 1 },
*   })
*   ```
*/
function getAdoptiumDownloadUrl(opts) {
	const { platformArch, releaseType = "ga", type = "jre", version } = opts;
	const query = ADOPTIUM_QUERY_MAP[platformArch];
	if (!query) return;
	return `https://api.adoptium.net/v3/binary/latest/${version}/${releaseType}/${query.os}/${query.architecture}/${type}/hotspot/normal/eclipse`;
}
/**
* Returns the Adoptium query parameters for a given platform-arch, or
* `undefined` if no Adoptium build exists for that target.
*/
function getAdoptiumQuery(platformArch) {
	return ADOPTIUM_QUERY_MAP[platformArch];
}

//#endregion
exports.ADOPTIUM_QUERY_MAP = ADOPTIUM_QUERY_MAP;
exports.getAdoptiumDownloadUrl = getAdoptiumDownloadUrl;
exports.getAdoptiumQuery = getAdoptiumQuery;