"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const designSystem = require("@choiceform/design-system");
const react = require("../../_vendor/@legendapp/state/react.cjs");
const index = require("../../_vendor/usehooks-ts/dist-index.cjs");
const coreStore = require("../../stores/core-store.cjs");
const AttachmentPreviewDialog = react.observer(() => {
  const attachmentPreviewDialog = react.use$(coreStore.coreStore$.ui.attachmentPreviewDialog);
  const handleOpenChange = index.useEventCallback((open) => {
    if (open) {
      coreStore.coreActions.setAttachmentPreviewDialog(attachmentPreviewDialog.attachment);
    } else {
      coreStore.coreActions.closeAttachmentPreviewDialog();
    }
  });
  return /* @__PURE__ */ jsxRuntime.jsxs(
    designSystem.Dialog,
    {
      outsidePress: true,
      draggable: true,
      open: attachmentPreviewDialog.open,
      onOpenChange: handleOpenChange,
      className: "overflow-hidden",
      focusManagerProps: {
        initialFocus: 0
      },
      children: [
        /* @__PURE__ */ jsxRuntime.jsx(
          designSystem.Dialog.Header,
          {
            title: attachmentPreviewDialog.attachment?.name,
            className: "border-none"
          }
        ),
        /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Content, { children: attachmentPreviewDialog.attachment && /* @__PURE__ */ jsxRuntime.jsx(
          "img",
          {
            src: attachmentPreviewDialog.attachment.url,
            alt: attachmentPreviewDialog.attachment.name,
            className: "max-h-[80vh] max-w-[80vw]"
          }
        ) })
      ]
    }
  );
});
exports.AttachmentPreviewDialog = AttachmentPreviewDialog;
//# sourceMappingURL=attachment-preview-dialog.cjs.map
