import { jsx as m, jsxs as L } from "react/jsx-runtime";
import { useEffect as R } from "react";
import { a as v } from "./index.CfQlFjZU.js";
import { S as T } from "./shared.EdGf6tcG.js";
import { a as k } from "./TextInput.63vMRxAK.js";
import { U as D } from "./Upload.X0oU32lw.js";
import { a as E } from "./Button.CpTwUWVr.js";
import { u as S, M as w } from "./modal.BZAvb1Nx.js";
import { u as x } from "./useId.7P31viIO.js";
const I = "creator_mailLinkContainer_p7Z7y", N = { mailLinkContainer: I }, j = ({
  onSubmit: s,
  onCancel: l,
  onThumbnailChange: t,
  onTitleChange: r,
  onEmailChange: p,
  onCropComplete: u,
  thumbnailUploading: c,
  thumbnail: d,
  title: M,
  email: f,
  helpers: g,
  errors: b,
  disabled: y,
  visible: i = !0
}) => {
  const e = x(), o = 1 / 1, h = ["image/png", "image/jpeg", "image/webp"], { Modal: A, openModal: n, closeModal: a } = S();
  return R(() => {
    i ? n() : a();
  }, [i, n, a]), {
    onSubmit: (C) => {
      C.preventDefault(), s(C);
    },
    onCancel: l,
    onThumbnailChange: t,
    onThumbnailRemove: () => {
      t(null);
    },
    onTitleChange: r,
    onEmailChange: p,
    thumbnail: d,
    title: M || "",
    email: f || "",
    suggestedAllowedMediaTypes: h,
    thumbnailUploading: c,
    disabled: y,
    helpers: g,
    errors: b,
    formId: e,
    containerClassName: N.mailLinkContainer,
    Modal: A,
    squareAspectRatio: o,
    onCropComplete: u
  };
}, U = ({
  onSubmit: s,
  onCancel: l,
  onThumbnailChange: t,
  onThumbnailRemove: r,
  onTitleChange: p,
  onEmailChange: u,
  onCropComplete: c,
  thumbnail: d,
  title: M,
  email: f,
  suggestedAllowedMediaTypes: g,
  thumbnailUploading: b,
  disabled: y,
  helpers: i,
  errors: e,
  formId: o,
  containerClassName: h,
  Modal: A,
  squareAspectRatio: n
}) => /* @__PURE__ */ m(
  A,
  {
    type: w.ADVANCED,
    heading: "Add Mail Link",
    buttons: [
      {
        label: "Done",
        semantic: T.PRIMARY,
        type: E.SUBMIT,
        form: o,
        disabled: y
      },
      {
        label: "Cancel",
        semantic: T.SECONDARY,
        onClick: () => l()
      }
    ],
    onDismiss: () => l(),
    children: /* @__PURE__ */ L("form", { id: o, className: h, onSubmit: s, children: [
      /* @__PURE__ */ m(
        D,
        {
          allowCropping: !0,
          label: "Thumbnail",
          helper: e?.thumbnail || i?.thumbnail,
          error: !!e?.thumbnail,
          suggestedAllowedTypes: g,
          onFileSelect: (a) => t(a),
          onFileRemove: () => r(),
          file: d,
          uploading: b,
          onCropComplete: c,
          cropAspectRatio: n
        }
      ),
      /* @__PURE__ */ m(
        k,
        {
          label: "Title",
          helper: e?.title || i?.title,
          isError: !!e?.title,
          value: M,
          onChange: (a) => p(a.target.value)
        }
      ),
      /* @__PURE__ */ m(
        k,
        {
          label: "Email",
          type: "email",
          helper: e?.email || i?.email,
          isError: !!e?.email,
          value: f,
          onChange: (a) => u(a.target.value)
        }
      )
    ] })
  }
), z = v(U, j);
export {
  z as M
};
