import { j as jsxRuntimeExports } from "../../../../../_virtual/jsx-runtime.js";
import { a as I } from "../../../../sdk/dist/shared/chunk-PXI7AHWS.js";
import "../../../../sdk/dist/shared/chunk-3YVJ2ELD.js";
import "../../../../sdk/dist/shared/chunk-AFVJZPLS.js";
import "@sinclair/typebox";
import "../../../../sdk/dist/shared/chunk-A3GF4PYW.js";
import "../../../../sdk/dist/shared/chunk-W33JMRRN.js";
import TextContent from "../components/TextContent.js";
import { tx as D } from "../../../../style-system/dist/twind.js";
import { useBrickStyle } from "../hooks/use-brick-style.js";
import BrickRoot from "../components/BrickRoot.js";
import { useBrickProps } from "../hooks/use-brick-props.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__ */ jsxRuntimeExports.jsxs(
    BrickRoot,
    {
      brick,
      editable,
      manifest: I,
      className: D(
        "flex relative overflow-hidden !flex-nowrap",
        brickProps.imagePosition === "left" || brickProps.imagePosition === "right" ? "flex-row" : "flex-col",
        classes
      ),
      children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(
          "div",
          {
            className: D(
              "card-inner-wrapper",
              brickProps.imagePosition === "top" ? "order-2" : brickProps.imagePosition === "left" ? "order-last" : "order-1"
            ),
            children: [
              !brickProps.noTitle && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: D("text-[120%] font-semibold z-auto my-4 mx-4"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                TextContent,
                {
                  propPath: "title.content",
                  className: D("flex-1"),
                  brickId: brick.id,
                  content: brickProps.title,
                  rawContent: brick.props.title,
                  editable,
                  inline: true
                }
              ) }),
              brickProps.imagePosition !== "middle" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: D("z-auto p-4", !brickProps.noTitle && "pt-0"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                TextContent,
                {
                  propPath: "text.content",
                  className: D("flex-grow"),
                  brickId: brick.id,
                  content: brickProps.text,
                  rawContent: brick.props.text,
                  editable
                }
              ) })
            ]
          }
        ),
        brickProps.cardImage?.src && showImage && /* @__PURE__ */ jsxRuntimeExports.jsx(
          "img",
          {
            onError: () => setShowImage(false),
            className: D(
              " select-none pointer-events-none bg-transparent",
              brickProps.cardImage.position ?? "object-center",
              brickProps.cardImage.fit ?? "object-cover",
              brickProps.imagePosition === "left" && "order-1",
              brickProps.imagePosition === "right" && "order-last",
              brickProps.imagePosition === "middle" && "order-2",
              brickProps.imagePosition === "top" && "order-first",
              brickProps.imagePosition === "bottom" && "order-last mt-auto",
              brickProps.imagePosition === "left" || brickProps.imagePosition === "right" ? "h-auto w-[clamp(100px,40%,400px)]" : "w-inherit h-[clamp(100px,50%,250px)]"
            ),
            src: brickProps.cardImage.src,
            alt: brickProps.cardImage.alt || "Card Image"
          }
        ),
        brickProps.text && brickProps.imagePosition === "middle" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: D("z-auto p-4 order-last"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
          TextContent,
          {
            propPath: "text.content",
            className: D("flex-1 prose lg:prose-lg"),
            brickId: brick.id,
            content: brickProps.text,
            rawContent: brick.props.text,
            editable
          }
        ) })
      ]
    }
  );
}
export {
  Card as default
};
//# sourceMappingURL=card.js.map
