import { __exports as h } from "./index-_virtual60.js";
import U from "react";
import { __require as X } from "./index-prop-types.js";
import { __require as Y } from "./index-styles.js";
import { __require as Z } from "./index-defaultRanges.js";
import { __require as ee } from "./index-DayCell.js";
import { __require as te } from "./index-InputRangeField.js";
import { __require as ne } from "./index-classnames2.js";
var M;
function se() {
  if (M) return h;
  M = 1;
  function y(e) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? y = function(n) {
      return typeof n;
    } : y = function(n) {
      return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
    }, y(e);
  }
  Object.defineProperty(h, "__esModule", {
    value: !0
  }), h.default = void 0;
  var s = k(U), i = v(/* @__PURE__ */ X()), p = v(Y()), q = Z(), $ = ee(), W = v(te()), D = v(ne());
  function v(e) {
    return e && e.__esModule ? e : { default: e };
  }
  function I(e) {
    if (typeof WeakMap != "function") return null;
    var t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap();
    return (I = function(a) {
      return a ? n : t;
    })(e);
  }
  function k(e, t) {
    if (e && e.__esModule)
      return e;
    if (e === null || y(e) !== "object" && typeof e != "function")
      return { default: e };
    var n = I(t);
    if (n && n.has(e))
      return n.get(e);
    var r = {}, a = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for (var u in e)
      if (u !== "default" && Object.prototype.hasOwnProperty.call(e, u)) {
        var o = a ? Object.getOwnPropertyDescriptor(e, u) : null;
        o && (o.get || o.set) ? Object.defineProperty(r, u, o) : r[u] = e[u];
      }
    return r.default = e, n && n.set(e, r), r;
  }
  function E(e, t) {
    var n = Object.keys(e);
    if (Object.getOwnPropertySymbols) {
      var r = Object.getOwnPropertySymbols(e);
      t && (r = r.filter(function(a) {
        return Object.getOwnPropertyDescriptor(e, a).enumerable;
      })), n.push.apply(n, r);
    }
    return n;
  }
  function N(e) {
    for (var t = 1; t < arguments.length; t++) {
      var n = arguments[t] != null ? arguments[t] : {};
      t % 2 ? E(Object(n), !0).forEach(function(r) {
        O(e, r, n[r]);
      }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : E(Object(n)).forEach(function(r) {
        Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(n, r));
      });
    }
    return e;
  }
  function B(e, t) {
    if (!(e instanceof t))
      throw new TypeError("Cannot call a class as a function");
  }
  function F(e, t) {
    for (var n = 0; n < t.length; n++) {
      var r = t[n];
      r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r);
    }
  }
  function L(e, t, n) {
    return t && F(e.prototype, t), e;
  }
  function T(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 && P(e, t);
  }
  function P(e, t) {
    return P = Object.setPrototypeOf || function(r, a) {
      return r.__proto__ = a, r;
    }, P(e, t);
  }
  function V(e) {
    var t = z();
    return function() {
      var r = m(e), a;
      if (t) {
        var u = m(this).constructor;
        a = Reflect.construct(r, arguments, u);
      } else
        a = r.apply(this, arguments);
      return j(this, a);
    };
  }
  function j(e, t) {
    return t && (y(t) === "object" || typeof t == "function") ? t : x(e);
  }
  function x(e) {
    if (e === void 0)
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return e;
  }
  function z() {
    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 m(e) {
    return m = Object.setPrototypeOf ? Object.getPrototypeOf : function(n) {
      return n.__proto__ || Object.getPrototypeOf(n);
    }, m(e);
  }
  function O(e, t, n) {
    return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e;
  }
  var C = /* @__PURE__ */ (function(e) {
    T(n, e);
    var t = V(n);
    function n(r) {
      var a;
      return B(this, n), a = t.call(this, r), O(x(a), "handleRangeChange", function(u) {
        var o = a.props, c = o.onChange, f = o.ranges, g = o.focusedRange, d = f[g[0]];
        !c || !d || c(O({}, d.key || "range".concat(g[0] + 1), N(N({}, d), u)));
      }), a.state = {
        rangeOffset: 0,
        focusedInput: -1
      }, a;
    }
    return L(n, [{
      key: "getRangeOptionValue",
      value: function(a) {
        var u = this.props, o = u.ranges, c = o === void 0 ? [] : o, f = u.focusedRange, g = f === void 0 ? [] : f;
        if (typeof a.getCurrentValue != "function")
          return "";
        var d = c[g[0]] || {};
        return a.getCurrentValue(d) || "";
      }
    }, {
      key: "getSelectedRange",
      value: function(a, u) {
        var o = a.findIndex(function(f) {
          return !f.startDate || !f.endDate || f.disabled ? !1 : u.isSelected(f);
        }), c = a[o];
        return {
          selectedRange: c,
          focusedRangeIndex: o
        };
      }
    }, {
      key: "render",
      value: function() {
        var a = this, u = this.props, o = u.headerContent, c = u.footerContent, f = u.onPreviewChange, g = u.inputRanges, d = u.staticRanges, A = u.ranges, G = u.renderStaticRangeLabel, H = u.rangeColors, J = u.className;
        return /* @__PURE__ */ s.default.createElement("div", {
          className: (0, D.default)(p.default.definedRangesWrapper, J)
        }, o, /* @__PURE__ */ s.default.createElement("div", {
          className: p.default.staticRanges
        }, d.map(function(l, b) {
          var _ = a.getSelectedRange(A, l), R = _.selectedRange, Q = _.focusedRangeIndex, S;
          return l.hasCustomRendering ? S = G(l) : S = l.label, /* @__PURE__ */ s.default.createElement("button", {
            type: "button",
            className: (0, D.default)(p.default.staticRange, O({}, p.default.staticRangeSelected, !!R)),
            style: {
              color: R ? R.color || H[Q] : null
            },
            key: b,
            onClick: function() {
              return a.handleRangeChange(l.range(a.props));
            },
            onFocus: function() {
              return f && f(l.range(a.props));
            },
            onMouseOver: function() {
              return f && f(l.range(a.props));
            },
            onMouseLeave: function() {
              f && f();
            }
          }, /* @__PURE__ */ s.default.createElement("span", {
            tabIndex: -1,
            className: p.default.staticRangeLabel
          }, S));
        })), /* @__PURE__ */ s.default.createElement("div", {
          className: p.default.inputRanges
        }, g.map(function(l, b) {
          return /* @__PURE__ */ s.default.createElement(W.default, {
            key: b,
            styles: p.default,
            label: l.label,
            onFocus: function() {
              return a.setState({
                focusedInput: b,
                rangeOffset: 0
              });
            },
            onBlur: function() {
              return a.setState({
                rangeOffset: 0
              });
            },
            onChange: function(R) {
              return a.handleRangeChange(l.range(R, a.props));
            },
            value: a.getRangeOptionValue(l)
          });
        })), c);
      }
    }]), n;
  })(s.Component);
  C.propTypes = {
    inputRanges: i.default.array,
    staticRanges: i.default.array,
    ranges: i.default.arrayOf($.rangeShape),
    focusedRange: i.default.arrayOf(i.default.number),
    onPreviewChange: i.default.func,
    onChange: i.default.func,
    footerContent: i.default.any,
    headerContent: i.default.any,
    rangeColors: i.default.arrayOf(i.default.string),
    className: i.default.string,
    renderStaticRangeLabel: i.default.func
  }, C.defaultProps = {
    inputRanges: q.defaultInputRanges,
    staticRanges: q.defaultStaticRanges,
    ranges: [],
    rangeColors: ["#3d91ff", "#3ecf8e", "#fed14c"],
    focusedRange: [0, 0]
  };
  var K = C;
  return h.default = K, h;
}
export {
  se as __require
};
