/** @type {Map<string, Promise<import('stylelint').Rule>>} */
const ruleCache = new Map();

/**
 * Returns a cached Promise for the rule, avoiding async overhead for rules that
 * have already been loaded.
 *
 * @param {string} ruleName
 * @returns {Promise<import('stylelint').Rule>}
 */
function getCachedRule(ruleName) {
	let rule = ruleCache.get(ruleName);

	if (!rule) {
		rule = import(`./${ruleName}/index.mjs`).then((m) => m.default);
		ruleCache.set(ruleName, rule);
	}

	return rule;
}

const ruleNames = [
	'alpha-value-notation',
	'annotation-no-unknown',
	'at-rule-allowed-list',
	'at-rule-descriptor-no-unknown',
	'at-rule-descriptor-value-no-unknown',
	'at-rule-disallowed-list',
	'at-rule-empty-line-before',
	'at-rule-no-deprecated',
	'at-rule-no-unknown',
	'at-rule-no-vendor-prefix',
	'at-rule-prelude-no-invalid',
	'at-rule-property-required-list',
	'block-no-empty',
	'block-no-redundant-nested-style-rules',
	'color-function-alias-notation',
	'color-function-notation',
	'color-hex-alpha',
	'color-hex-length',
	'color-named',
	'color-no-hex',
	'color-no-invalid-hex',
	'comment-empty-line-before',
	'comment-no-empty',
	'comment-pattern',
	'comment-whitespace-inside',
	'comment-word-disallowed-list',
	'container-name-pattern',
	'custom-media-pattern',
	'custom-property-empty-line-before',
	'custom-property-no-missing-var-function',
	'custom-property-pattern',
	'declaration-block-no-duplicate-custom-properties',
	'declaration-block-no-duplicate-properties',
	'declaration-block-no-redundant-longhand-properties',
	'declaration-block-no-shorthand-property-overrides',
	'declaration-block-single-line-max-declarations',
	'declaration-empty-line-before',
	'declaration-no-important',
	'declaration-property-max-values',
	'declaration-property-unit-allowed-list',
	'declaration-property-unit-disallowed-list',
	'declaration-property-value-allowed-list',
	'declaration-property-value-disallowed-list',
	'declaration-property-value-keyword-no-deprecated',
	'declaration-property-value-no-unknown',
	'display-notation',
	'font-family-name-quotes',
	'font-family-no-duplicate-names',
	'font-family-no-missing-generic-family-keyword',
	'font-weight-notation',
	'function-allowed-list',
	'function-calc-no-unspaced-operator',
	'function-disallowed-list',
	'function-linear-gradient-no-nonstandard-direction',
	'function-name-case',
	'function-no-unknown',
	'function-url-no-scheme-relative',
	'function-url-quotes',
	'function-url-scheme-allowed-list',
	'function-url-scheme-disallowed-list',
	'hue-degree-notation',
	'import-notation',
	'keyframe-block-no-duplicate-selectors',
	'keyframe-declaration-no-important',
	'keyframe-selector-notation',
	'keyframes-name-pattern',
	'layer-name-pattern',
	'length-zero-no-unit',
	'lightness-notation',
	'max-nesting-depth',
	'media-feature-name-allowed-list',
	'media-feature-name-disallowed-list',
	'media-feature-name-no-unknown',
	'media-feature-name-no-vendor-prefix',
	'media-feature-name-unit-allowed-list',
	'media-feature-name-value-allowed-list',
	'media-feature-name-value-no-unknown',
	'media-feature-range-notation',
	'media-query-no-invalid',
	'media-type-no-deprecated',
	'named-grid-areas-no-invalid',
	'nesting-selector-no-missing-scoping-root',
	'no-descending-specificity',
	'no-duplicate-at-import-rules',
	'no-duplicate-selectors',
	'no-empty-source',
	'no-invalid-double-slash-comments',
	'no-invalid-position-at-import-rule',
	'no-invalid-position-declaration',
	'no-irregular-whitespace',
	'no-unknown-animations',
	'no-unknown-custom-media',
	'no-unknown-custom-properties',
	'number-max-precision',
	'property-allowed-list',
	'property-disallowed-list',
	'property-layout-mappings',
	'property-no-deprecated',
	'property-no-unknown',
	'property-no-vendor-prefix',
	'relative-selector-nesting-notation',
	'rule-empty-line-before',
	'rule-nesting-at-rule-required-list',
	'rule-selector-property-disallowed-list',
	'selector-anb-no-unmatchable',
	'selector-attribute-name-disallowed-list',
	'selector-attribute-operator-allowed-list',
	'selector-attribute-operator-disallowed-list',
	'selector-attribute-quotes',
	'selector-class-pattern',
	'selector-combinator-allowed-list',
	'selector-combinator-disallowed-list',
	'selector-disallowed-list',
	'selector-id-pattern',
	'selector-max-attribute',
	'selector-max-class',
	'selector-max-combinators',
	'selector-max-compound-selectors',
	'selector-max-id',
	'selector-max-pseudo-class',
	'selector-max-specificity',
	'selector-max-type',
	'selector-max-universal',
	'selector-nested-pattern',
	'selector-no-deprecated',
	'selector-no-invalid',
	'selector-no-qualifying-type',
	'selector-no-vendor-prefix',
	'selector-not-notation',
	'selector-pseudo-class-allowed-list',
	'selector-pseudo-class-disallowed-list',
	'selector-pseudo-class-no-unknown',
	'selector-pseudo-element-allowed-list',
	'selector-pseudo-element-colon-notation',
	'selector-pseudo-element-disallowed-list',
	'selector-pseudo-element-no-unknown',
	'selector-type-case',
	'selector-type-no-unknown',
	'shorthand-property-no-redundant-values',
	'string-no-newline',
	'syntax-string-no-invalid',
	'time-min-milliseconds',
	'unit-allowed-list',
	'unit-disallowed-list',
	'unit-layout-mappings',
	'unit-no-unknown',
	'value-keyword-case',
	'value-keyword-layout-mappings',
	'value-no-vendor-prefix',
];

const rules = /** @type {import('stylelint').PublicApi['rules']} */ ({});

for (const name of ruleNames) {
	Object.defineProperty(rules, name, {
		get() {
			return getCachedRule(name);
		},
		enumerable: true,
		configurable: true,
	});
}

export default rules;
