<script module lang="ts">
	const imgs = import.meta.glob(
		"./imgs/*.{avif,AVIF,heif,HEIF,jpeg,JPEG,jpg,JPG,png,PNG,tiff,TIFF,webp,WEBP,svg,SVG}",
		{
			eager: true,
			import: "default",
			query: {
				enhanced: true,
				w: "35",
				h: "35",
			},
		},
	);
	let trimmedImgs: Record<string, unknown> = {};
	Object.entries(imgs).forEach(([key, value]) => {
		let trimmedString = key.replace("./imgs/", "");
		let trimmedString2 = trimmedString.replace(/(.*)\.[^.]+$/, "$1");
		trimmedImgs[trimmedString2] = value;
	});
	function getTagImg(name: string): any {
		if (trimmedImgs[name]) {
			return trimmedImgs[name];
		} else {
			return trimmedImgs["unknown"];
		}
	}
	export { tagImg };
</script>

{#snippet tagImg(name: string)}
	<enhanced:img src={getTagImg(name)} width="35" height="35" />
{/snippet}
