import A from "./index-extends.js";
import { useContext as F, createElement as T } from "react";
import D from "./index-emotion-is-prop-valid.esm.js";
import "./index-emotion-react.browser.esm.js";
import { getRegisteredStyles as U, insertStyles as V } from "./index-emotion-utils.browser.esm.js";
import { serializeStyles as x } from "./index-emotion-serialize.esm.js";
import { w as I, T as Y } from "./index-emotion-element-8ce3e063.browser.esm.js";
var z = D, G = function(e) {
  return e !== "theme";
}, C = function(e) {
  return typeof e == "string" && // 96 is one less than the char code
  // for "a" so this is checking that
  // it's a lowercase character
  e.charCodeAt(0) > 96 ? z : G;
}, g = function(e, i, u) {
  var o;
  if (i) {
    var n = i.shouldForwardProp;
    o = e.__emotion_forwardProp && n ? function(s) {
      return e.__emotion_forwardProp(s) && n(s);
    } : n;
  }
  return typeof o != "function" && u && (o = e.__emotion_forwardProp), o;
};
var H = function _(e, i) {
  if (process.env.NODE_ENV !== "production" && e === void 0)
    throw new Error(`You are trying to create a styled element with an undefined component.
You may have forgotten to import it.`);
  var u = e.__emotion_real === e, o = u && e.__emotion_base || e, n, s;
  i !== void 0 && (n = i.label, s = i.target);
  var E = g(e, i, u), S = E || C(o), h = !S("as");
  return function() {
    var a = arguments, l = u && e.__emotion_styles !== void 0 ? e.__emotion_styles.slice(0) : [];
    if (n !== void 0 && l.push("label:" + n + ";"), a[0] == null || a[0].raw === void 0)
      l.push.apply(l, a);
    else {
      process.env.NODE_ENV !== "production" && a[0][0], l.push(a[0][0]);
      for (var O = a.length, f = 1; f < O; f++)
        process.env.NODE_ENV !== "production" && a[0][f], l.push(a[f], a[0][f]);
    }
    var t = I(function(r, d, R) {
      var y = h && r.as || o, m = "", P = [], c = r;
      if (r.theme == null) {
        c = {};
        for (var N in r)
          c[N] = r[N];
        c.theme = F(Y);
      }
      typeof r.className == "string" ? m = U(d.registered, P, r.className) : r.className != null && (m = r.className + " ");
      var w = x(l.concat(P), d.registered, c);
      V(d, w, typeof y == "string"), m += d.key + "-" + w.name, s !== void 0 && (m += " " + s);
      var b = h && E === void 0 ? C(y) : S, v = {};
      for (var p in r)
        h && p === "as" || // $FlowFixMe
        b(p) && (v[p] = r[p]);
      v.className = m, v.ref = R;
      var L = /* @__PURE__ */ T(y, v);
      return L;
    });
    return t.displayName = n !== void 0 ? n : "Styled(" + (typeof o == "string" ? o : o.displayName || o.name || "Component") + ")", t.defaultProps = e.defaultProps, t.__emotion_real = t, t.__emotion_base = o, t.__emotion_styles = l, t.__emotion_forwardProp = E, Object.defineProperty(t, "toString", {
      value: function() {
        return s === void 0 && process.env.NODE_ENV !== "production" ? "NO_COMPONENT_SELECTOR" : "." + s;
      }
    }), t.withComponent = function(r, d) {
      return _(r, A({}, i, {}, d, {
        shouldForwardProp: g(t, d, !0)
      })).apply(void 0, l);
    }, t;
  };
};
export {
  H as default
};
