@algorithm-shift/design-system 1.2.976 → 1.2.977

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -27025,7 +27025,7 @@ var TextInput = ({ className, style, ...props }) => {
27025
27025
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
27026
27026
  Input,
27027
27027
  {
27028
- type: "text",
27028
+ type: props.inputType || "text",
27029
27029
  name: props.name,
27030
27030
  className: cn(className, props.errorMessage ? "border-red-500" : ""),
27031
27031
  style: {
@@ -30908,8 +30908,22 @@ var Tabs_default = Tabs;
30908
30908
  // src/components/Navigation/Stages/Stages.tsx
30909
30909
  var import_react31 = __toESM(require("react"));
30910
30910
  var import_jsx_runtime57 = require("react/jsx-runtime");
30911
- var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey = "key", dataLabel = "header", loading, saving, triggerOnClick = false }) => {
30912
- const [activeStage, setActiveStage] = (0, import_react31.useState)(currentStage || (stages && stages.length > 0 ? stages[0].key : null));
30911
+ var StagesComponent = ({
30912
+ stages,
30913
+ isShowBtn,
30914
+ buttonText,
30915
+ className,
30916
+ style,
30917
+ onStageChange,
30918
+ currentStage,
30919
+ dataKey = "key",
30920
+ dataLabel = "header",
30921
+ loading,
30922
+ saving,
30923
+ triggerOnClick = false,
30924
+ canvasMode = "desktop"
30925
+ }) => {
30926
+ const [activeStage, setActiveStage] = (0, import_react31.useState)(currentStage || (stages && stages.length > 0 ? stages[0][dataKey] : null));
30913
30927
  const [isCompleted, setIsCompleted] = (0, import_react31.useState)(false);
30914
30928
  const updateStage = (stageKey) => {
30915
30929
  setActiveStage(stageKey);
@@ -30919,18 +30933,19 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
30919
30933
  if (!stages || stages.length === 0) return;
30920
30934
  const currentIndex = stages.findIndex((stage) => stage[dataKey] === activeStage);
30921
30935
  if (currentIndex + 1 === stages.length) {
30922
- const currentStage2 = stages[currentIndex];
30923
- updateStage(currentStage2[dataKey]);
30936
+ const currentStageObj = stages[currentIndex];
30937
+ updateStage(currentStageObj[dataKey]);
30924
30938
  setIsCompleted(true);
30925
30939
  return;
30926
30940
  }
30927
- if (currentIndex < stages.length) {
30928
- const currentStage2 = stages[currentIndex];
30929
- updateStage(currentStage2[dataKey]);
30941
+ if (currentIndex < stages.length - 1) {
30942
+ const nextStageObj = stages[currentIndex + 1];
30943
+ updateStage(nextStageObj[dataKey]);
30930
30944
  return;
30931
30945
  }
30932
30946
  };
30933
30947
  const lastStage = stages && stages.length > 0 ? stages[stages.length - 1][dataKey] : null;
30948
+ const isMobile = canvasMode === "mobile";
30934
30949
  const onStageClick = (stageKey) => {
30935
30950
  if (!stageKey || stageKey === activeStage || activeStage === lastStage) return;
30936
30951
  setActiveStage(stageKey);
@@ -30940,50 +30955,91 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
30940
30955
  };
30941
30956
  const isAllStagesCompleted = isCompleted || currentStage === lastStage;
30942
30957
  const disabled = isAllStagesCompleted || loading || saving;
30943
- return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className, style, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "flex items-center justify-between bg-red p-2 rounded-lg border border-gray-200 w-full", children: [
30944
- /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("button", { className: "p-2 hover:bg-gray-100 rounded", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("svg", { className: "w-4 h-4 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) }) }) }),
30945
- /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "flex items-center flex-1 px-2 flex-wrap gap-2", children: loading ? Array(6).fill(null).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
30946
- "button",
30947
- {
30948
- className: `
30949
- min-w-[80px] min-h-[35px] px-4 py-2 rounded-full text-sm font-medium transition-colors duration-200 whitespace-nowrap
30950
- text-gray-700 hover:bg-gray-100 border border-gray-200 bg-gray-100 animate-pulse`,
30951
- disabled: true
30952
- },
30953
- index
30954
- )) : stages?.length > 0 && stages?.map((stage, index) => {
30955
- const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
30956
- const isCompleted2 = isAllStagesCompleted || index < currentIndex;
30957
- const isActive = !isAllStagesCompleted && index === currentIndex;
30958
- return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_react31.default.Fragment, { children: [
30958
+ return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className, style, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
30959
+ "div",
30960
+ {
30961
+ className: `
30962
+ flex flex-col lg:flex-row items-start lg:items-center
30963
+ justify-between bg-red p-2 rounded-lg border border-gray-200 w-full
30964
+ gap-3 lg:gap-0
30965
+ ${isMobile ? "p-3 sm:p-4" : "p-2"}
30966
+ `,
30967
+ children: [
30968
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "flex items-center flex-shrink-0 order-1 lg:order-1", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("button", { className: "p-2 hover:bg-gray-100 rounded flex-shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("svg", { className: "w-4 h-4 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) }) }) }),
30959
30969
  /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
30960
- "button",
30970
+ "div",
30961
30971
  {
30962
30972
  className: `
30963
- min-w-[80px] px-4 py-2 rounded-full text-sm font-medium transition-colors duration-200 whitespace-nowrap
30964
- ${isActive ? "bg-green-700 text-white shadow-md" : isCompleted2 ? "bg-green-50 text-green-700 border border-green-700" : "bg-white text-gray-700 hover:bg-gray-100 border border-gray-200"}`,
30965
- onClick: () => {
30966
- if (isAllStagesCompleted) return;
30967
- onStageClick(stage[dataKey]);
30968
- },
30969
- children: stage[dataLabel]
30973
+ flex flex-col sm:flex-row items-center flex-1 px-1 sm:px-2
30974
+ flex-wrap gap-2 sm:gap-2 lg:gap-3 w-full lg:w-auto
30975
+ ${isMobile ? "order-2 mt-2 lg:mt-0" : "order-2"}
30976
+ `,
30977
+ children: loading ? Array(6).fill(null).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
30978
+ "button",
30979
+ {
30980
+ className: `
30981
+ min-w-[70px] sm:min-w-[80px] w-full sm:w-auto
30982
+ min-h-[32px] sm:min-h-[35px] px-3 sm:px-4 py-2 rounded-full
30983
+ text-xs sm:text-sm font-medium transition-colors duration-200
30984
+ whitespace-nowrap text-gray-700 hover:bg-gray-100 border
30985
+ border-gray-200 bg-gray-100 animate-pulse flex-shrink-0
30986
+ ${isMobile ? "flex-1" : ""}
30987
+ `,
30988
+ disabled: true
30989
+ },
30990
+ index
30991
+ )) : stages?.length > 0 && stages?.map((stage, index) => {
30992
+ const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
30993
+ const isCompletedStage = isAllStagesCompleted || index <= currentIndex;
30994
+ const isActive = !isAllStagesCompleted && index === currentIndex;
30995
+ return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_react31.default.Fragment, { children: [
30996
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
30997
+ "button",
30998
+ {
30999
+ className: `
31000
+ min-w-[70px] sm:min-w-[80px] w-full sm:w-auto px-3 sm:px-4 py-1.5 sm:py-2
31001
+ rounded-full text-xs sm:text-sm font-medium transition-colors duration-200
31002
+ whitespace-normal sm:whitespace-nowrap flex-shrink-0
31003
+ ${isActive ? "bg-green-700 text-white shadow-md" : isCompletedStage ? "bg-green-50 text-green-700 border-2 border-green-700" : "bg-white text-gray-700 hover:bg-gray-100 border border-gray-200"}
31004
+ ${isMobile ? "flex-1 text-center py-2.5" : ""}
31005
+ `,
31006
+ onClick: () => {
31007
+ if (isAllStagesCompleted) return;
31008
+ onStageClick(stage[dataKey]);
31009
+ },
31010
+ children: stage[dataLabel]
31011
+ }
31012
+ ),
31013
+ !isMobile && index < stages.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "hidden sm:flex sm:flex-shrink-0 w-3 h-px bg-gray-300 sm:w-4" })
31014
+ ] }, stage.id);
31015
+ })
30970
31016
  }
30971
31017
  ),
30972
- index < stages.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "flex-shrink-0 w-3 h-px bg-gray-300" })
30973
- ] }, stage.id);
30974
- }) }),
30975
- isShowBtn && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
30976
- "button",
30977
- {
30978
- className: `bg-green-700 text-white px-6 py-2 rounded-lg text-sm font-medium transition-colors duration-200 shadow-sm ${disabled ? "opacity-50 cursor-not-allowed" : ""}`,
30979
- onClick: () => {
30980
- nextStage();
30981
- },
30982
- disabled,
30983
- children: saving ? "Updating..." : buttonText
30984
- }
30985
- ) })
30986
- ] }) });
31018
+ isShowBtn && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
31019
+ "div",
31020
+ {
31021
+ className: `
31022
+ flex items-center flex-shrink-0 w-full lg:w-auto
31023
+ ${isMobile ? "order-3 mt-3 lg:mt-0" : "order-3"}
31024
+ `,
31025
+ children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
31026
+ "button",
31027
+ {
31028
+ className: `
31029
+ w-full lg:w-auto bg-green-700 text-white px-4 lg:px-6 py-2.5
31030
+ rounded-lg text-sm font-medium transition-colors duration-200
31031
+ shadow-sm ${disabled ? "opacity-50 cursor-not-allowed" : "hover:shadow-md"}
31032
+ `,
31033
+ onClick: nextStage,
31034
+ disabled,
31035
+ children: saving ? "Updating..." : buttonText
31036
+ }
31037
+ )
31038
+ }
31039
+ )
31040
+ ]
31041
+ }
31042
+ ) });
30987
31043
  };
30988
31044
  var Stages_default = StagesComponent;
30989
31045
 
@@ -31189,97 +31245,476 @@ function Navbar({
31189
31245
 
31190
31246
  // src/components/Chart/BarChart.tsx
31191
31247
  var import_react33 = __toESM(require("react"));
31248
+ var import_axios2 = __toESM(require("axios"));
31192
31249
  var import_recharts = require("recharts");
31193
31250
  var import_jsx_runtime64 = require("react/jsx-runtime");
31194
- var ChartComponent = ({ className, style, loading, ...props }) => {
31195
- const data = Array.isArray(props.data) ? props.data : [];
31251
+ var getRandomColor = () => {
31252
+ const palette = [
31253
+ "#2563eb",
31254
+ "#1d4ed8",
31255
+ "#1e40af",
31256
+ "#1e3a8a",
31257
+ "#1e293b",
31258
+ "#10b981",
31259
+ "#059669",
31260
+ "#047857",
31261
+ "#065f46",
31262
+ "#022c22",
31263
+ "#f59e0b",
31264
+ "#d97706",
31265
+ "#b45309",
31266
+ "#92400e",
31267
+ "#422006",
31268
+ "#ef4444",
31269
+ "#dc2626",
31270
+ "#b91c1c",
31271
+ "#991b1b",
31272
+ "#7f1d1d",
31273
+ "#8b5cf6",
31274
+ "#7c3aed",
31275
+ "#6d28d9",
31276
+ "#5b21b6",
31277
+ "#4c1d95",
31278
+ "#14b8a6",
31279
+ "#0d9488",
31280
+ "#0f766e",
31281
+ "#115e59",
31282
+ "#134e4a",
31283
+ "#ec4899",
31284
+ "#db2777",
31285
+ "#be185d",
31286
+ "#9d174d",
31287
+ "#831843",
31288
+ "#22c55e",
31289
+ "#16a34a",
31290
+ "#15803d",
31291
+ "#166534",
31292
+ "#14532d"
31293
+ ];
31294
+ return palette[Math.floor(Math.random() * palette.length)];
31295
+ };
31296
+ var ChartComponent = ({
31297
+ className,
31298
+ style,
31299
+ loading: externalLoading,
31300
+ dataKey,
31301
+ dataLabel,
31302
+ apiUrl,
31303
+ isPaginationEnabled,
31304
+ limit = 10,
31305
+ canvasMode,
31306
+ ...props
31307
+ }) => {
31308
+ const [rawData, setRawData] = (0, import_react33.useState)([]);
31309
+ const [rawMeta, setRawMeta] = (0, import_react33.useState)(null);
31310
+ const [localLoading, setLocalLoading] = (0, import_react33.useState)(false);
31311
+ const [currentPage, setCurrentPage] = (0, import_react33.useState)(1);
31312
+ const effectiveData = apiUrl ? rawData : props.data || [];
31313
+ const effectiveLoading = apiUrl ? localLoading : externalLoading;
31314
+ (0, import_react33.useEffect)(() => {
31315
+ if (apiUrl) {
31316
+ setCurrentPage(1);
31317
+ }
31318
+ }, [apiUrl]);
31319
+ const fetchData = (0, import_react33.useCallback)(async (page) => {
31320
+ if (!apiUrl) return;
31321
+ const cancelled = false;
31322
+ try {
31323
+ setLocalLoading(true);
31324
+ const params = new URLSearchParams({
31325
+ page: page.toString(),
31326
+ limit: limit.toString()
31327
+ });
31328
+ const res = await import_axios2.default.get(`${apiUrl}?${params.toString()}`, {
31329
+ withCredentials: true
31330
+ });
31331
+ if (!cancelled) {
31332
+ let data2 = [];
31333
+ let meta = null;
31334
+ if (res.data?.success && Array.isArray(res.data.data)) {
31335
+ data2 = res.data.data;
31336
+ meta = res.data.meta || null;
31337
+ } else if (Array.isArray(res.data)) {
31338
+ data2 = res.data;
31339
+ }
31340
+ setRawData(data2);
31341
+ setRawMeta(meta);
31342
+ }
31343
+ } catch (err) {
31344
+ if (!cancelled) {
31345
+ showSonnerToast({
31346
+ title: err?.response?.data?.message || err?.message || "Failed to load chart data",
31347
+ variant: "error"
31348
+ });
31349
+ setRawData([]);
31350
+ }
31351
+ } finally {
31352
+ if (!cancelled) setLocalLoading(false);
31353
+ }
31354
+ }, [apiUrl, limit]);
31355
+ (0, import_react33.useEffect)(() => {
31356
+ if (!apiUrl) return;
31357
+ fetchData(currentPage);
31358
+ }, [apiUrl, currentPage, fetchData]);
31359
+ const handlePageChange = (newPage) => {
31360
+ if (rawMeta && (newPage < 1 || newPage > rawMeta.pages)) return;
31361
+ setCurrentPage(newPage);
31362
+ };
31363
+ const data = (0, import_react33.useMemo)(() => {
31364
+ if (!Array.isArray(effectiveData) || effectiveData.length === 0 || !dataKey || !dataLabel) {
31365
+ return [];
31366
+ }
31367
+ return effectiveData.map((item) => ({
31368
+ ...item,
31369
+ [dataKey]: Number(item[dataKey] || 0),
31370
+ fill: getRandomColor()
31371
+ }));
31372
+ }, [effectiveData, dataKey, dataLabel]);
31196
31373
  const chartType = props.chartType || "bar";
31197
- const legendsPosition = props.legendsPosition === "middle" || props.legendsPosition === "bottom" ? props.legendsPosition : "top";
31198
- if (loading || data.length === 0) {
31199
- return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
31374
+ const legendsPosition = ["middle", "bottom"].includes(props.legendsPosition) ? props.legendsPosition : "top";
31375
+ if (effectiveLoading || data.length === 0) {
31376
+ return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
31200
31377
  "div",
31201
31378
  {
31202
- className: `flex items-center justify-center w-full h-[300px] md:h-[400px] bg-gray-50 animate-pulse rounded-lg ${className}`,
31379
+ className: `relative flex flex-col w-full h-[300px] md:h-[400px] bg-gradient-to-br from-gray-50 to-gray-100 rounded-xl p-6 ${className}`,
31203
31380
  style,
31204
- children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "text-gray-400 text-sm md:text-base", children: loading ? "Loading chart report..." : "No data available to display the chart." })
31381
+ children: [
31382
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "mb-6 flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "inline-flex items-center space-x-2 bg-white/90 px-6 py-2.5 rounded-xl backdrop-blur-sm border border-gray-200 shadow-lg", children: [
31383
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "w-5 h-5 border-2 border-gray-400 border-t-blue-500 rounded-full animate-spin" }),
31384
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "text-sm font-medium text-gray-700 bg-gradient-to-r from-gray-300 bg-clip-text animate-pulse", children: "Loading chart data..." })
31385
+ ] }) }),
31386
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "absolute inset-0 bg-gradient-to-r from-transparent via-white/60 to-transparent animate-shimmer rounded-xl" }),
31387
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "flex-1 relative w-full h-full min-h-[240px] md:min-h-[320px] bg-white/80 rounded-lg border border-gray-200/50 shadow-sm", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "absolute bottom-0 left-4 right-4 flex gap-2 h-[200px] md:h-[280px] justify-center items-end", children: [...Array(20)].map((_, idx) => {
31388
+ const randomHeight = `${Math.floor(Math.random() * 76) + 20}%`;
31389
+ return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
31390
+ "div",
31391
+ {
31392
+ className: `relative w-10 md:w-12 flex-1 max-w-[48px] rounded-t-lg bg-gradient-to-t from-gray-100 via-gray-200 to-transparent shadow-lg border border-gray-200/50 animate-slide-up stagger-${idx} overflow-hidden`,
31393
+ style: { height: randomHeight, animationDelay: `${idx * 0.08}s` },
31394
+ children: [
31395
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "absolute inset-0 bg-gradient-to-r from-white/40 via-transparent to-white/40 animate-shimmer-bar" }),
31396
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "absolute bottom-1 left-1/2 w-4 h-1 rounded-full transform -translate-x-1/2 blur-sm" })
31397
+ ]
31398
+ },
31399
+ `bar-${idx}`
31400
+ );
31401
+ }) }) })
31402
+ ]
31205
31403
  }
31206
31404
  );
31207
31405
  }
31208
- return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: `${className} h-[400px]`, style, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.ResponsiveContainer, { width: "100%", height: "100%", children: chartType === "bar" ? /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_recharts.BarChart, { data, title: "Leads", desc: "content", children: [
31209
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.CartesianGrid, { strokeDasharray: "3 3" }),
31210
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.XAxis, { dataKey: "name" }),
31211
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.YAxis, {}),
31212
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.Tooltip, { formatter: (value) => `${value}k` }),
31213
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.Legend, { verticalAlign: legendsPosition, align: "center" }),
31214
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
31215
- import_recharts.Bar,
31216
- {
31217
- dataKey: "value",
31218
- fill: "#00695C",
31219
- radius: [6, 6, 0, 0],
31220
- isAnimationActive: false,
31221
- children: data.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
31222
- "rect",
31406
+ return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: `${className} h-[450px]`, style, children: [
31407
+ isPaginationEnabled && rawMeta && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center justify-between mb-4 px-2", children: [
31408
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "text-sm text-gray-600 hidden sm:block", children: [
31409
+ "Page ",
31410
+ rawMeta.page,
31411
+ " of ",
31412
+ rawMeta.pages,
31413
+ " (",
31414
+ rawMeta.total.toLocaleString(),
31415
+ " total records)"
31416
+ ] }),
31417
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center space-x-2 sm:hidden w-full justify-center", children: [
31418
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
31419
+ "button",
31420
+ {
31421
+ onClick: () => handlePageChange(currentPage - 1),
31422
+ disabled: currentPage === 1 || localLoading,
31423
+ className: "flex-1 px-3 py-2 text-xs font-medium rounded-lg border bg-white shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 flex items-center justify-center space-x-1 min-w-0",
31424
+ children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { children: "\u2190 Prev" })
31425
+ }
31426
+ ),
31427
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "px-2 py-2 text-xs font-semibold text-gray-700 min-w-[36px] text-center flex-shrink-0", children: currentPage }),
31428
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
31429
+ "button",
31430
+ {
31431
+ onClick: () => handlePageChange(currentPage + 1),
31432
+ disabled: currentPage >= rawMeta.pages || localLoading,
31433
+ className: "flex-1 px-3 py-2 text-xs font-medium rounded-lg border bg-white shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 flex items-center justify-center space-x-1 min-w-0",
31434
+ children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { children: "Next \u2192" })
31435
+ }
31436
+ )
31437
+ ] }),
31438
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "flex items-center space-x-2 hidden sm:flex", children: [
31439
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
31440
+ "button",
31223
31441
  {
31224
- fill: entry.color || "#00695C"
31442
+ onClick: () => handlePageChange(currentPage - 1),
31443
+ disabled: currentPage === 1 || localLoading,
31444
+ className: "px-3 py-1.5 text-sm font-medium rounded-lg border bg-white shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 flex items-center space-x-1",
31445
+ children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { children: "\u2190 Prev" })
31446
+ }
31447
+ ),
31448
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "px-3 py-1 text-sm font-medium text-gray-700", children: currentPage }),
31449
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
31450
+ "button",
31451
+ {
31452
+ onClick: () => handlePageChange(currentPage + 1),
31453
+ disabled: currentPage >= rawMeta.pages || localLoading,
31454
+ className: "px-3 py-1.5 text-sm font-medium rounded-lg border bg-white shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 flex items-center space-x-1",
31455
+ children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { children: "Next \u2192" })
31456
+ }
31457
+ )
31458
+ ] })
31459
+ ] }),
31460
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.ResponsiveContainer, { width: "100%", height: "100%", children: chartType === "bar" ? /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_recharts.BarChart, { data, children: [
31461
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.CartesianGrid, { strokeDasharray: "3 3" }),
31462
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
31463
+ import_recharts.XAxis,
31464
+ {
31465
+ dataKey: dataLabel,
31466
+ angle: -45,
31467
+ textAnchor: "end",
31468
+ interval: 0,
31469
+ tickFormatter: (value) => value?.toString().length > 10 ? `${value.toString().substring(0, 10)}...` : value,
31470
+ tick: {
31471
+ fontSize: 13,
31472
+ fontWeight: 500,
31473
+ fill: "#666",
31474
+ fontFamily: "inherit"
31225
31475
  },
31226
- `bar-${index}`
31227
- ))
31228
- }
31229
- )
31230
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_recharts.AreaChart, { data, children: [
31231
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("linearGradient", { id: "colorCount", x1: "0", y1: "0", x2: "0", y2: "1", children: [
31232
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("stop", { offset: "5%", stopColor: "#00695C", stopOpacity: 0.8 }),
31233
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("stop", { offset: "95%", stopColor: "#00695C", stopOpacity: 0 })
31234
- ] }) }),
31235
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.CartesianGrid, { strokeDasharray: "3 3" }),
31236
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.XAxis, { dataKey: "name" }),
31237
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.YAxis, {}),
31238
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.Tooltip, { formatter: (value) => `${value}k` }),
31239
- /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
31240
- import_recharts.Area,
31241
- {
31242
- type: "monotone",
31243
- dataKey: "value",
31244
- stroke: "#00695C",
31245
- fillOpacity: 1,
31246
- fill: "url(#colorCount)",
31247
- isAnimationActive: false
31248
- }
31249
- )
31250
- ] }) }) });
31476
+ height: 80,
31477
+ className: "hidden sm:block"
31478
+ }
31479
+ ),
31480
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
31481
+ import_recharts.YAxis,
31482
+ {
31483
+ tickFormatter: (value) => `${(value / 1e3).toFixed(0)}k`,
31484
+ tick: {
31485
+ fontSize: 12,
31486
+ fill: "#94a3b8",
31487
+ fontWeight: 500
31488
+ },
31489
+ domain: ["dataMin", "dataMax"],
31490
+ width: 60
31491
+ }
31492
+ ),
31493
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.Tooltip, { formatter: (value) => [`${value}`, "Count"] }),
31494
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.Legend, { verticalAlign: legendsPosition, align: "center" }),
31495
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
31496
+ import_recharts.Bar,
31497
+ {
31498
+ dataKey,
31499
+ radius: [6, 6, 0, 0],
31500
+ isAnimationActive: false
31501
+ }
31502
+ )
31503
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_recharts.AreaChart, { data, children: [
31504
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("linearGradient", { id: "colorCount", x1: "0", y1: "0", x2: "0", y2: "1", children: [
31505
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("stop", { offset: "5%", stopColor: "#00695C", stopOpacity: 0.8 }),
31506
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("stop", { offset: "95%", stopColor: "#00695C", stopOpacity: 0 })
31507
+ ] }) }),
31508
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.CartesianGrid, { strokeDasharray: "3 3" }),
31509
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
31510
+ import_recharts.XAxis,
31511
+ {
31512
+ dataKey: dataLabel,
31513
+ angle: 0,
31514
+ interval: 0,
31515
+ tick: {
31516
+ fontSize: 13,
31517
+ fontWeight: 500,
31518
+ fill: "#666",
31519
+ fontFamily: "inherit"
31520
+ }
31521
+ }
31522
+ ),
31523
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
31524
+ import_recharts.YAxis,
31525
+ {
31526
+ tickFormatter: (value) => `${(value / 1e3).toFixed(0)}k`,
31527
+ tick: {
31528
+ fontSize: 12,
31529
+ fill: "#94a3b8",
31530
+ fontWeight: 500
31531
+ },
31532
+ domain: ["dataMin", "dataMax"],
31533
+ width: 60
31534
+ }
31535
+ ),
31536
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_recharts.Tooltip, { formatter: (value) => `${value}k` }),
31537
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
31538
+ import_recharts.Area,
31539
+ {
31540
+ type: "monotone",
31541
+ dataKey,
31542
+ stroke: "#00695C",
31543
+ fillOpacity: 1,
31544
+ fill: "url(#colorCount)",
31545
+ isAnimationActive: false
31546
+ }
31547
+ )
31548
+ ] }) })
31549
+ ] });
31251
31550
  };
31252
31551
  var BarChart_default = import_react33.default.memo(ChartComponent);
31253
31552
 
31254
31553
  // src/components/Chart/PieChart.tsx
31255
31554
  var import_react34 = __toESM(require("react"));
31555
+ var import_axios3 = __toESM(require("axios"));
31256
31556
  var import_recharts2 = require("recharts");
31257
31557
  var import_jsx_runtime65 = require("react/jsx-runtime");
31258
- var getRandomColor = () => {
31558
+ var getRandomColor2 = () => {
31259
31559
  const palette = [
31260
31560
  "#2563eb",
31561
+ "#1d4ed8",
31562
+ "#1e40af",
31563
+ "#1e3a8a",
31564
+ "#1e293b",
31261
31565
  "#10b981",
31566
+ "#059669",
31567
+ "#047857",
31568
+ "#065f46",
31569
+ "#022c22",
31262
31570
  "#f59e0b",
31571
+ "#d97706",
31572
+ "#b45309",
31573
+ "#92400e",
31574
+ "#422006",
31263
31575
  "#ef4444",
31576
+ "#dc2626",
31577
+ "#b91c1c",
31578
+ "#991b1b",
31579
+ "#7f1d1d",
31264
31580
  "#8b5cf6",
31581
+ "#7c3aed",
31582
+ "#6d28d9",
31583
+ "#5b21b6",
31584
+ "#4c1d95",
31265
31585
  "#14b8a6",
31586
+ "#0d9488",
31587
+ "#0f766e",
31588
+ "#115e59",
31589
+ "#134e4a",
31266
31590
  "#ec4899",
31267
- "#e11d48",
31591
+ "#db2777",
31592
+ "#be185d",
31593
+ "#9d174d",
31594
+ "#831843",
31268
31595
  "#22c55e",
31269
- "#3b82f6"
31596
+ "#16a34a",
31597
+ "#15803d",
31598
+ "#166534",
31599
+ "#14532d",
31600
+ "#3b82f6",
31601
+ "#2563eb",
31602
+ "#1d4ed8",
31603
+ "#1e40af",
31604
+ "#1e3a8a",
31605
+ "#f97316",
31606
+ "#ea580c",
31607
+ "#c2410c",
31608
+ "#9a3412",
31609
+ "#7c2d12",
31610
+ "#a855f7",
31611
+ "#9333ea",
31612
+ "#7e22ce",
31613
+ "#6b21a8",
31614
+ "#581c87",
31615
+ "#06b6d4",
31616
+ "#0891b2",
31617
+ "#0e7490",
31618
+ "#155e75",
31619
+ "#164e63"
31270
31620
  ];
31271
31621
  return palette[Math.floor(Math.random() * palette.length)];
31272
31622
  };
31273
- var DonutChart = ({ className, style, loading, ...props }) => {
31623
+ var DonutChart = ({
31624
+ className,
31625
+ style,
31626
+ loading: externalLoading,
31627
+ dataKey = "value",
31628
+ dataLabel = "name",
31629
+ apiUrl,
31630
+ ...props
31631
+ }) => {
31274
31632
  const showLegends = props.showLegends ?? true;
31275
- const labelType = props.labelType || "inside";
31276
31633
  const canvasMode = props.canvasMode;
31634
+ const [rawData, setRawData] = (0, import_react34.useState)([]);
31635
+ const [localLoading, setLocalLoading] = (0, import_react34.useState)(false);
31636
+ const effectiveData = apiUrl ? rawData : props.data || [];
31637
+ const effectiveLoading = apiUrl ? localLoading : externalLoading;
31638
+ (0, import_react34.useEffect)(() => {
31639
+ if (!apiUrl) return;
31640
+ let cancelled = false;
31641
+ const fetchData = async () => {
31642
+ try {
31643
+ setLocalLoading(true);
31644
+ const res = await import_axios3.default.get(apiUrl, {
31645
+ withCredentials: true
31646
+ });
31647
+ if (!cancelled) {
31648
+ let data2 = [];
31649
+ if (res.data?.success && Array.isArray(res.data.data)) {
31650
+ data2 = res.data.data;
31651
+ } else if (Array.isArray(res.data)) {
31652
+ data2 = res.data;
31653
+ }
31654
+ setRawData(data2);
31655
+ }
31656
+ } catch (err) {
31657
+ if (!cancelled) {
31658
+ showSonnerToast({
31659
+ title: err?.response?.data?.message || err?.message || "Failed to load chart data",
31660
+ variant: "error"
31661
+ });
31662
+ setRawData([]);
31663
+ }
31664
+ } finally {
31665
+ if (!cancelled) setLocalLoading(false);
31666
+ }
31667
+ };
31668
+ fetchData();
31669
+ return () => {
31670
+ cancelled = true;
31671
+ };
31672
+ }, [apiUrl]);
31277
31673
  const data = (0, import_react34.useMemo)(() => {
31278
- if (!Array.isArray(props.data)) return [];
31279
- return props.data.map((item) => ({ ...item, color: getRandomColor() }));
31280
- }, [props.data]);
31281
- const total = (0, import_react34.useMemo)(() => data.reduce((sum, d) => sum + d.value, 0), [data]);
31674
+ if (!Array.isArray(effectiveData) || effectiveData.length === 0) return [];
31675
+ return effectiveData.map((item) => ({
31676
+ ...item,
31677
+ color: item.color || getRandomColor2(),
31678
+ [dataKey]: Number(item[dataKey] ?? 0),
31679
+ [dataLabel]: item[dataLabel] ?? "Unknown"
31680
+ }));
31681
+ }, [effectiveData, dataKey, dataLabel]);
31682
+ const total = (0, import_react34.useMemo)(
31683
+ () => data.reduce((sum, d) => sum + (d[dataKey] ?? 0), 0),
31684
+ [data, dataKey]
31685
+ );
31686
+ const formattedTotal = (0, import_react34.useMemo)(() => {
31687
+ if (total >= 1e6) {
31688
+ return `${(total / 1e6).toFixed(1)}M`;
31689
+ }
31690
+ if (total >= 1e3) {
31691
+ return `${(total / 1e3).toFixed(0)}k`;
31692
+ }
31693
+ return total.toString();
31694
+ }, [total]);
31695
+ const chartData = (0, import_react34.useMemo)(() => {
31696
+ if (total === 0) return data;
31697
+ const sortedData = [...data].sort((a, b) => (b[dataKey] ?? 0) - (a[dataKey] ?? 0));
31698
+ const minAngle = 360 / Math.max(12, sortedData.length);
31699
+ const minValue = total * minAngle / 360;
31700
+ return sortedData.map((item, index) => {
31701
+ const value = item[dataKey] ?? 0;
31702
+ if (value < minValue && index < 12) {
31703
+ return {
31704
+ ...item,
31705
+ [dataKey]: minValue * 1.2,
31706
+ isBoosted: true
31707
+ };
31708
+ }
31709
+ return item;
31710
+ });
31711
+ }, [data, total, dataKey]);
31282
31712
  const forceMobile = canvasMode === "mobile" || canvasMode === "tablet";
31713
+ const getDynamicRadius = () => {
31714
+ if (forceMobile) return { inner: 60, outer: 100 };
31715
+ if (chartData.length <= 6) return { inner: 85, outer: 150 };
31716
+ return { inner: 70, outer: 130 };
31717
+ };
31283
31718
  const [mounted, setMounted] = (0, import_react34.useState)(false);
31284
31719
  (0, import_react34.useEffect)(() => {
31285
31720
  const timeout = setTimeout(() => setMounted(true), 100);
@@ -31287,91 +31722,131 @@ var DonutChart = ({ className, style, loading, ...props }) => {
31287
31722
  }, []);
31288
31723
  const renderLegends = (0, import_react34.useMemo)(() => {
31289
31724
  if (!showLegends) return null;
31290
- return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_jsx_runtime65.Fragment, { children: data.map((d) => /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
31291
- "div",
31292
- {
31293
- className: "flex items-center space-x-2 rounded-md border border-gray-200 px-3 py-2 w-[48%] md:w-auto",
31294
- children: [
31295
- /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
31296
- "span",
31297
- {
31298
- className: "inline-block w-[16px] h-[16px] rounded",
31299
- style: { backgroundColor: d.color }
31300
- }
31301
- ),
31302
- /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "text-[#000000] text-[12px] md:text-[13px] font-[500]", children: d.name })
31303
- ]
31304
- },
31305
- d.name
31306
- )) });
31307
- }, [data, showLegends]);
31725
+ return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "flex flex-wrap justify-center gap-2 mt-4 w-full max-w-4xl", children: chartData.map((d, index) => {
31726
+ const actualValue = data.find(
31727
+ (item) => item[dataLabel] === d[dataLabel]
31728
+ )?.[dataKey] ?? d[dataKey];
31729
+ const displayValue = actualValue >= 1e3 ? `${(actualValue / 1e3).toFixed(0)}k` : actualValue.toLocaleString();
31730
+ return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
31731
+ "div",
31732
+ {
31733
+ className: "flex items-center space-x-2 rounded-lg border border-gray-200/50 px-3 py-1.5 w-[48%] sm:w-[32%] md:w-auto bg-white/80 backdrop-blur-sm shadow-sm hover:shadow-md transition-all",
31734
+ children: [
31735
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
31736
+ "span",
31737
+ {
31738
+ className: "inline-block w-[12px] h-[12px] rounded-full shrink-0 border-2 border-white/50",
31739
+ style: { backgroundColor: d.color }
31740
+ }
31741
+ ),
31742
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "min-w-0 flex-1", children: [
31743
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "text-gray-900 text-[11px] md:text-[13px] font-semibold block truncate leading-tight", children: d[dataLabel] }),
31744
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "flex items-center gap-1 text-xs text-gray-600 font-medium", children: [
31745
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { children: displayValue }),
31746
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("span", { children: [
31747
+ (actualValue / total * 100).toFixed(1),
31748
+ "%"
31749
+ ] }),
31750
+ d.isBoosted && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "text-[9px] px-1 py-0.5 bg-blue-100 text-blue-700 rounded-full", children: "min" })
31751
+ ] })
31752
+ ] })
31753
+ ]
31754
+ },
31755
+ `legend-${index}`
31756
+ );
31757
+ }) });
31758
+ }, [chartData, data, dataLabel, dataKey, total, showLegends]);
31308
31759
  if (!mounted) return null;
31309
- if (loading || data.length === 0) {
31310
- return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
31760
+ if (effectiveLoading || data.length === 0) {
31761
+ return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
31311
31762
  "div",
31312
31763
  {
31313
- className: `flex items-center justify-center w-full h-[300px] md:h-[400px] bg-gray-50 animate-pulse rounded-lg ${className}`,
31764
+ className: `relative flex flex-col items-center w-full h-[300px] md:h-[400px] bg-gradient-to-br from-gray-50 to-gray-100 rounded-xl p-6 ${className}`,
31314
31765
  style,
31315
- children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "text-gray-400 text-sm md:text-base", children: loading ? "Loading chart report..." : "No data available to display the chart." })
31316
- }
31317
- );
31318
- }
31319
- return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
31320
- "div",
31321
- {
31322
- className: `relative flex flex-col items-center ${className}`,
31323
- style,
31324
- children: [
31325
- /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "relative w-full md:w-[70%] h-[300px] md:h-[400px] flex items-center justify-center", children: [
31326
- /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_recharts2.ResponsiveContainer, { width: "99%", height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_recharts2.PieChart, { children: [
31327
- /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
31328
- import_recharts2.Pie,
31329
- {
31330
- data,
31331
- cx: "50%",
31332
- cy: "50%",
31333
- innerRadius: forceMobile ? 60 : 80,
31334
- outerRadius: forceMobile ? 100 : 140,
31335
- dataKey: "value",
31336
- labelLine: false,
31337
- isAnimationActive: false,
31338
- children: [
31339
- data.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_recharts2.Cell, { fill: entry.color }, `cell-${index}`)),
31340
- /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
31341
- import_recharts2.LabelList,
31342
- {
31343
- dataKey: "value",
31344
- position: labelType === "inside" ? "inside" : "outside",
31345
- fill: labelType === "inside" ? "#fff" : "#000",
31346
- fontSize: forceMobile ? 10 : 13,
31347
- fontWeight: 600
31348
- }
31349
- )
31350
- ]
31351
- }
31352
- ),
31353
- /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
31354
- import_recharts2.Tooltip,
31355
- {
31356
- formatter: (value, name) => [`${value}k`, name]
31357
- }
31358
- )
31766
+ children: [
31767
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "absolute inset-0 bg-gradient-to-r from-transparent via-white/60 to-transparent animate-shimmer rounded-xl" }),
31768
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "mt-6 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "inline-flex items-center space-x-2 bg-white/80 px-6 py-2 rounded-full backdrop-blur-sm border border-gray-200 shadow-lg", children: [
31769
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "w-5 h-5 border-2 border-gray-300 border-t-blue-400 rounded-full animate-spin" }),
31770
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "text-sm font-medium text-gray-600 bg-gradient-to-r from-gray-300 bg-clip-text animate-pulse", children: "Loading chart data..." })
31359
31771
  ] }) }),
31360
- /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
31772
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "flex flex-wrap justify-center gap-3 mt-8 w-full max-w-4xl", children: [...Array(18)].map((_, idx) => /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
31361
31773
  "div",
31362
31774
  {
31363
- className: `absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 ${forceMobile ? "text-2xl" : "text-4xl"} font-bold text-[#000]`,
31775
+ className: `h-10 w-[48%] sm:w-[32%] md:w-32 rounded-xl bg-gradient-to-r from-gray-200 via-gray-300/50 to-gray-200 p-3 flex items-center space-x-3 animate-slide-up stagger-${idx} shadow-sm border border-gray-200/50`,
31364
31776
  children: [
31365
- total,
31366
- "k"
31777
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "w-4 h-4 rounded-full bg-gradient-to-r from-blue-300 to-purple-300 animate-pulse" }),
31778
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "flex-1 space-y-1", children: [
31779
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "h-3 w-20 bg-gray-300 rounded animate-pulse" }),
31780
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "h-2.5 w-16 bg-gray-200/60 rounded animate-pulse-delayed" })
31781
+ ] })
31367
31782
  ]
31783
+ },
31784
+ idx
31785
+ )) })
31786
+ ]
31787
+ }
31788
+ );
31789
+ }
31790
+ const { inner, outer } = getDynamicRadius();
31791
+ const innerRadius = inner;
31792
+ const outerRadius = outer;
31793
+ return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: `relative flex flex-col items-center ${className}`, style, children: [
31794
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "relative w-full md:w-[75%] h-[280px] md:h-[380px] flex items-center justify-center mb-2", children: [
31795
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_recharts2.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_recharts2.PieChart, { children: [
31796
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
31797
+ import_recharts2.Pie,
31798
+ {
31799
+ data: chartData,
31800
+ cx: "50%",
31801
+ cy: "50%",
31802
+ innerRadius,
31803
+ outerRadius,
31804
+ dataKey,
31805
+ labelLine: false,
31806
+ isAnimationActive: true,
31807
+ animationDuration: 800,
31808
+ minAngle: 3,
31809
+ children: chartData.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
31810
+ import_recharts2.Cell,
31811
+ {
31812
+ fill: entry.color,
31813
+ stroke: entry.isBoosted ? "#fff" : "transparent",
31814
+ strokeWidth: entry.isBoosted ? 1.5 : 0
31815
+ },
31816
+ `cell-${index}`
31817
+ ))
31818
+ }
31819
+ ),
31820
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
31821
+ import_recharts2.Tooltip,
31822
+ {
31823
+ formatter: (value, name, payload) => {
31824
+ const label = payload && payload.payload ? payload.payload[dataLabel] : name;
31825
+ const actualItem = data.find((item) => item[dataLabel] === label);
31826
+ const actualValue = actualItem ? actualItem[dataKey] : value;
31827
+ const valueFormatted = actualValue >= 1e3 ? `${(actualValue / 1e3).toFixed(0)}k` : actualValue.toLocaleString();
31828
+ const percentage = (actualValue / total * 100).toFixed(1);
31829
+ return [
31830
+ `${label}: ${valueFormatted} (${percentage}%)`
31831
+ ];
31832
+ },
31833
+ contentStyle: {
31834
+ backgroundColor: "white",
31835
+ border: "1px solid #e5e7eb",
31836
+ borderRadius: "8px",
31837
+ fontSize: "13px",
31838
+ padding: "8px 12px"
31368
31839
  }
31369
- )
31370
- ] }),
31371
- /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "flex flex-wrap justify-center gap-2 mt-6 w-full md:w-auto", children: renderLegends })
31372
- ]
31373
- }
31374
- );
31840
+ }
31841
+ )
31842
+ ] }) }),
31843
+ total > 0 && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: `absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-center pointer-events-none ${forceMobile ? "text-xl px-2" : "text-3xl px-4"} font-bold bg-white/90 backdrop-blur-sm rounded-full py-1 shadow-lg`, children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "text-[#1f2937] leading-tight", children: [
31844
+ formattedTotal,
31845
+ /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "text-sm md:text-base font-normal text-gray-600 block md:inline-block md:ml-1", children: "total" })
31846
+ ] }) })
31847
+ ] }),
31848
+ renderLegends
31849
+ ] });
31375
31850
  };
31376
31851
  var PieChart_default = import_react34.default.memo(DonutChart);
31377
31852