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