@zydon/common 2.8.77 → 2.8.79

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 (59) hide show
  1. package/dist/chunk-ERLI5GAP.js +4 -0
  2. package/dist/chunk-ERLI5GAP.js.map +1 -0
  3. package/dist/chunk-J7RPKCIN.js +9 -0
  4. package/dist/chunk-J7RPKCIN.js.map +1 -0
  5. package/dist/chunk-K2PWIYEM.js +4 -0
  6. package/dist/chunk-K2PWIYEM.js.map +1 -0
  7. package/dist/chunk-UWTX4JMW.js +7 -0
  8. package/dist/chunk-UWTX4JMW.js.map +1 -0
  9. package/dist/chunk-VGTQYKAC.js +8 -0
  10. package/dist/chunk-VGTQYKAC.js.map +1 -0
  11. package/dist/chunk-XAPSXJZO.js +8 -0
  12. package/dist/chunk-XAPSXJZO.js.map +1 -0
  13. package/dist/chunk-XL6SZZGI.js +6 -0
  14. package/dist/chunk-XL6SZZGI.js.map +1 -0
  15. package/dist/{chunk-UC2R4AXD.js → chunk-XQZPUMVQ.js} +4 -4
  16. package/dist/chunk-XQZPUMVQ.js.map +1 -0
  17. package/dist/components/Analytics/OverviewAnalytics/index.d.ts +1 -1
  18. package/dist/components/Analytics/OverviewAnalytics/index.js +6 -6
  19. package/dist/components/Analytics/OverviewAnalytics/index.js.map +1 -1
  20. package/dist/components/Analytics/PartnerAnalysis/index.d.ts +123 -0
  21. package/dist/components/Analytics/PartnerAnalysis/index.js +28 -0
  22. package/dist/components/Analytics/PartnerAnalysis/index.js.map +1 -0
  23. package/dist/components/Analytics/index.d.ts +37 -2
  24. package/dist/components/Analytics/index.js +26 -13
  25. package/dist/components/Analytics/index.js.map +1 -1
  26. package/dist/components/Avatar/index.d.ts +1 -1
  27. package/dist/components/AvatarButton/index.js +4 -4
  28. package/dist/components/AvatarButton/index.js.map +1 -1
  29. package/dist/components/DataView/index.d.ts +1 -1
  30. package/dist/components/DateRangeCalendar/index.js +1 -7
  31. package/dist/components/DateRangeCalendar/index.js.map +1 -1
  32. package/dist/components/form/DateField/index.js +1 -8
  33. package/dist/components/form/DateField/index.js.map +1 -1
  34. package/dist/components/form/Form/index.js +1 -7
  35. package/dist/components/form/Form/index.js.map +1 -1
  36. package/dist/hooks/useSnackbar.d.ts +1 -1
  37. package/dist/index.d.ts +2 -2
  38. package/dist/theme/core/index.d.ts +1 -1
  39. package/dist/theme/styles/index.d.ts +13 -13
  40. package/dist/types/analytics.d.ts +7 -9
  41. package/dist/types/analytics.js +1 -1
  42. package/dist/types/overviewAnalytics.d.ts +1 -1
  43. package/dist/types/partnerAnalysis.d.ts +68 -0
  44. package/dist/types/partnerAnalysis.js +2 -0
  45. package/dist/types/partnerAnalysis.js.map +1 -0
  46. package/dist/utils/analytics.d.ts +24 -0
  47. package/dist/utils/analytics.js +2 -0
  48. package/dist/utils/analytics.js.map +1 -0
  49. package/dist/utils/partnerAnalysis.d.ts +28 -0
  50. package/dist/utils/partnerAnalysis.js +2 -0
  51. package/dist/utils/partnerAnalysis.js.map +1 -0
  52. package/dist/utils/periodDates.d.ts +21 -0
  53. package/dist/utils/periodDates.js +3 -0
  54. package/dist/utils/periodDates.js.map +1 -0
  55. package/package.json +5 -1
  56. package/dist/chunk-UC2R4AXD.js.map +0 -1
  57. package/dist/chunk-Y2SILVOR.js +0 -4
  58. package/dist/chunk-Y2SILVOR.js.map +0 -1
  59. package/dist/{index-c8f1e6e7.d.ts → index-5a5e5dc8.d.ts} +12 -12
@@ -0,0 +1,4 @@
1
+ var S=(A=>(A.MONTHLY="MONTHLY",A.DAILY="DAILY",A))(S||{}),Y={["MONTHLY"]:"Mensal",["DAILY"]:"Di\xE1rio"},_=(A=>(A.XLSX="XLSX",A.PDF="PDF",A))(_||{}),L=(T=>(T.TODAY="TODAY",T.YESTERDAY="YESTERDAY",T.LAST_7_DAYS="LAST_7_DAYS",T.LAST_28_DAYS="LAST_28_DAYS",T.LAST_90_DAYS="LAST_90_DAYS",T.LAST_WEEK="LAST_WEEK",T.LAST_MONTH="LAST_MONTH",T.THIS_MONTH="THIS_MONTH",T.THIS_YEAR="THIS_YEAR",T.OTHER="OTHER",T))(L||{}),E={["TODAY"]:"Hoje",["YESTERDAY"]:"Ontem",["LAST_7_DAYS"]:"\xDAltimos 7 dias",["LAST_28_DAYS"]:"\xDAltimos 28 dias",["LAST_90_DAYS"]:"\xDAltimos 90 dias",["LAST_WEEK"]:"Semana passada",["LAST_MONTH"]:"M\xEAs passado",["THIS_MONTH"]:"Este m\xEAs",["THIS_YEAR"]:"Este ano",["OTHER"]:"Personalizado"};
2
+
3
+ export { S as a, Y as b, _ as c, L as d, E as e };
4
+ //# sourceMappingURL=chunk-ERLI5GAP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/analytics.ts"],"names":["ViewMode","VIEW_MODE_LABELS","ExportFormat","FilterPeriod","FILTER_PERIOD_LABELS"],"mappings":"AAAO,IAAKA,OACVA,EAAA,QAAU,UACVA,EAAA,MAAQ,QAFEA,OAAA,IAKCC,EAA6C,CACxD,CAAC,SAAgB,EAAG,SACpB,CAAC,OAAc,EAAG,WACpB,EAEYC,OACVA,EAAA,KAAO,OACPA,EAAA,IAAM,MAFIA,OAAA,IAKAC,OACVA,EAAA,MAAQ,QACRA,EAAA,UAAY,YACZA,EAAA,YAAc,cACdA,EAAA,aAAe,eACfA,EAAA,aAAe,eACfA,EAAA,UAAY,YACZA,EAAA,WAAa,aACbA,EAAA,WAAa,aACbA,EAAA,UAAY,YACZA,EAAA,MAAQ,QAVEA,OAAA,IAaCC,EAAqD,CAChE,CAAC,OAAkB,EAAG,OACtB,CAAC,WAAsB,EAAG,QAC1B,CAAC,aAAwB,EAAG,oBAC5B,CAAC,cAAyB,EAAG,qBAC7B,CAAC,cAAyB,EAAG,qBAC7B,CAAC,WAAsB,EAAG,iBAC1B,CAAC,YAAuB,EAAG,iBAC3B,CAAC,YAAuB,EAAG,cAC3B,CAAC,WAAsB,EAAG,WAC1B,CAAC,OAAkB,EAAG,eACxB","sourcesContent":["export enum ViewMode {\n MONTHLY = 'MONTHLY',\n DAILY = 'DAILY',\n}\n\nexport const VIEW_MODE_LABELS: Record<ViewMode, string> = {\n [ViewMode.MONTHLY]: 'Mensal',\n [ViewMode.DAILY]: 'Diário',\n};\n\nexport enum ExportFormat {\n XLSX = 'XLSX',\n PDF = 'PDF',\n}\n\nexport enum FilterPeriod {\n TODAY = 'TODAY',\n YESTERDAY = 'YESTERDAY',\n LAST_7_DAYS = 'LAST_7_DAYS',\n LAST_28_DAYS = 'LAST_28_DAYS',\n LAST_90_DAYS = 'LAST_90_DAYS',\n LAST_WEEK = 'LAST_WEEK',\n LAST_MONTH = 'LAST_MONTH',\n THIS_MONTH = 'THIS_MONTH',\n THIS_YEAR = 'THIS_YEAR',\n OTHER = 'OTHER',\n}\n\nexport const FILTER_PERIOD_LABELS: Record<FilterPeriod, string> = {\n [FilterPeriod.TODAY]: 'Hoje',\n [FilterPeriod.YESTERDAY]: 'Ontem',\n [FilterPeriod.LAST_7_DAYS]: 'Últimos 7 dias',\n [FilterPeriod.LAST_28_DAYS]: 'Últimos 28 dias',\n [FilterPeriod.LAST_90_DAYS]: 'Últimos 90 dias',\n [FilterPeriod.LAST_WEEK]: 'Semana passada',\n [FilterPeriod.LAST_MONTH]: 'Mês passado',\n [FilterPeriod.THIS_MONTH]: 'Este mês',\n [FilterPeriod.THIS_YEAR]: 'Este ano',\n [FilterPeriod.OTHER]: 'Personalizado',\n};\n"]}
@@ -0,0 +1,9 @@
1
+ import { useFormContext, Controller } from 'react-hook-form';
2
+ import { DateField } from '@mui/x-date-pickers-pro';
3
+ import c from 'dayjs';
4
+ import { jsx } from 'react/jsx-runtime';
5
+
6
+ var g=({name:t,rules:s,tabIndex:i,helperText:p,required:u,...e})=>{let{control:d}=useFormContext();return jsx(Controller,{name:t,control:d,rules:s,render:({field:{ref:f,onChange:m,...o},fieldState:{error:l}})=>jsx(DateField,{inputRef:f,format:"DD/MM/YYYY",...o,"data-intercom-target":t,...e,value:o.value?c(o.value):null,onChange:r=>{let a=r?r.toDate():null;m(a),e.onChange&&e.onChange(a);},slotProps:{textField:{...e.slotProps?.textField,name:t,required:u,error:!!l,helperText:l?.message||p,autoComplete:"off",spellCheck:"false",fullWidth:!0,inputProps:{tabIndex:i}}}})})},h=g;
7
+
8
+ export { h as a };
9
+ //# sourceMappingURL=chunk-J7RPKCIN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/form/DateField/index.tsx"],"names":["Controller","useFormContext","MuiDateField","dayjs","jsx","DateField","name","rules","tabIndex","helperText","required","other","control","ref","onChange","field","error","v","newValue","DateField_default"],"mappings":"AAAA,OAAS,cAAAA,EAAY,kBAAAC,MAAsB,kBAC3C,OAAS,aAAaC,MAAoB,0BAC1C,OAAOC,MAAW,QAuBV,cAAAC,MAAA,oBAnBR,IAAMC,EAAY,CAAC,CACjB,KAAAC,EACA,MAAAC,EACA,SAAAC,EACA,WAAAC,EACA,SAAAC,EACA,GAAGC,CACL,IAAsB,CACpB,GAAM,CAAE,QAAAC,CAAQ,EAAIX,EAAe,EAEnC,OACEG,EAACJ,EAAA,CACC,KAAMM,EACN,QAASM,EACT,MAAOL,EACP,OAAQ,CAAC,CACP,MAAO,CAAE,IAAAM,EAAK,SAAAC,EAAU,GAAGC,CAAM,EACjC,WAAY,CAAE,MAAAC,CAAM,CACtB,IACEZ,EAACF,EAAA,CACC,SAAUW,EACV,OAAO,aACN,GAAGE,EACJ,uBAAsBT,EACrB,GAAGK,EACJ,MAAOI,EAAM,MAAQZ,EAAMY,EAAM,KAAK,EAAI,KAC1C,SAAUE,GAAK,CACb,IAAMC,EAAWD,EAAIA,EAAE,OAAO,EAAI,KAClCH,EAASI,CAAQ,EACjBP,EAAM,UAAYA,EAAM,SAASO,CAAQ,CAC3C,EACA,UAAW,CACT,UAAW,CACT,GAAGP,EAAM,WAAW,UACpB,KAAAL,EACA,SAAAI,EACA,MAAO,CAAC,CAACM,EACT,WAAYA,GAAO,SAAWP,EAC9B,aAAc,MACd,WAAY,QACZ,UAAW,GACX,WAAY,CACV,SAAAD,CACF,CACF,CACF,EACF,EAEJ,CAEJ,EAEOW,EAAQd","sourcesContent":["import { Controller, useFormContext } from 'react-hook-form';\nimport { DateField as MuiDateField } from '@mui/x-date-pickers-pro';\nimport dayjs from 'dayjs';\n\nimport { DateFieldProps } from 'types/dateFieldProps';\n\nconst DateField = ({\n name,\n rules,\n tabIndex,\n helperText,\n required,\n ...other\n}: DateFieldProps) => {\n const { control } = useFormContext();\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({\n field: { ref, onChange, ...field },\n fieldState: { error },\n }) => (\n <MuiDateField\n inputRef={ref}\n format=\"DD/MM/YYYY\"\n {...field}\n data-intercom-target={name}\n {...other}\n value={field.value ? dayjs(field.value) : null}\n onChange={v => {\n const newValue = v ? v.toDate() : null;\n onChange(newValue);\n other.onChange && other.onChange(newValue);\n }}\n slotProps={{\n textField: {\n ...other.slotProps?.textField,\n name,\n required,\n error: !!error,\n helperText: error?.message || helperText,\n autoComplete: 'off',\n spellCheck: 'false',\n fullWidth: true,\n inputProps: {\n tabIndex,\n },\n },\n }}\n />\n )}\n />\n );\n};\n\nexport default DateField;\n"]}
@@ -0,0 +1,4 @@
1
+ var T=(E=>(E.SALE_TOTAL_VALUE="SALE_TOTAL_VALUE",E.SALE_COUNT="SALE_COUNT",E.SALE_AVERAGE_VALUE="SALE_AVERAGE_VALUE",E))(T||{}),I=(E=>(E.A="A",E.B="B",E.C="C",E))(I||{}),o=(C=>(C.CLASSIFICATION="CLASSIFICATION",C.ABC_CURVE="ABC_CURVE",C))(o||{}),S=(A=>(A.ACTIVE="ACTIVE",A.AT_RISK="AT_RISK",A.INACTIVE="INACTIVE",A.LOST="LOST",A.NEW_CLIENT="NEW_CLIENT",A.PROSPECT="PROSPECT",A))(S||{}),L={["ACTIVE"]:{label:"Ativo",color:"#22C55E"},["AT_RISK"]:{label:"Em risco",color:"#FFAB00"},["INACTIVE"]:{label:"Inativo",color:"#FF5630"},["LOST"]:{label:"Perdido",color:"#C4CDD5"},["NEW_CLIENT"]:{label:"Novo cliente",color:"#8E33FF"},["PROSPECT"]:{label:"Prospect",color:"#00B8D9"}};
2
+
3
+ export { T as a, I as b, o as c, S as d, L as e };
4
+ //# sourceMappingURL=chunk-K2PWIYEM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/partnerAnalysis.ts"],"names":["RankingType","AbcCurve","SellerPortfolioQueryType","Status","STATUS_OPTIONS"],"mappings":"AAAO,IAAKA,OACVA,EAAA,iBAAmB,mBACnBA,EAAA,WAAa,aACbA,EAAA,mBAAqB,qBAHXA,OAAA,IAMAC,OACVA,EAAA,EAAI,IACJA,EAAA,EAAI,IACJA,EAAA,EAAI,IAHMA,OAAA,IAMAC,OACVA,EAAA,eAAiB,iBACjBA,EAAA,UAAY,YAFFA,OAAA,IAKAC,OACVA,EAAA,OAAS,SACTA,EAAA,QAAU,UACVA,EAAA,SAAW,WACXA,EAAA,KAAO,OACPA,EAAA,WAAa,aACbA,EAAA,SAAW,WANDA,OAAA,IASCC,EACX,CACE,CAAC,QAAa,EAAG,CACf,MAAO,QACP,MAAO,SACT,EACA,CAAC,SAAc,EAAG,CAChB,MAAO,WACP,MAAO,SACT,EACA,CAAC,UAAe,EAAG,CACjB,MAAO,UACP,MAAO,SACT,EACA,CAAC,MAAW,EAAG,CACb,MAAO,UACP,MAAO,SACT,EACA,CAAC,YAAiB,EAAG,CACnB,MAAO,eACP,MAAO,SACT,EACA,CAAC,UAAe,EAAG,CACjB,MAAO,WACP,MAAO,SACT,CACF","sourcesContent":["export enum RankingType {\n SALE_TOTAL_VALUE = 'SALE_TOTAL_VALUE',\n SALE_COUNT = 'SALE_COUNT',\n SALE_AVERAGE_VALUE = 'SALE_AVERAGE_VALUE',\n}\n\nexport enum AbcCurve {\n A = 'A',\n B = 'B',\n C = 'C',\n}\n\nexport enum SellerPortfolioQueryType {\n CLASSIFICATION = 'CLASSIFICATION',\n ABC_CURVE = 'ABC_CURVE',\n}\n\nexport enum Status {\n ACTIVE = 'ACTIVE',\n AT_RISK = 'AT_RISK',\n INACTIVE = 'INACTIVE',\n LOST = 'LOST',\n NEW_CLIENT = 'NEW_CLIENT',\n PROSPECT = 'PROSPECT',\n}\n\nexport const STATUS_OPTIONS: Record<Status, { label: string; color: string }> =\n {\n [Status.ACTIVE]: {\n label: 'Ativo',\n color: '#22C55E',\n },\n [Status.AT_RISK]: {\n label: 'Em risco',\n color: '#FFAB00',\n },\n [Status.INACTIVE]: {\n label: 'Inativo',\n color: '#FF5630',\n },\n [Status.LOST]: {\n label: 'Perdido',\n color: '#C4CDD5',\n },\n [Status.NEW_CLIENT]: {\n label: 'Novo cliente',\n color: '#8E33FF',\n },\n [Status.PROSPECT]: {\n label: 'Prospect',\n color: '#00B8D9',\n },\n };\n"]}
@@ -0,0 +1,7 @@
1
+ import { d, e } from './chunk-ERLI5GAP.js';
2
+ import r from 'dayjs';
3
+
4
+ var n="YYYY-MM-DD",i=Object.values(d).map(e$1=>({label:e[e$1],value:e$1}));function o(e){let t=r().startOf("day");switch(e){case"TODAY":return {start_date:t.toDate(),end_date:t.toDate()};case"YESTERDAY":{let a=t.subtract(1,"day");return {start_date:a.toDate(),end_date:a.toDate()}}case"LAST_7_DAYS":return {start_date:t.subtract(6,"day").toDate(),end_date:t.toDate()};case"LAST_28_DAYS":return {start_date:t.subtract(27,"day").toDate(),end_date:t.toDate()};case"LAST_90_DAYS":return {start_date:t.subtract(89,"day").toDate(),end_date:t.toDate()};case"LAST_WEEK":{let a=t.subtract(1,"week").startOf("week"),d=a.endOf("week");return {start_date:a.toDate(),end_date:d.toDate()}}case"LAST_MONTH":{let a=t.subtract(1,"month").startOf("month"),d=a.endOf("month");return {start_date:a.toDate(),end_date:d.toDate()}}case"THIS_MONTH":return {start_date:t.startOf("month").toDate(),end_date:t.toDate()};case"THIS_YEAR":return {start_date:t.startOf("year").toDate(),end_date:t.endOf("year").toDate()};case"OTHER":default:return {start_date:t.subtract(6,"day").toDate(),end_date:t.toDate()}}}function l(){let e=o("LAST_7_DAYS");return {period:"LAST_7_DAYS",start_date:r(e.start_date).format(n),end_date:r(e.end_date).format(n)}}function S(e){let t=o(e);return {period:e,start_date:r(t.start_date).format(n),end_date:r(t.end_date).format(n)}}function f(e,t){if(!e||!t)return "OTHER";let a=i.find(({value:d})=>{if(d==="OTHER")return !1;let s=o(d);return e.toDateString()===s.start_date.toDateString()&&t.toDateString()===s.end_date.toDateString()});return a?a.value:"OTHER"}function T(e){return {period:e.period,start_date:e.start_date?r(e.start_date).format(n):"",end_date:e.end_date?r(e.end_date).format(n):""}}
5
+
6
+ export { i as a, o as b, l as c, S as d, f as e, T as f };
7
+ //# sourceMappingURL=chunk-UWTX4JMW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/periodDates.ts"],"names":["dayjs","DATE_FORMAT","periodOptions","FilterPeriod","period","FILTER_PERIOD_LABELS","getPeriodDates","today","yesterday","lastWeekStart","lastWeekEnd","lastMonthStart","lastMonthEnd","getDefaultFilterDateState","dates","getFilterDateStateFor","findMatchingPeriod","startDate","endDate","match","value","toFilterDateState","form"],"mappings":"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","sourcesContent":["import dayjs from 'dayjs';\n\nimport { FilterDateState } from 'types/analytics';\nimport { FILTER_PERIOD_LABELS, FilterPeriod } from 'utils/analytics';\n\nconst DATE_FORMAT = 'YYYY-MM-DD';\n\nexport const periodOptions = Object.values(FilterPeriod).map(period => ({\n label: FILTER_PERIOD_LABELS[period],\n value: period,\n}));\n\nexport function getPeriodDates(period: FilterPeriod): {\n start_date: Date;\n end_date: Date;\n} {\n const today = dayjs().startOf('day');\n\n switch (period) {\n case FilterPeriod.TODAY:\n return {\n start_date: today.toDate(),\n end_date: today.toDate(),\n };\n\n case FilterPeriod.YESTERDAY: {\n const yesterday = today.subtract(1, 'day');\n return {\n start_date: yesterday.toDate(),\n end_date: yesterday.toDate(),\n };\n }\n\n case FilterPeriod.LAST_7_DAYS:\n return {\n start_date: today.subtract(6, 'day').toDate(),\n end_date: today.toDate(),\n };\n\n case FilterPeriod.LAST_28_DAYS:\n return {\n start_date: today.subtract(27, 'day').toDate(),\n end_date: today.toDate(),\n };\n\n case FilterPeriod.LAST_90_DAYS:\n return {\n start_date: today.subtract(89, 'day').toDate(),\n end_date: today.toDate(),\n };\n\n case FilterPeriod.LAST_WEEK: {\n const lastWeekStart = today.subtract(1, 'week').startOf('week');\n const lastWeekEnd = lastWeekStart.endOf('week');\n return {\n start_date: lastWeekStart.toDate(),\n end_date: lastWeekEnd.toDate(),\n };\n }\n\n case FilterPeriod.LAST_MONTH: {\n const lastMonthStart = today.subtract(1, 'month').startOf('month');\n const lastMonthEnd = lastMonthStart.endOf('month');\n return {\n start_date: lastMonthStart.toDate(),\n end_date: lastMonthEnd.toDate(),\n };\n }\n\n case FilterPeriod.THIS_MONTH:\n return {\n start_date: today.startOf('month').toDate(),\n end_date: today.toDate(),\n };\n\n case FilterPeriod.THIS_YEAR:\n return {\n start_date: today.startOf('year').toDate(),\n end_date: today.endOf('year').toDate(),\n };\n\n case FilterPeriod.OTHER:\n default:\n return {\n start_date: today.subtract(6, 'day').toDate(),\n end_date: today.toDate(),\n };\n }\n}\n\nexport function getDefaultFilterDateState(): FilterDateState {\n const dates = getPeriodDates(FilterPeriod.LAST_7_DAYS);\n return {\n period: FilterPeriod.LAST_7_DAYS,\n start_date: dayjs(dates.start_date).format(DATE_FORMAT),\n end_date: dayjs(dates.end_date).format(DATE_FORMAT),\n };\n}\n\nexport function getFilterDateStateFor(period: FilterPeriod): FilterDateState {\n const dates = getPeriodDates(period);\n return {\n period,\n start_date: dayjs(dates.start_date).format(DATE_FORMAT),\n end_date: dayjs(dates.end_date).format(DATE_FORMAT),\n };\n}\n\nexport function findMatchingPeriod(\n startDate: Date | null,\n endDate: Date | null,\n): FilterPeriod {\n if (!startDate || !endDate) return FilterPeriod.OTHER;\n\n const match = periodOptions.find(({ value }) => {\n if (value === FilterPeriod.OTHER) return false;\n\n const dates = getPeriodDates(value);\n\n return (\n startDate.toDateString() === dates.start_date.toDateString() &&\n endDate.toDateString() === dates.end_date.toDateString()\n );\n });\n\n return match ? (match.value as FilterPeriod) : FilterPeriod.OTHER;\n}\n\nexport function toFilterDateState(form: {\n period: FilterPeriod;\n start_date: Date | null;\n end_date: Date | null;\n}): FilterDateState {\n return {\n period: form.period,\n start_date: form.start_date\n ? dayjs(form.start_date).format(DATE_FORMAT)\n : '',\n end_date: form.end_date ? dayjs(form.end_date).format(DATE_FORMAT) : '',\n };\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { DateRangeCalendar } from '@mui/x-date-pickers-pro';
2
+ import e from 'dayjs';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ var r=a=>[a?.[0]?e(a[0]):null,a?.[1]?e(a[1]):null],u=a=>[a[0]?a[0].toDate():null,a[1]?a[1].toDate():null],s=({value:a,onChange:l,...n})=>{let t=r(a);return jsx(DateRangeCalendar,{...n,value:t,onChange:o=>{l(u(o));}})},C=s;
6
+
7
+ export { r as a, u as b, C as c };
8
+ //# sourceMappingURL=chunk-VGTQYKAC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/DateRangeCalendar/index.tsx"],"names":["MuiDateRangeCalendar","dayjs","jsx","toCalendarValue","value","toDateRange","newRange","DateRangeCalendar","onChange","other","calendarValue","DateRangeCalendar_default"],"mappings":"AAAA,OAAS,qBAAqBA,MAA4B,0BAC1D,OAAOC,MAA2B,QAkC9B,cAAAC,MAAA,oBA1BG,IAAMC,EACXC,GACiC,CACjCA,IAAQ,CAAC,EAAIH,EAAMG,EAAM,CAAC,CAAC,EAAI,KAC/BA,IAAQ,CAAC,EAAIH,EAAMG,EAAM,CAAC,CAAC,EAAI,IACjC,EAEaC,EACXC,GACmB,CACnBA,EAAS,CAAC,EAAIA,EAAS,CAAC,EAAE,OAAO,EAAI,KACrCA,EAAS,CAAC,EAAIA,EAAS,CAAC,EAAE,OAAO,EAAI,IACvC,EAEMC,EAAoB,CAAC,CACzB,MAAAH,EACA,SAAAI,EACA,GAAGC,CACL,IAA8B,CAC5B,IAAMC,EAAgBP,EAAgBC,CAAK,EAM3C,OACEF,EAACF,EAAA,CACE,GAAGS,EACJ,MAAOC,EACP,SARkBJ,GAA2C,CAC/DE,EAASH,EAAYC,CAAQ,CAAC,CAChC,EAOE,CAEJ,EAEOK,EAAQJ","sourcesContent":["import { DateRangeCalendar as MuiDateRangeCalendar } from '@mui/x-date-pickers-pro';\nimport dayjs, { type Dayjs } from 'dayjs';\n\nimport {\n DateRangeCalendarProps,\n DateRangeValue,\n MaybeDateRangeValue,\n} from './props';\n\nexport const toCalendarValue = (\n value: MaybeDateRangeValue,\n): [Dayjs | null, Dayjs | null] => [\n value?.[0] ? dayjs(value[0]) : null,\n value?.[1] ? dayjs(value[1]) : null,\n];\n\nexport const toDateRange = (\n newRange: [Dayjs | null, Dayjs | null],\n): DateRangeValue => [\n newRange[0] ? newRange[0].toDate() : null,\n newRange[1] ? newRange[1].toDate() : null,\n];\n\nconst DateRangeCalendar = ({\n value,\n onChange,\n ...other\n}: DateRangeCalendarProps) => {\n const calendarValue = toCalendarValue(value);\n\n const handleChange = (newRange: [Dayjs | null, Dayjs | null]) => {\n onChange(toDateRange(newRange));\n };\n\n return (\n <MuiDateRangeCalendar\n {...other}\n value={calendarValue}\n onChange={handleChange}\n />\n );\n};\n\nexport default DateRangeCalendar;\n"]}
@@ -0,0 +1,8 @@
1
+ import { FormProvider } from 'react-hook-form';
2
+ import e from '@mui/material/Stack';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ var f=({id:r,children:m,onSubmit:t,methods:i,...p})=>jsx(FormProvider,{...i,children:jsx(e,{component:"form",id:r,onSubmit:t,flex:1,width:1,noValidate:!0,...p,children:m})}),h=f;
6
+
7
+ export { h as a };
8
+ //# sourceMappingURL=chunk-XAPSXJZO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/form/Form/index.tsx"],"names":["FormProvider","Stack","jsx","Form","id","children","onSubmit","methods","other","Form_default"],"mappings":"AACA,OAAS,gBAAAA,MAAoB,kBAC7B,OAAOC,MAAW,sBAaZ,cAAAC,MAAA,oBATN,IAAMC,EAAO,CAAC,CACZ,GAAAC,EACA,SAAAC,EACA,SAAAC,EACA,QAAAC,EACA,GAAGC,CACL,IAEIN,EAACF,EAAA,CAAc,GAAGO,EAChB,SAAAL,EAACD,EAAA,CACC,UAAU,OACV,GAAIG,EACJ,SAAUE,EACV,KAAM,EACN,MAAO,EACP,WAAU,GACT,GAAGE,EAEH,SAAAH,EACH,EACF,EAIGI,EAAQN","sourcesContent":["import { PropsWithChildren } from 'react';\nimport { FormProvider } from 'react-hook-form';\nimport Stack from '@mui/material/Stack';\n\nimport { FormProps } from './props';\n\nconst Form = ({\n id,\n children,\n onSubmit,\n methods,\n ...other\n}: PropsWithChildren<FormProps>) => {\n return (\n <FormProvider {...methods}>\n <Stack\n component=\"form\"\n id={id}\n onSubmit={onSubmit}\n flex={1}\n width={1}\n noValidate\n {...other}\n >\n {children}\n </Stack>\n </FormProvider>\n );\n};\n\nexport default Form;\n"]}
@@ -0,0 +1,6 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+
3
+ var a=n=>{let{viewBox:t,activeCoordX:e,referenceCircleColor:s,activeIndex:l}=n,r=t?.y;return r==null||l===null||e==null?null:jsx("circle",{cx:e,cy:r,r:6,fill:s,stroke:"#fff",strokeWidth:2,pointerEvents:"none"})},m=a;var u=11,d=6.5,h=(n,t)=>{let e=Math.max(4,Math.floor(t/d));if(n.length<=e)return [n,""];let l=n.slice(0,e).lastIndexOf(" "),r=l>0?l:e,i=n.slice(0,r).trim(),o=n.slice(r).trim(),f=o.length>e?`${o.slice(0,e-1)}\u2026`:o;return [i,f]},C=({x:n,y:t,payload:e,slotWidth:s=60})=>{if(n==null||t==null||!e)return null;let[l,r]=h(e.value,s-8);return jsx("g",{transform:`translate(${n},${t})`,children:jsxs("text",{textAnchor:"middle",fill:"#637381",fontSize:u,children:[jsx("tspan",{x:0,dy:14,children:l}),r&&jsx("tspan",{x:0,dy:14,children:r})]})})},v=C;
4
+
5
+ export { m as a, v as b };
6
+ //# sourceMappingURL=chunk-XL6SZZGI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Analytics/ReferenceCircle/index.tsx","../src/components/Analytics/WrappedTick/index.tsx"],"names":["jsx","ReferenceCircle","props","viewBox","activeCoordX","referenceCircleColor","activeIndex","baseY","ReferenceCircle_default","jsxs","FONT_SIZE","CHAR_WIDTH","splitLabel","text","maxWidth","charsPerLine","spaceIdx","breakAt","line1","rest","line2","WrappedTick","x","y","payload","slotWidth","WrappedTick_default"],"mappings":"AAYI,cAAAA,MAAA,oBAVJ,IAAMC,EAAmBC,GAAgC,CACvD,GAAM,CAAE,QAAAC,EAAS,aAAAC,EAAc,qBAAAC,EAAsB,YAAAC,CAAY,EAAIJ,EAE/DK,EAAQJ,GAAS,EAEvB,OAAII,GAAS,MAAQD,IAAgB,MAAQF,GAAgB,KACpD,KAIPJ,EAAC,UACC,GAAII,EACJ,GAAIG,EACJ,EAAG,EACH,KAAMF,EACN,OAAO,OACP,YAAa,EACb,cAAc,OAChB,CAEJ,EAEOG,EAAQP,ECKT,OACE,OAAAD,EADF,QAAAS,MAAA,oBA3BN,IAAMC,EAAY,GACZC,EAAa,IAEbC,EAAa,CAACC,EAAcC,IAAuC,CACvE,IAAMC,EAAe,KAAK,IAAI,EAAG,KAAK,MAAMD,EAAWH,CAAU,CAAC,EAElE,GAAIE,EAAK,QAAUE,EAAc,MAAO,CAACF,EAAM,EAAE,EAGjD,IAAMG,EADaH,EAAK,MAAM,EAAGE,CAAY,EACjB,YAAY,GAAG,EACrCE,EAAUD,EAAW,EAAIA,EAAWD,EAEpCG,EAAQL,EAAK,MAAM,EAAGI,CAAO,EAAE,KAAK,EACpCE,EAAON,EAAK,MAAMI,CAAO,EAAE,KAAK,EAChCG,EACJD,EAAK,OAASJ,EAAe,GAAGI,EAAK,MAAM,EAAGJ,EAAe,CAAC,UAAOI,EAEvE,MAAO,CAACD,EAAOE,CAAK,CACtB,EAEMC,EAAc,CAAC,CAAE,EAAAC,EAAG,EAAAC,EAAG,QAAAC,EAAS,UAAAC,EAAY,EAAG,IAAwB,CAC3E,GAAIH,GAAK,MAAQC,GAAK,MAAQ,CAACC,EAAS,OAAO,KAE/C,GAAM,CAACN,EAAOE,CAAK,EAAIR,EAAWY,EAAQ,MAAOC,EAAY,CAAC,EAE9D,OACEzB,EAAC,KAAE,UAAW,aAAasB,KAAKC,KAC9B,SAAAd,EAAC,QAAK,WAAW,SAAS,KAAK,UAAU,SAAUC,EACjD,UAAAV,EAAC,SAAM,EAAG,EAAG,GAAI,GACd,SAAAkB,EACH,EACCE,GACCpB,EAAC,SAAM,EAAG,EAAG,GAAI,GACd,SAAAoB,EACH,GAEJ,EACF,CAEJ,EAEOM,EAAQL","sourcesContent":["import { ReferenceCircleProps } from './props';\n\nconst ReferenceCircle = (props: ReferenceCircleProps) => {\n const { viewBox, activeCoordX, referenceCircleColor, activeIndex } = props;\n\n const baseY = viewBox?.y;\n\n if (baseY == null || activeIndex === null || activeCoordX == null) {\n return null;\n }\n\n return (\n <circle\n cx={activeCoordX}\n cy={baseY}\n r={6}\n fill={referenceCircleColor}\n stroke=\"#fff\"\n strokeWidth={2}\n pointerEvents=\"none\"\n />\n );\n};\n\nexport default ReferenceCircle;\n","import { WrappedTickProps } from './props';\n\nconst FONT_SIZE = 11;\nconst CHAR_WIDTH = 6.5;\n\nconst splitLabel = (text: string, maxWidth: number): [string, string] => {\n const charsPerLine = Math.max(4, Math.floor(maxWidth / CHAR_WIDTH));\n\n if (text.length <= charsPerLine) return [text, ''];\n\n const firstChunk = text.slice(0, charsPerLine);\n const spaceIdx = firstChunk.lastIndexOf(' ');\n const breakAt = spaceIdx > 0 ? spaceIdx : charsPerLine;\n\n const line1 = text.slice(0, breakAt).trim();\n const rest = text.slice(breakAt).trim();\n const line2 =\n rest.length > charsPerLine ? `${rest.slice(0, charsPerLine - 1)}…` : rest;\n\n return [line1, line2];\n};\n\nconst WrappedTick = ({ x, y, payload, slotWidth = 60 }: WrappedTickProps) => {\n if (x == null || y == null || !payload) return null;\n\n const [line1, line2] = splitLabel(payload.value, slotWidth - 8);\n\n return (\n <g transform={`translate(${x},${y})`}>\n <text textAnchor=\"middle\" fill=\"#637381\" fontSize={FONT_SIZE}>\n <tspan x={0} dy={14}>\n {line1}\n </tspan>\n {line2 && (\n <tspan x={0} dy={14}>\n {line2}\n </tspan>\n )}\n </text>\n </g>\n );\n};\n\nexport default WrappedTick;\n"]}
@@ -3,12 +3,12 @@ import e from '@mui/material/Box';
3
3
  import f from '@mui/material/Card';
4
4
  import b from '@mui/material/CardHeader';
5
5
  import w from '@mui/material/Checkbox';
6
- import r from '@mui/material/Stack';
6
+ import t from '@mui/material/Stack';
7
7
  import { styled } from '@mui/material/styles';
8
8
  import g from '@mui/material/Typography';
9
9
  import { jsxs, jsx } from 'react/jsx-runtime';
10
10
 
11
- var y=styled(f)(({theme:o})=>({width:"100%",border:`1px solid ${o.palette.divider}`,boxShadow:"none",overflow:"visible"})),k=styled(b)(({theme:o})=>({[o.breakpoints.down("sm")]:{flexWrap:"wrap",gap:o.spacing(2),"& .MuiCardHeader-action":{width:"100%"}}})),S=styled(r)({position:"relative",width:"100%",overflow:"visible","& .recharts-wrapper, & .recharts-wrapper *":{outline:"none !important",boxShadow:"none !important",WebkitTapHighlightColor:"transparent"}}),v=styled(e)(({theme:o})=>({backgroundColor:o.palette.background.paper,border:"1px solid",borderColor:o.palette.divider,borderRadius:o.shape.borderRadius,padding:o.spacing(1.5),boxShadow:o.shadows[3]})),T=styled(e)(({theme:o})=>({width:"100%",height:"1px",backgroundColor:o.palette.divider,marginBottom:o.spacing(1.5)})),D=styled(e,{shouldForwardProp:o=>o!=="dotColor"})(({dotColor:o})=>({width:10,height:10,borderRadius:"50%",backgroundColor:o})),I=styled(r)({flexDirection:"row",flexWrap:"wrap",justifyContent:"center",alignItems:"center",gap:16,marginTop:16}),H=styled(r)({flexDirection:"row",alignItems:"center",cursor:"pointer"}),R=styled(w,{shouldForwardProp:o=>o!=="checkboxColor"})(({checkboxColor:o})=>({color:o,"&.Mui-checked":{color:o},padding:4})),A=styled(r)({flexDirection:"row",alignItems:"flex-start",gap:32,marginBottom:24,flexWrap:"wrap"}),W=styled(e)(({theme:o})=>({width:"1px",height:40,backgroundColor:o.palette.divider,alignSelf:"center"})),z=styled(r)({minHeight:350,alignItems:"center",justifyContent:"center",gap:12});var L=()=>jsxs(r,{minHeight:300,alignItems:"center",justifyContent:"center",gap:1.5,children:[jsx(a,{icon:"CALENDAR_TODAY",width:60,color:"text.secondary"}),jsxs(r,{textAlign:"center",children:[jsx(g,{variant:"subtitle1",fontSize:"subtitle1.fontSize",children:"Nenhum dado dispon\xEDvel ainda"}),jsx(g,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:"Assim que houver registros, os dados ser\xE3o exibidos aqui."})]})]}),J=L;var M=o=>{let{x:p,y:d,payload:a,tickFormatter:l,index:u=0,maxChars:s=10}=o;if(p==null||d==null||!a)return null;let i=l?l(a.value,u):a.value,C=i.length>s?`${i.slice(0,s)}...`:i;return jsx("g",{transform:`translate(${p},${d})`,children:jsx("text",{x:0,y:0,dy:4,textAnchor:"end",fill:"#637381",fontSize:11,transform:"rotate(-45)",children:C})})},U=M;
11
+ var y=styled(f)(({theme:o})=>({width:"100%",border:`1px solid ${o.palette.divider}`,boxShadow:"none",overflow:"visible"})),k=styled(b)(({theme:o})=>({[o.breakpoints.down("sm")]:{flexWrap:"wrap",gap:o.spacing(2),"& .MuiCardHeader-action":{width:"100%"}}})),v=styled(t)({position:"relative",width:"100%",overflow:"visible","& .recharts-wrapper, & .recharts-wrapper *":{outline:"none !important",boxShadow:"none !important",WebkitTapHighlightColor:"transparent"}}),S=styled(e)(({theme:o})=>({backgroundColor:o.palette.background.paper,border:"1px solid",borderColor:o.palette.divider,borderRadius:o.shape.borderRadius,padding:o.spacing(1.5),boxShadow:o.shadows[3]})),T=styled(e)(({theme:o})=>({width:"100%",height:"1px",backgroundColor:o.palette.divider,marginBottom:o.spacing(1.5)})),D=styled(e,{shouldForwardProp:o=>o!=="dotColor"})(({dotColor:o})=>({width:10,height:10,borderRadius:"50%",backgroundColor:o})),I=styled(t)({flexDirection:"row",flexWrap:"wrap",justifyContent:"center",alignItems:"center",gap:16,marginTop:16}),H=styled(t)({flexDirection:"row",alignItems:"center",cursor:"pointer"}),R=styled(w,{shouldForwardProp:o=>o!=="checkboxColor"})(({checkboxColor:o})=>({color:o,"&.Mui-checked":{color:o},padding:4})),A=styled(t)({flexDirection:"row",alignItems:"flex-start",gap:32,marginBottom:24,flexWrap:"wrap"}),W=styled(e)(({theme:o})=>({width:"1px",height:40,backgroundColor:o.palette.divider,alignSelf:"center"})),L=styled(t)({minHeight:350,alignItems:"center",justifyContent:"center",gap:12});var M=()=>jsxs(t,{minHeight:300,alignItems:"center",justifyContent:"center",gap:1.5,children:[jsx(a,{icon:"CALENDAR_TODAY",width:60,color:"text.secondary"}),jsxs(t,{textAlign:"center",children:[jsx(g,{variant:"subtitle1",children:"Nenhum dado dispon\xEDvel ainda"}),jsx(g,{variant:"body2",color:"text.secondary",children:"Assim que houver registros, os dados ser\xE3o exibidos aqui."})]})]}),J=M;var E=o=>{let{x:p,y:d,payload:a,tickFormatter:l,index:C=0,maxChars:s=10}=o;if(p==null||d==null||!a)return null;let i=l?l(a.value,C):a.value,u=i.length>s?`${i.slice(0,s)}...`:i;return jsx("g",{transform:`translate(${p},${d})`,children:jsx("text",{x:0,y:0,dy:4,textAnchor:"end",fill:"#637381",fontSize:11,transform:"rotate(-45)",children:u})})},U=E;
12
12
 
13
- export { y as a, k as b, S as c, v as d, T as e, D as f, I as g, H as h, R as i, A as j, W as k, z as l, J as m, U as n };
14
- //# sourceMappingURL=chunk-UC2R4AXD.js.map
13
+ export { y as a, k as b, v as c, S as d, T as e, D as f, I as g, H as h, R as i, A as j, W as k, L as l, J as m, U as n };
14
+ //# sourceMappingURL=chunk-XQZPUMVQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Analytics/ChartStyles/styles.ts","../src/components/Analytics/EmptyState/index.tsx","../src/components/Analytics/RotatedTick/index.tsx"],"names":["Box","MuiCard","MuiCardHeader","MuiCheckbox","Stack","styled","ChartCard","theme","ChartCardHeader","ChartWrapper","TooltipContainer","TooltipDivider","TooltipDot","prop","dotColor","LegendContainer","LegendItem","ColoredCheckbox","checkboxColor","SummaryStack","SummaryDivider","EmptyStateContainer","Typography","jsx","jsxs","EmptyState","Icon_default","EmptyState_default","RotatedTick","props","x","y","payload","tickFormatter","index","maxChars","raw","label","RotatedTick_default"],"mappings":"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","sourcesContent":["import Box from '@mui/material/Box';\nimport MuiCard from '@mui/material/Card';\nimport MuiCardHeader from '@mui/material/CardHeader';\nimport MuiCheckbox from '@mui/material/Checkbox';\nimport Stack from '@mui/material/Stack';\nimport { styled } from '@mui/material/styles';\n\nexport const ChartCard = styled(MuiCard)(({ theme }) => ({\n width: '100%',\n\n border: `1px solid ${theme.palette.divider}`,\n\n boxShadow: 'none',\n overflow: 'visible',\n}));\n\nexport const ChartCardHeader = styled(MuiCardHeader)(({ theme }) => ({\n [theme.breakpoints.down('sm')]: {\n flexWrap: 'wrap',\n gap: theme.spacing(2),\n\n '& .MuiCardHeader-action': {\n width: '100%',\n },\n },\n}));\n\nexport const ChartWrapper = styled(Stack)({\n position: 'relative',\n width: '100%',\n overflow: 'visible',\n\n '& .recharts-wrapper, & .recharts-wrapper *': {\n outline: 'none !important',\n boxShadow: 'none !important',\n WebkitTapHighlightColor: 'transparent',\n },\n});\n\nexport const TooltipContainer = styled(Box)(({ theme }) => ({\n backgroundColor: theme.palette.background.paper,\n border: '1px solid',\n borderColor: theme.palette.divider,\n borderRadius: theme.shape.borderRadius,\n padding: theme.spacing(1.5),\n boxShadow: theme.shadows[3],\n}));\n\nexport const TooltipDivider = styled(Box)(({ theme }) => ({\n width: '100%',\n height: '1px',\n backgroundColor: theme.palette.divider,\n marginBottom: theme.spacing(1.5),\n}));\n\nexport const TooltipDot = styled(Box, {\n shouldForwardProp: prop => prop !== 'dotColor',\n})<{ dotColor: string }>(({ dotColor }) => ({\n width: 10,\n height: 10,\n borderRadius: '50%',\n backgroundColor: dotColor,\n}));\n\nexport const LegendContainer = styled(Stack)({\n flexDirection: 'row',\n flexWrap: 'wrap',\n justifyContent: 'center',\n alignItems: 'center',\n gap: 16,\n marginTop: 16,\n});\n\nexport const LegendItem = styled(Stack)({\n flexDirection: 'row',\n alignItems: 'center',\n cursor: 'pointer',\n});\n\nexport const ColoredCheckbox = styled(MuiCheckbox, {\n shouldForwardProp: prop => prop !== 'checkboxColor',\n})<{ checkboxColor: string }>(({ checkboxColor }) => ({\n color: checkboxColor,\n '&.Mui-checked': { color: checkboxColor },\n padding: 4,\n}));\n\nexport const SummaryStack = styled(Stack)({\n flexDirection: 'row',\n alignItems: 'flex-start',\n gap: 32,\n marginBottom: 24,\n flexWrap: 'wrap',\n});\n\nexport const SummaryDivider = styled(Box)(({ theme }) => ({\n width: '1px',\n height: 40,\n backgroundColor: theme.palette.divider,\n alignSelf: 'center',\n}));\n\nexport const EmptyStateContainer = styled(Stack)({\n minHeight: 350,\n alignItems: 'center',\n justifyContent: 'center',\n gap: 12,\n});\n","import Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport Icon from 'components/Icon';\n\nconst EmptyState = () => {\n return (\n <Stack\n minHeight={300}\n alignItems=\"center\"\n justifyContent=\"center\"\n gap={1.5}\n >\n <Icon icon=\"CALENDAR_TODAY\" width={60} color=\"text.secondary\" />\n\n <Stack textAlign=\"center\">\n <Typography variant=\"subtitle1\">\n Nenhum dado disponível ainda\n </Typography>\n\n <Typography variant=\"body2\" color=\"text.secondary\">\n Assim que houver registros, os dados serão exibidos aqui.\n </Typography>\n </Stack>\n </Stack>\n );\n};\n\nexport default EmptyState;\n","import { RotatedTickProps } from './props';\n\nconst RotatedTick = (props: RotatedTickProps) => {\n const { x, y, payload, tickFormatter, index = 0, maxChars = 10 } = props;\n if (x == null || y == null || !payload) return null;\n\n const raw = tickFormatter\n ? tickFormatter(payload.value, index)\n : payload.value;\n const label = raw.length > maxChars ? `${raw.slice(0, maxChars)}...` : raw;\n\n return (\n <g transform={`translate(${x},${y})`}>\n <text\n x={0}\n y={0}\n dy={4}\n textAnchor=\"end\"\n fill=\"#637381\"\n fontSize={11}\n transform=\"rotate(-45)\"\n >\n {label}\n </text>\n </g>\n );\n};\n\nexport default RotatedTick;\n"]}
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ComponentType, ReactNode } from 'react';
3
- import { ViewMode } from '../../../types/analytics.js';
3
+ import { ViewMode } from '../../../utils/analytics.js';
4
4
  import { QuotationDashboardSeriesItem, OverviewDetailBaseProps, OverviewDetailProps, RevenueGoalDashboardSeriesItem, RevenueGoalDashboardKpis, SalesForecastDashboardSeriesItem } from '../../../types/overviewAnalytics.js';
5
5
  import { GridQuery } from '../../../types/filter.js';
6
6
  import '../../../types/entityMetadata.js';
@@ -1,6 +1,6 @@
1
1
  import { b, c, d as d$3 } from '../../../chunk-FYG3YWFZ.js';
2
- import { a, m, c as c$1, n } from '../../../chunk-UC2R4AXD.js';
3
- import { b as b$2 } from '../../../chunk-Y2SILVOR.js';
2
+ import { b as b$2 } from '../../../chunk-ERLI5GAP.js';
3
+ import { a, m, c as c$1, n } from '../../../chunk-XQZPUMVQ.js';
4
4
  import { a as a$7 } from '../../../chunk-DRGARBKB.js';
5
5
  import { a as a$6 } from '../../../chunk-J5XGGHQ7.js';
6
6
  import { a as a$4 } from '../../../chunk-J5B2YJSR.js';
@@ -31,17 +31,17 @@ import { a as a$5 } from '../../../chunk-RMYYQLRJ.js';
31
31
  import { useState, useCallback, useMemo, useRef } from 'react';
32
32
  import mt from '@mui/material/CardContent';
33
33
  import dt from '@mui/material/CardHeader';
34
- import L from '@mui/material/Stack';
34
+ import D from '@mui/material/Stack';
35
35
  import { ResponsiveContainer, BarChart, CartesianGrid, XAxis, YAxis, Tooltip, Bar, ComposedChart, Line } from 'recharts';
36
36
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
37
37
  import ue from '@mui/material/Divider';
38
- import T from '@mui/material/Typography';
38
+ import M from '@mui/material/Typography';
39
39
  import He from '@mui/material/Checkbox';
40
40
  import Ke from '@mui/material/FormControlLabel';
41
41
  import xt from '@mui/material/Link';
42
42
  import { styled, alpha } from '@mui/material/styles';
43
43
 
44
- var ee={orders:"#22C55E",quotations:"#0EA5E9"};var Yo=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:t+12,height:r+6,fill:"#919EAB",opacity:.16,rx:6}),Re=Yo;var qo=({x:e=0,y:o=0,width:t=0,index:r=0,data:a,visibleSeries:i,isMonthly:n,shouldRotateLabels:l})=>{if(!n||l)return null;let c=a[r];if(!c)return null;let s=0;return i.orders&&(s+=c.order_count??0),i.quotations&&(s+=c.quotation_count??0),s?jsx("text",{x:e+t/2,y:o-8,textAnchor:"middle",fontSize:11,fill:"#212B36",children:s}):null},Oe=qo;var Qo=({active:e,payload:o,label:t,viewMode:r})=>{if(!e||!o?.length)return null;let a=r==="DAILY",i=String(t),n=i.split("-");if(n.length>=2){let s=parseInt(n[1],10)-1,p=b[s];a&&n.length===3?i=`${parseInt(n[2],10)} de ${p} de ${n[0]}`:a||(i=`${p} de ${n[0]}`);}let l=o[0].payload,c=[{name:"Vendas",count:l.order_count??0,value:l.order_value??0,color:o.find(s=>s.dataKey==="order_count")?.color??"#22C55E"},{name:"Or\xE7amentos",count:l.quotation_count??0,value:l.quotation_value??0,color:o.find(s=>s.dataKey==="quotation_count")?.color??"#0EA5E9"}];return jsxs(a$7,{minWidth:{xs:"auto",sm:300},p:1,gap:1,children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:i}),jsx(ue,{}),jsx(L,{children:c.map((s,p)=>jsxs(L,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:2,"data-testid":`tooltip-item-${p}`,children:[jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsx(L,{width:6,height:6,borderRadius:"50%",bgcolor:s.color}),jsx(T,{variant:"body2",fontSize:"body2.fontSize",noWrap:!0,children:s.name})]}),jsxs(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.disabled",noWrap:!0,children:[s.count," ",s.count===1?"pedido":"pedidos","\u2002",jsx(T,{component:"span",variant:"body2",fontSize:"body2.fontSize",color:"text.primary",children:h(s.value)})]})]},s.name))})]})},mo=Qo;var at=({data:e,viewMode:o,visibleSeries:t,activeBarIndex:r,onMouseMove:a,onMouseLeave:i,onBarClick:n$1})=>{let l=o==="MONTHLY",[c$2,s]=useState(0),p=useRef(null),m=useCallback(d=>{p.current&&(p.current.disconnect(),p.current=null),d&&(s(d.clientWidth),p.current=new ResizeObserver(()=>s(d.clientWidth)),p.current.observe(d));},[]),y=useMemo(()=>!l||c$2===0||e.length===0?!1:(c$2-60)/e.length<80,[l,c$2,e.length]),C=useMemo(()=>e.some(d=>(d.order_count??0)>0),[e]),h=useMemo(()=>e.some(d=>(d.quotation_count??0)>0),[e]),v=useMemo(()=>{if(!e.length)return [0,1];let d=Math.max(...e.map(f=>(f.order_count??0)+(f.quotation_count??0)));return [0,d>0?d*1.15:1]},[e]),z=useMemo(()=>{let[,d]=v,f=d/6;return [...new Set(Array.from({length:7},(x,M)=>Math.round(f*M)))]},[v]),S=t.quotations&&h,g=t.orders&&C&&!S,B=useMemo(()=>l?c:d$3,[l]);return jsx(c$1,{ref:m,children:jsx(ResponsiveContainer,{width:"100%",height:250,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:y?-90:0,left:20},barCategoryGap:"20%",style:{cursor:"pointer"},onMouseMove:a,onMouseLeave:i,onClick:d=>{d?.activeTooltipIndex!=null&&n$1?.(Number(d.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...y&&{interval:0,height:120},tick:y?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:B}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:d=>d$1(d),domain:v,ticks:z}),jsx(Tooltip,{content:jsx(mo,{viewMode:o}),cursor:!1}),jsx(Bar,{dataKey:"order_count",name:"Vendas",fill:ee.orders,stackId:"orders",maxBarSize:48,isAnimationActive:!1,hide:!t.orders,background:jsx(Re,{activeBarIndex:r}),radius:g?[4,4,0,0]:void 0,...g&&{label:{position:"top",fontSize:11,fill:"#212B36",content:jsx(Oe,{data:e,visibleSeries:t,isMonthly:l,shouldRotateLabels:y})}}}),jsx(Bar,{dataKey:"quotation_count",name:"Or\xE7amentos",fill:ee.quotations,stackId:"orders",maxBarSize:48,isAnimationActive:!1,hide:!t.quotations,radius:S?[4,4,0,0]:void 0,...!t.orders&&{background:jsx(Re,{activeBarIndex:r})},...S&&{label:{position:"top",fontSize:11,fill:"#212B36",content:jsx(Oe,{data:e,visibleSeries:t,isMonthly:l,shouldRotateLabels:y})}}})]})})})},uo=at;var st=({visibleSeries:e,onToggleSerie:o})=>jsxs(L,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ke,{control:jsx(He,{checked:e.orders,onChange:()=>o("orders"),sx:{"&.Mui-checked":{color:ee.orders}}}),label:"Vendas"}),jsx(Ke,{control:jsx(He,{checked:e.quotations,onChange:()=>o("quotations"),sx:{"&.Mui-checked":{color:ee.quotations}}}),label:"Or\xE7amentos"})]}),So=st;var ct=({ordersTotal:e,quotationsTotal:o,isMonthly:t})=>{let r=b$1("down","md");return jsxs(L,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[r&&jsx(ue,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(L,{children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:t?"Vendas no ano":"Vendas no m\xEAs"}),jsxs(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",children:[e," vendas"]})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:t?"Or\xE7amentos no ano":"Or\xE7amentos no m\xEAs"}),jsxs(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",children:[o," or\xE7amentos"]})]})]})},Ae=ct;var ft=({data:e,viewMode:o,selectedYear:t,DetailComponent:r})=>{let a$2=o==="MONTHLY",[i,n]=useState({orders:!0,quotations:!0}),[l,c]=useState(null),[s,p]=useState(!1),[m$1,y]=useState(""),[C,h]=useState(0),v=useCallback(f=>{n(x=>({...x,[f]:!x[f]}));},[]),z=useCallback(f=>{f?.activeTooltipIndex!=null&&c(Number(f.activeTooltipIndex));},[]),S=useCallback(()=>c(null),[]),g=useCallback(f=>{let x=e[f];x&&(y(x.label),h(x.order_value),p(!0));},[e]),B=useCallback(()=>{p(!1);},[]),d=useMemo(()=>{let f=e.reduce((M,N)=>M+(N.order_count??0),0),x=e.reduce((M,N)=>M+(N.quotation_count??0),0);return {ordersTotal:f,quotationsTotal:x}},[e]);return jsxs(Fragment,{children:[jsxs(a,{children:[jsx(dt,{title:"Quantidade de pedidos por tipo"}),jsx(mt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(L,{gap:3,children:[jsx(L,{display:{xs:"none",md:"block"},children:jsx(Ae,{isMonthly:a$2,ordersTotal:d.ordersTotal,quotationsTotal:d.quotationsTotal})}),jsx(uo,{data:e,viewMode:o,visibleSeries:i,activeBarIndex:l,onMouseMove:z,onMouseLeave:S,onBarClick:g}),jsx(So,{visibleSeries:i,onToggleSerie:v}),jsx(L,{display:{xs:"block",md:"none"},children:jsx(Ae,{isMonthly:a$2,ordersTotal:d.ordersTotal,quotationsTotal:d.quotationsTotal})})]})})})]}),m$1&&r&&jsx(r,{open:s,onClose:B,label:m$1,viewMode:o,selectedYear:t,totalValue:C})]})},ut=ft;var ht=({title:e,viewMode:o,selectedYear:t,periodLabel:r})=>jsxs(L,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(T,{variant:"subtitle1",fontSize:"subtitle1.fontSize",noWrap:!0,children:"Detalhes do relat\xF3rio"}),jsxs(L,{direction:"row",alignItems:"center",columnGap:1.5,rowGap:0,flexWrap:"wrap",children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",flexShrink:0,children:e}),"\u2022",jsx(T,{variant:"body2",fontSize:"body2.fontSize",flexShrink:0,children:b$2[o]}),"\u2022",jsx(T,{variant:"body2",fontSize:"body2.fontSize",flexShrink:0,children:t}),"\u2022",jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",noWrap:!0,children:r})]})]}),xo=ht;var ko=styled(ue)(()=>({height:30,alignSelf:"center",borderStyle:"dashed"})),zo=styled(L)(({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 Ct=e=>jsx(L,{justifyContent:"center",height:1,children:jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.primary",children:e.id})}),kt=(e,o)=>jsx(L,{justifyContent:"center",height:1,children:e?.partner?.id&&o?jsx(xt,{component:"a",href:o(e.partner.id),target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",fontSize:"subtitle2.fontSize",sx:{textDecoration:"underline"},noWrap:!0,children:e.partner?.name||"-"}):jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.primary",noWrap:!0,children:e.partner?.name||"-"})}),zt=e=>jsx(L,{justifyContent:"center",height:1,children:jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.primary",children:h(e.total_value)})}),Tt=e=>jsx(L,{justifyContent:"center",height:1,children:e.negotiation_date?jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.primary",children:d$2(e.negotiation_date,"DD/MM/YYYY")}):"-"}),Mt=e=>jsx(L,{justifyContent:"center",height:1,children:e.status||"-"}),Lt=e=>jsx(zo,{children:jsxs(L,{gap:1,children:[jsxs(L,{children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:"Pedido"}),jsx(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",color:"text.primary",children:e.id})]}),jsxs(L,{children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:"Cliente"}),jsx(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",color:"primary.main",children:e.partner?.name||"-"})]}),jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsxs(L,{flex:1,overflow:"hidden",children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",noWrap:!0,children:"Valor do pedido"}),jsx(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",color:"text.primary",noWrap:!0,children:h(e.total_value)})]}),jsx(ue,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(L,{flex:1,overflow:"hidden",children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",noWrap:!0,children:"Data"}),jsx(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",color:"text.primary",noWrap:!0,children:e.negotiation_date?d$2(e.negotiation_date,"DD/MM/YYYY"):"-"})]})]}),jsxs(L,{gap:.5,children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:"Status"}),jsx(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",color:"text.primary",children:e.status||"-"})]})]})},e.id),Dt=({open:e,onClose:o,title:t,viewMode:r,selectedYear:a,totalValue:i,periodLabel:n,suffix:l,rows:c,total:s,isLoading:p,isFetching:m,page:y,perPage:C,onSearch:h$1,onPaginationChange:v,buildPartnerLink:z,mobileItemSlot:S})=>{let g=b$1("down","sm"),B=jsxs(L,{gap:3,children:[jsxs(L,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",gap:2,children:[jsxs(L,{minWidth:0,direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:[jsxs(L,{children:[jsxs(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:["Vendas ",l]}),jsx(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",color:"text.primary",children:h(i)})]}),jsx(ko,{orientation:"vertical",flexItem:!0}),jsxs(L,{children:[jsxs(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:["Qtd. de pedidos ",l]}),jsx(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",color:"text.primary",children:s})]})]}),jsx(a$2,{size:"small",placeholder:"Buscar",onSearch:h$1,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(d,{title:"Pedidos",header:jsx(Fragment,{}),headerProps:{p:0},columns:[{field:"external_id",headerName:"Pedido",flex:1,renderCell:({row:f})=>Ct(f)},{field:"partner_name",headerName:"Cliente",flex:1,renderCell:({row:f})=>kt(f,z)},{field:"total_value",headerName:"Valor do pedido",flex:1,renderCell:({row:f})=>zt(f)},{field:"created_at",headerName:"Data",flex:1,renderCell:({row:f})=>Tt(f)},{field:"last_status",headerName:"Status",flex:1,renderCell:({row:f})=>Mt(f)}],rows:c,rowCount:s,mobileRender:f=>S?S(f):Lt(f),loading:p,fetching:m,paginationModel:{page:y,pageSize:C},onPaginationChange:v,paginationMode:"server",disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),d$1=jsx(xo,{title:t,viewMode:r,selectedYear:a,periodLabel:n});return g?jsx(a$3,{open:e,onClose:o,headerTitle:d$1,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:B}):jsx(a$4,{open:e,onClose:o,maxWidth:"lg",dialogTitle:d$1,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:B})},wt=Dt;var We=(e,o)=>{let t=e.split("-");if(o==="DAILY"&&t.length===3){let n=`${t[0]}-${t[1]}-${t[2]}`;return {startDate:n,endDate:n}}let r=parseInt(t[0],10),a=parseInt(t[1],10),i=new Date(r,a,0).getDate();return {startDate:`${t[0]}-${t[1]}-01`,endDate:`${t[0]}-${t[1]}-${String(i).padStart(2,"0")}`}},_e=(e,o)=>{let t=e.split("-"),r=parseInt(t[1],10)-1,a=b[r]??"";if(o==="DAILY"&&t.length===3){let i=parseInt(t[2],10);return `${a} - Dia ${i}`}return a},Ee=e=>e==="MONTHLY"?"no m\xEAs":"no dia";var Rt=(e,o)=>{let{page:t,perPage:r,search:a,handlePaginationModelChange:i,handleSearch:n}=a$5(),{startDate:l,endDate:c}=useMemo(()=>We(e,o),[e,o]),s=useMemo(()=>_e(e,o),[e,o]),p=Ee(o),m=useMemo(()=>({page:t,perPage:r,...a?{search:a}:{},filter:{operator:"AND",groups:[{operator:"AND",conditionals:[{fieldName:"negotiationDate",conditional:"GREATER_THAN_OR_EQUAL",value:[`${l}T00:00:00`]},{fieldName:"negotiationDate",conditional:"LESS_THAN_OR_EQUAL",value:[`${c}T23:59:59`]}]}]}}),[c,t,r,a,l]),y=useCallback((C,h)=>{i({page:C,pageSize:h});},[i]);return {page:t,perPage:r,periodLabel:s,suffix:p,queryParams:m,handleSearch:n,handlePaginationChange:y}},Ot=Rt;var k={sales:"#22C55E",forecast:"#F59E0B",goal:"#212B36"};var It=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:t+6*2,height:r+6,fill:k.sales,opacity:.16,rx:6}),ke=It;var Vt=({active:e,payload:o,label:t,viewMode:r})=>{if(!e||!o?.length)return null;let a=r==="DAILY",i=o[0].payload,n=Number(i.realized)||0,l=Number(i.forecast)||0,c=Number(i.goal)||0,s=c>0?n/c*100:0,p=c>n?c-n:0,m=a?"no dia":"no m\xEAs",y=a?"di\xE1ria":"mensal",C=String(t),h$1=C.split("-");if(h$1.length>=2){let z=parseInt(h$1[1],10)-1,S=b[z];a&&h$1.length===3?C=`${parseInt(h$1[2],10)} de ${S} de ${h$1[0]}`:a||(C=`${S} de ${h$1[0]}`);}let v=[{name:`Realizado ${m}`,value:h(n),color:k.sales},{name:`Previsto ${m}`,value:h(l),color:k.forecast},{name:`Meta ${y}`,value:h(c),color:k.goal},{name:"Atingimento",value:`${s.toFixed(0)}%`,color:"#00B8D9"},{name:`GAP ${m}`,value:h(p),color:"#FF5630"}];return jsxs(a$7,{minWidth:{xs:"auto",sm:400},p:1,gap:1,children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:C}),jsx(ue,{}),jsx(L,{children:v.map((z,S)=>jsxs(L,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${S}`,children:[jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsx(L,{width:6,height:6,borderRadius:"50%",bgcolor:z.color}),jsx(T,{variant:"body2",fontSize:"body2.fontSize",noWrap:!0,children:z.name})]}),jsx(T,{variant:"body2",fontSize:"body2.fontSize",children:z.value})]},S))})]})},Te=Vt;var Ht=({data:e,visibleSeries:o,yDomain:t,yTicks:r,viewMode:a,activeBarIndex:i,onMouseMove:n,onMouseLeave:l,onBarClick:c})=>{let s=useCallback(p=>d$1(p),[]);return jsx(ResponsiveContainer,{width:"100%",height:350,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:0,left:20},style:{cursor:"pointer"},onMouseMove:n,onMouseLeave:l,onClick:p=>{p?.activeTooltipIndex!=null&&c?.(Number(p.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:d$3}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:s,domain:t,ticks:r}),jsx(Tooltip,{content:jsx(Te,{viewMode:a})}),jsx(Bar,{dataKey:"realized",fill:"transparent",isAnimationActive:!1,background:jsx(ke,{activeBarIndex:i})}),o.goal&&jsx(Line,{dataKey:"goal",name:"Meta",stroke:k.goal,strokeWidth:2,strokeDasharray:"8 4",dot:!1,isAnimationActive:!1}),o.realized&&jsx(Line,{dataKey:"realized",name:"Vendas",stroke:k.sales,strokeWidth:2,dot:{fill:k.sales,r:4,strokeWidth:0},isAnimationActive:!1}),o.forecast&&jsx(Line,{dataKey:"forecast",name:"Previsto",stroke:k.forecast,strokeWidth:2,strokeDasharray:"6 3",dot:{fill:k.forecast,r:4,strokeWidth:0},isAnimationActive:!1})]})})},To=Ht;var tr=({data:e,visibleSeries:o,yDomain:t,yTicks:r,shouldRotateLabels:a,activeBarIndex:i,onMouseMove:n$1,onMouseLeave:l,onBarClick:c$1,viewMode:s})=>{let p=useMemo(()=>a?!1:{position:"top",fontSize:12,fill:"#212B36",formatter:m=>h(Number(m))},[a]);return jsx(ResponsiveContainer,{width:"100%",height:300,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:a?-90:0,left:20},barCategoryGap:"20%",style:{cursor:"pointer"},onMouseMove:n$1,onMouseLeave:l,onClick:m=>{m?.activeTooltipIndex!=null&&c$1?.(Number(m.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...a&&{interval:0,height:120},tick:a?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:c}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:m=>d$1(m),domain:t,ticks:r}),jsx(Tooltip,{content:jsx(Te,{viewMode:s})}),o.goal&&jsx(Line,{dataKey:"goal",name:"Meta",stroke:k.goal,strokeWidth:2,strokeDasharray:"8 4",dot:!1,isAnimationActive:!1}),o.realized&&jsx(Bar,{dataKey:"realized",name:"Vendas",fill:k.sales,maxBarSize:48,isAnimationActive:!1,radius:[4,4,0,0],background:jsx(ke,{activeBarIndex:i}),label:p}),o.forecast&&jsx(Line,{dataKey:"forecast",name:"Previsto",stroke:k.forecast,strokeWidth:2,strokeDasharray:"6 3",dot:{fill:k.forecast,r:4,strokeWidth:0},isAnimationActive:!1})]})})},Lo=tr;var nr=({data:e,viewMode:o,visibleSeries:t,yDomain:r,yTicks:a,formatYAxis:i,onBarClick:n})=>{let[l,c]=useState(null),[s,p]=useState(0),m=useRef(null),y=o==="MONTHLY",C=useMemo(()=>!y||s===0||e.length===0?!1:(s-60)/e.length<60,[s,e.length,y]),h=useCallback(()=>c(null),[]),v=useCallback(S=>{S?.activeTooltipIndex!=null&&c(Number(S.activeTooltipIndex));},[]),z=useCallback(S=>{m.current&&(m.current.disconnect(),m.current=null),S&&(p(S.clientWidth),m.current=new ResizeObserver(()=>p(S.clientWidth)),m.current.observe(S));},[]);return y?jsx(c$1,{ref:z,children:jsx(Lo,{data:e,visibleSeries:t,yDomain:r,yTicks:a,formatYAxis:i,shouldRotateLabels:C,activeBarIndex:l,onMouseMove:v,onMouseLeave:h,onBarClick:n,viewMode:o})}):jsx(c$1,{ref:z,children:jsx(To,{data:e,visibleSeries:t,yDomain:r,yTicks:a,formatYAxis:i,viewMode:o,activeBarIndex:l,onMouseMove:v,onMouseLeave:h,onBarClick:n})})},wo=nr;var lr=({visibleSeries:e,onToggleSerie:o})=>jsxs(L,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ke,{control:jsx(He,{checked:e.realized,onChange:()=>o("realized"),sx:{"&.Mui-checked":{color:k.sales}}}),label:"Vendas"}),jsx(Ke,{control:jsx(He,{checked:e.forecast,onChange:()=>o("forecast"),sx:{"&.Mui-checked":{color:k.forecast}}}),label:"Previsto"}),jsx(Ke,{control:jsx(He,{checked:e.goal,onChange:()=>o("goal"),sx:{"&.Mui-checked":{color:k.goal}}}),label:"Meta"})]}),Bo=lr;var pr=({kpis:e,isMonthly:o,editGoalAction:t})=>{let r=b$1("down","md");return jsxs(L,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[r&&jsx(ue,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(L,{children:[jsxs(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:["Previsto no ",o?"ano":"m\xEAs"]}),jsx(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",children:h(e?.forecast)})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsxs(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:["Realizado no ",o?"ano":"m\xEAs"]}),jsx(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",children:h(e?.realized)})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsxs(L,{direction:"row",alignItems:"center",gap:3,children:[jsxs(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:["Meta ",o?"anual":"mensal"]}),t]}),jsx(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",children:h(e?.goal)})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:"Atingimento"}),jsx(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",children:c$2(e?.achievement??0,{maximumFractionDigits:2,minimumFractionDigits:2})})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsxs(L,{direction:"row",gap:.5,children:[jsxs(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:["GAP do ",o?"ano":"m\xEAs"]}),jsx(a$6,{text:"Diferen\xE7a entre o valor realizado e a meta. Um GAP significa que as vendas ainda est\xE3o abaixo do objetivo definido para o per\xEDodo.",width:18,arrow:!0,sx:{mt:-.1}})]}),jsx(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",children:h(e?.gap)})]})]})},Qe=pr;var fr=({data:e,kpis:o,viewMode:t,selectedYear:r,editGoalAction:a$2,DetailComponent:i})=>{let[n,l]=useState({realized:!0,forecast:!0,goal:!0}),[c,s]=useState(!1),[p,m$1]=useState(""),[y,C]=useState(0),h=t==="MONTHLY",v=useMemo(()=>{if(!e.length)return [0,1];let x=e.flatMap(N=>[Number(N.realized)||0,Number(N.forecast)||0,Number(N.goal)||0]),M=Math.max(...x);return [0,M>0?M*1.15:1]},[e]),z=useMemo(()=>{let[,x]=v,M=x/6,N=Array.from({length:7},($r,$o)=>Math.round(M*$o));return [...new Set(N)]},[v]),S=useCallback(x=>{l(M=>({...M,[x]:!M[x]}));},[]),g=useCallback(x=>S(x),[S]),B=useCallback(x=>{let M=e[x];M&&(m$1(M.label),C(M.realized),s(!0));},[e]),d=useCallback(()=>{s(!1);},[]),f=useCallback(x=>d$1(x),[]);return jsxs(Fragment,{children:[jsxs(a,{children:[jsx(dt,{title:"Evolu\xE7\xE3o de vendas"}),jsx(mt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(L,{gap:3,children:[jsx(L,{display:{xs:"none",md:"block"},children:jsx(Qe,{kpis:o,isMonthly:h,editGoalAction:a$2})}),jsx(wo,{data:e,viewMode:t,visibleSeries:n,yDomain:v,yTicks:z,formatYAxis:f,onBarClick:B}),jsx(Bo,{visibleSeries:n,onToggleSerie:g}),jsx(L,{display:{xs:"block",md:"none"},children:jsx(Qe,{kpis:o,isMonthly:h,editGoalAction:a$2})})]})})})]}),p&&i&&jsx(i,{open:c,onClose:d,label:p,viewMode:t,selectedYear:r,totalValue:y})]})},ur=fr;var ie={realized:"#22C55E",forecast:"#F59E0B"};var hr=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:t+12,height:r+6,fill:"#919EAB",opacity:.16,rx:6}),Ro=hr;var gr=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i,bothRendered:n})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:n?t*2+4+12:t+12,height:r+6,fill:"#919EAB",opacity:.16,rx:6}),Oo=gr;var xr=({active:e,payload:o,label:t,viewMode:r})=>{if(!e||!o?.length)return null;let a=r==="DAILY",i=String(t),n=i.split("-");if(n.length>=2){let l=parseInt(n[1],10)-1,c=b[l];a&&n.length===3?i=`${parseInt(n[2],10)} de ${c} de ${n[0]}`:a||(i=`${c} de ${n[0]}`);}return jsxs(a$7,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:i}),jsx(ue,{}),jsx(L,{children:o.map((l,c)=>jsxs(L,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${c}`,children:[jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsx(L,{width:6,height:6,borderRadius:"50%",bgcolor:l.color}),jsx(T,{variant:"body2",fontSize:"body2.fontSize",noWrap:!0,children:l.name})]}),jsx(T,{variant:"body2",fontSize:"body2.fontSize",children:h(l.value)})]},l.name))})]})},Io=xr;var Pr=({data:e,viewMode:o,visibleSeries:t,activeBarIndex:r,onMouseMove:a,onMouseLeave:i})=>{let n$1=o==="MONTHLY",[l,c$2]=useState(0),s=useRef(null),p=useCallback(g=>{s.current&&(s.current.disconnect(),s.current=null),g&&(c$2(g.clientWidth),s.current=new ResizeObserver(()=>c$2(g.clientWidth)),s.current.observe(g));},[]),m=useMemo(()=>!n$1||l===0||e.length===0?!1:(l-60)/e.length<80,[n$1,l,e.length]),y=useMemo(()=>e.some(g=>g.realized_value>0),[e]),C=useMemo(()=>e.some(g=>g.forecast_value>0),[e]),h=useMemo(()=>{if(!e.length)return [0,1];let g=e.flatMap(d=>[d.realized_value,d.forecast_value]),B=Math.max(...g);return [0,B>0?B*1.15:1]},[e]),v=useMemo(()=>{let[,g]=h,B=g/6;return [...new Set(Array.from({length:7},(d,f)=>Math.round(B*f)))]},[h]),z=useMemo(()=>n$1?c:d$3,[n$1]),S=t.realized&&y&&t.forecast&&C;return jsx(c$1,{ref:p,children:jsx(ResponsiveContainer,{width:"100%",height:250,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:m?-90:0,left:20},barCategoryGap:"20%",barGap:4,onMouseMove:a,onMouseLeave:i,children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...m&&{interval:0,height:120},tick:m?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:z}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:g=>d$1(g),domain:h,ticks:v}),jsx(Tooltip,{content:jsx(Io,{viewMode:o}),cursor:!1}),t.realized&&y&&jsx(Bar,{dataKey:"realized_value",name:"Realizado",fill:ie.realized,maxBarSize:32,isAnimationActive:!1,radius:[4,4,0,0],background:jsx(Oo,{activeBarIndex:r,bothRendered:S})}),t.forecast&&C&&jsx(Bar,{dataKey:"forecast_value",name:"Previsto",fill:ie.forecast,maxBarSize:32,isAnimationActive:!1,radius:[4,4,0,0],...!t.realized&&{background:jsx(Ro,{activeBarIndex:r})}})]})})})},Fo=Pr;var Ir=({visibleSeries:e,onToggleSerie:o})=>jsxs(L,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ke,{control:jsx(He,{checked:e.realized,onChange:()=>o("realized"),sx:{"&.Mui-checked":{color:ie.realized}}}),label:"Realizado"}),jsx(Ke,{control:jsx(He,{checked:e.forecast,onChange:()=>o("forecast"),sx:{"&.Mui-checked":{color:ie.forecast}}}),label:"Previsto"})]}),_o=Ir;var Fr=({totalForecast:e,totalRealized:o,percentage:t,isMonthly:r})=>{let a=b$1("down","md");return jsxs(L,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[a&&jsx(ue,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(L,{children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:r?"Total previsto no ano":"Total previsto no m\xEAs"}),jsx(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",children:h(e)})]}),jsx(ue,{orientation:a?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:a?"solid":"dashed"}}),jsxs(L,{children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:r?"Total realizado no ano":"Total realizado no m\xEAs"}),jsx(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",children:h(o)})]}),jsx(ue,{orientation:a?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:a?"solid":"dashed"}}),jsxs(L,{children:[jsx(T,{variant:"body2",fontSize:"body2.fontSize",color:"text.secondary",children:"Atingimento"}),jsxs(T,{variant:"subtitle2",fontSize:"subtitle2.fontSize",children:[t,"%"]})]})]})},eo=Fr;var Er=({data:e,viewMode:o})=>{let t=o==="MONTHLY",[r,a$2]=useState({realized:!0,forecast:!0}),[i,n]=useState(null),l=useCallback(m=>{a$2(y=>({...y,[m]:!y[m]}));},[]),c=useCallback(m=>{m?.activeTooltipIndex!=null&&n(Number(m.activeTooltipIndex));},[]),s=useCallback(()=>n(null),[]),p=useMemo(()=>{let m=e.reduce((h,v)=>h+(v.realized_value??0),0),y=e.reduce((h,v)=>h+(v.forecast_value??0),0),C=y>0?Math.round(m/y*100):0;return {totalRealized:m,totalForecast:y,percentage:C}},[e]);return jsxs(a,{children:[jsx(dt,{title:"Previsto vs. Realizado (Positiva\xE7\xE3o)"}),jsx(mt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(L,{gap:3,children:[jsx(L,{display:{xs:"none",md:"block"},children:jsx(eo,{totalForecast:p.totalForecast,totalRealized:p.totalRealized,percentage:p.percentage,isMonthly:t})}),jsx(Fo,{data:e,viewMode:o,visibleSeries:r,activeBarIndex:i,onMouseMove:c,onMouseLeave:s}),jsx(_o,{visibleSeries:r,onToggleSerie:l}),jsx(L,{display:{xs:"block",md:"none"},children:jsx(eo,{totalForecast:p.totalForecast,totalRealized:p.totalRealized,percentage:p.percentage,isMonthly:t})})]})})})]})},Nr=Er;
44
+ var ee={orders:"#22C55E",quotations:"#0EA5E9"};var Yo=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:t+12,height:r+6,fill:"#919EAB",opacity:.16,rx:6}),Oe=Yo;var qo=({x:e=0,y:o=0,width:t=0,index:r=0,data:a,visibleSeries:i,isMonthly:n,shouldRotateLabels:l})=>{if(!n||l)return null;let c=a[r];if(!c)return null;let s=0;return i.orders&&(s+=c.order_count??0),i.quotations&&(s+=c.quotation_count??0),s?jsx("text",{x:e+t/2,y:o-8,textAnchor:"middle",fontSize:11,fill:"#212B36",children:s}):null},Ie=qo;var Qo=({active:e,payload:o,label:t,viewMode:r})=>{if(!e||!o?.length)return null;let a=r==="DAILY",i=String(t),n=i.split("-");if(n.length>=2){let s=parseInt(n[1],10)-1,p=b[s];a&&n.length===3?i=`${parseInt(n[2],10)} de ${p} de ${n[0]}`:a||(i=`${p} de ${n[0]}`);}let l=o[0].payload,c=[{name:"Vendas",count:l.order_count??0,value:l.order_value??0,color:o.find(s=>s.dataKey==="order_count")?.color??"#22C55E"},{name:"Or\xE7amentos",count:l.quotation_count??0,value:l.quotation_value??0,color:o.find(s=>s.dataKey==="quotation_count")?.color??"#0EA5E9"}];return jsxs(a$7,{minWidth:{xs:"auto",sm:300},p:1,gap:1,children:[jsx(M,{variant:"body2",color:"text.secondary",children:i}),jsx(ue,{}),jsx(D,{children:c.map((s,p)=>jsxs(D,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:2,"data-testid":`tooltip-item-${p}`,children:[jsxs(D,{direction:"row",alignItems:"center",gap:1,children:[jsx(D,{width:6,height:6,borderRadius:"50%",bgcolor:s.color}),jsx(M,{variant:"body2",noWrap:!0,children:s.name})]}),jsxs(M,{variant:"body2",color:"text.disabled",noWrap:!0,children:[s.count," ",s.count===1?"pedido":"pedidos","\u2002",jsx(M,{component:"span",variant:"body2",color:"text.primary",children:h(s.value)})]})]},s.name))})]})},mo=Qo;var at=({data:e,viewMode:o,visibleSeries:t,activeBarIndex:r,onMouseMove:a,onMouseLeave:i,onBarClick:n$1})=>{let l=o==="MONTHLY",[c$2,s]=useState(0),p=useRef(null),m=useCallback(d=>{p.current&&(p.current.disconnect(),p.current=null),d&&(s(d.clientWidth),p.current=new ResizeObserver(()=>s(d.clientWidth)),p.current.observe(d));},[]),h=useMemo(()=>!l||c$2===0||e.length===0?!1:(c$2-60)/e.length<80,[l,c$2,e.length]),C=useMemo(()=>e.some(d=>(d.order_count??0)>0),[e]),y=useMemo(()=>e.some(d=>(d.quotation_count??0)>0),[e]),S=useMemo(()=>{if(!e.length)return [0,1];let d=Math.max(...e.map(f=>(f.order_count??0)+(f.quotation_count??0)));return [0,d>0?d*1.15:1]},[e]),T=useMemo(()=>{let[,d]=S,f=d/6;return [...new Set(Array.from({length:7},(x,L)=>Math.round(f*L)))]},[S]),g=t.quotations&&y,v=t.orders&&C&&!g,P=useMemo(()=>l?c:d$3,[l]);return jsx(c$1,{ref:m,children:jsx(ResponsiveContainer,{width:"100%",height:250,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:h?-90:0,left:20},barCategoryGap:"20%",style:{cursor:"pointer"},onMouseMove:a,onMouseLeave:i,onClick:d=>{d?.activeTooltipIndex!=null&&n$1?.(Number(d.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...h&&{interval:0,height:120},tick:h?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:P}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:d=>d$1(d),domain:S,ticks:T}),jsx(Tooltip,{content:jsx(mo,{viewMode:o}),cursor:!1}),jsx(Bar,{dataKey:"order_count",name:"Vendas",fill:ee.orders,stackId:"orders",maxBarSize:48,isAnimationActive:!1,hide:!t.orders,background:jsx(Oe,{activeBarIndex:r}),radius:v?[4,4,0,0]:void 0,...v&&{label:{position:"top",fontSize:11,fill:"#212B36",content:jsx(Ie,{data:e,visibleSeries:t,isMonthly:l,shouldRotateLabels:h})}}}),jsx(Bar,{dataKey:"quotation_count",name:"Or\xE7amentos",fill:ee.quotations,stackId:"orders",maxBarSize:48,isAnimationActive:!1,hide:!t.quotations,radius:g?[4,4,0,0]:void 0,...!t.orders&&{background:jsx(Oe,{activeBarIndex:r})},...g&&{label:{position:"top",fontSize:11,fill:"#212B36",content:jsx(Ie,{data:e,visibleSeries:t,isMonthly:l,shouldRotateLabels:h})}}})]})})})},uo=at;var st=({visibleSeries:e,onToggleSerie:o})=>jsxs(D,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ke,{control:jsx(He,{checked:e.orders,onChange:()=>o("orders"),sx:{"&.Mui-checked":{color:ee.orders}}}),label:"Vendas"}),jsx(Ke,{control:jsx(He,{checked:e.quotations,onChange:()=>o("quotations"),sx:{"&.Mui-checked":{color:ee.quotations}}}),label:"Or\xE7amentos"})]}),go=st;var ct=({ordersTotal:e,quotationsTotal:o,isMonthly:t})=>{let r=b$1("down","md");return jsxs(D,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[r&&jsx(ue,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:t?"Vendas no ano":"Vendas no m\xEAs"}),jsxs(M,{variant:"subtitle2",children:[e," vendas"]})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:t?"Or\xE7amentos no ano":"Or\xE7amentos no m\xEAs"}),jsxs(M,{variant:"subtitle2",children:[o," or\xE7amentos"]})]})]})},Ae=ct;var ft=({data:e,viewMode:o,selectedYear:t,DetailComponent:r})=>{let a$2=o==="MONTHLY",[i,n]=useState({orders:!0,quotations:!0}),[l,c]=useState(null),[s,p]=useState(!1),[m$1,h]=useState(""),[C,y]=useState(0),S=useCallback(f=>{n(x=>({...x,[f]:!x[f]}));},[]),T=useCallback(f=>{f?.activeTooltipIndex!=null&&c(Number(f.activeTooltipIndex));},[]),g=useCallback(()=>c(null),[]),v=useCallback(f=>{let x=e[f];x&&(h(x.label),y(x.order_value),p(!0));},[e]),P=useCallback(()=>{p(!1);},[]),d=useMemo(()=>{let f=e.reduce((L,N)=>L+(N.order_count??0),0),x=e.reduce((L,N)=>L+(N.quotation_count??0),0);return {ordersTotal:f,quotationsTotal:x}},[e]);return jsxs(Fragment,{children:[jsxs(a,{children:[jsx(dt,{title:"Quantidade de pedidos por tipo"}),jsx(mt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(D,{gap:3,children:[jsx(D,{display:{xs:"none",md:"block"},children:jsx(Ae,{isMonthly:a$2,ordersTotal:d.ordersTotal,quotationsTotal:d.quotationsTotal})}),jsx(uo,{data:e,viewMode:o,visibleSeries:i,activeBarIndex:l,onMouseMove:T,onMouseLeave:g,onBarClick:v}),jsx(go,{visibleSeries:i,onToggleSerie:S}),jsx(D,{display:{xs:"block",md:"none"},children:jsx(Ae,{isMonthly:a$2,ordersTotal:d.ordersTotal,quotationsTotal:d.quotationsTotal})})]})})})]}),m$1&&r&&jsx(r,{open:s,onClose:P,label:m$1,viewMode:o,selectedYear:t,totalValue:C})]})},ut=ft;var yt=({title:e,viewMode:o,selectedYear:t,periodLabel:r})=>jsxs(D,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(M,{variant:"subtitle1",noWrap:!0,children:"Detalhes do relat\xF3rio"}),jsxs(D,{direction:"row",alignItems:"center",columnGap:1.5,rowGap:0,flexWrap:"wrap",children:[jsx(M,{variant:"body2",color:"text.secondary",flexShrink:0,children:e}),"\u2022",jsx(M,{variant:"body2",flexShrink:0,children:b$2[o]}),"\u2022",jsx(M,{variant:"body2",flexShrink:0,children:t}),"\u2022",jsx(M,{variant:"body2",color:"text.secondary",noWrap:!0,children:r})]})]}),xo=yt;var ko=styled(ue)(()=>({height:30,alignSelf:"center",borderStyle:"dashed"})),To=styled(D)(({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 Ct=e=>jsx(D,{justifyContent:"center",height:1,children:jsx(M,{variant:"body2",color:"text.primary",children:e.id})}),kt=(e,o)=>jsx(D,{justifyContent:"center",height:1,children:e?.partner?.id&&o?jsx(xt,{component:"a",href:o(e.partner.id),target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",sx:{textDecoration:"underline"},noWrap:!0,children:e.partner?.name||"-"}):jsx(M,{variant:"body2",color:"text.primary",noWrap:!0,children:e.partner?.name||"-"})}),Tt=e=>jsx(D,{justifyContent:"center",height:1,children:jsx(M,{variant:"body2",color:"text.primary",children:h(e.total_value)})}),Mt=e=>jsx(D,{justifyContent:"center",height:1,children:e.negotiation_date?jsx(M,{variant:"body2",color:"text.primary",children:d$2(e.negotiation_date,"DD/MM/YYYY")}):"-"}),Lt=e=>jsx(D,{justifyContent:"center",height:1,children:e.status||"-"}),Dt=e=>jsx(To,{children:jsxs(D,{gap:1,children:[jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Pedido"}),jsx(M,{variant:"subtitle2",color:"text.primary",children:e.id})]}),jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Cliente"}),jsx(M,{variant:"subtitle2",color:"primary.main",children:e.partner?.name||"-"})]}),jsxs(D,{direction:"row",alignItems:"center",gap:1,children:[jsxs(D,{flex:1,overflow:"hidden",children:[jsx(M,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Valor do pedido"}),jsx(M,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h(e.total_value)})]}),jsx(ue,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(D,{flex:1,overflow:"hidden",children:[jsx(M,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Data"}),jsx(M,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:e.negotiation_date?d$2(e.negotiation_date,"DD/MM/YYYY"):"-"})]})]}),jsxs(D,{gap:.5,children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Status"}),jsx(M,{variant:"subtitle2",color:"text.primary",children:e.status||"-"})]})]})},e.id),wt=({open:e,onClose:o,title:t,viewMode:r,selectedYear:a,totalValue:i,periodLabel:n,suffix:l,rows:c,total:s,isLoading:p,isFetching:m,page:h$1,perPage:C,onSearch:y,onPaginationChange:S,buildPartnerLink:T,mobileItemSlot:g})=>{let v=b$1("down","sm"),P=jsxs(D,{gap:3,children:[jsxs(D,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",gap:2,children:[jsxs(D,{minWidth:0,direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:[jsxs(D,{children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Vendas ",l]}),jsx(M,{variant:"subtitle2",color:"text.primary",children:h(i)})]}),jsx(ko,{orientation:"vertical",flexItem:!0}),jsxs(D,{children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Qtd. de pedidos ",l]}),jsx(M,{variant:"subtitle2",color:"text.primary",children:s})]})]}),jsx(a$2,{size:"small",placeholder:"Buscar",onSearch:y,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(d,{title:"Pedidos",header:jsx(Fragment,{}),headerProps:{p:0},columns:[{field:"external_id",headerName:"Pedido",flex:1,renderCell:({row:f})=>Ct(f)},{field:"partner_name",headerName:"Cliente",flex:1,renderCell:({row:f})=>kt(f,T)},{field:"total_value",headerName:"Valor do pedido",flex:1,renderCell:({row:f})=>Tt(f)},{field:"created_at",headerName:"Data",flex:1,renderCell:({row:f})=>Mt(f)},{field:"last_status",headerName:"Status",flex:1,renderCell:({row:f})=>Lt(f)}],rows:c,rowCount:s,mobileRender:f=>g?g(f):Dt(f),loading:p,fetching:m,paginationModel:{page:h$1,pageSize:C},onPaginationChange:S,paginationMode:"server",disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),d$1=jsx(xo,{title:t,viewMode:r,selectedYear:a,periodLabel:n});return v?jsx(a$3,{open:e,onClose:o,headerTitle:d$1,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:P}):jsx(a$4,{open:e,onClose:o,maxWidth:"lg",dialogTitle:d$1,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:P})},Bt=wt;var We=(e,o)=>{let t=e.split("-");if(o==="DAILY"&&t.length===3){let n=`${t[0]}-${t[1]}-${t[2]}`;return {startDate:n,endDate:n}}let r=parseInt(t[0],10),a=parseInt(t[1],10),i=new Date(r,a,0).getDate();return {startDate:`${t[0]}-${t[1]}-01`,endDate:`${t[0]}-${t[1]}-${String(i).padStart(2,"0")}`}},_e=(e,o)=>{let t=e.split("-"),r=parseInt(t[1],10)-1,a=b[r]??"";if(o==="DAILY"&&t.length===3){let i=parseInt(t[2],10);return `${a} - Dia ${i}`}return a},Ee=e=>e==="MONTHLY"?"no m\xEAs":"no dia";var Ot=(e,o)=>{let{page:t,perPage:r,search:a,handlePaginationModelChange:i,handleSearch:n}=a$5(),{startDate:l,endDate:c}=useMemo(()=>We(e,o),[e,o]),s=useMemo(()=>_e(e,o),[e,o]),p=Ee(o),m=useMemo(()=>({page:t,perPage:r,...a?{search:a}:{},filter:{operator:"AND",groups:[{operator:"AND",conditionals:[{fieldName:"negotiationDate",conditional:"GREATER_THAN_OR_EQUAL",value:[`${l}T00:00:00`]},{fieldName:"negotiationDate",conditional:"LESS_THAN_OR_EQUAL",value:[`${c}T23:59:59`]}]}]}}),[c,t,r,a,l]),h=useCallback((C,y)=>{i({page:C,pageSize:y});},[i]);return {page:t,perPage:r,periodLabel:s,suffix:p,queryParams:m,handleSearch:n,handlePaginationChange:h}},It=Ot;var k={sales:"#22C55E",forecast:"#F59E0B",goal:"#212B36"};var zt=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:t+6*2,height:r+6,fill:k.sales,opacity:.16,rx:6}),ke=zt;var Vt=({active:e,payload:o,label:t,viewMode:r})=>{if(!e||!o?.length)return null;let a=r==="DAILY",i=o[0].payload,n=Number(i.realized)||0,l=Number(i.forecast)||0,c=Number(i.goal)||0,s=c>0?n/c*100:0,p=c>n?c-n:0,m=a?"no dia":"no m\xEAs",h$1=a?"di\xE1ria":"mensal",C=String(t),y=C.split("-");if(y.length>=2){let T=parseInt(y[1],10)-1,g=b[T];a&&y.length===3?C=`${parseInt(y[2],10)} de ${g} de ${y[0]}`:a||(C=`${g} de ${y[0]}`);}let S=[{name:`Realizado ${m}`,value:h(n),color:k.sales},{name:`Previsto ${m}`,value:h(l),color:k.forecast},{name:`Meta ${h$1}`,value:h(c),color:k.goal},{name:"Atingimento",value:`${s.toFixed(0)}%`,color:"#00B8D9"},{name:`GAP ${m}`,value:h(p),color:"#FF5630"}];return jsxs(a$7,{minWidth:{xs:"auto",sm:400},p:1,gap:1,children:[jsx(M,{variant:"body2",color:"text.secondary",children:C}),jsx(ue,{}),jsx(D,{children:S.map((T,g)=>jsxs(D,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${g}`,children:[jsxs(D,{direction:"row",alignItems:"center",gap:1,children:[jsx(D,{width:6,height:6,borderRadius:"50%",bgcolor:T.color}),jsx(M,{variant:"body2",noWrap:!0,children:T.name})]}),jsx(M,{variant:"body2",children:T.value})]},g))})]})},Me=Vt;var Ht=({data:e,visibleSeries:o,yDomain:t,yTicks:r,viewMode:a,activeBarIndex:i,onMouseMove:n,onMouseLeave:l,onBarClick:c})=>{let s=useCallback(p=>d$1(p),[]);return jsx(ResponsiveContainer,{width:"100%",height:350,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:0,left:20},style:{cursor:"pointer"},onMouseMove:n,onMouseLeave:l,onClick:p=>{p?.activeTooltipIndex!=null&&c?.(Number(p.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:d$3}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:s,domain:t,ticks:r}),jsx(Tooltip,{content:jsx(Me,{viewMode:a})}),jsx(Bar,{dataKey:"realized",fill:"transparent",isAnimationActive:!1,background:jsx(ke,{activeBarIndex:i})}),o.goal&&jsx(Line,{dataKey:"goal",name:"Meta",stroke:k.goal,strokeWidth:2,strokeDasharray:"8 4",dot:!1,isAnimationActive:!1}),o.realized&&jsx(Line,{dataKey:"realized",name:"Vendas",stroke:k.sales,strokeWidth:2,dot:{fill:k.sales,r:4,strokeWidth:0},isAnimationActive:!1}),o.forecast&&jsx(Line,{dataKey:"forecast",name:"Previsto",stroke:k.forecast,strokeWidth:2,strokeDasharray:"6 3",dot:{fill:k.forecast,r:4,strokeWidth:0},isAnimationActive:!1})]})})},Mo=Ht;var tr=({data:e,visibleSeries:o,yDomain:t,yTicks:r,shouldRotateLabels:a,activeBarIndex:i,onMouseMove:n$1,onMouseLeave:l,onBarClick:c$1,viewMode:s})=>{let p=useMemo(()=>a?!1:{position:"top",fontSize:12,fill:"#212B36",formatter:m=>h(Number(m))},[a]);return jsx(ResponsiveContainer,{width:"100%",height:300,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:a?-90:0,left:20},barCategoryGap:"20%",style:{cursor:"pointer"},onMouseMove:n$1,onMouseLeave:l,onClick:m=>{m?.activeTooltipIndex!=null&&c$1?.(Number(m.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...a&&{interval:0,height:120},tick:a?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:c}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:m=>d$1(m),domain:t,ticks:r}),jsx(Tooltip,{content:jsx(Me,{viewMode:s})}),o.goal&&jsx(Line,{dataKey:"goal",name:"Meta",stroke:k.goal,strokeWidth:2,strokeDasharray:"8 4",dot:!1,isAnimationActive:!1}),o.realized&&jsx(Bar,{dataKey:"realized",name:"Vendas",fill:k.sales,maxBarSize:48,isAnimationActive:!1,radius:[4,4,0,0],background:jsx(ke,{activeBarIndex:i}),label:p}),o.forecast&&jsx(Line,{dataKey:"forecast",name:"Previsto",stroke:k.forecast,strokeWidth:2,strokeDasharray:"6 3",dot:{fill:k.forecast,r:4,strokeWidth:0},isAnimationActive:!1})]})})},Do=tr;var nr=({data:e,viewMode:o,visibleSeries:t,yDomain:r,yTicks:a,formatYAxis:i,onBarClick:n})=>{let[l,c]=useState(null),[s,p]=useState(0),m=useRef(null),h=o==="MONTHLY",C=useMemo(()=>!h||s===0||e.length===0?!1:(s-60)/e.length<60,[s,e.length,h]),y=useCallback(()=>c(null),[]),S=useCallback(g=>{g?.activeTooltipIndex!=null&&c(Number(g.activeTooltipIndex));},[]),T=useCallback(g=>{m.current&&(m.current.disconnect(),m.current=null),g&&(p(g.clientWidth),m.current=new ResizeObserver(()=>p(g.clientWidth)),m.current.observe(g));},[]);return h?jsx(c$1,{ref:T,children:jsx(Do,{data:e,visibleSeries:t,yDomain:r,yTicks:a,formatYAxis:i,shouldRotateLabels:C,activeBarIndex:l,onMouseMove:S,onMouseLeave:y,onBarClick:n,viewMode:o})}):jsx(c$1,{ref:T,children:jsx(Mo,{data:e,visibleSeries:t,yDomain:r,yTicks:a,formatYAxis:i,viewMode:o,activeBarIndex:l,onMouseMove:S,onMouseLeave:y,onBarClick:n})})},Bo=nr;var lr=({visibleSeries:e,onToggleSerie:o})=>jsxs(D,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ke,{control:jsx(He,{checked:e.realized,onChange:()=>o("realized"),sx:{"&.Mui-checked":{color:k.sales}}}),label:"Vendas"}),jsx(Ke,{control:jsx(He,{checked:e.forecast,onChange:()=>o("forecast"),sx:{"&.Mui-checked":{color:k.forecast}}}),label:"Previsto"}),jsx(Ke,{control:jsx(He,{checked:e.goal,onChange:()=>o("goal"),sx:{"&.Mui-checked":{color:k.goal}}}),label:"Meta"})]}),Po=lr;var pr=({kpis:e,isMonthly:o,editGoalAction:t})=>{let r=b$1("down","md");return jsxs(D,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[r&&jsx(ue,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(D,{children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Previsto no ",o?"ano":"m\xEAs"]}),jsx(M,{variant:"subtitle2",children:h(e?.forecast)})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(D,{children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Realizado no ",o?"ano":"m\xEAs"]}),jsx(M,{variant:"subtitle2",children:h(e?.realized)})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(D,{children:[jsxs(D,{direction:"row",alignItems:"center",gap:3,children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Meta ",o?"anual":"mensal"]}),t]}),jsx(M,{variant:"subtitle2",children:h(e?.goal)})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Atingimento"}),jsx(M,{variant:"subtitle2",children:c$2(e?.achievement??0,{maximumFractionDigits:2,minimumFractionDigits:2})})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(D,{children:[jsxs(D,{direction:"row",gap:.5,children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["GAP do ",o?"ano":"m\xEAs"]}),jsx(a$6,{text:"Diferen\xE7a entre o valor realizado e a meta. Um GAP significa que as vendas ainda est\xE3o abaixo do objetivo definido para o per\xEDodo.",width:18,arrow:!0,sx:{mt:-.1}})]}),jsx(M,{variant:"subtitle2",children:h(e?.gap)})]})]})},Qe=pr;var fr=({data:e,kpis:o,viewMode:t,selectedYear:r,editGoalAction:a$2,DetailComponent:i})=>{let[n,l]=useState({realized:!0,forecast:!0,goal:!0}),[c,s]=useState(!1),[p,m$1]=useState(""),[h,C]=useState(0),y=t==="MONTHLY",S=useMemo(()=>{if(!e.length)return [0,1];let x=e.flatMap(N=>[Number(N.realized)||0,Number(N.forecast)||0,Number(N.goal)||0]),L=Math.max(...x);return [0,L>0?L*1.15:1]},[e]),T=useMemo(()=>{let[,x]=S,L=x/6,N=Array.from({length:7},($r,$o)=>Math.round(L*$o));return [...new Set(N)]},[S]),g=useCallback(x=>{l(L=>({...L,[x]:!L[x]}));},[]),v=useCallback(x=>g(x),[g]),P=useCallback(x=>{let L=e[x];L&&(m$1(L.label),C(L.realized),s(!0));},[e]),d=useCallback(()=>{s(!1);},[]),f=useCallback(x=>d$1(x),[]);return jsxs(Fragment,{children:[jsxs(a,{children:[jsx(dt,{title:"Evolu\xE7\xE3o de vendas"}),jsx(mt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(D,{gap:3,children:[jsx(D,{display:{xs:"none",md:"block"},children:jsx(Qe,{kpis:o,isMonthly:y,editGoalAction:a$2})}),jsx(Bo,{data:e,viewMode:t,visibleSeries:n,yDomain:S,yTicks:T,formatYAxis:f,onBarClick:P}),jsx(Po,{visibleSeries:n,onToggleSerie:v}),jsx(D,{display:{xs:"block",md:"none"},children:jsx(Qe,{kpis:o,isMonthly:y,editGoalAction:a$2})})]})})})]}),p&&i&&jsx(i,{open:c,onClose:d,label:p,viewMode:t,selectedYear:r,totalValue:h})]})},ur=fr;var ie={realized:"#22C55E",forecast:"#F59E0B"};var yr=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:t+12,height:r+6,fill:"#919EAB",opacity:.16,rx:6}),Oo=yr;var vr=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i,bothRendered:n})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:n?t*2+4+12:t+12,height:r+6,fill:"#919EAB",opacity:.16,rx:6}),Io=vr;var xr=({active:e,payload:o,label:t,viewMode:r})=>{if(!e||!o?.length)return null;let a=r==="DAILY",i=String(t),n=i.split("-");if(n.length>=2){let l=parseInt(n[1],10)-1,c=b[l];a&&n.length===3?i=`${parseInt(n[2],10)} de ${c} de ${n[0]}`:a||(i=`${c} de ${n[0]}`);}return jsxs(a$7,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(M,{variant:"body2",color:"text.secondary",children:i}),jsx(ue,{}),jsx(D,{children:o.map((l,c)=>jsxs(D,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${c}`,children:[jsxs(D,{direction:"row",alignItems:"center",gap:1,children:[jsx(D,{width:6,height:6,borderRadius:"50%",bgcolor:l.color}),jsx(M,{variant:"body2",noWrap:!0,children:l.name})]}),jsx(M,{variant:"body2",children:h(l.value)})]},l.name))})]})},zo=xr;var Rr=({data:e,viewMode:o,visibleSeries:t,activeBarIndex:r,onMouseMove:a,onMouseLeave:i})=>{let n$1=o==="MONTHLY",[l,c$2]=useState(0),s=useRef(null),p=useCallback(v=>{s.current&&(s.current.disconnect(),s.current=null),v&&(c$2(v.clientWidth),s.current=new ResizeObserver(()=>c$2(v.clientWidth)),s.current.observe(v));},[]),m=useMemo(()=>!n$1||l===0||e.length===0?!1:(l-60)/e.length<80,[n$1,l,e.length]),h=useMemo(()=>e.some(v=>v.realized_value>0),[e]),C=useMemo(()=>e.some(v=>v.forecast_value>0),[e]),y=useMemo(()=>{if(!e.length)return [0,1];let v=e.flatMap(d=>[d.realized_value,d.forecast_value]),P=Math.max(...v);return [0,P>0?P*1.15:1]},[e]),S=useMemo(()=>{let[,v]=y,P=v/6;return [...new Set(Array.from({length:7},(d,f)=>Math.round(P*f)))]},[y]),T=useMemo(()=>n$1?c:d$3,[n$1]),g=t.realized&&h&&t.forecast&&C;return jsx(c$1,{ref:p,children:jsx(ResponsiveContainer,{width:"100%",height:250,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:m?-90:0,left:20},barCategoryGap:"20%",barGap:4,onMouseMove:a,onMouseLeave:i,children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...m&&{interval:0,height:120},tick:m?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:T}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:v=>d$1(v),domain:y,ticks:S}),jsx(Tooltip,{content:jsx(zo,{viewMode:o}),cursor:!1}),t.realized&&h&&jsx(Bar,{dataKey:"realized_value",name:"Realizado",fill:ie.realized,maxBarSize:32,isAnimationActive:!1,radius:[4,4,0,0],background:jsx(Io,{activeBarIndex:r,bothRendered:g})}),t.forecast&&C&&jsx(Bar,{dataKey:"forecast_value",name:"Previsto",fill:ie.forecast,maxBarSize:32,isAnimationActive:!1,radius:[4,4,0,0],...!t.realized&&{background:jsx(Oo,{activeBarIndex:r})}})]})})})},Fo=Rr;var zr=({visibleSeries:e,onToggleSerie:o})=>jsxs(D,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ke,{control:jsx(He,{checked:e.realized,onChange:()=>o("realized"),sx:{"&.Mui-checked":{color:ie.realized}}}),label:"Realizado"}),jsx(Ke,{control:jsx(He,{checked:e.forecast,onChange:()=>o("forecast"),sx:{"&.Mui-checked":{color:ie.forecast}}}),label:"Previsto"})]}),_o=zr;var Fr=({totalForecast:e,totalRealized:o,percentage:t,isMonthly:r})=>{let a=b$1("down","md");return jsxs(D,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[a&&jsx(ue,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:r?"Total previsto no ano":"Total previsto no m\xEAs"}),jsx(M,{variant:"subtitle2",children:h(e)})]}),jsx(ue,{orientation:a?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:a?"solid":"dashed"}}),jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:r?"Total realizado no ano":"Total realizado no m\xEAs"}),jsx(M,{variant:"subtitle2",children:h(o)})]}),jsx(ue,{orientation:a?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:a?"solid":"dashed"}}),jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Atingimento"}),jsxs(M,{variant:"subtitle2",children:[t,"%"]})]})]})},eo=Fr;var Er=({data:e,viewMode:o})=>{let t=o==="MONTHLY",[r,a$2]=useState({realized:!0,forecast:!0}),[i,n]=useState(null),l=useCallback(m=>{a$2(h=>({...h,[m]:!h[m]}));},[]),c=useCallback(m=>{m?.activeTooltipIndex!=null&&n(Number(m.activeTooltipIndex));},[]),s=useCallback(()=>n(null),[]),p=useMemo(()=>{let m=e.reduce((y,S)=>y+(S.realized_value??0),0),h=e.reduce((y,S)=>y+(S.forecast_value??0),0),C=h>0?Math.round(m/h*100):0;return {totalRealized:m,totalForecast:h,percentage:C}},[e]);return jsxs(a,{children:[jsx(dt,{title:"Previsto vs. Realizado (Positiva\xE7\xE3o)"}),jsx(mt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(D,{gap:3,children:[jsx(D,{display:{xs:"none",md:"block"},children:jsx(eo,{totalForecast:p.totalForecast,totalRealized:p.totalRealized,percentage:p.percentage,isMonthly:t})}),jsx(Fo,{data:e,viewMode:o,visibleSeries:r,activeBarIndex:i,onMouseMove:c,onMouseLeave:s}),jsx(_o,{visibleSeries:r,onToggleSerie:l}),jsx(D,{display:{xs:"block",md:"none"},children:jsx(eo,{totalForecast:p.totalForecast,totalRealized:p.totalRealized,percentage:p.percentage,isMonthly:t})})]})})})]})},Nr=Er;
45
45
 
46
- export { ut as OrdersByType, wt as OverviewDetail, ur as SalesEvolution, Nr as SalesForecast, We as getDateRange, _e as getPeriodLabel, Ee as getPeriodSuffix, Ot as useOverviewDetailState };
46
+ export { ut as OrdersByType, Bt as OverviewDetail, ur as SalesEvolution, Nr as SalesForecast, We as getDateRange, _e as getPeriodLabel, Ee as getPeriodSuffix, It as useOverviewDetailState };
47
47
  //# sourceMappingURL=index.js.map