"use client";
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import * as React from 'react';
import { jsx, jsxs } from 'react/jsx-runtime';

// lib/utils.ts
function cn(...inputs) {
  return twMerge(clsx(inputs));
}
var svgCache = /* @__PURE__ */ new Map();
function DynamicIcon({
  name,
  size = 28,
  color,
  className,
  alt
}) {
  const [svgContent, setSvgContent] = React.useState(null);
  const [isLoading, setIsLoading] = React.useState(true);
  const [error, setError] = React.useState(null);
  const { url, iconName } = React.useMemo(() => {
    const separator = name.includes("/") ? "/" : ":";
    const [prefix, iconName2] = name.split(separator);
    const baseUrl = `https://icons.opensite.ai/api/icon/${prefix}/${iconName2}?format=svg&width=${size}&height=${size}`;
    return {
      url: baseUrl,
      iconName: iconName2
    };
  }, [name, size]);
  React.useEffect(() => {
    let isMounted = true;
    const fetchSvg = async () => {
      const cached = svgCache.get(url);
      if (cached) {
        if (isMounted) {
          setSvgContent(cached);
          setIsLoading(false);
        }
        return;
      }
      try {
        setIsLoading(true);
        setError(null);
        const response = await fetch(url);
        if (!response.ok) {
          throw new Error(`Failed to fetch icon: ${response.status}`);
        }
        let svg = await response.text();
        svg = processSvgForCurrentColor(svg);
        svgCache.set(url, svg);
        if (isMounted) {
          setSvgContent(svg);
          setIsLoading(false);
        }
      } catch (err) {
        if (isMounted) {
          setError(err instanceof Error ? err.message : "Failed to load icon");
          setIsLoading(false);
        }
      }
    };
    fetchSvg();
    return () => {
      isMounted = false;
    };
  }, [url]);
  if (isLoading) {
    return /* @__PURE__ */ jsx(
      "span",
      {
        className: cn("inline-block", className),
        style: { width: size, height: size },
        "aria-hidden": "true"
      }
    );
  }
  if (error || !svgContent) {
    return /* @__PURE__ */ jsx(
      "span",
      {
        className: cn("inline-block", className),
        style: { width: size, height: size },
        role: "img",
        "aria-label": alt || iconName
      }
    );
  }
  return /* @__PURE__ */ jsx(
    "span",
    {
      className: cn("inline-flex items-center justify-center", className),
      style: {
        width: size,
        height: size,
        color: color || "inherit"
      },
      role: "img",
      "aria-label": alt || iconName,
      dangerouslySetInnerHTML: { __html: svgContent }
    }
  );
}
function processSvgForCurrentColor(svg) {
  let processed = svg;
  processed = processed.replace(
    /stroke=["'](#000000|#000|black)["']/gi,
    'stroke="currentColor"'
  );
  processed = processed.replace(
    /fill=["'](#000000|#000|black)["']/gi,
    'fill="currentColor"'
  );
  return processed;
}
var defaultStats = [
  {
    icon: "lucide/users",
    value: "10M+",
    label: "Active Users",
    description: "Developers and teams using our platform daily"
  },
  {
    icon: "lucide/globe",
    value: "150+",
    label: "Countries",
    description: "Global reach across every continent"
  },
  {
    icon: "lucide/code",
    value: "1B+",
    label: "Lines of Code",
    description: "Generated through our platform"
  },
  {
    icon: "lucide/star",
    value: "4.9/5",
    label: "Rating",
    description: "Average customer satisfaction score"
  }
];
var defaultFeatures = [
  {
    icon: "lucide/rocket",
    title: "Fast Deployment",
    description: "Deploy your applications in seconds, not hours."
  },
  {
    icon: "lucide/shield-check",
    title: "Enterprise Security",
    description: "SOC 2 compliant with end-to-end encryption."
  },
  {
    icon: "lucide/headphones",
    title: "24/7 Support",
    description: "Our team is always here to help you succeed."
  }
];
var defaultProps = {
  title: "Why Choose Us",
  description: "We've built a platform that scales with your needs, from startup to enterprise. Here's what sets us apart.",
  stats: defaultStats,
  features: defaultFeatures
};
function AboutStatsSidebar({
  className,
  title = defaultProps.title,
  description = defaultProps.description,
  stats = defaultProps.stats,
  features = defaultProps.features
}) {
  return /* @__PURE__ */ jsx("section", { className: cn("py-32", className), children: /* @__PURE__ */ jsx("div", { className: "container", children: /* @__PURE__ */ jsxs("div", { className: "grid gap-12 lg:grid-cols-3", children: [
    /* @__PURE__ */ jsxs("div", { className: "lg:sticky lg:top-24 lg:self-start", children: [
      /* @__PURE__ */ jsx("h2", { className: "text-3xl font-bold tracking-tight md:text-4xl", children: title }),
      /* @__PURE__ */ jsx("p", { className: "mt-4 text-lg text-muted-foreground", children: description })
    ] }),
    /* @__PURE__ */ jsxs("div", { className: "lg:col-span-2", children: [
      stats && stats.length > 0 && /* @__PURE__ */ jsx("div", { className: "grid gap-6 sm:grid-cols-2", children: stats.map((stat, idx) => /* @__PURE__ */ jsxs(
        "div",
        {
          className: "rounded-xl border bg-card p-6",
          children: [
            stat.icon && /* @__PURE__ */ jsx(
              DynamicIcon,
              {
                name: stat.icon,
                size: 24,
                className: "text-primary"
              }
            ),
            /* @__PURE__ */ jsx("p", { className: "mt-4 text-4xl font-bold", children: stat.value }),
            /* @__PURE__ */ jsx("p", { className: "mt-1 font-semibold", children: stat.label }),
            stat.description && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: stat.description })
          ]
        },
        idx
      )) }),
      features && features.length > 0 && /* @__PURE__ */ jsx("div", { className: "mt-12 space-y-6", children: features.map((feature, idx) => /* @__PURE__ */ jsxs("div", { className: "flex gap-4", children: [
        /* @__PURE__ */ jsx("div", { className: "flex h-12 w-12 shrink-0 items-center justify-center rounded-lg bg-primary/10", children: /* @__PURE__ */ jsx(
          DynamicIcon,
          {
            name: feature.icon,
            size: 24,
            className: "text-primary"
          }
        ) }),
        /* @__PURE__ */ jsxs("div", { children: [
          /* @__PURE__ */ jsx("h3", { className: "font-semibold", children: feature.title }),
          /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: feature.description })
        ] })
      ] }, idx)) })
    ] })
  ] }) }) });
}

export { AboutStatsSidebar };
//# sourceMappingURL=about-stats-sidebar.js.map
//# sourceMappingURL=about-stats-sidebar.js.map