UNPKG

welcome-ui

Version:

Customizable design system with react, typescript, tailwindcss and ariakit.

1,073 lines (1,072 loc) 45 kB
"use client"; import { P as n, a as ve } from "./tslib.es6-CKhMT3k3.js"; import { cloneElement as et, Component as tt } from "react"; function Z(t, o) { if (t == null) return {}; var r = {}; for (var s in t) if ({}.hasOwnProperty.call(t, s)) { if (o.indexOf(s) !== -1) continue; r[s] = t[s]; } return r; } function M() { return M = Object.assign ? Object.assign.bind() : function(t) { for (var o = 1; o < arguments.length; o++) { var r = arguments[o]; for (var s in r) ({}).hasOwnProperty.call(r, s) && (t[s] = r[s]); } return t; }, M.apply(null, arguments); } function me(t) { if (t === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return t; } function pe(t, o) { return pe = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(r, s) { return r.__proto__ = s, r; }, pe(t, o); } function nt(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, pe(t, o); } var ie = { exports: {} }, O = {}, Ee; function ot() { if (Ee) return O; Ee = 1; var t = 60103, o = 60106, r = 60107, s = 60108, d = 60114, e = 60109, l = 60110, v = 60112, y = 60113, C = 60120, S = 60115, N = 60116, V = 60121, P = 60122, b = 60117, H = 60129, T = 60131; if (typeof Symbol == "function" && Symbol.for) { var f = Symbol.for; t = f("react.element"), o = f("react.portal"), r = f("react.fragment"), s = f("react.strict_mode"), d = f("react.profiler"), e = f("react.provider"), l = f("react.context"), v = f("react.forward_ref"), y = f("react.suspense"), C = f("react.suspense_list"), S = f("react.memo"), N = f("react.lazy"), V = f("react.block"), P = f("react.server.block"), b = f("react.fundamental"), H = f("react.debug_trace_mode"), T = f("react.legacy_hidden"); } function i(a) { if (typeof a == "object" && a !== null) { var R = a.$$typeof; switch (R) { case t: switch (a = a.type, a) { case r: case d: case s: case y: case C: return a; default: switch (a = a && a.$$typeof, a) { case l: case v: case N: case S: case e: return a; default: return R; } } case o: return R; } } } var c = e, u = t, _ = v, m = r, E = N, g = S, h = o, I = d, w = s, x = y; return O.ContextConsumer = l, O.ContextProvider = c, O.Element = u, O.ForwardRef = _, O.Fragment = m, O.Lazy = E, O.Memo = g, O.Portal = h, O.Profiler = I, O.StrictMode = w, O.Suspense = x, O.isAsyncMode = function() { return !1; }, O.isConcurrentMode = function() { return !1; }, O.isContextConsumer = function(a) { return i(a) === l; }, O.isContextProvider = function(a) { return i(a) === e; }, O.isElement = function(a) { return typeof a == "object" && a !== null && a.$$typeof === t; }, O.isForwardRef = function(a) { return i(a) === v; }, O.isFragment = function(a) { return i(a) === r; }, O.isLazy = function(a) { return i(a) === N; }, O.isMemo = function(a) { return i(a) === S; }, O.isPortal = function(a) { return i(a) === o; }, O.isProfiler = function(a) { return i(a) === d; }, O.isStrictMode = function(a) { return i(a) === s; }, O.isSuspense = function(a) { return i(a) === y; }, O.isValidElementType = function(a) { return typeof a == "string" || typeof a == "function" || a === r || a === d || a === H || a === s || a === y || a === C || a === T || typeof a == "object" && a !== null && (a.$$typeof === N || a.$$typeof === S || a.$$typeof === e || a.$$typeof === l || a.$$typeof === v || a.$$typeof === b || a.$$typeof === V || a[0] === P); }, O.typeOf = i, O; } var D = {}, Ie; function rt() { return Ie || (Ie = 1, process.env.NODE_ENV !== "production" && function() { var t = 60103, o = 60106, r = 60107, s = 60108, d = 60114, e = 60109, l = 60110, v = 60112, y = 60113, C = 60120, S = 60115, N = 60116, V = 60121, P = 60122, b = 60117, H = 60129, T = 60131; if (typeof Symbol == "function" && Symbol.for) { var f = Symbol.for; t = f("react.element"), o = f("react.portal"), r = f("react.fragment"), s = f("react.strict_mode"), d = f("react.profiler"), e = f("react.provider"), l = f("react.context"), v = f("react.forward_ref"), y = f("react.suspense"), C = f("react.suspense_list"), S = f("react.memo"), N = f("react.lazy"), V = f("react.block"), P = f("react.server.block"), b = f("react.fundamental"), f("react.scope"), f("react.opaque.id"), H = f("react.debug_trace_mode"), f("react.offscreen"), T = f("react.legacy_hidden"); } var i = !1; function c(p) { return !!(typeof p == "string" || typeof p == "function" || p === r || p === d || p === H || p === s || p === y || p === C || p === T || i || typeof p == "object" && p !== null && (p.$$typeof === N || p.$$typeof === S || p.$$typeof === e || p.$$typeof === l || p.$$typeof === v || p.$$typeof === b || p.$$typeof === V || p[0] === P)); } function u(p) { if (typeof p == "object" && p !== null) { var F = p.$$typeof; switch (F) { case t: var re = p.type; switch (re) { case r: case d: case s: case y: case C: return re; default: var he = re && re.$$typeof; switch (he) { case l: case v: case N: case S: case e: return he; default: return F; } } case o: return F; } } } var _ = l, m = e, E = t, g = v, h = r, I = N, w = S, x = o, a = d, R = s, A = y, B = !1, Y = !1; function ee(p) { return B || (B = !0, console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")), !1; } function W(p) { return Y || (Y = !0, console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")), !1; } function U(p) { return u(p) === l; } function j(p) { return u(p) === e; } function G(p) { return typeof p == "object" && p !== null && p.$$typeof === t; } function q(p) { return u(p) === v; } function X(p) { return u(p) === r; } function k(p) { return u(p) === N; } function $(p) { return u(p) === S; } function z(p) { return u(p) === o; } function te(p) { return u(p) === d; } function ne(p) { return u(p) === s; } function oe(p) { return u(p) === y; } D.ContextConsumer = _, D.ContextProvider = m, D.Element = E, D.ForwardRef = g, D.Fragment = h, D.Lazy = I, D.Memo = w, D.Portal = x, D.Profiler = a, D.StrictMode = R, D.Suspense = A, D.isAsyncMode = ee, D.isConcurrentMode = W, D.isContextConsumer = U, D.isContextProvider = j, D.isElement = G, D.isForwardRef = q, D.isFragment = X, D.isLazy = k, D.isMemo = $, D.isPortal = z, D.isProfiler = te, D.isStrictMode = ne, D.isSuspense = oe, D.isValidElementType = c, D.typeOf = u; }()), D; } var ye; function it() { return ye || (ye = 1, process.env.NODE_ENV === "production" ? ie.exports = ot() : ie.exports = rt()), ie.exports; } var we = it(); let Ne = (t) => typeof t == "object" && t != null && t.nodeType === 1, Oe = (t, o) => (!o || t !== "hidden") && t !== "visible" && t !== "clip", le = (t, o) => { if (t.clientHeight < t.scrollHeight || t.clientWidth < t.scrollWidth) { let r = getComputedStyle(t, null); return Oe(r.overflowY, o) || Oe(r.overflowX, o) || ((s) => { let d = ((e) => { if (!e.ownerDocument || !e.ownerDocument.defaultView) return null; try { return e.ownerDocument.defaultView.frameElement; } catch { return null; } })(s); return !!d && (d.clientHeight < s.scrollHeight || d.clientWidth < s.scrollWidth); })(t); } return !1; }, se = (t, o, r, s, d, e, l, v) => e < t && l > o || e > t && l < o ? 0 : e <= t && v <= r || l >= o && v >= r ? e - t - s : l > o && v < r || e < t && v > r ? l - o + d : 0, st = (t) => { let o = t.parentElement; return o ?? (t.getRootNode().host || null); }; var ut = (t, o) => { var r, s, d, e, l, v; if (typeof document > "u") return []; let { inline: y, boundary: C, skipOverflowHiddenElements: S } = o, N = typeof C == "function" ? C : (x) => x !== C; if (!Ne(t)) throw new TypeError("Invalid target"); let V = document.scrollingElement || document.documentElement, P = [], b = t; for (; Ne(b) && N(b); ) { if (b = st(b), b === V) { P.push(b); break; } b != null && b === document.body && le(b) && !le(document.documentElement) || b != null && le(b, S) && P.push(b); } let H = (s = (r = window.visualViewport) == null ? void 0 : r.width) != null ? s : innerWidth, T = (e = (d = window.visualViewport) == null ? void 0 : d.height) != null ? e : innerHeight, f = (l = window.scrollX) != null ? l : pageXOffset, i = (v = window.scrollY) != null ? v : pageYOffset, { height: c, width: u, top: _, right: m, bottom: E, left: g } = t.getBoundingClientRect(), h = _, I = y === "center" ? g + u / 2 : y === "end" ? m : g, w = []; for (let x = 0; x < P.length; x++) { let a = P[x], { height: R, width: A, top: B, right: Y, bottom: ee, left: W } = a.getBoundingClientRect(); if (_ >= 0 && g >= 0 && E <= T && m <= H && _ >= B && E <= ee && g >= W && m <= Y) return w; let U = getComputedStyle(a), j = parseInt(U.borderLeftWidth, 10), G = parseInt(U.borderTopWidth, 10), q = parseInt(U.borderRightWidth, 10), X = parseInt(U.borderBottomWidth, 10), k = 0, $ = 0, z = "offsetWidth" in a ? a.offsetWidth - a.clientWidth - j - q : 0, te = "offsetHeight" in a ? a.offsetHeight - a.clientHeight - G - X : 0, ne = "offsetWidth" in a ? a.offsetWidth === 0 ? 0 : A / a.offsetWidth : 0, oe = "offsetHeight" in a ? a.offsetHeight === 0 ? 0 : R / a.offsetHeight : 0; if (V === a) k = se(i, i + T, T, G, X, i + h, i + h + c, c), $ = y === "start" ? I : y === "center" ? I - H / 2 : y === "end" ? I - H : se(f, f + H, H, j, q, f + I, f + I + u, u), k = Math.max(0, k + i), $ = Math.max(0, $ + f); else { k = se(B, ee, R, G, X + te, h, h + c, c), $ = y === "start" ? I - W - j : y === "center" ? I - (W + A / 2) + z / 2 : y === "end" ? I - Y + q + z : se(W, Y, A, j, q + z, I, I + u, u); let { scrollLeft: p, scrollTop: F } = a; k = Math.max(0, Math.min(F + k / oe, a.scrollHeight - R / oe + te)), $ = Math.max(0, Math.min(p + $ / ne, a.scrollWidth - A / ne + z)), h += F - k, I += p - $; } w.push({ el: a, top: k, left: $ }); } return w; }, at = 0; function De(t) { return typeof t == "function" ? t : L; } function L() { } function Pe(t, o) { if (t) { var r = ut(t, { boundary: o }); r.forEach(function(s) { var d = s.el, e = s.top, l = s.left; d.scrollTop = e, d.scrollLeft = l; }); } } function be(t, o, r) { var s = t === o || o instanceof r.Node && t.contains && t.contains(o); return s; } function ge(t, o) { var r; function s() { r && clearTimeout(r); } function d() { for (var e = arguments.length, l = new Array(e), v = 0; v < e; v++) l[v] = arguments[v]; s(), r = setTimeout(function() { r = null, t.apply(void 0, l); }, o); } return d.cancel = s, d; } function K() { for (var t = arguments.length, o = new Array(t), r = 0; r < t; r++) o[r] = arguments[r]; return function(s) { for (var d = arguments.length, e = new Array(d > 1 ? d - 1 : 0), l = 1; l < d; l++) e[l - 1] = arguments[l]; return o.some(function(v) { return v && v.apply(void 0, [s].concat(e)), s.preventDownshiftDefault || s.hasOwnProperty("nativeEvent") && s.nativeEvent.preventDownshiftDefault; }); }; } function Se() { for (var t = arguments.length, o = new Array(t), r = 0; r < t; r++) o[r] = arguments[r]; return function(s) { o.forEach(function(d) { typeof d == "function" ? d(s) : d && (d.current = s); }); }; } function ct() { return String(at++); } function Me(t) { var o = t.isOpen, r = t.resultCount, s = t.previousResultCount; return o ? r ? r !== s ? r + " result" + (r === 1 ? " is" : "s are") + " available, use up and down arrow keys to navigate. Press Enter key to select." : "" : "No results are available." : ""; } function Ce(t, o) { return t = Array.isArray(t) ? ( /* istanbul ignore next (preact) */ t[0] ) : t, !t && o ? o : t; } function He(t) { return typeof t.type == "string"; } function Ae(t) { return t.props; } function lt(t, o) { console.error('The property "' + o + '" is required in "' + t + '"'); } var dt = ["highlightedIndex", "inputValue", "isOpen", "selectedItem", "type"]; function ue(t) { t === void 0 && (t = {}); var o = {}; return dt.forEach(function(r) { t.hasOwnProperty(r) && (o[r] = t[r]); }), o; } function pt(t, o) { return Object.keys(t).reduce(function(r, s) { return r[s] = fe(o, s) ? o[s] : t[s], r; }, {}); } function fe(t, o) { return t[o] !== void 0; } function Ve(t) { var o = t.key, r = t.keyCode; return r >= 37 && r <= 40 && o.indexOf("Arrow") !== 0 ? "Arrow" + o : o; } function ft(t) { return Object.prototype.toString.call(t) === "[object Object]"; } function de(t, o, r, s, d) { if (d === void 0 && (d = !0), r === 0) return -1; var e = r - 1; (typeof o != "number" || o < 0 || o >= r) && (o = t > 0 ? -1 : e + 1); var l = o + t; l < 0 ? l = d ? e : 0 : l > e && (l = d ? 0 : e); var v = Q(t, l, r, s, d); return v === -1 ? o >= r ? -1 : o : v; } function Q(t, o, r, s, d) { var e = s(o); if (!e || !e.hasAttribute("disabled")) return o; if (t > 0) { for (var l = o + 1; l < r; l++) if (!s(l).hasAttribute("disabled")) return l; } else for (var v = o - 1; v >= 0; v--) if (!s(v).hasAttribute("disabled")) return v; return d ? t > 0 ? Q(1, 0, r, s, !1) : Q(-1, r - 1, r, s, !1) : -1; } function xe(t, o, r, s) { return s === void 0 && (s = !0), o.some(function(d) { return d && (be(d, t, r) || s && be(d, r.document.activeElement, r)); }); } var Te = L; process.env.NODE_ENV !== "production" && (Te = function(o, r, s) { var d = "This prop should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled Downshift element for the lifetime of the component. More info: https://github.com/downshift-js/downshift#control-props"; Object.keys(o).forEach(function(e) { r[e] !== void 0 && s[e] === void 0 ? console.error('downshift: A component has changed the controlled prop "' + e + '" to be uncontrolled. ' + d) : r[e] === void 0 && s[e] !== void 0 && console.error('downshift: A component has changed the uncontrolled prop "' + e + '" to be controlled. ' + d); }); }); var _t = ge(function(t) { $e(t).textContent = ""; }, 500); function ke(t, o) { var r = $e(o); t && (r.textContent = t, _t(o)); } function $e(t) { t === void 0 && (t = document); var o = t.getElementById("a11y-status-message"); return o || (o = t.createElement("div"), o.setAttribute("id", "a11y-status-message"), o.setAttribute("role", "status"), o.setAttribute("aria-live", "polite"), o.setAttribute("aria-relevant", "additions text"), Object.assign(o.style, { border: "0", clip: "rect(0 0 0 0)", height: "1px", margin: "-1px", overflow: "hidden", padding: "0", position: "absolute", width: "1px" }), t.body.appendChild(o), o); } var Ke = process.env.NODE_ENV !== "production" ? "__autocomplete_unknown__" : 0, Le = process.env.NODE_ENV !== "production" ? "__autocomplete_mouseup__" : 1, Be = process.env.NODE_ENV !== "production" ? "__autocomplete_item_mouseenter__" : 2, ae = process.env.NODE_ENV !== "production" ? "__autocomplete_keydown_arrow_up__" : 3, ce = process.env.NODE_ENV !== "production" ? "__autocomplete_keydown_arrow_down__" : 4, Ye = process.env.NODE_ENV !== "production" ? "__autocomplete_keydown_escape__" : 5, We = process.env.NODE_ENV !== "production" ? "__autocomplete_keydown_enter__" : 6, Ue = process.env.NODE_ENV !== "production" ? "__autocomplete_keydown_home__" : 7, je = process.env.NODE_ENV !== "production" ? "__autocomplete_keydown_end__" : 8, qe = process.env.NODE_ENV !== "production" ? "__autocomplete_click_item__" : 9, ze = process.env.NODE_ENV !== "production" ? "__autocomplete_blur_input__" : 10, Fe = process.env.NODE_ENV !== "production" ? "__autocomplete_change_input__" : 11, Ge = process.env.NODE_ENV !== "production" ? "__autocomplete_keydown_space_button__" : 12, _e = process.env.NODE_ENV !== "production" ? "__autocomplete_click_button__" : 13, Xe = process.env.NODE_ENV !== "production" ? "__autocomplete_blur_button__" : 14, Ze = process.env.NODE_ENV !== "production" ? "__autocomplete_controlled_prop_updated_selected_item__" : 15, Je = process.env.NODE_ENV !== "production" ? "__autocomplete_touchend__" : 16, gt = /* @__PURE__ */ Object.freeze({ __proto__: null, unknown: Ke, mouseUp: Le, itemMouseEnter: Be, keyDownArrowUp: ae, keyDownArrowDown: ce, keyDownEscape: Ye, keyDownEnter: We, keyDownHome: Ue, keyDownEnd: je, clickItem: qe, blurInput: ze, changeInput: Fe, keyDownSpaceButton: Ge, clickButton: _e, blurButton: Xe, controlledPropUpdatedSelectedItem: Ze, touchEnd: Je }), ht = ["refKey", "ref"], vt = ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"], mt = ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"], Et = ["refKey", "ref"], It = ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"], Qe = /* @__PURE__ */ function() { var t = /* @__PURE__ */ function(o) { nt(r, o); function r(d) { var e; e = o.call(this, d) || this, e.id = e.props.id || "downshift-" + ct(), e.menuId = e.props.menuId || e.id + "-menu", e.labelId = e.props.labelId || e.id + "-label", e.inputId = e.props.inputId || e.id + "-input", e.getItemId = e.props.getItemId || function(i) { return e.id + "-item-" + i; }, e.input = null, e.items = [], e.itemCount = null, e.previousResultCount = 0, e.timeoutIds = [], e.internalSetTimeout = function(i, c) { var u = setTimeout(function() { e.timeoutIds = e.timeoutIds.filter(function(_) { return _ !== u; }), i(); }, c); e.timeoutIds.push(u); }, e.setItemCount = function(i) { e.itemCount = i; }, e.unsetItemCount = function() { e.itemCount = null; }, e.setHighlightedIndex = function(i, c) { i === void 0 && (i = e.props.defaultHighlightedIndex), c === void 0 && (c = {}), c = ue(c), e.internalSetState(M({ highlightedIndex: i }, c)); }, e.clearSelection = function(i) { e.internalSetState({ selectedItem: null, inputValue: "", highlightedIndex: e.props.defaultHighlightedIndex, isOpen: e.props.defaultIsOpen }, i); }, e.selectItem = function(i, c, u) { c = ue(c), e.internalSetState(M({ isOpen: e.props.defaultIsOpen, highlightedIndex: e.props.defaultHighlightedIndex, selectedItem: i, inputValue: e.props.itemToString(i) }, c), u); }, e.selectItemAtIndex = function(i, c, u) { var _ = e.items[i]; _ != null && e.selectItem(_, c, u); }, e.selectHighlightedItem = function(i, c) { return e.selectItemAtIndex(e.getState().highlightedIndex, i, c); }, e.internalSetState = function(i, c) { var u, _, m = {}, E = typeof i == "function"; return !E && i.hasOwnProperty("inputValue") && e.props.onInputValueChange(i.inputValue, M({}, e.getStateAndHelpers(), i)), e.setState(function(g) { g = e.getState(g); var h = E ? i(g) : i; h = e.props.stateReducer(g, h), u = h.hasOwnProperty("selectedItem"); var I = {}; return u && h.selectedItem !== g.selectedItem && (_ = h.selectedItem), h.type = h.type || Ke, Object.keys(h).forEach(function(w) { g[w] !== h[w] && (m[w] = h[w]), w !== "type" && (h[w], fe(e.props, w) || (I[w] = h[w])); }), E && h.hasOwnProperty("inputValue") && e.props.onInputValueChange(h.inputValue, M({}, e.getStateAndHelpers(), h)), I; }, function() { De(c)(); var g = Object.keys(m).length > 1; g && e.props.onStateChange(m, e.getStateAndHelpers()), u && e.props.onSelect(i.selectedItem, e.getStateAndHelpers()), _ !== void 0 && e.props.onChange(_, e.getStateAndHelpers()), e.props.onUserAction(m, e.getStateAndHelpers()); }); }, e.rootRef = function(i) { return e._rootNode = i; }, e.getRootProps = function(i, c) { var u, _ = i === void 0 ? {} : i, m = _.refKey, E = m === void 0 ? "ref" : m, g = _.ref, h = Z(_, ht), I = c === void 0 ? {} : c, w = I.suppressRefError, x = w === void 0 ? !1 : w; e.getRootProps.called = !0, e.getRootProps.refKey = E, e.getRootProps.suppressRefError = x; var a = e.getState(), R = a.isOpen; return M((u = {}, u[E] = Se(g, e.rootRef), u.role = "combobox", u["aria-expanded"] = R, u["aria-haspopup"] = "listbox", u["aria-owns"] = R ? e.menuId : null, u["aria-labelledby"] = e.labelId, u), h); }, e.keyDownHandlers = { ArrowDown: function(c) { var u = this; if (c.preventDefault(), this.getState().isOpen) { var _ = c.shiftKey ? 5 : 1; this.moveHighlightedIndex(_, { type: ce }); } else this.internalSetState({ isOpen: !0, type: ce }, function() { var m = u.getItemCount(); if (m > 0) { var E = u.getState(), g = E.highlightedIndex, h = de(1, g, m, function(I) { return u.getItemNodeFromIndex(I); }); u.setHighlightedIndex(h, { type: ce }); } }); }, ArrowUp: function(c) { var u = this; if (c.preventDefault(), this.getState().isOpen) { var _ = c.shiftKey ? -5 : -1; this.moveHighlightedIndex(_, { type: ae }); } else this.internalSetState({ isOpen: !0, type: ae }, function() { var m = u.getItemCount(); if (m > 0) { var E = u.getState(), g = E.highlightedIndex, h = de(-1, g, m, function(I) { return u.getItemNodeFromIndex(I); }); u.setHighlightedIndex(h, { type: ae }); } }); }, Enter: function(c) { if (c.which !== 229) { var u = this.getState(), _ = u.isOpen, m = u.highlightedIndex; if (_ && m != null) { c.preventDefault(); var E = this.items[m], g = this.getItemNodeFromIndex(m); if (E == null || g && g.hasAttribute("disabled")) return; this.selectHighlightedItem({ type: We }); } } }, Escape: function(c) { c.preventDefault(), this.reset(M({ type: Ye }, !this.state.isOpen && { selectedItem: null, inputValue: "" })); } }, e.buttonKeyDownHandlers = M({}, e.keyDownHandlers, { " ": function(c) { c.preventDefault(), this.toggleMenu({ type: Ge }); } }), e.inputKeyDownHandlers = M({}, e.keyDownHandlers, { Home: function(c) { var u = this, _ = this.getState(), m = _.isOpen; if (m) { c.preventDefault(); var E = this.getItemCount(); if (!(E <= 0 || !m)) { var g = Q(1, 0, E, function(h) { return u.getItemNodeFromIndex(h); }, !1); this.setHighlightedIndex(g, { type: Ue }); } } }, End: function(c) { var u = this, _ = this.getState(), m = _.isOpen; if (m) { c.preventDefault(); var E = this.getItemCount(); if (!(E <= 0 || !m)) { var g = Q(-1, E - 1, E, function(h) { return u.getItemNodeFromIndex(h); }, !1); this.setHighlightedIndex(g, { type: je }); } } } }), e.getToggleButtonProps = function(i) { var c = i === void 0 ? {} : i, u = c.onClick; c.onPress; var _ = c.onKeyDown, m = c.onKeyUp, E = c.onBlur, g = Z(c, vt), h = e.getState(), I = h.isOpen, w = { onClick: K(u, e.buttonHandleClick), onKeyDown: K(_, e.buttonHandleKeyDown), onKeyUp: K(m, e.buttonHandleKeyUp), onBlur: K(E, e.buttonHandleBlur) }, x = g.disabled ? {} : w; return M({ type: "button", role: "button", "aria-label": I ? "close menu" : "open menu", "aria-haspopup": !0, "data-toggle": !0 }, x, g); }, e.buttonHandleKeyUp = function(i) { i.preventDefault(); }, e.buttonHandleKeyDown = function(i) { var c = Ve(i); e.buttonKeyDownHandlers[c] && e.buttonKeyDownHandlers[c].call(me(e), i); }, e.buttonHandleClick = function(i) { i.preventDefault(), e.props.environment.document.activeElement === e.props.environment.document.body && i.target.focus(), process.env.NODE_ENV === "test" ? e.toggleMenu({ type: _e }) : e.internalSetTimeout(function() { return e.toggleMenu({ type: _e }); }); }, e.buttonHandleBlur = function(i) { var c = i.target; e.internalSetTimeout(function() { !e.isMouseDown && (e.props.environment.document.activeElement == null || e.props.environment.document.activeElement.id !== e.inputId) && e.props.environment.document.activeElement !== c && e.reset({ type: Xe }); }); }, e.getLabelProps = function(i) { return M({ htmlFor: e.inputId, id: e.labelId }, i); }, e.getInputProps = function(i) { var c = i === void 0 ? {} : i, u = c.onKeyDown, _ = c.onBlur, m = c.onChange, E = c.onInput; c.onChangeText; var g = Z(c, mt), h, I = {}; h = "onChange"; var w = e.getState(), x = w.inputValue, a = w.isOpen, R = w.highlightedIndex; if (!g.disabled) { var A; I = (A = {}, A[h] = K(m, E, e.inputHandleChange), A.onKeyDown = K(u, e.inputHandleKeyDown), A.onBlur = K(_, e.inputHandleBlur), A); } return M({ "aria-autocomplete": "list", "aria-activedescendant": a && typeof R == "number" && R >= 0 ? e.getItemId(R) : null, "aria-controls": a ? e.menuId : null, "aria-labelledby": g && g["aria-label"] ? void 0 : e.labelId, // https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion // revert back since autocomplete="nope" is ignored on latest Chrome and Opera autoComplete: "off", value: x, id: e.inputId }, I, g); }, e.inputHandleKeyDown = function(i) { var c = Ve(i); c && e.inputKeyDownHandlers[c] && e.inputKeyDownHandlers[c].call(me(e), i); }, e.inputHandleChange = function(i) { e.internalSetState({ type: Fe, isOpen: !0, inputValue: i.target.value, highlightedIndex: e.props.defaultHighlightedIndex }); }, e.inputHandleBlur = function() { e.internalSetTimeout(function() { var i = e.props.environment.document && !!e.props.environment.document.activeElement && !!e.props.environment.document.activeElement.dataset && e.props.environment.document.activeElement.dataset.toggle && e._rootNode && e._rootNode.contains(e.props.environment.document.activeElement); !e.isMouseDown && !i && e.reset({ type: ze }); }); }, e.menuRef = function(i) { e._menuNode = i; }, e.getMenuProps = function(i, c) { var u, _ = i === void 0 ? {} : i, m = _.refKey, E = m === void 0 ? "ref" : m, g = _.ref, h = Z(_, Et), I = c === void 0 ? {} : c, w = I.suppressRefError, x = w === void 0 ? !1 : w; return e.getMenuProps.called = !0, e.getMenuProps.refKey = E, e.getMenuProps.suppressRefError = x, M((u = {}, u[E] = Se(g, e.menuRef), u.role = "listbox", u["aria-labelledby"] = h && h["aria-label"] ? null : e.labelId, u.id = e.menuId, u), h); }, e.getItemProps = function(i) { var c, u = i === void 0 ? {} : i, _ = u.onMouseMove, m = u.onMouseDown, E = u.onClick; u.onPress; var g = u.index, h = u.item, I = h === void 0 ? process.env.NODE_ENV === "production" ? ( /* istanbul ignore next */ void 0 ) : lt("getItemProps", "item") : h, w = Z(u, It); g === void 0 ? (e.items.push(I), g = e.items.indexOf(I)) : e.items[g] = I; var x = "onClick", a = E, R = (c = { // onMouseMove is used over onMouseEnter here. onMouseMove // is only triggered on actual mouse movement while onMouseEnter // can fire on DOM changes, interrupting keyboard navigation onMouseMove: K(_, function() { g !== e.getState().highlightedIndex && (e.setHighlightedIndex(g, { type: Be }), e.avoidScrolling = !0, e.internalSetTimeout(function() { return e.avoidScrolling = !1; }, 250)); }), onMouseDown: K(m, function(B) { B.preventDefault(); }) }, c[x] = K(a, function() { e.selectItemAtIndex(g, { type: qe }); }), c), A = w.disabled ? { onMouseDown: R.onMouseDown } : R; return M({ id: e.getItemId(g), role: "option", "aria-selected": e.getState().highlightedIndex === g }, A, w); }, e.clearItems = function() { e.items = []; }, e.reset = function(i, c) { i === void 0 && (i = {}), i = ue(i), e.internalSetState(function(u) { var _ = u.selectedItem; return M({ isOpen: e.props.defaultIsOpen, highlightedIndex: e.props.defaultHighlightedIndex, inputValue: e.props.itemToString(_) }, i); }, c); }, e.toggleMenu = function(i, c) { i === void 0 && (i = {}), i = ue(i), e.internalSetState(function(u) { var _ = u.isOpen; return M({ isOpen: !_ }, _ && { highlightedIndex: e.props.defaultHighlightedIndex }, i); }, function() { var u = e.getState(), _ = u.isOpen, m = u.highlightedIndex; _ && e.getItemCount() > 0 && typeof m == "number" && e.setHighlightedIndex(m, i), De(c)(); }); }, e.openMenu = function(i) { e.internalSetState({ isOpen: !0 }, i); }, e.closeMenu = function(i) { e.internalSetState({ isOpen: !1 }, i); }, e.updateStatus = ge(function() { var i = e.getState(), c = e.items[i.highlightedIndex], u = e.getItemCount(), _ = e.props.getA11yStatusMessage(M({ itemToString: e.props.itemToString, previousResultCount: e.previousResultCount, resultCount: u, highlightedItem: c }, i)); e.previousResultCount = u, ke(_, e.props.environment.document); }, 200); var l = e.props, v = l.defaultHighlightedIndex, y = l.initialHighlightedIndex, C = y === void 0 ? v : y, S = l.defaultIsOpen, N = l.initialIsOpen, V = N === void 0 ? S : N, P = l.initialInputValue, b = P === void 0 ? "" : P, H = l.initialSelectedItem, T = H === void 0 ? null : H, f = e.getState({ highlightedIndex: C, isOpen: V, inputValue: b, selectedItem: T }); return f.selectedItem != null && e.props.initialInputValue === void 0 && (f.inputValue = e.props.itemToString(f.selectedItem)), e.state = f, e; } var s = r.prototype; return s.internalClearTimeouts = function() { this.timeoutIds.forEach(function(e) { clearTimeout(e); }), this.timeoutIds = []; }, s.getState = function(e) { return e === void 0 && (e = this.state), pt(e, this.props); }, s.getItemCount = function() { var e = this.items.length; return this.itemCount != null ? e = this.itemCount : this.props.itemCount !== void 0 && (e = this.props.itemCount), e; }, s.getItemNodeFromIndex = function(e) { return this.props.environment.document.getElementById(this.getItemId(e)); }, s.scrollHighlightedItemIntoView = function() { { var e = this.getItemNodeFromIndex(this.getState().highlightedIndex); this.props.scrollIntoView(e, this._menuNode); } }, s.moveHighlightedIndex = function(e, l) { var v = this, y = this.getItemCount(), C = this.getState(), S = C.highlightedIndex; if (y > 0) { var N = de(e, S, y, function(V) { return v.getItemNodeFromIndex(V); }); this.setHighlightedIndex(N, l); } }, s.getStateAndHelpers = function() { var e = this.getState(), l = e.highlightedIndex, v = e.inputValue, y = e.selectedItem, C = e.isOpen, S = this.props.itemToString, N = this.id, V = this.getRootProps, P = this.getToggleButtonProps, b = this.getLabelProps, H = this.getMenuProps, T = this.getInputProps, f = this.getItemProps, i = this.openMenu, c = this.closeMenu, u = this.toggleMenu, _ = this.selectItem, m = this.selectItemAtIndex, E = this.selectHighlightedItem, g = this.setHighlightedIndex, h = this.clearSelection, I = this.clearItems, w = this.reset, x = this.setItemCount, a = this.unsetItemCount, R = this.internalSetState; return { // prop getters getRootProps: V, getToggleButtonProps: P, getLabelProps: b, getMenuProps: H, getInputProps: T, getItemProps: f, // actions reset: w, openMenu: i, closeMenu: c, toggleMenu: u, selectItem: _, selectItemAtIndex: m, selectHighlightedItem: E, setHighlightedIndex: g, clearSelection: h, clearItems: I, setItemCount: x, unsetItemCount: a, setState: R, // props itemToString: S, // derived id: N, // state highlightedIndex: l, inputValue: v, isOpen: C, selectedItem: y }; }, s.componentDidMount = function() { var e = this; process.env.NODE_ENV !== "production" && this.getMenuProps.called && !this.getMenuProps.suppressRefError && Re(this._menuNode, this.getMenuProps); { var l = function() { e.isMouseDown = !0; }, v = function(P) { e.isMouseDown = !1; var b = xe(P.target, [e._rootNode, e._menuNode], e.props.environment); !b && e.getState().isOpen && e.reset({ type: Le }, function() { return e.props.onOuterClick(e.getStateAndHelpers()); }); }, y = function() { e.isTouchMove = !1; }, C = function() { e.isTouchMove = !0; }, S = function(P) { var b = xe(P.target, [e._rootNode, e._menuNode], e.props.environment, !1); !e.isTouchMove && !b && e.getState().isOpen && e.reset({ type: Je }, function() { return e.props.onOuterClick(e.getStateAndHelpers()); }); }, N = this.props.environment; N.addEventListener("mousedown", l), N.addEventListener("mouseup", v), N.addEventListener("touchstart", y), N.addEventListener("touchmove", C), N.addEventListener("touchend", S), this.cleanup = function() { e.internalClearTimeouts(), e.updateStatus.cancel(), N.removeEventListener("mousedown", l), N.removeEventListener("mouseup", v), N.removeEventListener("touchstart", y), N.removeEventListener("touchmove", C), N.removeEventListener("touchend", S); }; } }, s.shouldScroll = function(e, l) { var v = this.props.highlightedIndex === void 0 ? this.getState() : this.props, y = v.highlightedIndex, C = l.highlightedIndex === void 0 ? e : l, S = C.highlightedIndex, N = y && this.getState().isOpen && !e.isOpen, V = y !== S; return N || V; }, s.componentDidUpdate = function(e, l) { process.env.NODE_ENV !== "production" && (Te(this.state, e, this.props), this.getMenuProps.called && !this.getMenuProps.suppressRefError && Re(this._menuNode, this.getMenuProps)), fe(this.props, "selectedItem") && this.props.selectedItemChanged(e.selectedItem, this.props.selectedItem) && this.internalSetState({ type: Ze, inputValue: this.props.itemToString(this.props.selectedItem) }), !this.avoidScrolling && this.shouldScroll(l, e) && this.scrollHighlightedItemIntoView(), this.updateStatus(); }, s.componentWillUnmount = function() { this.cleanup(); }, s.render = function() { var e = Ce(this.props.children, L); this.clearItems(), this.getRootProps.called = !1, this.getRootProps.refKey = void 0, this.getRootProps.suppressRefError = void 0, this.getMenuProps.called = !1, this.getMenuProps.refKey = void 0, this.getMenuProps.suppressRefError = void 0, this.getLabelProps.called = !1, this.getInputProps.called = !1; var l = Ce(e(this.getStateAndHelpers())); if (!l) return null; if (this.getRootProps.called || this.props.suppressRefError) return process.env.NODE_ENV !== "production" && !this.getRootProps.suppressRefError && !this.props.suppressRefError && yt(l, this.getRootProps), l; if (He(l)) return /* @__PURE__ */ et(l, this.getRootProps(Ae(l))); if (process.env.NODE_ENV !== "production") throw new Error("downshift: If you return a non-DOM element, you must apply the getRootProps function"); }, r; }(tt); return t.defaultProps = { defaultHighlightedIndex: null, defaultIsOpen: !1, getA11yStatusMessage: Me, itemToString: function(r) { return r == null ? "" : (process.env.NODE_ENV !== "production" && ft(r) && !r.hasOwnProperty("toString") && console.warn("downshift: An object was passed to the default implementation of `itemToString`. You should probably provide your own `itemToString` implementation. Please refer to the `itemToString` API documentation.", "The object that was passed:", r), String(r)); }, onStateChange: L, onInputValueChange: L, onUserAction: L, onChange: L, onSelect: L, onOuterClick: L, selectedItemChanged: function(r, s) { return r !== s; }, environment: ( /* istanbul ignore next (ssr) */ typeof window > "u" ? {} : window ), stateReducer: function(r, s) { return s; }, suppressRefError: !1, scrollIntoView: Pe }, t.stateChangeTypes = gt, t; }(); process.env.NODE_ENV !== "production" && (Qe.propTypes = { children: n.func, defaultHighlightedIndex: n.number, defaultIsOpen: n.bool, initialHighlightedIndex: n.number, initialSelectedItem: n.any, initialInputValue: n.string, initialIsOpen: n.bool, getA11yStatusMessage: n.func, itemToString: n.func, onChange: n.func, onSelect: n.func, onStateChange: n.func, onInputValueChange: n.func, onUserAction: n.func, onOuterClick: n.func, selectedItemChanged: n.func, stateReducer: n.func, itemCount: n.number, id: n.string, environment: n.shape({ addEventListener: n.func, removeEventListener: n.func, document: n.shape({ getElementById: n.func, activeElement: n.any, body: n.any }) }), suppressRefError: n.bool, scrollIntoView: n.func, // things we keep in state for uncontrolled components // but can accept as props for controlled components /* eslint-disable react/no-unused-prop-types */ selectedItem: n.any, isOpen: n.bool, inputValue: n.string, highlightedIndex: n.number, labelId: n.string, inputId: n.string, menuId: n.string, getItemId: n.func /* eslint-enable react/no-unused-prop-types */ }); var Ct = Qe; function Re(t, o) { var r = o.refKey; t || console.error('downshift: The ref prop "' + r + '" from getMenuProps was not applied correctly on your menu element.'); } function yt(t, o) { var r = o.refKey, s = r !== "ref", d = !He(t); d && !s && !we.isForwardRef(t) ? console.error("downshift: You returned a non-DOM element. You must specify a refKey in getRootProps") : !d && s && console.error('downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "' + r + '"'), !we.isForwardRef(t) && !Ae(t)[r] && console.error('downshift: You must apply the ref prop "' + r + '" from getRootProps onto your root element.'); } function wt(t, o) { return o.changes; } function Nt(t) { var o = t.selectedItem, r = t.itemToString; return o ? r(o) + " has been selected." : ""; } ge(function(t, o) { ke(t(), o); }, 200); function Ot(t) { return t ? String(t) : ""; } var J = { itemToString: Ot, stateReducer: wt, getA11ySelectionMessage: Nt, scrollIntoView: Pe, environment: ( /* istanbul ignore next (ssr) */ typeof window > "u" ? {} : window ) }; process.env.NODE_ENV; process.env.NODE_ENV; n.array.isRequired, n.func, n.func, n.func, n.number, n.number, n.number, n.bool, n.bool, n.bool, n.any, n.any, n.any, n.string, n.string, n.string, n.func, n.string, n.func, n.func, n.func, n.func, n.func, n.shape({ addEventListener: n.func, removeEventListener: n.func, document: n.shape({ getElementById: n.func, activeElement: n.any, body: n.any }) }); function Dt(t) { var o = t.isOpen, r = t.resultCount, s = t.previousResultCount; return o ? r ? r !== s ? "".concat(r, " result").concat(r === 1 ? " is" : "s are", " available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.") : "" : "No results are available." : ""; } ve(ve({}, J), { getA11yStatusMessage: Dt }); process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; n.array.isRequired, n.func, n.func, n.func, n.func, n.number, n.number, n.number, n.bool, n.bool, n.bool, n.any, n.any, n.any, n.string, n.string, n.string, n.string, n.string, n.string, n.func, n.string, n.string, n.func, n.func, n.func, n.func, n.func, n.func, n.shape({ addEventListener: n.func, removeEventListener: n.func, document: n.shape({ getElementById: n.func, activeElement: n.any, body: n.any }) }); process.env.NODE_ENV; M({}, J, { selectedItemChanged: function(o, r) { return o !== r; }, getA11yStatusMessage: Me }); n.array, n.array, n.array, n.func, n.func, n.func, n.number, n.number, n.number, n.func, n.func, n.string, n.string, n.shape({ addEventListener: n.func, removeEventListener: n.func, document: n.shape({ getElementById: n.func, activeElement: n.any, body: n.any }) }); J.itemToString, J.stateReducer, J.environment; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; process.env.NODE_ENV; export { Ct as D };