"use strict";(self.webpackChunkcomplianz_gdpr=self.webpackChunkcomplianz_gdpr||[]).push([[7660],{95279:(e,t,a)=>{a.r(t),a.d(t,{default:()=>z});var n=a(51609),l=a(86087),d=a(59402),r=a(30020),s=a(1806),o=a(31127),u=a(66212),c=a(92998),i=a(20543),D=a(2118),f=a(19312),m=a(17054),y=a(49317),p=a(53039),g=a(81810),w=a(72346),h=a(45111),b=a(27723),_=a(38432);const z=()=>{const[e,t]=(0,l.useState)(null),a=Boolean(e),z=(0,_.default)((e=>e.startDate)),M=(0,_.default)((e=>e.endDate)),E=(0,_.default)((e=>e.setStartDate)),k=(0,_.default)((e=>e.setEndDate)),v=(0,_.default)((e=>e.range)),A=(0,_.default)((e=>e.setRange)),C={startDate:(0,s.A)(z),endDate:(0,s.A)(M),key:"selection"},S=(0,l.useRef)(0),L=["today","yesterday","last-7-days","last-30-days","last-90-days","last-month","last-year","year-to-date"],O={today:{label:(0,b.__)("Today","complianz-gdpr"),range:()=>({startDate:(0,o.default)(new Date),endDate:(0,u.default)(new Date)})},yesterday:{label:(0,b.__)("Yesterday","complianz-gdpr"),range:()=>({startDate:(0,o.default)((0,c.default)(new Date,-1)),endDate:(0,u.default)((0,c.default)(new Date,-1))})},"last-7-days":{label:(0,b.__)("Last 7 days","complianz-gdpr"),range:()=>({startDate:(0,o.default)((0,c.default)(new Date,-7)),endDate:(0,u.default)((0,c.default)(new Date,-1))})},"last-30-days":{label:(0,b.__)("Last 30 days","complianz-gdpr"),range:()=>({startDate:(0,o.default)((0,c.default)(new Date,-30)),endDate:(0,u.default)((0,c.default)(new Date,-1))})},"last-90-days":{label:(0,b.__)("Last 90 days","complianz-gdpr"),range:()=>({startDate:(0,o.default)((0,c.default)(new Date,-90)),endDate:(0,u.default)((0,c.default)(new Date,-1))})},"last-month":{label:(0,b.__)("Last month","complianz-gdpr"),range:()=>({startDate:(0,i.default)((0,D.default)(new Date,-1)),endDate:(0,f.default)((0,D.default)(new Date,-1))})},"year-to-date":{label:(0,b.__)("Year to date","complianz-gdpr"),range:()=>({startDate:(0,m.A)(new Date),endDate:(0,u.default)(new Date)})},"last-year":{label:(0,b.__)("Last year","complianz-gdpr"),range:()=>({startDate:(0,m.A)((0,y.default)(new Date,-1)),endDate:(0,p.A)((0,y.default)(new Date,-1))})}};function R(e){const t=this.range();return(0,g.default)(e.startDate,t.startDate)&&(0,g.default)(e.endDate,t.endDate)}const j=[];for(const[e,t]of Object.entries(L))t&&(j.push(O[t]),j[j.length-1].isSelected=R);const F=e=>{t(null)},N="MMMM d, yyyy",T=z?(0,w.default)(new Date(z),N):(0,w.default)(defaultStart,N),Y=M?(0,w.default)(new Date(M),N):(0,w.default)(defaultEnd,N);return(0,n.createElement)("div",{className:"cmplz-date-range-container"},(0,n.createElement)("button",{onClick:e=>{t(e.currentTarget)},id:"cmplz-date-range-picker-open-button"},(0,n.createElement)(h.default,{name:"calendar",size:"18"}),"custom"===v&&T+" - "+Y,"custom"!==v&&O[v].label,(0,n.createElement)(h.default,{name:"chevron-down"})),(0,n.createElement)(d.Ay,{anchorEl:e,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},open:a,onClose:F,className:"burst"},(0,n.createElement)("div",{id:"cmplz-date-range-picker-container"},(0,n.createElement)(r.Ur,{ranges:[C],rangeColors:["var(--rsp-brand-primary)"],dateDisplayFormat:N,monthDisplayFormat:"MMMM",onChange:e=>{(e=>{S.current++;let t=(0,w.default)(e.selection.startDate,"yyyy-MM-dd"),a=(0,w.default)(e.selection.endDate,"yyyy-MM-dd"),n="custom";for(const[t,a]of Object.entries(O))a.isSelected(e.selection)&&(n=t);e.selection.startDate,e.selection.endDate,2!==S.current&&t===a&&"custom"===n||(S.current=0,E(t),k(a),A(n),F())})(e)},inputRanges:[],showSelectionPreview:!0,months:2,direction:"horizontal",minDate:new Date(2022,0,1),maxDate:new Date,staticRanges:j}))))}}}]);