import { importShared } from './__federation_fn_import-DDy87RIy.js';
import { j as jsxRuntimeExports } from './jsx-runtime-XI9uIe3W.js';
import { a } from './styles-DDrlgeIu.js';
import { E as EmailConfigTabs } from './email-config-tabs-D4ah5Oeo.js';
import { c as createPostmarkPluginDefinitionSchema } from './plugin-definition-vuaf6Owu.js';

const {PluginUtils} = await importShared('@baseplate-dev/project-builder-lib');

const {useBlockUnsavedChangesNavigate,useDefinitionSchema,useProjectDefinition,useResettableForm} = await importShared('@baseplate-dev/project-builder-lib/web');

const {FormActionBar,SectionList,SectionListSection,SectionListSectionContent,SectionListSectionDescription,SectionListSectionHeader,SectionListSectionTitle} = await importShared('@baseplate-dev/ui-components');
const {useMemo} = await importShared('react');
function PostmarkDefinitionEditor({
  definition: pluginMetadata,
  metadata,
  onSave
}) {
  const { definitionContainer, saveDefinitionWithFeedback } = useProjectDefinition();
  const postmarkPluginDefinitionSchema = useDefinitionSchema(
    createPostmarkPluginDefinitionSchema
  );
  const defaultValues = useMemo(() => {
    if (pluginMetadata?.config) {
      return pluginMetadata.config;
    }
    return {
      postmarkOptions: {}
    };
  }, [pluginMetadata?.config]);
  const form = useResettableForm({
    resolver: a(postmarkPluginDefinitionSchema),
    defaultValues
  });
  const { control, reset, handleSubmit } = form;
  const onSubmit = handleSubmit(
    (data) => saveDefinitionWithFeedback(
      (draftConfig) => {
        PluginUtils.setPluginConfig(
          draftConfig,
          metadata,
          data,
          definitionContainer
        );
      },
      {
        successMessage: "Successfully saved Postmark configuration!",
        onSuccess: () => {
          onSave();
        }
      }
    )
  );
  useBlockUnsavedChangesNavigate({ control, reset, onSubmit });
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "email:relative email:flex email:h-full email:flex-1 email:flex-col email:gap-4 email:overflow-hidden", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(EmailConfigTabs, {}),
    /* @__PURE__ */ jsxRuntimeExports.jsx(
      "div",
      {
        className: "email:mb-[--action-bar-height] email:flex email:flex-1 email:overflow-y-auto",
        style: {
          "--action-bar-height": "52px"
        },
        children: /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit, className: "email:max-w-6xl email:flex-1", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "email:pb-16", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SectionList, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(SectionListSection, { children: [
            /* @__PURE__ */ jsxRuntimeExports.jsxs(SectionListSectionHeader, { children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx(SectionListSectionTitle, { children: "Postmark Configuration" }),
              /* @__PURE__ */ jsxRuntimeExports.jsx(SectionListSectionDescription, { children: "Postmark is configured using the POSTMARK_SERVER_TOKEN environment variable. No additional configuration is needed here." })
            ] }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(SectionListSectionContent, { className: "email:space-y-6", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "email:text-sm email:text-muted-foreground", children: [
              "Add your Postmark Server API Token to your environment variables as ",
              /* @__PURE__ */ jsxRuntimeExports.jsx("code", { children: "POSTMARK_SERVER_TOKEN" }),
              "."
            ] }) })
          ] }) }) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(FormActionBar, { form, allowSaveWithoutDirty: !pluginMetadata })
        ] })
      }
    )
  ] });
}

const {createPluginModule,webConfigSpec} = await importShared('@baseplate-dev/project-builder-lib');
const web = createPluginModule({
  name: "web",
  dependencies: {
    webConfig: webConfigSpec
  },
  initialize: ({ webConfig }, { pluginKey }) => {
    webConfig.components.set(pluginKey, PostmarkDefinitionEditor);
  }
});

export { web as default };
//# sourceMappingURL=__federation_expose_postmarkCoreWeb-CDsV5Jit.js.map
