import {lazy, Suspense} from 'react';

import type {SkillEffectPreviewProps} from './SkillEffectPreview';

const SkillEffectPreview = lazy(async () => {
  const module = await import('./SkillEffectPreview');

  return {
    default: module.SkillEffectPreview,
  };
});

function SkillEffectPreviewFallback() {
  return (
    <div className="rounded-2xl border border-white/10 bg-black/20 p-4">
      <div className="mb-3 space-y-2">
        <div className="h-4 w-28 rounded bg-white/10" />
        <div className="h-3 w-40 rounded bg-white/5" />
      </div>
      <div className="overflow-hidden rounded-2xl border border-white/10 bg-black">
        <div className="h-[300px] animate-pulse bg-[radial-gradient(circle_at_top,rgba(255,255,255,0.08),transparent_42%),linear-gradient(180deg,rgba(255,255,255,0.05),rgba(255,255,255,0.02))]" />
      </div>
    </div>
  );
}

export function LazySkillEffectPreview(props: SkillEffectPreviewProps) {
  return (
    <Suspense fallback={<SkillEffectPreviewFallback />}>
      <SkillEffectPreview {...props} />
    </Suspense>
  );
}
