@zydon/common 2.8.78 → 2.8.80

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.
Files changed (45) hide show
  1. package/dist/{chunk-ANEPP6QT.js → chunk-ERLI5GAP.js} +3 -3
  2. package/dist/{chunk-ANEPP6QT.js.map → chunk-ERLI5GAP.js.map} +1 -1
  3. package/dist/chunk-K2PWIYEM.js +4 -0
  4. package/dist/chunk-K2PWIYEM.js.map +1 -0
  5. package/dist/chunk-UQJKTFVZ.js +27 -0
  6. package/dist/chunk-UQJKTFVZ.js.map +1 -0
  7. package/dist/{chunk-SP5U3DJP.js → chunk-UWTX4JMW.js} +4 -4
  8. package/dist/chunk-UWTX4JMW.js.map +1 -0
  9. package/dist/components/Analytics/OverviewAnalytics/index.d.ts +1 -1
  10. package/dist/components/Analytics/OverviewAnalytics/index.js +2 -2
  11. package/dist/components/Analytics/OverviewAnalytics/index.js.map +1 -1
  12. package/dist/components/Analytics/PartnerAnalysis/index.d.ts +82 -2
  13. package/dist/components/Analytics/PartnerAnalysis/index.js +35 -17
  14. package/dist/components/Analytics/PartnerAnalysis/index.js.map +1 -1
  15. package/dist/components/Analytics/index.d.ts +2 -1
  16. package/dist/components/Analytics/index.js +2 -2
  17. package/dist/components/Analytics/index.js.map +1 -1
  18. package/dist/components/Avatar/index.d.ts +1 -1
  19. package/dist/components/DataView/index.d.ts +1 -1
  20. package/dist/components/DataView/index.js +1 -1
  21. package/dist/components/DynamicDataView/index.js +1 -1
  22. package/dist/hooks/useSnackbar.d.ts +1 -1
  23. package/dist/index.d.ts +2 -2
  24. package/dist/theme/core/index.d.ts +1 -1
  25. package/dist/theme/styles/index.d.ts +13 -13
  26. package/dist/types/analytics.d.ts +3 -23
  27. package/dist/types/analytics.js +1 -1
  28. package/dist/types/overviewAnalytics.d.ts +1 -1
  29. package/dist/types/partnerAnalysis.d.ts +4 -27
  30. package/dist/types/partnerAnalysis.js +1 -1
  31. package/dist/utils/analytics.d.ts +24 -0
  32. package/dist/utils/analytics.js +2 -0
  33. package/dist/utils/analytics.js.map +1 -0
  34. package/dist/utils/partnerAnalysis.d.ts +28 -0
  35. package/dist/utils/partnerAnalysis.js +2 -0
  36. package/dist/utils/partnerAnalysis.js.map +1 -0
  37. package/dist/utils/periodDates.d.ts +2 -1
  38. package/dist/utils/periodDates.js +2 -2
  39. package/package.json +1 -1
  40. package/dist/chunk-BHYLHO5P.js +0 -4
  41. package/dist/chunk-BHYLHO5P.js.map +0 -1
  42. package/dist/chunk-SP5U3DJP.js.map +0 -1
  43. package/dist/chunk-Z275MVEP.js +0 -27
  44. package/dist/chunk-Z275MVEP.js.map +0 -1
  45. package/dist/{index-c8f1e6e7.d.ts → index-5a5e5dc8.d.ts} +12 -12
@@ -1,6 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
- import { RankingItem, RankingType, SellerPortfolioQueryType } from '../../../types/partnerAnalysis.js';
3
+ import { ReactNode } from 'react';
4
+ import { GridColDef } from '@mui/x-data-grid-premium';
5
+ import { DashboardPartner, RankingItem } from '../../../types/partnerAnalysis.js';
6
+ import { RankingType, SellerPortfolioQueryType } from '../../../utils/partnerAnalysis.js';
4
7
  import * as _emotion_styled from '@emotion/styled';
5
8
  import * as _mui_system from '@mui/system';
6
9
  import * as _mui_material_styles from '@mui/material/styles';
@@ -63,6 +66,44 @@ interface SegmentChartItem {
63
66
 
64
67
  declare const PartnersByProfile: ({ data, chartData, total, isEmptyData, onPieClick, onLegendClick, hiddenKeys, onToggle, }: PartnersByProfileProps) => react_jsx_runtime.JSX.Element;
65
68
 
69
+ interface PartnersDetailProps {
70
+ open: boolean;
71
+ onClose: VoidFunction;
72
+ title: string;
73
+ label: string;
74
+ columns: GridColDef[];
75
+ rows: DashboardPartner[];
76
+ totalPartners: number;
77
+ isLoading: boolean;
78
+ isFetching: boolean;
79
+ isFetchingNextPage?: boolean;
80
+ onSearch: (value: string) => void;
81
+ onRowsScrollEnd?: () => void;
82
+ sellerName?: string;
83
+ buildSellerLink?: (sellerId: string) => string;
84
+ sellerExternalId?: string;
85
+ mobileRender: (data: DashboardPartner) => ReactNode;
86
+ }
87
+
88
+ declare const PartnersDetail: ({ open, onClose, title, label, columns, rows, totalPartners, isLoading, isFetching, isFetchingNextPage, onSearch, onRowsScrollEnd, sellerName, buildSellerLink, sellerExternalId, mobileRender, }: PartnersDetailProps) => react_jsx_runtime.JSX.Element;
89
+
90
+ interface ProfileDetailProps {
91
+ open: boolean;
92
+ onClose: VoidFunction;
93
+ profileName: string;
94
+ columns: GridColDef[];
95
+ rows: DashboardPartner[];
96
+ totalPartners: number;
97
+ isLoading: boolean;
98
+ isFetching: boolean;
99
+ isFetchingNextPage?: boolean;
100
+ onSearch: (value: string) => void;
101
+ onRowsScrollEnd?: () => void;
102
+ mobileRender: (data: DashboardPartner) => ReactNode;
103
+ }
104
+
105
+ declare const ProfileDetail: ({ open, onClose, profileName, columns, rows, totalPartners, isLoading, isFetching, isFetchingNextPage, onSearch, onRowsScrollEnd, mobileRender, }: ProfileDetailProps) => react_jsx_runtime.JSX.Element;
106
+
66
107
  interface RankingTypeConfig {
67
108
  label: string;
68
109
  color: string;
@@ -94,6 +135,45 @@ declare const ItemButton: _emotion_styled.StyledComponent<_mui_material_Button.B
94
135
  ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
95
136
  }, "children" | "disabled" | "className" | "style" | "classes" | "sx" | "variant" | "color" | "tabIndex" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "size" | "href" | "fullWidth" | "disableElevation" | "disableFocusRipple" | "endIcon" | "startIcon"> & _mui_system.MUIStyledCommonProps<_mui_material_styles.Theme> & ItemButtonProps, {}, {}>;
96
137
 
138
+ interface RankingDetailBaseProps {
139
+ open: boolean;
140
+ onClose: VoidFunction;
141
+ partner: RankingItem | null;
142
+ rankingLabel: string;
143
+ startDate: string;
144
+ endDate: string;
145
+ }
146
+ interface RankingDetailOrder {
147
+ id: string;
148
+ partner?: {
149
+ id: string;
150
+ name: string;
151
+ };
152
+ total_value: number;
153
+ negotiation_date?: Date | string;
154
+ status?: string;
155
+ }
156
+ interface RankingDetailProps {
157
+ open: boolean;
158
+ onClose: VoidFunction;
159
+ partnerName: string;
160
+ rankingLabel: string;
161
+ rows: RankingDetailOrder[];
162
+ total: number;
163
+ totalValue: number;
164
+ averageTicket: number;
165
+ isLoading: boolean;
166
+ isFetching: boolean;
167
+ page: number;
168
+ perPage: number;
169
+ onSearch: (value: string) => void;
170
+ onPaginationChange: (page: number, pageSize: number) => void;
171
+ buildPartnerLink?: (partnerId: string) => string;
172
+ mobileItemSlot?: (row: RankingDetailOrder) => ReactNode;
173
+ }
174
+
175
+ declare const RankingDetail: ({ open, onClose, partnerName, rankingLabel, rows, total, totalValue, averageTicket, isLoading, isFetching, page, perPage, onSearch, onPaginationChange, buildPartnerLink, mobileItemSlot, }: RankingDetailProps) => react_jsx_runtime.JSX.Element;
176
+
97
177
  interface StackedBarSeries {
98
178
  dataKey: string;
99
179
  name: string;
@@ -119,4 +199,4 @@ declare const SELLER_PORTFOLIO_CONFIG: Record<SellerPortfolioQueryType, SellerPo
119
199
 
120
200
  declare const SellerPortfolio: ({ data, config, onBarClick, children, }: SellerPortfolioProps) => react_jsx_runtime.JSX.Element;
121
201
 
122
- export { ChartItem as BreakdownChartItem, LegendItem$1 as BreakdownLegendItem, ChartDataRow, MAX_VISIBLE as PROFILE_MAX_VISIBLE, PartnerBreakdown, PartnerBreakdownProps, PartnersByProfile, PartnersByProfileProps, LegendItem as ProfileLegendItem, RANKING_CONFIG, Ranking, ItemButton as RankingItemButton, RankingProps, RankingTypeConfig, SEGMENT_COLORS, SELLER_PORTFOLIO_CONFIG, SegmentChartItem, SellerPortfolio, SellerPortfolioProps, SellerPortfolioTypeConfig };
202
+ export { ChartItem as BreakdownChartItem, LegendItem$1 as BreakdownLegendItem, ChartDataRow, MAX_VISIBLE as PROFILE_MAX_VISIBLE, PartnerBreakdown, PartnerBreakdownProps, PartnersByProfile, PartnersByProfileProps, PartnersDetail, PartnersDetailProps, ProfileDetail, ProfileDetailProps, LegendItem as ProfileLegendItem, RANKING_CONFIG, Ranking, RankingDetail, RankingDetailBaseProps, RankingDetailOrder, RankingDetailProps, ItemButton as RankingItemButton, RankingProps, RankingTypeConfig, SEGMENT_COLORS, SELLER_PORTFOLIO_CONFIG, SegmentChartItem, SellerPortfolio, SellerPortfolioProps, SellerPortfolioTypeConfig };
@@ -1,28 +1,46 @@
1
- import '../../../chunk-BHYLHO5P.js';
2
- import { b as b$2, a as a$2 } from '../../../chunk-XL6SZZGI.js';
1
+ import '../../../chunk-K2PWIYEM.js';
2
+ import { b as b$2, a as a$5 } from '../../../chunk-XL6SZZGI.js';
3
3
  import { a, b as b$1, m, n, c } from '../../../chunk-XQZPUMVQ.js';
4
- import { a as a$5 } from '../../../chunk-DRGARBKB.js';
5
- import { h, d, a as a$3, c as c$1 } from '../../../chunk-OF6623HG.js';
4
+ import { a as a$8 } from '../../../chunk-DRGARBKB.js';
5
+ import { a as a$4 } from '../../../chunk-J5B2YJSR.js';
6
+ import { a as a$3 } from '../../../chunk-CBW32OUQ.js';
7
+ import { d as d$2 } from '../../../chunk-N7IK5EUP.js';
8
+ import { h, d, a as a$6, c as c$1 } from '../../../chunk-OF6623HG.js';
9
+ import { d as d$1 } from '../../../chunk-UQJKTFVZ.js';
10
+ import { a as a$2 } from '../../../chunk-R2BCPHRH.js';
6
11
  import { a as a$1 } from '../../../chunk-4F2NKGF6.js';
7
- import { a as a$4 } from '../../../chunk-F65ZXAGV.js';
12
+ import '../../../chunk-NMGWHSNZ.js';
13
+ import '../../../chunk-6U5LS7MP.js';
14
+ import '../../../chunk-LZQ7OFKO.js';
15
+ import '../../../chunk-NIQW2J3M.js';
16
+ import '../../../chunk-PRWQQJDL.js';
17
+ import '../../../chunk-XUDTPZHF.js';
18
+ import '../../../chunk-UVPQR2Q2.js';
19
+ import '../../../chunk-RBTYTONM.js';
20
+ import { a as a$7 } from '../../../chunk-F65ZXAGV.js';
21
+ import '../../../chunk-I4PPSW36.js';
22
+ import '../../../chunk-CO2KQFUN.js';
8
23
  import '../../../chunk-2GTD4JW2.js';
9
24
  import '../../../chunk-PBLSVXV5.js';
25
+ import '../../../chunk-LQRRMVFN.js';
10
26
  import { b } from '../../../chunk-2ZJUGM2S.js';
11
- import Lt from '@mui/material/CardContent';
12
- import At from '@mui/material/CardHeader';
13
- import N from '@mui/material/Stack';
27
+ import '../../../chunk-GLRLKFPS.js';
28
+ import st from '@mui/material/CardContent';
29
+ import pt from '@mui/material/CardHeader';
30
+ import T from '@mui/material/Stack';
14
31
  import { ResponsiveContainer, ComposedChart, CartesianGrid, XAxis, YAxis, Tooltip, ReferenceLine, Bar, PieChart, Pie, BarChart } from 'recharts';
15
- import { styled } from '@mui/material/styles';
16
- import Ct from '@mui/material/Divider';
17
- import ae from '@mui/material/Typography';
32
+ import { styled, alpha } from '@mui/material/styles';
33
+ import qr from '@mui/material/Divider';
34
+ import C from '@mui/material/Typography';
18
35
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
19
- import ot from '@mui/material/Checkbox';
20
- import at from '@mui/material/FormControlLabel';
36
+ import Lr from '@mui/material/Checkbox';
37
+ import Ar from '@mui/material/FormControlLabel';
38
+ import zt from '@mui/material/Link';
21
39
  import { memo, useState, useRef, useCallback, useMemo } from 'react';
22
- import Lr from '@mui/material/Slider';
23
- import Er from '@mui/material/Button';
40
+ import So from '@mui/material/Slider';
41
+ import Po from '@mui/material/Button';
24
42
 
25
- var Fe=styled(N)(({theme:e})=>({position:"relative",alignSelf:"flex-start",flexShrink:0,"& .recharts-wrapper, & .recharts-wrapper *":{outline:"none !important",boxShadow:"none !important"},"& .recharts-pie-sector":{cursor:"pointer"},[e.breakpoints.down("md")]:{alignSelf:"center"}}));var De=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),bt=({active:e,payload:t,total:a})=>{if(!e||!t?.length)return null;let r=t[0];return jsxs(a$5,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(ae,{variant:"body2",color:"text.secondary",children:r.name}),jsx(Ct,{}),jsxs(N,{children:[jsxs(N,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(N,{direction:"row",alignItems:"center",gap:1,children:[jsx(N,{width:6,height:6,borderRadius:"50%",bgcolor:r.payload.fill}),jsx(ae,{variant:"body2",noWrap:!0,children:r.name})]}),jsxs(ae,{variant:"body2",noWrap:!0,children:[De(r.payload.percentage)," (",r.value,")"]})]}),jsxs(N,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(N,{direction:"row",alignItems:"center",gap:1,children:[jsx(N,{width:6,height:6,borderRadius:"50%",bgcolor:"#919EAB"}),jsx(ae,{variant:"body2",noWrap:!0,children:"Total"})]}),jsxs(ae,{variant:"body2",noWrap:!0,children:[De(100)," (",a,")"]})]})]})]})},Me=bt;var Pt=({chartData:e,total:t,isEmptyData:a,onPieClick:r,clickable:o})=>jsx(Fe,{children:jsx(ResponsiveContainer,{width:200,height:200,children:jsxs(PieChart,{children:[jsx(Pie,{data:e,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:60,outerRadius:90,paddingAngle:2,strokeWidth:0,isAnimationActive:!1,onClick:r,cursor:o?"pointer":void 0}),jsx("text",{x:"50%",y:"46%",textAnchor:"middle",dominantBaseline:"middle",style:{fontSize:24,fontWeight:700},children:a$3(t)}),jsx("text",{x:"50%",y:"58%",textAnchor:"middle",dominantBaseline:"middle",style:{fontSize:12,fill:"#919EAB"},children:"clientes"}),!a&&jsx(Tooltip,{content:jsx(Me,{total:t})})]})})}),Ke=Pt;var Bt=({items:e,hiddenKeys:t,onToggle:a,onItemClick:r})=>jsx(N,{width:"100%",justifyContent:"center",children:e.map(o=>jsxs(N,{display:"grid",gridTemplateColumns:"1fr auto auto",alignItems:"center",gap:1.5,onClick:()=>r?.(o.key,o.label),sx:{...r?{cursor:"pointer"}:{}},children:[jsx(at,{label:o.label,onClick:i=>i.stopPropagation(),control:jsx(ot,{size:"small",checked:!t.has(o.key),onChange:(i,n)=>a(o.key,n),sx:{"&.Mui-checked":{color:o.color}}}),sx:{"& .MuiFormControlLabel-label":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}}}),jsx(ae,{variant:"body2",color:"text.secondary",textAlign:"right",noWrap:!0,children:c$1(o.percentage,{maximumFractionDigits:2,...o.percentage>0&&o.percentage<100?{minimumFractionDigits:2}:{}})}),jsx(ae,{variant:"subtitle2",color:"text.primary",textAlign:"right",noWrap:!0,children:d(o.count)})]},o.key))}),Oe=Bt;var _t=({title:e,chartData:t,total:a$1,isEmptyData:r,legendItems:o,hiddenKeys:i,onToggle:n,onPieClick:p,onItemClick:c})=>jsxs(a,{children:[jsx(At,{title:e}),jsx(Lt,{children:jsxs(N,{direction:{xs:"column",sm:"row"},alignItems:"center",gap:1.5,minWidth:0,children:[jsx(Ke,{chartData:t,total:a$1,isEmptyData:r,onPieClick:p,clickable:!!p}),jsx(Oe,{items:o,hiddenKeys:i,onToggle:n,onItemClick:c})]})})]}),Ft=_t;var ze=Math.PI/180,Ge=22,Dt=2,Mt=e=>{let{cx:t,cy:a,midAngle:r,outerRadius:o,percentage:i}=e;if(i<Dt)return null;let n=Number(t),p=Number(a),c=Number(o),u=Number(r);if(isNaN(n)||isNaN(p)||isNaN(c))return null;let v=Math.sin(-u*ze),P=Math.cos(-u*ze),R=n+c*P,B=p+c*v,y=n+(c+Ge*.5)*P,s=p+(c+Ge*.5)*v,l=P>=0?1:-1,d=y+l*10,h=s,b=c$1(i,{maximumFractionDigits:1,...i>0&&i<100?{minimumFractionDigits:1}:{}}),g=b.length*7+10,T=l===1?d+2:d-g-2;return jsxs("g",{children:[jsx("path",{d:`M${R},${B} L${y},${s} L${d},${h}`,stroke:"#637381",fill:"none",strokeWidth:1}),jsx("rect",{x:T,y:h-10,width:g,height:20,rx:4,fill:"#212B36"}),jsx("text",{x:T+g/2,y:h,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fontWeight:600,fill:"#FFFFFF",children:b})]})},He=Mt;var Xe=styled(N)({position:"relative",alignItems:"center",justifyContent:"center","& .recharts-wrapper, & .recharts-wrapper *":{outline:"none !important",boxShadow:"none !important"},"& .recharts-wrapper":{overflow:"visible !important"},"& .recharts-wrapper svg":{overflow:"visible"},"& .recharts-pie-sector":{cursor:"pointer"}});var Ye=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),Vt=({active:e,payload:t,total:a})=>{if(!e||!t?.length)return null;let r=t[0];return jsxs(a$5,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(ae,{variant:"body2",color:"text.secondary",children:r.name}),jsx(Ct,{}),jsxs(N,{children:[jsxs(N,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(N,{direction:"row",alignItems:"center",gap:1,children:[jsx(N,{width:6,height:6,borderRadius:"50%",bgcolor:r.payload.fill}),jsx(ae,{variant:"body2",noWrap:!0,children:r.name})]}),jsxs(ae,{variant:"body2",noWrap:!0,children:[Ye(r.payload.percentage)," (",r.value,")"]})]}),jsxs(N,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(N,{direction:"row",alignItems:"center",gap:1,children:[jsx(N,{width:6,height:6,borderRadius:"50%",bgcolor:"#919EAB"}),jsx(ae,{variant:"body2",noWrap:!0,children:"Total"})]}),jsxs(ae,{variant:"body2",noWrap:!0,children:[Ye(100)," (",a,")"]})]})]})]})},$e=Vt;var Yt=e=>jsx(He,{...e}),$t=({chartData:e,total:t,isEmptyData:a,onPieClick:r})=>jsx(Xe,{children:jsx(ResponsiveContainer,{width:280,height:280,children:jsxs(PieChart,{children:[jsx(Pie,{data:e,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:90,paddingAngle:1,strokeWidth:0,isAnimationActive:!1,label:a?!1:Yt,labelLine:!1,onClick:r,cursor:r?"pointer":void 0}),!a&&jsx(Tooltip,{content:jsx($e,{total:t})})]})})}),Ue=$t;var Jt=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),jt=({items:e,hiddenKeys:t,onToggle:a,onItemClick:r})=>jsx(a$4,{sx:{maxHeight:280,width:"100%",pl:.5},children:e.map(o=>jsxs(N,{display:"grid",gridTemplateColumns:"1fr auto auto",alignItems:"center",gap:1.5,onClick:()=>r?.(o.key),sx:r?{cursor:"pointer"}:void 0,children:[jsx(at,{label:o.label,onClick:i=>i.stopPropagation(),control:jsx(ot,{size:"small",checked:!t.has(o.key),onChange:(i,n)=>a(o.key,n),sx:{"&.Mui-checked":{color:o.color}}}),sx:{"& .MuiFormControlLabel-label":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}}}),jsx(ae,{variant:"body2",color:"text.secondary",textAlign:"right",noWrap:!0,children:Jt(o.percentage)}),jsx(ae,{variant:"subtitle2",color:"text.primary",textAlign:"right",noWrap:!0,children:d(o.count)})]},o.key))}),Ze=jt;var ar=({data:e,chartData:t,total:a$2,isEmptyData:r,onPieClick:o,onLegendClick:i,hiddenKeys:n,onToggle:p})=>jsxs(a,{children:[jsx(At,{title:"Clientes por segmentos"}),jsx(Lt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(N,{alignItems:"center",gap:2,children:[jsx(Ue,{chartData:t,total:a$2,isEmptyData:r,onPieClick:o}),jsx(Ze,{items:e,hiddenKeys:n,onToggle:p,onItemClick:i})]})})})]}),nr=ar;var ir=["#FF5630","#FFAB00","#22C55E","#C4CDD5","#8E33FF","#00B8D9","#3366FF","#FF6C40","#36B37E","#B76E00"],lr=12;var V="#212B36",sr={["SALE_TOTAL_VALUE"]:{label:"Por valor total",color:"#22C55E",dataKey:"total_sale_value",barName:"Valor total por cliente",averageName:"M\xE9dia total de valor por cliente",averageDataKey:"average_total_value",formatLabel:h,formatYAxis:d},["SALE_COUNT"]:{label:"Por pedidos",color:"#C684FF",dataKey:"total_value_by_customer",barName:"Quantidade de pedidos",averageName:"Quantidade total de pedidos",averageDataKey:"average_sale_count",formatLabel:String,formatYAxis:d,floorAverage:!0},["SALE_AVERAGE_VALUE"]:{label:"Por ticket m\xE9dio",color:"#00B8D9",dataKey:"total_sale_value",barName:"Ticket m\xE9dio por cliente",averageName:"M\xE9dia do ticket m\xE9dio",averageDataKey:"average_ticket",formatLabel:h,formatYAxis:d}};var mr=({x:e=0,y:t=0,width:a=0,height:r=0,index:o=0,activeBarIndex:i,color:n,data:p,onBarClick:c})=>i!==o?null:jsx("rect",{x:e-6,y:t,width:a+12,height:r+6,fill:n,opacity:.16,rx:6,style:{cursor:"pointer"},onClick:()=>c(p[o])}),Je=mr;var dr=({active:e,payload:t,label:a,config:r,average:o})=>!e||!t?.length?null:jsxs(a$5,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(ae,{variant:"body2",color:"text.secondary",children:a}),jsx(Ct,{}),jsxs(N,{children:[t.map((i,n)=>jsxs(N,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${n}`,children:[jsxs(N,{direction:"row",alignItems:"center",gap:1,children:[jsx(N,{width:6,height:6,borderRadius:"50%",bgcolor:i.color}),jsx(ae,{variant:"body2",noWrap:!0,children:r.barName})]}),jsx(ae,{variant:"body2",children:r.formatLabel(i.value)})]},i.dataKey)),jsxs(N,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(N,{direction:"row",alignItems:"center",gap:1,children:[jsx(N,{width:6,height:6,borderRadius:"50%",bgcolor:V}),jsx(ae,{variant:"body2",noWrap:!0,children:r.averageName})]}),jsx(ae,{variant:"body2",children:r.formatLabel(o)})]})]})]}),je=dr;var kr=48,Sr=kr/.8,xr=({data:e,config:t,visibleSeries:a,average:r,activeBarIndex:o,activeCoordX:i,shouldRotateLabels:n$1,onMouseMove:p,onMouseLeave:c$1,onBarClick:u})=>{let v=useMemo(()=>{if(!e.length)return [0,1];let l=e.map(h=>h[t.dataKey]||0);a.average&&r>0&&l.push(r);let d=Math.max(...l);return [0,d>0?d*1.15:1]},[e,t.dataKey,r,a.average]),P=useMemo(()=>{let[,l]=v,d=l/6;return [...new Set(Array.from({length:7},(h,b)=>Math.round(d*b)))]},[v]),R=useMemo(()=>n$1?!1:{position:"top",fontSize:11,fill:"#212B36",formatter:l=>t.formatLabel(Number(l))},[n$1,t]),B=useMemo(()=>jsx(je,{config:t,average:r}),[t,r]),y=useCallback(l=>n$1?jsx(n,{...l}):jsx(b$2,{x:l.x,y:l.y,payload:l.payload,slotWidth:Sr}),[n$1]),s=useCallback(l=>{l&&u(l);},[u]);return jsx(c,{children:jsx(ResponsiveContainer,{width:"100%",height:350,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:0,left:20},barCategoryGap:"20%",onMouseMove:p,onMouseLeave:c$1,children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"partner_name",axisLine:!1,tickLine:!1,interval:0,height:n$1?70:50,tick:y}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:l=>d(l),domain:v,ticks:P}),jsx(Tooltip,{content:B}),a.average&&r>0&&jsx(ReferenceLine,{y:r,stroke:V,strokeDasharray:"8 4",strokeWidth:2,ifOverflow:"extendDomain"}),a.average&&r>0&&jsx(ReferenceLine,{y:r,stroke:"none",ifOverflow:"extendDomain",label:jsx(a$2,{activeCoordX:i,referenceCircleColor:V,activeIndex:o})}),a.bar&&jsx(Bar,{dataKey:t.dataKey,name:t.barName,fill:t.color,maxBarSize:48,isAnimationActive:!1,radius:[4,4,0,0],cursor:"pointer",onClick:s,background:jsx(Je,{activeBarIndex:o,color:t.color,data:e,onBarClick:u}),label:R})]})})})},rt=xr;var Rr=({visibleSeries:e,config:t,onToggleSerie:a})=>jsxs(N,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(at,{control:jsx(ot,{checked:e.bar,onChange:()=>a("bar"),sx:{"&.Mui-checked":{color:t.color}}}),label:t.barName}),jsx(at,{control:jsx(ot,{checked:e.average,onChange:()=>a("average"),sx:{"&.Mui-checked":{color:V}}}),label:t.averageName})]}),nt=Rr;var st=memo(({data:e,config:t,average:a$2,onBarClick:r,children:o})=>{let i=b("down","sm"),n=b("down","lg"),[p,c]=useState({bar:!0,average:!0}),[u,v]=useState(12),[P,R]=useState(null),[B,y]=useState(null),[s,l]=useState(0),d=useRef(null),h=useCallback(m=>{d.current&&(d.current.disconnect(),d.current=null),m&&(l(m.clientWidth),d.current=new ResizeObserver(()=>l(m.clientWidth)),d.current.observe(m));},[]),b$2=useMemo(()=>[...e].sort((m,S)=>S[t.dataKey]-m[t.dataKey]),[e,t.dataKey]),g=b$2.length,T=useMemo(()=>i?10:n?25:30,[i,n]),ke=!i&&g>10,re=Math.min(g,T),oe=Math.min(i?g:u,g,T),K=useMemo(()=>b$2.slice(0,oe),[b$2,oe]),Se=useMemo(()=>s===0||K.length===0?!1:(s-60)/K.length<80,[s,K.length]),xe=useCallback(m=>{c(S=>({...S,[m]:!S[m]}));},[]),ve=useCallback(m=>{m?.activeTooltipIndex!=null&&R(Number(m.activeTooltipIndex)),m?.activeCoordinate?.x!=null&&y(m.activeCoordinate.x);},[]),Pe=useCallback(()=>{R(null),y(null);},[]),Re=useCallback(m=>{m&&r?.(m);},[r]),f=useCallback((m,S)=>{v(S);},[]);return jsxs(a,{children:[jsx(b$1,{title:"Ranking de clientes",action:o}),jsx(Lt,{children:jsx(a$1,{isEmpty:K.length===0,empty:jsx(m,{}),children:jsxs(N,{alignItems:"center",gap:1.5,children:[jsx(N,{width:"100%",ref:h,children:jsx(rt,{data:K,config:t,visibleSeries:p,average:a$2,activeBarIndex:P,activeCoordX:B,shouldRotateLabels:Se,onMouseMove:ve,onMouseLeave:Pe,onBarClick:Re})}),jsx(nt,{visibleSeries:p,config:t,onToggleSerie:xe}),ke&&jsx(Lr,{size:"small",min:10,max:re,value:oe,valueLabelDisplay:"auto",onChange:f})]})})})]})});st.displayName="Ranking";var Ar=st;var Fr=styled(Er,{shouldForwardProp:e=>e!=="active"})(({theme:e,active:t})=>({justifyContent:"flex-start",color:t?e.palette.primary.main:e.palette.text.secondary,fontWeight:t?800:400,"&:hover":{background:e.palette.action.hover}}));var Dr=({x:e=0,y:t=0,width:a=0,height:r=0,index:o=0,activeBarIndex:i,data:n,onBarClick:p})=>{if(i!==o)return null;let c=n[o];return jsx("rect",{x:e-6,y:t,width:a+12,height:r+6,fill:"#919EAB",opacity:.16,rx:6,style:{cursor:"pointer"},onClick:()=>{c&&p(String(c.seller_external_id),String(c.seller_name));}})},mt=Dr;var pt=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),Nr=({active:e,payload:t,label:a,config:r})=>{if(!e||!t?.length)return null;let o=t.filter(n=>n.value!=null&&n.value>0),i=o.reduce((n,p)=>n+p.value,0);return jsxs(a$5,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(ae,{variant:"body2",color:"text.secondary",children:a}),jsx(Ct,{}),jsxs(N,{children:[o.map(n=>{let p=r.series.find(u=>u.dataKey===n.dataKey),c=i>0?pt(n.value/i*100):"0%";return jsxs(N,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(N,{direction:"row",alignItems:"center",gap:1,children:[jsx(N,{width:6,height:6,borderRadius:"50%",bgcolor:n.color}),jsx(ae,{variant:"body2",noWrap:!0,children:p?.name??n.dataKey})]}),jsxs(ae,{variant:"body2",noWrap:!0,children:[c," (",n.value,")"]})]},n.dataKey)}),jsxs(N,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(N,{direction:"row",alignItems:"center",gap:1,children:[jsx(N,{width:6,height:6,borderRadius:"50%",bgcolor:"#919EAB"}),jsx(ae,{variant:"body2",noWrap:!0,children:"Total"})]}),jsxs(ae,{variant:"body2",noWrap:!0,children:[pt(100)," (",i,")"]})]})]})]})},ct=Nr;var Yr=48,$r=Yr/.8,Ur=({data:e,config:t,visibleSeries:a,hiddenKeys:r,activeBarIndex:o,shouldRotateLabels:i,onMouseMove:n$1,onMouseLeave:p,onBarClick:c$1})=>{let u=useMemo(()=>{if(!e.length)return [0,1];let s=Math.max(...e.map(l=>l._visibleTotal));return [0,s>0?s*1.15:1]},[e]),v=useMemo(()=>{let[,s]=u,l=s/6;return [...new Set(Array.from({length:7},(d,h)=>Math.round(l*h)))]},[u]),P=useMemo(()=>jsx(ct,{config:t}),[t]),R=useCallback(s=>i?jsx(n,{...s}):jsx(b$2,{x:s.x,y:s.y,payload:s.payload,slotWidth:$r}),[i]),B=useCallback(s=>{if(!s)return;let l=s.payload;l&&c$1(String(l.seller_external_id),String(l.seller_name));},[c$1]),y=useCallback(s=>{let{x:l,y:d,width:h,index:b}=s,g=e[b]?._visibleTotal;return g?jsx("text",{x:l+h/2,y:d-6,textAnchor:"middle",fontSize:11,fill:"#212B36",children:g}):jsx(Fragment,{})},[e]);return jsx(c,{children:jsx(ResponsiveContainer,{width:"100%",height:350,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:0,left:20},barCategoryGap:"20%",onMouseMove:n$1,onMouseLeave:p,children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"seller_name",axisLine:!1,tickLine:!1,interval:0,height:i?70:50,tick:R}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:s=>d(s),domain:u,ticks:v}),jsx(Tooltip,{content:P,cursor:!1}),t.series.map(s=>{let l=!r.has(s.dataKey),d=a[0],h=a[a.length-1],b=l&&s.dataKey===d?.dataKey,g=l&&s.dataKey===h?.dataKey;return jsx(Bar,{dataKey:l?s.dataKey:`_hidden_${s.dataKey}`,name:s.name,fill:s.color,stackId:"stack",maxBarSize:48,isAnimationActive:!1,cursor:"pointer",hide:!l,onClick:B,...b&&{background:jsx(mt,{activeBarIndex:o,data:e,onBarClick:c$1})},...g&&{radius:[4,4,0,0]},...g&&!i&&{label:{position:"top",fontSize:11,fill:"#212B36",content:y}}},s.dataKey)})]})})})},dt=Ur;var eo=({series:e,hiddenKeys:t,onToggleSerie:a})=>jsx(N,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:e.map(r=>jsx(at,{control:jsx(ot,{checked:!t.has(r.dataKey),onChange:()=>a(r.dataKey),sx:{"&.Mui-checked":{color:r.color}}}),label:r.name},r.dataKey))}),ft=eo;var ao=({data:e,config:t,onBarClick:a$2,children:r})=>{let o=b("down","sm"),i=b("down","lg"),[n,p]=useState(new Set),[c,u]=useState(12),[v,P]=useState(null),[R,B]=useState(0),y=useRef(null),s=useMemo(()=>[...e].sort((f,m)=>m._total-f._total),[e]),l=useMemo(()=>o?10:i?25:30,[i,o]),d=s.length,h=!o&&d>10,b$2=Math.min(d,l),g=Math.min(o?d:c,d,l),T=useMemo(()=>s.slice(0,g),[s,g]),ke=useMemo(()=>R===0||T.length===0?!1:(R-60)/T.length<80,[R,T.length]),re=useMemo(()=>t.series.filter(f=>!n.has(f.dataKey)),[t.series,n]),oe=useMemo(()=>T.map(f=>({...f,_visibleTotal:re.reduce((m,S)=>m+(Number(f[S.dataKey])||0),0)})),[T,re]),K=useCallback(f=>{y.current&&(y.current.disconnect(),y.current=null),f&&(B(f.clientWidth),y.current=new ResizeObserver(()=>B(f.clientWidth)),y.current.observe(f));},[]),Se=useCallback(f=>{p(m=>{let S=new Set(m);return S.has(f)?S.delete(f):S.add(f),S});},[]),xe=useCallback(f=>{f?.activeTooltipIndex!=null&&P(Number(f.activeTooltipIndex));},[]),ve=useCallback(()=>{P(null);},[]),Pe=useCallback((f,m)=>{a$2?.(f,m);},[a$2]),Re=useCallback((f,m)=>{u(m);},[]);return jsxs(a,{children:[jsx(b$1,{title:"Carteira de clientes do vendedor",action:r}),jsx(Lt,{children:jsx(a$1,{isEmpty:T.length===0,empty:jsx(m,{}),children:jsxs(N,{alignItems:"center",gap:1.5,children:[jsx(N,{width:"100%",ref:K,children:jsx(dt,{data:oe,config:t,visibleSeries:re,hiddenKeys:n,activeBarIndex:v,shouldRotateLabels:ke,onMouseMove:xe,onMouseLeave:ve,onBarClick:Pe})}),jsx(ft,{series:t.series,hiddenKeys:n,onToggleSerie:Se}),h&&jsx(Lr,{size:"small",min:10,max:b$2,value:g,valueLabelDisplay:"auto",onChange:Re})]})})})]})},no=ao;var io=[{dataKey:"ACTIVE",name:"Ativos",color:"#22C55E"},{dataKey:"AT_RISK",name:"Em risco",color:"#FFAB00"},{dataKey:"INACTIVE",name:"Inativos",color:"#FF5630"},{dataKey:"NEW_CLIENT",name:"Novos clientes",color:"#8E33FF"},{dataKey:"PROSPECT",name:"Prospects",color:"#00B8D9"},{dataKey:"LOST",name:"Perdidos",color:"#C4CDD5"}],lo=[{dataKey:"A",name:"Curva A",color:"#22C55E"},{dataKey:"B",name:"Curva B",color:"#FFAB00"},{dataKey:"C",name:"Curva C",color:"#FF5630"}],so={["CLASSIFICATION"]:{label:"Por classifica\xE7\xE3o",series:io,formatYAxis:d},["ABC_CURVE"]:{label:"Por curva ABC",series:lo,formatYAxis:d}};
43
+ var er=styled(T)(({theme:e})=>({position:"relative",alignSelf:"flex-start",flexShrink:0,"& .recharts-wrapper, & .recharts-wrapper *":{outline:"none !important",boxShadow:"none !important"},"& .recharts-pie-sector":{cursor:"pointer"},[e.breakpoints.down("md")]:{alignSelf:"center"}}));var rr=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),Zr=({active:e,payload:r,total:a})=>{if(!e||!r?.length)return null;let t=r[0];return jsxs(a$8,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(C,{variant:"body2",color:"text.secondary",children:t.name}),jsx(qr,{}),jsxs(T,{children:[jsxs(T,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(T,{direction:"row",alignItems:"center",gap:1,children:[jsx(T,{width:6,height:6,borderRadius:"50%",bgcolor:t.payload.fill}),jsx(C,{variant:"body2",noWrap:!0,children:t.name})]}),jsxs(C,{variant:"body2",noWrap:!0,children:[rr(t.payload.percentage)," (",t.value,")"]})]}),jsxs(T,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(T,{direction:"row",alignItems:"center",gap:1,children:[jsx(T,{width:6,height:6,borderRadius:"50%",bgcolor:"#919EAB"}),jsx(C,{variant:"body2",noWrap:!0,children:"Total"})]}),jsxs(C,{variant:"body2",noWrap:!0,children:[rr(100)," (",a,")"]})]})]})]})},tr=Zr;var tt=({chartData:e,total:r,isEmptyData:a,onPieClick:t,clickable:o})=>jsx(er,{children:jsx(ResponsiveContainer,{width:200,height:200,children:jsxs(PieChart,{children:[jsx(Pie,{data:e,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:60,outerRadius:90,paddingAngle:2,strokeWidth:0,isAnimationActive:!1,onClick:t,cursor:o?"pointer":void 0}),jsx("text",{x:"50%",y:"46%",textAnchor:"middle",dominantBaseline:"middle",style:{fontSize:24,fontWeight:700},children:a$6(r)}),jsx("text",{x:"50%",y:"58%",textAnchor:"middle",dominantBaseline:"middle",style:{fontSize:12,fill:"#919EAB"},children:"clientes"}),!a&&jsx(Tooltip,{content:jsx(tr,{total:r})})]})})}),or=tt;var it=({items:e,hiddenKeys:r,onToggle:a,onItemClick:t})=>jsx(T,{width:"100%",justifyContent:"center",children:e.map(o=>jsxs(T,{display:"grid",gridTemplateColumns:"1fr auto auto",alignItems:"center",gap:1.5,onClick:()=>t?.(o.key,o.label),sx:{...t?{cursor:"pointer"}:{}},children:[jsx(Ar,{label:o.label,onClick:i=>i.stopPropagation(),control:jsx(Lr,{size:"small",checked:!r.has(o.key),onChange:(i,n)=>a(o.key,n),sx:{"&.Mui-checked":{color:o.color}}}),sx:{"& .MuiFormControlLabel-label":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}}}),jsx(C,{variant:"body2",color:"text.secondary",textAlign:"right",noWrap:!0,children:c$1(o.percentage,{maximumFractionDigits:2,...o.percentage>0&&o.percentage<100?{minimumFractionDigits:2}:{}})}),jsx(C,{variant:"subtitle2",color:"text.primary",textAlign:"right",noWrap:!0,children:d(o.count)})]},o.key))}),ir=it;var ct=({title:e,chartData:r,total:a$1,isEmptyData:t,legendItems:o,hiddenKeys:i,onToggle:n,onPieClick:c,onItemClick:m})=>jsxs(a,{children:[jsx(pt,{title:e}),jsx(st,{children:jsxs(T,{direction:{xs:"column",sm:"row"},alignItems:"center",gap:1.5,minWidth:0,children:[jsx(or,{chartData:r,total:a$1,isEmptyData:t,onPieClick:c,clickable:!!c}),jsx(ir,{items:o,hiddenKeys:i,onToggle:n,onItemClick:m})]})})]}),dt=ct;var sr=Math.PI/180,pr=22,ft=2,gt=e=>{let{cx:r,cy:a,midAngle:t,outerRadius:o,percentage:i}=e;if(i<ft)return null;let n=Number(r),c=Number(a),m=Number(o),u=Number(t);if(isNaN(n)||isNaN(c)||isNaN(m))return null;let x=Math.sin(-u*sr),S=Math.cos(-u*sr),k=n+m*S,v=c+m*x,y=n+(m+pr*.5)*S,l=c+(m+pr*.5)*x,s=S>=0?1:-1,d=y+s*10,b=l,f=c$1(i,{maximumFractionDigits:1,...i>0&&i<100?{minimumFractionDigits:1}:{}}),P=f.length*7+10,L=s===1?d+2:d-P-2;return jsxs("g",{children:[jsx("path",{d:`M${k},${v} L${y},${l} L${d},${b}`,stroke:"#637381",fill:"none",strokeWidth:1}),jsx("rect",{x:L,y:b-10,width:P,height:20,rx:4,fill:"#212B36"}),jsx("text",{x:L+P/2,y:b,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fontWeight:600,fill:"#FFFFFF",children:f})]})},mr=gt;var cr=styled(T)({position:"relative",alignItems:"center",justifyContent:"center","& .recharts-wrapper, & .recharts-wrapper *":{outline:"none !important",boxShadow:"none !important"},"& .recharts-wrapper":{overflow:"visible !important"},"& .recharts-wrapper svg":{overflow:"visible"},"& .recharts-pie-sector":{cursor:"pointer"}});var dr=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),Ct=({active:e,payload:r,total:a})=>{if(!e||!r?.length)return null;let t=r[0];return jsxs(a$8,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(C,{variant:"body2",color:"text.secondary",children:t.name}),jsx(qr,{}),jsxs(T,{children:[jsxs(T,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(T,{direction:"row",alignItems:"center",gap:1,children:[jsx(T,{width:6,height:6,borderRadius:"50%",bgcolor:t.payload.fill}),jsx(C,{variant:"body2",noWrap:!0,children:t.name})]}),jsxs(C,{variant:"body2",noWrap:!0,children:[dr(t.payload.percentage)," (",t.value,")"]})]}),jsxs(T,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(T,{direction:"row",alignItems:"center",gap:1,children:[jsx(T,{width:6,height:6,borderRadius:"50%",bgcolor:"#919EAB"}),jsx(C,{variant:"body2",noWrap:!0,children:"Total"})]}),jsxs(C,{variant:"body2",noWrap:!0,children:[dr(100)," (",a,")"]})]})]})]})},fr=Ct;var Pt=e=>jsx(mr,{...e}),Tt=({chartData:e,total:r,isEmptyData:a,onPieClick:t})=>jsx(cr,{children:jsx(ResponsiveContainer,{width:280,height:280,children:jsxs(PieChart,{children:[jsx(Pie,{data:e,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:90,paddingAngle:1,strokeWidth:0,isAnimationActive:!1,label:a?!1:Pt,labelLine:!1,onClick:t,cursor:t?"pointer":void 0}),!a&&jsx(Tooltip,{content:jsx(fr,{total:r})})]})})}),gr=Tt;var Bt=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),Lt=({items:e,hiddenKeys:r,onToggle:a,onItemClick:t})=>jsx(a$7,{sx:{maxHeight:280,width:"100%",pl:.5},children:e.map(o=>jsxs(T,{display:"grid",gridTemplateColumns:"1fr auto auto",alignItems:"center",gap:1.5,onClick:()=>t?.(o.key),sx:t?{cursor:"pointer"}:void 0,children:[jsx(Ar,{label:o.label,onClick:i=>i.stopPropagation(),control:jsx(Lr,{size:"small",checked:!r.has(o.key),onChange:(i,n)=>a(o.key,n),sx:{"&.Mui-checked":{color:o.color}}}),sx:{"& .MuiFormControlLabel-label":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}}}),jsx(C,{variant:"body2",color:"text.secondary",textAlign:"right",noWrap:!0,children:Bt(o.percentage)}),jsx(C,{variant:"subtitle2",color:"text.primary",textAlign:"right",noWrap:!0,children:d(o.count)})]},o.key))}),ur=Lt;var Et=({data:e,chartData:r,total:a$2,isEmptyData:t,onPieClick:o,onLegendClick:i,hiddenKeys:n,onToggle:c})=>jsxs(a,{children:[jsx(pt,{title:"Clientes por segmentos"}),jsx(st,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(T,{alignItems:"center",gap:2,children:[jsx(gr,{chartData:r,total:a$2,isEmptyData:t,onPieClick:o}),jsx(ur,{items:e,hiddenKeys:n,onToggle:c,onItemClick:i})]})})})]}),Ft=Et;var Nt=["#FF5630","#FFAB00","#22C55E","#C4CDD5","#8E33FF","#00B8D9","#3366FF","#FF6C40","#36B37E","#B76E00"],Kt=12;var Vt=({title:e,label:r})=>jsxs(T,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(C,{variant:"subtitle1",noWrap:!0,children:e}),jsx(C,{variant:"body2",color:"text.secondary",noWrap:!0,children:r})]}),kr=Vt;var Yt=({open:e,onClose:r,title:a,label:t,columns:o,rows:i,totalPartners:n,isLoading:c,isFetching:m,isFetchingNextPage:u,onSearch:x,onRowsScrollEnd:S,sellerName:k,buildSellerLink:v,sellerExternalId:y,mobileRender:l})=>{let s=b("down","sm"),d=jsxs(T,{gap:3,children:[jsxs(T,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",alignItems:{sm:"center"},gap:3,children:[jsxs(T,{direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:[k&&y&&jsxs(Fragment,{children:[v?jsx(zt,{component:"a",href:v(y),target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",sx:{textDecoration:"underline"},noWrap:!0,children:k}):jsx(C,{variant:"subtitle2",noWrap:!0,children:k}),jsx(qr,{orientation:"vertical",flexItem:!0})]}),jsxs(T,{children:[jsx(C,{variant:"body2",color:"text.secondary",children:"Total de clientes:"}),jsx(C,{variant:"subtitle2",color:"text.primary",children:n})]})]}),jsx(a$2,{size:"small",placeholder:"Buscar",onSearch:x,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(d$1,{title:"Clientes",header:jsx(Fragment,{}),headerProps:{p:0},columns:o,rows:i,getRowId:f=>f.external_id,mobileRender:l,loading:c,fetching:m&&!u,fetchingNextPage:u,onRowsScrollEnd:S,scrollEndThreshold:600,disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),b$1=jsx(kr,{title:a,label:t});return s?jsx(a$3,{open:e,onClose:r,headerTitle:b$1,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:d}):jsx(a$4,{open:e,onClose:r,maxWidth:"lg",dialogTitle:b$1,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:d})},Xt=Yt;var Qt=({profileName:e})=>jsxs(T,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(C,{variant:"subtitle1",noWrap:!0,children:"Clientes por perfil"}),jsx(C,{variant:"body2",color:"text.secondary",noWrap:!0,children:e})]}),Pr=Qt;var qt=({open:e,onClose:r,profileName:a,columns:t,rows:o,totalPartners:i,isLoading:n,isFetching:c,isFetchingNextPage:m,onSearch:u,onRowsScrollEnd:x,mobileRender:S})=>{let k=b("down","sm"),v=jsxs(T,{gap:3,children:[jsxs(T,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",alignItems:{sm:"center"},gap:2,children:[jsx(T,{direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:jsxs(T,{children:[jsx(C,{variant:"body2",color:"text.secondary",children:"Total de clientes:"}),jsx(C,{variant:"subtitle2",color:"text.primary",children:i})]})}),jsx(a$2,{size:"small",placeholder:"Buscar",onSearch:u,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(d$1,{title:"Clientes",header:jsx(Fragment,{}),headerProps:{p:0},columns:t,rows:o,getRowId:l=>l.external_id,mobileRender:S,loading:n,fetching:c&&!m,fetchingNextPage:m,onRowsScrollEnd:x,scrollEndThreshold:600,disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),y=jsx(Pr,{profileName:a});return k?jsx(a$3,{open:e,onClose:r,headerTitle:y,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:v}):jsx(a$4,{open:e,onClose:r,maxWidth:"lg",dialogTitle:y,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:v})},Zt=qt;var U="#212B36",jt={["SALE_TOTAL_VALUE"]:{label:"Por valor total",color:"#22C55E",dataKey:"total_sale_value",barName:"Valor total por cliente",averageName:"M\xE9dia total de valor por cliente",averageDataKey:"average_total_value",formatLabel:h,formatYAxis:d},["SALE_COUNT"]:{label:"Por pedidos",color:"#C684FF",dataKey:"total_value_by_customer",barName:"Quantidade de pedidos",averageName:"Quantidade total de pedidos",averageDataKey:"average_sale_count",formatLabel:String,formatYAxis:d,floorAverage:!0},["SALE_AVERAGE_VALUE"]:{label:"Por ticket m\xE9dio",color:"#00B8D9",dataKey:"total_sale_value",barName:"Ticket m\xE9dio por cliente",averageName:"M\xE9dia do ticket m\xE9dio",averageDataKey:"average_ticket",formatLabel:h,formatYAxis:d}};var eo=({x:e=0,y:r=0,width:a=0,height:t=0,index:o=0,activeBarIndex:i,color:n,data:c,onBarClick:m})=>i!==o?null:jsx("rect",{x:e-6,y:r,width:a+12,height:t+6,fill:n,opacity:.16,rx:6,style:{cursor:"pointer"},onClick:()=>m(c[o])}),Rr=eo;var oo=({active:e,payload:r,label:a,config:t,average:o})=>!e||!r?.length?null:jsxs(a$8,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(C,{variant:"body2",color:"text.secondary",children:a}),jsx(qr,{}),jsxs(T,{children:[r.map((i,n)=>jsxs(T,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${n}`,children:[jsxs(T,{direction:"row",alignItems:"center",gap:1,children:[jsx(T,{width:6,height:6,borderRadius:"50%",bgcolor:i.color}),jsx(C,{variant:"body2",noWrap:!0,children:t.barName})]}),jsx(C,{variant:"body2",children:t.formatLabel(i.value)})]},i.dataKey)),jsxs(T,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(T,{direction:"row",alignItems:"center",gap:1,children:[jsx(T,{width:6,height:6,borderRadius:"50%",bgcolor:U}),jsx(C,{variant:"body2",noWrap:!0,children:t.averageName})]}),jsx(C,{variant:"body2",children:t.formatLabel(o)})]})]})]}),wr=oo;var co=48,fo=co/.8,go=({data:e,config:r,visibleSeries:a,average:t,activeBarIndex:o,activeCoordX:i,shouldRotateLabels:n$1,onMouseMove:c$1,onMouseLeave:m,onBarClick:u})=>{let x=useMemo(()=>{if(!e.length)return [0,1];let s=e.map(b=>b[r.dataKey]||0);a.average&&t>0&&s.push(t);let d=Math.max(...s);return [0,d>0?d*1.15:1]},[e,r.dataKey,t,a.average]),S=useMemo(()=>{let[,s]=x,d=s/6;return [...new Set(Array.from({length:7},(b,f)=>Math.round(d*f)))]},[x]),k=useMemo(()=>n$1?!1:{position:"top",fontSize:11,fill:"#212B36",formatter:s=>r.formatLabel(Number(s))},[n$1,r]),v=useMemo(()=>jsx(wr,{config:r,average:t}),[r,t]),y=useCallback(s=>n$1?jsx(n,{...s}):jsx(b$2,{x:s.x,y:s.y,payload:s.payload,slotWidth:fo}),[n$1]),l=useCallback(s=>{s&&u(s);},[u]);return jsx(c,{children:jsx(ResponsiveContainer,{width:"100%",height:350,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:0,left:20},barCategoryGap:"20%",onMouseMove:c$1,onMouseLeave:m,children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"partner_name",axisLine:!1,tickLine:!1,interval:0,height:n$1?70:50,tick:y}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:s=>d(s),domain:x,ticks:S}),jsx(Tooltip,{content:v}),a.average&&t>0&&jsx(ReferenceLine,{y:t,stroke:U,strokeDasharray:"8 4",strokeWidth:2,ifOverflow:"extendDomain"}),a.average&&t>0&&jsx(ReferenceLine,{y:t,stroke:"none",ifOverflow:"extendDomain",label:jsx(a$5,{activeCoordX:i,referenceCircleColor:U,activeIndex:o})}),a.bar&&jsx(Bar,{dataKey:r.dataKey,name:r.barName,fill:r.color,maxBarSize:48,isAnimationActive:!1,radius:[4,4,0,0],cursor:"pointer",onClick:l,background:jsx(Rr,{activeBarIndex:o,color:r.color,data:e,onBarClick:u}),label:k})]})})})},Br=go;var yo=({visibleSeries:e,config:r,onToggleSerie:a})=>jsxs(T,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ar,{control:jsx(Lr,{checked:e.bar,onChange:()=>a("bar"),sx:{"&.Mui-checked":{color:r.color}}}),label:r.barName}),jsx(Ar,{control:jsx(Lr,{checked:e.average,onChange:()=>a("average"),sx:{"&.Mui-checked":{color:U}}}),label:r.averageName})]}),_r=yo;var Er=memo(({data:e,config:r,average:a$2,onBarClick:t,children:o})=>{let i=b("down","sm"),n=b("down","lg"),[c,m$1]=useState({bar:!0,average:!0}),[u,x]=useState(12),[S,k]=useState(null),[v,y]=useState(null),[l,s]=useState(0),d=useRef(null),b$2=useCallback(g=>{d.current&&(d.current.disconnect(),d.current=null),g&&(s(g.clientWidth),d.current=new ResizeObserver(()=>s(g.clientWidth)),d.current.observe(g));},[]),f=useMemo(()=>[...e].sort((g,D)=>D[r.dataKey]-g[r.dataKey]),[e,r.dataKey]),P=f.length,L=useMemo(()=>i?10:n?25:30,[i,n]),Ee=!i&&P>10,fe=Math.min(P,L),ge=Math.min(i?P:u,P,L),Y=useMemo(()=>f.slice(0,ge),[f,ge]),Fe=useMemo(()=>l===0||Y.length===0?!1:(l-60)/Y.length<80,[l,Y.length]),Ne=useCallback(g=>{m$1(D=>({...D,[g]:!D[g]}));},[]),Ke=useCallback(g=>{g?.activeTooltipIndex!=null&&k(Number(g.activeTooltipIndex)),g?.activeCoordinate?.x!=null&&y(g.activeCoordinate.x);},[]),Oe=useCallback(()=>{k(null),y(null);},[]),Ve=useCallback(g=>{g&&t?.(g);},[t]),h=useCallback((g,D)=>{x(D);},[]);return jsxs(a,{children:[jsx(b$1,{title:"Ranking de clientes",action:o}),jsx(st,{children:jsx(a$1,{isEmpty:Y.length===0,empty:jsx(m,{}),children:jsxs(T,{alignItems:"center",gap:1.5,children:[jsx(T,{width:"100%",ref:b$2,children:jsx(Br,{data:Y,config:r,visibleSeries:c,average:a$2,activeBarIndex:S,activeCoordX:v,shouldRotateLabels:Fe,onMouseMove:Ke,onMouseLeave:Oe,onBarClick:Ve})}),jsx(_r,{visibleSeries:c,config:r,onToggleSerie:Ne}),Ee&&jsx(So,{size:"small",min:10,max:fe,value:ge,valueLabelDisplay:"auto",onChange:h})]})})})]})});Er.displayName="Ranking";var vo=Er;var Ro=styled(Po,{shouldForwardProp:e=>e!=="active"})(({theme:e,active:r})=>({justifyContent:"flex-start",color:r?e.palette.primary.main:e.palette.text.secondary,fontWeight:r?800:400,"&:hover":{background:e.palette.action.hover}}));var wo=({rankingLabel:e,partnerName:r})=>jsxs(T,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(C,{variant:"subtitle1",noWrap:!0,children:"Detalhes do relat\xF3rio"}),jsxs(T,{direction:"row",alignItems:"center",columnGap:1.5,rowGap:0,flexWrap:"wrap",children:[jsx(C,{variant:"body2",color:"text.secondary",flexShrink:0,children:"Top clientes"}),"\u2022",jsxs(C,{variant:"body2",flexShrink:0,children:['Por "',e,'"']}),"\u2022",jsx(C,{variant:"body2",color:"text.secondary",noWrap:!0,children:r})]})]}),Nr=wo;var We=styled(qr)(()=>({height:30,alignSelf:"center",borderStyle:"dashed"})),Or=styled(T)(({theme:e})=>({position:"relative",display:"flex",flexDirection:"column",padding:e.spacing(2),gap:e.spacing(1),color:e.palette.text.primary,"& a":{textDecoration:"none"},"&+div":{borderTop:`1px dashed ${alpha(e.palette.grey[500],.2)}`}}));var _o=e=>jsx(T,{justifyContent:"center",height:1,children:jsx(C,{variant:"body2",color:"text.primary",children:e.id})}),Wo=(e,r)=>jsx(T,{justifyContent:"center",height:1,children:e?.partner?.id&&r?jsx(zt,{component:"a",href:r(e.partner.id),target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",sx:{textDecoration:"underline"},noWrap:!0,children:e.partner?.name||"-"}):jsx(C,{variant:"body2",color:"text.primary",noWrap:!0,children:e.partner?.name||"-"})}),Mo=e=>jsx(T,{justifyContent:"center",height:1,children:jsx(C,{variant:"body2",color:"text.primary",children:h(e.total_value)})}),Eo=e=>jsx(T,{justifyContent:"center",height:1,children:e.negotiation_date?jsx(C,{variant:"body2",color:"text.primary",children:d$2(e.negotiation_date,"DD/MM/YYYY")}):"-"}),Fo=e=>jsx(T,{justifyContent:"center",height:1,children:e.status||"-"}),No=e=>jsx(Or,{children:jsxs(T,{gap:1,children:[jsxs(T,{children:[jsx(C,{variant:"body2",color:"text.secondary",children:"Pedido"}),jsx(C,{variant:"subtitle2",color:"text.primary",children:e.id})]}),jsxs(T,{children:[jsx(C,{variant:"body2",color:"text.secondary",children:"Cliente"}),jsx(C,{variant:"subtitle2",color:"primary.main",children:e.partner?.name||"-"})]}),jsxs(T,{direction:"row",alignItems:"center",gap:1,children:[jsxs(T,{flex:1,overflow:"hidden",children:[jsx(C,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Valor do pedido"}),jsx(C,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h(e.total_value)})]}),jsx(qr,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(T,{flex:1,overflow:"hidden",children:[jsx(C,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Data"}),jsx(C,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:e.negotiation_date?d$2(e.negotiation_date,"DD/MM/YYYY"):"-"})]})]}),jsxs(T,{gap:.5,children:[jsx(C,{variant:"body2",color:"text.secondary",children:"Status"}),jsx(C,{variant:"subtitle2",color:"text.primary",children:e.status||"-"})]})]})},e.id),Ko=({open:e,onClose:r,partnerName:a,rankingLabel:t,rows:o,total:i,totalValue:n,averageTicket:c,isLoading:m,isFetching:u,page:x,perPage:S,onSearch:k,onPaginationChange:v,buildPartnerLink:y,mobileItemSlot:l})=>{let s=b("down","sm"),d=jsxs(T,{gap:3,children:[jsxs(T,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",gap:2,children:[jsxs(T,{minWidth:0,direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:[jsx(C,{variant:"subtitle2",noWrap:!0,children:a}),jsx(We,{orientation:"vertical",flexItem:!0}),jsxs(T,{children:[jsx(C,{variant:"body2",color:"text.secondary",children:"Qtd. de pedidos"}),jsx(C,{variant:"subtitle2",color:"text.primary",children:i})]}),jsx(We,{orientation:"vertical",flexItem:!0}),jsxs(T,{children:[jsx(C,{variant:"body2",color:"text.secondary",children:"Valor em pedidos"}),jsx(C,{variant:"subtitle2",color:"text.primary",children:h(n)})]}),jsx(We,{orientation:"vertical",flexItem:!0}),jsxs(T,{children:[jsx(C,{variant:"body2",color:"text.secondary",children:"Ticket m\xE9dio"}),jsx(C,{variant:"subtitle2",color:"text.primary",children:h(c)})]})]}),jsx(a$2,{size:"small",placeholder:"Buscar",onSearch:k,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(d$1,{title:"Pedidos",header:jsx(Fragment,{}),headerProps:{p:0},columns:[{field:"external_id",headerName:"Pedido",flex:1,renderCell:({row:f})=>_o(f)},{field:"partner_name",headerName:"Cliente",flex:1,renderCell:({row:f})=>Wo(f,y)},{field:"total_value",headerName:"Valor do pedido",flex:1,renderCell:({row:f})=>Mo(f)},{field:"created_at",headerName:"Data",flex:1,renderCell:({row:f})=>Eo(f)},{field:"last_status",headerName:"Status",flex:1,renderCell:({row:f})=>Fo(f)}],rows:o,rowCount:i,mobileRender:f=>l?l(f):No(f),loading:m,fetching:u,paginationModel:{page:x,pageSize:S},onPaginationChange:v,paginationMode:"server",disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),b$1=jsx(Nr,{rankingLabel:t,partnerName:a});return s?jsx(a$3,{open:e,onClose:r,headerTitle:b$1,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:d}):jsx(a$4,{open:e,onClose:r,maxWidth:"lg",dialogTitle:b$1,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:d})},Oo=Ko;var Go=({x:e=0,y:r=0,width:a=0,height:t=0,index:o=0,activeBarIndex:i,data:n,onBarClick:c})=>{if(i!==o)return null;let m=n[o];return jsx("rect",{x:e-6,y:r,width:a+12,height:t+6,fill:"#919EAB",opacity:.16,rx:6,style:{cursor:"pointer"},onClick:()=>{m&&c(String(m.seller_external_id),String(m.seller_name));}})},Vr=Go;var Gr=e=>c$1(e,{maximumFractionDigits:2,...e>0&&e<100?{minimumFractionDigits:2}:{}}),Yo=({active:e,payload:r,label:a,config:t})=>{if(!e||!r?.length)return null;let o=r.filter(n=>n.value!=null&&n.value>0),i=o.reduce((n,c)=>n+c.value,0);return jsxs(a$8,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(C,{variant:"body2",color:"text.secondary",children:a}),jsx(qr,{}),jsxs(T,{children:[o.map(n=>{let c=t.series.find(u=>u.dataKey===n.dataKey),m=i>0?Gr(n.value/i*100):"0%";return jsxs(T,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(T,{direction:"row",alignItems:"center",gap:1,children:[jsx(T,{width:6,height:6,borderRadius:"50%",bgcolor:n.color}),jsx(C,{variant:"body2",noWrap:!0,children:c?.name??n.dataKey})]}),jsxs(C,{variant:"body2",noWrap:!0,children:[m," (",n.value,")"]})]},n.dataKey)}),jsxs(T,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,children:[jsxs(T,{direction:"row",alignItems:"center",gap:1,children:[jsx(T,{width:6,height:6,borderRadius:"50%",bgcolor:"#919EAB"}),jsx(C,{variant:"body2",noWrap:!0,children:"Total"})]}),jsxs(C,{variant:"body2",noWrap:!0,children:[Gr(100)," (",i,")"]})]})]})]})},Hr=Yo;var jo=48,ea=jo/.8,ra=({data:e,config:r,visibleSeries:a,hiddenKeys:t,activeBarIndex:o,shouldRotateLabels:i,onMouseMove:n$1,onMouseLeave:c$1,onBarClick:m})=>{let u=useMemo(()=>{if(!e.length)return [0,1];let l=Math.max(...e.map(s=>s._visibleTotal));return [0,l>0?l*1.15:1]},[e]),x=useMemo(()=>{let[,l]=u,s=l/6;return [...new Set(Array.from({length:7},(d,b)=>Math.round(s*b)))]},[u]),S=useMemo(()=>jsx(Hr,{config:r}),[r]),k=useCallback(l=>i?jsx(n,{...l}):jsx(b$2,{x:l.x,y:l.y,payload:l.payload,slotWidth:ea}),[i]),v=useCallback(l=>{if(!l)return;let s=l.payload;s&&m(String(s.seller_external_id),String(s.seller_name));},[m]),y=useCallback(l=>{let{x:s,y:d,width:b,index:f}=l,P=e[f]?._visibleTotal;return P?jsx("text",{x:s+b/2,y:d-6,textAnchor:"middle",fontSize:11,fill:"#212B36",children:P}):jsx(Fragment,{})},[e]);return jsx(c,{children:jsx(ResponsiveContainer,{width:"100%",height:350,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:0,left:20},barCategoryGap:"20%",onMouseMove:n$1,onMouseLeave:c$1,children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"seller_name",axisLine:!1,tickLine:!1,interval:0,height:i?70:50,tick:k}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:l=>d(l),domain:u,ticks:x}),jsx(Tooltip,{content:S,cursor:!1}),r.series.map(l=>{let s=!t.has(l.dataKey),d=a[0],b=a[a.length-1],f=s&&l.dataKey===d?.dataKey,P=s&&l.dataKey===b?.dataKey;return jsx(Bar,{dataKey:s?l.dataKey:`_hidden_${l.dataKey}`,name:l.name,fill:l.color,stackId:"stack",maxBarSize:48,isAnimationActive:!1,cursor:"pointer",hide:!s,onClick:v,...f&&{background:jsx(Vr,{activeBarIndex:o,data:e,onBarClick:m})},...P&&{radius:[4,4,0,0]},...P&&!i&&{label:{position:"top",fontSize:11,fill:"#212B36",content:y}}},l.dataKey)})]})})})},zr=ra;var la=({series:e,hiddenKeys:r,onToggleSerie:a})=>jsx(T,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:e.map(t=>jsx(Ar,{control:jsx(Lr,{checked:!r.has(t.dataKey),onChange:()=>a(t.dataKey),sx:{"&.Mui-checked":{color:t.color}}}),label:t.name},t.dataKey))}),Yr=la;var ca=({data:e,config:r,onBarClick:a$2,children:t})=>{let o=b("down","sm"),i=b("down","lg"),[n,c]=useState(new Set),[m$1,u]=useState(12),[x,S]=useState(null),[k,v]=useState(0),y=useRef(null),l=useMemo(()=>[...e].sort((h,g)=>g._total-h._total),[e]),s=useMemo(()=>o?10:i?25:30,[i,o]),d=l.length,b$2=!o&&d>10,f=Math.min(d,s),P=Math.min(o?d:m$1,d,s),L=useMemo(()=>l.slice(0,P),[l,P]),Ee=useMemo(()=>k===0||L.length===0?!1:(k-60)/L.length<80,[k,L.length]),fe=useMemo(()=>r.series.filter(h=>!n.has(h.dataKey)),[r.series,n]),ge=useMemo(()=>L.map(h=>({...h,_visibleTotal:fe.reduce((g,D)=>g+(Number(h[D.dataKey])||0),0)})),[L,fe]),Y=useCallback(h=>{y.current&&(y.current.disconnect(),y.current=null),h&&(v(h.clientWidth),y.current=new ResizeObserver(()=>v(h.clientWidth)),y.current.observe(h));},[]),Fe=useCallback(h=>{c(g=>{let D=new Set(g);return D.has(h)?D.delete(h):D.add(h),D});},[]),Ne=useCallback(h=>{h?.activeTooltipIndex!=null&&S(Number(h.activeTooltipIndex));},[]),Ke=useCallback(()=>{S(null);},[]),Oe=useCallback((h,g)=>{a$2?.(h,g);},[a$2]),Ve=useCallback((h,g)=>{u(g);},[]);return jsxs(a,{children:[jsx(b$1,{title:"Carteira de clientes do vendedor",action:t}),jsx(st,{children:jsx(a$1,{isEmpty:L.length===0,empty:jsx(m,{}),children:jsxs(T,{alignItems:"center",gap:1.5,children:[jsx(T,{width:"100%",ref:Y,children:jsx(zr,{data:ge,config:r,visibleSeries:fe,hiddenKeys:n,activeBarIndex:x,shouldRotateLabels:Ee,onMouseMove:Ne,onMouseLeave:Ke,onBarClick:Oe})}),jsx(Yr,{series:r.series,hiddenKeys:n,onToggleSerie:Fe}),b$2&&jsx(So,{size:"small",min:10,max:f,value:P,valueLabelDisplay:"auto",onChange:Ve})]})})})]})},da=ca;var fa=[{dataKey:"ACTIVE",name:"Ativos",color:"#22C55E"},{dataKey:"AT_RISK",name:"Em risco",color:"#FFAB00"},{dataKey:"INACTIVE",name:"Inativos",color:"#FF5630"},{dataKey:"NEW_CLIENT",name:"Novos clientes",color:"#8E33FF"},{dataKey:"PROSPECT",name:"Prospects",color:"#00B8D9"},{dataKey:"LOST",name:"Perdidos",color:"#C4CDD5"}],ga=[{dataKey:"A",name:"Curva A",color:"#22C55E"},{dataKey:"B",name:"Curva B",color:"#FFAB00"},{dataKey:"C",name:"Curva C",color:"#FF5630"}],ha={["CLASSIFICATION"]:{label:"Por classifica\xE7\xE3o",series:fa,formatYAxis:d},["ABC_CURVE"]:{label:"Por curva ABC",series:ga,formatYAxis:d}};
26
44
 
27
- export { lr as PROFILE_MAX_VISIBLE, Ft as PartnerBreakdown, nr as PartnersByProfile, sr as RANKING_CONFIG, Ar as Ranking, Fr as RankingItemButton, ir as SEGMENT_COLORS, so as SELLER_PORTFOLIO_CONFIG, no as SellerPortfolio };
45
+ export { Kt as PROFILE_MAX_VISIBLE, dt as PartnerBreakdown, Ft as PartnersByProfile, Xt as PartnersDetail, Zt as ProfileDetail, jt as RANKING_CONFIG, vo as Ranking, Oo as RankingDetail, Ro as RankingItemButton, Nt as SEGMENT_COLORS, ha as SELLER_PORTFOLIO_CONFIG, da as SellerPortfolio };
28
46
  //# sourceMappingURL=index.js.map