import { jsxs as u, Fragment as o, jsx as a } from "react/jsx-runtime";
import { useState as O, useEffect as k } from "react";
import { o as w, t as p, d as _, w as P, x as K, S as E } from "./index-C62tPk5p.js";
const F = [
  {
    label: "on_booking_option",
    value: "ON_BOOKING"
  }
], n = [
  { label: "United States dollar (USD)", value: "usd" },
  { label: "Singapore dollar (SGD)", value: "sgd" },
  { label: "Malaysian ringgit (MYR)", value: "myr" },
  { label: "Indonesian rupiah (IDR)", value: "idr" },
  { label: "Japanese yen (JPY)", value: "jpy" },
  { label: "Hong Kong dollar (HKD)", value: "hkd" },
  { label: "Thai baht (THB)", value: "thb" },
  { label: "Australian dollar (AUD)", value: "aud" },
  { label: "New Zealand dollar (NZD)", value: "nzd" },
  { label: "British pound sterling (GBP)", value: "gbp" },
  { label: "Philippine peso (PHP)", value: "php" },
  { label: "Indian rupee (INR)", value: "inr" },
  { label: "Chinese yuan (CNY)", value: "cny" },
  { label: "Euro (EUR)", value: "eur" },
  { label: "Swiss franc (CHF)", value: "chf" },
  { label: "Danish krone (DKK)", value: "dkk" },
  { label: "Swedish krona (SEK)", value: "sek" },
  { label: "Norwegian krone (NOK)", value: "nok" },
  { label: "Vietnamese đồng (VND)", value: "vnd" },
  { label: "Canadian dollar (CAD)", value: "cad" },
  { label: "South Korean won (KRW)", value: "krw" }
], V = ({
  getAppData: l,
  setAppData: r,
  disabled: h,
  eventType: d
}) => {
  var b;
  const m = l("price"), t = l("currency") || n[0].value, [i, f] = O(
    n.find((e) => e.value === t) || {
      label: n[0].label,
      value: n[0].value
    }
  ), g = l("paymentOption"), c = l("enabled"), { t: s } = w(), v = ((b = d.recurringEvent) == null ? void 0 : b.count) !== void 0, S = !!d.seatsPerTimeSlot, N = (e, y) => 0 .toLocaleString(e, {
    style: "currency",
    currency: y,
    minimumFractionDigits: 0,
    maximumFractionDigits: 0
  }).replace(/\d/g, "").trim();
  k(() => {
    c && (l("currency") || r("currency", n[0].value), l("paymentOption") || r("paymentOption", F[0].value));
  }, [c, l, r]);
  const x = (e) => {
    const C = Math.floor(e).toString();
    return parseInt(C);
  };
  return /* @__PURE__ */ u(o, { children: [
    v && /* @__PURE__ */ a(p, { className: "mt-2", severity: "warning", title: s("warning_recurring_event_payment") }),
    !v && c && /* @__PURE__ */ u(o, { children: [
      /* @__PURE__ */ a("div", { className: "mt-4 block items-center justify-start sm:flex sm:space-x-2", children: /* @__PURE__ */ a(
        _,
        {
          "data-testid": "stripe-price-input",
          label: s("price"),
          className: "h-[38px]",
          addOnLeading: /* @__PURE__ */ a(o, { children: i.value ? N("en", i.value) : "" }),
          addOnSuffix: t.toUpperCase(),
          addOnClassname: "h-[38px]",
          step: "1",
          min: "1",
          type: "number",
          required: !0,
          placeholder: "Price",
          disabled: h,
          onChange: (e) => {
            r("price", P(Number(e.target.value), t));
          },
          value: m > 0 ? x(K(m, t)) : void 0
        }
      ) }),
      /* @__PURE__ */ u("div", { className: "mt-5 w-60", children: [
        /* @__PURE__ */ a("label", { className: "text-default mb-1 block text-sm font-medium", htmlFor: "currency", children: s("currency") }),
        /* @__PURE__ */ a(
          E,
          {
            "data-testid": "stripe-currency-select",
            variant: "default",
            options: n,
            value: i,
            className: "text-black",
            defaultValue: i,
            onChange: (e) => {
              e && (f(e), r("currency", e.value));
            }
          }
        )
      ] }),
      S && g === "HOLD" && /* @__PURE__ */ a(p, { className: "mt-2", severity: "warning", title: s("seats_and_no_show_fee_error") })
    ] })
  ] });
};
export {
  V as default
};
