Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
Add radial chart for matching score
Khuram Niazc76c0a8f47f9
diff --git a/package-lock.json b/package-lock.jsonindex b9a9e62..a9ad582 100644--- a/package-lock.json+++ b/package-lock.json@@ -49,6 +49,7 @@"react-day-picker": "^8.10.1","react-dom": "^18","react-hook-form": "^7.51.5",+ "recharts": "^2.12.7","tailwind-merge": "^2.3.0","tailwindcss-animate": "^1.0.7","zod": "^3.23.8"@@ -4445,16 +4446,37 @@"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz","integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA=="},+ "node_modules/@types/d3-array": {+ "version": "3.2.1",+ "resolved": "https://registry.npmjs.org/@types/d3-array/-/d3-array-3.2.1.tgz",+ "integrity": "sha512-Y2Jn2idRrLzUfAKV2LyRImR+y4oa2AntrgID95SHJxuMUrkNXmanDSed71sRNZysveJVt1hLLemQZIady0FpEg==",+ "license": "MIT"+ },"node_modules/@types/d3-color": {"version": "3.1.3","resolved": "https://registry.npmjs.org/@types/d3-color/-/d3-color-3.1.3.tgz","integrity": "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A=="},+ "node_modules/@types/d3-ease": {+ "version": "3.0.2",+ "resolved": "https://registry.npmjs.org/@types/d3-ease/-/d3-ease-3.0.2.tgz",+ "integrity": "sha512-NcV1JjO5oDzoK26oMzbILE6HW7uVXOHLQvHshBUW4UMdZGfiY6v5BeQwh9a9tCzv+CeefZQHJt5SRgK154RtiA==",+ "license": "MIT"+ },"node_modules/@types/d3-format": {"version": "1.4.5","resolved": "https://registry.npmjs.org/@types/d3-format/-/d3-format-1.4.5.tgz","integrity": "sha512-mLxrC1MSWupOSncXN/HOlWUAAIffAEBaI4+PKy2uMPsKe4FNZlk7qrbTjmzJXITQQqBHivaks4Td18azgqnotA=="},+ "node_modules/@types/d3-interpolate": {+ "version": "3.0.4",+ "resolved": "https://registry.npmjs.org/@types/d3-interpolate/-/d3-interpolate-3.0.4.tgz",+ "integrity": "sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==",+ "license": "MIT",+ "dependencies": {+ "@types/d3-color": "*"+ }+ },"node_modules/@types/d3-path": {"version": "3.1.0","resolved": "https://registry.npmjs.org/@types/d3-path/-/d3-path-3.1.0.tgz",@@ -4491,6 +4513,12 @@"resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-2.3.4.tgz","integrity": "sha512-xdDXbpVO74EvadI3UDxjxTdR6QIxm1FKzEA/+F8tL4GWWUg/hgvBqf6chql64U5A9ZUGWo7pEu4eNlyLwbKdhg=="},+ "node_modules/@types/d3-timer": {+ "version": "3.0.2",+ "resolved": "https://registry.npmjs.org/@types/d3-timer/-/d3-timer-3.0.2.tgz",+ "integrity": "sha512-Ps3T8E8dZDam6fUyNiMkekK3XUsaUEik+idO9/YjPtfj2qruF8tFBXS7XhtE4iIXBLxhmLjP3SXpLhVf21I9Lw==",+ "license": "MIT"+ },"node_modules/@types/graceful-fs": {"version": "4.1.9","resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz",@@ -5878,8 +5906,7 @@"node_modules/csstype": {"version": "3.1.3","resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",- "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",- "devOptional": true+ "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="},"node_modules/d3-array": {"version": "3.2.4",@@ -5900,6 +5927,15 @@"node": ">=12"}},+ "node_modules/d3-ease": {+ "version": "3.0.1",+ "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz",+ "integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==",+ "license": "BSD-3-Clause",+ "engines": {+ "node": ">=12"+ }+ },"node_modules/d3-format": {"version": "1.4.5","resolved": "https://registry.npmjs.org/d3-format/-/d3-format-1.4.5.tgz",@@ -5986,6 +6022,15 @@"d3-time": "1 - 2"}},+ "node_modules/d3-timer": {+ "version": "3.0.1",+ "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz",+ "integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==",+ "license": "ISC",+ "engines": {+ "node": ">=12"+ }+ },"node_modules/damerau-levenshtein": {"version": "1.0.8","resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz",@@ -6097,6 +6142,12 @@"integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==","devOptional": true},+ "node_modules/decimal.js-light": {+ "version": "2.5.1",+ "resolved": "https://registry.npmjs.org/decimal.js-light/-/decimal.js-light-2.5.1.tgz",+ "integrity": "sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg==",+ "license": "MIT"+ },"node_modules/dedent": {"version": "1.5.3","resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.3.tgz",@@ -6250,6 +6301,16 @@"dev": true,"peer": true},+ "node_modules/dom-helpers": {+ "version": "5.2.1",+ "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz",+ "integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==",+ "license": "MIT",+ "dependencies": {+ "@babel/runtime": "^7.8.7",+ "csstype": "^3.0.2"+ }+ },"node_modules/domexception": {"version": "4.0.0","resolved": "https://registry.npmjs.org/domexception/-/domexception-4.0.0.tgz",@@ -7026,6 +7087,15 @@"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==","dev": true},+ "node_modules/fast-equals": {+ "version": "5.0.1",+ "resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-5.0.1.tgz",+ "integrity": "sha512-WF1Wi8PwwSY7/6Kx0vKXtw8RwuSGoM1bvDaJbu7MxDlR1vovZjIAKrnzyrThgAjm6JDTu0fVgWXDlMGspodfoQ==",+ "license": "MIT",+ "engines": {+ "node": ">=6.0.0"+ }+ },"node_modules/fast-glob": {"version": "3.3.2","resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",@@ -9760,6 +9830,7 @@"version": "0.379.0","resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.379.0.tgz","integrity": "sha512-KcdeVPqmhRldldAAgptb8FjIunM2x2Zy26ZBh1RsEUcdLIvsEmbcw7KpzFYUy5BbpGeWhPu9Z9J5YXfStiXwhg==",+ "license": "ISC","peerDependencies": {"react": "^16.5.1 || ^17.0.0 || ^18.0.0"}@@ -11322,6 +11393,21 @@}}},+ "node_modules/react-smooth": {+ "version": "4.0.1",+ "resolved": "https://registry.npmjs.org/react-smooth/-/react-smooth-4.0.1.tgz",+ "integrity": "sha512-OE4hm7XqR0jNOq3Qmk9mFLyd6p2+j6bvbPJ7qlB7+oo0eNcL2l7WQzG6MBnT3EXY6xzkLMUBec3AfewJdA0J8w==",+ "license": "MIT",+ "dependencies": {+ "fast-equals": "^5.0.1",+ "prop-types": "^15.8.1",+ "react-transition-group": "^4.4.5"+ },+ "peerDependencies": {+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"+ }+ },"node_modules/react-style-singleton": {"version": "2.2.1","resolved": "https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.2.1.tgz",@@ -11344,6 +11430,22 @@}}},+ "node_modules/react-transition-group": {+ "version": "4.4.5",+ "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz",+ "integrity": "sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==",+ "license": "BSD-3-Clause",+ "dependencies": {+ "@babel/runtime": "^7.5.5",+ "dom-helpers": "^5.0.1",+ "loose-envify": "^1.4.0",+ "prop-types": "^15.6.2"+ },+ "peerDependencies": {+ "react": ">=16.6.0",+ "react-dom": ">=16.6.0"+ }+ },"node_modules/read-cache": {"version": "1.0.0","resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",@@ -11374,6 +11476,38 @@"url": "https://github.com/sponsors/jonschlinkert"}},+ "node_modules/recharts": {+ "version": "2.12.7",+ "resolved": "https://registry.npmjs.org/recharts/-/recharts-2.12.7.tgz",+ "integrity": "sha512-hlLJMhPQfv4/3NBSAyq3gzGg4h2v69RJh6KU7b3pXYNNAELs9kEoXOjbkxdXpALqKBoVmVptGfLpxdaVYqjmXQ==",+ "license": "MIT",+ "dependencies": {+ "clsx": "^2.0.0",+ "eventemitter3": "^4.0.1",+ "lodash": "^4.17.21",+ "react-is": "^16.10.2",+ "react-smooth": "^4.0.0",+ "recharts-scale": "^0.4.4",+ "tiny-invariant": "^1.3.1",+ "victory-vendor": "^36.6.8"+ },+ "engines": {+ "node": ">=14"+ },+ "peerDependencies": {+ "react": "^16.0.0 || ^17.0.0 || ^18.0.0",+ "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0"+ }+ },+ "node_modules/recharts-scale": {+ "version": "0.4.5",+ "resolved": "https://registry.npmjs.org/recharts-scale/-/recharts-scale-0.4.5.tgz",+ "integrity": "sha512-kivNFO+0OcUNu7jQquLXAxz1FIwZj8nrj+YkOKc5694NbjCvcT6aSZiIzNzd2Kul4o4rTto8QVR9lMNtxD4G1w==",+ "license": "MIT",+ "dependencies": {+ "decimal.js-light": "^2.4.1"+ }+ },"node_modules/redent": {"version": "3.0.0","resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz",@@ -12229,6 +12363,12 @@"node": ">=0.8"}},+ "node_modules/tiny-invariant": {+ "version": "1.3.3",+ "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz",+ "integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==",+ "license": "MIT"+ },"node_modules/tippy.js": {"version": "6.3.7","resolved": "https://registry.npmjs.org/tippy.js/-/tippy.js-6.3.7.tgz",@@ -12712,6 +12852,46 @@"node": ">=10.12.0"}},+ "node_modules/victory-vendor": {+ "version": "36.9.2",+ "resolved": "https://registry.npmjs.org/victory-vendor/-/victory-vendor-36.9.2.tgz",+ "integrity": "sha512-PnpQQMuxlwYdocC8fIJqVXvkeViHYzotI+NJrCuav0ZYFoq912ZHBk3mCeuj+5/VpodOjPe1z0Fk2ihgzlXqjQ==",+ "license": "MIT AND ISC",+ "dependencies": {+ "@types/d3-array": "^3.0.3",+ "@types/d3-ease": "^3.0.0",+ "@types/d3-interpolate": "^3.0.1",+ "@types/d3-scale": "^4.0.2",+ "@types/d3-shape": "^3.1.0",+ "@types/d3-time": "^3.0.0",+ "@types/d3-timer": "^3.0.0",+ "d3-array": "^3.1.6",+ "d3-ease": "^3.0.1",+ "d3-interpolate": "^3.0.1",+ "d3-scale": "^4.0.2",+ "d3-shape": "^3.1.0",+ "d3-time": "^3.0.0",+ "d3-timer": "^3.0.1"+ }+ },+ "node_modules/victory-vendor/node_modules/@types/d3-time": {+ "version": "3.0.3",+ "resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-3.0.3.tgz",+ "integrity": "sha512-2p6olUZ4w3s+07q3Tm2dbiMZy5pCDfYwtLXXHUnVzXgQlZ/OyPtUz6OL382BkOuGlLXqfT+wqv8Fw2v8/0geBw==",+ "license": "MIT"+ },+ "node_modules/victory-vendor/node_modules/d3-time": {+ "version": "3.1.0",+ "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz",+ "integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==",+ "license": "ISC",+ "dependencies": {+ "d3-array": "2 - 3"+ },+ "engines": {+ "node": ">=12"+ }+ },"node_modules/w3c-keyname": {"version": "2.2.8","resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",diff --git a/package.json b/package.jsonindex a3ab542..b77f4b9 100644--- a/package.json+++ b/package.json@@ -54,6 +54,7 @@"react-day-picker": "^8.10.1","react-dom": "^18","react-hook-form": "^7.51.5",+ "recharts": "^2.12.7","tailwind-merge": "^2.3.0","tailwindcss-animate": "^1.0.7","zod": "^3.23.8"diff --git a/src/app/globals.css b/src/app/globals.cssindex 221d925..9035f87 100644--- a/src/app/globals.css+++ b/src/app/globals.css@@ -24,6 +24,11 @@--input: 214.3 31.8% 91.4%;--ring: 221.2 83.2% 53.3%;--radius: 0.5rem;+ --chart-1: 12 76% 61%;+ --chart-2: 173 58% 39%;+ --chart-3: 197 37% 24%;+ --chart-4: 43 74% 66%;+ --chart-5: 27 87% 67%;}.dark {@@ -46,6 +51,11 @@--border: 217.2 32.6% 23.5%;--input: 217.2 32.6% 21.5%;--ring: 224.3 76.3% 48%;+ --chart-1: 220 70% 50%;+ --chart-2: 160 60% 45%;+ --chart-3: 30 80% 55%;+ --chart-4: 280 65% 60%;+ --chart-5: 340 75% 55%;}}diff --git a/src/components/RadialChart.tsx b/src/components/RadialChart.tsxnew file mode 100644index 0000000..2d158f0--- /dev/null+++ b/src/components/RadialChart.tsx@@ -0,0 +1,83 @@+"use client";++import { Label, PolarRadiusAxis, RadialBar, RadialBarChart } from "recharts";++import {+ ChartConfig,+ ChartContainer,+ ChartTooltip,+ ChartTooltipContent,+} from "@/components/ui/chart";++const chartConfig = {+ score: {+ label: "Score",+ color: "hsl(var(--chart-2))",+ },+ improve: {+ label: "Improve",+ color: "hsl(var(--chart-1))",+ },+} satisfies ChartConfig;++export function RadialChartComponent({ score }: { score: number }) {+ const chartData = [{ score, improve: 100 - score }];+ return (+ <ChartContainer+ config={chartConfig}+ className="mx-auto aspect-square w-full max-w-[180px] max-h-[180px]"+ >+ <RadialBarChart+ data={chartData}+ endAngle={180}+ innerRadius={80}+ outerRadius={130}+ >+ <ChartTooltip+ cursor={false}+ content={<ChartTooltipContent hideLabel />}+ />+ <PolarRadiusAxis tick={false} tickLine={false} axisLine={false}>+ <Label+ content={({ viewBox }) => {+ if (viewBox && "cx" in viewBox && "cy" in viewBox) {+ return (+ <text x={viewBox.cx} y={viewBox.cy} textAnchor="middle">+ <tspan+ x={viewBox.cx}+ y={(viewBox.cy || 0) - 16}+ className="fill-foreground text-2xl font-bold"+ >+ {score.toLocaleString()}+ </tspan>+ <tspan+ x={viewBox.cx}+ y={(viewBox.cy || 0) + 4}+ className="fill-muted-foreground"+ >+ Score+ </tspan>+ </text>+ );+ }+ }}+ />+ </PolarRadiusAxis>+ <RadialBar+ dataKey="improve"+ stackId="a"+ cornerRadius={5}+ fill="var(--color-improve)"+ className="stroke-transparent stroke-2"+ />+ <RadialBar+ dataKey="score"+ fill="var(--color-score)"+ stackId="a"+ cornerRadius={5}+ className="stroke-transparent stroke-2"+ />+ </RadialBarChart>+ </ChartContainer>+ );+}diff --git a/src/components/profile/AiJobMatchResponseContent.tsx b/src/components/profile/AiJobMatchResponseContent.tsxindex 2840411..a5a49a8 100644--- a/src/components/profile/AiJobMatchResponseContent.tsx+++ b/src/components/profile/AiJobMatchResponseContent.tsx@@ -1,3 +1,4 @@+import { RadialChartComponent } from "../RadialChart";import { SheetDescription } from "../ui/sheet";import { parse } from "best-effort-json-parser";@@ -6,10 +7,10 @@ export const AiJobMatchResponseContent = ({ content }: { content: any }) => {<><div className="pt-2">{content.length > 1 && parse(content).matching_score && (- <h2>Score: {parse(content).matching_score}</h2>+ <RadialChartComponent score={parse(content).matching_score} />)}</div>- <div className="pt-2">+ <div>{content.length > 1 && parse(content).detailed_analysis && (<><h2 className="font-semibold">Detailed Analysis:</h2>diff --git a/src/components/profile/AiJobMatchSection.tsx b/src/components/profile/AiJobMatchSection.tsxindex 4727b5a..f056a9c 100644--- a/src/components/profile/AiJobMatchSection.tsx+++ b/src/components/profile/AiJobMatchSection.tsx@@ -22,6 +22,7 @@ import {import Loading from "../Loading";import { JobMatchResponse } from "@/models/ai.model";import { AiJobMatchResponseContent } from "./AiJobMatchResponseContent";+import { RadialChartComponent } from "../RadialChart";interface AiSectionProps {aISectionOpen: boolean;diff --git a/src/components/ui/chart.tsx b/src/components/ui/chart.tsxnew file mode 100644index 0000000..8620baa--- /dev/null+++ b/src/components/ui/chart.tsx@@ -0,0 +1,365 @@+"use client"++import * as React from "react"+import * as RechartsPrimitive from "recharts"++import { cn } from "@/lib/utils"++// Format: { THEME_NAME: CSS_SELECTOR }+const THEMES = { light: "", dark: ".dark" } as const++export type ChartConfig = {+ [k in string]: {+ label?: React.ReactNode+ icon?: React.ComponentType+ } & (+ | { color?: string; theme?: never }+ | { color?: never; theme: Record<keyof typeof THEMES, string> }+ )+}++type ChartContextProps = {+ config: ChartConfig+}++const ChartContext = React.createContext<ChartContextProps | null>(null)++function useChart() {+ const context = React.useContext(ChartContext)++ if (!context) {+ throw new Error("useChart must be used within a <ChartContainer />")+ }++ return context+}++const ChartContainer = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div"> & {+ config: ChartConfig+ children: React.ComponentProps<+ typeof RechartsPrimitive.ResponsiveContainer+ >["children"]+ }+>(({ id, className, children, config, ...props }, ref) => {+ const uniqueId = React.useId()+ const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`++ return (+ <ChartContext.Provider value={{ config }}>+ <div+ data-chart={chartId}+ ref={ref}+ className={cn(+ "flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",+ className+ )}+ {...props}+ >+ <ChartStyle id={chartId} config={config} />+ <RechartsPrimitive.ResponsiveContainer>+ {children}+ </RechartsPrimitive.ResponsiveContainer>+ </div>+ </ChartContext.Provider>+ )+})+ChartContainer.displayName = "Chart"++const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {+ const colorConfig = Object.entries(config).filter(+ ([_, config]) => config.theme || config.color+ )++ if (!colorConfig.length) {+ return null+ }++ return (+ <style+ dangerouslySetInnerHTML={{+ __html: Object.entries(THEMES)+ .map(+ ([theme, prefix]) => `+${prefix} [data-chart=${id}] {+${colorConfig+ .map(([key, itemConfig]) => {+ const color =+ itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||+ itemConfig.color+ return color ? ` --color-${key}: ${color};` : null+ })+ .join("\n")}+}+`+ )+ .join("\n"),+ }}+ />+ )+}++const ChartTooltip = RechartsPrimitive.Tooltip++const ChartTooltipContent = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<typeof RechartsPrimitive.Tooltip> &+ React.ComponentProps<"div"> & {+ hideLabel?: boolean+ hideIndicator?: boolean+ indicator?: "line" | "dot" | "dashed"+ nameKey?: string+ labelKey?: string+ }+>(+ (+ {+ active,+ payload,+ className,+ indicator = "dot",+ hideLabel = false,+ hideIndicator = false,+ label,+ labelFormatter,+ labelClassName,+ formatter,+ color,+ nameKey,+ labelKey,+ },+ ref+ ) => {+ const { config } = useChart()++ const tooltipLabel = React.useMemo(() => {+ if (hideLabel || !payload?.length) {+ return null+ }++ const [item] = payload+ const key = `${labelKey || item.dataKey || item.name || "value"}`+ const itemConfig = getPayloadConfigFromPayload(config, item, key)+ const value =+ !labelKey && typeof label === "string"+ ? config[label as keyof typeof config]?.label || label+ : itemConfig?.label++ if (labelFormatter) {+ return (+ <div className={cn("font-medium", labelClassName)}>+ {labelFormatter(value, payload)}+ </div>+ )+ }++ if (!value) {+ return null+ }++ return <div className={cn("font-medium", labelClassName)}>{value}</div>+ }, [+ label,+ labelFormatter,+ payload,+ hideLabel,+ labelClassName,+ config,+ labelKey,+ ])++ if (!active || !payload?.length) {+ return null+ }++ const nestLabel = payload.length === 1 && indicator !== "dot"++ return (+ <div+ ref={ref}+ className={cn(+ "grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",+ className+ )}+ >+ {!nestLabel ? tooltipLabel : null}+ <div className="grid gap-1.5">+ {payload.map((item, index) => {+ const key = `${nameKey || item.name || item.dataKey || "value"}`+ const itemConfig = getPayloadConfigFromPayload(config, item, key)+ const indicatorColor = color || item.payload.fill || item.color++ return (+ <div+ key={item.dataKey}+ className={cn(+ "flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",+ indicator === "dot" && "items-center"+ )}+ >+ {formatter && item?.value !== undefined && item.name ? (+ formatter(item.value, item.name, item, index, item.payload)+ ) : (+ <>+ {itemConfig?.icon ? (+ <itemConfig.icon />+ ) : (+ !hideIndicator && (+ <div+ className={cn(+ "shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",+ {+ "h-2.5 w-2.5": indicator === "dot",+ "w-1": indicator === "line",+ "w-0 border-[1.5px] border-dashed bg-transparent":+ indicator === "dashed",+ "my-0.5": nestLabel && indicator === "dashed",+ }+ )}+ style={+ {+ "--color-bg": indicatorColor,+ "--color-border": indicatorColor,+ } as React.CSSProperties+ }+ />+ )+ )}+ <div+ className={cn(+ "flex flex-1 justify-between leading-none",+ nestLabel ? "items-end" : "items-center"+ )}+ >+ <div className="grid gap-1.5">+ {nestLabel ? tooltipLabel : null}+ <span className="text-muted-foreground">+ {itemConfig?.label || item.name}+ </span>+ </div>+ {item.value && (+ <span className="font-mono font-medium tabular-nums text-foreground">+ {item.value.toLocaleString()}+ </span>+ )}+ </div>+ </>+ )}+ </div>+ )+ })}+ </div>+ </div>+ )+ }+)+ChartTooltipContent.displayName = "ChartTooltip"++const ChartLegend = RechartsPrimitive.Legend++const ChartLegendContent = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div"> &+ Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {+ hideIcon?: boolean+ nameKey?: string+ }+>(+ (+ { className, hideIcon = false, payload, verticalAlign = "bottom", nameKey },+ ref+ ) => {+ const { config } = useChart()++ if (!payload?.length) {+ return null+ }++ return (+ <div+ ref={ref}+ className={cn(+ "flex items-center justify-center gap-4",+ verticalAlign === "top" ? "pb-3" : "pt-3",+ className+ )}+ >+ {payload.map((item) => {+ const key = `${nameKey || item.dataKey || "value"}`+ const itemConfig = getPayloadConfigFromPayload(config, item, key)++ return (+ <div+ key={item.value}+ className={cn(+ "flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"+ )}+ >+ {itemConfig?.icon && !hideIcon ? (+ <itemConfig.icon />+ ) : (+ <div+ className="h-2 w-2 shrink-0 rounded-[2px]"+ style={{+ backgroundColor: item.color,+ }}+ />+ )}+ {itemConfig?.label}+ </div>+ )+ })}+ </div>+ )+ }+)+ChartLegendContent.displayName = "ChartLegend"++// Helper to extract item config from a payload.+function getPayloadConfigFromPayload(+ config: ChartConfig,+ payload: unknown,+ key: string+) {+ if (typeof payload !== "object" || payload === null) {+ return undefined+ }++ const payloadPayload =+ "payload" in payload &&+ typeof payload.payload === "object" &&+ payload.payload !== null+ ? payload.payload+ : undefined++ let configLabelKey: string = key++ if (+ key in payload &&+ typeof payload[key as keyof typeof payload] === "string"+ ) {+ configLabelKey = payload[key as keyof typeof payload] as string+ } else if (+ payloadPayload &&+ key in payloadPayload &&+ typeof payloadPayload[key as keyof typeof payloadPayload] === "string"+ ) {+ configLabelKey = payloadPayload[+ key as keyof typeof payloadPayload+ ] as string+ }++ return configLabelKey in config+ ? config[configLabelKey]+ : config[key as keyof typeof config]+}++export {+ ChartContainer,+ ChartTooltip,+ ChartTooltipContent,+ ChartLegend,+ ChartLegendContent,+ ChartStyle,+}