'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var o = require('react');
var Fuse = require('fuse.js');

function _arrayLikeToArray(r, a) {
  (null == a || a > r.length) && (a = r.length);
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
  return n;
}
function _arrayWithHoles(r) {
  if (Array.isArray(r)) return r;
}
function _defineProperty(e, r, t) {
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
    value: t,
    enumerable: true,
    configurable: true,
    writable: true
  }) : e[r] = t, e;
}
function _extends() {
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
    for (var e = 1; e < arguments.length; e++) {
      var t = arguments[e];
      for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
    }
    return n;
  }, _extends.apply(null, arguments);
}
function _iterableToArrayLimit(r, l) {
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  if (null != t) {
    var e,
      n,
      i,
      u,
      a = [],
      f = true,
      o = false;
    try {
      if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
    } catch (r) {
      o = true, n = r;
    } finally {
      try {
        if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
      } finally {
        if (o) throw n;
      }
    }
    return a;
  }
}
function _nonIterableRest() {
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function ownKeys(e, r) {
  var t = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var o = Object.getOwnPropertySymbols(e);
    r && (o = o.filter(function (r) {
      return Object.getOwnPropertyDescriptor(e, r).enumerable;
    })), t.push.apply(t, o);
  }
  return t;
}
function _objectSpread2(e) {
  for (var r = 1; r < arguments.length; r++) {
    var t = null != arguments[r] ? arguments[r] : {};
    r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
      _defineProperty(e, r, t[r]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
      Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
    });
  }
  return e;
}
function _slicedToArray(r, e) {
  return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
function _taggedTemplateLiteral(e, t) {
  return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, {
    raw: {
      value: Object.freeze(t)
    }
  }));
}
function _toPrimitive(t, r) {
  if ("object" != typeof t || !t) return t;
  var e = t[Symbol.toPrimitive];
  if (undefined !== e) {
    var i = e.call(t, r || "default");
    if ("object" != typeof i) return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return ("string" === r ? String : Number)(t);
}
function _toPropertyKey(t) {
  var i = _toPrimitive(t, "string");
  return "symbol" == typeof i ? i : i + "";
}
function _unsupportedIterableToArray(r, a) {
  if (r) {
    if ("string" == typeof r) return _arrayLikeToArray(r, a);
    var t = {}.toString.call(r).slice(8, -1);
    return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
  }
}

function getDefaultExportFromCjs (x) {
	return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}

var index = {};

var hasRequiredIndex;

function requireIndex () {
	if (hasRequiredIndex) return index;
	hasRequiredIndex = 1;
	var React = o;

	function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

	var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

	/*
	Based on Glamor's sheet
	https://github.com/threepointone/glamor/blob/667b480d31b3721a905021b26e1290ce92ca2879/src/sheet.js
	*/ function _defineProperties(target, props) {
	    for(var i = 0; i < props.length; i++){
	        var descriptor = props[i];
	        descriptor.enumerable = descriptor.enumerable || false;
	        descriptor.configurable = true;
	        if ("value" in descriptor) descriptor.writable = true;
	        Object.defineProperty(target, descriptor.key, descriptor);
	    }
	}
	function _createClass(Constructor, protoProps, staticProps) {
	    _defineProperties(Constructor.prototype, protoProps);
	    return Constructor;
	}
	var isProd = typeof process !== "undefined" && process.env && process.env.NODE_ENV === "production";
	var isString = function(o) {
	    return Object.prototype.toString.call(o) === "[object String]";
	};
	var StyleSheet = /*#__PURE__*/ function() {
	    function StyleSheet(param) {
	        var ref = param === undefined ? {} : param, _name = ref.name, name = _name === undefined ? "stylesheet" : _name, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === undefined ? isProd : _optimizeForSpeed;
	        invariant$1(isString(name), "`name` must be a string");
	        this._name = name;
	        this._deletedRulePlaceholder = "#" + name + "-deleted-rule____{}";
	        invariant$1(typeof optimizeForSpeed === "boolean", "`optimizeForSpeed` must be a boolean");
	        this._optimizeForSpeed = optimizeForSpeed;
	        this._serverSheet = undefined;
	        this._tags = [];
	        this._injected = false;
	        this._rulesCount = 0;
	        var node = typeof window !== "undefined" && document.querySelector('meta[property="csp-nonce"]');
	        this._nonce = node ? node.getAttribute("content") : null;
	    }
	    var _proto = StyleSheet.prototype;
	    _proto.setOptimizeForSpeed = function setOptimizeForSpeed(bool) {
	        invariant$1(typeof bool === "boolean", "`setOptimizeForSpeed` accepts a boolean");
	        invariant$1(this._rulesCount === 0, "optimizeForSpeed cannot be when rules have already been inserted");
	        this.flush();
	        this._optimizeForSpeed = bool;
	        this.inject();
	    };
	    _proto.isOptimizeForSpeed = function isOptimizeForSpeed() {
	        return this._optimizeForSpeed;
	    };
	    _proto.inject = function inject() {
	        var _this = this;
	        invariant$1(!this._injected, "sheet already injected");
	        this._injected = true;
	        if (typeof window !== "undefined" && this._optimizeForSpeed) {
	            this._tags[0] = this.makeStyleTag(this._name);
	            this._optimizeForSpeed = "insertRule" in this.getSheet();
	            if (!this._optimizeForSpeed) {
	                if (!isProd) {
	                    console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode.");
	                }
	                this.flush();
	                this._injected = true;
	            }
	            return;
	        }
	        this._serverSheet = {
	            cssRules: [],
	            insertRule: function(rule, index) {
	                if (typeof index === "number") {
	                    _this._serverSheet.cssRules[index] = {
	                        cssText: rule
	                    };
	                } else {
	                    _this._serverSheet.cssRules.push({
	                        cssText: rule
	                    });
	                }
	                return index;
	            },
	            deleteRule: function(index) {
	                _this._serverSheet.cssRules[index] = null;
	            }
	        };
	    };
	    _proto.getSheetForTag = function getSheetForTag(tag) {
	        if (tag.sheet) {
	            return tag.sheet;
	        }
	        // this weirdness brought to you by firefox
	        for(var i = 0; i < document.styleSheets.length; i++){
	            if (document.styleSheets[i].ownerNode === tag) {
	                return document.styleSheets[i];
	            }
	        }
	    };
	    _proto.getSheet = function getSheet() {
	        return this.getSheetForTag(this._tags[this._tags.length - 1]);
	    };
	    _proto.insertRule = function insertRule(rule, index) {
	        invariant$1(isString(rule), "`insertRule` accepts only strings");
	        if (typeof window === "undefined") {
	            if (typeof index !== "number") {
	                index = this._serverSheet.cssRules.length;
	            }
	            this._serverSheet.insertRule(rule, index);
	            return this._rulesCount++;
	        }
	        if (this._optimizeForSpeed) {
	            var sheet = this.getSheet();
	            if (typeof index !== "number") {
	                index = sheet.cssRules.length;
	            }
	            // this weirdness for perf, and chrome's weird bug
	            // https://stackoverflow.com/questions/20007992/chrome-suddenly-stopped-accepting-insertrule
	            try {
	                sheet.insertRule(rule, index);
	            } catch (error) {
	                if (!isProd) {
	                    console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
	                }
	                return -1;
	            }
	        } else {
	            var insertionPoint = this._tags[index];
	            this._tags.push(this.makeStyleTag(this._name, rule, insertionPoint));
	        }
	        return this._rulesCount++;
	    };
	    _proto.replaceRule = function replaceRule(index, rule) {
	        if (this._optimizeForSpeed || typeof window === "undefined") {
	            var sheet = typeof window !== "undefined" ? this.getSheet() : this._serverSheet;
	            if (!rule.trim()) {
	                rule = this._deletedRulePlaceholder;
	            }
	            if (!sheet.cssRules[index]) {
	                // @TBD Should we throw an error?
	                return index;
	            }
	            sheet.deleteRule(index);
	            try {
	                sheet.insertRule(rule, index);
	            } catch (error) {
	                if (!isProd) {
	                    console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
	                }
	                // In order to preserve the indices we insert a deleteRulePlaceholder
	                sheet.insertRule(this._deletedRulePlaceholder, index);
	            }
	        } else {
	            var tag = this._tags[index];
	            invariant$1(tag, "old rule at index `" + index + "` not found");
	            tag.textContent = rule;
	        }
	        return index;
	    };
	    _proto.deleteRule = function deleteRule(index) {
	        if (typeof window === "undefined") {
	            this._serverSheet.deleteRule(index);
	            return;
	        }
	        if (this._optimizeForSpeed) {
	            this.replaceRule(index, "");
	        } else {
	            var tag = this._tags[index];
	            invariant$1(tag, "rule at index `" + index + "` not found");
	            tag.parentNode.removeChild(tag);
	            this._tags[index] = null;
	        }
	    };
	    _proto.flush = function flush() {
	        this._injected = false;
	        this._rulesCount = 0;
	        if (typeof window !== "undefined") {
	            this._tags.forEach(function(tag) {
	                return tag && tag.parentNode.removeChild(tag);
	            });
	            this._tags = [];
	        } else {
	            // simpler on server
	            this._serverSheet.cssRules = [];
	        }
	    };
	    _proto.cssRules = function cssRules() {
	        var _this = this;
	        if (typeof window === "undefined") {
	            return this._serverSheet.cssRules;
	        }
	        return this._tags.reduce(function(rules, tag) {
	            if (tag) {
	                rules = rules.concat(Array.prototype.map.call(_this.getSheetForTag(tag).cssRules, function(rule) {
	                    return rule.cssText === _this._deletedRulePlaceholder ? null : rule;
	                }));
	            } else {
	                rules.push(null);
	            }
	            return rules;
	        }, []);
	    };
	    _proto.makeStyleTag = function makeStyleTag(name, cssString, relativeToTag) {
	        if (cssString) {
	            invariant$1(isString(cssString), "makeStyleTag accepts only strings as second parameter");
	        }
	        var tag = document.createElement("style");
	        if (this._nonce) tag.setAttribute("nonce", this._nonce);
	        tag.type = "text/css";
	        tag.setAttribute("data-" + name, "");
	        if (cssString) {
	            tag.appendChild(document.createTextNode(cssString));
	        }
	        var head = document.head || document.getElementsByTagName("head")[0];
	        if (relativeToTag) {
	            head.insertBefore(tag, relativeToTag);
	        } else {
	            head.appendChild(tag);
	        }
	        return tag;
	    };
	    _createClass(StyleSheet, [
	        {
	            key: "length",
	            get: function get() {
	                return this._rulesCount;
	            }
	        }
	    ]);
	    return StyleSheet;
	}();
	function invariant$1(condition, message) {
	    if (!condition) {
	        throw new Error("StyleSheet: " + message + ".");
	    }
	}

	function hash(str) {
	    var _$hash = 5381, i = str.length;
	    while(i){
	        _$hash = _$hash * 33 ^ str.charCodeAt(--i);
	    }
	    /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
	   * integers. Since we want the results to be always positive, convert the
	   * signed int to an unsigned by doing an unsigned bitshift. */ return _$hash >>> 0;
	}
	var stringHash = hash;

	var sanitize = function(rule) {
	    return rule.replace(/\/style/gi, "\\/style");
	};
	var cache = {};
	/**
	 * computeId
	 *
	 * Compute and memoize a jsx id from a basedId and optionally props.
	 */ function computeId(baseId, props) {
	    if (!props) {
	        return "jsx-" + baseId;
	    }
	    var propsToString = String(props);
	    var key = baseId + propsToString;
	    if (!cache[key]) {
	        cache[key] = "jsx-" + stringHash(baseId + "-" + propsToString);
	    }
	    return cache[key];
	}
	/**
	 * computeSelector
	 *
	 * Compute and memoize dynamic selectors.
	 */ function computeSelector(id, css) {
	    var selectoPlaceholderRegexp = /__jsx-style-dynamic-selector/g;
	    // Sanitize SSR-ed CSS.
	    // Client side code doesn't need to be sanitized since we use
	    // document.createTextNode (dev) and the CSSOM api sheet.insertRule (prod).
	    if (typeof window === "undefined") {
	        css = sanitize(css);
	    }
	    var idcss = id + css;
	    if (!cache[idcss]) {
	        cache[idcss] = css.replace(selectoPlaceholderRegexp, id);
	    }
	    return cache[idcss];
	}

	function mapRulesToStyle(cssRules, options) {
	    if (options === undefined) options = {};
	    return cssRules.map(function(args) {
	        var id = args[0];
	        var css = args[1];
	        return /*#__PURE__*/ React__default["default"].createElement("style", {
	            id: "__" + id,
	            // Avoid warnings upon render with a key
	            key: "__" + id,
	            nonce: options.nonce ? options.nonce : undefined,
	            dangerouslySetInnerHTML: {
	                __html: css
	            }
	        });
	    });
	}
	var StyleSheetRegistry = /*#__PURE__*/ function() {
	    function StyleSheetRegistry(param) {
	        var ref = param === undefined ? {} : param, _styleSheet = ref.styleSheet, styleSheet = _styleSheet === undefined ? null : _styleSheet, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === undefined ? false : _optimizeForSpeed;
	        this._sheet = styleSheet || new StyleSheet({
	            name: "styled-jsx",
	            optimizeForSpeed: optimizeForSpeed
	        });
	        this._sheet.inject();
	        if (styleSheet && typeof optimizeForSpeed === "boolean") {
	            this._sheet.setOptimizeForSpeed(optimizeForSpeed);
	            this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
	        }
	        this._fromServer = undefined;
	        this._indices = {};
	        this._instancesCounts = {};
	    }
	    var _proto = StyleSheetRegistry.prototype;
	    _proto.add = function add(props) {
	        var _this = this;
	        if (undefined === this._optimizeForSpeed) {
	            this._optimizeForSpeed = Array.isArray(props.children);
	            this._sheet.setOptimizeForSpeed(this._optimizeForSpeed);
	            this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
	        }
	        if (typeof window !== "undefined" && !this._fromServer) {
	            this._fromServer = this.selectFromServer();
	            this._instancesCounts = Object.keys(this._fromServer).reduce(function(acc, tagName) {
	                acc[tagName] = 0;
	                return acc;
	            }, {});
	        }
	        var ref = this.getIdAndRules(props), styleId = ref.styleId, rules = ref.rules;
	        // Deduping: just increase the instances count.
	        if (styleId in this._instancesCounts) {
	            this._instancesCounts[styleId] += 1;
	            return;
	        }
	        var indices = rules.map(function(rule) {
	            return _this._sheet.insertRule(rule);
	        })// Filter out invalid rules
	        .filter(function(index) {
	            return index !== -1;
	        });
	        this._indices[styleId] = indices;
	        this._instancesCounts[styleId] = 1;
	    };
	    _proto.remove = function remove(props) {
	        var _this = this;
	        var styleId = this.getIdAndRules(props).styleId;
	        invariant(styleId in this._instancesCounts, "styleId: `" + styleId + "` not found");
	        this._instancesCounts[styleId] -= 1;
	        if (this._instancesCounts[styleId] < 1) {
	            var tagFromServer = this._fromServer && this._fromServer[styleId];
	            if (tagFromServer) {
	                tagFromServer.parentNode.removeChild(tagFromServer);
	                delete this._fromServer[styleId];
	            } else {
	                this._indices[styleId].forEach(function(index) {
	                    return _this._sheet.deleteRule(index);
	                });
	                delete this._indices[styleId];
	            }
	            delete this._instancesCounts[styleId];
	        }
	    };
	    _proto.update = function update(props, nextProps) {
	        this.add(nextProps);
	        this.remove(props);
	    };
	    _proto.flush = function flush() {
	        this._sheet.flush();
	        this._sheet.inject();
	        this._fromServer = undefined;
	        this._indices = {};
	        this._instancesCounts = {};
	    };
	    _proto.cssRules = function cssRules() {
	        var _this = this;
	        var fromServer = this._fromServer ? Object.keys(this._fromServer).map(function(styleId) {
	            return [
	                styleId,
	                _this._fromServer[styleId]
	            ];
	        }) : [];
	        var cssRules = this._sheet.cssRules();
	        return fromServer.concat(Object.keys(this._indices).map(function(styleId) {
	            return [
	                styleId,
	                _this._indices[styleId].map(function(index) {
	                    return cssRules[index].cssText;
	                }).join(_this._optimizeForSpeed ? "" : "\n")
	            ];
	        })// filter out empty rules
	        .filter(function(rule) {
	            return Boolean(rule[1]);
	        }));
	    };
	    _proto.styles = function styles(options) {
	        return mapRulesToStyle(this.cssRules(), options);
	    };
	    _proto.getIdAndRules = function getIdAndRules(props) {
	        var css = props.children, dynamic = props.dynamic, id = props.id;
	        if (dynamic) {
	            var styleId = computeId(id, dynamic);
	            return {
	                styleId: styleId,
	                rules: Array.isArray(css) ? css.map(function(rule) {
	                    return computeSelector(styleId, rule);
	                }) : [
	                    computeSelector(styleId, css)
	                ]
	            };
	        }
	        return {
	            styleId: computeId(id),
	            rules: Array.isArray(css) ? css : [
	                css
	            ]
	        };
	    };
	    /**
	   * selectFromServer
	   *
	   * Collects style tags from the document with id __jsx-XXX
	   */ _proto.selectFromServer = function selectFromServer() {
	        var elements = Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]'));
	        return elements.reduce(function(acc, element) {
	            var id = element.id.slice(2);
	            acc[id] = element;
	            return acc;
	        }, {});
	    };
	    return StyleSheetRegistry;
	}();
	function invariant(condition, message) {
	    if (!condition) {
	        throw new Error("StyleSheetRegistry: " + message + ".");
	    }
	}
	var StyleSheetContext = /*#__PURE__*/ React.createContext(null);
	StyleSheetContext.displayName = "StyleSheetContext";
	function createStyleRegistry() {
	    return new StyleSheetRegistry();
	}
	function StyleRegistry(param) {
	    var configuredRegistry = param.registry, children = param.children;
	    var rootRegistry = React.useContext(StyleSheetContext);
	    var ref = React.useState(function() {
	        return rootRegistry || configuredRegistry || createStyleRegistry();
	    }), registry = ref[0];
	    return /*#__PURE__*/ React__default["default"].createElement(StyleSheetContext.Provider, {
	        value: registry
	    }, children);
	}
	function useStyleRegistry() {
	    return React.useContext(StyleSheetContext);
	}

	// Opt-into the new `useInsertionEffect` API in React 18, fallback to `useLayoutEffect`.
	// https://github.com/reactwg/react-18/discussions/110
	var useInsertionEffect = React__default["default"].useInsertionEffect || React__default["default"].useLayoutEffect;
	var defaultRegistry = typeof window !== "undefined" ? createStyleRegistry() : undefined;
	function JSXStyle(props) {
	    var registry = defaultRegistry ? defaultRegistry : useStyleRegistry();
	    // If `registry` does not exist, we do nothing here.
	    if (!registry) {
	        return null;
	    }
	    if (typeof window === "undefined") {
	        registry.add(props);
	        return null;
	    }
	    useInsertionEffect(function() {
	        registry.add(props);
	        return function() {
	            registry.remove(props);
	        };
	    // props.children can be string[], will be striped since id is identical
	    }, [
	        props.id,
	        String(props.dynamic)
	    ]);
	    return null;
	}
	JSXStyle.dynamic = function(info) {
	    return info.map(function(tagInfo) {
	        var baseId = tagInfo[0];
	        var props = tagInfo[1];
	        return computeId(baseId, props);
	    }).join(" ");
	};

	index.StyleRegistry = StyleRegistry;
	index.createStyleRegistry = createStyleRegistry;
	index.style = JSXStyle;
	index.useStyleRegistry = useStyleRegistry;
	return index;
}

var style;
var hasRequiredStyle;

function requireStyle () {
	if (hasRequiredStyle) return style;
	hasRequiredStyle = 1;
	style = requireIndex().style;
	return style;
}

var styleExports = requireStyle();
var _JSXStyle = /*@__PURE__*/getDefaultExportFromCjs(styleExports);

var defaultTheme = {
  height: '44px',
  border: '1px solid #dfe1e5',
  borderRadius: '24px',
  backgroundColor: 'white',
  boxShadow: 'rgba(32, 33, 36, 0.28) 0px 1px 6px 0px',
  hoverBackgroundColor: '#eee',
  color: '#212121',
  fontSize: '16px',
  fontFamily: 'Arial',
  iconColor: 'grey',
  lineColor: 'rgb(232, 234, 237)',
  placeholderColor: 'grey',
  zIndex: 0,
  clearIconMargin: '3px 14px 0 0',
  searchIconMargin: '0 0 0 16px'
};
var defaultFuseOptions = {
  shouldSort: true,
  threshold: 0.6,
  location: 0,
  distance: 100,
  minMatchCharLength: 1,
  keys: ['name']
};

function debounce(func, wait, immediate) {
  var timeout;
  return function () {
    var context = this;
    var args = arguments;
    var later = function later() {
      timeout = null;
      func.apply(context, args);
    };
    timeout && clearTimeout(timeout);
    timeout = setTimeout(later, wait);
  };
}

/******************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol */


var __assign = function() {
  __assign = Object.assign || function __assign(t) {
      for (var s, i = 1, n = arguments.length; i < n; i++) {
          s = arguments[i];
          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
      }
      return t;
  };
  return __assign.apply(this, arguments);
};

function __spreadArray(to, from, pack) {
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
      if (ar || !(i in from)) {
          if (!ar) ar = Array.prototype.slice.call(from, 0, i);
          ar[i] = from[i];
      }
  }
  return to.concat(ar || Array.prototype.slice.call(from));
}

typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
  var e = new Error(message);
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};

function memoize(fn) {
  var cache = Object.create(null);
  return function (arg) {
    if (cache[arg] === undefined) cache[arg] = fn(arg);
    return cache[arg];
  };
}

var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23

var isPropValid = /* #__PURE__ */memoize(function (prop) {
  return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111
  /* o */
  && prop.charCodeAt(1) === 110
  /* n */
  && prop.charCodeAt(2) < 91;
}
/* Z+1 */
);

var MS = '-ms-';
var MOZ = '-moz-';
var WEBKIT = '-webkit-';

var COMMENT = 'comm';
var RULESET = 'rule';
var DECLARATION = 'decl';
var IMPORT = '@import';
var KEYFRAMES = '@keyframes';
var LAYER = '@layer';

/**
 * @param {number}
 * @return {number}
 */
var abs = Math.abs;

/**
 * @param {number}
 * @return {string}
 */
var from = String.fromCharCode;

/**
 * @param {object}
 * @return {object}
 */
var assign = Object.assign;

/**
 * @param {string} value
 * @param {number} length
 * @return {number}
 */
function hash (value, length) {
	return charat(value, 0) ^ 45 ? (((((((length << 2) ^ charat(value, 0)) << 2) ^ charat(value, 1)) << 2) ^ charat(value, 2)) << 2) ^ charat(value, 3) : 0
}

/**
 * @param {string} value
 * @return {string}
 */
function trim (value) {
	return value.trim()
}

/**
 * @param {string} value
 * @param {RegExp} pattern
 * @return {string?}
 */
function match (value, pattern) {
	return (value = pattern.exec(value)) ? value[0] : value
}

/**
 * @param {string} value
 * @param {(string|RegExp)} pattern
 * @param {string} replacement
 * @return {string}
 */
function replace (value, pattern, replacement) {
	return value.replace(pattern, replacement)
}

/**
 * @param {string} value
 * @param {string} search
 * @param {number} position
 * @return {number}
 */
function indexof (value, search, position) {
	return value.indexOf(search, position)
}

/**
 * @param {string} value
 * @param {number} index
 * @return {number}
 */
function charat (value, index) {
	return value.charCodeAt(index) | 0
}

/**
 * @param {string} value
 * @param {number} begin
 * @param {number} end
 * @return {string}
 */
function substr (value, begin, end) {
	return value.slice(begin, end)
}

/**
 * @param {string} value
 * @return {number}
 */
function strlen (value) {
	return value.length
}

/**
 * @param {any[]} value
 * @return {number}
 */
function sizeof (value) {
	return value.length
}

/**
 * @param {any} value
 * @param {any[]} array
 * @return {any}
 */
function append (value, array) {
	return array.push(value), value
}

/**
 * @param {string[]} array
 * @param {function} callback
 * @return {string}
 */
function combine (array, callback) {
	return array.map(callback).join('')
}

/**
 * @param {string[]} array
 * @param {RegExp} pattern
 * @return {string[]}
 */
function filter (array, pattern) {
	return array.filter(function (value) { return !match(value, pattern) })
}

var line = 1;
var column = 1;
var length = 0;
var position = 0;
var character = 0;
var characters = '';

/**
 * @param {string} value
 * @param {object | null} root
 * @param {object | null} parent
 * @param {string} type
 * @param {string[] | string} props
 * @param {object[] | string} children
 * @param {object[]} siblings
 * @param {number} length
 */
function node (value, root, parent, type, props, children, length, siblings) {
	return {value: value, root: root, parent: parent, type: type, props: props, children: children, line: line, column: column, length: length, return: '', siblings: siblings}
}

/**
 * @param {object} root
 * @param {object} props
 * @return {object}
 */
function copy (root, props) {
	return assign(node('', null, null, '', null, null, 0, root.siblings), root, {length: -root.length}, props)
}

/**
 * @param {object} root
 */
function lift (root) {
	while (root.root)
		root = copy(root.root, {children: [root]});

	append(root, root.siblings);
}

/**
 * @return {number}
 */
function char () {
	return character
}

/**
 * @return {number}
 */
function prev () {
	character = position > 0 ? charat(characters, --position) : 0;

	if (column--, character === 10)
		column = 1, line--;

	return character
}

/**
 * @return {number}
 */
function next () {
	character = position < length ? charat(characters, position++) : 0;

	if (column++, character === 10)
		column = 1, line++;

	return character
}

/**
 * @return {number}
 */
function peek () {
	return charat(characters, position)
}

/**
 * @return {number}
 */
function caret () {
	return position
}

/**
 * @param {number} begin
 * @param {number} end
 * @return {string}
 */
function slice (begin, end) {
	return substr(characters, begin, end)
}

/**
 * @param {number} type
 * @return {number}
 */
function token (type) {
	switch (type) {
		// \0 \t \n \r \s whitespace token
		case 0: case 9: case 10: case 13: case 32:
			return 5
		// ! + , / > @ ~ isolate token
		case 33: case 43: case 44: case 47: case 62: case 64: case 126:
		// ; { } breakpoint token
		case 59: case 123: case 125:
			return 4
		// : accompanied token
		case 58:
			return 3
		// " ' ( [ opening delimit token
		case 34: case 39: case 40: case 91:
			return 2
		// ) ] closing delimit token
		case 41: case 93:
			return 1
	}

	return 0
}

/**
 * @param {string} value
 * @return {any[]}
 */
function alloc (value) {
	return line = column = 1, length = strlen(characters = value), position = 0, []
}

/**
 * @param {any} value
 * @return {any}
 */
function dealloc (value) {
	return characters = '', value
}

/**
 * @param {number} type
 * @return {string}
 */
function delimit (type) {
	return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)))
}

/**
 * @param {number} type
 * @return {string}
 */
function whitespace (type) {
	while (character = peek())
		if (character < 33)
			next();
		else
			break

	return token(type) > 2 || token(character) > 3 ? '' : ' '
}

/**
 * @param {number} index
 * @param {number} count
 * @return {string}
 */
function escaping (index, count) {
	while (--count && next())
		// not 0-9 A-F a-f
		if (character < 48 || character > 102 || (character > 57 && character < 65) || (character > 70 && character < 97))
			break

	return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32))
}

/**
 * @param {number} type
 * @return {number}
 */
function delimiter (type) {
	while (next())
		switch (character) {
			// ] ) " '
			case type:
				return position
			// " '
			case 34: case 39:
				if (type !== 34 && type !== 39)
					delimiter(character);
				break
			// (
			case 40:
				if (type === 41)
					delimiter(type);
				break
			// \
			case 92:
				next();
				break
		}

	return position
}

/**
 * @param {number} type
 * @param {number} index
 * @return {number}
 */
function commenter (type, index) {
	while (next())
		// //
		if (type + character === 47 + 10)
			break
		// /*
		else if (type + character === 42 + 42 && peek() === 47)
			break

	return '/*' + slice(index, position - 1) + '*' + from(type === 47 ? type : next())
}

/**
 * @param {number} index
 * @return {string}
 */
function identifier (index) {
	while (!token(peek()))
		next();

	return slice(index, position)
}

/**
 * @param {string} value
 * @return {object[]}
 */
function compile (value) {
	return dealloc(parse('', null, null, null, [''], value = alloc(value), 0, [0], value))
}

/**
 * @param {string} value
 * @param {object} root
 * @param {object?} parent
 * @param {string[]} rule
 * @param {string[]} rules
 * @param {string[]} rulesets
 * @param {number[]} pseudo
 * @param {number[]} points
 * @param {string[]} declarations
 * @return {object}
 */
function parse (value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {
	var index = 0;
	var offset = 0;
	var length = pseudo;
	var atrule = 0;
	var property = 0;
	var previous = 0;
	var variable = 1;
	var scanning = 1;
	var ampersand = 1;
	var character = 0;
	var type = '';
	var props = rules;
	var children = rulesets;
	var reference = rule;
	var characters = type;

	while (scanning)
		switch (previous = character, character = next()) {
			// (
			case 40:
				if (previous != 108 && charat(characters, length - 1) == 58) {
					if (indexof(characters += replace(delimit(character), '&', '&\f'), '&\f', abs(index ? points[index - 1] : 0)) != -1)
						ampersand = -1;
					break
				}
			// " ' [
			case 34: case 39: case 91:
				characters += delimit(character);
				break
			// \t \n \r \s
			case 9: case 10: case 13: case 32:
				characters += whitespace(previous);
				break
			// \
			case 92:
				characters += escaping(caret() - 1, 7);
				continue
			// /
			case 47:
				switch (peek()) {
					case 42: case 47:
						append(comment(commenter(next(), caret()), root, parent, declarations), declarations);
						break
					default:
						characters += '/';
				}
				break
			// {
			case 123 * variable:
				points[index++] = strlen(characters) * ampersand;
			// } ; \0
			case 125 * variable: case 59: case 0:
				switch (character) {
					// \0 }
					case 0: case 125: scanning = 0;
					// ;
					case 59 + offset: if (ampersand == -1) characters = replace(characters, /\f/g, '');
						if (property > 0 && (strlen(characters) - length))
							append(property > 32 ? declaration(characters + ';', rule, parent, length - 1, declarations) : declaration(replace(characters, ' ', '') + ';', rule, parent, length - 2, declarations), declarations);
						break
					// @ ;
					case 59: characters += ';';
					// { rule/at-rule
					default:
						append(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length, rulesets), rulesets);

						if (character === 123)
							if (offset === 0)
								parse(characters, root, reference, reference, props, rulesets, length, points, children);
							else
								switch (atrule === 99 && charat(characters, 3) === 110 ? 100 : atrule) {
									// d l m s
									case 100: case 108: case 109: case 115:
										parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length, children), children), rules, children, length, points, rule ? props : children);
										break
									default:
										parse(characters, reference, reference, reference, [''], children, 0, points, children);
								}
				}

				index = offset = property = 0, variable = ampersand = 1, type = characters = '', length = pseudo;
				break
			// :
			case 58:
				length = 1 + strlen(characters), property = previous;
			default:
				if (variable < 1)
					if (character == 123)
						--variable;
					else if (character == 125 && variable++ == 0 && prev() == 125)
						continue

				switch (characters += from(character), character * variable) {
					// &
					case 38:
						ampersand = offset > 0 ? 1 : (characters += '\f', -1);
						break
					// ,
					case 44:
						points[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1;
						break
					// @
					case 64:
						// -
						if (peek() === 45)
							characters += delimit(next());

						atrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++;
						break
					// -
					case 45:
						if (previous === 45 && strlen(characters) == 2)
							variable = 0;
				}
		}

	return rulesets
}

/**
 * @param {string} value
 * @param {object} root
 * @param {object?} parent
 * @param {number} index
 * @param {number} offset
 * @param {string[]} rules
 * @param {number[]} points
 * @param {string} type
 * @param {string[]} props
 * @param {string[]} children
 * @param {number} length
 * @param {object[]} siblings
 * @return {object}
 */
function ruleset (value, root, parent, index, offset, rules, points, type, props, children, length, siblings) {
	var post = offset - 1;
	var rule = offset === 0 ? rules : [''];
	var size = sizeof(rule);

	for (var i = 0, j = 0, k = 0; i < index; ++i)
		for (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x)
			if (z = trim(j > 0 ? rule[x] + ' ' + y : replace(y, /&\f/g, rule[x])))
				props[k++] = z;

	return node(value, root, parent, offset === 0 ? RULESET : type, props, children, length, siblings)
}

/**
 * @param {number} value
 * @param {object} root
 * @param {object?} parent
 * @param {object[]} siblings
 * @return {object}
 */
function comment (value, root, parent, siblings) {
	return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0, siblings)
}

/**
 * @param {string} value
 * @param {object} root
 * @param {object?} parent
 * @param {number} length
 * @param {object[]} siblings
 * @return {object}
 */
function declaration (value, root, parent, length, siblings) {
	return node(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length, siblings)
}

/**
 * @param {string} value
 * @param {number} length
 * @param {object[]} children
 * @return {string}
 */
function prefix (value, length, children) {
	switch (hash(value, length)) {
		// color-adjust
		case 5103:
			return WEBKIT + 'print-' + value + value
		// animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function)
		case 5737: case 4201: case 3177: case 3433: case 1641: case 4457: case 2921:
		// text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break
		case 5572: case 6356: case 5844: case 3191: case 6645: case 3005:
		// mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite,
		case 6391: case 5879: case 5623: case 6135: case 4599: case 4855:
		// background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width)
		case 4215: case 6389: case 5109: case 5365: case 5621: case 3829:
			return WEBKIT + value + value
		// tab-size
		case 4789:
			return MOZ + value + value
		// appearance, user-select, transform, hyphens, text-size-adjust
		case 5349: case 4246: case 4810: case 6968: case 2756:
			return WEBKIT + value + MOZ + value + MS + value + value
		// writing-mode
		case 5936:
			switch (charat(value, length + 11)) {
				// vertical-l(r)
				case 114:
					return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, 'tb') + value
				// vertical-r(l)
				case 108:
					return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, 'tb-rl') + value
				// horizontal(-)tb
				case 45:
					return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, 'lr') + value
				// default: fallthrough to below
			}
		// flex, flex-direction, scroll-snap-type, writing-mode
		case 6828: case 4268: case 2903:
			return WEBKIT + value + MS + value + value
		// order
		case 6165:
			return WEBKIT + value + MS + 'flex-' + value + value
		// align-items
		case 5187:
			return WEBKIT + value + replace(value, /(\w+).+(:[^]+)/, WEBKIT + 'box-$1$2' + MS + 'flex-$1$2') + value
		// align-self
		case 5443:
			return WEBKIT + value + MS + 'flex-item-' + replace(value, /flex-|-self/g, '') + (!match(value, /flex-|baseline/) ? MS + 'grid-row-' + replace(value, /flex-|-self/g, '') : '') + value
		// align-content
		case 4675:
			return WEBKIT + value + MS + 'flex-line-pack' + replace(value, /align-content|flex-|-self/g, '') + value
		// flex-shrink
		case 5548:
			return WEBKIT + value + MS + replace(value, 'shrink', 'negative') + value
		// flex-basis
		case 5292:
			return WEBKIT + value + MS + replace(value, 'basis', 'preferred-size') + value
		// flex-grow
		case 6060:
			return WEBKIT + 'box-' + replace(value, '-grow', '') + WEBKIT + value + MS + replace(value, 'grow', 'positive') + value
		// transition
		case 4554:
			return WEBKIT + replace(value, /([^-])(transform)/g, '$1' + WEBKIT + '$2') + value
		// cursor
		case 6187:
			return replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + '$1'), /(image-set)/, WEBKIT + '$1'), value, '') + value
		// background, background-image
		case 5495: case 3959:
			return replace(value, /(image-set\([^]*)/, WEBKIT + '$1' + '$`$1')
		// justify-content
		case 4968:
			return replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + 'box-pack:$3' + MS + 'flex-pack:$3'), /s.+-b[^;]+/, 'justify') + WEBKIT + value + value
		// justify-self
		case 4200:
			if (!match(value, /flex-|baseline/)) return MS + 'grid-column-align' + substr(value, length) + value
			break
		// grid-template-(columns|rows)
		case 2592: case 3360:
			return MS + replace(value, 'template-', '') + value
		// grid-(row|column)-start
		case 4384: case 3616:
			if (children && children.some(function (element, index) { return length = index, match(element.props, /grid-\w+-end/) })) {
				return ~indexof(value + (children = children[length].value), 'span', 0) ? value : (MS + replace(value, '-start', '') + value + MS + 'grid-row-span:' + (~indexof(children, 'span', 0) ? match(children, /\d+/) : +match(children, /\d+/) - +match(value, /\d+/)) + ';')
			}
			return MS + replace(value, '-start', '') + value
		// grid-(row|column)-end
		case 4896: case 4128:
			return (children && children.some(function (element) { return match(element.props, /grid-\w+-start/) })) ? value : MS + replace(replace(value, '-end', '-span'), 'span ', '') + value
		// (margin|padding)-inline-(start|end)
		case 4095: case 3583: case 4068: case 2532:
			return replace(value, /(.+)-inline(.+)/, WEBKIT + '$1$2') + value
		// (min|max)?(width|height|inline-size|block-size)
		case 8116: case 7059: case 5753: case 5535:
		case 5445: case 5701: case 4933: case 4677:
		case 5533: case 5789: case 5021: case 4765:
			// stretch, max-content, min-content, fill-available
			if (strlen(value) - 1 - length > 6)
				switch (charat(value, length + 1)) {
					// (m)ax-content, (m)in-content
					case 109:
						// -
						if (charat(value, length + 4) !== 45)
							break
					// (f)ill-available, (f)it-content
					case 102:
						return replace(value, /(.+:)(.+)-([^]+)/, '$1' + WEBKIT + '$2-$3' + '$1' + MOZ + (charat(value, length + 3) == 108 ? '$3' : '$2-$3')) + value
					// (s)tretch
					case 115:
						return ~indexof(value, 'stretch', 0) ? prefix(replace(value, 'stretch', 'fill-available'), length, children) + value : value
				}
			break
		// grid-(column|row)
		case 5152: case 5920:
			return replace(value, /(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/, function (_, a, b, c, d, e, f) { return (MS + a + ':' + b + f) + (c ? (MS + a + '-span:' + (d ? e : +e - +b)) + f : '') + value })
		// position: sticky
		case 4949:
			// stick(y)?
			if (charat(value, length + 6) === 121)
				return replace(value, ':', ':' + WEBKIT) + value
			break
		// display: (flex|inline-flex|grid|inline-grid)
		case 6444:
			switch (charat(value, charat(value, 14) === 45 ? 18 : 11)) {
				// (inline-)?fle(x)
				case 120:
					return replace(value, /(.+:)([^;\s!]+)(;|(\s+)?!.+)?/, '$1' + WEBKIT + (charat(value, 14) === 45 ? 'inline-' : '') + 'box$3' + '$1' + WEBKIT + '$2$3' + '$1' + MS + '$2box$3') + value
				// (inline-)?gri(d)
				case 100:
					return replace(value, ':', ':' + MS) + value
			}
			break
		// scroll-margin, scroll-margin-(top|right|bottom|left)
		case 5719: case 2647: case 2135: case 3927: case 2391:
			return replace(value, 'scroll-', 'scroll-snap-') + value
	}

	return value
}

/**
 * @param {object[]} children
 * @param {function} callback
 * @return {string}
 */
function serialize (children, callback) {
	var output = '';

	for (var i = 0; i < children.length; i++)
		output += callback(children[i], i, children, callback) || '';

	return output
}

/**
 * @param {object} element
 * @param {number} index
 * @param {object[]} children
 * @param {function} callback
 * @return {string}
 */
function stringify (element, index, children, callback) {
	switch (element.type) {
		case LAYER: if (element.children.length) break
		case IMPORT: case DECLARATION: return element.return = element.return || element.value
		case COMMENT: return ''
		case KEYFRAMES: return element.return = element.value + '{' + serialize(element.children, callback) + '}'
		case RULESET: if (!strlen(element.value = element.props.join(','))) return ''
	}

	return strlen(children = serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : ''
}

/**
 * @param {function[]} collection
 * @return {function}
 */
function middleware (collection) {
	var length = sizeof(collection);

	return function (element, index, children, callback) {
		var output = '';

		for (var i = 0; i < length; i++)
			output += collection[i](element, index, children, callback) || '';

		return output
	}
}

/**
 * @param {function} callback
 * @return {function}
 */
function rulesheet (callback) {
	return function (element) {
		if (!element.root)
			if (element = element.return)
				callback(element);
	}
}

/**
 * @param {object} element
 * @param {number} index
 * @param {object[]} children
 * @param {function} callback
 */
function prefixer (element, index, children, callback) {
	if (element.length > -1)
		if (!element.return)
			switch (element.type) {
				case DECLARATION: element.return = prefix(element.value, element.length, children);
					return
				case KEYFRAMES:
					return serialize([copy(element, {value: replace(element.value, '@', '@' + WEBKIT)})], callback)
				case RULESET:
					if (element.length)
						return combine(children = element.props, function (value) {
							switch (match(value, callback = /(::plac\w+|:read-\w+)/)) {
								// :read-(only|write)
								case ':read-only': case ':read-write':
									lift(copy(element, {props: [replace(value, /:(read-\w+)/, ':' + MOZ + '$1')]}));
									lift(copy(element, {props: [value]}));
									assign(element, {props: filter(children, callback)});
									break
								// :placeholder
								case '::placeholder':
									lift(copy(element, {props: [replace(value, /:(plac\w+)/, ':' + WEBKIT + 'input-$1')]}));
									lift(copy(element, {props: [replace(value, /:(plac\w+)/, ':' + MOZ + '$1')]}));
									lift(copy(element, {props: [replace(value, /:(plac\w+)/, MS + 'input-$1')]}));
									lift(copy(element, {props: [value]}));
									assign(element, {props: filter(children, callback)});
									break
							}

							return ''
						})
			}
}

var unitlessKeys = {
  animationIterationCount: 1,
  aspectRatio: 1,
  borderImageOutset: 1,
  borderImageSlice: 1,
  borderImageWidth: 1,
  boxFlex: 1,
  boxFlexGroup: 1,
  boxOrdinalGroup: 1,
  columnCount: 1,
  columns: 1,
  flex: 1,
  flexGrow: 1,
  flexPositive: 1,
  flexShrink: 1,
  flexNegative: 1,
  flexOrder: 1,
  gridRow: 1,
  gridRowEnd: 1,
  gridRowSpan: 1,
  gridRowStart: 1,
  gridColumn: 1,
  gridColumnEnd: 1,
  gridColumnSpan: 1,
  gridColumnStart: 1,
  msGridRow: 1,
  msGridRowSpan: 1,
  msGridColumn: 1,
  msGridColumnSpan: 1,
  fontWeight: 1,
  lineHeight: 1,
  opacity: 1,
  order: 1,
  orphans: 1,
  tabSize: 1,
  widows: 1,
  zIndex: 1,
  zoom: 1,
  WebkitLineClamp: 1,
  // SVG-related properties
  fillOpacity: 1,
  floodOpacity: 1,
  stopOpacity: 1,
  strokeDasharray: 1,
  strokeDashoffset: 1,
  strokeMiterlimit: 1,
  strokeOpacity: 1,
  strokeWidth: 1
};

var f="undefined"!=typeof process&&undefined!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",m="active",y="data-styled-version",v="6.1.14",g="/*!sc*/\n",S="undefined"!=typeof window&&"HTMLElement"in window,w=Boolean("boolean"==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:"undefined"!=typeof process&&undefined!==process.env&&undefined!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&""!==process.env.REACT_APP_SC_DISABLE_SPEEDY?"false"!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&process.env.REACT_APP_SC_DISABLE_SPEEDY:"undefined"!=typeof process&&undefined!==process.env&&undefined!==process.env.SC_DISABLE_SPEEDY&&""!==process.env.SC_DISABLE_SPEEDY?"false"!==process.env.SC_DISABLE_SPEEDY&&process.env.SC_DISABLE_SPEEDY:"production"!==process.env.NODE_ENV),E=/invalid hook call/i,N=new Set,P=function(t,n){if("production"!==process.env.NODE_ENV){var o$1=n?' with the id of "'.concat(n,'"'):"",s="The component ".concat(t).concat(o$1," has been created dynamically.\n")+"You may see this warning because you've called styled inside another component.\nTo resolve this only create new StyledComponents outside of any render method and function component.",i=console.error;try{var a=!0;console.error=function(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];E.test(t)?(a=!1,N.delete(s)):i.apply(void 0,__spreadArray([t],n,!1));},o.useRef(),a&&!N.has(s)&&(console.warn(s),N.add(s));}catch(e){E.test(e.message)&&N.delete(s);}finally{console.error=i;}}},_=Object.freeze([]),C=Object.freeze({});function I(e,t,n){return undefined===n&&(n=C),e.theme!==n.theme&&e.theme||t||n.theme}var A=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),O=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,D=/(^-|-$)/g;function R(e){return e.replace(O,"-").replace(D,"")}var T=/(a)(d)/gi,k=52,j=function(e){return String.fromCharCode(e+(e>25?39:97))};function x(e){var t,n="";for(t=Math.abs(e);t>k;t=t/k|0)n=j(t%k)+n;return (j(t%k)+n).replace(T,"$1-$2")}var V,F=5381,M=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},z=function(e){return M(F,e)};function $(e){return x(z(e)>>>0)}function B(e){return "production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}function L(e){return "string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}var G="function"==typeof Symbol&&Symbol.for,Y=G?Symbol.for("react.memo"):60115,W=G?Symbol.for("react.forward_ref"):60112,q={childContextTypes:true,contextType:true,contextTypes:true,defaultProps:true,displayName:true,getDefaultProps:true,getDerivedStateFromError:true,getDerivedStateFromProps:true,mixins:true,propTypes:true,type:true},H={name:true,length:true,prototype:true,caller:true,callee:true,arguments:true,arity:true},U={$$typeof:true,compare:true,defaultProps:true,displayName:true,propTypes:true,type:true},J=((V={})[W]={$$typeof:true,render:true,defaultProps:true,displayName:true,propTypes:true},V[Y]=U,V);function X(e){return ("type"in(t=e)&&t.type.$$typeof)===Y?U:"$$typeof"in e?J[e.$$typeof]:q;var t;}var Z=Object.defineProperty,K=Object.getOwnPropertyNames,Q=Object.getOwnPropertySymbols,ee=Object.getOwnPropertyDescriptor,te=Object.getPrototypeOf,ne=Object.prototype;function oe(e,t,n){if("string"!=typeof t){if(ne){var o=te(t);o&&o!==ne&&oe(e,o,n);}var r=K(t);Q&&(r=r.concat(Q(t)));for(var s=X(e),i=X(t),a=0;a<r.length;++a){var c=r[a];if(!(c in H||n&&n[c]||i&&c in i||s&&c in s)){var l=ee(t,c);try{Z(e,c,l);}catch(e){}}}}return e}function re(e){return "function"==typeof e}function se(e){return "object"==typeof e&&"styledComponentId"in e}function ie(e,t){return e&&t?"".concat(e," ").concat(t):e||t||""}function ae(e,t){if(0===e.length)return "";for(var n=e[0],o=1;o<e.length;o++)n+=e[o];return n}function ce(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function le(e,t,n){if(undefined===n&&(n=false),!n&&!ce(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var o=0;o<t.length;o++)e[o]=le(e[o],t[o]);else if(ce(t))for(var o in t)e[o]=le(e[o],t[o]);return e}function ue(e,t){Object.defineProperty(e,"toString",{value:t});}var pe="production"!==process.env.NODE_ENV?{1:"Cannot create styled-component for component: %s.\n\n",2:"Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",3:"Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n",4:"The `StyleSheetManager` expects a valid target or sheet prop!\n\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n\n",5:"The clone method cannot be used on the client!\n\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n\n",6:"Trying to insert a new style tag, but the given Node is unmounted!\n\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n\n",7:'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',8:'ThemeProvider: Please make your "theme" prop an object.\n\n',9:"Missing document `<head>`\n\n",10:"Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n",11:"_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n",12:"It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n",13:"%s is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.\n\n",14:'ThemeProvider: "theme" prop is required.\n\n',15:"A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n",16:"Reached the limit of how many styled components may be created at group %s.\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\nas for instance in your render method then you may be running into this limitation.\n\n",17:"CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n",18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function de(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=e[0],o=[],r=1,s=e.length;r<s;r+=1)o.push(e[r]);return o.forEach(function(e){n=n.replace(/%[a-z]/,e);}),n}function he(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];return "production"===process.env.NODE_ENV?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(n.length>0?" Args: ".concat(n.join(", ")):"")):new Error(de.apply(undefined,__spreadArray([pe[t]],n,false)).trim())}var fe=function(){function e(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e;}return e.prototype.indexOfGroup=function(e){for(var t=0,n=0;n<e;n++)t+=this.groupSizes[n];return t},e.prototype.insertRules=function(e,t){if(e>=this.groupSizes.length){for(var n=this.groupSizes,o=n.length,r=o;e>=r;)if((r<<=1)<0)throw he(16,"".concat(e));this.groupSizes=new Uint32Array(r),this.groupSizes.set(n),this.length=r;for(var s=o;s<r;s++)this.groupSizes[s]=0;}for(var i=this.indexOfGroup(e+1),a=(s=0,t.length);s<a;s++)this.tag.insertRule(i,t[s])&&(this.groupSizes[e]++,i++);},e.prototype.clearGroup=function(e){if(e<this.length){var t=this.groupSizes[e],n=this.indexOfGroup(e),o=n+t;this.groupSizes[e]=0;for(var r=n;r<o;r++)this.tag.deleteRule(n);}},e.prototype.getGroup=function(e){var t="";if(e>=this.length||0===this.groupSizes[e])return t;for(var n=this.groupSizes[e],o=this.indexOfGroup(e),r=o+n,s=o;s<r;s++)t+="".concat(this.tag.getRule(s)).concat(g);return t},e}(),me=1<<30,ye=new Map,ve=new Map,ge=1,Se=function(e){if(ye.has(e))return ye.get(e);for(;ve.has(ge);)ge++;var t=ge++;if("production"!==process.env.NODE_ENV&&((0|t)<0||t>me))throw he(16,"".concat(t));return ye.set(e,t),ve.set(t,e),t},we=function(e,t){ge=t+1,ye.set(e,t),ve.set(t,e);},be="style[".concat(f,"][").concat(y,'="').concat(v,'"]'),Ee=new RegExp("^".concat(f,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Ne=function(e,t,n){for(var o,r=n.split(","),s=0,i=r.length;s<i;s++)(o=r[s])&&e.registerName(t,o);},Pe=function(e,t){for(var n,o=(null!==(n=t.textContent)&&undefined!==n?n:"").split(g),r=[],s=0,i=o.length;s<i;s++){var a=o[s].trim();if(a){var c=a.match(Ee);if(c){var l=0|parseInt(c[1],10),u=c[2];0!==l&&(we(u,l),Ne(e,u,c[3]),e.getTag().insertRules(l,r)),r.length=0;}else r.push(a);}}},_e=function(e){for(var t=document.querySelectorAll(be),n=0,o=t.length;n<o;n++){var r=t[n];r&&r.getAttribute(f)!==m&&(Pe(e,r),r.parentNode&&r.parentNode.removeChild(r));}};function Ce(){return "undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null}var Ie=function(e){var t=document.head,n=e||t,o=document.createElement("style"),r=function(e){var t=Array.from(e.querySelectorAll("style[".concat(f,"]")));return t[t.length-1]}(n),s=undefined!==r?r.nextSibling:null;o.setAttribute(f,m),o.setAttribute(y,v);var i=Ce();return i&&o.setAttribute("nonce",i),n.insertBefore(o,s),o},Ae=function(){function e(e){this.element=Ie(e),this.element.appendChild(document.createTextNode("")),this.sheet=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets,n=0,o=t.length;n<o;n++){var r=t[n];if(r.ownerNode===e)return r}throw he(17)}(this.element),this.length=0;}return e.prototype.insertRule=function(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return  false}},e.prototype.deleteRule=function(e){this.sheet.deleteRule(e),this.length--;},e.prototype.getRule=function(e){var t=this.sheet.cssRules[e];return t&&t.cssText?t.cssText:""},e}(),Oe=function(){function e(e){this.element=Ie(e),this.nodes=this.element.childNodes,this.length=0;}return e.prototype.insertRule=function(e,t){if(e<=this.length&&e>=0){var n=document.createTextNode(t);return this.element.insertBefore(n,this.nodes[e]||null),this.length++,true}return  false},e.prototype.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--;},e.prototype.getRule=function(e){return e<this.length?this.nodes[e].textContent:""},e}(),De=function(){function e(e){this.rules=[],this.length=0;}return e.prototype.insertRule=function(e,t){return e<=this.length&&(this.rules.splice(e,0,t),this.length++,true)},e.prototype.deleteRule=function(e){this.rules.splice(e,1),this.length--;},e.prototype.getRule=function(e){return e<this.length?this.rules[e]:""},e}(),Re=S,Te={isServer:!S,useCSSOMInjection:!w},ke=function(){function e(e,n,o){ undefined===e&&(e=C),undefined===n&&(n={});var r=this;this.options=__assign(__assign({},Te),e),this.gs=n,this.names=new Map(o),this.server=!!e.isServer,!this.server&&S&&Re&&(Re=false,_e(this)),ue(this,function(){return function(e){for(var t=e.getTag(),n=t.length,o="",r=function(n){var r=function(e){return ve.get(e)}(n);if(undefined===r)return "continue";var s=e.names.get(r),i=t.getGroup(n);if(undefined===s||!s.size||0===i.length)return "continue";var a="".concat(f,".g").concat(n,'[id="').concat(r,'"]'),c="";undefined!==s&&s.forEach(function(e){e.length>0&&(c+="".concat(e,","));}),o+="".concat(i).concat(a,'{content:"').concat(c,'"}').concat(g);},s=0;s<n;s++)r(s);return o}(r)});}return e.registerId=function(e){return Se(e)},e.prototype.rehydrate=function(){!this.server&&S&&_e(this);},e.prototype.reconstructWithOptions=function(n,o){return undefined===o&&(o=true),new e(__assign(__assign({},this.options),n),this.gs,o&&this.names||undefined)},e.prototype.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},e.prototype.getTag=function(){return this.tag||(this.tag=(e=function(e){var t=e.useCSSOMInjection,n=e.target;return e.isServer?new De(n):t?new Ae(n):new Oe(n)}(this.options),new fe(e)));var e;},e.prototype.hasNameForId=function(e,t){return this.names.has(e)&&this.names.get(e).has(t)},e.prototype.registerName=function(e,t){if(Se(e),this.names.has(e))this.names.get(e).add(t);else {var n=new Set;n.add(t),this.names.set(e,n);}},e.prototype.insertRules=function(e,t,n){this.registerName(e,t),this.getTag().insertRules(Se(e),n);},e.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear();},e.prototype.clearRules=function(e){this.getTag().clearGroup(Se(e)),this.clearNames(e);},e.prototype.clearTag=function(){this.tag=undefined;},e}(),je=/&/g,xe=/^\s*\/\/.*$/gm;function Ve(e,t){return e.map(function(e){return "rule"===e.type&&(e.value="".concat(t," ").concat(e.value),e.value=e.value.replaceAll(",",",".concat(t," ")),e.props=e.props.map(function(e){return "".concat(t," ").concat(e)})),Array.isArray(e.children)&&"@keyframes"!==e.type&&(e.children=Ve(e.children,t)),e})}function Fe(e){var t,n,o,r=C,s=r.options,i=undefined===s?C:s,a=r.plugins,c=undefined===a?_:a,l=function(e,o,r){return r.startsWith(n)&&r.endsWith(n)&&r.replaceAll(n,"").length>0?".".concat(t):e},u=c.slice();u.push(function(e){e.type===RULESET&&e.value.includes("&")&&(e.props[0]=e.props[0].replace(je,n).replace(o,l));}),i.prefix&&u.push(prefixer),u.push(stringify);var p=function(e,r,s,a){ undefined===r&&(r=""),undefined===s&&(s=""),undefined===a&&(a="&"),t=a,n=r,o=new RegExp("\\".concat(n,"\\b"),"g");var c=e.replace(xe,""),l=compile(s||r?"".concat(s," ").concat(r," { ").concat(c," }"):c);i.namespace&&(l=Ve(l,i.namespace));var p=[];return serialize(l,middleware(u.concat(rulesheet(function(e){return p.push(e)})))),p};return p.hash=c.length?c.reduce(function(e,t){return t.name||he(15),M(e,t.name)},F).toString():"",p}var Me=new ke,ze=Fe(),$e=o.createContext({shouldForwardProp:undefined,styleSheet:Me,stylis:ze});$e.Consumer;o.createContext(undefined);function Ge(){return o.useContext($e)}var We=function(){function e(e,t){var n=this;this.inject=function(e,t){ undefined===t&&(t=ze);var o=n.name+t.hash;e.hasNameForId(n.id,o)||e.insertRules(n.id,o,t(n.rules,o,"@keyframes"));},this.name=e,this.id="sc-keyframes-".concat(e),this.rules=t,ue(this,function(){throw he(12,String(n.name))});}return e.prototype.getName=function(e){return undefined===e&&(e=ze),this.name+e.hash},e}(),qe=function(e){return e>="A"&&e<="Z"};function He(e){for(var t="",n=0;n<e.length;n++){var o=e[n];if(1===n&&"-"===o&&"-"===e[0])return e;qe(o)?t+="-"+o.toLowerCase():t+=o;}return t.startsWith("ms-")?"-"+t:t}var Ue=function(e){return null==e||false===e||""===e},Je=function(t){var n,o,r=[];for(var s in t){var i=t[s];t.hasOwnProperty(s)&&!Ue(i)&&(Array.isArray(i)&&i.isCss||re(i)?r.push("".concat(He(s),":"),i,";"):ce(i)?r.push.apply(r,__spreadArray(__spreadArray(["".concat(s," {")],Je(i),false),["}"],false)):r.push("".concat(He(s),": ").concat((n=s,null==(o=i)||"boolean"==typeof o||""===o?"":"number"!=typeof o||0===o||n in unitlessKeys||n.startsWith("--")?String(o).trim():"".concat(o,"px")),";")));}return r};function Xe(e,t,n,o){if(Ue(e))return [];if(se(e))return [".".concat(e.styledComponentId)];if(re(e)){if(!re(s=e)||s.prototype&&s.prototype.isReactComponent||!t)return [e];var r=e(t);return "production"===process.env.NODE_ENV||"object"!=typeof r||Array.isArray(r)||r instanceof We||ce(r)||null===r||console.error("".concat(B(e)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Xe(r,t,n,o)}var s;return e instanceof We?n?(e.inject(n,o),[e.getName(o)]):[e]:ce(e)?Je(e):Array.isArray(e)?Array.prototype.concat.apply(_,e.map(function(e){return Xe(e,t,n,o)})):[e.toString()]}function Ze(e){for(var t=0;t<e.length;t+=1){var n=e[t];if(re(n)&&!se(n))return  false}return  true}var Ke=z(v),Qe=function(){function e(e,t,n){this.rules=e,this.staticRulesId="",this.isStatic="production"===process.env.NODE_ENV&&(undefined===n||n.isStatic)&&Ze(e),this.componentId=t,this.baseHash=M(Ke,t),this.baseStyle=n,ke.registerId(t);}return e.prototype.generateAndInjectStyles=function(e,t,n){var o=this.baseStyle?this.baseStyle.generateAndInjectStyles(e,t,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&t.hasNameForId(this.componentId,this.staticRulesId))o=ie(o,this.staticRulesId);else {var r=ae(Xe(this.rules,e,t,n)),s=x(M(this.baseHash,r)>>>0);if(!t.hasNameForId(this.componentId,s)){var i=n(r,".".concat(s),undefined,this.componentId);t.insertRules(this.componentId,s,i);}o=ie(o,s),this.staticRulesId=s;}else {for(var a=M(this.baseHash,n.hash),c="",l=0;l<this.rules.length;l++){var u=this.rules[l];if("string"==typeof u)c+=u,"production"!==process.env.NODE_ENV&&(a=M(a,u));else if(u){var p=ae(Xe(u,e,t,n));a=M(a,p+l),c+=p;}}if(c){var d=x(a>>>0);t.hasNameForId(this.componentId,d)||t.insertRules(this.componentId,d,n(c,".".concat(d),undefined,this.componentId)),o=ie(o,d);}}return o},e}(),et=o.createContext(undefined);et.Consumer;var rt={},st=new Set;function it(e,r,s){var i=se(e),a=e,c=!L(e),p=r.attrs,d=undefined===p?_:p,h=r.componentId,f=undefined===h?function(e,t){var n="string"!=typeof e?"sc":R(e);rt[n]=(rt[n]||0)+1;var o="".concat(n,"-").concat($(v+n+rt[n]));return t?"".concat(t,"-").concat(o):o}(r.displayName,r.parentComponentId):h,m=r.displayName,y=undefined===m?function(e){return L(e)?"styled.".concat(e):"Styled(".concat(B(e),")")}(e):m,g=r.displayName&&r.componentId?"".concat(R(r.displayName),"-").concat(r.componentId):r.componentId||f,S=i&&a.attrs?a.attrs.concat(d).filter(Boolean):d,w=r.shouldForwardProp;if(i&&a.shouldForwardProp){var b=a.shouldForwardProp;if(r.shouldForwardProp){var E=r.shouldForwardProp;w=function(e,t){return b(e,t)&&E(e,t)};}else w=b;}var N=new Qe(s,g,i?a.componentStyle:undefined);function O(e,r){return function(e,r,s){var i=e.attrs,a=e.componentStyle,c=e.defaultProps,p=e.foldedComponentIds,d=e.styledComponentId,h=e.target,f=o.useContext(et),m=Ge(),y=e.shouldForwardProp||m.shouldForwardProp;"production"!==process.env.NODE_ENV&&o.useDebugValue(d);var v=I(r,f,c)||C,g=function(e,n,o){for(var r,s=__assign(__assign({},n),{className:undefined,theme:o}),i=0;i<e.length;i+=1){var a=re(r=e[i])?r(s):r;for(var c in a)s[c]="className"===c?ie(s[c],a[c]):"style"===c?__assign(__assign({},s[c]),a[c]):a[c];}return n.className&&(s.className=ie(s.className,n.className)),s}(i,r,v),S=g.as||h,w={};for(var b in g) undefined===g[b]||"$"===b[0]||"as"===b||"theme"===b&&g.theme===v||("forwardedAs"===b?w.as=g.forwardedAs:y&&!y(b,S)||(w[b]=g[b],y||"development"!==process.env.NODE_ENV||isPropValid(b)||st.has(b)||!A.has(S)||(st.add(b),console.warn('styled-components: it looks like an unknown prop "'.concat(b,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var E=function(e,t){var n=Ge(),o$1=e.generateAndInjectStyles(t,n.styleSheet,n.stylis);return "production"!==process.env.NODE_ENV&&o.useDebugValue(o$1),o$1}(a,g);"production"!==process.env.NODE_ENV&&e.warnTooManyClasses&&e.warnTooManyClasses(E);var N=ie(p,d);return E&&(N+=" "+E),g.className&&(N+=" "+g.className),w[L(S)&&!A.has(S)?"class":"className"]=N,s&&(w.ref=s),o.createElement(S,w)}(D,e,r)}O.displayName=y;var D=o.forwardRef(O);return D.attrs=S,D.componentStyle=N,D.displayName=y,D.shouldForwardProp=w,D.foldedComponentIds=i?ie(a.foldedComponentIds,a.styledComponentId):"",D.styledComponentId=g,D.target=i?a.target:e,Object.defineProperty(D,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(e){this._foldedDefaultProps=i?function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var o=0,r=t;o<r.length;o++)le(e,r[o],true);return e}({},a.defaultProps,e):e;}}),"production"!==process.env.NODE_ENV&&(P(y,g),D.warnTooManyClasses=function(e,t){var n={},o=false;return function(r){if(!o&&(n[r]=true,Object.keys(n).length>=200)){var s=t?' with the id of "'.concat(t,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(e).concat(s,".\n")+"Consider using the attrs method, together with a style object for frequently changed styles.\nExample:\n  const Component = styled.div.attrs(props => ({\n    style: {\n      background: props.background,\n    },\n  }))`width: 100%;`\n\n  <Component />"),o=true,n={};}}}(y,g)),ue(D,function(){return ".".concat(D.styledComponentId)}),c&&oe(D,e,{attrs:true,componentStyle:true,displayName:true,foldedComponentIds:true,shouldForwardProp:true,styledComponentId:true,target:true}),D}function at(e,t){for(var n=[e[0]],o=0,r=t.length;o<r;o+=1)n.push(t[o],e[o+1]);return n}var ct=function(e){return Object.assign(e,{isCss:true})};function lt(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];if(re(t)||ce(t))return ct(Xe(at(_,__spreadArray([t],n,true))));var r=t;return 0===n.length&&1===r.length&&"string"==typeof r[0]?Xe(r):ct(Xe(at(r,n)))}function ut(n,o,r){if(undefined===r&&(r=C),!o)throw he(1,o);var s=function(t){for(var s=[],i=1;i<arguments.length;i++)s[i-1]=arguments[i];return n(o,r,lt.apply(undefined,__spreadArray([t],s,false)))};return s.attrs=function(e){return ut(n,o,__assign(__assign({},r),{attrs:Array.prototype.concat(r.attrs,e).filter(Boolean)}))},s.withConfig=function(e){return ut(n,o,__assign(__assign({},r),e))},s}var pt=function(e){return ut(it,e)},dt=pt;A.forEach(function(e){dt[e]=pt(e);});"production"!==process.env.NODE_ENV&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product&&console.warn("It looks like you've imported 'styled-components' on React Native.\nPerhaps you're looking to import 'styled-components/native'?\nRead more about this at https://www.styled-components.com/docs/basics#react-native");var St="__sc-".concat(f,"__");"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV&&"undefined"!=typeof window&&(window[St]||(window[St]=0),1===window[St]&&console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info."),window[St]+=1);

var _templateObject$3;
var SearchIcon = function SearchIcon(_ref) {
  var showIcon = _ref.showIcon;
  if (!showIcon) {
    return null;
  }
  return /*#__PURE__*/React.createElement(StyledSearchIcon, {
    className: "search-icon",
    width: 20,
    height: 20,
    focusable: "false",
    xmlns: "http://www.w3.org/2000/svg",
    viewBox: "0 0 24 24"
  }, /*#__PURE__*/React.createElement("path", {
    d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
  }));
};
var StyledSearchIcon = dt.svg(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n  flex-shrink: 0;\n  margin: ", ";\n  fill: ", ";\n"])), function (props) {
  return props.theme.searchIconMargin;
}, function (props) {
  return props.theme.iconColor;
});

var _templateObject$2;
function Results(_ref) {
  var _ref$results = _ref.results,
    results = _ref$results === undefined ? [] : _ref$results,
    onClick = _ref.onClick,
    setSearchString = _ref.setSearchString,
    showIcon = _ref.showIcon,
    maxResults = _ref.maxResults,
    _ref$resultStringKeyN = _ref.resultStringKeyName,
    resultStringKeyName = _ref$resultStringKeyN === undefined ? 'name' : _ref$resultStringKeyN,
    highlightedItem = _ref.highlightedItem,
    setHighlightedItem = _ref.setHighlightedItem,
    formatResult = _ref.formatResult,
    _ref$showNoResultsFla = _ref.showNoResultsFlag,
    showNoResultsFlag = _ref$showNoResultsFla === undefined ? true : _ref$showNoResultsFla,
    _ref$showNoResultsTex = _ref.showNoResultsText,
    showNoResultsText = _ref$showNoResultsTex === undefined ? 'No results' : _ref$showNoResultsTex;
  var formatResultWithKey = formatResult ? formatResult : function (item) {
    return item[resultStringKeyName];
  };
  var handleClick = function handleClick(result) {
    onClick(result);
    setSearchString(result[resultStringKeyName]);
  };
  var handleMouseDown = function handleMouseDown(_ref2) {
    var event = _ref2.event,
      result = _ref2.result;
    if (event.button === 0) {
      event.preventDefault();
      handleClick(result);
    }
  };
  if (showNoResultsFlag) {
    return /*#__PURE__*/React.createElement(ResultsWrapper, null, /*#__PURE__*/React.createElement("li", {
      "data-test": "no-results-message"
    }, /*#__PURE__*/React.createElement(SearchIcon, {
      showIcon: showIcon
    }), /*#__PURE__*/React.createElement("div", {
      className: "ellipsis"
    }, showNoResultsText)));
  }
  if ((results === null || results === undefined ? undefined : results.length) <= 0 && !showNoResultsFlag) {
    return null;
  }
  return /*#__PURE__*/React.createElement(ResultsWrapper, null, results.slice(0, maxResults).map(function (result, index) {
    return /*#__PURE__*/React.createElement("li", {
      className: highlightedItem === index ? 'selected' : '',
      onMouseEnter: function onMouseEnter() {
        return setHighlightedItem({
          index: index
        });
      },
      "data-test": "result",
      key: "rsa-result-".concat(result.id),
      onMouseDown: function onMouseDown(event) {
        return handleMouseDown({
          event: event,
          result: result
        });
      },
      onClick: function onClick() {
        return handleClick(result);
      }
    }, /*#__PURE__*/React.createElement(SearchIcon, {
      showIcon: showIcon
    }), /*#__PURE__*/React.createElement("div", {
      className: "ellipsis",
      title: result[resultStringKeyName]
    }, formatResultWithKey(result)));
  }));
}
var ResultsWrapper = function ResultsWrapper(_ref3) {
  var children = _ref3.children;
  return /*#__PURE__*/React.createElement(StyledResults, null, /*#__PURE__*/React.createElement("div", {
    className: "line"
  }), /*#__PURE__*/React.createElement("ul", null, children));
};
var StyledResults = dt.div(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\n  > div.line {\n    border-top-color: ", ";\n    border-top-style: solid;\n    border-top-width: 1px;\n\n    margin-bottom: 0px;\n    margin-left: 14px;\n    margin-right: 20px;\n    margin-top: 0px;\n\n    padding-bottom: 4px;\n  }\n\n  > ul {\n    list-style-type: none;\n    margin: 0;\n    padding: 0px 0 16px 0;\n    max-height: ", ";\n\n    > li {\n      display: flex;\n      align-items: center;\n      padding: 4px 0 4px 0;\n\n      > div {\n        margin-left: 13px;\n      }\n    }\n  }\n\n  .ellipsis {\n    text-align: left;\n    width: 100%;\n    white-space: nowrap;\n    overflow: hidden;\n    text-overflow: ellipsis;\n  }\n\n  .selected {\n    background-color: ", ";\n  }\n"])), function (props) {
  return props.theme.lineColor;
}, function (props) {
  return props.theme.maxHeight;
}, function (props) {
  return props.theme.hoverBackgroundColor;
});

var _templateObject$1;
var ClearIcon = function ClearIcon(_ref) {
  var showClear = _ref.showClear,
    setSearchString = _ref.setSearchString,
    searchString = _ref.searchString,
    setFocus = _ref.setFocus,
    onClear = _ref.onClear;
  var handleClearSearchString = function handleClearSearchString() {
    setSearchString({
      target: {
        value: ''
      }
    });
    setFocus();
    onClear();
  };
  if (!showClear) {
    return null;
  }
  if (!searchString || (searchString === null || searchString === undefined ? undefined : searchString.length) <= 0) {
    return null;
  }
  return /*#__PURE__*/React.createElement(StyledClearIcon, {
    className: "clear-icon",
    onClick: handleClearSearchString
  }, /*#__PURE__*/React.createElement("svg", {
    width: 20,
    height: 20,
    focusable: "false",
    xmlns: "http://www.w3.org/2000/svg",
    viewBox: "0 0 24 24"
  }, /*#__PURE__*/React.createElement("path", {
    d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.58 12 5 17.58 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
  })));
};
var StyledClearIcon = dt.div(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n  margin: ", ";\n\n  &:hover {\n    cursor: pointer;\n  }\n\n  > svg {\n    fill: ", ";\n  }\n"])), function (props) {
  return props.theme.clearIconMargin;
}, function (props) {
  return props.theme.iconColor;
});

var _templateObject;
function SearchInput(_ref) {
  var searchString = _ref.searchString,
    setSearchString = _ref.setSearchString,
    setHighlightedItem = _ref.setHighlightedItem,
    eraseResults = _ref.eraseResults,
    autoFocus = _ref.autoFocus,
    onFocus = _ref.onFocus,
    onClear = _ref.onClear,
    placeholder = _ref.placeholder,
    _ref$showIcon = _ref.showIcon,
    showIcon = _ref$showIcon === undefined ? true : _ref$showIcon,
    _ref$showClear = _ref.showClear,
    showClear = _ref$showClear === undefined ? true : _ref$showClear,
    maxLength = _ref.maxLength;
  var ref = o.useRef(null);
  var manualFocus = true;
  var setFocus = function setFocus() {
    manualFocus = false;
    (ref === null || ref === undefined ? undefined : ref.current) && ref.current.focus();
    manualFocus = true;
  };
  var handleOnFocus = function handleOnFocus(event) {
    manualFocus && onFocus(event);
  };
  var maxLengthProperty = maxLength ? {
    maxLength: maxLength
  } : {};
  return /*#__PURE__*/React.createElement(StyledSearchInput, null, /*#__PURE__*/React.createElement(SearchIcon, {
    showIcon: showIcon
  }), /*#__PURE__*/React.createElement("input", _extends({
    type: "text",
    ref: ref,
    spellCheck: false,
    value: searchString,
    onChange: setSearchString,
    onFocus: handleOnFocus,
    placeholder: placeholder,
    autoFocus: autoFocus,
    onBlur: function onBlur() {
      return eraseResults();
    },
    onKeyDown: function onKeyDown(event) {
      return setHighlightedItem({
        event: event
      });
    },
    "data-test": "search-input"
  }, maxLengthProperty)), /*#__PURE__*/React.createElement(ClearIcon, {
    showClear: showClear,
    setSearchString: setSearchString,
    searchString: searchString,
    onClear: onClear,
    setFocus: setFocus
  }));
}
var StyledSearchInput = dt.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n  min-height: ", ";\n  width: 100%;\n\n  display: flex;\n  align-items: center;\n\n  > input {\n    width: 100%;\n\n    padding: 0 0 0 13px;\n\n    border: none;\n    outline: none;\n\n    background-color: rgba(0, 0, 0, 0);\n    font-size: inherit;\n    font-family: inherit;\n\n    color: ", ";\n\n    ::placeholder {\n      color: ", ";\n      opacity: 1;\n\n      :-ms-input-placeholder {\n        color: ", ";\n      }\n\n      ::-ms-input-placeholder {\n        color: ", ";\n      }\n    }\n  }\n"])), function (props) {
  return props.theme.height;
}, function (props) {
  return props.theme.color;
}, function (props) {
  return props.theme.placeholderColor;
}, function (props) {
  return props.theme.placeholderColor;
}, function (props) {
  return props.theme.placeholderColor;
});

var DEFAULT_INPUT_DEBOUNCE = 200;
var MAX_RESULTS = 10;
function ReactSearchAutocomplete(_ref) {
  var _ref$items = _ref.items,
    items = _ref$items === undefined ? [] : _ref$items,
    _ref$fuseOptions = _ref.fuseOptions,
    fuseOptions = _ref$fuseOptions === undefined ? defaultFuseOptions : _ref$fuseOptions,
    _ref$inputDebounce = _ref.inputDebounce,
    inputDebounce = _ref$inputDebounce === undefined ? DEFAULT_INPUT_DEBOUNCE : _ref$inputDebounce,
    _ref$onSearch = _ref.onSearch,
    onSearch = _ref$onSearch === undefined ? function () {} : _ref$onSearch,
    _ref$onHover = _ref.onHover,
    onHover = _ref$onHover === undefined ? function () {} : _ref$onHover,
    _ref$onSelect = _ref.onSelect,
    onSelect = _ref$onSelect === undefined ? function () {} : _ref$onSelect,
    _ref$onFocus = _ref.onFocus,
    onFocus = _ref$onFocus === undefined ? function () {} : _ref$onFocus,
    _ref$onClear = _ref.onClear,
    onClear = _ref$onClear === undefined ? function () {} : _ref$onClear,
    _ref$showIcon = _ref.showIcon,
    showIcon = _ref$showIcon === undefined ? true : _ref$showIcon,
    _ref$showClear = _ref.showClear,
    showClear = _ref$showClear === undefined ? true : _ref$showClear,
    _ref$maxResults = _ref.maxResults,
    maxResults = _ref$maxResults === undefined ? MAX_RESULTS : _ref$maxResults,
    _ref$placeholder = _ref.placeholder,
    placeholder = _ref$placeholder === undefined ? '' : _ref$placeholder,
    _ref$autoFocus = _ref.autoFocus,
    autoFocus = _ref$autoFocus === undefined ? false : _ref$autoFocus,
    _ref$styling = _ref.styling,
    styling = _ref$styling === undefined ? {} : _ref$styling,
    _ref$resultStringKeyN = _ref.resultStringKeyName,
    resultStringKeyName = _ref$resultStringKeyN === undefined ? 'name' : _ref$resultStringKeyN,
    _ref$inputSearchStrin = _ref.inputSearchString,
    inputSearchString = _ref$inputSearchStrin === undefined ? '' : _ref$inputSearchStrin,
    formatResult = _ref.formatResult,
    _ref$showNoResults = _ref.showNoResults,
    showNoResults = _ref$showNoResults === undefined ? true : _ref$showNoResults,
    _ref$showNoResultsTex = _ref.showNoResultsText,
    showNoResultsText = _ref$showNoResultsTex === undefined ? 'No results' : _ref$showNoResultsTex,
    _ref$showItemsOnFocus = _ref.showItemsOnFocus,
    showItemsOnFocus = _ref$showItemsOnFocus === undefined ? false : _ref$showItemsOnFocus,
    _ref$maxLength = _ref.maxLength,
    maxLength = _ref$maxLength === undefined ? 0 : _ref$maxLength;
    _ref.className;
  _objectSpread2(_objectSpread2({}, defaultTheme), styling);
  var options = _objectSpread2(_objectSpread2({}, defaultFuseOptions), fuseOptions);
  var fuse = new Fuse(items, options);
  fuse.setCollection(items);
  var _useState = o.useState(inputSearchString),
    _useState2 = _slicedToArray(_useState, 2),
    searchString = _useState2[0],
    setSearchString = _useState2[1];
  var _useState3 = o.useState([]),
    _useState4 = _slicedToArray(_useState3, 2),
    results = _useState4[0],
    setResults = _useState4[1];
  var _useState5 = o.useState(-1),
    _useState6 = _slicedToArray(_useState5, 2),
    highlightedItem = _useState6[0],
    setHighlightedItem = _useState6[1];
  var _useState7 = o.useState(false),
    _useState8 = _slicedToArray(_useState7, 2),
    isSearchComplete = _useState8[0],
    setIsSearchComplete = _useState8[1];
  var _useState9 = o.useState(false),
    _useState10 = _slicedToArray(_useState9, 2),
    isTyping = _useState10[0],
    setIsTyping = _useState10[1];
  var _useState11 = o.useState(false),
    _useState12 = _slicedToArray(_useState11, 2),
    showNoResultsFlag = _useState12[0],
    setShowNoResultsFlag = _useState12[1];
  var _useState13 = o.useState(false),
    _useState14 = _slicedToArray(_useState13, 2),
    hasFocus = _useState14[0],
    setHasFocus = _useState14[1];
  o.useEffect(function () {
    setSearchString(inputSearchString);
    var timeoutId = setTimeout(function () {
      return setResults(fuseResults(inputSearchString));
    }, 0);
    return function () {
      return clearTimeout(timeoutId);
    };
  }, [inputSearchString]);
  o.useEffect(function () {
    (searchString === null || searchString === undefined ? undefined : searchString.length) > 0 && results && (results === null || results === undefined ? undefined : results.length) > 0 && setResults(fuseResults(searchString));
  }, [items]);
  o.useEffect(function () {
    if (showNoResults && searchString.length > 0 && !isTyping && results.length === 0 && !isSearchComplete) {
      setShowNoResultsFlag(true);
    } else {
      setShowNoResultsFlag(false);
    }
  }, [isTyping, showNoResults, isSearchComplete, searchString, results]);
  o.useEffect(function () {
    if (showItemsOnFocus && results.length === 0 && searchString.length === 0 && hasFocus) {
      setResults(items.slice(0, maxResults));
    }
  }, [showItemsOnFocus, results, searchString, hasFocus]);
  o.useEffect(function () {
    var handleDocumentClick = function handleDocumentClick() {
      eraseResults();
      setHasFocus(false);
    };
    document.addEventListener('click', handleDocumentClick);
    return function () {
      return document.removeEventListener('click', handleDocumentClick);
    };
  }, []);
  var handleOnFocus = function handleOnFocus(event) {
    onFocus(event);
    setHasFocus(true);
  };
  var callOnSearch = function callOnSearch(keyword) {
    var newResults = [];
    (keyword === null || keyword === undefined ? undefined : keyword.length) > 0 && (newResults = fuseResults(keyword));
    setResults(newResults);
    onSearch(keyword, newResults);
    setIsTyping(false);
  };
  var handleOnSearch = o.useCallback(inputDebounce > 0 ? debounce(function (keyword) {
    return callOnSearch(keyword);
  }, inputDebounce) : function (keyword) {
    return callOnSearch(keyword);
  }, [items]);
  var handleOnClick = function handleOnClick(result) {
    eraseResults();
    onSelect(result);
    setSearchString(result[resultStringKeyName]);
    setHighlightedItem(0);
  };
  var fuseResults = function fuseResults(keyword) {
    return fuse.search(keyword, {
      limit: maxResults
    }).map(function (result) {
      return _objectSpread2({}, result.item);
    }).slice(0, maxResults);
  };
  var handleSetSearchString = function handleSetSearchString(_ref2) {
    var target = _ref2.target;
    var keyword = target.value;
    setSearchString(keyword);
    handleOnSearch(keyword);
    setIsTyping(true);
    if (isSearchComplete) {
      setIsSearchComplete(false);
    }
  };
  var eraseResults = function eraseResults() {
    setResults([]);
    setIsSearchComplete(true);
  };
  var handleSetHighlightedItem = function handleSetHighlightedItem(_ref3) {
    var index = _ref3.index,
      event = _ref3.event;
    var itemIndex = -1;
    var setValues = function setValues(index) {
      setHighlightedItem(index);
      (results === null || results === undefined ? undefined : results[index]) && onHover(results[index]);
    };
    if (index !== undefined) {
      setHighlightedItem(index);
      (results === null || results === undefined ? undefined : results[index]) && onHover(results[index]);
    } else if (event) {
      switch (event.key) {
        case 'Enter':
          if (results.length > 0 && results[highlightedItem]) {
            event.preventDefault();
            onSelect(results[highlightedItem]);
            setSearchString(results[highlightedItem][resultStringKeyName]);
            onSearch(results[highlightedItem][resultStringKeyName], results);
          } else {
            onSearch(searchString, results);
          }
          setHighlightedItem(-1);
          eraseResults();
          break;
        case 'ArrowUp':
          event.preventDefault();
          itemIndex = highlightedItem > -1 ? highlightedItem - 1 : results.length - 1;
          setValues(itemIndex);
          break;
        case 'ArrowDown':
          event.preventDefault();
          itemIndex = highlightedItem < results.length - 1 ? highlightedItem + 1 : -1;
          setValues(itemIndex);
          break;
      }
    }
  };
  return /*#__PURE__*/o.createElement("div", {
    className: _JSXStyle.dynamic([["3512916558", [function (props) {
      return parseInt(props.theme.height) + 2 + 'px';
    }, function (props) {
      return props.theme.border;
    }, function (props) {
      return props.theme.borderRadius;
    }, function (props) {
      return props.theme.backgroundColor;
    }, function (props) {
      return props.theme.color;
    }, function (props) {
      return props.theme.fontSize;
    }, function (props) {
      return props.theme.fontFamily;
    }, function (props) {
      return props.theme.zIndex;
    }, function (props) {
      return props.theme.boxShadow;
    }, function (props) {
      return props.theme.boxShadow;
    }, function (props) {
      return props.theme.boxShadow;
    }]]]) + " " + "search-bar-wrapper"
  }, /*#__PURE__*/o.createElement(SearchInput, {
    searchString: searchString,
    setSearchString: handleSetSearchString,
    eraseResults: eraseResults,
    autoFocus: autoFocus,
    onFocus: handleOnFocus,
    onClear: onClear,
    placeholder: placeholder,
    showIcon: showIcon,
    showClear: showClear,
    setHighlightedItem: handleSetHighlightedItem,
    maxLength: maxLength
  }), /*#__PURE__*/o.createElement(Results, {
    results: results,
    onClick: handleOnClick,
    setSearchString: setSearchString,
    showIcon: showIcon,
    maxResults: maxResults,
    resultStringKeyName: resultStringKeyName,
    formatResult: formatResult,
    highlightedItem: highlightedItem,
    setHighlightedItem: handleSetHighlightedItem,
    showNoResultsFlag: showNoResultsFlag,
    showNoResultsText: showNoResultsText
  }), /*#__PURE__*/o.createElement(_JSXStyle, {
    id: "3512916558",
    dynamic: [function (props) {
      return parseInt(props.theme.height) + 2 + 'px';
    }, function (props) {
      return props.theme.border;
    }, function (props) {
      return props.theme.borderRadius;
    }, function (props) {
      return props.theme.backgroundColor;
    }, function (props) {
      return props.theme.color;
    }, function (props) {
      return props.theme.fontSize;
    }, function (props) {
      return props.theme.fontFamily;
    }, function (props) {
      return props.theme.zIndex;
    }, function (props) {
      return props.theme.boxShadow;
    }, function (props) {
      return props.theme.boxShadow;
    }, function (props) {
      return props.theme.boxShadow;
    }]
  }, ".__jsx-style-dynamic-selector{position:relative;height:".concat(function (props) {
    return parseInt(props.theme.height) + 2 + 'px';
  }, ";}.search-bar-wrapper.__jsx-style-dynamic-selector{position:absolute;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;width:100%;border:").concat(function (props) {
    return props.theme.border;
  }, ";border-radius:").concat(function (props) {
    return props.theme.borderRadius;
  }, ";background-color:").concat(function (props) {
    return props.theme.backgroundColor;
  }, ";color:").concat(function (props) {
    return props.theme.color;
  }, ";font-size:").concat(function (props) {
    return props.theme.fontSize;
  }, ";font-family:").concat(function (props) {
    return props.theme.fontFamily;
  }, ";z-index:").concat(function (props) {
    return props.theme.zIndex;
  }, ";}.search-bar-wrapper.__jsx-style-dynamic-selector:hover{box-shadow:").concat(function (props) {
    return props.theme.boxShadow;
  }, ";}.search-bar-wrapper.__jsx-style-dynamic-selector:active{box-shadow:").concat(function (props) {
    return props.theme.boxShadow;
  }, ";}.search-bar-wrapper.__jsx-style-dynamic-selector:focus-within{box-shadow:").concat(function (props) {
    return props.theme.boxShadow;
  }, ";}")));
}

exports.default = ReactSearchAutocomplete;
