const require_base = require("../base.cjs");
//#region src/client/ui-internal/index.ts
var UiClient = class UiClient extends require_base.BaseClient {
	static promiseCache = {};
	static getOrCached(key, fn) {
		if (UiClient.promiseCache[key] != null) return UiClient.promiseCache[key];
		const promise = fn();
		UiClient.promiseCache[key] = promise;
		return promise;
	}
	async getComponent(assistantId, agentName) {
		return UiClient.getOrCached(`${this.apiUrl}-${assistantId}-${agentName}`, async () => {
			let [url, init] = this.prepareFetchOptions(`/ui/${assistantId}`, {
				headers: {
					Accept: "text/html",
					"Content-Type": "application/json"
				},
				method: "POST",
				json: { name: agentName }
			});
			if (this.onRequest != null) init = await this.onRequest(url, init);
			return (await this.asyncCaller.fetch(url.toString(), init)).text();
		});
	}
};
//#endregion
exports.UiClient = UiClient;

//# sourceMappingURL=index.cjs.map