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