import type { LoadingDotsProps } from "$/types/LoadingTypes";


export default function CircleShrinkingDots({
	width,
	height,
	className,
	animationDuration = 0.6,
	stroke,
	fill
}: LoadingDotsProps){
	//https://github.com/n3r4zzurr0/svg-spinners/blob/main/svg-smil/6-dots-scale.svg?short_path=17d1946
	const id = crypto.randomUUID().replaceAll("-", "");


	return (
		<svg
			width={width}
			height={height}
			viewBox="0 0 24 24"
			xmlns="http://www.w3.org/2000/svg"
		>
			<circle
				cx="12"
				cy="3"
				r="0"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`firstShrinkingDot_${id}`}
					begin={`0;thirdShrinkingDot_${id}.end-${animationDuration * 4 / 5}s`}
					attributeName="r"
					calcMode="spline"
					dur={animationDuration}
					values="0;2;0"
					keyTimes="0;.2;1"
					keySplines="0,1,0,1;.53,0,.61,.73"
					fill="freeze"
				/>
			</circle>
			<circle
				cx="16.50"
				cy="4.21"
				r="0"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`secondShrinkingDot_${id}`}
					begin={`firstShrinkingDot_${id}.begin+${animationDuration / 6}s`}
					attributeName="r"
					calcMode="spline"
					dur={animationDuration}
					values="0;2;0"
					keyTimes="0;.2;1"
					keySplines="0,1,0,1;.53,0,.61,.73"
					fill="freeze"
				/>
			</circle>
			<circle
				cx="7.50"
				cy="4.21"
				r="0"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`thirdShrinkingDot_${id}`}
					begin={`fifthShrinkingDot_${id}.begin+${animationDuration / 6}s`}
					attributeName="r"
					calcMode="spline"
					dur={animationDuration}
					values="0;2;0"
					keyTimes="0;.2;1"
					keySplines="0,1,0,1;.53,0,.61,.73"
					fill="freeze"
				/>
			</circle>
			<circle
				cx="19.79"
				cy="7.50"
				r="0"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`fourthShrinkingDot_${id}`}
					begin={`secondShrinkingDot_${id}.begin+${animationDuration / 6}s`}
					attributeName="r"
					calcMode="spline"
					dur={animationDuration}
					values="0;2;0"
					keyTimes="0;.2;1"
					keySplines="0,1,0,1;.53,0,.61,.73" fill="freeze"
				/>
			</circle>
			<circle
				cx="4.21"
				cy="7.50"
				r="0"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`fifthShrinkingDot_${id}`}
					begin={`seventhShrinkingDot_${id}.begin+${animationDuration / 6}s`}
					attributeName="r"
					calcMode="spline"
					dur={animationDuration}
					values="0;2;0"
					keyTimes="0;.2;1"
					keySplines="0,1,0,1;.53,0,.61,.73"
					fill="freeze"
				/>
			</circle>
			<circle
				cx="21.00"
				cy="12.00"
				r="0"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`sixthShrinkingDot_${id}`}
					begin={`fourthShrinkingDot_${id}.begin+${animationDuration / 6}s`}
					attributeName="r"
					calcMode="spline"
					dur={animationDuration}
					values="0;2;0"
					keyTimes="0;.2;1"
					keySplines="0,1,0,1;.53,0,.61,.73"
					fill="freeze"
				/>
			</circle>
			<circle
				cx="3.00"
				cy="12.00"
				r="0"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`seventhShrinkingDot_${id}`}
					begin={`ninthShrinkingDot_${id}.begin+${animationDuration / 6}s`}
					attributeName="r"
					calcMode="spline"
					dur={animationDuration}
					values="0;2;0"
					keyTimes="0;.2;1"
					keySplines="0,1,0,1;.53,0,.61,.73"
					fill="freeze"
				/>
			</circle>
			<circle
				cx="19.79"
				cy="16.50"
				r="0"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`eighthShrinkingDot_${id}`}
					begin={`sixthShrinkingDot_${id}.begin+${animationDuration / 6}s`}
					attributeName="r"
					calcMode="spline"
					dur={animationDuration}
					values="0;2;0"
					keyTimes="0;.2;1"
					keySplines="0,1,0,1;.53,0,.61,.73"
					fill="freeze"
				/>
			</circle>
			<circle
				cx="4.21"
				cy="16.50"
				r="0"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`ninthShrinkingDot_${id}`}
					begin={`eleventhShrinkingDot_${id}.begin+${animationDuration / 6}s`}
					attributeName="r"
					calcMode="spline"
					dur={animationDuration}
					values="0;2;0"
					keyTimes="0;.2;1"
					keySplines="0,1,0,1;.53,0,.61,.73"
					fill="freeze"
				/>
			</circle>
			<circle
				cx="16.50"
				cy="19.79"
				r="0"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`tenthShrinkingDot_${id}`}
					begin={`eighthShrinkingDot_${id}.begin+${animationDuration / 6}s`}
					attributeName="r"
					calcMode="spline"
					dur={animationDuration}
					values="0;2;0"
					keyTimes="0;.2;1"
					keySplines="0,1,0,1;.53,0,.61,.73"
					fill="freeze"
				/>
			</circle>
			<circle
				cx="7.50"
				cy="19.79"
				r="0"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`eleventhShrinkingDot_${id}`}
					begin={`twelfthShrinkingDot_${id}.begin+${animationDuration / 6}s`}
					attributeName="r"
					calcMode="spline"
					dur={animationDuration}
					values="0;2;0"
					keyTimes="0;.2;1"
					keySplines="0,1,0,1;.53,0,.61,.73"
					fill="freeze"
				/>
			</circle>
			<circle
				cx="12"
				cy="21"
				r="0"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`twelfthShrinkingDot_${id}`}
					begin={`tenthShrinkingDot_${id}.begin+${animationDuration / 6}s`}
					attributeName="r"
					calcMode="spline"
					dur={animationDuration}
					values="0;2;0"
					keyTimes="0;.2;1"
					keySplines="0,1,0,1;.53,0,.61,.73"
					fill="freeze"
				/>
			</circle>
		</svg>
	);
}
