import { e as usePHModal, a9 as useDocumentById, p as useTranslation, aa as validateDocument, j as jsxRuntimeExports, i as closePHModal, ab as exportFile } from "./index-DEuI3Aoa.js";
import { C as ConnectConfirmationModal } from "./confirmation-modal-JaOmXglG.js";
function ExportDocumentWithErrorsModal() {
  const phModal = usePHModal();
  const open = phModal?.type === "exportDocumentWithErrors";
  const documentId = open ? phModal.documentId : void 0;
  const [document] = useDocumentById(documentId);
  const { t } = useTranslation();
  if (!document) {
    return null;
  }
  const validationErrors = validateDocument(document);
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
    ConnectConfirmationModal,
    {
      header: t("modals.exportDocumentWithErrors.title"),
      title: t("modals.exportDocumentWithErrors.title"),
      body: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: t("modals.exportDocumentWithErrors.body") }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "mt-4 flex list-disc flex-col items-start px-4 text-xs", children: validationErrors.map((error, index) => /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: error.message }, index)) })
      ] }),
      cancelLabel: t("common.cancel"),
      continueLabel: t("common.export"),
      onCancel: () => closePHModal(),
      onContinue: async () => {
        try {
          await exportFile(document);
        } catch (error) {
          console.error(error);
        } finally {
          closePHModal();
        }
      },
      open,
      onOpenChange: (status) => {
        if (!status) return closePHModal();
      }
    }
  );
}
export {
  ExportDocumentWithErrorsModal
};
//# sourceMappingURL=ExportDocumentWithErrorsModal-peNRErWI.js.map
