import { jsx as t, jsxs as x } from "react/jsx-runtime";
import { useTheme as C, useMediaQuery as j, Box as e, Typography as A } from "@mui/material";
import { isEthereumDid as B } from "@arcblock/did";
import { getDIDMotifInfo as P } from "@arcblock/did-motif";
import { useCreation as T } from "ahooks";
import "../Theme/theme.js";
import "../Theme/theme-provider.js";
import E from "../PoweredByArcBlock/index.js";
import b from "../Avatar/index.js";
import { getDIDColor as M, hexToRgba as z } from "../Util/index.js";
import L from "../hooks/use-blocklet-logo.js";
function K({
  did: a,
  children: n,
  title: l = void 0,
  description: s = void 0,
  actions: h = void 0,
  logo: o = void 0,
  logoSize: d = 50,
  poweredBy: c = void 0,
  termsOfUse: u = void 0,
  standalone: y = !1
}) {
  const i = globalThis?.blocklet || globalThis?.env || {}, { palette: g } = C(), m = j((r) => r.breakpoints.down("lg")), D = L({
    meta: i
  }), I = T(() => {
    const r = i.appPid, v = B(r), w = v ? void 0 : P(r);
    return v ? M(r) : w.color;
  }, [i?.appPid]);
  if (!a)
    return n;
  l === void 0 && (l = i.appName), s === void 0 && (s = i.appDescription), o === void 0 && (o = D || ""), typeof o == "string" && (o ? o = /* @__PURE__ */ t(
    e,
    {
      sx: {
        height: d,
        maxHeight: d,
        objectFit: "contain"
      },
      component: "img",
      src: o,
      alt: `${i.appName}'s logo`
    }
  ) : o = /* @__PURE__ */ t(b, { size: d, did: a, src: o, variant: "rounded" })), c === void 0 && (c = /* @__PURE__ */ t(
    E,
    {
      linkProps: {
        color: g.text.secondary,
        sx: {
          "&:hover": {
            textDecoration: "underline"
          }
        }
      },
      showExtra: !m,
      sx: {
        textAlign: "center",
        fontSize: "12px",
        color: "text.secondary"
      }
    }
  ));
  let p = n;
  !n && !m && (p = /* @__PURE__ */ t(
    e,
    {
      sx: {
        filter: "blur(180px)",
        display: "flex"
      },
      children: /* @__PURE__ */ t(b, { size: 210, did: a, variant: "rounded" })
    }
  ));
  const k = !!n;
  let f = !y;
  return m && (f = !k), /* @__PURE__ */ x(
    e,
    {
      sx: {
        width: "100%",
        minHeight: "100vh",
        display: "flex",
        justifyContent: "center",
        alignItems: "center",
        px: {
          xs: 2,
          sm: 4,
          md: 8
        },
        pt: {
          xs: 2,
          sm: 4,
          md: 6
        },
        pb: {
          xs: 5,
          md: 8
        },
        background: `radial-gradient(circle at bottom right, ${z(I, 0.3)} 10%, ${g.background.default} 50%)`,
        position: "relative"
      },
      children: [
        /* @__PURE__ */ x(
          e,
          {
            sx: {
              maxWidth: 1200,
              display: "flex",
              alignItems: "center",
              justifyContent: [f, p].filter(Boolean).length > 1 ? "space-between" : "center",
              width: "100%",
              margin: "auto"
            },
            children: [
              f ? /* @__PURE__ */ x(
                e,
                {
                  sx: {
                    display: "flex",
                    flexDirection: "column",
                    gap: 1.5
                  },
                  children: [
                    /* @__PURE__ */ t(e, { sx: { display: "flex", alignItems: "center" }, children: o }),
                    /* @__PURE__ */ t(
                      A,
                      {
                        variant: "h2",
                        sx: {
                          fontWeight: "bold",
                          fontSize: {
                            sm: "2.25rem",
                            md: "2.75rem",
                            xl: "3.5rem"
                          }
                        },
                        children: l
                      }
                    ),
                    s ? /* @__PURE__ */ t(
                      e,
                      {
                        sx: {
                          mb: 2,
                          color: "text.secondary"
                        },
                        children: s
                      }
                    ) : null,
                    h ? /* @__PURE__ */ t(e, { sx: { mt: 8 }, children: h }) : null,
                    u ? /* @__PURE__ */ t(e, { sx: { mt: -1, color: "grey" }, children: u }) : null
                  ]
                }
              ) : null,
              p
            ]
          }
        ),
        /* @__PURE__ */ t(
          e,
          {
            sx: {
              position: "absolute",
              zIndex: 10,
              bottom: 10,
              left: 10,
              right: 10,
              textAlign: "center"
            },
            children: c
          }
        )
      ]
    }
  );
}
export {
  K as default
};
