import { jsx as i, jsxs as l } from "react/jsx-runtime";
import { cn as m } from "../../utils/cn/cn.es.js";
import { EAnalyticsEventType as p, EAnalyticsEvent as b } from "../../types/analytics/analytics.es.js";
import a from "../../modules/IndividualProductCard/individualProductCard.module.css";
import { PlainFeaturesGroup as z } from "../../components/PlainFeaturesGroup/PlainFeaturesGroup.es.js";
import { ImageGallery as D } from "../../components/ImageGallery/ImageGallery.es.js";
import { RatingPreview as w } from "../../components/RatingPreview/RatingPreview.es.js";
import { Quote as G } from "../../components/Quote/Quote.es.js";
import { Typography as h } from "../../components/Typography/Typography.es.js";
import { Button as k } from "../../components/Button/Button.es.js";
import { TextButton as H } from "../../components/TextButton/TextButton.es.js";
import { FeaturesList as O } from "../../components/FeaturesList/FeaturesList.es.js";
import { PlanCard as P } from "./components/PlanCard/PlanCard.es.js";
import { SmartCallout as Q } from "../../components/SmartCallout/SmartCallout.es.js";
const ai = ({
  zenpatientId: E,
  name: d,
  description: v,
  features: A,
  featuresGroup: y,
  images: S,
  quote: f,
  label: I,
  rating: u,
  ratingText: g,
  plans: o,
  button: t,
  textButton: n,
  selectedPlanId: N,
  onSelectPlan: c,
  trackingEvent: V,
  trackingLocation: C,
  signupUrl: _
}) => {
  const s = o && o.length > 0 && c, F = (e) => {
    if (c == null || c(e), V) {
      const r = o == null ? void 0 : o.find((j) => j.id === e);
      p.interaction, r == null || r.price, r == null || r.duration;
    }
  }, L = () => {
    var r;
    const e = {
      event: b.ctaClicked,
      location: C || "not_set",
      type: p.interaction,
      component: "IndividualProductCard",
      element: "primary_button",
      payload: {
        productId: E,
        ctaLabel: t.label,
        productName: d,
        selectedPlanId: N || "none"
      }
    };
    (r = window.eventBus) == null || r.emit("analytics", e);
  }, T = () => {
    var e;
    (e = window.eventBus) == null || e.emit("analytics", {
      event: b.ctaClicked,
      location: C || "not_set",
      type: p.interaction,
      component: "IndividualProductCard",
      element: "secondary_button",
      payload: {
        ctaLabel: n == null ? void 0 : n.label,
        productName: d
      }
    });
  };
  return /* @__PURE__ */ i("section", { className: a.root, children: /* @__PURE__ */ l("div", { className: m(a.container, !s && a.noPlans), children: [
    /* @__PURE__ */ l("div", { className: a.gallery, children: [
      /* @__PURE__ */ i(D, { images: S, label: I }),
      /* @__PURE__ */ i("div", { className: m(a.ratingContainer, a.mobileOnly), children: /* @__PURE__ */ i(w, { rating: u, text: g }) }),
      f && /* @__PURE__ */ i("div", { className: a.quoteWrapper, children: /* @__PURE__ */ i(G, { ...f }) })
    ] }),
    /* @__PURE__ */ l("div", { className: a.info, children: [
      /* @__PURE__ */ l("div", { className: a.infoHeader, children: [
        /* @__PURE__ */ i(h, { as: "h3", defaultVariant: "displayXs", mobileVariant: "headingLg", weight: "regular", children: d }),
        !!v && /* @__PURE__ */ i(
          h,
          {
            as: "p",
            defaultVariant: "bodySm",
            className: a.infoDescription,
            weight: "regular",
            children: v
          }
        )
      ] }),
      !s && /* @__PURE__ */ l("div", { className: a.actions, children: [
        /* @__PURE__ */ i(k, { variant: "primary", size: "lg", ...t, onClick: L, children: t.label }),
        n && /* @__PURE__ */ i(H, { ...n, onClick: T, children: n.label })
      ] }),
      /* @__PURE__ */ i(O, { features: A }),
      y && /* @__PURE__ */ i(z, { ...y })
    ] }),
    s && /* @__PURE__ */ l("div", { className: a.plansSection, children: [
      /* @__PURE__ */ l("div", { className: a.plans, children: [
        /* @__PURE__ */ i(h, { as: "h4", defaultVariant: "labelSm", emphasis: !0, weight: "regular", children: "Subscribe & Save" }),
        o.map((e) => /* @__PURE__ */ i(
          P,
          {
            plan: e,
            onSelect: F,
            isActive: N === e.id
          },
          e.id
        ))
      ] }),
      /* @__PURE__ */ i("div", { className: m(a.ratingContainer, a.desktopOnly), children: /* @__PURE__ */ i(w, { rating: u, text: g }) }),
      /* @__PURE__ */ l("div", { className: a.actions, children: [
        /* @__PURE__ */ i(k, { variant: "primary", size: "lg", as: "a", href: _ || "#0", ...t, children: t.label }),
        /* @__PURE__ */ i(Q, { label: "HSA/FSA Eligible", type: "plain" })
      ] })
    ] })
  ] }) });
};
export {
  ai as IndividualProductCard
};
