const require_chunk = require('./chunk-CNVrAnJR.cjs');
const require_plugin = require('./plugin-CM1TSv1B.cjs');
const require_persistence = require('./persistence-D_clXRxP.cjs');
const require_load = require('./load-DPB0maqs.cjs');
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
let __alloy_js_core = require("@alloy-js/core");

//#region src/helpers/create-reflection-resource.ts
const __ΩRecord = [
	"K",
	"T",
	"Record",
	"l'e#\"Rb!b\"Pde\"!N#!w#y"
];
function __assignType(fn, args) {
	fn.__type = args;
	return fn;
}
/**
* Creates a reflection resource for the environment configuration.
*
* @param context - The environment plugin context.
* @returns A resource that provides the reflection of the environment configuration.
*/
function createReflectionResource(context) {
	const defaultValue = (0, __alloy_js_core.computed)(() => context && require_load.loadEnvFromContext(context, process.env));
	return __alloy_js_core.createResource.Ω = [[
		() => __ΩRecord,
		() => __powerlines_deepkit_vendor_type.ReflectionClass,
		"P&\"o!#7\""
	]], (0, __alloy_js_core.createResource)(async () => {
		if (!context) return new __powerlines_deepkit_vendor_type.ReflectionClass({
			kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
			description: `The initial environment configuration state for the Powerlines project.`,
			types: []
		});
		const result = await require_persistence.readEnvTypeReflection(context, "env");
		result.getProperties().forEach(__assignType((prop) => {
			prop.getAlias().filter(Boolean).forEach(__assignType((alias) => {
				result.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!\"/\""
		]));
		result.getProperties().forEach(__assignType((prop) => {
			prop.setDefaultValue(defaultValue.value?.[prop.getNameAsString()] ?? prop.getAlias().reduce(__assignType((ret, alias) => ret ?? defaultValue.value?.[alias], [
				"ret",
				"alias",
				"",
				"P\"2!\"2\"\"/#"
			]), void 0) ?? prop.getDefaultValue());
		}, [
			"prop",
			"",
			"P\"2!\"/\""
		]));
		return result;
	});
}
createReflectionResource.__type = [
	() => require_plugin.__ΩEnvPluginContext,
	"context",
	"createReflectionResource",
	"Creates a reflection resource for the environment configuration.",
	"Pn!2\"8\"/#?$"
];

//#endregion
Object.defineProperty(exports, 'createReflectionResource', {
  enumerable: true,
  get: function () {
    return createReflectionResource;
  }
});