import { __exports as D } from "./index-_virtual35.js";
import ce from "react";
import { __require as le } from "./index-prop-types.js";
import { __require as pe } from "./index-Calendar.js";
import { __require as de } from "./index-DayCell.js";
import { __require as ge } from "./index-utils7.js";
import ve from "./index-_virtual36.js";
import _e from "./index-_virtual37.js";
import he from "./index-_virtual38.js";
import ye from "./index-_virtual39.js";
import me from "./index-_virtual40.js";
import Re from "./index-_virtual41.js";
import { __require as Oe } from "./index-classnames2.js";
import { __require as we } from "./index-styles.js";
var A;
function Te() {
  if (A) return D;
  A = 1;
  function y(e) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? y = function(r) {
      return typeof r;
    } : y = function(r) {
      return r && typeof Symbol == "function" && r.constructor === Symbol && r !== Symbol.prototype ? "symbol" : typeof r;
    }, y(e);
  }
  Object.defineProperty(D, "__esModule", {
    value: !0
  }), D.default = void 0;
  var W = Y(ce), v = s(/* @__PURE__ */ le()), M = s(pe()), G = de(), q = ge(), H = s(ve), J = s(_e), T = s(he), F = s(ye), L = s(me), j = s(Re), Q = s(Oe()), X = s(we());
  function s(e) {
    return e && e.__esModule ? e : { default: e };
  }
  function B(e) {
    if (typeof WeakMap != "function") return null;
    var t = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap();
    return (B = function(i) {
      return i ? r : t;
    })(e);
  }
  function Y(e, t) {
    if (e && e.__esModule)
      return e;
    if (e === null || y(e) !== "object" && typeof e != "function")
      return { default: e };
    var r = B(t);
    if (r && r.has(e))
      return r.get(e);
    var n = {}, i = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for (var a in e)
      if (a !== "default" && Object.prototype.hasOwnProperty.call(e, a)) {
        var o = i ? Object.getOwnPropertyDescriptor(e, a) : null;
        o && (o.get || o.set) ? Object.defineProperty(n, a, o) : n[a] = e[a];
      }
    return n.default = e, r && r.set(e, n), n;
  }
  function x() {
    return x = Object.assign || function(e) {
      for (var t = 1; t < arguments.length; t++) {
        var r = arguments[t];
        for (var n in r)
          Object.prototype.hasOwnProperty.call(r, n) && (e[n] = r[n]);
      }
      return e;
    }, x.apply(this, arguments);
  }
  function V(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 _(e) {
    for (var t = 1; t < arguments.length; t++) {
      var r = arguments[t] != null ? arguments[t] : {};
      t % 2 ? V(Object(r), !0).forEach(function(n) {
        h(e, n, r[n]);
      }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : V(Object(r)).forEach(function(n) {
        Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
      });
    }
    return e;
  }
  function Z(e, t) {
    if (!(e instanceof t))
      throw new TypeError("Cannot call a class as a function");
  }
  function k(e, t) {
    for (var r = 0; r < t.length; r++) {
      var n = t[r];
      n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n);
    }
  }
  function ee(e, t, r) {
    return t && k(e.prototype, t), e;
  }
  function te(e, t) {
    if (typeof t != "function" && t !== null)
      throw new TypeError("Super expression must either be null or a function");
    e.prototype = Object.create(t && t.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), t && $(e, t);
  }
  function $(e, t) {
    return $ = Object.setPrototypeOf || function(n, i) {
      return n.__proto__ = i, n;
    }, $(e, t);
  }
  function re(e) {
    var t = ae();
    return function() {
      var n = S(e), i;
      if (t) {
        var a = S(this).constructor;
        i = Reflect.construct(n, arguments, a);
      } else
        i = n.apply(this, arguments);
      return ne(this, i);
    };
  }
  function ne(e, t) {
    return t && (y(t) === "object" || typeof t == "function") ? t : m(e);
  }
  function m(e) {
    if (e === void 0)
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return e;
  }
  function ae() {
    if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
    if (typeof Proxy == "function") return !0;
    try {
      return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
      })), !0;
    } catch {
      return !1;
    }
  }
  function S(e) {
    return S = Object.setPrototypeOf ? Object.getPrototypeOf : function(r) {
      return r.__proto__ || Object.getPrototypeOf(r);
    }, S(e);
  }
  function h(e, t, r) {
    return t in e ? Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = r, e;
  }
  var N = /* @__PURE__ */ (function(e) {
    te(r, e);
    var t = re(r);
    function r(n, i) {
      var a;
      return Z(this, r), a = t.call(this, n, i), h(m(a), "calcNewSelection", function(o) {
        var p = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, f = a.props.focusedRange || a.state.focusedRange, c = a.props, R = c.ranges, d = c.onChange, g = c.maxDate, P = c.moveRangeOnFirstSelection, O = c.retainEndDateOnFirstSelection, w = c.disabledDates, ie = f[0], E = R[ie];
        if (!E || !d) return {};
        var l = E.startDate, u = E.endDate, z = /* @__PURE__ */ new Date(), b;
        if (!p)
          l = o.startDate, u = o.endDate;
        else if (f[1] === 0) {
          var ue = (0, L.default)(u || z, l), fe = function() {
            return P ? (0, F.default)(o, ue) : O ? !u || (0, j.default)(o, u) ? u : o : o || z;
          };
          l = o, u = fe(), g && (u = (0, T.default)([u, g])), b = [f[0], 1];
        } else
          u = o;
        var I = f[1] === 0;
        if ((0, j.default)(u, l)) {
          I = !I;
          var K = [u, l];
          l = K[0], u = K[1];
        }
        var C = w.filter(function(U) {
          return (0, J.default)(U, {
            start: l,
            end: u
          });
        });
        if (C.length > 0 && (I ? l = (0, F.default)((0, H.default)(C), 1) : u = (0, F.default)((0, T.default)(C), -1)), !b) {
          var se = (0, q.findNextRangeIndex)(a.props.ranges, f[0]);
          b = [se, 0];
        }
        return {
          wasValid: !(C.length > 0),
          range: {
            startDate: l,
            endDate: u
          },
          nextFocusRange: b
        };
      }), h(m(a), "setSelection", function(o, p) {
        var f = a.props, c = f.onChange, R = f.ranges, d = f.onRangeFocusChange, g = a.props.focusedRange || a.state.focusedRange, P = g[0], O = R[P];
        if (O) {
          var w = a.calcNewSelection(o, p);
          c(h({}, O.key || "range".concat(P + 1), _(_({}, O), w.range))), a.setState({
            focusedRange: w.nextFocusRange,
            preview: null
          }), d && d(w.nextFocusRange);
        }
      }), h(m(a), "handleRangeFocusChange", function(o) {
        a.setState({
          focusedRange: o
        }), a.props.onRangeFocusChange && a.props.onRangeFocusChange(o);
      }), h(m(a), "updatePreview", function(o) {
        var p;
        if (!o) {
          a.setState({
            preview: null
          });
          return;
        }
        var f = a.props, c = f.rangeColors, R = f.ranges, d = a.props.focusedRange || a.state.focusedRange, g = ((p = R[d[0]]) === null || p === void 0 ? void 0 : p.color) || c[d[0]] || g;
        a.setState({
          preview: _(_({}, o.range), {}, {
            color: g
          })
        });
      }), a.state = {
        focusedRange: n.initialFocusedRange || [(0, q.findNextRangeIndex)(n.ranges), 0],
        preview: null
      }, a.styles = (0, q.generateStyles)([X.default, n.classNames]), a;
    }
    return ee(r, [{
      key: "render",
      value: function() {
        var i = this;
        return /* @__PURE__ */ W.default.createElement(M.default, x({
          focusedRange: this.state.focusedRange,
          onRangeFocusChange: this.handleRangeFocusChange,
          preview: this.state.preview,
          onPreviewChange: function(o) {
            i.updatePreview(o ? i.calcNewSelection(o) : null);
          }
        }, this.props, {
          displayMode: "dateRange",
          className: (0, Q.default)(this.styles.dateRangeWrapper, this.props.className),
          onChange: this.setSelection,
          updateRange: function(o) {
            return i.setSelection(o, !1);
          },
          ref: function(o) {
            i.calendar = o;
          }
        }));
      }
    }]), r;
  })(W.Component);
  N.defaultProps = {
    classNames: {},
    ranges: [],
    moveRangeOnFirstSelection: !1,
    retainEndDateOnFirstSelection: !1,
    rangeColors: ["#3d91ff", "#3ecf8e", "#fed14c"],
    disabledDates: []
  }, N.propTypes = _(_({}, M.default.propTypes), {}, {
    onChange: v.default.func,
    onRangeFocusChange: v.default.func,
    className: v.default.string,
    ranges: v.default.arrayOf(G.rangeShape),
    moveRangeOnFirstSelection: v.default.bool,
    retainEndDateOnFirstSelection: v.default.bool
  });
  var oe = N;
  return D.default = oe, D;
}
export {
  Te as __require
};
