@zydon/common 2.9.36 → 2.9.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-IFYEQTIR.js → chunk-3RFXFIBL.js} +2 -2
- package/dist/chunk-5GXRPVV5.js +9 -0
- package/dist/{chunk-XT2AH5G2.js → chunk-5ZMA4N4W.js} +1 -1
- package/dist/{chunk-ALVCWIRN.js → chunk-ANH46M6K.js} +3 -3
- package/dist/{chunk-A2LPDSRW.js → chunk-BK36QQTT.js} +2 -2
- package/dist/chunk-CB4KDKZY.js +6 -0
- package/dist/chunk-CB4KDKZY.js.map +1 -0
- package/dist/{chunk-CK6Q4FGI.js → chunk-COAGQGZA.js} +2 -2
- package/dist/{chunk-5N6Y3FIM.js → chunk-CZ5Y53WA.js} +2 -2
- package/dist/{chunk-U2XWJMVE.js → chunk-EICUAMNN.js} +2 -2
- package/dist/chunk-H762KDPN.js +11 -0
- package/dist/chunk-H762KDPN.js.map +1 -0
- package/dist/{chunk-LKX2OZSP.js → chunk-JBYYU67F.js} +3 -3
- package/dist/{chunk-FCC5IEAW.js → chunk-JKAMT5TC.js} +2 -2
- package/dist/chunk-K34AZXX4.js +8 -0
- package/dist/chunk-K34AZXX4.js.map +1 -0
- package/dist/{chunk-IWNQZ4DU.js → chunk-KDSM2AIT.js} +2 -2
- package/dist/chunk-KJJDGCL4.js +8 -0
- package/dist/chunk-KJJDGCL4.js.map +1 -0
- package/dist/{chunk-XA36N32L.js → chunk-L6CMWQCC.js} +2 -2
- package/dist/{chunk-HPBLOHGU.js → chunk-MJFCJZFD.js} +2 -2
- package/dist/chunk-MTJT2RGA.js +8 -0
- package/dist/chunk-MTJT2RGA.js.map +1 -0
- package/dist/{chunk-W6J37DOS.js → chunk-MY4CZ5PC.js} +2 -2
- package/dist/{chunk-XECFL7W6.js → chunk-NJLLYK4S.js} +2 -2
- package/dist/{chunk-QZVNKHIE.js → chunk-PMKM67BB.js} +2 -2
- package/dist/{chunk-3GERPUNO.js → chunk-PVHLAOT2.js} +5 -5
- package/dist/chunk-Q2R3X4EB.js +8 -0
- package/dist/chunk-Q2R3X4EB.js.map +1 -0
- package/dist/{chunk-C3JTGVAS.js → chunk-R7BNGTUT.js} +2 -2
- package/dist/{chunk-K6O5RVKC.js → chunk-TAA5KCEG.js} +3 -3
- package/dist/{chunk-772DOKEN.js → chunk-TS7QZPD6.js} +2 -2
- package/dist/{chunk-7IHZRIIU.js → chunk-TSEVZMIE.js} +2 -2
- package/dist/chunk-UYYDORSQ.js +6 -0
- package/dist/chunk-UYYDORSQ.js.map +1 -0
- package/dist/{chunk-4FRN4I7H.js → chunk-VELCTMU2.js} +2 -2
- package/dist/{chunk-BUDIH7D2.js → chunk-VPZL6AIF.js} +2 -2
- package/dist/{chunk-7CMID2IK.js → chunk-W27CC2AQ.js} +5 -5
- package/dist/{chunk-ZYFY6BCA.js → chunk-YHOVSR7P.js} +2 -2
- package/dist/chunk-YJYS2LQQ.js +12 -0
- package/dist/chunk-YJYS2LQQ.js.map +1 -0
- package/dist/chunk-Z3HTIXB2.js +6 -0
- package/dist/chunk-Z3HTIXB2.js.map +1 -0
- package/dist/components/Accordion/index.js +2 -2
- package/dist/components/ActionButton/index.js +2 -2
- package/dist/components/Analytics/Carts/index.d.ts +29 -0
- package/dist/components/Analytics/Carts/index.js +61 -0
- package/dist/components/Analytics/Carts/index.js.map +1 -0
- package/dist/components/Analytics/OrderProjection/index.d.ts +6 -78
- package/dist/components/Analytics/OrderProjection/index.js +29 -29
- package/dist/components/Analytics/OrderProjection/index.js.map +1 -1
- package/dist/components/Analytics/OverviewAnalytics/index.d.ts +6 -3
- package/dist/components/Analytics/OverviewAnalytics/index.js +21 -20
- package/dist/components/Analytics/OverviewAnalytics/index.js.map +1 -1
- package/dist/components/Analytics/PartnerAnalysis/index.d.ts +9 -6
- package/dist/components/Analytics/PartnerAnalysis/index.js +25 -24
- package/dist/components/Analytics/PartnerAnalysis/index.js.map +1 -1
- package/dist/components/Analytics/index.js +7 -7
- package/dist/components/Analytics/index.js.map +1 -1
- package/dist/components/Autocomplete/index.js +2 -2
- package/dist/components/AvatarButton/index.js +5 -5
- package/dist/components/BuilderLayout/index.js +2 -2
- package/dist/components/BuilderSidebar/index.js +1 -1
- package/dist/components/BulkEditModal/index.js +4 -4
- package/dist/components/CardBrand/index.js +1 -1
- package/dist/components/ColorPickerInput/index.js +2 -2
- package/dist/components/ColumnResizeHandle/index.d.ts +3 -2
- package/dist/components/ColumnResizeHandle/index.js +1 -1
- package/dist/components/Common/index.js +4 -4
- package/dist/components/CopyButton/index.js +2 -2
- package/dist/components/DataView/index.js +5 -5
- package/dist/components/DataViewMobileItem/index.d.ts +6 -0
- package/dist/components/DataViewMobileItem/index.js +2 -0
- package/dist/components/DataViewMobileItem/index.js.map +1 -0
- package/dist/components/DragButton/index.js +2 -2
- package/dist/components/Drawer/index.js +2 -2
- package/dist/components/DynamicDataView/index.js +8 -8
- package/dist/components/EasyCropModal/index.js +3 -3
- package/dist/components/Error/index.js +1 -1
- package/dist/components/ExpandableGroup/index.js +1 -1
- package/dist/components/FileUpload/index.js +6 -6
- package/dist/components/Filters/index.js +4 -4
- package/dist/components/FrameSkeleton/index.js +1 -1
- package/dist/components/HelpButton/index.js +2 -2
- package/dist/components/Icon/index.js +1 -1
- package/dist/components/IconButton/index.js +2 -2
- package/dist/components/ImageCropModal/index.js +2 -2
- package/dist/components/Incrementer/index.js +2 -2
- package/dist/components/InfoCircle/index.js +2 -2
- package/dist/components/ListBundles/index.js +2 -2
- package/dist/components/MenuItem/index.js +2 -10
- package/dist/components/MenuItem/index.js.map +1 -1
- package/dist/components/Modal/index.js +2 -2
- package/dist/components/MoreMenu/index.js +4 -11
- package/dist/components/MoreMenu/index.js.map +1 -1
- package/dist/components/NotFound/index.js +1 -1
- package/dist/components/PasswordRules/index.js +1 -1
- package/dist/components/PopoverSelect/index.js +1 -1
- package/dist/components/PortalBrandImage/index.js +1 -1
- package/dist/components/SearchInput/index.js +2 -2
- package/dist/components/SelectList/index.js +4 -4
- package/dist/components/SelectableCards/index.js +3 -3
- package/dist/components/SeoPreview/index.js +1 -1
- package/dist/components/StateDisplay/index.js +2 -2
- package/dist/components/StepUpDialog/index.js +1 -1
- package/dist/components/Steps/index.js +1 -1
- package/dist/components/StyledTab/index.js +1 -1
- package/dist/components/SwapList/index.js +2 -2
- package/dist/components/ToggleTheme/index.js +3 -3
- package/dist/components/WebhookCard/index.js +1 -1
- package/dist/components/carousel/index.js +2 -2
- package/dist/components/form/Address/index.js +3 -3
- package/dist/components/form/Autocomplete/index.js +3 -3
- package/dist/components/form/ColorPicker/index.js +2 -2
- package/dist/components/form/FileUpload/index.js +6 -6
- package/dist/components/form/Incrementer/index.js +2 -2
- package/dist/components/form/Password/index.js +1 -1
- package/dist/components/form/SelectList/index.js +4 -4
- package/dist/components/form/SelectableCards/index.js +3 -3
- package/dist/components/form/Webhook/index.js +4 -4
- package/dist/components/lightbox/index.js +1 -1
- package/dist/components/table/index.js +2 -2
- package/dist/hooks/useCartsFilters.d.ts +8 -0
- package/dist/hooks/useCartsFilters.js +5 -0
- package/dist/hooks/useCartsFilters.js.map +1 -0
- package/dist/hooks/useOrderProjectionFilters.d.ts +4 -58
- package/dist/hooks/useOrderProjectionFilters.js +3 -3
- package/dist/hooks/useResizableColumns.d.ts +1 -1
- package/dist/hooks/useResizableColumns.js +1 -1
- package/dist/hooks/useThemeToggle.js +3 -3
- package/dist/index.js +3 -3
- package/dist/theme/theme-provider.js +3 -3
- package/dist/types/carts.d.ts +8 -0
- package/dist/types/carts.js +2 -0
- package/dist/types/carts.js.map +1 -0
- package/dist/types/orderProjection.d.ts +3 -2
- package/dist/types/partnerAnalysis.d.ts +3 -2
- package/dist/useCartsFilters-9eb738ab.d.ts +219 -0
- package/dist/useOrderProjectionFilters-5c1162d5.d.ts +297 -0
- package/dist/{useResizableColumns.types-6611ee0b.d.ts → useResizableColumns.types-33105448.d.ts} +4 -3
- package/dist/utils/buildExportPayload.js +1 -1
- package/dist/utils/carts.d.ts +20 -0
- package/dist/utils/carts.js +3 -0
- package/dist/utils/carts.js.map +1 -0
- package/dist/utils/orderProjection.d.ts +2 -1
- package/dist/utils/orderProjection.js +1 -1
- package/package.json +5 -1
- package/dist/chunk-7WUAJEER.js +0 -6
- package/dist/chunk-7WUAJEER.js.map +0 -1
- package/dist/chunk-OONF23Z2.js +0 -6
- package/dist/chunk-OONF23Z2.js.map +0 -1
- package/dist/chunk-SRP3UTFW.js +0 -9
- package/dist/chunk-TQFKLNTU.js +0 -8
- package/dist/chunk-TQFKLNTU.js.map +0 -1
- package/dist/orderProjection-c6f4f71e.d.ts +0 -182
- /package/dist/{chunk-IFYEQTIR.js.map → chunk-3RFXFIBL.js.map} +0 -0
- /package/dist/{chunk-SRP3UTFW.js.map → chunk-5GXRPVV5.js.map} +0 -0
- /package/dist/{chunk-XT2AH5G2.js.map → chunk-5ZMA4N4W.js.map} +0 -0
- /package/dist/{chunk-ALVCWIRN.js.map → chunk-ANH46M6K.js.map} +0 -0
- /package/dist/{chunk-A2LPDSRW.js.map → chunk-BK36QQTT.js.map} +0 -0
- /package/dist/{chunk-CK6Q4FGI.js.map → chunk-COAGQGZA.js.map} +0 -0
- /package/dist/{chunk-5N6Y3FIM.js.map → chunk-CZ5Y53WA.js.map} +0 -0
- /package/dist/{chunk-U2XWJMVE.js.map → chunk-EICUAMNN.js.map} +0 -0
- /package/dist/{chunk-LKX2OZSP.js.map → chunk-JBYYU67F.js.map} +0 -0
- /package/dist/{chunk-FCC5IEAW.js.map → chunk-JKAMT5TC.js.map} +0 -0
- /package/dist/{chunk-IWNQZ4DU.js.map → chunk-KDSM2AIT.js.map} +0 -0
- /package/dist/{chunk-XA36N32L.js.map → chunk-L6CMWQCC.js.map} +0 -0
- /package/dist/{chunk-HPBLOHGU.js.map → chunk-MJFCJZFD.js.map} +0 -0
- /package/dist/{chunk-W6J37DOS.js.map → chunk-MY4CZ5PC.js.map} +0 -0
- /package/dist/{chunk-XECFL7W6.js.map → chunk-NJLLYK4S.js.map} +0 -0
- /package/dist/{chunk-QZVNKHIE.js.map → chunk-PMKM67BB.js.map} +0 -0
- /package/dist/{chunk-3GERPUNO.js.map → chunk-PVHLAOT2.js.map} +0 -0
- /package/dist/{chunk-C3JTGVAS.js.map → chunk-R7BNGTUT.js.map} +0 -0
- /package/dist/{chunk-K6O5RVKC.js.map → chunk-TAA5KCEG.js.map} +0 -0
- /package/dist/{chunk-772DOKEN.js.map → chunk-TS7QZPD6.js.map} +0 -0
- /package/dist/{chunk-7IHZRIIU.js.map → chunk-TSEVZMIE.js.map} +0 -0
- /package/dist/{chunk-4FRN4I7H.js.map → chunk-VELCTMU2.js.map} +0 -0
- /package/dist/{chunk-BUDIH7D2.js.map → chunk-VPZL6AIF.js.map} +0 -0
- /package/dist/{chunk-7CMID2IK.js.map → chunk-W27CC2AQ.js.map} +0 -0
- /package/dist/{chunk-ZYFY6BCA.js.map → chunk-YHOVSR7P.js.map} +0 -0
|
@@ -1,61 +1,61 @@
|
|
|
1
|
+
import { a as a$d } from '../../../chunk-K34AZXX4.js';
|
|
1
2
|
import { i as i$1, h as h$1 } from '../../../chunk-BBVOF2BY.js';
|
|
2
|
-
import { a as a$
|
|
3
|
+
import { a as a$g, b as b$1, c as c$1 } from '../../../chunk-EICUAMNN.js';
|
|
3
4
|
import { d, e as e$1 } from '../../../chunk-K2PWIYEM.js';
|
|
4
|
-
import { a as a$g, b as b$1, c as c$1 } from '../../../chunk-U2XWJMVE.js';
|
|
5
5
|
import { a as a$5 } from '../../../chunk-DRGARBKB.js';
|
|
6
6
|
import '../../../chunk-55XSPNSX.js';
|
|
7
7
|
import { a as a$7 } from '../../../chunk-RUABKHIV.js';
|
|
8
|
-
import { a as a$c } from '../../../chunk-
|
|
9
|
-
import { a as a$b } from '../../../chunk-
|
|
8
|
+
import { a as a$c } from '../../../chunk-TS7QZPD6.js';
|
|
9
|
+
import { a as a$b } from '../../../chunk-CZ5Y53WA.js';
|
|
10
10
|
import { d as d$1, g } from '../../../chunk-2W5FGLTC.js';
|
|
11
11
|
import { h } from '../../../chunk-OF6623HG.js';
|
|
12
12
|
import { a as a$3 } from '../../../chunk-HE2LUROB.js';
|
|
13
13
|
import { a as a$f } from '../../../chunk-5J35UAV6.js';
|
|
14
14
|
import { a as a$e } from '../../../chunk-4F2NKGF6.js';
|
|
15
15
|
import { a } from '../../../chunk-AZJ3VCNL.js';
|
|
16
|
-
import { a as a$i } from '../../../chunk-
|
|
16
|
+
import { a as a$i } from '../../../chunk-YHOVSR7P.js';
|
|
17
17
|
import { a as a$a } from '../../../chunk-CO2KQFUN.js';
|
|
18
|
-
import { a as a$1 } from '../../../chunk-
|
|
18
|
+
import { a as a$1 } from '../../../chunk-5ZMA4N4W.js';
|
|
19
19
|
import '../../../chunk-Z6YXPKWP.js';
|
|
20
20
|
import '../../../chunk-F65ZXAGV.js';
|
|
21
21
|
import { a as a$9 } from '../../../chunk-E3R7W7GK.js';
|
|
22
|
-
import { a as a$4 } from '../../../chunk-
|
|
23
|
-
import {
|
|
22
|
+
import { a as a$4 } from '../../../chunk-5GXRPVV5.js';
|
|
23
|
+
import { v, e, s, l, n, m, p, q, o, i, j, u, t, w, k } from '../../../chunk-UYYDORSQ.js';
|
|
24
|
+
import { b } from '../../../chunk-TXJ45CNA.js';
|
|
24
25
|
import '../../../chunk-ERLI5GAP.js';
|
|
25
26
|
import { a as a$8 } from '../../../chunk-LQRRMVFN.js';
|
|
26
|
-
import { a as a$6 } from '../../../chunk-
|
|
27
|
-
import { b } from '../../../chunk-TXJ45CNA.js';
|
|
27
|
+
import { a as a$6 } from '../../../chunk-CB4KDKZY.js';
|
|
28
28
|
import { a as a$2 } from '../../../chunk-LFHA3YUV.js';
|
|
29
29
|
import { a as a$h } from '../../../chunk-GGJJ3II3.js';
|
|
30
30
|
import { createContext, memo, useMemo, useContext, useCallback, useRef, useState } from 'react';
|
|
31
31
|
import vl from '@mui/material/CircularProgress';
|
|
32
|
-
import
|
|
33
|
-
import
|
|
32
|
+
import Be from '@mui/material/TableCell';
|
|
33
|
+
import un from '@mui/material/TableRow';
|
|
34
34
|
import fe from 'dayjs';
|
|
35
35
|
import { styled, alpha } from '@mui/material/styles';
|
|
36
36
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import
|
|
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
48
|
import gd from '@mui/material/Card';
|
|
49
49
|
import ud from '@mui/material/Table';
|
|
50
50
|
import hd from '@mui/material/TableBody';
|
|
51
|
-
import
|
|
52
|
-
import
|
|
53
|
-
import
|
|
51
|
+
import Td from '@mui/material/TableContainer';
|
|
52
|
+
import yn from '@mui/material/Badge';
|
|
53
|
+
import Sd from '@mui/material/Checkbox';
|
|
54
54
|
import bd from '@mui/material/FormControlLabel';
|
|
55
55
|
import { PickersDay } from '@mui/x-date-pickers/PickersDay';
|
|
56
56
|
|
|
57
|
-
var wo=styled(Ne,{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%"}})),io=styled(Ne,{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"})),Ir=styled(gn)(({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 Me=createContext(null),Tn=({adapters:o,slots:r,children:e})=>{let t=a$4(),a=useMemo(()=>({adapters:o,slots:r,filters:t}),[o,r,t]);return jsx(Me.Provider,{value:a,children:e})},c=()=>{let o=useContext(Me);if(!o)throw new Error("useOrderProjectionContext must be used within an OrderProjectionProvider");return o},x=()=>c().filters;var Fe=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(l=>l.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(co,{gap:1.5,children:[jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"CALENDAR_TODAY",color:"grey.400"}),jsx(W,{variant:"caption",fontWeight:"bold",children:"Pedidos"})]}),jsxs(co,{gap:.5,children:[!t&&jsxs(Fragment,{children:[jsxs(W,{variant:"caption",children:["Pedidos em andamento:"," ",jsx("strong",{children:a.shopping_cart_active})]}),jsxs(W,{variant:"caption",children:["Pedidos realizados: ",jsx("strong",{children:a.order_placed})]}),jsxs(W,{variant:"caption",children:["Pedidos fora do padr\xE3o: ",jsx("strong",{children:a.order_unplanned})]})]}),jsxs(W,{variant:"caption",children:["Pedidos previstos: ",jsx("strong",{children:a.order_planned})]}),!t&&jsxs(W,{variant:"caption",children:["Carrinhos abandonados:"," ",jsx("strong",{children:a.shopping_cart_abandoned})]})]})]})},We=Pn;var _n=({day:o,summary:r,isFetchingSummary:e})=>{let t=o.isSame(fe(),"day"),{ordersPlacedCount:a,ordersExpectedCount:i}=useMemo(()=>{let n=o.format("YYYY-MM-DD"),l=r?.days.find(u=>u.date===n),d=l?.order_placed??0,y=l?.order_unplanned??0,f=l?.order_planned??0;return {ordersPlacedCount:d+y,ordersExpectedCount:d+y+f}},[o,r]);return jsx(a$e,{isLoading:e,loading:jsx(Dn,{width:50,height:24}),children:jsx(a$f,{title:jsx(We,{day:o,summary:r}),arrow:!0,children:jsx("span",{children:jsxs(Fe,{variant:"filled",backgroundColor:"#919EAB29",color:"text.secondary",isToday:t,children:[a," de ",i]})})})})},Ge=_n;var An=["Dom.","Seg.","Ter.","Qua.","Qui.","Sex.","S\xE1b."],On=({day:o,index:r,summary:e,isFetchingSummary:t,resize:a})=>{let i=o.isSame(fe(),"day");return jsxs(io,{isToday:i,"data-testid":`day-cell-${r}`,children:[jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1,children:[jsxs(co,{children:[jsx(W,{variant:"subtitle2",color:i?"primary.main":"text.secondary",children:o.date()}),jsx(W,{variant:"body2",fontSize:13,color:i?"primary.main":"text.secondary",children:An[o.day()]})]}),jsx(Ge,{day:o,summary:e,isFetchingSummary:t})]}),a&&jsx(a$d,{label:`Redimensionar coluna ${o.format("DD/MM")}`,...a})]})},ze=On;var Nt=styled(wn,{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 Nn=({summary:o})=>jsxs(co,{gap:1.5,children:[jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"USER_GROUP",color:"grey.400"}),jsx(W,{variant:"caption",fontWeight:"bold",children:"Clientes"})]}),jsx(co,{gap:.5,children:jsxs(W,{variant:"caption",children:["Total de clientes: ",jsx("strong",{children:o?.partner_count??0})]})})]}),Ue=Nn;var Fn=({summary:o,isFetchingSummary:r,resize:e})=>{let{open:t,onClose:a$1,onOpen:i}=a$8(),{ascending:n,setAscending:l}=x(),d=useCallback(y=>{l(y),a$1();},[a$1,l]);return jsxs(Fragment,{children:[jsxs(wo,{cellAlign:"center",children:[jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1,children:[jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(W,{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(Ue,{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:()=>d(!0),active:n,fullWidth:!0,children:"De A \xE0 Z"}),jsx(Nt,{variant:"text",onClick:()=>d(!1),active:!n,fullWidth:!0,children:"De Z \xE0 A"})]})]})},qe=Fn;var Qe=styled(Gn)(({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 Vn=({days:o,summary:r,isFetchingSummary:e,getColumnResizeProps:t})=>jsx(Qe,{children:jsxs(gn,{children:[jsx(qe,{summary:r,isFetchingSummary:e,resize:t(l)}),o.map((a,i)=>jsx(ze,{index:i,day:a,summary:r,isFetchingSummary:e,resize:t(p(i))},i))]})}),Xe=Vn;var $n={["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"}),"."]})}},Ke={["ORDER_UNPLANNED"]:()=>{let o=u("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}=t(o||new Date),e=u("ORDER_PLANNED",r),{icon:t$1,message:a}=$n[r];return {icon:t$1,message:a,background:e.background,color:e.color}},["SHOPPING_CART_ACTIVE"]:()=>{let o=u("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=u("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 Je=styled(Un,{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 qn=({origin:o,referenceDate:r})=>{let e=Ke[o];if(!e)return null;let t=e({origin:o,referenceDate:r});return t?jsx(Je,{icon:t.icon,customBackground:t.background,customColor:t.color,children:t.message}):null},Ze=qn;var Zn=({message:o,onRetry:r,isFetching:e})=>jsxs(co,{alignItems:"center",justifyContent:"center",p:3,gap:.5,children:[jsx(W,{variant:"body2",color:"text.secondary",children:o}),jsx(Xn,{variant:"text",startIcon:jsx(a$1,{icon:"REFRESH_CHANGE"}),size:"small",onClick:r,loading:e,children:"Tentar novamente"})]}),no=Zn;var rp=()=>jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{gap:.5,children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Status do pedido"}),jsx(a$7,{width:"30%",height:22})]})]}),jsxs(co,{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})]})]}),oa=rp;var ep=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{renderEventStatus:a,renderEventActions:i}=e,{data:n,isLoading:l,isFetching:d,isError:y,refetch:f}=t(o,{skip:!o}),u=n?.detail?.sale_external_id||n?.detail?.external_id,_=l||d,D=n?.external_origin==="SALE";return jsx(a$e,{isLoading:_,loading:jsx(oa,{}),anError:y,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido realizado!",onRetry:f,isFetching:d}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:u?`#${u}`:"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d$1(n?.detail?.created_at,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h(n?.detail?.total_value??n?.amount_value)})]}),n&&a?.(n)]}),jsxs(co,{gap:1.5,children:[n&&i?.(n),!D&&jsx(Un,{severity:"warning",children:"Este pedido foi importado do ERP. Para visualizar detalhes ou realizar a\xE7\xF5es, acesse o sistema ERP."})]})]})})},ta=ep;var ap=({period:o})=>{let r=o==="PAST",e=o==="FUTURE";return jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:e?"Comportamento de compra":"Resumo"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data prevista"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(a$7,{width:"30%",height:22})]}),r&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Per\xEDodo desde o \xFAltimo pedido"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),jsx(a$7,{width:"50%",height:22})]})]})]}),jsxs(co,{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})]})]})},ea=ap;var np=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t$1}=r,{renderEventActions:a,renderSaleLink:i}=e,{data:n,isLoading:l,isFetching:d,isError:y,refetch:f}=t$1(o,{skip:!o}),{period:u}=t(n?.reference_date??new Date),_=u==="PAST",D=u==="FUTURE",E=n?.partner?.sale_analysis?.last_sale_sale_external_id||n?.partner?.sale_analysis?.last_sale_external_id,J=n?.partner?.sale_analysis?.last_sale_negotiation_date;return jsx(a$e,{isLoading:l,loading:jsx(ea,{period:u}),anError:y,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido previsto!",onRetry:f,isFetching:d}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:D?"Comportamento de compra":"Resumo"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data prevista"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d$1(n?.reference_date,"DD/MM/YYYY")})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:s(n?.partner?.recurrence)})]}),_&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Per\xEDodo desde o \xFAltimo pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:J?g(J):"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),E?jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[i?.(E),jsxs(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:["em ",d$1(J,"DD/MM/YYYY [\xE0s] HH:mm")]})]}):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"})]})]})]}),n&&a?.(n)]})})},aa=np;var sp=()=>jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(a$7,{width:"25%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(a$7,{width:"20%",height:22})]})]}),jsx(Xo,{sx:{mx:-3}}),jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(a$7,{width:"35%",height:22})]})]}),jsxs(co,{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=sp;var dp=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{renderEventActions:a}=e,{data:i,isLoading:n,isFetching:l,isError:d,refetch:y}=t(o,{skip:!o}),f=i?.detail?.sale_external_id||i?.detail?.external_id;return jsx(a$e,{isLoading:n,loading:jsx(ia,{}),anError:d,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido!",onRetry:y,isFetching:l}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:f?`#${f}`:"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:d$1(i?.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:h(i?.amount_value)})]})]}),jsx(Xo,{sx:{mx:-3}}),jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:s(i?.partner?.recurrence)})]})]}),i&&a?.(i)]})})},na=dp;var lp=()=>jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do carrinho"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Tempo decorrido desde o abandono"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(a$7,{width:"80%",height:22})]})]}),jsx(a$7,{width:"100%",height:30})]}),pa=lp;var yp=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{formatAddress:a}=e,{data:i,isLoading:n,isFetching:l,isError:d,refetch:y}=t(o,{skip:!o});return jsx(a$e,{isLoading:n,loading:jsx(pa,{}),anError:d,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do carrinho abandonado!",onRetry:y,isFetching:l}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do carrinho"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Tempo decorrido desde o abandono"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:d$1(i?.detail?.abandoned_at,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:i?.detail?.new_order?.name??"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:i?.detail?.payment_method?.name??"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:h(i?.detail?.total??i?.amount_value)})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:a(i?.detail?.address)})]})]}),jsx(wn,{component:si,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"})]})})},sa=yp;var fp=()=>jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do carrinho"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(a$7,{width:"80%",height:22})]})]}),jsx(a$7,{width:"100%",height:30})]}),da=fp;var hp=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{formatAddress:a}=e,{data:i,isLoading:n,isFetching:l,isError:d,refetch:y}=t(o,{skip:!o});return jsx(a$e,{isLoading:n,loading:jsx(da,{}),anError:d,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do carrinho!",onRetry:y,isFetching:l}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do carrinho"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:i?.detail?.new_order?.name??"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:i?.detail?.payment_method?.name??"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:h(i?.detail?.total??i?.amount_value)})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:a(i?.detail?.address)})]})]}),jsx(wn,{component:si,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=hp;var Sp={["ORDER_PLACED"]:ta,["ORDER_UNPLANNED"]:na,["ORDER_PLANNED"]:aa,["SHOPPING_CART_ACTIVE"]:la,["SHOPPING_CART_ABANDONED"]:sa},Tp=({origin:o,eventId:r})=>{let e=Sp[o];return e?jsx(e,{eventId:r}):null},jt=Tp;var vp=({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(W,{variant:"overline",color:"text.secondary",children:["Pedido:\u2002",jsxs(W,{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))})},ma=vp;var xp=()=>jsxs(co,{p:3,gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do cliente"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Nome"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$7,{width:"100%",height:22})]}),jsx(wn,{variant:"text",startIcon:jsx(a$1,{icon:"PENCIL_EDIT"}),color:"inherit",size:"small",disabled:!0,children:"Editar"})]})]}),fa=xp;var Dp=({partner:o,isLoading:r,onPhoneUpdated:e})=>{let{renderPartnerLink:t,renderPhoneEditor:a}=c().slots;return jsx(a$e,{isLoading:r,loading:jsx(fa,{}),children:jsxs(co,{p:3,gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do cliente"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Nome"}),t?t(o):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o?.name||"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:o?.tax_id?i$1(o.tax_id):"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),o?.phone?jsx(si,{href:`https://wa.me/${o.phone}`,target:"_blank",rel:"noopener noreferrer",color:"#22C55E",children:jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"WHATSAPP",color:"#22C55E"}),jsx(W,{variant:"subtitle2",color:"success.main",children:h$1(o.phone)})]})}):jsx(W,{variant:"subtitle2",color:"text.primary",children:"-"})]}),a?.(o?.external_id??"",e??(()=>{}))]})]})})},ua=Dp;var ha=styled(co,{shouldForwardProp:o=>o!=="customBackground"&&o!=="customColor"})(({theme:o,customBackground:r,customColor:e})=>({padding:o.spacing(.5,1),borderRadius:4,background:r,color:e}));var Lp=({open:o,onClose:r,events:e})=>{let t$1=e[0],[a,i]=useState(),{useEventDetails:n}=c().adapters,{data:l,isLoading:d,refetch:y}=n(t$1?.id??"",{skip:!o||!t$1?.id}),{period:f}=t(t$1?.reference_date??new Date),u$1=u(t$1?.type,f),_=useCallback(D=>{i(D),y();},[y]);return jsxs(a$b,{open:o,onClose:r,headerTitle:jsxs(Fragment,{children:["Detalhes"," ",jsx(ha,{customBackground:u$1.background,customColor:u$1.color,children:jsx(W,{variant:"subtitle2",fontSize:13,noWrap:!0,children:u$1.label})})]}),headerProps:{direction:"row-reverse"},contentProps:{p:0},maxWidth:520,children:[jsx(co,{position:"sticky",top:0,zIndex:9,children:jsx(Ze,{origin:t$1?.type,referenceDate:t$1?.reference_date})}),jsx(ua,{partner:l?.partner?{...l.partner,phone:a??l.partner.phone}:void 0,isLoading:d,onPhoneUpdated:_}),jsx(Xo,{}),jsx(ma,{events:e})]})},yt=Lp;var Mp=({icon:o,title:r,description:e,details:t,footer:a})=>jsxs(co,{gap:1,children:[jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[o,jsx(W,{variant:"caption",fontWeight:"bold",children:r})]}),jsx(W,{variant:"caption",children:e}),t&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsx(co,{children:t})]}),a&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),a]})]}),X=Mp;var Bp=({event:o})=>{let{getEventCode:r}=c().slots;return jsx(X,{icon:jsx(a$1,{icon:"CHECK_CIRCLE",color:"#22C55E"}),title:"Pedido realizado",description:"Pedido realizado com sucesso!",details:jsxs(Fragment,{children:[jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(o)?`#${r(o)}`:"-"})]}),jsxs(W,{variant:"caption",children:["Data e hora:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})})},Ca=Bp;var Yp=({event:o})=>{let{period:r}=t(o.reference_date);return r==="PAST"?jsx(X,{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(W,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY")})]})}):r==="TODAY"?jsx(X,{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(W,{variant:"caption",children:["Valor previsto: ",jsx("strong",{children:h(o.amount_value)})]})}):jsx(X,{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(W,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY")})]})})},Pa=Yp;var Wp=({event:o})=>{let{getEventCode:r}=c().slots;return jsx(X,{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(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(o)?`#${r(o)}`:"-"})]}),jsxs(W,{variant:"caption",children:["Data e hora:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})})},xa=Wp;var Hp=({event:o})=>jsx(X,{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(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:o.external_id?`#${o.external_id}`:"-"})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})}),Ea=Hp;var zp=({event:o})=>jsx(X,{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(W,{variant:"caption",children:["Valor parcial: ",jsx("strong",{children:h(o.amount_value)})]})}),_a=zp;var re={color:"common.white",width:16,height:16,sx:{flexShrink:0}},Ia={["ORDER_PLACED"]:{getIcon:()=>null,getTitle:()=>"Pedido realizado",getDescription:()=>"Pedido confirmado com sucesso!",getTooltip:o=>jsx(Ca,{event:o})},["ORDER_UNPLANNED"]:{getIcon:()=>null,getTitle:()=>"Pedido fora do padr\xE3o",getDescription:()=>"Pedido feito fora do dia habitual.",getTooltip:o=>jsx(xa,{event:o})},["ORDER_PLANNED"]:{getIcon:o=>{let{period:r}=t(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}=t(o.reference_date);return r==="PAST"?"Pedido n\xE3o realizado":r==="TODAY"?"Pedido previsto para hoje":"Pedido previsto"},getDescription:o=>{let{period:r}=t(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(Pa,{event:o})},["SHOPPING_CART_ACTIVE"]:{getIcon:()=>null,getTitle:()=>"Pedido em andamento",getDescription:()=>"Cliente est\xE1 atualizando o carrinho neste momento.",getTooltip:o=>jsx(_a,{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(Ea,{event:o})}};var Oa=styled(co,{shouldForwardProp:o=>o!=="eventType"&&o!=="period"})(({theme:o,eventType:r,period:e})=>{let t=u(r,e);return {position:"relative",padding:o.spacing(.5,1),borderRadius:4,background:t.background,color:t.color,cursor:"pointer","&:hover":{background:t.backgroundHover}}}),wa=styled(co,{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:u(r,e).iconBadgeColor,boxShadow:`0 0 0 2px ${o.palette.common.white}`}));var Up=({event:o,index:r})=>{let[e,t$1]=a$9(),a=Ia[o.type];if(!a)return null;let{period:i}=t(o.reference_date),n=a.getIcon(o);return jsxs(Fragment,{children:[jsx(a$f,{title:a.getTooltip(o),arrow:!0,children:jsxs(Oa,{"data-testid":`event-${r}`,eventType:o.type,period:i,onClick:t$1,children:[n&&jsx(wa,{eventType:o.type,period:i,children:n}),jsx(W,{variant:"subtitle2",fontSize:13,noWrap:!0,children:a.getTitle(o)}),jsx(W,{variant:"caption",noWrap:!0,children:a.getDescription(o)})]})}),jsx(yt,{open:e,onClose:t$1,events:[o]})]})},Ma=Up;var Qp=({icon:o,title:r,description:e,children:t})=>jsxs(co,{gap:1,children:[jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[o,jsx(W,{variant:"caption",fontWeight:"bold",children:r})]}),jsx(W,{variant:"caption",children:e}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsx(co,{gap:1,children:t})]}),lo=Qp;var Kp=({events:o})=>{let{getEventCode:r}=c().slots,e=o.slice(0,k),t=o.length-k;return jsxs(lo,{icon:jsx(a$1,{icon:"CHECK_CIRCLE",color:"#22C55E"}),title:"Pedidos realizados",description:"Pedidos realizados com sucesso!",children:[e.map((a,i)=>jsxs(co,{children:[i>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(a)?`#${r(a)}`:"-"})]}),jsxs(W,{variant:"caption",children:["Data/Hora:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(a.amount_value)})]})]},a.id)),t>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",t," pedido",t>1?"s":""]})]})]})},Wa=Kp;var os={["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"})},rs={["PAST"]:"Pedidos n\xE3o realizados",["TODAY"]:"Pedidos previstos para hoje",["FUTURE"]:"Pedidos previstos"},ts={["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."},es=({events:o})=>{let{period:r}=t(o[0]?.reference_date),e=o.slice(0,k),t$1=o.length-k;return jsxs(lo,{icon:os[r],title:rs[r],description:ts[r],children:[e.map((a,i)=>jsxs(co,{children:[i>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY")})]})]},a.id)),t$1>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",t$1," pedido",t$1>1?"s":""]})]})]})},Va=es;var ns=({events:o})=>{let{getEventCode:r}=c().slots,e=o.slice(0,k),t=o.length-k;return jsxs(lo,{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(co,{children:[i>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(a)?`#${r(a)}`:"-"})]}),jsxs(W,{variant:"caption",children:["Data/Hora:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(a.amount_value)})]})]},a.id)),t>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",t," pedido",t>1?"s":""]})]})]})},$a=ns;var ds=({events:o})=>{let r=o.slice(0,k),e=o.length-k;return jsxs(lo,{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(co,{children:[a>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:t.external_id?`#${t.external_id}`:"-"})]}),jsxs(W,{variant:"caption",children:["Inativo h\xE1: ",jsx("strong",{children:g(t.reference_date)})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(t.amount_value)})]})]},t.id)),e>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",e," carrinho",e>1?"s":""]})]})]})},ja=ds;var ms=({events:o})=>{let r=o.slice(0,k),e=o.length-k;return jsxs(lo,{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(co,{children:[a>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:t.external_id?`#${t.external_id}`:"-"})]}),jsxs(W,{variant:"caption",children:["Valor parcial: ",jsx("strong",{children:h(t.amount_value)})]})]},t.id)),e>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",e," carrinho",e>1?"s":""]})]})]})},Qa=ms;var Xa={["ORDER_PLACED"]:Wa,["ORDER_UNPLANNED"]:$a,["ORDER_PLANNED"]:Va,["SHOPPING_CART_ACTIVE"]:Qa,["SHOPPING_CART_ABANDONED"]:ja};var Ka=styled(co,{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 hs=({group:o,index:r})=>{let[e,t]=a$9(),{config:a,count:i,events:n}=o,l=i>1?a.labelPlural:a.label,d=Xa[n[0].type];return jsxs(Fragment,{children:[jsx(a$f,{title:jsx(d,{events:n}),arrow:!0,children:jsx(Ka,{"data-testid":`grouped-events-${r}`,customBackground:a.background,customColor:a.color,customHoverBackground:a.backgroundHover,onClick:t,children:jsxs(W,{variant:"subtitle2",fontSize:13,title:`${i} ${l}`,noWrap:!0,children:[jsx("strong",{children:i})," ",l]})})}),jsx(yt,{open:e,onClose:t,events:n})]})},Za=hs;var bs=({events:o})=>{let r=useMemo(()=>{let e={};return o.forEach(t$1=>{let a=t$1.type==="ORDER_PLANNED"?u(t$1.type,t(t$1.reference_date).period):u(t$1.type);e[a.label]||(e[a.label]={count:0,config:a,events:[]}),e[a.label].count+=1,e[a.label].events.push(t$1);}),Object.values(e)},[o]);return jsx(Fragment,{children:r.map((e,t)=>jsx(Za,{index:t,group:e},t))})},ri=bs;var ti=styled(co)({gap:4});var ks=({events:o,day:r,index:e})=>{let t=r.isSame(fe(),"day");if(o.length===0)return jsx(io,{isToday:t,"data-testid":`day-column-${e}`});let a=o.length>j;return jsx(io,{isToday:t,"data-testid":`day-column-${e}`,children:jsx(ti,{children:a?jsx(ri,{events:o}):o.map((i,n)=>jsx(Ma,{index:n,event:i},n))})})},ei=ks;var Es=({day:o,index:r,events:e,isFetching:t})=>{let a=o.isSame(fe(),"day");return t?jsx(io,{isToday:a,"data-testid":`day-column-${r}`,children:jsx(a$7,{width:"100%",height:"100%",sx:{maxHeight:46.42}})}):jsx(ei,{events:e,day:o,index:r})},ai=Es;var ii=styled(_s)(()=>({width:6,height:6,borderRadius:"50%",flexShrink:0}));var Os=({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(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(ii,{bgcolor:i}),jsx(W,{variant:r,color:e,noWrap:!0,children:a})]})},Ct=Os;var Ns=()=>jsxs(co,{mt:-1,px:1,gap:1,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Nome"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"E-mail"}),jsx(a$7,{width:"35%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Status do cliente"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{gap:.5,children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Segmento"}),jsx(a$7,{width:"35%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$7,{width:"100%",height:22})]}),jsx(wn,{variant:"text",startIcon:jsx(a$1,{icon:"PENCIL_EDIT"}),color:"inherit",size:"small",disabled:!0,children:"Editar"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Vendedor preferencial"}),jsx(a$7,{width:"40%",height:22})]})]}),pi=Ns;var Ys=({partner:o,onPhoneUpdated:r})=>{let[e,t]=a$9(!0),{adapters:a,slots:i}=c(),{renderPartnerLink:n,renderPhoneEditor:l}=i,{data:d,isLoading:y,refetch:f}=a.usePartnerDetails(o.external_id,{skip:!o.external_id||!e}),u=d?.mobile??d?.phone,_=useMemo(()=>d?.fiscal_registration_number?i$1(d?.fiscal_registration_number):"-",[d?.fiscal_registration_number]),D=useCallback(E=>{f(),r?.(E);},[f,r]);return jsxs(a$g,{expanded:e,onChange:t,defaultExpanded:!0,children:[jsx(b$1,{children:jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es"})}),jsx(c$1,{children:jsx(a$e,{isLoading:y,loading:jsx(pi,{}),children:jsxs(co,{mt:-1,px:1,gap:1,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Nome"}),n?n(d):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o?.name||"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:_})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"E-mail"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d?.email||"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Status do cliente"}),o.classification?jsx(Ct,{status:o.classification,variant:"subtitle2",color:"text.primary"}):jsx(W,{variant:"subtitle2",color:"text.primary",children:"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{gap:.5,children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Segmento"}),d?.profile?.name?jsx(Fs,{variant:"outlined",label:d.profile.name,size:"small",color:"default",sx:{width:"fit-content"}}):jsx(W,{variant:"subtitle2",color:"text.primary",children:"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),u?jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[jsx(a$1,{icon:"WHATSAPP",color:"success.main",sx:{flexShrink:0}}),jsx(si,{component:si,href:`https://wa.me/${u}`,target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",color:"success.main",noWrap:!0,children:h$1(u)})]}):jsx(W,{variant:"subtitle2",color:"text.primary",children:"-"})]}),l?.(o.external_id,D)]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Vendedor preferencial"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d?.main_seller?.name||"-"})]})]})})})]})},di=Ys;var Hs=({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(co,{overflow:"hidden",children:[o?.id?r?.(o.id):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"}),jsx(W,{variant:"caption",color:"text.secondary",children:d$1(o?.negotiation_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(W,{variant:"subtitle2",color:"text.primary",children:h(o?.total_value)})]})},ci=memo(Hs,a$2);var zs=()=>jsxs(co,{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})]}),mi=zs;var js=({partner:o})=>{let[r,e]=a$9(!1),t=useMemo(()=>o?.external_id?{perPage:5,sort:{fieldName:"negotiationDate",sortType:"DESC"},filter:{operator:"AND",groups:[{operator:"AND",conditionals:[{fieldName:"partnerId",conditional:"EQUALS",value:[o.external_id]}]}]}}:null,[o?.external_id]),{usePartnerOrders:a}=c().adapters,{data:{items:i=[]}={},isLoading:n}=a(t,{skip:!t});return jsxs(a$g,{expanded:r,onChange:e,children:[jsx(b$1,{children:jsx(W,{variant:"overline",color:"text.secondary",children:"\xDAltimos pedidos"})}),jsx(c$1,{children:jsx(co,{mt:-1,px:1,children:jsx(a$e,{isLoading:n,loading:jsx(mi,{}),isEmpty:i?.length===0,empty:jsx(co,{alignItems:"center",justifyContent:"center",gap:1.5,p:2,children:jsx(W,{variant:"body2",color:"text.secondary",children:"Este cliente ainda n\xE3o possui pedidos realizados."})}),children:jsx(co,{gap:1.5,children:i?.map((l,d)=>jsx(ci,{order:l,"data-testid":`last-order-${d}`},l.id))})})})})]})},fi=js;var Ks=({partner:o})=>{let{renderSaleLink:r}=c().slots,[e,t]=a$9(!1),a=useMemo(()=>s(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,children:[jsx(b$1,{children:jsx(W,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"})}),jsx(c$1,{children:jsxs(co,{mt:-1,px:1,gap:1,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:a})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),i?jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[r?.(i),jsxs(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:["em ",d$1(n,"DD/MM/YYYY [\xE0s] HH:mm")]})]}):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"})]})]})})]})},gi=Ks;var se=styled(Xo)(({theme:o})=>({height:30,alignSelf:"center",borderStyle:"dashed",[o.breakpoints.down("sm")]:{display:"none"}}));var od=()=>jsxs(co,{direction:{xs:"column",sm:"row"},justifyContent:{xs:"flex-start",sm:"center"},gap:3,children:[jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Qtd. de pedidos"}),jsx(a$7,{width:30,height:22})]}),jsx(se,{orientation:"vertical",flexItem:!0}),jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Valor total"}),jsx(a$7,{width:92,height:22})]}),jsx(se,{orientation:"vertical",flexItem:!0}),jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Ticket m\xE9dio"}),jsx(a$7,{width:71,height:22})]})]}),ui=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(W,{variant:"overline",color:"text.secondary",children:"Indicadores de vendas"})}),jsx(c$1,{children:jsx(co,{mt:-1,px:1,children:jsx(a$e,{isLoading:i,loading:jsx(ui,{}),children:jsxs(co,{direction:{xs:"column",sm:"row"},justifyContent:{xs:"flex-start",sm:"center"},gap:3,children:[jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Qtd. de pedidos"}),jsx(W,{variant:"subtitle2",children:a?.order_quantity||0})]}),jsx(Xo,{orientation:"vertical",flexItem:!0}),jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Valor total"}),jsx(W,{variant:"subtitle2",children:h(a?.total_value)})]}),jsx(Xo,{orientation:"vertical",flexItem:!0}),jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Ticket m\xE9dio"}),jsx(W,{variant:"subtitle2",children:h(a?.average_ticket)})]})]})})})})]})},Si=rd;var td=({partner:o,onPhoneUpdated:r})=>jsxs(Fragment,{children:[jsx(di,{partner:o,onPhoneUpdated:r}),jsx(Si,{partner:o}),jsx(gi,{partner:o}),jsx(fi,{partner:o})]}),Ti=td;var vi=styled(co)(({theme:o})=>({minHeight:47.42,flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:o.spacing(1.5)})),le=styled(wn)(({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),[l,d]=useState(o.phone),y=l?.replace(/\D/g,""),f=!!y,u=useCallback(L=>{d(L);},[]),_=o.sale_analysis.sale_count,D=useMemo(()=>`${_} pedido${_===0||_>1?"s":""}`,[_]),E=useMemo(()=>{let Ro=[e$1[o.classification]?.label,D].filter(Boolean).join(" \u2022 ");return `${o.name}
|
|
58
|
-
${Ro}`},[o.classification,o.name,D]),J=useCallback(()=>{a.current&&t(a.current);},[t]),P=useCallback(()=>{e(),n();},[e,n]);return jsxs(Fragment,{children:[jsx(wo,{title:E,onClick:J,sx:{cursor:"pointer"},children:jsxs(vi,{children:[jsxs(co,{overflow:"hidden",children:[jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o.name}),jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[jsx(Ct,{status:o.classification,variant:"caption",color:"text.disabled"}),jsxs(W,{variant:"caption",color:"text.disabled",noWrap:!0,children:[o.classification&&jsx(Fragment,{children:"\u2022"})," ",D]})]})]}),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:si,href:`https://wa.me/${y}`,target:"_blank",rel:"noopener noreferrer",variant:"text",startIcon:jsx(a$1,{icon:"WHATSAPP"}),disabled:!f,fullWidth:!0,children:"Enviar mensagem"}),jsx(le,{variant:"text",startIcon:jsx(a$1,{icon:"INFORMATIONS"}),onClick:P,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(Ti,{partner:o,onPhoneUpdated:u})})]})},Di=ld;var yd=({partner:o,index:r,days:e,isFetching:t})=>{let a=useMemo(()=>{let i=new Map;return o.events.forEach(n=>{let l=new Date(n.reference_date).toISOString().slice(0,10),d=i.get(l)??[];d.push(n),i.set(l,d);}),i},[o.events]);return jsxs(Ir,{"data-testid":`partner-${r}`,children:[jsx(Di,{partner:o}),e.map((i,n)=>jsx(ai,{index:n,day:i,events:a.get(i.format("YYYY-MM-DD"))??[],isFetching:t},n))]})},_i=memo(yd);var Ii=styled(gd)({display:"flex",flexDirection:"column",width:"100%",height:"calc(100vh - 300px)",boxShadow:"none",overflow:"hidden"}),Ri=styled(Sd)({flex:1}),Ai=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"}})),Oi=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(Td,{name:`classification-${o}`,checked:r,onChange:e}),label:jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(co,{width:6,height:16,bgcolor:a,borderRadius:1})," ",t]})})},Li=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(W,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Classifica\xE7\xF5es"})}),jsx(c$1,{children:jsx(co,{mt:-1,children:Dd.map(i=>jsx(Li,{classification:i,checked:o.includes(i),onToggle:()=>a(i)},i))})})]})},Ni=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}}}),Bi=styled(a$3)(()=>({"&.MuiDateCalendar-root":{margin:-24},"& .MuiPickersCalendarHeader-label":{textTransform:"capitalize"}})),Fi=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(f=>It(f,a)||It(f,i)||f>a&&f<i,[a,i]),l=useCallback(f=>It(f,a),[a]),d=useCallback(f=>It(f,i),[i]),y=useCallback(f=>{f&&t(fe(f));},[t]);return jsxs(co,{p:2,pb:3,gap:2,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Calend\xE1rio"}),jsx(co,{alignItems:"center",children:jsx(Bi,{value:o.toDate(),onChange:y,showDaysOutsideCurrentMonth:!0,slots:{day:Fi},slotProps:{day:f=>{let u=f.day.toDate();return {isInRange:n(u),isStart:l(u),isEnd:d(u),isDaily:e==="DAY",disableMargin:!0}}},dayOfWeekFormatter:f=>Od[f.day()],fixedWeekNumber:6})})]})},Wi=wd;var Yd=()=>{let{selectedPartners:o,setSelectedPartners:r}=x(),[e,t]=a$9(!0),[a,i]=useState(""),{buildOptions:n,finishSearch:l,onSearch:d,onSelectValue:y,search:f,searching:u}=a$h(),{usePartnerOptions:_}=c().adapters,{items:D,isFetching:E,isLoading:J}=_({search:f,skip:!e}),P=useMemo(()=>u||E?[]:n(D.map(({id:m,name:b})=>({value:m,label:b||""})),E),[n,E,D,u]),L=o.length>0,Ro=useCallback(m=>{y(P,m);let b=typeof m=="string"?m:String(m?.value||""),At=P.find(Ao=>String(Ao.value)===b)?.label||(typeof m=="string"?m:String(m?.label||""));b&&!o.some(Ao=>Ao.id===b)&&r([...o,{id:b,name:At}]),i("");},[r,y,P,o]),_r=useCallback(m=>{r(o.filter(b=>b.id!==m.id));},[r,o]);return jsxs(a$g,{expanded:e,onChange:t,children:[jsx(b$1,{children:jsx(W,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Clientes"})}),jsx(c$1,{children:jsxs(co,{gap:1,children:[jsx(a$i,{name:"partners",label:"Clientes",placeholder:"Digite para buscar um cliente...",size:"small",options:P,loading:J,inputValue:a,onInputChange:(m,b)=>i(b),onSearch:d,onBlur:l,onChange:Ro,filterOptions:m=>m,noOptionsText:u||E?"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:!L,empty:jsx(W,{variant:"body2",color:"text.secondary",children:"Nenhum cliente selecionado"}),children:o.map((m,b)=>jsx(Fs,{variant:"outlined",label:m.name,color:"default",onDelete:()=>_r(m),"data-testid":`filter-partner-${b}`},m.id))})})]})})]})},zi=Yd;var zd=()=>{let{selectedProfiles:o,setSelectedProfiles:r}=x(),[e,t]=a$9(!!o.length),[a,i]=useState(""),{buildOptions:n,finishSearch:l,onSearch:d,onSelectValue:y,search:f,searching:u}=a$h(),{useProfileOptions:_}=c().adapters,{items:D,isFetching:E,isLoading:J}=_({search:f,skip:!e}),P=useMemo(()=>u||E?[]:n(D.map(({id:m,name:b})=>({value:m,label:b||""})),E),[n,E,D,u]),L=o.length>0,Ro=useCallback(m=>{y(P,m);let b=typeof m=="string"?m:String(m?.value||""),At=P.find(Ao=>String(Ao.value)===b)?.label||(typeof m=="string"?m:String(m?.label||""));b&&!o.some(Ao=>Ao.id===b)&&r([...o,{id:b,name:At}]),i("");},[r,y,P,o]),_r=useCallback(m=>{r(o.filter(b=>b.id!==m.id));},[r,o]);return jsxs(a$g,{expanded:e,onChange:t,children:[jsx(b$1,{children:jsx(W,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Segmentos"})}),jsx(c$1,{children:jsxs(co,{gap:1,children:[jsx(a$i,{name:"profiles",label:"Segmentos",placeholder:"Digite para buscar um segmento...",size:"small",options:P,loading:J,inputValue:a,onInputChange:(m,b)=>i(b),onSearch:d,onBlur:l,onChange:Ro,filterOptions:m=>m,noOptionsText:u||E?"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:!L,empty:jsx(W,{variant:"body2",color:"text.secondary",children:"Nenhum segmento selecionado"}),children:o.map((m,b)=>jsx(Fs,{variant:"outlined",label:m.name,color:"default",onDelete:()=>_r(m),"data-testid":`filter-profile-${b}`},m.id))})})]})})]})},qi=zd;var jd=({status:o,checked:r,onToggle:e})=>{let{label:t,color:a}=v[o];return jsx(bd,{control:jsx(Td,{name:`status-${o}`,checked:r,onChange:e}),label:jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(co,{width:6,height:16,bgcolor:a,borderRadius:1})," ",t]})})},Xi=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(W,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Status de eventos"})}),jsx(c$1,{children:jsx(co,{mt:-1,children:Jd.map(i=>jsx(Xi,{status:i,checked:o.includes(i),onToggle:()=>a(i)},i))})})]})},Ki=Zd;var rl=()=>jsxs(Fragment,{children:[jsx(Wi,{}),jsx(zi,{}),jsx(qi,{}),jsx(Ki,{}),jsx(Ni,{})]}),Ji=rl;var on=styled(co)(({theme:o})=>({flexDirection:"row",alignItems:"center",padding:o.spacing(2.5),gap:o.spacing(1)})),rn=styled(co)(({theme:o})=>({flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:o.spacing(2.5),gap:o.spacing(1)})),he=styled(_s)({flex:1,display:"flex",alignItems:"center",minWidth:0}),tn=styled(he)({justifyContent:"flex-start"}),en=styled(he)({justifyContent:"center"}),an=styled(he)({justifyContent:"flex-end"});var nn={["DAY"]:"Dia",["WEEK"]:"Semana"},pn={["DAY"]:"CALENDAR_TODAY",["WEEK"]:"COLUMNS"};var Se=styled(wn,{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(wn,{variant:"text",startIcon:jsx(a$1,{icon:pn[t]}),endIcon:jsx(a$1,{icon:"ARROW_DOWN_SIMPLE"}),color:"inherit",size:"small",onClick:e,children:nn[t]}),jsxs(a$a,{open:o,onClose:r,disabledArrow:!0,sx:{width:180,p:1},children:[jsx(Se,{variant:"text",startIcon:jsx(a$1,{icon:"CALENDAR_TODAY"}),onClick:()=>i("DAY"),active:t==="DAY",fullWidth:!0,children:"Dia"}),jsx(Se,{variant:"text",startIcon:jsx(a$1,{icon:"COLUMNS"}),onClick:()=>i("WEEK"),active:t==="WEEK",fullWidth:!0,children:"Semana"})]})]})},dn=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 l=i.month()===n.month(),d=i.year()===n.year();return l&&d?`${i.format("DD")} - ${d$1(n.toDate(),"DD [de] MMM [de] YYYY")}`:d?`${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(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$c,{label:"Semana anterior",icon:"CHEVRON_LEFT",color:"inherit",size:"small",onClick:e}),jsx(W,{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 Sl=()=>{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(rn,{children:[jsx(be,{}),jsx(cn,{badgeContent:a,invisible:a===0,color:"primary",children:jsx(a$c,{label:"Filtrar",icon:"FILTER_LIST",color:"inherit",size:"small",onClick:n})})]}):jsxs(on,{children:[jsx(tn,{children:jsx(dn,{})}),jsx(en,{children:jsx(be,{})}),jsx(an,{children:jsx(cn,{badgeContent:a,invisible:a===0,color:"primary",children:jsx(wn,{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(Ji,{})})]})},mn=Sl;var kl=({partners:o$1,summary:r$1,isFetching:e,isFetchingSummary:t,onRowsScrollEnd:a,isFetchingNextPage:i$1})=>{let{dateRange:n$1,scrollRef:l$1}=x(),d=b("down","sm"),y=useMemo(()=>r(n$1.start_date,n$1.end_date),[n$1.start_date,n$1.end_date]),f=useMemo(()=>[{key:l,minWidth:n,defaultWidth:m},...y.map((P,L)=>({key:p(L),minWidth:o}))],[y]),{columnWidths:u,totalWidth:_,isResizing:D,getColumnResizeProps:E}=a$6({columns:f,containerRef:l$1,enabled:!d}),J=useCallback(()=>{let P=l$1.current;if(!P||i$1)return;let{scrollTop:L,scrollHeight:Ro,clientHeight:_r}=P;Ro-L-_r<=i&&a();},[l$1,a,i$1]);return jsxs(Ii,{variant:"outlined",children:[jsx(mn,{}),jsx(Ri,{ref:l$1,onScroll:J,children:jsxs(Ai,{stickyHeader:!0,totalWidth:_,isResizing:D,children:[!!u.length&&jsx("colgroup",{children:u.map((P,L)=>jsx("col",{style:{width:P.width}},L))}),jsx(Xe,{days:y,summary:r$1,isFetchingSummary:t,getColumnResizeProps:E}),jsxs(Oi,{children:[!o$1.length&&jsxs(Ir,{children:[jsx(wo,{}),y.map((P,L)=>jsx(io,{isToday:P.isSame(fe(),"day")},L))]}),o$1.map((P,L)=>jsx(_i,{index:L,partner:P,days:y,isFetching:e},P.external_id)),i$1&&jsx(gn,{children:jsx(Ne,{colSpan:y.length+1,align:"center",sx:{py:2,border:"none"},children:jsx(vl,{size:24})})})]})]})})]})},Dl=kl;
|
|
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;
|
|
59
59
|
|
|
60
|
-
export { Dl as Calendar,
|
|
60
|
+
export { Dl as Calendar, bn as OrderProjectionProvider, c as useOrderProjectionContext, x as useOrderProjectionFilterContext };
|
|
61
61
|
//# sourceMappingURL=index.js.map
|