var UrlGenerator = class {
	constructor(baseUrl) {
		this.baseUrl = baseUrl;
	}
	/**
	* Generate video segment URL
	*/
	generateSegmentUrl(segmentId, renditionId, metadata) {
		const audioRendition = metadata.audioRendition;
		const videoRendition = metadata.videoRendition;
		const rendition = audioRendition ?? videoRendition;
		if (!rendition) {
			console.error("Rendition not found", metadata);
			throw new Error(`Rendition ${renditionId} not found`);
		}
		const template = segmentId === "init" ? metadata.templates.initSegment : metadata.templates.mediaSegment;
		return template.replace("{rendition}", renditionId).replace("{segmentId}", segmentId.toString()).replace("{src}", metadata.src).replace("{trackId}", rendition.trackId?.toString() ?? "");
	}
	/**
	* Generate init segment URL
	*/
	generateInitSegmentUrl(mediaUrl, rendition) {
		return `${this.baseUrl()}/api/v1/transcode/${rendition}/init.m4s?url=${encodeURIComponent(mediaUrl)}`;
	}
	/**
	* Generate manifest URL
	*/
	generateManifestUrl(mediaUrl) {
		return `${this.baseUrl()}/api/v1/transcode/manifest.json?url=${encodeURIComponent(mediaUrl)}`;
	}
	/**
	* Generate track fragment index URL
	*/
	generateTrackFragmentIndexUrl(mediaUrl) {
		const normalizedSrc = mediaUrl.startsWith("/") ? mediaUrl.slice(1) : mediaUrl;
		return `/@ef-track-fragment-index/${normalizedSrc}`;
	}
	/**
	* Generate quality presets URL
	*/
	generatePresetsUrl() {
		return `${this.baseUrl()}/api/v1/transcode/presets`;
	}
};
export { UrlGenerator };
