import { j as jsxRuntimeExports } from "./jsx-runtime.CXYVdt5g.js";
import { I as useSitemap, b3 as manifest } from "./use-editor.CurXdZnZ.js";
import "@sinclair/typebox";
import "lodash-es";
import { a as tx, c as css } from "./twind.B1qQmF_s.js";
import { b as useBrickStyle } from "./use-section-style.D8_SY6rK.js";
import { B as BrickRoot } from "./BrickRoot.C4Jpjw20.js";
function Button({ brick, editable }) {
  const styles = useBrickStyle(brick);
  const { props } = brick;
  const classes = Object.values(styles);
  const sitemap = useSitemap();
  const handleClick = (e) => {
    if (editable) {
      e.preventDefault();
      return;
    }
    if (props.link) {
      if (props.link.startsWith("http")) {
        window.open(props.link, "_blank");
      } else {
        const page = sitemap.find((p) => p.id === props.link);
        if (page) {
          window.location.href = page.attributes.path;
        }
      }
    }
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
    BrickRoot,
    {
      brick,
      manifest,
      editable,
      as: "button",
      type: "button",
      className: tx(
        classes,
        "btn",
        css({
          "&:hover": {
            filter: "brightness(1.15)"
          }
        }),
        editable && "pointer-events-none"
      ),
      "data-prevented-by-editor": editable ? "true" : "false",
      onClick: handleClick,
      children: props.label
    }
  );
}
export {
  Button as default
};
//# sourceMappingURL=button.DEk6uTgO.js.map
