@zydon/common 2.9.39 → 2.9.40

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 (38) hide show
  1. package/dist/chunk-BBLPAVHA.js +8 -0
  2. package/dist/chunk-BBLPAVHA.js.map +1 -0
  3. package/dist/chunk-FCKDOHEL.js +16 -0
  4. package/dist/chunk-FCKDOHEL.js.map +1 -0
  5. package/dist/chunk-JYHO7CDG.js +9 -0
  6. package/dist/chunk-JYHO7CDG.js.map +1 -0
  7. package/dist/components/Analytics/Carts/index.d.ts +2 -1
  8. package/dist/components/Analytics/Carts/index.js +23 -23
  9. package/dist/components/Analytics/Carts/index.js.map +1 -1
  10. package/dist/components/Analytics/OrderProjection/index.d.ts +2 -1
  11. package/dist/components/Analytics/OrderProjection/index.js +29 -28
  12. package/dist/components/Analytics/OrderProjection/index.js.map +1 -1
  13. package/dist/components/Analytics/PartnerAnalysis/index.d.ts +2 -1
  14. package/dist/components/Analytics/index.d.ts +1 -0
  15. package/dist/components/Analytics/index.js +3 -3
  16. package/dist/components/Avatar/index.d.ts +1 -1
  17. package/dist/components/DataView/index.d.ts +1 -1
  18. package/dist/hooks/useCartsFilters.d.ts +2 -1
  19. package/dist/hooks/useCartsFilters.js +1 -1
  20. package/dist/hooks/useOrderProjectionFilters.d.ts +2 -1
  21. package/dist/hooks/useOrderProjectionFilters.js +1 -1
  22. package/dist/hooks/useSnackbar.d.ts +1 -1
  23. package/dist/index.d.ts +2 -2
  24. package/dist/theme/core/index.d.ts +1 -1
  25. package/dist/theme/styles/index.d.ts +13 -13
  26. package/dist/types/carts.d.ts +2 -1
  27. package/dist/types/orderProjection.d.ts +2 -1
  28. package/dist/types/partnerAnalysis.d.ts +2 -1
  29. package/dist/types-15e95556.d.ts +15 -0
  30. package/dist/{useCartsFilters-9eb738ab.d.ts → useCartsFilters-44ddc83e.d.ts} +8 -20
  31. package/dist/{useOrderProjectionFilters-5c1162d5.d.ts → useOrderProjectionFilters-3722b749.d.ts} +13 -24
  32. package/dist/utils/orderProjection.d.ts +2 -1
  33. package/package.json +1 -1
  34. package/dist/chunk-5GXRPVV5.js +0 -9
  35. package/dist/chunk-5GXRPVV5.js.map +0 -1
  36. package/dist/chunk-KJJDGCL4.js +0 -8
  37. package/dist/chunk-KJJDGCL4.js.map +0 -1
  38. package/dist/{index-c8f1e6e7.d.ts → index-5a5e5dc8.d.ts} +12 -12
@@ -1,4 +1,5 @@
1
1
  import { a as a$d } from '../../../chunk-K34AZXX4.js';
2
+ import { a as a$h } from '../../../chunk-FCKDOHEL.js';
2
3
  import { i as i$1, h as h$1 } from '../../../chunk-BBVOF2BY.js';
3
4
  import { a as a$g, b as b$1, c as c$1 } from '../../../chunk-EICUAMNN.js';
4
5
  import { d, e as e$1 } from '../../../chunk-K2PWIYEM.js';
@@ -13,49 +14,49 @@ import { a as a$3 } from '../../../chunk-HE2LUROB.js';
13
14
  import { a as a$f } from '../../../chunk-5J35UAV6.js';
14
15
  import { a as a$e } from '../../../chunk-4F2NKGF6.js';
15
16
  import { a } from '../../../chunk-AZJ3VCNL.js';
16
- import { a as a$i } from '../../../chunk-YHOVSR7P.js';
17
+ import '../../../chunk-YHOVSR7P.js';
17
18
  import { a as a$a } from '../../../chunk-CO2KQFUN.js';
18
19
  import { a as a$1 } from '../../../chunk-5ZMA4N4W.js';
19
20
  import '../../../chunk-Z6YXPKWP.js';
20
21
  import '../../../chunk-F65ZXAGV.js';
21
22
  import { a as a$9 } from '../../../chunk-E3R7W7GK.js';
22
- import { a as a$4 } from '../../../chunk-5GXRPVV5.js';
23
+ import { a as a$4 } from '../../../chunk-JYHO7CDG.js';
23
24
  import { v, e, s, l, n, m, p, q, o, i, j, u, t, w, k } from '../../../chunk-UYYDORSQ.js';
24
25
  import { b } from '../../../chunk-TXJ45CNA.js';
25
26
  import '../../../chunk-ERLI5GAP.js';
26
27
  import { a as a$8 } from '../../../chunk-LQRRMVFN.js';
27
28
  import { a as a$6 } from '../../../chunk-CB4KDKZY.js';
28
29
  import { a as a$2 } from '../../../chunk-LFHA3YUV.js';
29
- import { a as a$h } from '../../../chunk-GGJJ3II3.js';
30
+ import '../../../chunk-GGJJ3II3.js';
30
31
  import { createContext, memo, useMemo, useContext, useCallback, useRef, useState } from 'react';
31
- import vl from '@mui/material/CircularProgress';
32
- import Be from '@mui/material/TableCell';
33
- import un from '@mui/material/TableRow';
34
- import fe from 'dayjs';
32
+ import nl from '@mui/material/CircularProgress';
33
+ import Ie from '@mui/material/TableCell';
34
+ import an from '@mui/material/TableRow';
35
+ import ne from 'dayjs';
35
36
  import { styled, alpha } from '@mui/material/styles';
36
37
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
37
- import mo from '@mui/material/Stack';
38
- import Y from '@mui/material/Typography';
39
- import En from '@mui/material/Skeleton';
40
- import Ln from '@mui/material/Button';
41
- import Hn from '@mui/material/TableHead';
42
- import Qo from '@mui/material/Divider';
43
- import jn from '@mui/material/Alert';
44
- import Qn from '@mui/lab/LoadingButton';
45
- import li from '@mui/material/Link';
46
- import Is from '@mui/material/Box';
47
- import Ys from '@mui/material/Chip';
48
- import gd from '@mui/material/Card';
49
- import ud from '@mui/material/Table';
50
- import hd from '@mui/material/TableBody';
51
- import Td from '@mui/material/TableContainer';
52
- import yn from '@mui/material/Badge';
53
- import Sd from '@mui/material/Checkbox';
54
- import bd from '@mui/material/FormControlLabel';
38
+ import io from '@mui/material/Stack';
39
+ import R from '@mui/material/Typography';
40
+ import un from '@mui/material/Skeleton';
41
+ import Pn from '@mui/material/Button';
42
+ import An from '@mui/material/TableHead';
43
+ import $o from '@mui/material/Divider';
44
+ import Mn from '@mui/material/Alert';
45
+ import Wn from '@mui/lab/LoadingButton';
46
+ import ti from '@mui/material/Link';
47
+ import Ts from '@mui/material/Box';
48
+ import _s from '@mui/material/Chip';
49
+ import ad from '@mui/material/Card';
50
+ import id from '@mui/material/Table';
51
+ import nd from '@mui/material/TableBody';
52
+ import pd from '@mui/material/TableContainer';
53
+ import Zi from '@mui/material/Badge';
54
+ import sd from '@mui/material/Checkbox';
55
+ import dd from '@mui/material/FormControlLabel';
55
56
  import { PickersDay } from '@mui/x-date-pickers/PickersDay';
56
57
 
57
- var Lo=styled(Be,{shouldForwardProp:o=>o!=="cellAlign"})(({theme:o,cellAlign:r="top"})=>({position:"sticky",left:0,zIndex:1,verticalAlign:r,backgroundColor:o.palette.background.paper,[o.breakpoints.down("sm")]:{width:"50%",minWidth:"50%"}})),no=styled(Be,{shouldForwardProp:o=>o!=="isToday"})(({theme:o,isToday:r})=>({width:"auto",minWidth:"auto",overflow:"hidden",backgroundColor:`${r?o.palette.grey[200]:o.palette.common.white} !important`,verticalAlign:"top"})),Or=styled(un)(({theme:o})=>({"& .MuiTableCell-root":{padding:o.spacing(1,2),borderBottom:`1px solid ${o.palette.divider} !important`,borderRight:`1px solid ${o.palette.divider} !important`,"&:last-child":{borderRight:"none !important"}}}));var Fe=createContext(null),bn=({adapters:o,slots:r,children:e})=>{let t=a$4(),a=useMemo(()=>({adapters:o,slots:r,filters:t}),[o,r,t]);return jsx(Fe.Provider,{value:a,children:e})},c=()=>{let o=useContext(Fe);if(!o)throw new Error("useOrderProjectionContext must be used within an OrderProjectionProvider");return o},x=()=>c().filters;var We=styled(a,{shouldForwardProp:o=>o!=="isToday"})(({theme:o,isToday:r})=>({color:r?o.palette.primary.main:o.palette.text.secondary,backgroundColor:r?alpha(o.palette.primary.main,.15):alpha(o.palette.grey[500],.15),cursor:"pointer"}));var Pn=({day:o,summary:r})=>{let e=useMemo(()=>fe().startOf("day"),[]),t=o.isAfter(e,"day"),a=useMemo(()=>{let i=o.format("YYYY-MM-DD"),n=r?.days.find(d=>d.date===i);return {shopping_cart_active:n?.shopping_cart_active??0,order_placed:n?.order_placed??0,order_unplanned:n?.order_unplanned??0,order_planned:n?.order_planned??0,shopping_cart_abandoned:n?.shopping_cart_abandoned??0}},[o,r]);return jsxs(mo,{gap:1.5,children:[jsxs(mo,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"CALENDAR_TODAY",color:"grey.400"}),jsx(Y,{variant:"caption",fontWeight:"bold",children:"Pedidos"})]}),jsxs(mo,{gap:.5,children:[!t&&jsxs(Fragment,{children:[jsxs(Y,{variant:"caption",children:["Pedidos em andamento:"," ",jsx("strong",{children:a.shopping_cart_active})]}),jsxs(Y,{variant:"caption",children:["Pedidos realizados: ",jsx("strong",{children:a.order_placed})]}),jsxs(Y,{variant:"caption",children:["Pedidos fora do padr\xE3o: ",jsx("strong",{children:a.order_unplanned})]})]}),jsxs(Y,{variant:"caption",children:["Pedidos previstos: ",jsx("strong",{children:a.order_planned})]}),!t&&jsxs(Y,{variant:"caption",children:["Carrinhos abandonados:"," ",jsx("strong",{children:a.shopping_cart_abandoned})]})]})]})},He=Pn;var In=({day:o,summary:r,isFetchingSummary:e})=>{let t=o.isSame(fe(),"day"),{ordersPlacedCount:a,ordersExpectedCount:i}=useMemo(()=>{let n=o.format("YYYY-MM-DD"),d=r?.days.find(f=>f.date===n),l=d?.order_placed??0,h=d?.order_unplanned??0,y=d?.order_planned??0;return {ordersPlacedCount:l+h,ordersExpectedCount:l+h+y}},[o,r]);return jsx(a$e,{isLoading:e,loading:jsx(En,{width:50,height:24}),children:jsx(a$f,{title:jsx(He,{day:o,summary:r}),arrow:!0,children:jsx("span",{children:jsxs(We,{variant:"filled",backgroundColor:"#919EAB29",color:"text.secondary",isToday:t,children:[a," de ",i]})})})})},Ve=In;var On=["Dom.","Seg.","Ter.","Qua.","Qui.","Sex.","S\xE1b."],wn=({day:o,index:r,summary:e,isFetchingSummary:t,resize:a,previousResize:i,previousLabel:n})=>{let d=o.isSame(fe(),"day");return jsxs(no,{isToday:d,"data-testid":`day-cell-${r}`,children:[i&&jsx(a$d,{placement:"left",label:`Redimensionar coluna ${n}`,...i}),jsxs(mo,{direction:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1,children:[jsxs(mo,{children:[jsx(Y,{variant:"subtitle2",color:d?"primary.main":"text.secondary",children:o.date()}),jsx(Y,{variant:"body2",fontSize:13,color:d?"primary.main":"text.secondary",children:On[o.day()]})]}),jsx(Ve,{day:o,summary:e,isFetchingSummary:t})]}),a&&jsx(a$d,{label:`Redimensionar coluna ${o.format("DD/MM")}`,...a})]})},Ue=wn;var Nt=styled(Ln,{shouldForwardProp:o=>o!=="active"})(({theme:o,active:r})=>({justifyContent:"flex-start",color:r?o.palette.primary.main:o.palette.text.secondary,fontWeight:r?800:400,"&:hover":{background:o.palette.action.hover}}));var Mn=({summary:o})=>jsxs(mo,{gap:1.5,children:[jsxs(mo,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"USER_GROUP",color:"grey.400"}),jsx(Y,{variant:"caption",fontWeight:"bold",children:"Clientes"})]}),jsx(mo,{gap:.5,children:jsxs(Y,{variant:"caption",children:["Total de clientes: ",jsx("strong",{children:o?.partner_count??0})]})})]}),qe=Mn;var Yn=({summary:o,isFetchingSummary:r,resize:e})=>{let{open:t,onClose:a$1,onOpen:i}=a$8(),{ascending:n,setAscending:d}=x(),l=useCallback(h=>{d(h),a$1();},[a$1,d]);return jsxs(Fragment,{children:[jsxs(Lo,{cellAlign:"center",children:[jsxs(mo,{direction:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1,children:[jsxs(mo,{direction:"row",alignItems:"center",gap:1,children:[jsx(Y,{variant:"caption",color:"text.primary",children:"Clientes"}),jsx(a$e,{isLoading:r,loading:jsx(a$7,{width:26,height:24}),children:jsx(a$f,{title:jsx(qe,{summary:o}),arrow:!0,children:jsx("span",{children:jsx(a,{variant:"filled",backgroundColor:"#919EAB29",color:"text.secondary",sx:{cursor:"pointer"},children:o?.partner_count??0})})})})]}),jsx(a$c,{label:"Selecionar ordena\xE7\xE3o",icon:"SORTING_AZ_02",color:"text.secondary",size:"small",onClick:i})]}),e&&jsx(a$d,{label:"Redimensionar coluna Clientes",...e})]}),jsxs(a$a,{open:t,onClose:a$1,disabledArrow:!0,sx:{width:180,p:1},children:[jsx(Nt,{variant:"text",onClick:()=>l(!0),active:n,fullWidth:!0,children:"De A \xE0 Z"}),jsx(Nt,{variant:"text",onClick:()=>l(!1),active:!n,fullWidth:!0,children:"De Z \xE0 A"})]})]})},Ke=Yn;var Qe=styled(Hn)(({theme:o})=>({"& .MuiTableCell-root":{padding:o.spacing(1,2),borderTop:`1px solid ${o.palette.divider} !important`,borderBottom:`1px solid ${o.palette.divider} !important`,borderRight:`1px solid ${o.palette.divider} !important`,background:o.palette.common.white,"&:last-child":{borderRight:"none !important"}},"& .MuiTableCell-root:first-of-type":{zIndex:3}}));var $n=({days:o,summary:r,isFetchingSummary:e,getColumnResizeProps:t})=>jsx(Qe,{children:jsxs(un,{children:[jsx(Ke,{summary:r,isFetchingSummary:e,resize:t(l)}),o.map((a,i)=>jsx(Ue,{index:i,day:a,summary:r,isFetchingSummary:e,resize:t(q(i)),previousResize:t(i===0?l:q(i-1)),previousLabel:i===0?"Clientes":o[i-1].format("DD/MM")},i))]})}),Je=$n;var Un={["PAST"]:{icon:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630",width:24}),message:jsxs(Fragment,{children:["O cliente deveria ter feito pedido, conforme sua frequ\xEAncia de compra, mas nenhum pedido foi registrado. Esse comportamento pode indicar"," ",jsx("strong",{children:"queda de engajamento"})," ou"," ",jsx("strong",{children:"risco de inativa\xE7\xE3o"}),"."]})},["TODAY"]:{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00",width:24}),message:jsx(Fragment,{children:"Conforme a frequ\xEAncia de compra deste cliente, um pedido era esperado hoje, mas nenhum registro foi feito at\xE9 o momento."})},["FUTURE"]:{icon:jsx(a$1,{icon:"INFO",color:"common.black",width:24}),message:jsxs(Fragment,{children:["Baseado na rotina de compras identificada."," ",jsx("strong",{children:"Nenhuma a\xE7\xE3o \xE9 necess\xE1ria no momento"}),"."]})}},Ze={["ORDER_UNPLANNED"]:()=>{let o=v("ORDER_UNPLANNED");return {icon:jsx(a$1,{icon:"INFO",color:"#00B8D9",width:24}),message:jsxs(Fragment,{children:["O cliente realizou um pedido em um dia diferente da sua rotina habitual. Isso pode indicar uma"," ",jsx("strong",{children:"mudan\xE7a de comportamento de compra"})," ou uma"," ",jsx("strong",{children:"demanda excepcional"}),"."]}),background:o.background,color:o.color}},["ORDER_PLANNED"]:({referenceDate:o})=>{let{period:r}=u(o||new Date),e=v("ORDER_PLANNED",r),{icon:t,message:a}=Un[r];return {icon:t,message:a,background:e.background,color:e.color}},["SHOPPING_CART_ACTIVE"]:()=>{let o=v("SHOPPING_CART_ACTIVE");return {icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00",width:24}),message:jsx(Fragment,{children:"O cliente est\xE1 atualizando o carrinho neste momento."}),background:o.background,color:o.color}},["SHOPPING_CART_ABANDONED"]:({referenceDate:o})=>{let r=v("SHOPPING_CART_ABANDONED");return {icon:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630",width:24}),message:jsxs(Fragment,{children:["Carrinho est\xE1 abandonado h\xE1 ",jsx("strong",{children:g(o)}),"."]}),background:r.background,color:r.color}}};var oa=styled(jn,{shouldForwardProp:o=>o!=="customBackground"&&o!=="customColor"})(({theme:o,customBackground:r,customColor:e})=>({padding:o.spacing(1.5,2),borderRadius:0,borderBottom:`1px solid ${o.palette.divider}`,background:r,color:e}));var Xn=({origin:o,referenceDate:r})=>{let e=Ze[o];if(!e)return null;let t=e({origin:o,referenceDate:r});return t?jsx(oa,{icon:t.icon,customBackground:t.background,customColor:t.color,children:t.message}):null},ra=Xn;var op=({message:o,onRetry:r,isFetching:e})=>jsxs(mo,{alignItems:"center",justifyContent:"center",p:3,gap:.5,children:[jsx(Y,{variant:"body2",color:"text.secondary",children:o}),jsx(Qn,{variant:"text",startIcon:jsx(a$1,{icon:"REFRESH_CHANGE"}),size:"small",onClick:r,loading:e,children:"Tentar novamente"})]}),po=op;var tp=()=>jsxs(mo,{gap:3,p:3,children:[jsxs(mo,{gap:1,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{gap:.5,children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Status do pedido"}),jsx(a$7,{width:"30%",height:22})]})]}),jsxs(mo,{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1.5,children:[jsx(a$7,{width:"100%",height:30}),jsx(a$7,{width:"100%",height:30})]})]}),ta=tp;var ap=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{renderEventStatus:a,renderEventActions:i}=e,{data:n,isLoading:d,isFetching:l,isError:h$1,refetch:y}=t(o,{skip:!o}),f=n?.detail?.sale_external_id||n?.detail?.external_id,E=d||l,P=n?.external_origin==="SALE";return jsx(a$e,{isLoading:E,loading:jsx(ta,{}),anError:h$1,error:jsx(po,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido realizado!",onRetry:y,isFetching:l}),children:jsxs(mo,{gap:3,p:3,children:[jsxs(mo,{gap:1,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:f?`#${f}`:"-"})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d$1(n?.detail?.created_at,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h(n?.detail?.total_value??n?.amount_value)})]}),n&&a?.(n)]}),jsxs(mo,{gap:1.5,children:[n&&i?.(n),!P&&jsx(jn,{severity:"warning",children:"Este pedido foi importado do ERP. Para visualizar detalhes ou realizar a\xE7\xF5es, acesse o sistema ERP."})]})]})})},aa=ap;var ip=({period:o})=>{let r=o==="PAST",e=o==="FUTURE";return jsxs(mo,{gap:3,p:3,children:[jsxs(mo,{gap:1,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:e?"Comportamento de compra":"Resumo"}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Data prevista"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(a$7,{width:"30%",height:22})]}),r&&jsxs(Fragment,{children:[jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Per\xEDodo desde o \xFAltimo pedido"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),jsx(a$7,{width:"50%",height:22})]})]})]}),jsxs(mo,{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1,children:[jsx(a$7,{width:"100%",height:30}),jsx(a$7,{width:"100%",height:30})]})]})},ia=ip;var pp=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t$1}=r,{renderEventActions:a,renderSaleLink:i}=e,{data:n,isLoading:d,isFetching:l,isError:h,refetch:y}=t$1(o,{skip:!o}),{period:f}=u(n?.reference_date??new Date),E=f==="PAST",P=f==="FUTURE",D=n?.partner?.sale_analysis?.last_sale_sale_external_id||n?.partner?.sale_analysis?.last_sale_external_id,Z=n?.partner?.sale_analysis?.last_sale_negotiation_date;return jsx(a$e,{isLoading:d,loading:jsx(ia,{period:f}),anError:h,error:jsx(po,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido previsto!",onRetry:y,isFetching:l}),children:jsxs(mo,{gap:3,p:3,children:[jsxs(mo,{gap:1,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:P?"Comportamento de compra":"Resumo"}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Data prevista"}),jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d$1(n?.reference_date,"DD/MM/YYYY")})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:t(n?.partner?.recurrence)})]}),E&&jsxs(Fragment,{children:[jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Per\xEDodo desde o \xFAltimo pedido"}),jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:Z?g(Z):"-"})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),D?jsxs(mo,{direction:"row",alignItems:"center",gap:.5,children:[i?.(D),jsxs(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:["em ",d$1(Z,"DD/MM/YYYY [\xE0s] HH:mm")]})]}):jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"})]})]})]}),n&&a?.(n)]})})},na=pp;var dp=()=>jsxs(mo,{gap:3,p:3,children:[jsxs(mo,{gap:1,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(a$7,{width:"25%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(a$7,{width:"20%",height:22})]})]}),jsx(Qo,{sx:{mx:-3}}),jsxs(mo,{gap:1,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(a$7,{width:"35%",height:22})]})]}),jsxs(mo,{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1,children:[jsx(a$7,{width:"100%",height:30}),jsx(a$7,{width:"100%",height:30})]})]}),pa=dp;var lp=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t$1}=r,{renderEventActions:a}=e,{data:i,isLoading:n,isFetching:d,isError:l,refetch:h$1}=t$1(o,{skip:!o}),y=i?.detail?.sale_external_id||i?.detail?.external_id;return jsx(a$e,{isLoading:n,loading:jsx(pa,{}),anError:l,error:jsx(po,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido!",onRetry:h$1,isFetching:d}),children:jsxs(mo,{gap:3,p:3,children:[jsxs(mo,{gap:1,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:y?`#${y}`:"-"})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:d$1(i?.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:h(i?.amount_value)})]})]}),jsx(Qo,{sx:{mx:-3}}),jsxs(mo,{gap:1,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:t(i?.partner?.recurrence)})]})]}),i&&a?.(i)]})})},sa=lp;var cp=()=>jsxs(mo,{gap:3,p:3,children:[jsxs(mo,{gap:1,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do carrinho"}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Tempo decorrido desde o abandono"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(a$7,{width:"80%",height:22})]})]}),jsx(a$7,{width:"100%",height:30})]}),da=cp;var fp=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{formatAddress:a}=e,{data:i,isLoading:n,isFetching:d,isError:l,refetch:h$1}=t(o,{skip:!o});return jsx(a$e,{isLoading:n,loading:jsx(da,{}),anError:l,error:jsx(po,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do carrinho abandonado!",onRetry:h$1,isFetching:d}),children:jsxs(mo,{gap:3,p:3,children:[jsxs(mo,{gap:1,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do carrinho"}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Tempo decorrido desde o abandono"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:d$1(i?.detail?.abandoned_at,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:i?.detail?.new_order?.name??"-"})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:i?.detail?.payment_method?.name??"-"})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:h(i?.detail?.total??i?.amount_value)})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:a(i?.detail?.address)})]})]}),jsx(Ln,{component:li,href:`https://wa.me/${i?.partner?.phone}`,target:"_blank",rel:"noopener noreferrer",variant:"outlined",startIcon:jsx(a$1,{icon:"WHATSAPP",color:"success.main"}),color:"inherit",size:"small",disabled:!i?.partner?.phone,children:"Enviar mensagem"})]})})},la=fp;var gp=()=>jsxs(mo,{gap:3,p:3,children:[jsxs(mo,{gap:1,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:"Resumo do carrinho"}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(a$7,{width:"80%",height:22})]})]}),jsx(a$7,{width:"100%",height:30})]}),ca=gp;var Tp=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{formatAddress:a}=e,{data:i,isLoading:n,isFetching:d,isError:l,refetch:h$1}=t(o,{skip:!o});return jsx(a$e,{isLoading:n,loading:jsx(ca,{}),anError:l,error:jsx(po,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do carrinho!",onRetry:h$1,isFetching:d}),children:jsxs(mo,{gap:3,p:3,children:[jsxs(mo,{gap:1,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:"Resumo do carrinho"}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:i?.detail?.new_order?.name??"-"})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:i?.detail?.payment_method?.name??"-"})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:h(i?.detail?.total??i?.amount_value)})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:a(i?.detail?.address)})]})]}),jsx(Ln,{component:li,href:`https://wa.me/${i?.partner?.phone}`,target:"_blank",rel:"noopener noreferrer",variant:"outlined",startIcon:jsx(a$1,{icon:"WHATSAPP",color:"success.main"}),color:"inherit",size:"small",disabled:!i?.partner?.phone,children:"Enviar mensagem"})]})})},ma=Tp;var Sp={["ORDER_PLACED"]:aa,["ORDER_UNPLANNED"]:sa,["ORDER_PLANNED"]:na,["SHOPPING_CART_ACTIVE"]:ma,["SHOPPING_CART_ABANDONED"]:la},bp=({origin:o,eventId:r})=>{let e=Sp[o];return e?jsx(e,{eventId:r}):null},jt=bp;var Cp=({events:o})=>{let{getEventCode:r}=c().slots;if(o.length<=1){let e=o[0];return e?jsx(jt,{origin:e.type,eventId:e.id}):null}return jsx(Fragment,{children:o.map(e=>jsxs(a$g,{slotProps:{transition:{unmountOnExit:!0}},children:[jsx(b$1,{children:jsxs(Y,{variant:"overline",color:"text.secondary",children:["Pedido:\u2002",jsxs(Y,{component:"span",variant:"body2",fontWeight:600,color:"text.primary",children:["#",r(e)]})]})}),jsx(c$1,{sx:{p:0,mt:-2},children:jsx(jt,{origin:e.type,eventId:e.id})})]},e.id))})},fa=Cp;var kp=()=>jsxs(mo,{p:3,gap:1,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do cliente"}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Nome"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$7,{width:"100%",height:22})]}),jsx(Ln,{variant:"text",startIcon:jsx(a$1,{icon:"PENCIL_EDIT"}),color:"inherit",size:"small",disabled:!0,children:"Editar"})]})]}),ua=kp;var Ep=({partner:o,isLoading:r,onPhoneUpdated:e})=>{let{renderPartnerLink:t,renderPhoneEditor:a}=c().slots;return jsx(a$e,{isLoading:r,loading:jsx(ua,{}),children:jsxs(mo,{p:3,gap:1,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do cliente"}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Nome"}),t?t(o):jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o?.name||"-"})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:o?.tax_id?i$1(o.tax_id):"-"})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Telefone"}),o?.phone?jsx(li,{href:`https://wa.me/${o.phone}`,target:"_blank",rel:"noopener noreferrer",color:"#22C55E",children:jsxs(mo,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"WHATSAPP",color:"#22C55E"}),jsx(Y,{variant:"subtitle2",color:"success.main",children:h$1(o.phone)})]})}):jsx(Y,{variant:"subtitle2",color:"text.primary",children:"-"})]}),a?.(o?.external_id??"",e??(()=>{}))]})]})})},Ta=Ep;var Sa=styled(mo,{shouldForwardProp:o=>o!=="customBackground"&&o!=="customColor"})(({theme:o,customBackground:r,customColor:e})=>({padding:o.spacing(.5,1),borderRadius:4,background:r,color:e}));var Np=({open:o,onClose:r,events:e})=>{let t=e[0],[a,i]=useState(),{useEventDetails:n}=c().adapters,{data:d,isLoading:l,refetch:h}=n(t?.id??"",{skip:!o||!t?.id}),{period:y}=u(t?.reference_date??new Date),f=v(t?.type,y),E=useCallback(P=>{i(P),h();},[h]);return jsxs(a$b,{open:o,onClose:r,headerTitle:jsxs(Fragment,{children:["Detalhes"," ",jsx(Sa,{customBackground:f.background,customColor:f.color,children:jsx(Y,{variant:"subtitle2",fontSize:13,noWrap:!0,children:f.label})})]}),headerProps:{direction:"row-reverse"},contentProps:{p:0},maxWidth:520,children:[jsx(mo,{position:"sticky",top:0,zIndex:9,children:jsx(ra,{origin:t?.type,referenceDate:t?.reference_date})}),jsx(Ta,{partner:d?.partner?{...d.partner,phone:a??d.partner.phone}:void 0,isLoading:l,onPhoneUpdated:E}),jsx(Qo,{}),jsx(fa,{events:e})]})},yt=Np;var Bp=({icon:o,title:r,description:e,details:t,footer:a})=>jsxs(mo,{gap:1,children:[jsxs(mo,{direction:"row",alignItems:"center",gap:.5,children:[o,jsx(Y,{variant:"caption",fontWeight:"bold",children:r})]}),jsx(Y,{variant:"caption",children:e}),t&&jsxs(Fragment,{children:[jsx(Qo,{sx:{borderStyle:"dashed"}}),jsx(mo,{children:t})]}),a&&jsxs(Fragment,{children:[jsx(Qo,{sx:{borderStyle:"dashed"}}),a]})]}),Q=Bp;var Fp=({event:o})=>{let{getEventCode:r}=c().slots;return jsx(Q,{icon:jsx(a$1,{icon:"CHECK_CIRCLE",color:"#22C55E"}),title:"Pedido realizado",description:"Pedido realizado com sucesso!",details:jsxs(Fragment,{children:[jsxs(Y,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(o)?`#${r(o)}`:"-"})]}),jsxs(Y,{variant:"caption",children:["Data e hora:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(Y,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})})},Pa=Fp;var Wp=({event:o})=>{let{period:r}=u(o.reference_date);return r==="PAST"?jsx(Q,{icon:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630"}),title:"Pedido n\xE3o realizado",description:"Cliente n\xE3o realizou o pedido previsto na data esperada.",details:jsxs(Y,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY")})]})}):r==="TODAY"?jsx(Q,{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),title:"Pedido previsto para hoje",description:"Nenhum pedido registrado at\xE9 o momento.",details:jsxs(Y,{variant:"caption",children:["Valor previsto: ",jsx("strong",{children:h(o.amount_value)})]})}):jsx(Q,{icon:jsx(a$1,{icon:"CALENDAR_TODAY",color:"#C4CDD5"}),title:"Pedido previsto",description:"Pr\xF3ximo pedido estimado conforme padr\xE3o de frequ\xEAncia.",details:jsxs(Y,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY")})]})})},ka=Wp;var Gp=({event:o})=>{let{getEventCode:r}=c().slots;return jsx(Q,{icon:jsx(a$1,{icon:"INFO",color:"#00B8D9"}),title:"Pedido fora do padr\xE3o",description:"Pedido feito em dia n\xE3o previsto pela frequ\xEAncia.",details:jsxs(Fragment,{children:[jsxs(Y,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(o)?`#${r(o)}`:"-"})]}),jsxs(Y,{variant:"caption",children:["Data e hora:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(Y,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})})},Da=Gp;var Vp=({event:o})=>jsx(Q,{icon:jsx(a$1,{icon:"CANCEL_CIRCLE_SOLID",color:"#FF5630"}),title:"Carrinho abandonado",description:jsxs(Fragment,{children:["Carrinho inativo h\xE1 ",jsx("strong",{children:g(o.reference_date)})," \u2014 valor estimado: ",jsx("strong",{children:h(o.amount_value)}),"."]}),details:jsxs(Fragment,{children:[jsxs(Y,{variant:"caption",children:["ID:"," ",jsx("strong",{children:o.external_id?`#${o.external_id}`:"-"})]}),jsxs(Y,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})}),Ia=Vp;var zp=({event:o})=>jsx(Q,{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),title:"Pedido em andamento",description:"Cliente est\xE1 atualizando o carrinho neste momento.",details:jsxs(Y,{variant:"caption",children:["Valor parcial: ",jsx("strong",{children:h(o.amount_value)})]})}),Ra=zp;var re={color:"common.white",width:16,height:16,sx:{flexShrink:0}},Aa={["ORDER_PLACED"]:{getIcon:()=>null,getTitle:()=>"Pedido realizado",getDescription:()=>"Pedido confirmado com sucesso!",getTooltip:o=>jsx(Pa,{event:o})},["ORDER_UNPLANNED"]:{getIcon:()=>null,getTitle:()=>"Pedido fora do padr\xE3o",getDescription:()=>"Pedido feito fora do dia habitual.",getTooltip:o=>jsx(Da,{event:o})},["ORDER_PLANNED"]:{getIcon:o=>{let{period:r}=u(o.reference_date);return r==="PAST"?jsx(a$1,{icon:"HEXAGON_WARNING",...re}):r==="TODAY"?jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",...re}):null},getTitle:o=>{let{period:r}=u(o.reference_date);return r==="PAST"?"Pedido n\xE3o realizado":r==="TODAY"?"Pedido previsto para hoje":"Pedido previsto"},getDescription:o=>{let{period:r}=u(o.reference_date);return r==="PAST"?"Cliente n\xE3o realizou o pedido previsto na data esperada.":r==="TODAY"?"Nenhum pedido registrado at\xE9 o momento.":"Pr\xF3ximo pedido estimado conforme padr\xE3o de frequ\xEAncia."},getTooltip:o=>jsx(ka,{event:o})},["SHOPPING_CART_ACTIVE"]:{getIcon:()=>null,getTitle:()=>"Pedido em andamento",getDescription:()=>"Cliente est\xE1 atualizando o carrinho neste momento.",getTooltip:o=>jsx(Ra,{event:o})},["SHOPPING_CART_ABANDONED"]:{getIcon:()=>jsx(a$1,{icon:"CANCEL_CIRCLE_SOLID",...re}),getTitle:()=>"Carrinho abandonado",getDescription:o=>`Carrinho inativo h\xE1 ${g(o.reference_date)} \u2014 valor estimado: ${h(o.amount_value)}.`,getTooltip:o=>jsx(Ia,{event:o})}};var La=styled(mo,{shouldForwardProp:o=>o!=="eventType"&&o!=="period"})(({theme:o,eventType:r,period:e})=>{let t=v(r,e);return {position:"relative",padding:o.spacing(.5,1),borderRadius:4,background:t.background,color:t.color,cursor:"pointer","&:hover":{background:t.backgroundHover}}}),Na=styled(mo,{shouldForwardProp:o=>o!=="eventType"&&o!=="period"})(({theme:o,eventType:r,period:e})=>({position:"absolute",top:-5,right:-5,width:20,height:20,alignItems:"center",justifyContent:"center",borderRadius:"50%",background:v(r,e).iconBadgeColor,boxShadow:`0 0 0 2px ${o.palette.common.white}`}));var jp=({event:o,index:r})=>{let[e,t]=a$9(),a=Aa[o.type];if(!a)return null;let{period:i}=u(o.reference_date),n=a.getIcon(o);return jsxs(Fragment,{children:[jsx(a$f,{title:a.getTooltip(o),arrow:!0,children:jsxs(La,{"data-testid":`event-${r}`,eventType:o.type,period:i,onClick:t,children:[n&&jsx(Na,{eventType:o.type,period:i,children:n}),jsx(Y,{variant:"subtitle2",fontSize:13,noWrap:!0,children:a.getTitle(o)}),jsx(Y,{variant:"caption",noWrap:!0,children:a.getDescription(o)})]})}),jsx(yt,{open:e,onClose:t,events:[o]})]})},Fa=jp;var Kp=({icon:o,title:r,description:e,children:t})=>jsxs(mo,{gap:1,children:[jsxs(mo,{direction:"row",alignItems:"center",gap:.5,children:[o,jsx(Y,{variant:"caption",fontWeight:"bold",children:r})]}),jsx(Y,{variant:"caption",children:e}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsx(mo,{gap:1,children:t})]}),co=Kp;var Jp=({events:o})=>{let{getEventCode:r}=c().slots,e=o.slice(0,k),t=o.length-k;return jsxs(co,{icon:jsx(a$1,{icon:"CHECK_CIRCLE",color:"#22C55E"}),title:"Pedidos realizados",description:"Pedidos realizados com sucesso!",children:[e.map((a,i)=>jsxs(mo,{children:[i>0&&jsx(Qo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(Y,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(a)?`#${r(a)}`:"-"})]}),jsxs(Y,{variant:"caption",children:["Data/Hora:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(Y,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(a.amount_value)})]})]},a.id)),t>0&&jsxs(Fragment,{children:[jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(Y,{variant:"caption",children:["e mais ",t," pedido",t>1?"s":""]})]})]})},Ha=Jp;var rs={["PAST"]:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630"}),["TODAY"]:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),["FUTURE"]:jsx(a$1,{icon:"CALENDAR_TODAY",color:"#C4CDD5"})},ts={["PAST"]:"Pedidos n\xE3o realizados",["TODAY"]:"Pedidos previstos para hoje",["FUTURE"]:"Pedidos previstos"},es={["PAST"]:"Clientes n\xE3o realizaram os pedidos previstos na data esperada.",["TODAY"]:"Nenhum pedido registrado at\xE9 o momento.",["FUTURE"]:"Pr\xF3ximos pedidos estimados conforme padr\xE3o de frequ\xEAncia."},as=({events:o})=>{let{period:r}=u(o[0]?.reference_date),e=o.slice(0,k),t=o.length-k;return jsxs(co,{icon:rs[r],title:ts[r],description:es[r],children:[e.map((a,i)=>jsxs(mo,{children:[i>0&&jsx(Qo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(Y,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY")})]})]},a.id)),t>0&&jsxs(Fragment,{children:[jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(Y,{variant:"caption",children:["e mais ",t," pedido",t>1?"s":""]})]})]})},za=as;var ps=({events:o})=>{let{getEventCode:r}=c().slots,e=o.slice(0,k),t=o.length-k;return jsxs(co,{icon:jsx(a$1,{icon:"INFO",color:"#00B8D9"}),title:"Pedidos fora do padr\xE3o",description:"Pedidos feitos em dias n\xE3o previstos pela frequ\xEAncia.",children:[e.map((a,i)=>jsxs(mo,{children:[i>0&&jsx(Qo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(Y,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(a)?`#${r(a)}`:"-"})]}),jsxs(Y,{variant:"caption",children:["Data/Hora:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(Y,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(a.amount_value)})]})]},a.id)),t>0&&jsxs(Fragment,{children:[jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(Y,{variant:"caption",children:["e mais ",t," pedido",t>1?"s":""]})]})]})},ja=ps;var ls=({events:o})=>{let r=o.slice(0,k),e=o.length-k;return jsxs(co,{icon:jsx(a$1,{icon:"CANCEL_CIRCLE_SOLID",color:"#FF5630"}),title:"Carrinhos abandonados",description:"Carrinhos inativos h\xE1 algum tempo.",children:[r.map((t,a)=>jsxs(mo,{children:[a>0&&jsx(Qo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(Y,{variant:"caption",children:["ID:"," ",jsx("strong",{children:t.external_id?`#${t.external_id}`:"-"})]}),jsxs(Y,{variant:"caption",children:["Inativo h\xE1: ",jsx("strong",{children:g(t.reference_date)})]}),jsxs(Y,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(t.amount_value)})]})]},t.id)),e>0&&jsxs(Fragment,{children:[jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(Y,{variant:"caption",children:["e mais ",e," carrinho",e>1?"s":""]})]})]})},Xa=ls;var ys=({events:o})=>{let r=o.slice(0,k),e=o.length-k;return jsxs(co,{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),title:"Pedidos em andamento",description:"Clientes est\xE3o atualizando seus carrinhos neste momento.",children:[r.map((t,a)=>jsxs(mo,{children:[a>0&&jsx(Qo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(Y,{variant:"caption",children:["ID:"," ",jsx("strong",{children:t.external_id?`#${t.external_id}`:"-"})]}),jsxs(Y,{variant:"caption",children:["Valor parcial: ",jsx("strong",{children:h(t.amount_value)})]})]},t.id)),e>0&&jsxs(Fragment,{children:[jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(Y,{variant:"caption",children:["e mais ",e," carrinho",e>1?"s":""]})]})]})},Qa=ys;var Ja={["ORDER_PLACED"]:Ha,["ORDER_UNPLANNED"]:ja,["ORDER_PLANNED"]:za,["SHOPPING_CART_ACTIVE"]:Qa,["SHOPPING_CART_ABANDONED"]:Xa};var Za=styled(mo,{shouldForwardProp:o=>o!=="customBackground"&&o!=="customColor"&&o!=="customHoverBackground"})(({theme:o,customBackground:r,customColor:e,customHoverBackground:t})=>({padding:o.spacing(.5,1),borderRadius:4,background:r,color:e,cursor:"pointer","&:hover":{background:t}}));var Ts=({group:o,index:r})=>{let[e,t]=a$9(),{config:a,count:i,events:n}=o,d=i>1?a.labelPlural:a.label,l=Ja[n[0].type];return jsxs(Fragment,{children:[jsx(a$f,{title:jsx(l,{events:n}),arrow:!0,children:jsx(Za,{"data-testid":`grouped-events-${r}`,customBackground:a.background,customColor:a.color,customHoverBackground:a.backgroundHover,onClick:t,children:jsxs(Y,{variant:"subtitle2",fontSize:13,title:`${i} ${d}`,noWrap:!0,children:[jsx("strong",{children:i})," ",d]})})}),jsx(yt,{open:e,onClose:t,events:n})]})},ri=Ts;var vs=({events:o})=>{let r=useMemo(()=>{let e={};return o.forEach(t=>{let a=t.type==="ORDER_PLANNED"?v(t.type,u(t.reference_date).period):v(t.type);e[a.label]||(e[a.label]={count:0,config:a,events:[]}),e[a.label].count+=1,e[a.label].events.push(t);}),Object.values(e)},[o]);return jsx(Fragment,{children:r.map((e,t)=>jsx(ri,{index:t,group:e},t))})},ei=vs;var ai=styled(mo)({gap:4});var Ds=({events:o,day:r,index:e})=>{let t=r.isSame(fe(),"day");if(o.length===0)return jsx(no,{isToday:t,"data-testid":`day-column-${e}`});let a=o.length>j;return jsx(no,{isToday:t,"data-testid":`day-column-${e}`,children:jsx(ai,{children:a?jsx(ei,{events:o}):o.map((i,n)=>jsx(Fa,{index:n,event:i},n))})})},ii=Ds;var _s=({day:o,index:r,events:e,isFetching:t})=>{let a=o.isSame(fe(),"day");return t?jsx(no,{isToday:a,"data-testid":`day-column-${r}`,children:jsx(a$7,{width:"100%",height:"100%",sx:{maxHeight:46.42}})}):jsx(ii,{events:e,day:o,index:r})},ni=_s;var pi=styled(Is)(()=>({width:6,height:6,borderRadius:"50%",flexShrink:0}));var ws=({status:o,variant:r="body2",color:e="text.primary"})=>{let t=e$1[o];if(!t)return null;let{label:a,color:i}=t;return jsxs(mo,{direction:"row",alignItems:"center",gap:1,children:[jsx(pi,{bgcolor:i}),jsx(Y,{variant:r,color:e,noWrap:!0,children:a})]})},Ct=ws;var Ms=()=>jsxs(mo,{mt:-1,px:1,gap:1,children:[jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Nome"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"E-mail"}),jsx(a$7,{width:"35%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Status do cliente"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{gap:.5,children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Segmento"}),jsx(a$7,{width:"35%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$7,{width:"100%",height:22})]}),jsx(Ln,{variant:"text",startIcon:jsx(a$1,{icon:"PENCIL_EDIT"}),color:"inherit",size:"small",disabled:!0,children:"Editar"})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Vendedor preferencial"}),jsx(a$7,{width:"40%",height:22})]})]}),di=Ms;var Ws=({partner:o,onPhoneUpdated:r})=>{let[e,t]=a$9(!0),{adapters:a,slots:i}=c(),{renderPartnerLink:n,renderPhoneEditor:d}=i,{data:l,isLoading:h,refetch:y}=a.usePartnerDetails(o.external_id,{skip:!o.external_id||!e}),f=l?.mobile??l?.phone,E=useMemo(()=>l?.fiscal_registration_number?i$1(l?.fiscal_registration_number):"-",[l?.fiscal_registration_number]),P=useCallback(D=>{y(),r?.(D);},[y,r]);return jsxs(a$g,{expanded:e,onChange:t,defaultExpanded:!0,children:[jsx(b$1,{children:jsx(Y,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es"})}),jsx(c$1,{children:jsx(a$e,{isLoading:h,loading:jsx(di,{}),children:jsxs(mo,{mt:-1,px:1,gap:1,children:[jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Nome"}),n?n(o):jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o?.name||"-"})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:E})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"E-mail"}),jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:l?.email||"-"})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Status do cliente"}),o.classification?jsx(Ct,{status:o.classification,variant:"subtitle2",color:"text.primary"}):jsx(Y,{variant:"subtitle2",color:"text.primary",children:"-"})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{gap:.5,children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Segmento"}),l?.profile?.name?jsx(Ys,{variant:"outlined",label:l.profile.name,size:"small",color:"default",sx:{width:"fit-content"}}):jsx(Y,{variant:"subtitle2",color:"text.primary",children:"-"})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Telefone"}),f?jsxs(mo,{direction:"row",alignItems:"center",gap:.5,children:[jsx(a$1,{icon:"WHATSAPP",color:"success.main",sx:{flexShrink:0}}),jsx(li,{component:li,href:`https://wa.me/${f}`,target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",color:"success.main",noWrap:!0,children:h$1(f)})]}):jsx(Y,{variant:"subtitle2",color:"text.primary",children:"-"})]}),d?.(o.external_id,P)]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Vendedor preferencial"}),jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:l?.main_seller?.name||"-"})]})]})})})]})},ci=Ws;var Vs=({order:o})=>{let{renderSaleLink:r}=c().slots;return jsxs(a$5,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,p:1.5,sx:{borderRadius:1},children:[jsxs(mo,{overflow:"hidden",children:[o?.id?r?.(o.id):jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"}),jsx(Y,{variant:"caption",color:"text.secondary",children:d$1(o?.negotiation_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:h(o?.total_value)})]})},yi=memo(Vs,a$2);var zs=()=>jsxs(mo,{gap:1.5,children:[jsx(a$7,{width:"100%",height:66}),jsx(a$7,{width:"100%",height:66}),jsx(a$7,{width:"100%",height:66}),jsx(a$7,{width:"100%",height:66}),jsx(a$7,{width:"100%",height:66})]}),fi=zs;var js=({partner:o})=>{let[r,e]=a$9(!1),{usePartnerOrders:t}=c().adapters,{data:{items:a=[]}={},isLoading:i}=t(o?.external_id,{skip:!o?.external_id||!r});return jsxs(a$g,{expanded:r,onChange:e,children:[jsx(b$1,{children:jsx(Y,{variant:"overline",color:"text.secondary",children:"\xDAltimos pedidos"})}),jsx(c$1,{children:jsx(mo,{mt:-1,px:1,children:jsx(a$e,{isLoading:i,loading:jsx(fi,{}),isEmpty:a?.length===0,empty:jsx(mo,{alignItems:"center",justifyContent:"center",gap:1.5,p:2,children:jsx(Y,{variant:"body2",color:"text.secondary",children:"Este cliente ainda n\xE3o possui pedidos realizados."})}),children:jsx(mo,{gap:1.5,children:a?.map((n,d)=>jsx(yi,{order:n,"data-testid":`last-order-${d}`},n.id))})})})})]})},ui=js;var Qs=({partner:o})=>{let{renderSaleLink:r}=c().slots,[e,t$1]=a$9(!1),a=useMemo(()=>t(o?.recurrence),[o?.recurrence]),i=o?.sale_analysis?.last_sale_sale_external_id||o?.sale_analysis?.last_sale_external_id,n=o?.sale_analysis?.last_sale_negotiation_date;return jsxs(a$g,{expanded:e,onChange:t$1,children:[jsx(b$1,{children:jsx(Y,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"})}),jsx(c$1,{children:jsxs(mo,{mt:-1,px:1,gap:1,children:[jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(Y,{variant:"subtitle2",color:"text.primary",children:a})]}),jsx(Qo,{sx:{borderStyle:"dashed"}}),jsxs(mo,{children:[jsx(Y,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),i?jsxs(mo,{direction:"row",alignItems:"center",gap:.5,children:[r?.(i),jsxs(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:["em ",d$1(n,"DD/MM/YYYY [\xE0s] HH:mm")]})]}):jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"})]})]})})]})},hi=Qs;var se=styled(Qo)(({theme:o})=>({height:30,alignSelf:"center",borderStyle:"dashed",[o.breakpoints.down("sm")]:{display:"none"}}));var od=()=>jsxs(mo,{direction:{xs:"column",sm:"row"},justifyContent:{xs:"flex-start",sm:"center"},gap:3,children:[jsxs(mo,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(Y,{variant:"body2",children:"Qtd. de pedidos"}),jsx(a$7,{width:30,height:22})]}),jsx(se,{orientation:"vertical",flexItem:!0}),jsxs(mo,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(Y,{variant:"body2",children:"Valor total"}),jsx(a$7,{width:92,height:22})]}),jsx(se,{orientation:"vertical",flexItem:!0}),jsxs(mo,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(Y,{variant:"body2",children:"Ticket m\xE9dio"}),jsx(a$7,{width:71,height:22})]})]}),Ti=od;var rd=({partner:o})=>{let[r,e]=a$9(!1),{usePartnerSaleSummary:t}=c().adapters,{data:a,isLoading:i}=t(o.external_id,{skip:!o.external_id||!r});return jsxs(a$g,{expanded:r,onChange:e,children:[jsx(b$1,{children:jsx(Y,{variant:"overline",color:"text.secondary",children:"Indicadores de vendas"})}),jsx(c$1,{children:jsx(mo,{mt:-1,px:1,children:jsx(a$e,{isLoading:i,loading:jsx(Ti,{}),children:jsxs(mo,{direction:{xs:"column",sm:"row"},justifyContent:{xs:"flex-start",sm:"center"},gap:3,children:[jsxs(mo,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(Y,{variant:"body2",children:"Qtd. de pedidos"}),jsx(Y,{variant:"subtitle2",children:a?.order_quantity||0})]}),jsx(Qo,{orientation:"vertical",flexItem:!0}),jsxs(mo,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(Y,{variant:"body2",children:"Valor total"}),jsx(Y,{variant:"subtitle2",children:h(a?.total_value)})]}),jsx(Qo,{orientation:"vertical",flexItem:!0}),jsxs(mo,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(Y,{variant:"body2",children:"Ticket m\xE9dio"}),jsx(Y,{variant:"subtitle2",children:h(a?.average_ticket)})]})]})})})})]})},bi=rd;var td=({partner:o,onPhoneUpdated:r})=>jsxs(Fragment,{children:[jsx(ci,{partner:o,onPhoneUpdated:r}),jsx(bi,{partner:o}),jsx(hi,{partner:o}),jsx(ui,{partner:o})]}),vi=td;var xi=styled(mo)(({theme:o})=>({minHeight:47.42,flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:o.spacing(1.5)})),le=styled(Ln)(({theme:o})=>({justifyContent:"flex-start",color:o.palette.text.primary,fontWeight:400,"&:hover":{background:o.palette.action.hover}}));var ld=({partner:o})=>{let{open:r,onClose:e,setOpen:t}=a$8(),a=useRef(null),[i,n]=a$9(!1),[d,l]=useState(o.phone),h=d?.replace(/\D/g,""),y=!!h,f=useCallback(bo=>{l(bo);},[]),E=o.sale_analysis.sale_count,P=useMemo(()=>`${E} pedido${E===0||E>1?"s":""}`,[E]),D=useMemo(()=>{let w=[e$1[o.classification]?.label,P].filter(Boolean).join(" \u2022 ");return `${o.name}
58
- ${w}`},[o.classification,o.name,P]),Z=useCallback(()=>{a.current&&t(a.current);},[t]),U=useCallback(()=>{e(),n();},[e,n]);return jsxs(Fragment,{children:[jsx(Lo,{title:D,onClick:Z,sx:{cursor:"pointer"},children:jsxs(xi,{children:[jsxs(mo,{overflow:"hidden",children:[jsx(Y,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o.name}),jsxs(mo,{direction:"row",alignItems:"center",gap:.5,children:[jsx(Ct,{status:o.classification,variant:"caption",color:"text.disabled"}),jsxs(Y,{variant:"caption",color:"text.disabled",noWrap:!0,children:[o.classification&&jsx(Fragment,{children:"\u2022"})," ",P]})]})]}),jsx("span",{ref:a,children:jsx(a$1,{icon:"ARROW_DOWN_SIMPLE",color:"text.secondary"})})]})}),jsxs(a$a,{open:r,onClose:e,disabledArrow:!0,sx:{width:180,p:1},children:[jsx(le,{component:li,href:`https://wa.me/${h}`,target:"_blank",rel:"noopener noreferrer",variant:"text",startIcon:jsx(a$1,{icon:"WHATSAPP"}),disabled:!y,fullWidth:!0,children:"Enviar mensagem"}),jsx(le,{variant:"text",startIcon:jsx(a$1,{icon:"INFORMATIONS"}),onClick:U,fullWidth:!0,children:"Ver detalhes"})]}),jsx(a$b,{open:i,onClose:n,headerTitle:"Detalhes do cliente",headerProps:{direction:"row-reverse"},maxWidth:520,contentProps:{p:0},children:jsx(vi,{partner:o,onPhoneUpdated:f})})]})},_i=ld;var yd=({partner:o,index:r,days:e,isFetching:t})=>{let a=useMemo(()=>{let i=new Map;return o.events.forEach(n=>{let d=new Date(n.reference_date).toISOString().slice(0,10),l=i.get(d)??[];l.push(n),i.set(d,l);}),i},[o.events]);return jsxs(Or,{"data-testid":`partner-${r}`,children:[jsx(_i,{partner:o}),e.map((i,n)=>jsx(ni,{index:n,day:i,events:a.get(i.format("YYYY-MM-DD"))??[],isFetching:t},n))]})},Ri=memo(yd);var Ai=styled(gd)({display:"flex",flexDirection:"column",width:"100%",height:"calc(100vh - 300px)",boxShadow:"none",overflow:"hidden"}),Oi=styled(Td)({flex:1}),wi=styled(ud,{shouldForwardProp:o=>o!=="totalWidth"&&o!=="isResizing"})(({totalWidth:o,isResizing:r})=>({tableLayout:"fixed",borderCollapse:"separate",borderSpacing:0,height:"100%",...o>0&&{width:o},...r&&{userSelect:"none",cursor:"col-resize"}})),Li=styled(hd)(({theme:o})=>({"& .MuiTableRow-root":{backgroundColor:o.palette.background.paper},"& .MuiTableRow-root:last-child .MuiTableCell-root":{height:"100%"}}));var vd=({classification:o,checked:r,onToggle:e})=>{let{label:t,color:a}=e$1[o];return jsx(bd,{control:jsx(Sd,{name:`classification-${o}`,checked:r,onChange:e}),label:jsxs(mo,{direction:"row",alignItems:"center",gap:1,children:[jsx(mo,{width:6,height:16,bgcolor:a,borderRadius:1})," ",t]})})},Mi=vd;var Dd=Object.values(d),Ed=()=>{let{selectedClassifications:o,setSelectedClassifications:r}=x(),[e,t]=a$9(!!o.length),a=useCallback(i=>{r(o.includes(i)?o.filter(n=>n!==i):[...o,i]);},[r,o]);return jsxs(a$g,{expanded:e,onChange:t,children:[jsx(b$1,{children:jsx(Y,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Classifica\xE7\xF5es"})}),jsx(c$1,{children:jsx(mo,{mt:-1,children:Dd.map(i=>jsx(Mi,{classification:i,checked:o.includes(i),onToggle:()=>a(i)},i))})})]})},Bi=Ed;var ye=(o,r,e="40%")=>({position:"relative",backgroundColor:"transparent","&::before":{content:'""',position:"absolute",inset:3,backgroundColor:o,borderRadius:e,zIndex:-1},"&:hover, &:focus":{backgroundColor:"transparent","&::before":{backgroundColor:r}}}),Yi=styled(a$3)(()=>({"&.MuiDateCalendar-root":{margin:-24},"& .MuiPickersCalendarHeader-label":{textTransform:"capitalize"}})),Wi=styled(PickersDay,{shouldForwardProp:o=>o!=="isDaily"&&o!=="isInRange"&&o!=="isStart"&&o!=="isEnd"})(({theme:o,isInRange:r,isStart:e,isEnd:t,isDaily:a})=>({borderRadius:0,"&:not(.Mui-selected):not(.MuiPickersDay-today)":{"&:hover, &:focus":{backgroundColor:o.palette.action.hover,borderRadius:"40%"}},...!r&&{"&.MuiPickersDay-today:not(.Mui-selected)":{color:o.palette.common.white,border:"none !important",...ye(o.palette.common.black,alpha(o.palette.common.black,.8))}},"&.Mui-selected":{color:`${o.palette.primary.contrastText} !important`,...ye(o.palette.primary.main,o.palette.primary.dark)},...r&&a&&{color:o.palette.primary.contrastText,...ye(o.palette.primary.main,o.palette.primary.dark,6)},...r&&!a&&{backgroundColor:"transparent",borderTop:`1px solid ${o.palette.divider}`,borderBottom:`1px solid ${o.palette.divider}`,borderLeft:e?`1px solid ${o.palette.divider}`:"none",borderRight:t?`1px solid ${o.palette.divider}`:"none",...e&&{borderTopLeftRadius:8,borderBottomLeftRadius:8},...t&&{borderTopRightRadius:8,borderBottomRightRadius:8},"&.MuiPickersDay-today:not(.Mui-selected)":{borderTop:`1px solid ${o.palette.divider} !important`,borderBottom:`1px solid ${o.palette.divider} !important`,borderLeft:"none !important",borderRight:"none !important"}}}));var Od=["D","S","T","Q","Q","S","S"],It=(o,r)=>o.getFullYear()===r.getFullYear()&&o.getMonth()===r.getMonth()&&o.getDate()===r.getDate(),wd=()=>{let{baseDate:o,dateRange:r,viewMode:e,handleBaseDateChange:t}=x(),a=fe(r.start_date).toDate(),i=fe(r.end_date).toDate(),n=useCallback(y=>It(y,a)||It(y,i)||y>a&&y<i,[a,i]),d=useCallback(y=>It(y,a),[a]),l=useCallback(y=>It(y,i),[i]),h=useCallback(y=>{y&&t(fe(y));},[t]);return jsxs(mo,{p:2,pb:3,gap:2,children:[jsx(Y,{variant:"overline",color:"text.secondary",children:"Calend\xE1rio"}),jsx(mo,{alignItems:"center",children:jsx(Yi,{value:o.toDate(),onChange:h,showDaysOutsideCurrentMonth:!0,slots:{day:Wi},slotProps:{day:y=>{let f=y.day.toDate();return {isInRange:n(f),isStart:d(f),isEnd:l(f),isDaily:e==="DAY",disableMargin:!0}}},dayOfWeekFormatter:y=>Od[y.day()],fixedWeekNumber:6})})]})},Hi=wd;var Yd=()=>{let{selectedPartners:o,setSelectedPartners:r}=x(),[e,t]=a$9(!0),[a,i]=useState(""),{buildOptions:n,finishSearch:d,onSearch:l,onSelectValue:h,search:y,searching:f}=a$h(),{usePartnerOptions:E}=c().adapters,{items:P,isFetching:D,isLoading:Z}=E({search:y,skip:!e}),U=useMemo(()=>f||D?[]:n(P.map(({id:m,name:S})=>({value:m,label:S||""})),D),[n,D,P,f]),bo=o.length>0,w=useCallback(m=>{h(U,m);let S=typeof m=="string"?m:String(m?.value||""),At=U.find(Oo=>String(Oo.value)===S)?.label||(typeof m=="string"?m:String(m?.label||""));S&&!o.some(Oo=>Oo.id===S)&&r([...o,{id:S,name:At}]),i("");},[r,h,U,o]),j=useCallback(m=>{r(o.filter(S=>S.id!==m.id));},[r,o]);return jsxs(a$g,{expanded:e,onChange:t,children:[jsx(b$1,{children:jsx(Y,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Clientes"})}),jsx(c$1,{children:jsxs(mo,{gap:1,children:[jsx(a$i,{name:"partners",label:"Clientes",placeholder:"Digite para buscar um cliente...",size:"small",options:U,loading:Z,inputValue:a,onInputChange:(m,S)=>i(S),onSearch:l,onBlur:d,onChange:w,filterOptions:m=>m,noOptionsText:f||D?"Carregando...":void 0,InputLabelProps:{shrink:!0},fullWidth:!0}),jsx(a$5,{direction:"row",alignItems:"center",flexWrap:"wrap",overflow:"auto",maxHeight:148,p:1.5,sx:{bgcolor:"grey.50"},children:jsx(a$e,{isEmpty:!bo,empty:jsx(Y,{variant:"body2",color:"text.secondary",children:"Nenhum cliente selecionado"}),children:o.map((m,S)=>jsx(Ys,{variant:"outlined",label:m.name,color:"default",onDelete:()=>j(m),"data-testid":`filter-partner-${S}`},m.id))})})]})})]})},Ui=Yd;var $d=()=>{let{selectedProfiles:o,setSelectedProfiles:r}=x(),[e,t]=a$9(!!o.length),[a,i]=useState(""),{buildOptions:n,finishSearch:d,onSearch:l,onSelectValue:h,search:y,searching:f}=a$h(),{useProfileOptions:E}=c().adapters,{items:P,isFetching:D,isLoading:Z}=E({search:y,skip:!e}),U=useMemo(()=>f||D?[]:n(P.map(({id:m,name:S})=>({value:m,label:S||""})),D),[n,D,P,f]),bo=o.length>0,w=useCallback(m=>{h(U,m);let S=typeof m=="string"?m:String(m?.value||""),At=U.find(Oo=>String(Oo.value)===S)?.label||(typeof m=="string"?m:String(m?.label||""));S&&!o.some(Oo=>Oo.id===S)&&r([...o,{id:S,name:At}]),i("");},[r,h,U,o]),j=useCallback(m=>{r(o.filter(S=>S.id!==m.id));},[r,o]);return jsxs(a$g,{expanded:e,onChange:t,children:[jsx(b$1,{children:jsx(Y,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Segmentos"})}),jsx(c$1,{children:jsxs(mo,{gap:1,children:[jsx(a$i,{name:"profiles",label:"Segmentos",placeholder:"Digite para buscar um segmento...",size:"small",options:U,loading:Z,inputValue:a,onInputChange:(m,S)=>i(S),onSearch:l,onBlur:d,onChange:w,filterOptions:m=>m,noOptionsText:f||D?"Carregando...":void 0,InputLabelProps:{shrink:!0},fullWidth:!0}),jsx(a$5,{direction:"row",alignItems:"center",flexWrap:"wrap",overflow:"auto",maxHeight:148,p:1.5,sx:{bgcolor:"grey.50"},children:jsx(a$e,{isEmpty:!bo,empty:jsx(Y,{variant:"body2",color:"text.secondary",children:"Nenhum segmento selecionado"}),children:o.map((m,S)=>jsx(Ys,{variant:"outlined",label:m.name,color:"default",onDelete:()=>j(m),"data-testid":`filter-profile-${S}`},m.id))})})]})})]})},Ki=$d;var jd=({status:o,checked:r,onToggle:e})=>{let{label:t,color:a}=w[o];return jsx(bd,{control:jsx(Sd,{name:`status-${o}`,checked:r,onChange:e}),label:jsxs(mo,{direction:"row",alignItems:"center",gap:1,children:[jsx(mo,{width:6,height:16,bgcolor:a,borderRadius:1})," ",t]})})},Ji=jd;var Jd=Object.values(e),Zd=()=>{let{selectedEventTypes:o,setSelectedEventTypes:r}=x(),[e,t]=a$9(!!o.length),a=useCallback(i=>{r(o.includes(i)?o.filter(n=>n!==i):[...o,i]);},[r,o]);return jsxs(a$g,{expanded:e,onChange:t,children:[jsx(b$1,{children:jsx(Y,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Status de eventos"})}),jsx(c$1,{children:jsx(mo,{mt:-1,children:Jd.map(i=>jsx(Ji,{status:i,checked:o.includes(i),onToggle:()=>a(i)},i))})})]})},Zi=Zd;var rl=()=>jsxs(Fragment,{children:[jsx(Hi,{}),jsx(Ui,{}),jsx(Ki,{}),jsx(Zi,{}),jsx(Bi,{})]}),on=rl;var tn=styled(mo)(({theme:o})=>({flexDirection:"row",alignItems:"center",padding:o.spacing(2.5),gap:o.spacing(1)})),en=styled(mo)(({theme:o})=>({flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:o.spacing(2.5),gap:o.spacing(1)})),he=styled(Is)({flex:1,display:"flex",alignItems:"center",minWidth:0}),an=styled(he)({justifyContent:"flex-start"}),nn=styled(he)({justifyContent:"center"}),pn=styled(he)({justifyContent:"flex-end"});var sn={["DAY"]:"Dia",["WEEK"]:"Semana"},dn={["DAY"]:"CALENDAR_TODAY",["WEEK"]:"COLUMNS"};var Te=styled(Ln,{shouldForwardProp:o=>o!=="active"})(({theme:o,active:r})=>({justifyContent:"flex-start",color:r?o.palette.primary.main:o.palette.text.secondary,fontWeight:r?800:400,"&:hover":{background:o.palette.action.hover}}));var dl=()=>{let{open:o,onClose:r,onOpen:e}=a$8(),{viewMode:t,setViewMode:a}=x(),i=useCallback(n=>{a(n),r();},[r,a]);return jsxs(Fragment,{children:[jsx(Ln,{variant:"text",startIcon:jsx(a$1,{icon:dn[t]}),endIcon:jsx(a$1,{icon:"ARROW_DOWN_SIMPLE"}),color:"inherit",size:"small",onClick:e,children:sn[t]}),jsxs(a$a,{open:o,onClose:r,disabledArrow:!0,sx:{width:180,p:1},children:[jsx(Te,{variant:"text",startIcon:jsx(a$1,{icon:"CALENDAR_TODAY"}),onClick:()=>i("DAY"),active:t==="DAY",fullWidth:!0,children:"Dia"}),jsx(Te,{variant:"text",startIcon:jsx(a$1,{icon:"COLUMNS"}),onClick:()=>i("WEEK"),active:t==="WEEK",fullWidth:!0,children:"Semana"})]})]})},cn=dl;var fl=()=>{let{visibleDays:o,dateRange:r,handlePreviousWeek:e,handleNextWeek:t}=x(),a=useMemo(()=>{let i=fe(r.start_date),n=fe(r.end_date);if(o===1)return d$1(i.toDate(),"DD [de] MMM [de] YYYY");let d=i.month()===n.month(),l=i.year()===n.year();return d&&l?`${i.format("DD")} - ${d$1(n.toDate(),"DD [de] MMM [de] YYYY")}`:l?`${d$1(i.toDate(),"DD [de] MMM")} - ${d$1(n.toDate(),"DD [de] MMM")}`:`${d$1(i.toDate(),"DD MMM YYYY")} - ${d$1(n.toDate(),"DD MMM YYYY")}`},[r,o]);return jsxs(mo,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$c,{label:"Semana anterior",icon:"CHEVRON_LEFT",color:"inherit",size:"small",onClick:e}),jsx(Y,{variant:"subtitle1",color:"text.primary",noWrap:!0,children:a}),jsx(a$c,{label:"Pr\xF3xima semana",icon:"CHEVRON_RIGHT",color:"inherit",size:"small",onClick:t})]})},be=fl;var Tl=()=>{let o=b("down","sm"),{selectedPartners:r,selectedProfiles:e,selectedEventTypes:t}=x(),a=useMemo(()=>r.length+e.length+t.length,[r.length,e.length,t.length]),[i,n]=a$9();return jsxs(Fragment,{children:[o?jsxs(en,{children:[jsx(be,{}),jsx(yn,{badgeContent:a,invisible:a===0,color:"primary",children:jsx(a$c,{label:"Filtrar",icon:"FILTER_LIST",color:"inherit",size:"small",onClick:n})})]}):jsxs(tn,{children:[jsx(an,{children:jsx(cn,{})}),jsx(nn,{children:jsx(be,{})}),jsx(pn,{children:jsx(yn,{badgeContent:a,invisible:a===0,color:"primary",children:jsx(Ln,{variant:"text",startIcon:jsx(a$1,{icon:"FILTER_LIST"}),endIcon:jsx(a$1,{icon:"ARROW_DOWN_SIMPLE"}),color:"inherit",size:"small",onClick:n,children:"Filtrar"})})})]}),jsx(a$b,{open:i,onClose:n,headerTitle:"Filtros",headerProps:{direction:"row-reverse"},contentProps:{p:0},maxWidth:320,children:jsx(on,{})})]})},fn=Tl;var kl=({partners:o$1,summary:r,isFetching:e,isFetchingSummary:t,onRowsScrollEnd:a,isFetchingNextPage:i$1})=>{let{dateRange:n$1,scrollRef:d,viewMode:l$1}=x(),h=b("down","sm"),y=l$1==="DAY",f=useMemo(()=>s(n$1.start_date,n$1.end_date),[n$1.start_date,n$1.end_date]),E=useMemo(()=>[{key:l,minWidth:n,defaultWidth:m,maxWidthRatio:y?p:void 0},...f.map((w,j)=>({key:q(j),minWidth:o}))],[f,y]),{columnWidths:P,totalWidth:D,isResizing:Z,getColumnResizeProps:U}=a$6({columns:E,containerRef:d,enabled:!h}),bo=useCallback(()=>{let w=d.current;if(!w||i$1)return;let{scrollTop:j,scrollHeight:m,clientHeight:S}=w;m-j-S<=i&&a();},[d,a,i$1]);return jsxs(Ai,{variant:"outlined",children:[jsx(fn,{}),jsx(Oi,{ref:d,onScroll:bo,children:jsxs(wi,{stickyHeader:!0,totalWidth:D,isResizing:Z,children:[!!P.length&&jsx("colgroup",{children:P.map((w,j)=>jsx("col",{style:{width:w.width}},j))}),jsx(Je,{days:f,summary:r,isFetchingSummary:t,getColumnResizeProps:U}),jsxs(Li,{children:[!o$1.length&&jsxs(Or,{children:[jsx(Lo,{}),f.map((w,j)=>jsx(no,{isToday:w.isSame(fe(),"day")},j))]}),o$1.map((w,j)=>jsx(Ri,{index:j,partner:w,days:f,isFetching:e},w.external_id)),i$1&&jsx(un,{children:jsx(Be,{colSpan:f.length+1,align:"center",sx:{py:2,border:"none"},children:jsx(vl,{size:24})})})]})]})})]})},Dl=kl;
58
+ var Eo=styled(Ie,{shouldForwardProp:o=>o!=="cellAlign"})(({theme:o,cellAlign:r="top"})=>({position:"sticky",left:0,zIndex:1,verticalAlign:r,backgroundColor:o.palette.background.paper,[o.breakpoints.down("sm")]:{width:"50%",minWidth:"50%"}})),oo=styled(Ie,{shouldForwardProp:o=>o!=="isToday"})(({theme:o,isToday:r})=>({width:"auto",minWidth:"auto",overflow:"hidden",backgroundColor:`${r?o.palette.grey[200]:o.palette.common.white} !important`,verticalAlign:"top"})),Dr=styled(an)(({theme:o})=>({"& .MuiTableCell-root":{padding:o.spacing(1,2),borderBottom:`1px solid ${o.palette.divider} !important`,borderRight:`1px solid ${o.palette.divider} !important`,"&:last-child":{borderRight:"none !important"}}}));var Re=createContext(null),dn=({adapters:o,slots:r,children:t})=>{let e=a$4(),a=useMemo(()=>({adapters:o,slots:r,filters:e}),[o,r,e]);return jsx(Re.Provider,{value:a,children:t})},c=()=>{let o=useContext(Re);if(!o)throw new Error("useOrderProjectionContext must be used within an OrderProjectionProvider");return o},S=()=>c().filters;var Oe=styled(a,{shouldForwardProp:o=>o!=="isToday"})(({theme:o,isToday:r})=>({color:r?o.palette.primary.main:o.palette.text.secondary,backgroundColor:r?alpha(o.palette.primary.main,.15):alpha(o.palette.grey[500],.15),cursor:"pointer"}));var yn=({day:o,summary:r})=>{let t=useMemo(()=>ne().startOf("day"),[]),e=o.isAfter(t,"day"),a=useMemo(()=>{let i=o.format("YYYY-MM-DD"),n=r?.days.find(d=>d.date===i);return {shopping_cart_active:n?.shopping_cart_active??0,order_placed:n?.order_placed??0,order_unplanned:n?.order_unplanned??0,order_planned:n?.order_planned??0,shopping_cart_abandoned:n?.shopping_cart_abandoned??0}},[o,r]);return jsxs(io,{gap:1.5,children:[jsxs(io,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"CALENDAR_TODAY",color:"grey.400"}),jsx(R,{variant:"caption",fontWeight:"bold",children:"Pedidos"})]}),jsxs(io,{gap:.5,children:[!e&&jsxs(Fragment,{children:[jsxs(R,{variant:"caption",children:["Pedidos em andamento:"," ",jsx("strong",{children:a.shopping_cart_active})]}),jsxs(R,{variant:"caption",children:["Pedidos realizados: ",jsx("strong",{children:a.order_placed})]}),jsxs(R,{variant:"caption",children:["Pedidos fora do padr\xE3o: ",jsx("strong",{children:a.order_unplanned})]})]}),jsxs(R,{variant:"caption",children:["Pedidos previstos: ",jsx("strong",{children:a.order_planned})]}),!e&&jsxs(R,{variant:"caption",children:["Carrinhos abandonados:"," ",jsx("strong",{children:a.shopping_cart_abandoned})]})]})]})},Le=yn;var Tn=({day:o,summary:r,isFetchingSummary:t})=>{let e=o.isSame(ne(),"day"),{ordersPlacedCount:a,ordersExpectedCount:i}=useMemo(()=>{let n=o.format("YYYY-MM-DD"),d=r?.days.find(u=>u.date===n),l=d?.order_placed??0,g=d?.order_unplanned??0,m=d?.order_planned??0;return {ordersPlacedCount:l+g,ordersExpectedCount:l+g+m}},[o,r]);return jsx(a$e,{isLoading:t,loading:jsx(un,{width:50,height:24}),children:jsx(a$f,{title:jsx(Le,{day:o,summary:r}),arrow:!0,children:jsx("span",{children:jsxs(Oe,{variant:"filled",backgroundColor:"#919EAB29",color:"text.secondary",isToday:e,children:[a," de ",i]})})})})},Ne=Tn;var vn=["Dom.","Seg.","Ter.","Qua.","Qui.","Sex.","S\xE1b."],Cn=({day:o,index:r,summary:t,isFetchingSummary:e,resize:a,previousResize:i,previousLabel:n})=>{let d=o.isSame(ne(),"day");return jsxs(oo,{isToday:d,"data-testid":`day-cell-${r}`,children:[i&&jsx(a$d,{placement:"left",label:`Redimensionar coluna ${n}`,...i}),jsxs(io,{direction:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1,children:[jsxs(io,{children:[jsx(R,{variant:"subtitle2",color:d?"primary.main":"text.secondary",children:o.date()}),jsx(R,{variant:"body2",fontSize:13,color:d?"primary.main":"text.secondary",children:vn[o.day()]})]}),jsx(Ne,{day:o,summary:t,isFetchingSummary:e})]}),a&&jsx(a$d,{label:`Redimensionar coluna ${o.format("DD/MM")}`,...a})]})},Fe=Cn;var Et=styled(Pn,{shouldForwardProp:o=>o!=="active"})(({theme:o,active:r})=>({justifyContent:"flex-start",color:r?o.palette.primary.main:o.palette.text.secondary,fontWeight:r?800:400,"&:hover":{background:o.palette.action.hover}}));var kn=({summary:o})=>jsxs(io,{gap:1.5,children:[jsxs(io,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"USER_GROUP",color:"grey.400"}),jsx(R,{variant:"caption",fontWeight:"bold",children:"Clientes"})]}),jsx(io,{gap:.5,children:jsxs(R,{variant:"caption",children:["Total de clientes: ",jsx("strong",{children:o?.partner_count??0})]})})]}),We=kn;var _n=({summary:o,isFetchingSummary:r,resize:t})=>{let{open:e,onClose:a$1,onOpen:i}=a$8(),{ascending:n,setAscending:d}=S(),l=useCallback(g=>{d(g),a$1();},[a$1,d]);return jsxs(Fragment,{children:[jsxs(Eo,{cellAlign:"center",children:[jsxs(io,{direction:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1,children:[jsxs(io,{direction:"row",alignItems:"center",gap:1,children:[jsx(R,{variant:"caption",color:"text.primary",children:"Clientes"}),jsx(a$e,{isLoading:r,loading:jsx(a$7,{width:26,height:24}),children:jsx(a$f,{title:jsx(We,{summary:o}),arrow:!0,children:jsx("span",{children:jsx(a,{variant:"filled",backgroundColor:"#919EAB29",color:"text.secondary",sx:{cursor:"pointer"},children:o?.partner_count??0})})})})]}),jsx(a$c,{label:"Selecionar ordena\xE7\xE3o",icon:"SORTING_AZ_02",color:"text.secondary",size:"small",onClick:i})]}),t&&jsx(a$d,{label:"Redimensionar coluna Clientes",...t})]}),jsxs(a$a,{open:e,onClose:a$1,disabledArrow:!0,sx:{width:180,p:1},children:[jsx(Et,{variant:"text",onClick:()=>l(!0),active:n,fullWidth:!0,children:"De A \xE0 Z"}),jsx(Et,{variant:"text",onClick:()=>l(!1),active:!n,fullWidth:!0,children:"De Z \xE0 A"})]})]})},He=_n;var Ve=styled(An)(({theme:o})=>({"& .MuiTableCell-root":{padding:o.spacing(1,2),borderTop:`1px solid ${o.palette.divider} !important`,borderBottom:`1px solid ${o.palette.divider} !important`,borderRight:`1px solid ${o.palette.divider} !important`,background:o.palette.common.white,"&:last-child":{borderRight:"none !important"}},"& .MuiTableCell-root:first-of-type":{zIndex:3}}));var wn=({days:o,summary:r,isFetchingSummary:t,getColumnResizeProps:e})=>jsx(Ve,{children:jsxs(an,{children:[jsx(He,{summary:r,isFetchingSummary:t,resize:e(l)}),o.map((a,i)=>jsx(Fe,{index:i,day:a,summary:r,isFetchingSummary:t,resize:e(q(i)),previousResize:e(i===0?l:q(i-1)),previousLabel:i===0?"Clientes":o[i-1].format("DD/MM")},i))]})}),$e=wn;var Nn={["PAST"]:{icon:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630",width:24}),message:jsxs(Fragment,{children:["O cliente deveria ter feito pedido, conforme sua frequ\xEAncia de compra, mas nenhum pedido foi registrado. Esse comportamento pode indicar"," ",jsx("strong",{children:"queda de engajamento"})," ou"," ",jsx("strong",{children:"risco de inativa\xE7\xE3o"}),"."]})},["TODAY"]:{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00",width:24}),message:jsx(Fragment,{children:"Conforme a frequ\xEAncia de compra deste cliente, um pedido era esperado hoje, mas nenhum registro foi feito at\xE9 o momento."})},["FUTURE"]:{icon:jsx(a$1,{icon:"INFO",color:"common.black",width:24}),message:jsxs(Fragment,{children:["Baseado na rotina de compras identificada."," ",jsx("strong",{children:"Nenhuma a\xE7\xE3o \xE9 necess\xE1ria no momento"}),"."]})}},ze={["ORDER_UNPLANNED"]:()=>{let o=v("ORDER_UNPLANNED");return {icon:jsx(a$1,{icon:"INFO",color:"#00B8D9",width:24}),message:jsxs(Fragment,{children:["O cliente realizou um pedido em um dia diferente da sua rotina habitual. Isso pode indicar uma"," ",jsx("strong",{children:"mudan\xE7a de comportamento de compra"})," ou uma"," ",jsx("strong",{children:"demanda excepcional"}),"."]}),background:o.background,color:o.color}},["ORDER_PLANNED"]:({referenceDate:o})=>{let{period:r}=u(o||new Date),t=v("ORDER_PLANNED",r),{icon:e,message:a}=Nn[r];return {icon:e,message:a,background:t.background,color:t.color}},["SHOPPING_CART_ACTIVE"]:()=>{let o=v("SHOPPING_CART_ACTIVE");return {icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00",width:24}),message:jsx(Fragment,{children:"O cliente est\xE1 atualizando o carrinho neste momento."}),background:o.background,color:o.color}},["SHOPPING_CART_ABANDONED"]:({referenceDate:o})=>{let r=v("SHOPPING_CART_ABANDONED");return {icon:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630",width:24}),message:jsxs(Fragment,{children:["Carrinho est\xE1 abandonado h\xE1 ",jsx("strong",{children:g(o)}),"."]}),background:r.background,color:r.color}}};var Ue=styled(Mn,{shouldForwardProp:o=>o!=="customBackground"&&o!=="customColor"})(({theme:o,customBackground:r,customColor:t})=>({padding:o.spacing(1.5,2),borderRadius:0,borderBottom:`1px solid ${o.palette.divider}`,background:r,color:t}));var Fn=({origin:o,referenceDate:r})=>{let t=ze[o];if(!t)return null;let e=t({origin:o,referenceDate:r});return e?jsx(Ue,{icon:e.icon,customBackground:e.background,customColor:e.color,children:e.message}):null},je=Fn;var Vn=({message:o,onRetry:r,isFetching:t})=>jsxs(io,{alignItems:"center",justifyContent:"center",p:3,gap:.5,children:[jsx(R,{variant:"body2",color:"text.secondary",children:o}),jsx(Wn,{variant:"text",startIcon:jsx(a$1,{icon:"REFRESH_CHANGE"}),size:"small",onClick:r,loading:t,children:"Tentar novamente"})]}),ro=Vn;var zn=()=>jsxs(io,{gap:3,p:3,children:[jsxs(io,{gap:1,children:[jsx(R,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(a$7,{width:"20%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(a$7,{width:"30%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(a$7,{width:"20%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{gap:.5,children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Status do pedido"}),jsx(a$7,{width:"30%",height:22})]})]}),jsxs(io,{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1.5,children:[jsx(a$7,{width:"100%",height:30}),jsx(a$7,{width:"100%",height:30})]})]}),qe=zn;var jn=({eventId:o})=>{let{adapters:r,slots:t}=c(),{useEventDetails:e}=r,{renderEventStatus:a,renderEventActions:i}=t,{data:n,isLoading:d,isFetching:l,isError:g,refetch:m}=e(o,{skip:!o}),u=n?.detail?.sale_external_id||n?.detail?.external_id,A=d||l,O=n?.external_origin==="SALE";return jsx(a$e,{isLoading:A,loading:jsx(qe,{}),anError:g,error:jsx(ro,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido realizado!",onRetry:m,isFetching:l}),children:jsxs(io,{gap:3,p:3,children:[jsxs(io,{gap:1,children:[jsx(R,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:u?`#${u}`:"-"})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d$1(n?.detail?.created_at,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h(n?.detail?.total_value??n?.amount_value)})]}),n&&a?.(n)]}),jsxs(io,{gap:1.5,children:[n&&i?.(n),!O&&jsx(Mn,{severity:"warning",children:"Este pedido foi importado do ERP. Para visualizar detalhes ou realizar a\xE7\xF5es, acesse o sistema ERP."})]})]})})},Ke=jn;var qn=({period:o})=>{let r=o==="PAST",t=o==="FUTURE";return jsxs(io,{gap:3,p:3,children:[jsxs(io,{gap:1,children:[jsx(R,{variant:"overline",color:"text.secondary",children:t?"Comportamento de compra":"Resumo"}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Data prevista"}),jsx(a$7,{width:"20%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(a$7,{width:"30%",height:22})]}),r&&jsxs(Fragment,{children:[jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Per\xEDodo desde o \xFAltimo pedido"}),jsx(a$7,{width:"20%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),jsx(a$7,{width:"50%",height:22})]})]})]}),jsxs(io,{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1,children:[jsx(a$7,{width:"100%",height:30}),jsx(a$7,{width:"100%",height:30})]})]})},Qe=qn;var Kn=({eventId:o})=>{let{adapters:r,slots:t$1}=c(),{useEventDetails:e}=r,{renderEventActions:a,renderSaleLink:i}=t$1,{data:n,isLoading:d,isFetching:l,isError:g$1,refetch:m}=e(o,{skip:!o}),{period:u$1}=u(n?.reference_date??new Date),A=u$1==="PAST",O=u$1==="FUTURE",lo=n?.partner?.sale_analysis?.last_sale_sale_external_id||n?.partner?.sale_analysis?.last_sale_external_id,ko=n?.partner?.sale_analysis?.last_sale_negotiation_date;return jsx(a$e,{isLoading:d,loading:jsx(Qe,{period:u$1}),anError:g$1,error:jsx(ro,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido previsto!",onRetry:m,isFetching:l}),children:jsxs(io,{gap:3,p:3,children:[jsxs(io,{gap:1,children:[jsx(R,{variant:"overline",color:"text.secondary",children:O?"Comportamento de compra":"Resumo"}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Data prevista"}),jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d$1(n?.reference_date,"DD/MM/YYYY")})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:t(n?.partner?.recurrence)})]}),A&&jsxs(Fragment,{children:[jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Per\xEDodo desde o \xFAltimo pedido"}),jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:ko?g(ko):"-"})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),lo?jsxs(io,{direction:"row",alignItems:"center",gap:.5,children:[i?.(lo),jsxs(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:["em ",d$1(ko,"DD/MM/YYYY [\xE0s] HH:mm")]})]}):jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"})]})]})]}),n&&a?.(n)]})})},Je=Kn;var Jn=()=>jsxs(io,{gap:3,p:3,children:[jsxs(io,{gap:1,children:[jsx(R,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(a$7,{width:"30%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(a$7,{width:"25%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(a$7,{width:"20%",height:22})]})]}),jsx($o,{sx:{mx:-3}}),jsxs(io,{gap:1,children:[jsx(R,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(a$7,{width:"35%",height:22})]})]}),jsxs(io,{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1,children:[jsx(a$7,{width:"100%",height:30}),jsx(a$7,{width:"100%",height:30})]})]}),Ze=Jn;var Zn=({eventId:o})=>{let{adapters:r,slots:t$1}=c(),{useEventDetails:e}=r,{renderEventActions:a}=t$1,{data:i,isLoading:n,isFetching:d,isError:l,refetch:g}=e(o,{skip:!o}),m=i?.detail?.sale_external_id||i?.detail?.external_id;return jsx(a$e,{isLoading:n,loading:jsx(Ze,{}),anError:l,error:jsx(ro,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido!",onRetry:g,isFetching:d}),children:jsxs(io,{gap:3,p:3,children:[jsxs(io,{gap:1,children:[jsx(R,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:m?`#${m}`:"-"})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:d$1(i?.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:h(i?.amount_value)})]})]}),jsx($o,{sx:{mx:-3}}),jsxs(io,{gap:1,children:[jsx(R,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:t(i?.partner?.recurrence)})]})]}),i&&a?.(i)]})})},oa=Zn;var op=()=>jsxs(io,{gap:3,p:3,children:[jsxs(io,{gap:1,children:[jsx(R,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do carrinho"}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Tempo decorrido desde o abandono"}),jsx(a$7,{width:"30%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(a$7,{width:"40%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(a$7,{width:"40%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(a$7,{width:"20%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(a$7,{width:"80%",height:22})]})]}),jsx(a$7,{width:"100%",height:30})]}),ra=op;var ep=({eventId:o})=>{let{adapters:r,slots:t}=c(),{useEventDetails:e}=r,{formatAddress:a}=t,{data:i,isLoading:n,isFetching:d,isError:l,refetch:g}=e(o,{skip:!o});return jsx(a$e,{isLoading:n,loading:jsx(ra,{}),anError:l,error:jsx(ro,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do carrinho abandonado!",onRetry:g,isFetching:d}),children:jsxs(io,{gap:3,p:3,children:[jsxs(io,{gap:1,children:[jsx(R,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do carrinho"}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Tempo decorrido desde o abandono"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:d$1(i?.detail?.abandoned_at,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:i?.detail?.new_order?.name??"-"})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:i?.detail?.payment_method?.name??"-"})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:h(i?.detail?.total??i?.amount_value)})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:a(i?.detail?.address)})]})]}),jsx(Pn,{component:ti,href:`https://wa.me/${i?.partner?.phone}`,target:"_blank",rel:"noopener noreferrer",variant:"outlined",startIcon:jsx(a$1,{icon:"WHATSAPP",color:"success.main"}),color:"inherit",size:"small",disabled:!i?.partner?.phone,children:"Enviar mensagem"})]})})},ta=ep;var ap=()=>jsxs(io,{gap:3,p:3,children:[jsxs(io,{gap:1,children:[jsx(R,{variant:"overline",color:"text.secondary",children:"Resumo do carrinho"}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(a$7,{width:"40%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(a$7,{width:"30%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(a$7,{width:"20%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(a$7,{width:"80%",height:22})]})]}),jsx(a$7,{width:"100%",height:30})]}),ea=ap;var pp=({eventId:o})=>{let{adapters:r,slots:t}=c(),{useEventDetails:e}=r,{formatAddress:a}=t,{data:i,isLoading:n,isFetching:d,isError:l,refetch:g}=e(o,{skip:!o});return jsx(a$e,{isLoading:n,loading:jsx(ea,{}),anError:l,error:jsx(ro,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do carrinho!",onRetry:g,isFetching:d}),children:jsxs(io,{gap:3,p:3,children:[jsxs(io,{gap:1,children:[jsx(R,{variant:"overline",color:"text.secondary",children:"Resumo do carrinho"}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:i?.detail?.new_order?.name??"-"})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:i?.detail?.payment_method?.name??"-"})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:h(i?.detail?.total??i?.amount_value)})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:a(i?.detail?.address)})]})]}),jsx(Pn,{component:ti,href:`https://wa.me/${i?.partner?.phone}`,target:"_blank",rel:"noopener noreferrer",variant:"outlined",startIcon:jsx(a$1,{icon:"WHATSAPP",color:"success.main"}),color:"inherit",size:"small",disabled:!i?.partner?.phone,children:"Enviar mensagem"})]})})},aa=pp;var sp={["ORDER_PLACED"]:Ke,["ORDER_UNPLANNED"]:oa,["ORDER_PLANNED"]:Je,["SHOPPING_CART_ACTIVE"]:aa,["SHOPPING_CART_ABANDONED"]:ta},dp=({origin:o,eventId:r})=>{let t=sp[o];return t?jsx(t,{eventId:r}):null},Yt=dp;var cp=({events:o})=>{let{getEventCode:r}=c().slots;if(o.length<=1){let t=o[0];return t?jsx(Yt,{origin:t.type,eventId:t.id}):null}return jsx(Fragment,{children:o.map(t=>jsxs(a$g,{slotProps:{transition:{unmountOnExit:!0}},children:[jsx(b$1,{children:jsxs(R,{variant:"overline",color:"text.secondary",children:["Pedido:\u2002",jsxs(R,{component:"span",variant:"body2",fontWeight:600,color:"text.primary",children:["#",r(t)]})]})}),jsx(c$1,{sx:{p:0,mt:-2},children:jsx(Yt,{origin:t.type,eventId:t.id})})]},t.id))})},na=cp;var fp=()=>jsxs(io,{p:3,gap:1,children:[jsx(R,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do cliente"}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Nome"}),jsx(a$7,{width:"40%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(a$7,{width:"30%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$7,{width:"100%",height:22})]}),jsx(Pn,{variant:"text",startIcon:jsx(a$1,{icon:"PENCIL_EDIT"}),color:"inherit",size:"small",disabled:!0,children:"Editar"})]})]}),sa=fp;var up=({partner:o,isLoading:r,onPhoneUpdated:t})=>{let{renderPartnerLink:e,renderPhoneEditor:a}=c().slots;return jsx(a$e,{isLoading:r,loading:jsx(sa,{}),children:jsxs(io,{p:3,gap:1,children:[jsx(R,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do cliente"}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Nome"}),e?e(o):jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o?.name||"-"})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:o?.tax_id?i$1(o.tax_id):"-"})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Telefone"}),o?.phone?jsx(ti,{href:`https://wa.me/${o.phone}`,target:"_blank",rel:"noopener noreferrer",color:"#22C55E",children:jsxs(io,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"WHATSAPP",color:"#22C55E"}),jsx(R,{variant:"subtitle2",color:"success.main",children:h$1(o.phone)})]})}):jsx(R,{variant:"subtitle2",color:"text.primary",children:"-"})]}),a?.(o?.external_id??"",t??(()=>{}))]})]})})},la=up;var ca=styled(io,{shouldForwardProp:o=>o!=="customBackground"&&o!=="customColor"})(({theme:o,customBackground:r,customColor:t})=>({padding:o.spacing(.5,1),borderRadius:4,background:r,color:t}));var xp=({open:o,onClose:r,events:t})=>{let e=t[0],[a,i]=useState(),{useEventDetails:n}=c().adapters,{data:d,isLoading:l,refetch:g}=n(e?.id??"",{skip:!o||!e?.id}),{period:m}=u(e?.reference_date??new Date),u$1=v(e?.type,m),A=useCallback(O=>{i(O),g();},[g]);return jsxs(a$b,{open:o,onClose:r,headerTitle:jsxs(Fragment,{children:["Detalhes"," ",jsx(ca,{customBackground:u$1.background,customColor:u$1.color,children:jsx(R,{variant:"subtitle2",fontSize:13,noWrap:!0,children:u$1.label})})]}),headerProps:{direction:"row-reverse"},contentProps:{p:0},maxWidth:520,children:[jsx(io,{position:"sticky",top:0,zIndex:9,children:jsx(je,{origin:e?.type,referenceDate:e?.reference_date})}),jsx(la,{partner:d?.partner?{...d.partner,phone:a??d.partner.phone}:void 0,isLoading:l,onPhoneUpdated:A}),jsx($o,{}),jsx(na,{events:t})]})},it=xp;var Dp=({icon:o,title:r,description:t,details:e,footer:a})=>jsxs(io,{gap:1,children:[jsxs(io,{direction:"row",alignItems:"center",gap:.5,children:[o,jsx(R,{variant:"caption",fontWeight:"bold",children:r})]}),jsx(R,{variant:"caption",children:t}),e&&jsxs(Fragment,{children:[jsx($o,{sx:{borderStyle:"dashed"}}),jsx(io,{children:e})]}),a&&jsxs(Fragment,{children:[jsx($o,{sx:{borderStyle:"dashed"}}),a]})]}),U=Dp;var Ep=({event:o})=>{let{getEventCode:r}=c().slots;return jsx(U,{icon:jsx(a$1,{icon:"CHECK_CIRCLE",color:"#22C55E"}),title:"Pedido realizado",description:"Pedido realizado com sucesso!",details:jsxs(Fragment,{children:[jsxs(R,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(o)?`#${r(o)}`:"-"})]}),jsxs(R,{variant:"caption",children:["Data e hora:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(R,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})})},ua=Ep;var Ip=({event:o})=>{let{period:r}=u(o.reference_date);return r==="PAST"?jsx(U,{icon:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630"}),title:"Pedido n\xE3o realizado",description:"Cliente n\xE3o realizou o pedido previsto na data esperada.",details:jsxs(R,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY")})]})}):r==="TODAY"?jsx(U,{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),title:"Pedido previsto para hoje",description:"Nenhum pedido registrado at\xE9 o momento.",details:jsxs(R,{variant:"caption",children:["Valor previsto: ",jsx("strong",{children:h(o.amount_value)})]})}):jsx(U,{icon:jsx(a$1,{icon:"CALENDAR_TODAY",color:"#C4CDD5"}),title:"Pedido previsto",description:"Pr\xF3ximo pedido estimado conforme padr\xE3o de frequ\xEAncia.",details:jsxs(R,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY")})]})})},ha=Ip;var Rp=({event:o})=>{let{getEventCode:r}=c().slots;return jsx(U,{icon:jsx(a$1,{icon:"INFO",color:"#00B8D9"}),title:"Pedido fora do padr\xE3o",description:"Pedido feito em dia n\xE3o previsto pela frequ\xEAncia.",details:jsxs(Fragment,{children:[jsxs(R,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(o)?`#${r(o)}`:"-"})]}),jsxs(R,{variant:"caption",children:["Data e hora:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(R,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})})},Ta=Rp;var Op=({event:o})=>jsx(U,{icon:jsx(a$1,{icon:"CANCEL_CIRCLE_SOLID",color:"#FF5630"}),title:"Carrinho abandonado",description:jsxs(Fragment,{children:["Carrinho inativo h\xE1 ",jsx("strong",{children:g(o.reference_date)})," \u2014 valor estimado: ",jsx("strong",{children:h(o.amount_value)}),"."]}),details:jsxs(Fragment,{children:[jsxs(R,{variant:"caption",children:["ID:"," ",jsx("strong",{children:o.external_id?`#${o.external_id}`:"-"})]}),jsxs(R,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})}),va=Op;var Lp=({event:o})=>jsx(U,{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),title:"Pedido em andamento",description:"Cliente est\xE1 atualizando o carrinho neste momento.",details:jsxs(R,{variant:"caption",children:["Valor parcial: ",jsx("strong",{children:h(o.amount_value)})]})}),Ca=Lp;var jt={color:"common.white",width:16,height:16,sx:{flexShrink:0}},Pa={["ORDER_PLACED"]:{getIcon:()=>null,getTitle:()=>"Pedido realizado",getDescription:()=>"Pedido confirmado com sucesso!",getTooltip:o=>jsx(ua,{event:o})},["ORDER_UNPLANNED"]:{getIcon:()=>null,getTitle:()=>"Pedido fora do padr\xE3o",getDescription:()=>"Pedido feito fora do dia habitual.",getTooltip:o=>jsx(Ta,{event:o})},["ORDER_PLANNED"]:{getIcon:o=>{let{period:r}=u(o.reference_date);return r==="PAST"?jsx(a$1,{icon:"HEXAGON_WARNING",...jt}):r==="TODAY"?jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",...jt}):null},getTitle:o=>{let{period:r}=u(o.reference_date);return r==="PAST"?"Pedido n\xE3o realizado":r==="TODAY"?"Pedido previsto para hoje":"Pedido previsto"},getDescription:o=>{let{period:r}=u(o.reference_date);return r==="PAST"?"Cliente n\xE3o realizou o pedido previsto na data esperada.":r==="TODAY"?"Nenhum pedido registrado at\xE9 o momento.":"Pr\xF3ximo pedido estimado conforme padr\xE3o de frequ\xEAncia."},getTooltip:o=>jsx(ha,{event:o})},["SHOPPING_CART_ACTIVE"]:{getIcon:()=>null,getTitle:()=>"Pedido em andamento",getDescription:()=>"Cliente est\xE1 atualizando o carrinho neste momento.",getTooltip:o=>jsx(Ca,{event:o})},["SHOPPING_CART_ABANDONED"]:{getIcon:()=>jsx(a$1,{icon:"CANCEL_CIRCLE_SOLID",...jt}),getTitle:()=>"Carrinho abandonado",getDescription:o=>`Carrinho inativo h\xE1 ${g(o.reference_date)} \u2014 valor estimado: ${h(o.amount_value)}.`,getTooltip:o=>jsx(va,{event:o})}};var Da=styled(io,{shouldForwardProp:o=>o!=="eventType"&&o!=="period"})(({theme:o,eventType:r,period:t})=>{let e=v(r,t);return {position:"relative",padding:o.spacing(.5,1),borderRadius:4,background:e.background,color:e.color,cursor:"pointer","&:hover":{background:e.backgroundHover}}}),Ea=styled(io,{shouldForwardProp:o=>o!=="eventType"&&o!=="period"})(({theme:o,eventType:r,period:t})=>({position:"absolute",top:-5,right:-5,width:20,height:20,alignItems:"center",justifyContent:"center",borderRadius:"50%",background:v(r,t).iconBadgeColor,boxShadow:`0 0 0 2px ${o.palette.common.white}`}));var Mp=({event:o,index:r})=>{let[t,e]=a$9(),a=Pa[o.type];if(!a)return null;let{period:i}=u(o.reference_date),n=a.getIcon(o);return jsxs(Fragment,{children:[jsx(a$f,{title:a.getTooltip(o),arrow:!0,children:jsxs(Da,{"data-testid":`event-${r}`,eventType:o.type,period:i,onClick:e,children:[n&&jsx(Ea,{eventType:o.type,period:i,children:n}),jsx(R,{variant:"subtitle2",fontSize:13,noWrap:!0,children:a.getTitle(o)}),jsx(R,{variant:"caption",noWrap:!0,children:a.getDescription(o)})]})}),jsx(it,{open:t,onClose:e,events:[o]})]})},Ra=Mp;var Yp=({icon:o,title:r,description:t,children:e})=>jsxs(io,{gap:1,children:[jsxs(io,{direction:"row",alignItems:"center",gap:.5,children:[o,jsx(R,{variant:"caption",fontWeight:"bold",children:r})]}),jsx(R,{variant:"caption",children:t}),jsx($o,{sx:{borderStyle:"dashed"}}),jsx(io,{gap:1,children:e})]}),ao=Yp;var Gp=({events:o})=>{let{getEventCode:r}=c().slots,t=o.slice(0,k),e=o.length-k;return jsxs(ao,{icon:jsx(a$1,{icon:"CHECK_CIRCLE",color:"#22C55E"}),title:"Pedidos realizados",description:"Pedidos realizados com sucesso!",children:[t.map((a,i)=>jsxs(io,{children:[i>0&&jsx($o,{sx:{borderStyle:"dashed",mb:1}}),jsxs(R,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(a)?`#${r(a)}`:"-"})]}),jsxs(R,{variant:"caption",children:["Data/Hora:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(R,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(a.amount_value)})]})]},a.id)),e>0&&jsxs(Fragment,{children:[jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(R,{variant:"caption",children:["e mais ",e," pedido",e>1?"s":""]})]})]})},La=Gp;var $p={["PAST"]:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630"}),["TODAY"]:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),["FUTURE"]:jsx(a$1,{icon:"CALENDAR_TODAY",color:"#C4CDD5"})},zp={["PAST"]:"Pedidos n\xE3o realizados",["TODAY"]:"Pedidos previstos para hoje",["FUTURE"]:"Pedidos previstos"},Up={["PAST"]:"Clientes n\xE3o realizaram os pedidos previstos na data esperada.",["TODAY"]:"Nenhum pedido registrado at\xE9 o momento.",["FUTURE"]:"Pr\xF3ximos pedidos estimados conforme padr\xE3o de frequ\xEAncia."},jp=({events:o})=>{let{period:r}=u(o[0]?.reference_date),t=o.slice(0,k),e=o.length-k;return jsxs(ao,{icon:$p[r],title:zp[r],description:Up[r],children:[t.map((a,i)=>jsxs(io,{children:[i>0&&jsx($o,{sx:{borderStyle:"dashed",mb:1}}),jsxs(R,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY")})]})]},a.id)),e>0&&jsxs(Fragment,{children:[jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(R,{variant:"caption",children:["e mais ",e," pedido",e>1?"s":""]})]})]})},Ba=jp;var Kp=({events:o})=>{let{getEventCode:r}=c().slots,t=o.slice(0,k),e=o.length-k;return jsxs(ao,{icon:jsx(a$1,{icon:"INFO",color:"#00B8D9"}),title:"Pedidos fora do padr\xE3o",description:"Pedidos feitos em dias n\xE3o previstos pela frequ\xEAncia.",children:[t.map((a,i)=>jsxs(io,{children:[i>0&&jsx($o,{sx:{borderStyle:"dashed",mb:1}}),jsxs(R,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(a)?`#${r(a)}`:"-"})]}),jsxs(R,{variant:"caption",children:["Data/Hora:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(R,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(a.amount_value)})]})]},a.id)),e>0&&jsxs(Fragment,{children:[jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(R,{variant:"caption",children:["e mais ",e," pedido",e>1?"s":""]})]})]})},Ya=Kp;var Zp=({events:o})=>{let r=o.slice(0,k),t=o.length-k;return jsxs(ao,{icon:jsx(a$1,{icon:"CANCEL_CIRCLE_SOLID",color:"#FF5630"}),title:"Carrinhos abandonados",description:"Carrinhos inativos h\xE1 algum tempo.",children:[r.map((e,a)=>jsxs(io,{children:[a>0&&jsx($o,{sx:{borderStyle:"dashed",mb:1}}),jsxs(R,{variant:"caption",children:["ID:"," ",jsx("strong",{children:e.external_id?`#${e.external_id}`:"-"})]}),jsxs(R,{variant:"caption",children:["Inativo h\xE1: ",jsx("strong",{children:g(e.reference_date)})]}),jsxs(R,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(e.amount_value)})]})]},e.id)),t>0&&jsxs(Fragment,{children:[jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(R,{variant:"caption",children:["e mais ",t," carrinho",t>1?"s":""]})]})]})},Ga=Zp;var ts=({events:o})=>{let r=o.slice(0,k),t=o.length-k;return jsxs(ao,{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),title:"Pedidos em andamento",description:"Clientes est\xE3o atualizando seus carrinhos neste momento.",children:[r.map((e,a)=>jsxs(io,{children:[a>0&&jsx($o,{sx:{borderStyle:"dashed",mb:1}}),jsxs(R,{variant:"caption",children:["ID:"," ",jsx("strong",{children:e.external_id?`#${e.external_id}`:"-"})]}),jsxs(R,{variant:"caption",children:["Valor parcial: ",jsx("strong",{children:h(e.amount_value)})]})]},e.id)),t>0&&jsxs(Fragment,{children:[jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(R,{variant:"caption",children:["e mais ",t," carrinho",t>1?"s":""]})]})]})},Va=ts;var $a={["ORDER_PLACED"]:La,["ORDER_UNPLANNED"]:Ya,["ORDER_PLANNED"]:Ba,["SHOPPING_CART_ACTIVE"]:Va,["SHOPPING_CART_ABANDONED"]:Ga};var za=styled(io,{shouldForwardProp:o=>o!=="customBackground"&&o!=="customColor"&&o!=="customHoverBackground"})(({theme:o,customBackground:r,customColor:t,customHoverBackground:e})=>({padding:o.spacing(.5,1),borderRadius:4,background:r,color:t,cursor:"pointer","&:hover":{background:e}}));var ps=({group:o,index:r})=>{let[t,e]=a$9(),{config:a,count:i,events:n}=o,d=i>1?a.labelPlural:a.label,l=$a[n[0].type];return jsxs(Fragment,{children:[jsx(a$f,{title:jsx(l,{events:n}),arrow:!0,children:jsx(za,{"data-testid":`grouped-events-${r}`,customBackground:a.background,customColor:a.color,customHoverBackground:a.backgroundHover,onClick:e,children:jsxs(R,{variant:"subtitle2",fontSize:13,title:`${i} ${d}`,noWrap:!0,children:[jsx("strong",{children:i})," ",d]})})}),jsx(it,{open:t,onClose:e,events:n})]})},ja=ps;var ls=({events:o})=>{let r=useMemo(()=>{let t={};return o.forEach(e=>{let a=e.type==="ORDER_PLANNED"?v(e.type,u(e.reference_date).period):v(e.type);t[a.label]||(t[a.label]={count:0,config:a,events:[]}),t[a.label].count+=1,t[a.label].events.push(e);}),Object.values(t)},[o]);return jsx(Fragment,{children:r.map((t,e)=>jsx(ja,{index:e,group:t},e))})},Xa=ls;var Ka=styled(io)({gap:4});var gs=({events:o,day:r,index:t})=>{let e=r.isSame(ne(),"day");if(o.length===0)return jsx(oo,{isToday:e,"data-testid":`day-column-${t}`});let a=o.length>j;return jsx(oo,{isToday:e,"data-testid":`day-column-${t}`,children:jsx(Ka,{children:a?jsx(Xa,{events:o}):o.map((i,n)=>jsx(Ra,{index:n,event:i},n))})})},Qa=gs;var hs=({day:o,index:r,events:t,isFetching:e})=>{let a=o.isSame(ne(),"day");return e?jsx(oo,{isToday:a,"data-testid":`day-column-${r}`,children:jsx(a$7,{width:"100%",height:"100%",sx:{maxHeight:46.42}})}):jsx(Qa,{events:t,day:o,index:r})},Ja=hs;var Za=styled(Ts)(()=>({width:6,height:6,borderRadius:"50%",flexShrink:0}));var Cs=({status:o,variant:r="body2",color:t="text.primary"})=>{let e=e$1[o];if(!e)return null;let{label:a,color:i}=e;return jsxs(io,{direction:"row",alignItems:"center",gap:1,children:[jsx(Za,{bgcolor:i}),jsx(R,{variant:r,color:t,noWrap:!0,children:a})]})},ft=Cs;var ks=()=>jsxs(io,{mt:-1,px:1,gap:1,children:[jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Nome"}),jsx(a$7,{width:"40%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(a$7,{width:"30%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"E-mail"}),jsx(a$7,{width:"35%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Status do cliente"}),jsx(a$7,{width:"20%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{gap:.5,children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Segmento"}),jsx(a$7,{width:"35%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$7,{width:"100%",height:22})]}),jsx(Pn,{variant:"text",startIcon:jsx(a$1,{icon:"PENCIL_EDIT"}),color:"inherit",size:"small",disabled:!0,children:"Editar"})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$7,{width:"20%",height:22})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Vendedor preferencial"}),jsx(a$7,{width:"40%",height:22})]})]}),ri=ks;var Is=({partner:o,onPhoneUpdated:r})=>{let[t,e]=a$9(!0),{adapters:a,slots:i}=c(),{renderPartnerLink:n,renderPhoneEditor:d}=i,{data:l,isLoading:g,refetch:m}=a.usePartnerDetails(o.external_id,{skip:!o.external_id||!t}),u=l?.mobile??l?.phone,A=useMemo(()=>l?.fiscal_registration_number?i$1(l?.fiscal_registration_number):"-",[l?.fiscal_registration_number]),O=useCallback(lo=>{m(),r?.(lo);},[m,r]);return jsxs(a$g,{expanded:t,onChange:e,defaultExpanded:!0,children:[jsx(b$1,{children:jsx(R,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es"})}),jsx(c$1,{children:jsx(a$e,{isLoading:g,loading:jsx(ri,{}),children:jsxs(io,{mt:-1,px:1,gap:1,children:[jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Nome"}),n?n(o):jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o?.name||"-"})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:A})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"E-mail"}),jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:l?.email||"-"})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Status do cliente"}),o.classification?jsx(ft,{status:o.classification,variant:"subtitle2",color:"text.primary"}):jsx(R,{variant:"subtitle2",color:"text.primary",children:"-"})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{gap:.5,children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Segmento"}),l?.profile?.name?jsx(_s,{variant:"outlined",label:l.profile.name,size:"small",color:"default",sx:{width:"fit-content"}}):jsx(R,{variant:"subtitle2",color:"text.primary",children:"-"})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Telefone"}),u?jsxs(io,{direction:"row",alignItems:"center",gap:.5,children:[jsx(a$1,{icon:"WHATSAPP",color:"success.main",sx:{flexShrink:0}}),jsx(ti,{component:ti,href:`https://wa.me/${u}`,target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",color:"success.main",noWrap:!0,children:h$1(u)})]}):jsx(R,{variant:"subtitle2",color:"text.primary",children:"-"})]}),d?.(o.external_id,O)]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Vendedor preferencial"}),jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:l?.main_seller?.name||"-"})]})]})})})]})},ei=Is;var Os=({order:o})=>{let{renderSaleLink:r}=c().slots;return jsxs(a$5,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,p:1.5,sx:{borderRadius:1},children:[jsxs(io,{overflow:"hidden",children:[o?.id?r?.(o.id):jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"}),jsx(R,{variant:"caption",color:"text.secondary",children:d$1(o?.negotiation_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(R,{variant:"subtitle2",color:"text.primary",children:h(o?.total_value)})]})},ii=memo(Os,a$2);var Ls=()=>jsxs(io,{gap:1.5,children:[jsx(a$7,{width:"100%",height:66}),jsx(a$7,{width:"100%",height:66}),jsx(a$7,{width:"100%",height:66}),jsx(a$7,{width:"100%",height:66}),jsx(a$7,{width:"100%",height:66})]}),ni=Ls;var Ms=({partner:o})=>{let[r,t]=a$9(!1),{usePartnerOrders:e}=c().adapters,{data:{items:a=[]}={},isLoading:i}=e(o?.external_id,{skip:!o?.external_id||!r});return jsxs(a$g,{expanded:r,onChange:t,children:[jsx(b$1,{children:jsx(R,{variant:"overline",color:"text.secondary",children:"\xDAltimos pedidos"})}),jsx(c$1,{children:jsx(io,{mt:-1,px:1,children:jsx(a$e,{isLoading:i,loading:jsx(ni,{}),isEmpty:a?.length===0,empty:jsx(io,{alignItems:"center",justifyContent:"center",gap:1.5,p:2,children:jsx(R,{variant:"body2",color:"text.secondary",children:"Este cliente ainda n\xE3o possui pedidos realizados."})}),children:jsx(io,{gap:1.5,children:a?.map((n,d)=>jsx(ii,{order:n,"data-testid":`last-order-${d}`},n.id))})})})})]})},si=Ms;var Ws=({partner:o})=>{let{renderSaleLink:r}=c().slots,[t$1,e]=a$9(!1),a=useMemo(()=>t(o?.recurrence),[o?.recurrence]),i=o?.sale_analysis?.last_sale_sale_external_id||o?.sale_analysis?.last_sale_external_id,n=o?.sale_analysis?.last_sale_negotiation_date;return jsxs(a$g,{expanded:t$1,onChange:e,children:[jsx(b$1,{children:jsx(R,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"})}),jsx(c$1,{children:jsxs(io,{mt:-1,px:1,gap:1,children:[jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(R,{variant:"subtitle2",color:"text.primary",children:a})]}),jsx($o,{sx:{borderStyle:"dashed"}}),jsxs(io,{children:[jsx(R,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),i?jsxs(io,{direction:"row",alignItems:"center",gap:.5,children:[r?.(i),jsxs(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:["em ",d$1(n,"DD/MM/YYYY [\xE0s] HH:mm")]})]}):jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"})]})]})})]})},di=Ws;var oe=styled($o)(({theme:o})=>({height:30,alignSelf:"center",borderStyle:"dashed",[o.breakpoints.down("sm")]:{display:"none"}}));var Vs=()=>jsxs(io,{direction:{xs:"column",sm:"row"},justifyContent:{xs:"flex-start",sm:"center"},gap:3,children:[jsxs(io,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(R,{variant:"body2",children:"Qtd. de pedidos"}),jsx(a$7,{width:30,height:22})]}),jsx(oe,{orientation:"vertical",flexItem:!0}),jsxs(io,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(R,{variant:"body2",children:"Valor total"}),jsx(a$7,{width:92,height:22})]}),jsx(oe,{orientation:"vertical",flexItem:!0}),jsxs(io,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(R,{variant:"body2",children:"Ticket m\xE9dio"}),jsx(a$7,{width:71,height:22})]})]}),li=Vs;var $s=({partner:o})=>{let[r,t]=a$9(!1),{usePartnerSaleSummary:e}=c().adapters,{data:a,isLoading:i}=e(o.external_id,{skip:!o.external_id||!r});return jsxs(a$g,{expanded:r,onChange:t,children:[jsx(b$1,{children:jsx(R,{variant:"overline",color:"text.secondary",children:"Indicadores de vendas"})}),jsx(c$1,{children:jsx(io,{mt:-1,px:1,children:jsx(a$e,{isLoading:i,loading:jsx(li,{}),children:jsxs(io,{direction:{xs:"column",sm:"row"},justifyContent:{xs:"flex-start",sm:"center"},gap:3,children:[jsxs(io,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(R,{variant:"body2",children:"Qtd. de pedidos"}),jsx(R,{variant:"subtitle2",children:a?.order_quantity||0})]}),jsx($o,{orientation:"vertical",flexItem:!0}),jsxs(io,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(R,{variant:"body2",children:"Valor total"}),jsx(R,{variant:"subtitle2",children:h(a?.total_value)})]}),jsx($o,{orientation:"vertical",flexItem:!0}),jsxs(io,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(R,{variant:"body2",children:"Ticket m\xE9dio"}),jsx(R,{variant:"subtitle2",children:h(a?.average_ticket)})]})]})})})})]})},mi=$s;var zs=({partner:o,onPhoneUpdated:r})=>jsxs(Fragment,{children:[jsx(ei,{partner:o,onPhoneUpdated:r}),jsx(mi,{partner:o}),jsx(di,{partner:o}),jsx(si,{partner:o})]}),yi=zs;var gi=styled(io)(({theme:o})=>({minHeight:47.42,flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:o.spacing(1.5)})),te=styled(Pn)(({theme:o})=>({justifyContent:"flex-start",color:o.palette.text.primary,fontWeight:400,"&:hover":{background:o.palette.action.hover}}));var Zs=({partner:o})=>{let{open:r,onClose:t,setOpen:e}=a$8(),a=useRef(null),[i,n]=a$9(!1),[d,l]=useState(o.phone),g=d?.replace(/\D/g,""),m=!!g,u=useCallback(Xr=>{l(Xr);},[]),A=o.sale_analysis.sale_count,O=useMemo(()=>`${A} pedido${A===0||A>1?"s":""}`,[A]),lo=useMemo(()=>{let z=[e$1[o.classification]?.label,O].filter(Boolean).join(" \u2022 ");return `${o.name}
59
+ ${z}`},[o.classification,o.name,O]),ko=useCallback(()=>{a.current&&e(a.current);},[e]),Pt=useCallback(()=>{t(),n();},[t,n]);return jsxs(Fragment,{children:[jsx(Eo,{title:lo,onClick:ko,sx:{cursor:"pointer"},children:jsxs(gi,{children:[jsxs(io,{overflow:"hidden",children:[jsx(R,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o.name}),jsxs(io,{direction:"row",alignItems:"center",gap:.5,children:[jsx(ft,{status:o.classification,variant:"caption",color:"text.disabled"}),jsxs(R,{variant:"caption",color:"text.disabled",noWrap:!0,children:[o.classification&&jsx(Fragment,{children:"\u2022"})," ",O]})]})]}),jsx("span",{ref:a,children:jsx(a$1,{icon:"ARROW_DOWN_SIMPLE",color:"text.secondary"})})]})}),jsxs(a$a,{open:r,onClose:t,disabledArrow:!0,sx:{width:180,p:1},children:[jsx(te,{component:ti,href:`https://wa.me/${g}`,target:"_blank",rel:"noopener noreferrer",variant:"text",startIcon:jsx(a$1,{icon:"WHATSAPP"}),disabled:!m,fullWidth:!0,children:"Enviar mensagem"}),jsx(te,{variant:"text",startIcon:jsx(a$1,{icon:"INFORMATIONS"}),onClick:Pt,fullWidth:!0,children:"Ver detalhes"})]}),jsx(a$b,{open:i,onClose:n,headerTitle:"Detalhes do cliente",headerProps:{direction:"row-reverse"},maxWidth:520,contentProps:{p:0},children:jsx(yi,{partner:o,onPhoneUpdated:u})})]})},bi=Zs;var td=({partner:o,index:r,days:t,isFetching:e})=>{let a=useMemo(()=>{let i=new Map;return o.events.forEach(n=>{let d=new Date(n.reference_date).toISOString().slice(0,10),l=i.get(d)??[];l.push(n),i.set(d,l);}),i},[o.events]);return jsxs(Dr,{"data-testid":`partner-${r}`,children:[jsx(bi,{partner:o}),t.map((i,n)=>jsx(Ja,{index:n,day:i,events:a.get(i.format("YYYY-MM-DD"))??[],isFetching:e},n))]})},Ci=memo(td);var Pi=styled(ad)({display:"flex",flexDirection:"column",width:"100%",height:"calc(100vh - 300px)",boxShadow:"none",overflow:"hidden"}),xi=styled(pd)({flex:1}),ki=styled(id,{shouldForwardProp:o=>o!=="totalWidth"&&o!=="isResizing"})(({totalWidth:o,isResizing:r})=>({tableLayout:"fixed",borderCollapse:"separate",borderSpacing:0,height:"100%",...o>0&&{width:o},...r&&{userSelect:"none",cursor:"col-resize"}})),Di=styled(nd)(({theme:o})=>({"& .MuiTableRow-root":{backgroundColor:o.palette.background.paper},"& .MuiTableRow-root:last-child .MuiTableCell-root":{height:"100%"}}));var ld=({classification:o,checked:r,onToggle:t})=>{let{label:e,color:a}=e$1[o];return jsx(dd,{control:jsx(sd,{name:`classification-${o}`,checked:r,onChange:t}),label:jsxs(io,{direction:"row",alignItems:"center",gap:1,children:[jsx(io,{width:6,height:16,bgcolor:a,borderRadius:1})," ",e]})})},_i=ld;var gd=Object.values(d),ud=()=>{let{selectedClassifications:o,setSelectedClassifications:r}=S(),[t,e]=a$9(!!o.length),a=useCallback(i=>{r(o.includes(i)?o.filter(n=>n!==i):[...o,i]);},[r,o]);return jsxs(a$g,{expanded:t,onChange:e,children:[jsx(b$1,{children:jsx(R,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Classifica\xE7\xF5es"})}),jsx(c$1,{children:jsx(io,{mt:-1,children:gd.map(i=>jsx(_i,{classification:i,checked:o.includes(i),onToggle:()=>a(i)},i))})})]})},Ii=ud;var ie=(o,r,t="40%")=>({position:"relative",backgroundColor:"transparent","&::before":{content:'""',position:"absolute",inset:3,backgroundColor:o,borderRadius:t,zIndex:-1},"&:hover, &:focus":{backgroundColor:"transparent","&::before":{backgroundColor:r}}}),Ai=styled(a$3)(()=>({"&.MuiDateCalendar-root":{margin:-24},"& .MuiPickersCalendarHeader-label":{textTransform:"capitalize"}})),Oi=styled(PickersDay,{shouldForwardProp:o=>o!=="isDaily"&&o!=="isInRange"&&o!=="isStart"&&o!=="isEnd"})(({theme:o,isInRange:r,isStart:t,isEnd:e,isDaily:a})=>({borderRadius:0,"&:not(.Mui-selected):not(.MuiPickersDay-today)":{"&:hover, &:focus":{backgroundColor:o.palette.action.hover,borderRadius:"40%"}},...!r&&{"&.MuiPickersDay-today:not(.Mui-selected)":{color:o.palette.common.white,border:"none !important",...ie(o.palette.common.black,alpha(o.palette.common.black,.8))}},"&.Mui-selected":{color:`${o.palette.primary.contrastText} !important`,...ie(o.palette.primary.main,o.palette.primary.dark)},...r&&a&&{color:o.palette.primary.contrastText,...ie(o.palette.primary.main,o.palette.primary.dark,6)},...r&&!a&&{backgroundColor:"transparent",borderTop:`1px solid ${o.palette.divider}`,borderBottom:`1px solid ${o.palette.divider}`,borderLeft:t?`1px solid ${o.palette.divider}`:"none",borderRight:e?`1px solid ${o.palette.divider}`:"none",...t&&{borderTopLeftRadius:8,borderBottomLeftRadius:8},...e&&{borderTopRightRadius:8,borderBottomRightRadius:8},"&.MuiPickersDay-today:not(.Mui-selected)":{borderTop:`1px solid ${o.palette.divider} !important`,borderBottom:`1px solid ${o.palette.divider} !important`,borderLeft:"none !important",borderRight:"none !important"}}}));var vd=["D","S","T","Q","Q","S","S"],vt=(o,r)=>o.getFullYear()===r.getFullYear()&&o.getMonth()===r.getMonth()&&o.getDate()===r.getDate(),Cd=()=>{let{baseDate:o,dateRange:r,viewMode:t,handleBaseDateChange:e}=S(),a=ne(r.start_date).toDate(),i=ne(r.end_date).toDate(),n=useCallback(m=>vt(m,a)||vt(m,i)||m>a&&m<i,[a,i]),d=useCallback(m=>vt(m,a),[a]),l=useCallback(m=>vt(m,i),[i]),g=useCallback(m=>{m&&e(ne(m));},[e]);return jsxs(io,{p:2,pb:3,gap:2,children:[jsx(R,{variant:"overline",color:"text.secondary",children:"Calend\xE1rio"}),jsx(io,{alignItems:"center",children:jsx(Ai,{value:o.toDate(),onChange:g,showDaysOutsideCurrentMonth:!0,slots:{day:Oi},slotProps:{day:m=>{let u=m.day.toDate();return {isInRange:n(u),isStart:d(u),isEnd:l(u),isDaily:t==="DAY",disableMargin:!0}}},dayOfWeekFormatter:m=>vd[m.day()],fixedWeekNumber:6})})]})},Li=Cd;var xd=()=>{let{usePartnerOptions:o}=c().adapters,{selectedPartners:r,setSelectedPartners:t}=S();return jsx(a$h,{name:"partners",title:"Clientes",placeholder:"Digite para buscar um cliente...",emptyText:"Nenhum cliente selecionado",testIdPrefix:"filter-partner",defaultExpanded:!0,selected:r,onChange:t,useOptions:o})},Ni=xd;var Dd=()=>{let{useProfileOptions:o}=c().adapters,{selectedProfiles:r,setSelectedProfiles:t}=S();return jsx(a$h,{name:"profiles",title:"Segmentos",placeholder:"Digite para buscar um segmento...",emptyText:"Nenhum segmento selecionado",testIdPrefix:"filter-profile",defaultExpanded:!!r.length,selected:r,onChange:t,useOptions:o})},Mi=Dd;var _d=({useOptions:o})=>{let{selectedSellers:r,setSelectedSellers:t}=S();return jsx(a$h,{name:"sellers",title:"Vendedores",placeholder:"Digite para buscar um vendedor...",emptyText:"Nenhum vendedor selecionado",testIdPrefix:"filter-seller",defaultExpanded:!!r.length,selected:r,onChange:t,useOptions:o})},Bi=_d;var Od=({status:o,checked:r,onToggle:t})=>{let{label:e,color:a}=w[o];return jsx(dd,{control:jsx(sd,{name:`status-${o}`,checked:r,onChange:t}),label:jsxs(io,{direction:"row",alignItems:"center",gap:1,children:[jsx(io,{width:6,height:16,bgcolor:a,borderRadius:1})," ",e]})})},Yi=Od;var Bd=Object.values(e),Fd=()=>{let{selectedEventTypes:o,setSelectedEventTypes:r}=S(),[t,e]=a$9(!!o.length),a=useCallback(i=>{r(o.includes(i)?o.filter(n=>n!==i):[...o,i]);},[r,o]);return jsxs(a$g,{expanded:t,onChange:e,children:[jsx(b$1,{children:jsx(R,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Status de eventos"})}),jsx(c$1,{children:jsx(io,{mt:-1,children:Bd.map(i=>jsx(Yi,{status:i,checked:o.includes(i),onToggle:()=>a(i)},i))})})]})},Wi=Fd;var Wd=()=>{let{useSellerOptions:o}=c().adapters;return jsxs(Fragment,{children:[jsx(Li,{}),jsx(Ni,{}),!!o&&jsx(Bi,{useOptions:o}),jsx(Mi,{}),jsx(Wi,{}),jsx(Ii,{})]})},Gi=Wd;var Vi=styled(io)(({theme:o})=>({flexDirection:"row",alignItems:"center",padding:o.spacing(2.5),gap:o.spacing(1)})),$i=styled(io)(({theme:o})=>({flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:o.spacing(2.5),gap:o.spacing(1)})),de=styled(Ts)({flex:1,display:"flex",alignItems:"center",minWidth:0}),zi=styled(de)({justifyContent:"flex-start"}),Ui=styled(de)({justifyContent:"center"}),ji=styled(de)({justifyContent:"flex-end"});var qi={["DAY"]:"Dia",["WEEK"]:"Semana"},Xi={["DAY"]:"CALENDAR_TODAY",["WEEK"]:"COLUMNS"};var le=styled(Pn,{shouldForwardProp:o=>o!=="active"})(({theme:o,active:r})=>({justifyContent:"flex-start",color:r?o.palette.primary.main:o.palette.text.secondary,fontWeight:r?800:400,"&:hover":{background:o.palette.action.hover}}));var qd=()=>{let{open:o,onClose:r,onOpen:t}=a$8(),{viewMode:e,setViewMode:a}=S(),i=useCallback(n=>{a(n),r();},[r,a]);return jsxs(Fragment,{children:[jsx(Pn,{variant:"text",startIcon:jsx(a$1,{icon:Xi[e]}),endIcon:jsx(a$1,{icon:"ARROW_DOWN_SIMPLE"}),color:"inherit",size:"small",onClick:t,children:qi[e]}),jsxs(a$a,{open:o,onClose:r,disabledArrow:!0,sx:{width:180,p:1},children:[jsx(le,{variant:"text",startIcon:jsx(a$1,{icon:"CALENDAR_TODAY"}),onClick:()=>i("DAY"),active:e==="DAY",fullWidth:!0,children:"Dia"}),jsx(le,{variant:"text",startIcon:jsx(a$1,{icon:"COLUMNS"}),onClick:()=>i("WEEK"),active:e==="WEEK",fullWidth:!0,children:"Semana"})]})]})},Qi=qd;var Zd=()=>{let{visibleDays:o,dateRange:r,handlePreviousWeek:t,handleNextWeek:e}=S(),a=useMemo(()=>{let i=ne(r.start_date),n=ne(r.end_date);if(o===1)return d$1(i.toDate(),"DD [de] MMM [de] YYYY");let d=i.month()===n.month(),l=i.year()===n.year();return d&&l?`${i.format("DD")} - ${d$1(n.toDate(),"DD [de] MMM [de] YYYY")}`:l?`${d$1(i.toDate(),"DD [de] MMM")} - ${d$1(n.toDate(),"DD [de] MMM")}`:`${d$1(i.toDate(),"DD MMM YYYY")} - ${d$1(n.toDate(),"DD MMM YYYY")}`},[r,o]);return jsxs(io,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$c,{label:"Semana anterior",icon:"CHEVRON_LEFT",color:"inherit",size:"small",onClick:t}),jsx(R,{variant:"subtitle1",color:"text.primary",noWrap:!0,children:a}),jsx(a$c,{label:"Pr\xF3xima semana",icon:"CHEVRON_RIGHT",color:"inherit",size:"small",onClick:e})]})},me=Zd;var el=()=>{let o=b("down","sm"),{adapters:r}=c(),{selectedPartners:t,selectedSellers:e,selectedProfiles:a,selectedEventTypes:i,selectedClassifications:n}=S(),d=useMemo(()=>{let m=r.useSellerOptions?e.length:0;return t.length+m+a.length+i.length+n.length},[r.useSellerOptions,t.length,e.length,a.length,i.length,n.length]),[l,g]=a$9();return jsxs(Fragment,{children:[o?jsxs($i,{children:[jsx(me,{}),jsx(Zi,{badgeContent:d,invisible:d===0,color:"primary",children:jsx(a$c,{label:"Filtrar",icon:"FILTER_LIST",color:"inherit",size:"small",onClick:g})})]}):jsxs(Vi,{children:[jsx(zi,{children:jsx(Qi,{})}),jsx(Ui,{children:jsx(me,{})}),jsx(ji,{children:jsx(Zi,{badgeContent:d,invisible:d===0,color:"primary",children:jsx(Pn,{variant:"text",startIcon:jsx(a$1,{icon:"FILTER_LIST"}),endIcon:jsx(a$1,{icon:"ARROW_DOWN_SIMPLE"}),color:"inherit",size:"small",onClick:g,children:"Filtrar"})})})]}),jsx(a$b,{open:l,onClose:g,headerTitle:"Filtros",headerProps:{direction:"row-reverse"},contentProps:{p:0},maxWidth:320,children:jsx(Gi,{})})]})},on=el;var ll=({partners:o$1,summary:r,isFetching:t,isFetchingSummary:e,onRowsScrollEnd:a,isFetchingNextPage:i$1})=>{let{dateRange:n$1,scrollRef:d,viewMode:l$1}=S(),g=b("down","sm"),m$1=l$1==="DAY",u=useMemo(()=>s(n$1.start_date,n$1.end_date),[n$1.start_date,n$1.end_date]),A=useMemo(()=>[{key:l,minWidth:n,defaultWidth:m,maxWidthRatio:m$1?p:void 0},...u.map((z,co)=>({key:q(co),minWidth:o}))],[u,m$1]),{columnWidths:O,totalWidth:lo,isResizing:ko,getColumnResizeProps:Pt}=a$6({columns:A,containerRef:d,enabled:!g}),Xr=useCallback(()=>{let z=d.current;if(!z||i$1)return;let{scrollTop:co,scrollHeight:tn,clientHeight:en}=z;tn-co-en<=i&&a();},[d,a,i$1]);return jsxs(Pi,{variant:"outlined",children:[jsx(on,{}),jsx(xi,{ref:d,onScroll:Xr,children:jsxs(ki,{stickyHeader:!0,totalWidth:lo,isResizing:ko,children:[!!O.length&&jsx("colgroup",{children:O.map((z,co)=>jsx("col",{style:{width:z.width}},co))}),jsx($e,{days:u,summary:r,isFetchingSummary:e,getColumnResizeProps:Pt}),jsxs(Di,{children:[!o$1.length&&jsxs(Dr,{children:[jsx(Eo,{}),u.map((z,co)=>jsx(oo,{isToday:z.isSame(ne(),"day")},co))]}),o$1.map((z,co)=>jsx(Ci,{index:co,partner:z,days:u,isFetching:t},z.external_id)),i$1&&jsx(an,{children:jsx(Ie,{colSpan:u.length+1,align:"center",sx:{py:2,border:"none"},children:jsx(nl,{size:24})})})]})]})})]})},cl=ll;
59
60
 
60
- export { Dl as Calendar, bn as OrderProjectionProvider, c as useOrderProjectionContext, x as useOrderProjectionFilterContext };
61
+ export { cl as Calendar, dn as OrderProjectionProvider, c as useOrderProjectionContext, S as useOrderProjectionFilterContext };
61
62
  //# sourceMappingURL=index.js.map