const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
let zod_v3 = require("zod/v3");
zod_v3 = require_rolldown_runtime.__toESM(zod_v3);
let __intlayer_docs = require("@intlayer/docs");

//#region src/tools/docs.ts
const loadDocsTools = async (server) => {
	const docsKeys = (0, __intlayer_docs.getDocsKeys)();
	server.tool("get-doc-list", "Get the list of docs names and their metadata to get more details about what doc to retrieve", {}, async () => {
		try {
			const docsMetadataRecord = await (0, __intlayer_docs.getDocMetadataRecord)();
			return { content: [{
				type: "text",
				text: JSON.stringify(docsMetadataRecord, null, 2)
			}] };
		} catch (error) {
			return { content: [{
				type: "text",
				text: `Get doc list failed: ${error instanceof Error ? error.message : "An unknown error occurred"}`
			}] };
		}
	});
	server.tool("get-doc", "Get a doc by his key. Example: `./docs/en/getting-started.md`. List all docs metadata first to get more details about what doc key to retrieve.", { docKey: zod_v3.default.enum(docsKeys) }, async ({ docKey }) => {
		try {
			return { content: [{
				type: "text",
				text: await (0, __intlayer_docs.getDoc)(docKey)
			}] };
		} catch (error) {
			return { content: [{
				type: "text",
				text: `Get doc failed: ${error instanceof Error ? error.message : "An unknown error occurred"}`
			}] };
		}
	});
	server.tool("get-doc-by-slug", "Get an array of docs by their slugs. If not slug is provided, return all docs (1.2Mb). List all docs metadata first to get more details about what doc to retrieve.", {
		slug: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.array(zod_v3.default.string())]).optional().describe("Slug of the docs. If not provided, return all docs. If not provided, return all docs."),
		strict: zod_v3.default.boolean().optional().describe("Strict mode - only return docs that match all slugs, by excluding additional slugs"),
		description: "Get an array of docs by their slugs"
	}, async ({ slug, strict }) => {
		try {
			return { content: (await (0, __intlayer_docs.getDocBySlug)(slug, void 0, strict)).map((d) => ({
				type: "text",
				text: d
			})) };
		} catch (error) {
			return { content: [{
				type: "text",
				text: `Get doc by slug failed: ${error instanceof Error ? error.message : "An unknown error occurred"}`
			}] };
		}
	});
};

//#endregion
exports.loadDocsTools = loadDocsTools;
//# sourceMappingURL=docs.cjs.map