import { jsx as t, Fragment as o, jsxs as u } from "react/jsx-runtime";
import { s as v, q as F, t as T, w as a, W as _, x as L, f as V, S as x } from "./index-ZQlxzdt5.js";
import { useMemo as W, useState as p } from "react";
import { A as $ } from "./AppCard-cTGNOAHy.js";
import { c as g, i as j, a as C } from "./currencyOptions-kannG2hu.js";
const H = function({ app: S, eventType: A }) {
  var f, h;
  const i = v.useSearchParams(), d = v.usePathname(), P = W(
    () => `${d}${i ? `?${i.toString()}` : ""}`,
    [d, i]
  ), { t: n } = F(), { getAppData: r, setAppData: c } = T(), y = r("price"), l = r("currency"), k = r("paymentOption"), N = r("enabled"), [s, O] = p(g.find((e) => e.value === l)), [w, E] = p(
    j(l) ? C[l] : ""
  ), [b, q] = p(N), m = ((f = a) == null ? void 0 : f.find((e) => k === e.value)) || {
    label: a[0].label,
    value: a[0].value
  }, D = ((h = A.recurringEvent) == null ? void 0 : h.count) !== void 0;
  return /* @__PURE__ */ t(
    $,
    {
      returnTo: _ + P,
      app: S,
      switchChecked: b,
      switchOnClick: (e) => {
        q(e);
      },
      description: /* @__PURE__ */ t(o, { children: "Add a mock payment to your events" }),
      children: /* @__PURE__ */ t(o, { children: D ? /* @__PURE__ */ t(L, { className: "mt-2", severity: "warning", title: n("warning_recurring_event_payment") }) : b && /* @__PURE__ */ u(o, { children: [
        /* @__PURE__ */ t("div", { className: "mt-2 block items-center sm:flex", children: /* @__PURE__ */ t(
          V,
          {
            id: "test-mock-payment-app-price",
            label: "Price",
            labelSrOnly: !0,
            addOnLeading: w,
            addOnSuffix: l,
            step: "0.01",
            min: "0.5",
            type: "number",
            required: !0,
            className: "block w-full rounded-sm pl-2 text-sm",
            placeholder: "Price",
            onChange: (e) => {
              c("price", Number(e.target.value) * 100), s && c("currency", s.value);
            },
            value: y > 0 ? y / 100 : void 0
          }
        ) }),
        /* @__PURE__ */ u("div", { className: "mt-5 w-60", children: [
          /* @__PURE__ */ t("label", { className: "text-default mb-1 block text-sm font-medium", htmlFor: "currency", children: n("currency") }),
          /* @__PURE__ */ t(
            x,
            {
              id: "test-mock-payment-app-currency-id",
              variant: "default",
              options: g,
              value: s,
              className: "text-black",
              defaultValue: s,
              onChange: (e) => {
                e && (O(e), E(C[e.value]), c("currency", e.value));
              }
            }
          )
        ] }),
        /* @__PURE__ */ u("div", { className: "mt-4 w-60", children: [
          /* @__PURE__ */ t("label", { className: "text-default mb-1 block text-sm font-medium", htmlFor: "currency", children: "Payment option" }),
          /* @__PURE__ */ t(
            x,
            {
              defaultValue: m ? { ...m, label: n(m.label) } : { ...a[0], label: n(a[0].label) },
              options: a.map((e) => ({ ...e, label: n(e.label) || e.label })),
              onChange: (e) => {
                e && c("paymentOption", e.value);
              },
              className: "mb-1 h-[38px] w-full",
              isDisabled: !1
            }
          )
        ] })
      ] }) })
    }
  );
};
export {
  H as default
};
