"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _react = require('react'); var _react2 = _interopRequireDefault(_react);var _material = require('@mui/material');var _xdatepickers = require('@mui/x-date-pickers');var _AdapterLuxon = require('@mui/x-date-pickers/AdapterLuxon');var _DatePicker = require('@mui/x-date-pickers/DatePicker');var _jsxruntime = require('react/jsx-runtime');function p(e){"@babel/helpers - typeof";return p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(e)}function P(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function A(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?P(Object(r),!0).forEach(function(n){M(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):P(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function M(e,t,r){return(t=B(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function B(e){var t=K(e,"string");return p(t)=="symbol"?t:t+""}function K(e,t){if(p(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(p(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function v(e,t){return U(e)||N(e,t)||H(e,t)||z()}function z(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function H(e,t){if(e){if(typeof e=="string")return F(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?F(e,t):void 0}}function F(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function N(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,i,d,u,f=[],c=!0,a=!1;try{if(d=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=d.call(r)).done)&&(f.push(n.value),f.length!==t);c=!0);}catch(y){a=!0,i=y}finally{try{if(!c&&r.return!=null&&(u=r.return(),Object(u)!==u))return}finally{if(a)throw i}}return f}}function U(e){if(Array.isArray(e))return e}var q=function(t){var r=t.createdFrom,n=t.createdTo,i=t.executeRefetch,d=t.onApply,u=t.onClearFilter,f=_react.useState.call(void 0, _nullishCoalesce(r, () => (null))),c=v(f,2),a=c[0],y=c[1],E=_react.useState.call(void 0, _nullishCoalesce(n, () => (null))),S=v(E,2),s=S[0],j=S[1],k=_react.useState.call(void 0, null),O=v(k,2),D=O[0],b=O[1],I=_react2.default.useMemo(function(){switch(D){case"minDate":return"End date cannot be earlier than start date.";case"invalidDate":return"Your date is not valid";default:return""}},[D]),L=function(){if(s&&a&&s<a){b("minDate");return}b(null),i({createdFrom:a?a.toISODate():null,createdTo:s?s.toISODate():null}),_optionalChain([d, 'optionalCall', _2 => _2()])},R=function(){(r||n)&&i({createdFrom:null,createdTo:null}),y(null),j(null),_optionalChain([u, 'optionalCall', _3 => _3()])},C=function(o){return s?o>s:!1},x=function(o){return a?o<a:!1};return _jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",gap:2,flexDirection:"column",children:[_jsxruntime.jsxs.call(void 0, _xdatepickers.LocalizationProvider,{dateAdapter:_AdapterLuxon.AdapterLuxon,children:[_jsxruntime.jsx.call(void 0, _DatePicker.DatePicker,{label:"Start date",onChange:function(o){return y(o)},disableFuture:!0,value:a,shouldDisableDate:C,slotProps:{day:function(o){return{sx:A({},C(o.day)&&{backgroundColor:"error.lighter"})}}}}),_jsxruntime.jsx.call(void 0, _DatePicker.DatePicker,{label:"End date",value:s,onChange:function(o){return j(o)},onError:function(o){return b(o)},disableFuture:!0,shouldDisableDate:x,slotProps:{textField:{helperText:I},day:function(o){return{sx:A({},x(o.day)&&{backgroundColor:"error.lighter"})}}}})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",gap:2,flexDirection:"column",mt:4,mb:2,children:[_jsxruntime.jsx.call(void 0, _material.Button,{onClick:L,variant:"contained",color:"inherit",children:"Filter"}),_jsxruntime.jsx.call(void 0, _material.Button,{onClick:R,variant:"outlined",color:"inherit",children:"Clear Filter"})]})]})},ee= exports.a =q;exports.a = ee;
//# sourceMappingURL=chunk-6XV3AQ6Y.js.map