@lukoweb/apitogo-plugin-dev-portal-billing 0.2.77 → 0.2.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
2
- import { f as parseManifestPlans, n as useDevPortalPreviewMode, r as useIsDemoSession, s as isActiveSubscription, t as useDevPortalApiBaseUrl, y as withPlanFeatures } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
3
- import { t as PricingCard } from "./PricingCard-KDRcH2ny.mjs";
2
+ import { b as withPlanFeatures, c as isActiveSubscription, n as useDevPortalPreviewMode, p as parseManifestPlans, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-TaJ7GhG5.mjs";
3
+ import { t as PricingCard } from "./PricingCard-CrN4GIZ7.mjs";
4
4
  import { n as readProblemDetail } from "./problem-details-n20-dy3w.mjs";
5
- import { t as useMySubscriptions } from "./useMySubscriptions-BHp7cjkN.mjs";
6
- import { t as usePlans } from "./usePlans-BKT8rIgl.mjs";
5
+ import { t as useMySubscriptions } from "./useMySubscriptions-DnjIFrcQ.mjs";
6
+ import { t as usePlans } from "./usePlans-BfvrukjB.mjs";
7
7
  import { n as readPendingCheckout, t as clearPendingCheckout } from "./pending-checkout-DpVaNnTu.mjs";
8
8
  import { Head } from "@lukoweb/apitogo/components";
9
9
  import { CreditCardIcon } from "@lukoweb/apitogo/icons";
@@ -1,8 +1,8 @@
1
1
  import { n as ALREADY_SUBSCRIBED_PARAM, s as PRICING_PATH, t as ACCOUNT_PLANS_PATH } from "./paths-DBr3Dj_q.mjs";
2
- import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
2
+ import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-TaJ7GhG5.mjs";
3
3
  import { n as readProblemDetail, t as isAlreadySubscribedMessage } from "./problem-details-n20-dy3w.mjs";
4
4
  import { r as rememberPendingCheckout } from "./pending-checkout-DpVaNnTu.mjs";
5
- import { t as FREE_CHECKOUT_MARKER } from "./billing-state-D0Nkuz7i.mjs";
5
+ import { t as FREE_CHECKOUT_MARKER } from "./billing-state-CIqyRwkD.mjs";
6
6
  import { ShieldIcon } from "@lukoweb/apitogo/icons";
7
7
  import { Link, useNavigate, useSearchParams } from "@lukoweb/apitogo/router";
8
8
  import { useEffect } from "react";
@@ -58,6 +58,8 @@ const RedirectPage = ({ icon: Icon, title, description, url, children }) => {
58
58
  const CheckoutPage = () => {
59
59
  const [searchParams] = useSearchParams();
60
60
  const planSku = searchParams.get("planSku") ?? "";
61
+ const billingPeriod = searchParams.get("period") ?? void 0;
62
+ const currency = searchParams.get("currency") ?? void 0;
61
63
  const navigate = useNavigate();
62
64
  const auth = useAuth();
63
65
  const apiBaseUrl = useDevPortalApiBaseUrl();
@@ -69,6 +71,8 @@ const CheckoutPage = () => {
69
71
  "dev-portal-checkout",
70
72
  apiBaseUrl,
71
73
  planSku,
74
+ billingPeriod,
75
+ currency,
72
76
  auth.profile?.sub
73
77
  ],
74
78
  enabled: Boolean(planSku) && !isPreview && !isDemoSession && auth.isAuthenticated && Boolean(apiBaseUrl),
@@ -81,7 +85,11 @@ const CheckoutPage = () => {
81
85
  "Content-Type": "application/json"
82
86
  },
83
87
  credentials: "include",
84
- body: JSON.stringify({ planSku })
88
+ body: JSON.stringify({
89
+ planSku,
90
+ billingPeriod,
91
+ currency
92
+ })
85
93
  });
86
94
  if (!response.ok) throw new Error(await readProblemDetail(response) ?? "Checkout failed.");
87
95
  return await response.json();
@@ -1,8 +1,8 @@
1
1
  import "./DevPortalBillingContext-BUQPLoyk.mjs";
2
2
  import { s as PRICING_PATH } from "./paths-DBr3Dj_q.mjs";
3
- import { l as isPlanCustomPriced, n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
3
+ import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl, u as isPlanCustomPriced } from "./useDevPortalApiBaseUrl-TaJ7GhG5.mjs";
4
4
  import { n as readProblemDetail } from "./problem-details-n20-dy3w.mjs";
5
- import { t as usePlans } from "./usePlans-BKT8rIgl.mjs";
5
+ import { t as usePlans } from "./usePlans-BfvrukjB.mjs";
6
6
  import { Link, useSearchParams } from "@lukoweb/apitogo/router";
7
7
  import { useState } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -1,9 +1,9 @@
1
1
  import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
2
2
  import { t as ACCOUNT_PLANS_PATH } from "./paths-DBr3Dj_q.mjs";
3
- import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
3
+ import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-TaJ7GhG5.mjs";
4
4
  import { r as createDemoCredentials, t as DEMO_GATEWAY_KEY_HEADER } from "./demo-session-yK9qEqV-.mjs";
5
- import { n as useApiKeys } from "./useApiKeys-Co1xhgcO.mjs";
6
- import { n as apiReferencePath, r as ApiKeysPanel } from "./account-links-DZ9i1WTa.mjs";
5
+ import { n as useApiKeys } from "./useApiKeys-BE2aLp-q.mjs";
6
+ import { n as apiReferencePath, r as ApiKeysPanel } from "./account-links-DGL7nKSZ.mjs";
7
7
  import { i as ChoosePlanNotice, r as keyPlanNote, t as apiKeysPageState } from "./page-state-Cmo0FPLl.mjs";
8
8
  import { Head } from "@lukoweb/apitogo/components";
9
9
  import { KeyRoundIcon } from "@lukoweb/apitogo/icons";
@@ -1,6 +1,6 @@
1
1
  import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
2
2
  import { i as CONTACT_SALES_PATH, r as CHECKOUT_PATH } from "./paths-DBr3Dj_q.mjs";
3
- import { d as listPlanFeatureLines, i as formatPlanDisplayPrice, l as isPlanCustomPriced, o as formatPlanPriceUnit, s as isActiveSubscription, u as isPlanFree } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
3
+ import { a as formatPlanDisplayPrice, c as isActiveSubscription, d as isPlanFree, f as listPlanFeatureLines, i as formatMoney, s as formatPlanPriceUnit, u as isPlanCustomPriced } from "./useDevPortalApiBaseUrl-TaJ7GhG5.mjs";
4
4
  import { Button } from "@lukoweb/apitogo/components";
5
5
  import { Link as Link$1 } from "@lukoweb/apitogo/router";
6
6
  import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@lukoweb/apitogo/ui/AlertDialog.js";
@@ -17,9 +17,16 @@ const accountCtaLabel = (plan) => {
17
17
  if (isPlanCustomPriced(plan)) return "Contact sales";
18
18
  return isPlanFree(plan) ? "Get started" : "Subscribe";
19
19
  };
20
- /** Custom-priced plans skip checkout and open the contact-sales form. */
21
- const planCtaPath = (plan) => `${isPlanCustomPriced(plan) ? CONTACT_SALES_PATH : CHECKOUT_PATH}?planSku=${encodeURIComponent(plan.sku)}`;
22
- const PricingCard = ({ plan, mode = "public", subscriptionStatus, isSubscribed = false, onUnsubscribe, onSwitch, isSwitching = false, isCanceling = false, cancelDisabled = false, featured = false, isConfirming = false }) => {
20
+ /**
21
+ * Custom-priced plans skip checkout and open the contact-sales form. A plan sold at several prices also says which one
22
+ * the card shows (its period and currency), so checkout charges what the visitor saw.
23
+ */
24
+ const planCtaPath = (plan) => {
25
+ const base = `${isPlanCustomPriced(plan) ? CONTACT_SALES_PATH : CHECKOUT_PATH}?planSku=${encodeURIComponent(plan.sku)}`;
26
+ if (isPlanCustomPriced(plan) || (plan.prices?.length ?? 0) < 2) return base;
27
+ return `${base}&period=${encodeURIComponent(plan.billingPeriod)}&currency=${encodeURIComponent(plan.priceCurrency)}`;
28
+ };
29
+ const PricingCard = ({ plan, mode = "public", subscriptionStatus, isSubscribed = false, onUnsubscribe, onSwitch, isSwitching = false, isCanceling = false, cancelDisabled = false, featured = false, isConfirming = false, discount = null }) => {
23
30
  const isActive = isSubscribed || isActiveSubscription(subscriptionStatus ?? "");
24
31
  const { showEndpoints } = useDevPortalBillingConfig();
25
32
  const features = listPlanFeatureLines(plan, { showEndpoints });
@@ -46,14 +53,39 @@ const PricingCard = ({ plan, mode = "public", subscriptionStatus, isSubscribed =
46
53
  }) : null
47
54
  ]
48
55
  }),
49
- /* @__PURE__ */ jsx("p", {
50
- className: "mt-3.5 text-[2.1rem] font-extrabold tracking-[-0.02em]",
51
- children: displayPrice
56
+ /* @__PURE__ */ jsxs("p", {
57
+ className: "mt-3.5 flex flex-wrap items-baseline gap-x-2.5",
58
+ children: [discount ? /* @__PURE__ */ jsxs("s", {
59
+ className: "text-xl font-semibold text-muted-foreground",
60
+ "data-testid": `original-price-${plan.sku}`,
61
+ children: [/* @__PURE__ */ jsx("span", {
62
+ className: "sr-only",
63
+ children: "Regular price "
64
+ }), formatMoney(discount.originalAmount, plan.priceCurrency)]
65
+ }) : null, /* @__PURE__ */ jsxs("span", {
66
+ className: "text-[2.1rem] font-extrabold tracking-[-0.02em]",
67
+ children: [discount ? /* @__PURE__ */ jsx("span", {
68
+ className: "sr-only",
69
+ children: "Now "
70
+ }) : null, displayPrice]
71
+ })]
52
72
  }),
53
73
  /* @__PURE__ */ jsx("p", {
54
- className: "mb-[18px] mt-0.5 text-[0.78125rem] text-muted-foreground",
74
+ className: "mt-0.5 text-[0.78125rem] text-muted-foreground",
55
75
  children: formatPlanPriceUnit(plan)
56
76
  }),
77
+ discount ? /* @__PURE__ */ jsxs("p", {
78
+ className: "mt-1.5 text-[0.8125rem] font-semibold text-emerald-600",
79
+ "data-testid": `saving-${plan.sku}`,
80
+ children: [
81
+ "You save ",
82
+ formatMoney(discount.savedAmount, plan.priceCurrency),
83
+ " (",
84
+ discount.percent,
85
+ "%)"
86
+ ]
87
+ }) : null,
88
+ /* @__PURE__ */ jsx("div", { className: "mb-[18px]" }),
57
89
  /* @__PURE__ */ jsx("div", {
58
90
  className: "space-y-2",
59
91
  children: mode === "account" ? isActive ? /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -0,0 +1,394 @@
1
+ import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
2
+ import { b as withPlanFeatures, d as isPlanFree, g as pickFeaturedPlanSku, n as useDevPortalPreviewMode, p as parseManifestPlans, u as isPlanCustomPriced } from "./useDevPortalApiBaseUrl-TaJ7GhG5.mjs";
3
+ import { t as PricingCard } from "./PricingCard-CrN4GIZ7.mjs";
4
+ import { t as usePlans } from "./usePlans-BfvrukjB.mjs";
5
+ import { t as isPreviewPricingEnabled } from "./pricing-config-Bc6eWFUO.mjs";
6
+ import { a as isPricingLoading, n as buildCompareRows } from "./billing-state-CIqyRwkD.mjs";
7
+ import { Head, Heading } from "@lukoweb/apitogo/components";
8
+ import { Navigate } from "@lukoweb/apitogo/router";
9
+ import { useState } from "react";
10
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
+ import { useAuth } from "@lukoweb/apitogo/hooks";
12
+
13
+ //#region src/utils/billing-period.ts
14
+ const PRICING_PERIODS = [
15
+ "monthly",
16
+ "quarterly",
17
+ "yearly"
18
+ ];
19
+ const PERIOD_LABELS = {
20
+ monthly: "Monthly",
21
+ quarterly: "Quarterly",
22
+ yearly: "Yearly"
23
+ };
24
+ const MONTHS = {
25
+ monthly: 1,
26
+ quarterly: 3,
27
+ yearly: 12
28
+ };
29
+ /** The view a billing period (`monthly`, `quarterly`, `annual`, `month`, `year`, …) belongs to. */
30
+ function periodOf(billingPeriod) {
31
+ const normalized = billingPeriod?.trim().toLowerCase();
32
+ if (normalized === "annual" || normalized === "year" || normalized === "yearly") return "yearly";
33
+ if (normalized === "quarterly" || normalized === "quarter") return "quarterly";
34
+ return "monthly";
35
+ }
36
+ /** A paid plan with a fixed price: the only kind that belongs to a period. Free and contact-us plans show in every view. */
37
+ const isPaidFixed = (plan) => !isPlanFree(plan) && !isPlanCustomPriced(plan);
38
+ /** The periods a plan is sold at, or `all` for a free or contact-us plan. */
39
+ function planPeriods(plan) {
40
+ if (!isPaidFixed(plan)) return "all";
41
+ if (plan.prices?.length) return new Set(plan.prices.map((price) => periodOf(price.billingPeriod)));
42
+ return new Set([periodOf(plan.billingPeriod)]);
43
+ }
44
+ /** The periods the page offers: every period some paid plan is sold at, shortest first. */
45
+ function availablePeriods(plans) {
46
+ const offered = /* @__PURE__ */ new Set();
47
+ for (const plan of plans) {
48
+ const periods = planPeriods(plan);
49
+ if (periods !== "all") for (const period of periods) offered.add(period);
50
+ }
51
+ return PRICING_PERIODS.filter((period) => offered.has(period));
52
+ }
53
+ /** The switch is offered only when paid plans come in more than one period; otherwise every plan shows as before. */
54
+ function hasPeriodChoice(plans) {
55
+ return availablePeriods(plans).length > 1;
56
+ }
57
+ /**
58
+ * The plan as it is sold in one period: a plan with several prices shows that period's price (in the plan's own
59
+ * currency when it has one there). A plan with no price in that period keeps its default price.
60
+ */
61
+ function planAtPeriod(plan, period) {
62
+ const inPeriod = (plan.prices ?? []).filter((price) => periodOf(price.billingPeriod) === period);
63
+ const price = inPeriod.find((p) => p.currency.toLowerCase() === plan.priceCurrency.toLowerCase()) ?? inPeriod.at(0);
64
+ return price ? {
65
+ ...plan,
66
+ priceAmount: price.amount,
67
+ priceCurrency: price.currency,
68
+ billingPeriod: price.billingPeriod
69
+ } : plan;
70
+ }
71
+ /**
72
+ * The plans of one view, in their own order: plans sold in that period (at that period's price), plans with several
73
+ * prices (at their default price when they have none in that period), and the free and contact-us plans.
74
+ */
75
+ function plansForPeriod(plans, period) {
76
+ if (!hasPeriodChoice(plans)) return plans;
77
+ return plans.filter((plan) => {
78
+ const periods = planPeriods(plan);
79
+ return periods === "all" || periods.has(period) || Boolean(plan.prices?.length);
80
+ }).map((plan) => planAtPeriod(plan, period));
81
+ }
82
+ const nameKey = (plan) => `${plan.displayName.trim().toLowerCase()}|${plan.priceCurrency.trim().toLowerCase()}`;
83
+ /** The monthly price to compare a plan with: its own monthly price, or the monthly plan with the same name. */
84
+ function monthlyPriceFor(plan, plans) {
85
+ const own = plan.prices?.find((price) => periodOf(price.billingPeriod) === "monthly" && price.currency.toLowerCase() === plan.priceCurrency.toLowerCase());
86
+ if (own) return own.amount;
87
+ return plans.map((other) => planAtPeriod(other, "monthly")).find((other) => isPaidFixed(other) && periodOf(other.billingPeriod) === "monthly" && nameKey(other) === nameKey(plan))?.priceAmount;
88
+ }
89
+ const cents = (amount) => Math.round(amount * 100) / 100;
90
+ /**
91
+ * The saving of a plan as shown (already at its period's price) against paying monthly for as long: its own monthly
92
+ * price, or the monthly plan with the same name and currency. Null for a monthly price, nothing to compare with, or no
93
+ * saving.
94
+ */
95
+ function discountFor(plan, plans) {
96
+ if (!isPaidFixed(plan)) return null;
97
+ const period = periodOf(plan.billingPeriod);
98
+ if (period === "monthly") return null;
99
+ const monthly = monthlyPriceFor(plan, plans);
100
+ if (!monthly) return null;
101
+ const originalAmount = cents(monthly * MONTHS[period]);
102
+ const savedAmount = cents(originalAmount - plan.priceAmount);
103
+ if (savedAmount <= 0) return null;
104
+ const percent = Math.round(savedAmount / originalAmount * 100);
105
+ return percent > 0 ? {
106
+ originalAmount,
107
+ savedAmount,
108
+ percent
109
+ } : null;
110
+ }
111
+ /**
112
+ * What a plan saves in a longer period against paying monthly for as long, in whole percent. Null when there is
113
+ * nothing to compare with or no saving.
114
+ */
115
+ function savingsPercent(plan, period, plans) {
116
+ if (period === "monthly" || !isPaidFixed(plan)) return null;
117
+ const atPeriod = planAtPeriod(plan, period);
118
+ if (periodOf(atPeriod.billingPeriod) !== period) return null;
119
+ return discountFor(atPeriod, plans)?.percent ?? null;
120
+ }
121
+ /**
122
+ * A period button's badge: "Save 20%" when every plan saves the same, "Save up to 25%" when they differ, null when
123
+ * none saves anything.
124
+ */
125
+ function savingsLabel(plans, period) {
126
+ const savings = plans.map((plan) => savingsPercent(plan, period, plans)).filter((percent) => percent !== null);
127
+ if (savings.length === 0) return null;
128
+ const best = Math.max(...savings);
129
+ return savings.every((percent) => percent === best) ? `Save ${best}%` : `Save up to ${best}%`;
130
+ }
131
+ /**
132
+ * The plan shown as "Popular" in a view: the marked plan, or, when it belongs to another period, the plan of this view
133
+ * with the same name (the yearly Pro when the monthly Pro is marked).
134
+ */
135
+ function featuredSkuForPeriod(visible, all, featuredSku) {
136
+ if (!featuredSku) return void 0;
137
+ if (visible.some((plan) => plan.sku === featuredSku)) return featuredSku;
138
+ const marked = all.find((plan) => plan.sku === featuredSku);
139
+ if (!marked) return void 0;
140
+ const name = marked.displayName.trim().toLowerCase();
141
+ return visible.find((plan) => plan.displayName.trim().toLowerCase() === name)?.sku;
142
+ }
143
+
144
+ //#endregion
145
+ //#region src/pages/PricingPage.tsx
146
+ const DEFAULT_COMPARE_ROWS = [
147
+ {
148
+ label: "Monthly requests",
149
+ values: [
150
+ "1,000",
151
+ "50,000",
152
+ "500,000",
153
+ "Unlimited"
154
+ ]
155
+ },
156
+ {
157
+ label: "Rate limit",
158
+ values: [
159
+ "10/sec",
160
+ "50/sec",
161
+ "200/sec",
162
+ "Custom"
163
+ ]
164
+ },
165
+ {
166
+ label: "Team seats",
167
+ values: [
168
+ "1",
169
+ "1",
170
+ "5",
171
+ "Unlimited"
172
+ ]
173
+ },
174
+ {
175
+ label: "Webhooks",
176
+ values: [
177
+ "—",
178
+ "Included",
179
+ "Included",
180
+ "Included"
181
+ ]
182
+ },
183
+ {
184
+ label: "SSO",
185
+ values: [
186
+ "—",
187
+ "—",
188
+ "—",
189
+ "Included"
190
+ ]
191
+ },
192
+ {
193
+ label: "Support",
194
+ values: [
195
+ "—",
196
+ "Email",
197
+ "Priority",
198
+ "Dedicated SLA"
199
+ ]
200
+ }
201
+ ];
202
+ /** Only what the platform itself does, so the defaults never promise anything for the tenant (API-124). */
203
+ const DEFAULT_FAQS = [{
204
+ question: "What happens if I go over my plan's limits?",
205
+ answer: "Calls over the rate limit or the quota are refused with a 429 response, and its Retry-After header says when to try again."
206
+ }, {
207
+ question: "Can I have more than one plan?",
208
+ answer: "Yes. Each plan has its own API keys and limits: create a key for a plan on the API keys page and use it in your app."
209
+ }];
210
+ const PricingPage = () => {
211
+ const { pricing, previewPlans, featuredPlanSku, planFeatures } = useDevPortalBillingConfig();
212
+ const isPreview = useDevPortalPreviewMode();
213
+ const pricingEnabled = isPreviewPricingEnabled() || isPreview;
214
+ const livePlans = usePlans();
215
+ const catalog = isPreview ? withPlanFeatures(parseManifestPlans(previewPlans), planFeatures) : livePlans.data;
216
+ const { isPending: authPending } = useAuth();
217
+ const [chosenPeriod, setPeriod] = useState("monthly");
218
+ const isLoading = isPricingLoading({
219
+ isPreview,
220
+ plansLoading: livePlans.isLoading,
221
+ hasPlans: Boolean(catalog?.plans?.length),
222
+ plansFailed: livePlans.isError,
223
+ authPending
224
+ });
225
+ const isError = isPreview ? false : livePlans.isError;
226
+ if (!pricingEnabled) return /* @__PURE__ */ jsx(Navigate, {
227
+ to: "/",
228
+ replace: true
229
+ });
230
+ const title = pricing?.title ?? "Plans and pricing";
231
+ const subtitle = pricing?.subtitle ?? "Choose the plan that fits how you use the API. Each plan lists its limits and what it includes.";
232
+ const allPlans = catalog?.plans ?? [];
233
+ const periods = availablePeriods(allPlans);
234
+ const periodChoice = periods.length > 1;
235
+ const period = periods.includes(chosenPeriod) ? chosenPeriod : periods.at(0) ?? "monthly";
236
+ const plans = plansForPeriod(allPlans, period);
237
+ const featuredSku = featuredSkuForPeriod(plans, allPlans, pickFeaturedPlanSku(allPlans, featuredPlanSku));
238
+ const compareRows = buildCompareRows({
239
+ plans,
240
+ configuredRows: pricing?.compareRows,
241
+ isPreview,
242
+ sampleRows: DEFAULT_COMPARE_ROWS
243
+ });
244
+ const faqs = pricing?.faqs && pricing.faqs.length > 0 ? pricing.faqs : DEFAULT_FAQS;
245
+ const compareHeaders = plans.length > 0 ? plans.map((p) => p.displayName) : [
246
+ "Free",
247
+ "Developer",
248
+ "Team",
249
+ "Enterprise"
250
+ ];
251
+ return /* @__PURE__ */ jsxs("div", {
252
+ className: "w-full",
253
+ children: [
254
+ /* @__PURE__ */ jsxs(Head, { children: [/* @__PURE__ */ jsx("title", { children: title }), /* @__PURE__ */ jsx("meta", {
255
+ name: "description",
256
+ content: subtitle
257
+ })] }),
258
+ /* @__PURE__ */ jsxs("section", {
259
+ className: "px-6 pb-4 pt-[clamp(3rem,6vw,4.5rem)] text-center",
260
+ children: [
261
+ /* @__PURE__ */ jsx("p", {
262
+ className: "text-xs font-bold uppercase tracking-[0.08em] text-primary",
263
+ children: "Pricing"
264
+ }),
265
+ /* @__PURE__ */ jsx(Heading, {
266
+ level: 1,
267
+ className: "mt-3 text-[clamp(2rem,3.5vw,3rem)] font-extrabold tracking-[-0.02em]",
268
+ "data-testid": "title",
269
+ children: title
270
+ }),
271
+ /* @__PURE__ */ jsx("p", {
272
+ className: "mx-auto mt-3.5 max-w-[34rem] text-lg leading-relaxed text-muted-foreground",
273
+ "data-testid": "subtitle",
274
+ children: subtitle
275
+ })
276
+ ]
277
+ }),
278
+ /* @__PURE__ */ jsxs("section", {
279
+ className: "px-6 pb-16 pt-8",
280
+ children: [
281
+ isLoading ? /* @__PURE__ */ jsx("p", {
282
+ className: "text-center text-muted-foreground",
283
+ children: "Loading plans…"
284
+ }) : null,
285
+ isError ? /* @__PURE__ */ jsx("p", {
286
+ className: "text-center text-destructive",
287
+ children: "Unable to load plans."
288
+ }) : null,
289
+ periodChoice ? /* @__PURE__ */ jsx("div", {
290
+ className: "mb-8 flex justify-center",
291
+ children: /* @__PURE__ */ jsx("div", {
292
+ role: "radiogroup",
293
+ "aria-label": "Billing period",
294
+ className: "inline-flex items-center gap-1 rounded-full border border-border bg-card p-1",
295
+ "data-testid": "billing-period-switch",
296
+ children: periods.map((option) => /* @__PURE__ */ jsxs("button", {
297
+ type: "button",
298
+ role: "radio",
299
+ "aria-checked": period === option,
300
+ onClick: () => setPeriod(option),
301
+ className: period === option ? "inline-flex items-center gap-2 rounded-full bg-primary px-5 py-2 text-sm font-semibold text-primary-foreground" : "inline-flex items-center gap-2 rounded-full px-5 py-2 text-sm font-semibold text-muted-foreground hover:text-foreground",
302
+ "data-testid": `billing-period-${option}`,
303
+ children: [PERIOD_LABELS[option], savingsLabel(allPlans, option) ? /* @__PURE__ */ jsx("span", {
304
+ className: period === option ? "rounded-full bg-primary-foreground/20 px-2 py-0.5 text-xs" : "rounded-full bg-primary/15 px-2 py-0.5 text-xs text-primary",
305
+ children: savingsLabel(allPlans, option)
306
+ }) : null]
307
+ }, option))
308
+ })
309
+ }) : null,
310
+ plans.length > 0 ? /* @__PURE__ */ jsx("div", {
311
+ className: "mx-auto grid max-w-[1200px] grid-cols-1 items-stretch gap-5 sm:grid-cols-2 lg:grid-cols-4",
312
+ children: plans.map((plan) => /* @__PURE__ */ jsx(PricingCard, {
313
+ plan,
314
+ mode: "public",
315
+ featured: plan.sku === featuredSku,
316
+ discount: periodChoice ? discountFor(plan, allPlans) : null
317
+ }, plan.sku))
318
+ }) : !isLoading && !isError ? /* @__PURE__ */ jsx("div", {
319
+ className: "mx-auto max-w-lg rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground",
320
+ "data-testid": "pricing-empty",
321
+ children: isPreview ? /* @__PURE__ */ jsxs(Fragment, { children: [
322
+ "No plans are configured yet. Add plans in",
323
+ " ",
324
+ /* @__PURE__ */ jsx("code", {
325
+ className: "rounded bg-muted px-1.5 py-0.5",
326
+ children: "apitogo.config.json"
327
+ }),
328
+ " ",
329
+ "and set",
330
+ " ",
331
+ /* @__PURE__ */ jsx("code", {
332
+ className: "rounded bg-muted px-1.5 py-0.5",
333
+ children: "modules.userPanel.plans.enabled"
334
+ }),
335
+ " ",
336
+ "to true."
337
+ ] }) : "Pricing is not available yet. Please check back soon."
338
+ }) : null
339
+ ]
340
+ }),
341
+ isLoading || compareRows.length === 0 ? null : /* @__PURE__ */ jsx("section", {
342
+ className: "border-t border-border bg-muted/40 px-6 py-16",
343
+ "data-testid": "pricing-compare",
344
+ children: /* @__PURE__ */ jsxs("div", {
345
+ className: "mx-auto max-w-[1200px]",
346
+ children: [/* @__PURE__ */ jsx("h2", {
347
+ className: "mb-6 text-[clamp(1.5rem,2.5vw,2.25rem)] font-extrabold tracking-[-0.02em]",
348
+ children: "Compare plans"
349
+ }), /* @__PURE__ */ jsx("div", {
350
+ className: "overflow-x-auto rounded-xl border border-border bg-card",
351
+ children: /* @__PURE__ */ jsxs("div", {
352
+ className: "min-w-[720px]",
353
+ children: [/* @__PURE__ */ jsxs("div", {
354
+ className: "grid gap-0 border-b border-border px-5 py-3.5 text-[0.78125rem] font-bold uppercase tracking-[0.04em] text-muted-foreground",
355
+ style: { gridTemplateColumns: `minmax(10rem,1.4fr) repeat(${compareHeaders.length}, minmax(6rem,1fr))` },
356
+ children: [/* @__PURE__ */ jsx("div", { children: "Feature" }), compareHeaders.map((header) => /* @__PURE__ */ jsx("div", { children: header }, header))]
357
+ }), compareRows.map((row) => /* @__PURE__ */ jsxs("div", {
358
+ className: "grid gap-0 border-b border-border px-5 py-3.5 text-[0.84375rem] text-muted-foreground last:border-b-0",
359
+ style: { gridTemplateColumns: `minmax(10rem,1.4fr) repeat(${compareHeaders.length}, minmax(6rem,1fr))` },
360
+ children: [/* @__PURE__ */ jsx("div", {
361
+ className: "font-medium text-foreground",
362
+ children: row.label
363
+ }), compareHeaders.map((header, index) => /* @__PURE__ */ jsx("div", { children: row.values[index] ?? "—" }, `${row.label}-${header}`))]
364
+ }, row.label))]
365
+ })
366
+ })]
367
+ })
368
+ }),
369
+ /* @__PURE__ */ jsx("section", {
370
+ className: "px-6 py-16",
371
+ "data-testid": "pricing-faq",
372
+ children: /* @__PURE__ */ jsxs("div", {
373
+ className: "mx-auto max-w-4xl",
374
+ children: [/* @__PURE__ */ jsx("h2", {
375
+ className: "mb-8 text-center text-[clamp(1.5rem,2.5vw,2.25rem)] font-extrabold tracking-[-0.02em]",
376
+ children: "Frequently asked questions"
377
+ }), /* @__PURE__ */ jsx("div", { children: faqs.map((faq) => /* @__PURE__ */ jsxs("div", {
378
+ className: "border-b border-border py-5 last:border-b-0",
379
+ children: [/* @__PURE__ */ jsx("div", {
380
+ className: "text-[0.9375rem] font-bold",
381
+ children: faq.question
382
+ }), /* @__PURE__ */ jsx("p", {
383
+ className: "mt-2 text-sm leading-relaxed text-muted-foreground",
384
+ children: faq.answer
385
+ })]
386
+ }, faq.question)) })]
387
+ })
388
+ })
389
+ ]
390
+ });
391
+ };
392
+
393
+ //#endregion
394
+ export { PricingPage as default };
@@ -1,12 +1,12 @@
1
1
  import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
2
2
  import { a as CREDENTIALS_PATH, n as ALREADY_SUBSCRIBED_PARAM, t as ACCOUNT_PLANS_PATH } from "./paths-DBr3Dj_q.mjs";
3
- import { a as formatPlanPrice, p as parseMonthlyQuotaCalls, s as isActiveSubscription, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
4
- import { t as useMySubscriptions } from "./useMySubscriptions-BHp7cjkN.mjs";
5
- import { t as usePlans } from "./usePlans-BKT8rIgl.mjs";
3
+ import { c as isActiveSubscription, m as parseMonthlyQuotaCalls, o as formatPlanPrice, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-TaJ7GhG5.mjs";
4
+ import { t as useMySubscriptions } from "./useMySubscriptions-DnjIFrcQ.mjs";
5
+ import { t as usePlans } from "./usePlans-BfvrukjB.mjs";
6
6
  import { n as readPendingCheckout, t as clearPendingCheckout } from "./pending-checkout-DpVaNnTu.mjs";
7
- import { n as useApiKeys } from "./useApiKeys-Co1xhgcO.mjs";
8
- import { t as useUsage } from "./useUsage-BKuMJS65.mjs";
9
- import { i as hasPaymentProvider, r as checkoutConfirmingText } from "./billing-state-D0Nkuz7i.mjs";
7
+ import { n as useApiKeys } from "./useApiKeys-BE2aLp-q.mjs";
8
+ import { t as useUsage } from "./useUsage-DQty3tDN.mjs";
9
+ import { i as hasPaymentProvider, r as checkoutConfirmingText } from "./billing-state-CIqyRwkD.mjs";
10
10
  import { i as ChoosePlanNotice, n as billingPageState, r as keyPlanNote } from "./page-state-Cmo0FPLl.mjs";
11
11
  import { Head, Spinner } from "@lukoweb/apitogo/components";
12
12
  import { Link as Link$1, useSearchParams } from "@lukoweb/apitogo/router";
@@ -1,8 +1,8 @@
1
1
  import "./DevPortalBillingContext-BUQPLoyk.mjs";
2
- import { m as parseQuotaPeriodDays, p as parseMonthlyQuotaCalls, s as isActiveSubscription } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
3
- import { t as useMySubscriptions } from "./useMySubscriptions-BHp7cjkN.mjs";
4
- import { t as usePlans } from "./usePlans-BKT8rIgl.mjs";
5
- import { n as useUsageRecent, t as useUsage } from "./useUsage-BKuMJS65.mjs";
2
+ import { c as isActiveSubscription, h as parseQuotaPeriodDays, m as parseMonthlyQuotaCalls } from "./useDevPortalApiBaseUrl-TaJ7GhG5.mjs";
3
+ import { t as useMySubscriptions } from "./useMySubscriptions-DnjIFrcQ.mjs";
4
+ import { t as usePlans } from "./usePlans-BfvrukjB.mjs";
5
+ import { n as useUsageRecent, t as useUsage } from "./useUsage-DQty3tDN.mjs";
6
6
  import { Head } from "@lukoweb/apitogo/components";
7
7
  import { Link as Link$1 } from "@lukoweb/apitogo/router";
8
8
  import { useState } from "react";
@@ -1,4 +1,4 @@
1
- import { i as useRevokeApiKey, r as useCreateApiKey, t as API_KEY_CAP_REACHED } from "./useApiKeys-Co1xhgcO.mjs";
1
+ import { i as useRevokeApiKey, r as useCreateApiKey, t as API_KEY_CAP_REACHED } from "./useApiKeys-BE2aLp-q.mjs";
2
2
  import { Spinner } from "@lukoweb/apitogo/components";
3
3
  import { KeyRoundIcon, TrashIcon } from "@lukoweb/apitogo/icons";
4
4
  import { useEffect, useState } from "react";
@@ -1,4 +1,4 @@
1
- import { _ as rateLimitCell, g as quotaCell } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
1
+ import { _ as quotaCell, v as rateLimitCell } from "./useDevPortalApiBaseUrl-TaJ7GhG5.mjs";
2
2
 
3
3
  //#region src/utils/billing-state.ts
4
4
  /** Whether the pricing page has no plans to show yet because the answer is still on its way. */
package/dist/index.d.mts CHANGED
@@ -21,7 +21,14 @@ type DevPortalPlan = {
21
21
  billingPeriod: string;
22
22
  syncedAtUtc?: string;
23
23
  includedActionKeys?: string[]; /** Optional marketing bullets for pricing cards (preview / local catalog). */
24
- features?: string[];
24
+ features?: string[]; /** Every price of a plan sold at several (periods, currencies); the first is the default. Absent: one price. */
25
+ prices?: DevPortalPlanPrice[];
26
+ };
27
+ /** One price of a plan: `monthly`, `quarterly` or `annual`, a lowercase currency, an amount for one period. */
28
+ type DevPortalPlanPrice = {
29
+ billingPeriod: string;
30
+ currency: string;
31
+ amount: number;
25
32
  };
26
33
  type DevPortalPlanCatalog = {
27
34
  plans: DevPortalPlan[];
@@ -79,6 +86,7 @@ type DevPortalBillingConfig = {
79
86
  limitsJson?: string | null;
80
87
  includedActionKeys?: string[];
81
88
  features?: string[];
89
+ prices?: DevPortalPlanPrice[];
82
90
  }>;
83
91
  };
84
92
  type DevPortalApiKey = {
package/dist/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
- import { t as AccountPlansPage } from "./AccountPlansPage-USlRPEhN.mjs";
1
+ import { t as AccountPlansPage } from "./AccountPlansPage-BDfagKTr.mjs";
2
2
  import { n as registerDevPortalBillingOptions, r as useDevPortalBillingConfig, t as DevPortalBillingProvider } from "./DevPortalBillingContext-BUQPLoyk.mjs";
3
3
  import { a as CREDENTIALS_PATH, c as SUBSCRIPTIONS_PATH, i as CONTACT_SALES_PATH, l as USAGE_PATH, o as LOGIN_NAV_PATH, r as CHECKOUT_PATH, s as PRICING_PATH, t as ACCOUNT_PLANS_PATH } from "./paths-DBr3Dj_q.mjs";
4
- import { d as listPlanFeatureLines, f as parseManifestPlans, h as pickFeaturedPlanSku, i as formatPlanDisplayPrice, o as formatPlanPriceUnit, s as isActiveSubscription, v as resolveDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
5
- import "./PricingCard-KDRcH2ny.mjs";
4
+ import { a as formatPlanDisplayPrice, c as isActiveSubscription, f as listPlanFeatureLines, g as pickFeaturedPlanSku, p as parseManifestPlans, s as formatPlanPriceUnit, y as resolveDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-TaJ7GhG5.mjs";
5
+ import "./PricingCard-CrN4GIZ7.mjs";
6
6
  import { t as DEMO_GATEWAY_KEY_HEADER } from "./demo-session-yK9qEqV-.mjs";
7
- import { t as useMySubscriptions } from "./useMySubscriptions-BHp7cjkN.mjs";
8
- import { n as startPlansPrefetch, t as usePlans } from "./usePlans-BKT8rIgl.mjs";
7
+ import { t as useMySubscriptions } from "./useMySubscriptions-DnjIFrcQ.mjs";
8
+ import { n as startPlansPrefetch, t as usePlans } from "./usePlans-BfvrukjB.mjs";
9
9
  import "./pending-checkout-DpVaNnTu.mjs";
10
- import { a as playgroundKeyIdentities, i as useRevokeApiKey, n as useApiKeys, r as useCreateApiKey, t as API_KEY_CAP_REACHED } from "./useApiKeys-Co1xhgcO.mjs";
11
- import { n as useUsageRecent, t as useUsage } from "./useUsage-BKuMJS65.mjs";
12
- import { r as ApiKeysPanel, t as accountLayoutProps } from "./account-links-DZ9i1WTa.mjs";
10
+ import { a as playgroundKeyIdentities, i as useRevokeApiKey, n as useApiKeys, r as useCreateApiKey, t as API_KEY_CAP_REACHED } from "./useApiKeys-BE2aLp-q.mjs";
11
+ import { n as useUsageRecent, t as useUsage } from "./useUsage-DQty3tDN.mjs";
12
+ import { r as ApiKeysPanel, t as accountLayoutProps } from "./account-links-DGL7nKSZ.mjs";
13
13
  import { t as isPreviewPricingEnabled } from "./pricing-config-Bc6eWFUO.mjs";
14
14
  import { Head, Link } from "@lukoweb/apitogo/components";
15
15
  import { ArrowRightIcon, KeyRoundIcon, StarsIcon } from "@lukoweb/apitogo/icons";
@@ -367,13 +367,13 @@ async function getSignedInIdentities(apiBaseUrl, fetchImpl = fetch) {
367
367
 
368
368
  //#endregion
369
369
  //#region src/DevPortalBillingPlugin.tsx
370
- const AccountPlansPage$1 = lazy(() => import("./AccountPlansPage-USlRPEhN.mjs").then((n) => n.n));
371
- const CheckoutPage = lazy(() => import("./CheckoutPage-CED9AYw0.mjs"));
372
- const ContactSalesPage = lazy(() => import("./ContactSalesPage-B1qWs7UW.mjs"));
373
- const CredentialsPage = lazy(() => import("./CredentialsPage-DpV3JBPM.mjs"));
374
- const PricingPage = lazy(() => import("./PricingPage-CiejO1vQ.mjs"));
375
- const SubscriptionsPage = lazy(() => import("./SubscriptionsPage-LvYhFxv1.mjs"));
376
- const UsagePage = lazy(() => import("./UsagePage-CeUcC33p.mjs"));
370
+ const AccountPlansPage$1 = lazy(() => import("./AccountPlansPage-BDfagKTr.mjs").then((n) => n.n));
371
+ const CheckoutPage = lazy(() => import("./CheckoutPage-4tCFiL7W.mjs"));
372
+ const ContactSalesPage = lazy(() => import("./ContactSalesPage-BqxdJ4wl.mjs"));
373
+ const CredentialsPage = lazy(() => import("./CredentialsPage-DMVMiDdL.mjs"));
374
+ const PricingPage = lazy(() => import("./PricingPage-DPIF_DOP.mjs"));
375
+ const SubscriptionsPage = lazy(() => import("./SubscriptionsPage-C8hRY5Sr.mjs"));
376
+ const UsagePage = lazy(() => import("./UsagePage-Cwqnusaz.mjs"));
377
377
  function resolvePricingEnabled(config) {
378
378
  if (config.__meta?.pricingEnabled !== void 0) return config.__meta.pricingEnabled;
379
379
  return isPreviewPricingEnabled();
@@ -1,5 +1,5 @@
1
1
  import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
2
- import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
2
+ import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-TaJ7GhG5.mjs";
3
3
  import { n as readProblemDetail } from "./problem-details-n20-dy3w.mjs";
4
4
  import { n as createDemoApiKeys, t as DEMO_GATEWAY_KEY_HEADER } from "./demo-session-yK9qEqV-.mjs";
5
5
  import { useMutation, useQuery, useQueryClient } from "@lukoweb/apitogo/react-query";
@@ -29,7 +29,8 @@ function mapPreviewPlans(plans) {
29
29
  billingPeriod: plan.billingPeriod,
30
30
  limitsJson: resolveLimitsJson(plan),
31
31
  includedActionKeys: plan.includedActionKeys,
32
- features: plan.features
32
+ features: plan.features,
33
+ ...plan.prices?.length ? { prices: plan.prices } : {}
33
34
  }));
34
35
  }
35
36
  function readModulePlanItems() {
@@ -48,7 +49,8 @@ function parseManifestPlans(configPlans) {
48
49
  limits: plan.limits,
49
50
  limitsJson: plan.limitsJson ?? null,
50
51
  includedActionKeys: plan.includedActionKeys ?? [],
51
- features: plan.features
52
+ features: plan.features,
53
+ prices: plan.prices
52
54
  }))) };
53
55
  if (manifestCatalog?.plans?.length) return { plans: mapPreviewPlans(manifestCatalog.plans) };
54
56
  const metaPlans = zudokuConfig?.__meta?.previewPlans;
@@ -65,7 +67,8 @@ function parseManifestPlans(configPlans) {
65
67
  limits: plan.limits,
66
68
  limitsJson: plan.limitsJson ?? null,
67
69
  includedActionKeys: plan.includedActionKeys ?? [],
68
- features: plan.features
70
+ features: plan.features,
71
+ prices: plan.prices
69
72
  }))) };
70
73
  return { plans: [] };
71
74
  }
@@ -81,6 +84,14 @@ function isPlanCustomPriced(plan) {
81
84
  function formatCustomPriceLabel(plan) {
82
85
  return plan.priceLabel?.trim() || "Custom";
83
86
  }
87
+ /** An amount in a currency, with cents only when it has them (`$588`, `$470.40`). */
88
+ function formatMoney(amount, currency) {
89
+ return new Intl.NumberFormat(void 0, {
90
+ style: "currency",
91
+ currency: currency.toUpperCase(),
92
+ minimumFractionDigits: Math.round(amount * 100) % 100 === 0 ? 0 : 2
93
+ }).format(amount);
94
+ }
84
95
  function formatPlanPrice(plan) {
85
96
  if (isPlanCustomPriced(plan)) return formatCustomPriceLabel(plan);
86
97
  if (plan.priceAmount <= 0) return "Free";
@@ -91,6 +102,7 @@ function formatPlanPrice(plan) {
91
102
  }).format(plan.priceAmount);
92
103
  const period = plan.billingPeriod.toLowerCase();
93
104
  if (period === "monthly" || period === "month") return `${amount}/mo`;
105
+ if (period === "quarterly" || period === "quarter") return `${amount}/qtr`;
94
106
  if (period === "annual" || period === "year") return `${amount}/yr`;
95
107
  return amount;
96
108
  }
@@ -100,6 +112,7 @@ function isPlanFree(plan) {
100
112
  function formatBillingPeriod(period) {
101
113
  const normalized = period.toLowerCase();
102
114
  if (normalized === "month" || normalized === "monthly") return "per month";
115
+ if (normalized === "quarter" || normalized === "quarterly") return "per quarter";
103
116
  if (normalized === "year" || normalized === "annual") return "per year";
104
117
  if (normalized === "custom") return "talk to us";
105
118
  return period;
@@ -109,7 +122,7 @@ function formatPlanDisplayPrice(plan) {
109
122
  if (isPlanCustomPriced(plan)) return formatCustomPriceLabel(plan);
110
123
  if (isPlanFree(plan)) return "$0";
111
124
  const priceLabel = formatPlanPrice(plan);
112
- return priceLabel.replace(/\/mo$/, "").replace(/\/yr$/, "") || priceLabel;
125
+ return priceLabel.replace(/\/mo$/, "").replace(/\/qtr$/, "").replace(/\/yr$/, "") || priceLabel;
113
126
  }
114
127
  /** Caption shown under the plan price (e.g. `per month`, `talk to us`). */
115
128
  function formatPlanPriceUnit(plan) {
@@ -268,4 +281,4 @@ function useDevPortalPreviewMode() {
268
281
  }
269
282
 
270
283
  //#endregion
271
- export { rateLimitCell as _, formatPlanPrice as a, isPlaceholderDevPortalApiUrl as c, listPlanFeatureLines as d, parseManifestPlans as f, quotaCell as g, pickFeaturedPlanSku as h, formatPlanDisplayPrice as i, isPlanCustomPriced as l, parseQuotaPeriodDays as m, useDevPortalPreviewMode as n, formatPlanPriceUnit as o, parseMonthlyQuotaCalls as p, useIsDemoSession as r, isActiveSubscription as s, useDevPortalApiBaseUrl as t, isPlanFree as u, resolveDevPortalApiBaseUrl as v, withPlanFeatures as y };
284
+ export { quotaCell as _, formatPlanDisplayPrice as a, withPlanFeatures as b, isActiveSubscription as c, isPlanFree as d, listPlanFeatureLines as f, pickFeaturedPlanSku as g, parseQuotaPeriodDays as h, formatMoney as i, isPlaceholderDevPortalApiUrl as l, parseMonthlyQuotaCalls as m, useDevPortalPreviewMode as n, formatPlanPrice as o, parseManifestPlans as p, useIsDemoSession as r, formatPlanPriceUnit as s, useDevPortalApiBaseUrl as t, isPlanCustomPriced as u, rateLimitCell as v, resolveDevPortalApiBaseUrl as y };
@@ -1,5 +1,5 @@
1
1
  import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
2
- import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
2
+ import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-TaJ7GhG5.mjs";
3
3
  import { i as createDemoMeResponse } from "./demo-session-yK9qEqV-.mjs";
4
4
  import { useQuery } from "@lukoweb/apitogo/react-query";
5
5
  import { useAuth } from "@lukoweb/apitogo/hooks";
@@ -1,5 +1,5 @@
1
1
  import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
2
- import { c as isPlaceholderDevPortalApiUrl, f as parseManifestPlans, n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl, y as withPlanFeatures } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
2
+ import { b as withPlanFeatures, l as isPlaceholderDevPortalApiUrl, n as useDevPortalPreviewMode, p as parseManifestPlans, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-TaJ7GhG5.mjs";
3
3
  import { useQuery } from "@lukoweb/apitogo/react-query";
4
4
 
5
5
  //#region src/utils/plans-prefetch.ts
@@ -1,4 +1,4 @@
1
- import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
1
+ import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-TaJ7GhG5.mjs";
2
2
  import { useQuery } from "@lukoweb/apitogo/react-query";
3
3
  import { useAuth } from "@lukoweb/apitogo/hooks";
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lukoweb/apitogo-plugin-dev-portal-billing",
3
- "version": "0.2.77",
3
+ "version": "0.2.79",
4
4
  "homepage": "https://docs.apitogo.com",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -42,8 +42,8 @@
42
42
  "react": "19.2.4",
43
43
  "react-dom": "19.2.4",
44
44
  "tsdown": "0.20.3",
45
- "@lukoweb/apitogo": "0.2.77",
46
- "@lukoweb/apitogo-module-user-panel": "0.2.77"
45
+ "@lukoweb/apitogo": "0.2.79",
46
+ "@lukoweb/apitogo-module-user-panel": "0.2.79"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "react": ">=19.2.0",
@@ -1,234 +0,0 @@
1
- import { r as useDevPortalBillingConfig } from "./DevPortalBillingContext-BUQPLoyk.mjs";
2
- import { f as parseManifestPlans, h as pickFeaturedPlanSku, n as useDevPortalPreviewMode, y as withPlanFeatures } from "./useDevPortalApiBaseUrl-B7gBA5El.mjs";
3
- import { t as PricingCard } from "./PricingCard-KDRcH2ny.mjs";
4
- import { t as usePlans } from "./usePlans-BKT8rIgl.mjs";
5
- import { t as isPreviewPricingEnabled } from "./pricing-config-Bc6eWFUO.mjs";
6
- import { a as isPricingLoading, n as buildCompareRows } from "./billing-state-D0Nkuz7i.mjs";
7
- import { Head, Heading } from "@lukoweb/apitogo/components";
8
- import { Navigate } from "@lukoweb/apitogo/router";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
- import { useAuth } from "@lukoweb/apitogo/hooks";
11
-
12
- //#region src/pages/PricingPage.tsx
13
- const DEFAULT_COMPARE_ROWS = [
14
- {
15
- label: "Monthly requests",
16
- values: [
17
- "1,000",
18
- "50,000",
19
- "500,000",
20
- "Unlimited"
21
- ]
22
- },
23
- {
24
- label: "Rate limit",
25
- values: [
26
- "10/sec",
27
- "50/sec",
28
- "200/sec",
29
- "Custom"
30
- ]
31
- },
32
- {
33
- label: "Team seats",
34
- values: [
35
- "1",
36
- "1",
37
- "5",
38
- "Unlimited"
39
- ]
40
- },
41
- {
42
- label: "Webhooks",
43
- values: [
44
- "—",
45
- "Included",
46
- "Included",
47
- "Included"
48
- ]
49
- },
50
- {
51
- label: "SSO",
52
- values: [
53
- "—",
54
- "—",
55
- "—",
56
- "Included"
57
- ]
58
- },
59
- {
60
- label: "Support",
61
- values: [
62
- "—",
63
- "Email",
64
- "Priority",
65
- "Dedicated SLA"
66
- ]
67
- }
68
- ];
69
- /** Only what the platform itself does, so the defaults never promise anything for the tenant (API-124). */
70
- const DEFAULT_FAQS = [{
71
- question: "What happens if I go over my plan's limits?",
72
- answer: "Calls over the rate limit or the quota are refused with a 429 response, and its Retry-After header says when to try again."
73
- }, {
74
- question: "Can I have more than one plan?",
75
- answer: "Yes. Each plan has its own API keys and limits: create a key for a plan on the API keys page and use it in your app."
76
- }];
77
- const PricingPage = () => {
78
- const { pricing, previewPlans, featuredPlanSku, planFeatures } = useDevPortalBillingConfig();
79
- const isPreview = useDevPortalPreviewMode();
80
- const pricingEnabled = isPreviewPricingEnabled() || isPreview;
81
- const livePlans = usePlans();
82
- const catalog = isPreview ? withPlanFeatures(parseManifestPlans(previewPlans), planFeatures) : livePlans.data;
83
- const { isPending: authPending } = useAuth();
84
- const isLoading = isPricingLoading({
85
- isPreview,
86
- plansLoading: livePlans.isLoading,
87
- hasPlans: Boolean(catalog?.plans?.length),
88
- plansFailed: livePlans.isError,
89
- authPending
90
- });
91
- const isError = isPreview ? false : livePlans.isError;
92
- if (!pricingEnabled) return /* @__PURE__ */ jsx(Navigate, {
93
- to: "/",
94
- replace: true
95
- });
96
- const title = pricing?.title ?? "Plans and pricing";
97
- const subtitle = pricing?.subtitle ?? "Choose the plan that fits how you use the API. Each plan lists its limits and what it includes.";
98
- const plans = catalog?.plans ?? [];
99
- const featuredSku = pickFeaturedPlanSku(plans, featuredPlanSku);
100
- const compareRows = buildCompareRows({
101
- plans,
102
- configuredRows: pricing?.compareRows,
103
- isPreview,
104
- sampleRows: DEFAULT_COMPARE_ROWS
105
- });
106
- const faqs = pricing?.faqs && pricing.faqs.length > 0 ? pricing.faqs : DEFAULT_FAQS;
107
- const compareHeaders = plans.length > 0 ? plans.map((p) => p.displayName) : [
108
- "Free",
109
- "Developer",
110
- "Team",
111
- "Enterprise"
112
- ];
113
- return /* @__PURE__ */ jsxs("div", {
114
- className: "w-full",
115
- children: [
116
- /* @__PURE__ */ jsxs(Head, { children: [/* @__PURE__ */ jsx("title", { children: title }), /* @__PURE__ */ jsx("meta", {
117
- name: "description",
118
- content: subtitle
119
- })] }),
120
- /* @__PURE__ */ jsxs("section", {
121
- className: "px-6 pb-4 pt-[clamp(3rem,6vw,4.5rem)] text-center",
122
- children: [
123
- /* @__PURE__ */ jsx("p", {
124
- className: "text-xs font-bold uppercase tracking-[0.08em] text-primary",
125
- children: "Pricing"
126
- }),
127
- /* @__PURE__ */ jsx(Heading, {
128
- level: 1,
129
- className: "mt-3 text-[clamp(2rem,3.5vw,3rem)] font-extrabold tracking-[-0.02em]",
130
- "data-testid": "title",
131
- children: title
132
- }),
133
- /* @__PURE__ */ jsx("p", {
134
- className: "mx-auto mt-3.5 max-w-[34rem] text-lg leading-relaxed text-muted-foreground",
135
- "data-testid": "subtitle",
136
- children: subtitle
137
- })
138
- ]
139
- }),
140
- /* @__PURE__ */ jsxs("section", {
141
- className: "px-6 pb-16 pt-8",
142
- children: [
143
- isLoading ? /* @__PURE__ */ jsx("p", {
144
- className: "text-center text-muted-foreground",
145
- children: "Loading plans…"
146
- }) : null,
147
- isError ? /* @__PURE__ */ jsx("p", {
148
- className: "text-center text-destructive",
149
- children: "Unable to load plans."
150
- }) : null,
151
- plans.length > 0 ? /* @__PURE__ */ jsx("div", {
152
- className: "mx-auto grid max-w-[1200px] grid-cols-1 items-stretch gap-5 sm:grid-cols-2 lg:grid-cols-4",
153
- children: plans.map((plan) => /* @__PURE__ */ jsx(PricingCard, {
154
- plan,
155
- mode: "public",
156
- featured: plan.sku === featuredSku
157
- }, plan.sku))
158
- }) : !isLoading && !isError ? /* @__PURE__ */ jsx("div", {
159
- className: "mx-auto max-w-lg rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground",
160
- "data-testid": "pricing-empty",
161
- children: isPreview ? /* @__PURE__ */ jsxs(Fragment, { children: [
162
- "No plans are configured yet. Add plans in",
163
- " ",
164
- /* @__PURE__ */ jsx("code", {
165
- className: "rounded bg-muted px-1.5 py-0.5",
166
- children: "apitogo.config.json"
167
- }),
168
- " ",
169
- "and set",
170
- " ",
171
- /* @__PURE__ */ jsx("code", {
172
- className: "rounded bg-muted px-1.5 py-0.5",
173
- children: "modules.userPanel.plans.enabled"
174
- }),
175
- " ",
176
- "to true."
177
- ] }) : "Pricing is not available yet. Please check back soon."
178
- }) : null
179
- ]
180
- }),
181
- isLoading || compareRows.length === 0 ? null : /* @__PURE__ */ jsx("section", {
182
- className: "border-t border-border bg-muted/40 px-6 py-16",
183
- "data-testid": "pricing-compare",
184
- children: /* @__PURE__ */ jsxs("div", {
185
- className: "mx-auto max-w-[1200px]",
186
- children: [/* @__PURE__ */ jsx("h2", {
187
- className: "mb-6 text-[clamp(1.5rem,2.5vw,2.25rem)] font-extrabold tracking-[-0.02em]",
188
- children: "Compare plans"
189
- }), /* @__PURE__ */ jsx("div", {
190
- className: "overflow-x-auto rounded-xl border border-border bg-card",
191
- children: /* @__PURE__ */ jsxs("div", {
192
- className: "min-w-[720px]",
193
- children: [/* @__PURE__ */ jsxs("div", {
194
- className: "grid gap-0 border-b border-border px-5 py-3.5 text-[0.78125rem] font-bold uppercase tracking-[0.04em] text-muted-foreground",
195
- style: { gridTemplateColumns: `minmax(10rem,1.4fr) repeat(${compareHeaders.length}, minmax(6rem,1fr))` },
196
- children: [/* @__PURE__ */ jsx("div", { children: "Feature" }), compareHeaders.map((header) => /* @__PURE__ */ jsx("div", { children: header }, header))]
197
- }), compareRows.map((row) => /* @__PURE__ */ jsxs("div", {
198
- className: "grid gap-0 border-b border-border px-5 py-3.5 text-[0.84375rem] text-muted-foreground last:border-b-0",
199
- style: { gridTemplateColumns: `minmax(10rem,1.4fr) repeat(${compareHeaders.length}, minmax(6rem,1fr))` },
200
- children: [/* @__PURE__ */ jsx("div", {
201
- className: "font-medium text-foreground",
202
- children: row.label
203
- }), compareHeaders.map((header, index) => /* @__PURE__ */ jsx("div", { children: row.values[index] ?? "—" }, `${row.label}-${header}`))]
204
- }, row.label))]
205
- })
206
- })]
207
- })
208
- }),
209
- /* @__PURE__ */ jsx("section", {
210
- className: "px-6 py-16",
211
- "data-testid": "pricing-faq",
212
- children: /* @__PURE__ */ jsxs("div", {
213
- className: "mx-auto max-w-4xl",
214
- children: [/* @__PURE__ */ jsx("h2", {
215
- className: "mb-8 text-center text-[clamp(1.5rem,2.5vw,2.25rem)] font-extrabold tracking-[-0.02em]",
216
- children: "Frequently asked questions"
217
- }), /* @__PURE__ */ jsx("div", { children: faqs.map((faq) => /* @__PURE__ */ jsxs("div", {
218
- className: "border-b border-border py-5 last:border-b-0",
219
- children: [/* @__PURE__ */ jsx("div", {
220
- className: "text-[0.9375rem] font-bold",
221
- children: faq.question
222
- }), /* @__PURE__ */ jsx("p", {
223
- className: "mt-2 text-sm leading-relaxed text-muted-foreground",
224
- children: faq.answer
225
- })]
226
- }, faq.question)) })]
227
- })
228
- })
229
- ]
230
- });
231
- };
232
-
233
- //#endregion
234
- export { PricingPage as default };