const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
const require_types_plugin = require('../types/plugin.cjs');
const require_helpers_persistence = require('./persistence.cjs');
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");

//#region src/helpers/template-helpers.ts
function __assignType(fn, args) {
	fn.__type = args;
	return fn;
}
/**
* Creates the reflection data used when generating runtime template files.
*
* @param context - The context for the configuration plugin.
* @param name - The name of the configuration template.
* @returns The reflection for the specified configuration template.
*/
async function createTemplateReflection(context, name) {
	const reflection = await require_helpers_persistence.readEnvTypeReflection(context, name);
	reflection.getProperties().forEach(__assignType((prop) => {
		prop.getAlias().filter(Boolean).forEach(__assignType((alias) => {
			reflection.addProperty({
				name: alias,
				optional: prop.isOptional() ? true : void 0,
				readonly: prop.isReadonly() ? true : void 0,
				description: prop.getDescription(),
				visibility: prop.getVisibility(),
				type: prop.getType(),
				default: prop.getDefaultValue(),
				tags: {
					hidden: prop.isHidden(),
					ignore: prop.isIgnored(),
					internal: prop.isInternal(),
					alias: prop.getAlias().filter(__assignType((a) => a !== alias, [
						"a",
						"",
						"P\"2!\"/\""
					])).concat(prop.name),
					title: prop.getTitle() || (0, __stryke_string_format_title_case.titleCase)(prop.name),
					readonly: prop.isReadonly(),
					permission: prop.getPermission(),
					domain: prop.getDomain()
				}
			});
		}, [
			"alias",
			"",
			"P\"2!\"/\""
		]));
	}, [
		"prop",
		"",
		"P\"2!\"/\""
	]));
	return reflection;
}
createTemplateReflection.__type = [
	() => require_types_plugin.__ΩEnvPluginContext,
	"context",
	() => require_types_plugin.__ΩEnvType,
	"name",
	() => __powerlines_deepkit_vendor_type.ReflectionClass,
	"createTemplateReflection",
	"Creates the reflection data used when generating runtime template files.",
	"Pn!2\"n#2$8P\"7%`/&?'"
];

//#endregion
exports.createTemplateReflection = createTemplateReflection;