"use client";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import * as React from "react";
import { Send } from "lucide-react";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { Button } from "../../primitives/button.js";
import {
  MessageComposer
} from "./MessageComposer.js";
function SendObjectMessageDialog({
  object,
  defaultValues,
  lockedType = "messages.defaultWithObjects",
  requiredActionConfig = null,
  disabled = false,
  viewHref: _viewHref = null,
  onSuccess
}) {
  const t = useT();
  const [open, setOpen] = React.useState(false);
  const openComposer = React.useCallback(() => {
    if (disabled) return;
    setOpen(true);
  }, [disabled]);
  const contextObject = React.useMemo(() => ({
    entityModule: object.entityModule,
    entityType: object.entityType,
    entityId: object.entityId,
    sourceEntityType: object.sourceEntityType ?? null,
    sourceEntityId: object.sourceEntityId ?? null,
    previewData: object.previewData ?? null
  }), [object.entityId, object.entityModule, object.entityType, object.sourceEntityId, object.sourceEntityType, object.previewData]);
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx(
      Button,
      {
        type: "button",
        size: "icon",
        variant: "ghost",
        disabled,
        onClick: openComposer,
        "aria-label": t("messages.compose", "Compose message"),
        title: t("messages.compose", "Compose message"),
        children: /* @__PURE__ */ jsx(Send, { className: "h-4 w-4" })
      }
    ),
    /* @__PURE__ */ jsx(
      MessageComposer,
      {
        variant: "compose",
        open,
        onOpenChange: setOpen,
        lockedType,
        contextObject,
        requiredActionConfig,
        defaultValues,
        onSuccess
      }
    )
  ] });
}
export {
  SendObjectMessageDialog
};
//# sourceMappingURL=SendObjectMessageDialog.js.map
