import { jsxs, jsx } from "react/jsx-runtime";
import { aL as manifest } from "./use-page-data.CMUQyNAA.js";
import "@sinclair/typebox";
import { T as TextContent } from "./TextContent.fGn2nGQK.js";
import { a as tx } from "./twind.DdSZmZu6.js";
import { b as useBrickStyle } from "./use-section-style.DjjgfIQS.js";
import { B as BrickRoot } from "./BrickRoot.D_a_fRJm.js";
import { u as useBrickProps } from "./use-brick-props.BH1ptgVL.js";
import { useState } from "react";
function Card(props) {
  const { brick, editable } = props;
  const brickProps = useBrickProps(props);
  const styles = useBrickStyle(brick);
  const classes = Object.values(styles);
  const [showImage, setShowImage] = useState(true);
  return /* @__PURE__ */ jsxs(
    BrickRoot,
    {
      brick,
      editable,
      manifest,
      className: tx("flex relative overflow-hidden !flex-nowrap flex-col", classes),
      children: [
        /* @__PURE__ */ jsxs("div", { className: tx("card-inner-wrapper", brickProps.imagePosition === "top" ? "order-2" : "order-1"), children: [
          !brickProps.noTitle && /* @__PURE__ */ jsx("div", { className: tx("text-[120%] font-semibold z-auto my-4 mx-4"), children: /* @__PURE__ */ jsx(
            TextContent,
            {
              propPath: "title.content",
              className: tx("flex-1"),
              brickId: brick.id,
              content: brickProps.title,
              rawContent: brick.props.title,
              editable,
              inline: true
            }
          ) }),
          brickProps.imagePosition !== "middle" && /* @__PURE__ */ jsx("div", { className: tx("z-auto p-4", !brickProps.noTitle && "pt-0"), children: /* @__PURE__ */ jsx(
            TextContent,
            {
              propPath: "text.content",
              className: tx("flex-grow"),
              brickId: brick.id,
              content: brickProps.text,
              rawContent: brick.props.text,
              editable
            }
          ) })
        ] }),
        brickProps.cardImage?.src && showImage && /* @__PURE__ */ jsx(
          "img",
          {
            onError: () => setShowImage(false),
            className: tx(
              " select-none pointer-events-none bg-transparent w-inherit h-[clamp(100px,50%,250px)]",
              brickProps.cardImage.position ?? "object-center",
              brickProps.cardImage.fit ?? "object-cover",
              brickProps.imagePosition === "middle" && "order-2",
              brickProps.imagePosition === "top" && "order-first",
              brickProps.imagePosition === "bottom" && "order-last mt-auto"
            ),
            src: brickProps.cardImage.src,
            alt: brickProps.cardImage.alt || "Card Image"
          }
        ),
        brickProps.text && brickProps.imagePosition === "middle" && /* @__PURE__ */ jsx("div", { className: tx("z-auto p-4 order-last"), children: /* @__PURE__ */ jsx(
          TextContent,
          {
            propPath: "text.content",
            className: tx("flex-1 prose lg:prose-lg"),
            brickId: brick.id,
            content: brickProps.text,
            rawContent: brick.props.text,
            editable
          }
        ) })
      ]
    }
  );
}
export {
  Card as default
};
//# sourceMappingURL=card.C3N7iouy.js.map
