@schematichq/schematic-components 0.4.2 → 0.4.3

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.
@@ -11207,6 +11207,21 @@ function PlanEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11207
11207
  };
11208
11208
  }
11209
11209
 
11210
+ // src/api/models/CustomPlanConfig.ts
11211
+ function CustomPlanConfigFromJSON(json) {
11212
+ return CustomPlanConfigFromJSONTyped(json, false);
11213
+ }
11214
+ function CustomPlanConfigFromJSONTyped(json, ignoreDiscriminator) {
11215
+ if (json == null) {
11216
+ return json;
11217
+ }
11218
+ return {
11219
+ ctaText: json["cta_text"],
11220
+ ctaWebSite: json["cta_web_site"],
11221
+ priceText: json["price_text"]
11222
+ };
11223
+ }
11224
+
11210
11225
  // src/api/models/CompanyPlanDetailResponseData.ts
11211
11226
  function CompanyPlanDetailResponseDataFromJSON(json) {
11212
11227
  return CompanyPlanDetailResponseDataFromJSONTyped(json, false);
@@ -11222,6 +11237,8 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11222
11237
  companyCount: json["company_count"],
11223
11238
  createdAt: new Date(json["created_at"]),
11224
11239
  current: json["current"],
11240
+ custom: json["custom"],
11241
+ customPlanConfig: json["custom_plan_config"] == null ? void 0 : CustomPlanConfigFromJSON(json["custom_plan_config"]),
11225
11242
  description: json["description"],
11226
11243
  entitlements: json["entitlements"].map(
11227
11244
  PlanEntitlementResponseDataFromJSON
@@ -11231,6 +11248,7 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11231
11248
  ),
11232
11249
  icon: json["icon"],
11233
11250
  id: json["id"],
11251
+ isCustom: json["is_custom"],
11234
11252
  isDefault: json["is_default"],
11235
11253
  isFree: json["is_free"],
11236
11254
  isTrialable: json["is_trialable"],
@@ -12479,8 +12497,12 @@ function isEditorState(obj) {
12479
12497
  });
12480
12498
  }
12481
12499
  function getEditorState(json) {
12482
- const obj = JSON.parse(json);
12483
- return isEditorState(obj) ? obj : void 0;
12500
+ if (json) {
12501
+ const obj = JSON.parse(json);
12502
+ if (isEditorState(obj)) {
12503
+ return obj;
12504
+ }
12505
+ }
12484
12506
  }
12485
12507
  function parseEditorState(data) {
12486
12508
  const initialMap = {};
@@ -12660,7 +12682,7 @@ var EmbedProvider = ({
12660
12682
  useEffect2(() => {
12661
12683
  if (accessToken) {
12662
12684
  const { headers = {} } = apiConfig ?? {};
12663
- headers["X-Schematic-Components-Version"] = "0.4.2";
12685
+ headers["X-Schematic-Components-Version"] = "0.4.3";
12664
12686
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
12665
12687
  const config = new Configuration({
12666
12688
  ...apiConfig,
@@ -12841,7 +12863,7 @@ function camelToHyphen(str) {
12841
12863
  function formatNumber(num) {
12842
12864
  return new Intl.NumberFormat("en-US").format(num);
12843
12865
  }
12844
- function formatCurrency(amount) {
12866
+ function formatCurrency(amount, currency = "USD") {
12845
12867
  try {
12846
12868
  const dollars = amount / 100;
12847
12869
  const formatValue = (value, symbol) => {
@@ -12849,6 +12871,9 @@ function formatCurrency(amount) {
12849
12871
  if (formatted.endsWith(".0")) {
12850
12872
  formatted = formatted.slice(0, -2);
12851
12873
  }
12874
+ if (currency.toUpperCase() !== "USD") {
12875
+ return `${currency.toUpperCase()}${formatted}${symbol}`;
12876
+ }
12852
12877
  return `$${formatted}${symbol}`;
12853
12878
  };
12854
12879
  if (dollars >= 1e6) {
@@ -12858,14 +12883,14 @@ function formatCurrency(amount) {
12858
12883
  } else {
12859
12884
  return new Intl.NumberFormat("en-US", {
12860
12885
  style: "currency",
12861
- currency: "USD"
12886
+ currency: currency.toUpperCase()
12862
12887
  }).format(dollars);
12863
12888
  }
12864
12889
  } catch (error) {
12865
12890
  console.error("Error formatting currency", error);
12866
12891
  return new Intl.NumberFormat("en-US", {
12867
12892
  style: "currency",
12868
- currency: "USD"
12893
+ currency: currency.toUpperCase()
12869
12894
  }).format(amount / 100);
12870
12895
  }
12871
12896
  }
@@ -14399,6 +14424,7 @@ var Sidebar = ({
14399
14424
  }
14400
14425
  let total = 0;
14401
14426
  const planPrice = (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price;
14427
+ const currency = (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.currency;
14402
14428
  if (planPrice) {
14403
14429
  total += planPrice;
14404
14430
  }
@@ -14412,7 +14438,7 @@ var Sidebar = ({
14412
14438
  0
14413
14439
  );
14414
14440
  total += payInAdvanceCost;
14415
- return formatCurrency(total);
14441
+ return formatCurrency(total, currency);
14416
14442
  }, [selectedPlan, addOns, payInAdvanceEntitlements, planPeriod]);
14417
14443
  const { amountOff, dueNow, newCharges, percentOff, periodStart, proration } = useMemo4(() => {
14418
14444
  return {
@@ -14647,7 +14673,10 @@ var Sidebar = ({
14647
14673
  $weight: theme.typography.text.fontWeight,
14648
14674
  $color: theme.typography.text.color,
14649
14675
  children: [
14650
- formatCurrency(data.company.plan.planPrice),
14676
+ formatCurrency(
14677
+ data.company.plan.planPrice,
14678
+ data.company.billingSubscription?.currency
14679
+ ),
14651
14680
  /* @__PURE__ */ jsxs8("sub", { children: [
14652
14681
  "/",
14653
14682
  shortenPeriod(
@@ -14707,7 +14736,8 @@ var Sidebar = ({
14707
14736
  $color: theme.typography.text.color,
14708
14737
  children: [
14709
14738
  formatCurrency(
14710
- (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
14739
+ (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0,
14740
+ (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.currency
14711
14741
  ),
14712
14742
  /* @__PURE__ */ jsxs8("sub", { children: [
14713
14743
  "/",
@@ -14770,14 +14800,20 @@ var Sidebar = ({
14770
14800
  $color: theme.typography.text.color,
14771
14801
  children: [
14772
14802
  entitlement.priceBehavior === "pay_in_advance" && typeof price === "number" && /* @__PURE__ */ jsxs8(Fragment4, { children: [
14773
- formatCurrency(price * quantity),
14803
+ formatCurrency(
14804
+ price * quantity,
14805
+ (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
14806
+ ),
14774
14807
  /* @__PURE__ */ jsxs8("sub", { children: [
14775
14808
  "/",
14776
14809
  shortenPeriod(planPeriod)
14777
14810
  ] })
14778
14811
  ] }),
14779
14812
  entitlement.priceBehavior === "pay_as_you_go" && typeof price === "number" && /* @__PURE__ */ jsxs8(Fragment4, { children: [
14780
- formatCurrency(price),
14813
+ formatCurrency(
14814
+ price,
14815
+ (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
14816
+ ),
14781
14817
  /* @__PURE__ */ jsxs8("sub", { children: [
14782
14818
  "/",
14783
14819
  (0, import_pluralize.default)(
@@ -14837,7 +14873,8 @@ var Sidebar = ({
14837
14873
  $color: theme.typography.text.color,
14838
14874
  children: [
14839
14875
  formatCurrency(
14840
- ((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * previous.quantity
14876
+ ((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * previous.quantity,
14877
+ (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
14841
14878
  ),
14842
14879
  /* @__PURE__ */ jsxs8("sub", { children: [
14843
14880
  "/",
@@ -14879,7 +14916,8 @@ var Sidebar = ({
14879
14916
  $color: theme.typography.text.color,
14880
14917
  children: [
14881
14918
  formatCurrency(
14882
- ((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * next2.quantity
14919
+ ((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * next2.quantity,
14920
+ (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
14883
14921
  ),
14884
14922
  /* @__PURE__ */ jsxs8("sub", { children: [
14885
14923
  "/",
@@ -14933,14 +14971,20 @@ var Sidebar = ({
14933
14971
  $color: theme.typography.text.color,
14934
14972
  children: [
14935
14973
  entitlement.priceBehavior === "pay_in_advance" && typeof price === "number" && /* @__PURE__ */ jsxs8(Fragment4, { children: [
14936
- formatCurrency(price * quantity),
14974
+ formatCurrency(
14975
+ price * quantity,
14976
+ (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
14977
+ ),
14937
14978
  /* @__PURE__ */ jsxs8("sub", { children: [
14938
14979
  "/",
14939
14980
  shortenPeriod(planPeriod)
14940
14981
  ] })
14941
14982
  ] }),
14942
14983
  entitlement.priceBehavior === "pay_as_you_go" && typeof price === "number" && /* @__PURE__ */ jsxs8(Fragment4, { children: [
14943
- formatCurrency(price),
14984
+ formatCurrency(
14985
+ price,
14986
+ (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
14987
+ ),
14944
14988
  /* @__PURE__ */ jsxs8("sub", { children: [
14945
14989
  "/",
14946
14990
  (0, import_pluralize.default)(
@@ -15001,7 +15045,8 @@ var Sidebar = ({
15001
15045
  children: [
15002
15046
  "-",
15003
15047
  formatCurrency(
15004
- (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
15048
+ (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0,
15049
+ (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.currency
15005
15050
  ),
15006
15051
  "/",
15007
15052
  /* @__PURE__ */ jsx12("sub", { children: shortenPeriod(planPeriod) })
@@ -15051,7 +15096,10 @@ var Sidebar = ({
15051
15096
  $weight: theme.typography.text.fontWeight,
15052
15097
  $color: theme.typography.text.color,
15053
15098
  children: [
15054
- formatCurrency(addOn.planPrice),
15099
+ formatCurrency(
15100
+ addOn.planPrice,
15101
+ (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
15102
+ ),
15055
15103
  /* @__PURE__ */ jsxs8("sub", { children: [
15056
15104
  "/",
15057
15105
  shortenPeriod(addOn.planPeriod)
@@ -15138,7 +15186,10 @@ var Sidebar = ({
15138
15186
  $size: theme.typography.text.fontSize,
15139
15187
  $weight: theme.typography.text.fontWeight,
15140
15188
  $color: theme.typography.text.color,
15141
- children: formatCurrency(proration)
15189
+ children: formatCurrency(
15190
+ proration,
15191
+ (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
15192
+ )
15142
15193
  }
15143
15194
  ) })
15144
15195
  ]
@@ -15242,7 +15293,10 @@ var Sidebar = ({
15242
15293
  $size: theme.typography.text.fontSize,
15243
15294
  $weight: theme.typography.text.fontWeight,
15244
15295
  $color: theme.typography.text.color,
15245
- children: formatCurrency(newCharges / 100 * percentOff)
15296
+ children: formatCurrency(
15297
+ newCharges / 100 * percentOff,
15298
+ (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
15299
+ )
15246
15300
  }
15247
15301
  ) })
15248
15302
  ]
@@ -15263,7 +15317,10 @@ var Sidebar = ({
15263
15317
  $weight: theme.typography.text.fontWeight,
15264
15318
  $color: theme.typography.text.color,
15265
15319
  children: t2("X off", {
15266
- amount: formatCurrency(Math.abs(amountOff))
15320
+ amount: formatCurrency(
15321
+ Math.abs(amountOff),
15322
+ (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
15323
+ )
15267
15324
  })
15268
15325
  }
15269
15326
  ) }),
@@ -15276,7 +15333,10 @@ var Sidebar = ({
15276
15333
  $color: theme.typography.text.color,
15277
15334
  children: [
15278
15335
  "-",
15279
- formatCurrency(Math.abs(amountOff))
15336
+ formatCurrency(
15337
+ Math.abs(amountOff),
15338
+ (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
15339
+ )
15280
15340
  ]
15281
15341
  }
15282
15342
  ) })
@@ -15349,7 +15409,10 @@ var Sidebar = ({
15349
15409
  $size: theme.typography.text.fontSize,
15350
15410
  $weight: theme.typography.text.fontWeight,
15351
15411
  $color: theme.typography.text.color,
15352
- children: formatCurrency(Math.max(0, dueNow))
15412
+ children: formatCurrency(
15413
+ Math.max(0, dueNow),
15414
+ (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
15415
+ )
15353
15416
  }
15354
15417
  ) })
15355
15418
  ]
@@ -15376,7 +15439,10 @@ var Sidebar = ({
15376
15439
  $size: theme.typography.text.fontSize,
15377
15440
  $weight: theme.typography.text.fontWeight,
15378
15441
  $color: theme.typography.text.color,
15379
- children: formatCurrency(Math.abs(dueNow))
15442
+ children: formatCurrency(
15443
+ Math.abs(dueNow),
15444
+ (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
15445
+ )
15380
15446
  }
15381
15447
  ) })
15382
15448
  ] }),
@@ -15537,7 +15603,8 @@ var Plan = ({
15537
15603
  $weight: theme.typography.heading2.fontWeight,
15538
15604
  $color: theme.typography.heading2.color,
15539
15605
  children: formatCurrency(
15540
- (period === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0
15606
+ (period === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0,
15607
+ (period === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.currency
15541
15608
  )
15542
15609
  }
15543
15610
  ),
@@ -15602,6 +15669,7 @@ var Plan = ({
15602
15669
  }[entitlement.metricPeriod];
15603
15670
  }
15604
15671
  const price = (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price;
15672
+ const currency = (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency;
15605
15673
  if (entitlement.priceBehavior && typeof price !== "number") {
15606
15674
  return acc;
15607
15675
  }
@@ -15633,7 +15701,7 @@ var Plan = ({
15633
15701
  $weight: theme.typography.text.fontWeight,
15634
15702
  $color: theme.typography.text.color,
15635
15703
  children: typeof price !== "undefined" ? /* @__PURE__ */ jsxs9(Fragment5, { children: [
15636
- formatCurrency(price),
15704
+ formatCurrency(price, currency),
15637
15705
  " ",
15638
15706
  t2("per"),
15639
15707
  " ",
@@ -15737,7 +15805,7 @@ var Plan = ({
15737
15805
  {
15738
15806
  disabled: isLoading || !plan.valid,
15739
15807
  onClick: () => {
15740
- selectPlan(plan);
15808
+ selectPlan({ plan });
15741
15809
  },
15742
15810
  $size: "sm",
15743
15811
  $color: "primary",
@@ -15823,7 +15891,8 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
15823
15891
  $weight: theme.typography.heading2.fontWeight,
15824
15892
  $color: theme.typography.heading2.color,
15825
15893
  children: formatCurrency(
15826
- (period === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.price ?? 0
15894
+ (period === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.price ?? 0,
15895
+ (period === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.currency
15827
15896
  )
15828
15897
  }
15829
15898
  ),
@@ -16024,7 +16093,8 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
16024
16093
  $color: theme.typography.text.color,
16025
16094
  children: [
16026
16095
  formatCurrency(
16027
- ((period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * quantity
16096
+ ((period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * quantity,
16097
+ (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
16028
16098
  ),
16029
16099
  /* @__PURE__ */ jsxs11("sub", { children: [
16030
16100
  "/",
@@ -16042,7 +16112,8 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
16042
16112
  $color: unitPriceColor,
16043
16113
  children: [
16044
16114
  formatCurrency(
16045
- (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0
16115
+ (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0,
16116
+ (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
16046
16117
  ),
16047
16118
  /* @__PURE__ */ jsxs11("sub", { children: [
16048
16119
  "/",
@@ -16075,14 +16146,19 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
16075
16146
  import { useEffect as useEffect4, useState as useState6 } from "react";
16076
16147
 
16077
16148
  // node_modules/@stripe/stripe-js/dist/index.mjs
16078
- var V3_URL = "https://js.stripe.com/v3";
16149
+ var ORIGIN = "https://js.stripe.com";
16150
+ var STRIPE_JS_URL = "".concat(ORIGIN, "/v3");
16079
16151
  var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
16152
+ var STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;
16080
16153
  var EXISTING_SCRIPT_MESSAGE = "loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";
16154
+ var isStripeJSURL = function isStripeJSURL2(url) {
16155
+ return V3_URL_REGEX.test(url) || STRIPE_JS_URL_REGEX.test(url);
16156
+ };
16081
16157
  var findScript = function findScript2() {
16082
- var scripts = document.querySelectorAll('script[src^="'.concat(V3_URL, '"]'));
16158
+ var scripts = document.querySelectorAll('script[src^="'.concat(ORIGIN, '"]'));
16083
16159
  for (var i2 = 0; i2 < scripts.length; i2++) {
16084
16160
  var script = scripts[i2];
16085
- if (!V3_URL_REGEX.test(script.src)) {
16161
+ if (!isStripeJSURL(script.src)) {
16086
16162
  continue;
16087
16163
  }
16088
16164
  return script;
@@ -16092,7 +16168,7 @@ var findScript = function findScript2() {
16092
16168
  var injectScript = function injectScript2(params) {
16093
16169
  var queryString = params && !params.advancedFraudSignals ? "?advancedFraudSignals=false" : "";
16094
16170
  var script = document.createElement("script");
16095
- script.src = "".concat(V3_URL).concat(queryString);
16171
+ script.src = "".concat(STRIPE_JS_URL).concat(queryString);
16096
16172
  var headOrBody = document.head || document.body;
16097
16173
  if (!headOrBody) {
16098
16174
  throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
@@ -16106,7 +16182,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
16106
16182
  }
16107
16183
  stripe._registerWrapper({
16108
16184
  name: "stripe-js",
16109
- version: "5.6.0",
16185
+ version: "5.7.0",
16110
16186
  startTime
16111
16187
  });
16112
16188
  };
@@ -16388,12 +16464,6 @@ var CheckoutDialog = ({ top = 0 }) => {
16388
16464
  const modalRef = useRef5(null);
16389
16465
  const contentRef = useRef5(null);
16390
16466
  const checkoutRef = useRef5(null);
16391
- const [checkoutStage, setCheckoutStage] = useState7(
16392
- () => selected.addOnId ? "addons" : selected.usage ? "usage" : "plan"
16393
- );
16394
- const [planPeriod, setPlanPeriod] = useState7(
16395
- selected.period || data.company?.plan?.planPeriod || "month"
16396
- );
16397
16467
  const [charges, setCharges] = useState7();
16398
16468
  const [paymentMethodId, setPaymentMethodId] = useState7();
16399
16469
  const [isLoading, setIsLoading] = useState7(false);
@@ -16402,13 +16472,18 @@ var CheckoutDialog = ({ top = 0 }) => {
16402
16472
  !data.subscription?.paymentMethod
16403
16473
  );
16404
16474
  const [promoCode, setPromoCode] = useState7();
16475
+ const [planPeriod, setPlanPeriod] = useState7(
16476
+ selected.period || data.company?.plan?.planPeriod || "month"
16477
+ );
16405
16478
  const {
16406
16479
  plans: availablePlans,
16407
16480
  addOns: availableAddOns,
16408
16481
  periods: availablePeriods
16409
16482
  } = useAvailablePlans(planPeriod);
16410
16483
  const [selectedPlan, setSelectedPlan] = useState7(
16411
- () => availablePlans.find((plan) => plan.current)
16484
+ () => availablePlans.find(
16485
+ (plan) => selected.planId ? plan.id === selected.planId : plan.current
16486
+ )
16412
16487
  );
16413
16488
  const currentAddOns = data.company?.addOns || [];
16414
16489
  const [addOns, setAddOns] = useState7(
@@ -16471,6 +16546,18 @@ var CheckoutDialog = ({ top = 0 }) => {
16471
16546
  ),
16472
16547
  [usageBasedEntitlements]
16473
16548
  );
16549
+ const [checkoutStage, setCheckoutStage] = useState7(() => {
16550
+ if (selected.planId !== currentPlan?.id) {
16551
+ return payInAdvanceEntitlements.length > 0 ? "usage" : "addons";
16552
+ }
16553
+ if (selected.addOnId) {
16554
+ return "addons";
16555
+ }
16556
+ if (selected.usage) {
16557
+ return "usage";
16558
+ }
16559
+ return "plan";
16560
+ });
16474
16561
  const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected === true);
16475
16562
  const hasActivePayInAdvanceEntitlements = payInAdvanceEntitlements.some(
16476
16563
  ({ quantity }) => quantity > 0
@@ -16515,50 +16602,12 @@ var CheckoutDialog = ({ top = 0 }) => {
16515
16602
  requiresPayment
16516
16603
  ]);
16517
16604
  const isLightBackground = useIsLightBackground();
16518
- const selectPlan = useCallback7(
16519
- (updatedPlan, updatedPeriod) => {
16520
- const entitlements = updatedPlan.entitlements.reduce(
16521
- createActiveUsageBasedEntitlementsReducer(updatedPeriod),
16522
- []
16523
- );
16524
- setSelectedPlan(updatedPlan);
16525
- setUsageBasedEntitlements(entitlements);
16526
- },
16527
- [createActiveUsageBasedEntitlementsReducer]
16528
- );
16529
- const toggleAddOn = (id) => {
16530
- setAddOns(
16531
- (prev2) => prev2.map((addOn) => ({
16532
- ...addOn,
16533
- ...addOn.id === id && { isSelected: !addOn.isSelected }
16534
- }))
16535
- );
16536
- };
16537
- const changePlanPeriod = useCallback7(
16538
- (period) => {
16539
- if (selectedPlan) {
16540
- selectPlan(selectedPlan, period);
16541
- }
16542
- setPlanPeriod(period);
16543
- },
16544
- [selectedPlan, selectPlan, setPlanPeriod]
16545
- );
16546
- const updateUsageBasedEntitlementQuantity = (id, updatedQuantity) => {
16547
- setUsageBasedEntitlements(
16548
- (prev2) => prev2.map(
16549
- ({ entitlement, allocation, quantity, usage }) => entitlement.id === id ? {
16550
- entitlement,
16551
- allocation,
16552
- quantity: updatedQuantity,
16553
- usage
16554
- } : { entitlement, allocation, quantity, usage }
16555
- )
16556
- );
16557
- };
16558
- useEffect5(() => {
16559
- async function previewCheckout() {
16560
- const planPriceId = planPeriod === "month" ? selectedPlan?.monthlyPrice?.id : selectedPlan?.yearlyPrice?.id;
16561
- if (!api || !selectedPlan || !planPriceId) {
16605
+ const previewCheckout = useCallback7(
16606
+ async (updates) => {
16607
+ const period = updates.period || planPeriod;
16608
+ const plan = updates.plan || selectedPlan;
16609
+ const planPriceId = period === "month" ? plan?.monthlyPrice?.id : plan?.yearlyPrice?.id;
16610
+ if (!api || !plan || !planPriceId) {
16562
16611
  return;
16563
16612
  }
16564
16613
  setError(void 0);
@@ -16567,23 +16616,26 @@ var CheckoutDialog = ({ top = 0 }) => {
16567
16616
  try {
16568
16617
  const { data: data2 } = await api.previewCheckout({
16569
16618
  changeSubscriptionRequestBody: {
16570
- newPlanId: selectedPlan.id,
16619
+ newPlanId: plan.id,
16571
16620
  newPriceId: planPriceId,
16572
- addOnIds: addOns.reduce((acc, addOn) => {
16573
- if (addOn.isSelected) {
16574
- const addOnPriceId = (planPeriod === "month" ? addOn?.monthlyPrice : addOn?.yearlyPrice)?.id;
16575
- if (addOnPriceId) {
16576
- acc.push({
16577
- addOnId: addOn.id,
16578
- priceId: addOnPriceId
16579
- });
16621
+ addOnIds: (updates.addOns || addOns).reduce(
16622
+ (acc, addOn) => {
16623
+ if (addOn.isSelected) {
16624
+ const addOnPriceId = (period === "month" ? addOn?.monthlyPrice : addOn?.yearlyPrice)?.id;
16625
+ if (addOnPriceId) {
16626
+ acc.push({
16627
+ addOnId: addOn.id,
16628
+ priceId: addOnPriceId
16629
+ });
16630
+ }
16580
16631
  }
16581
- }
16582
- return acc;
16583
- }, []),
16584
- payInAdvance: payInAdvanceEntitlements.reduce(
16632
+ return acc;
16633
+ },
16634
+ []
16635
+ ),
16636
+ payInAdvance: (updates.payInAdvanceEntitlements || payInAdvanceEntitlements).reduce(
16585
16637
  (acc, { entitlement, quantity }) => {
16586
- const priceId = (planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.priceId;
16638
+ const priceId = (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.priceId;
16587
16639
  if (priceId) {
16588
16640
  acc.push({
16589
16641
  priceId,
@@ -16594,7 +16646,7 @@ var CheckoutDialog = ({ top = 0 }) => {
16594
16646
  },
16595
16647
  []
16596
16648
  ),
16597
- promoCode
16649
+ promoCode: updates.promoCode || promoCode
16598
16650
  }
16599
16651
  });
16600
16652
  setCharges(data2);
@@ -16613,19 +16665,88 @@ var CheckoutDialog = ({ top = 0 }) => {
16613
16665
  } finally {
16614
16666
  setIsLoading(false);
16615
16667
  }
16616
- }
16617
- previewCheckout();
16618
- }, [
16619
- t2,
16620
- api,
16621
- planPeriod,
16622
- selectedPlan,
16623
- addOns,
16624
- payInAdvanceEntitlements,
16625
- promoCode
16626
- ]);
16668
+ },
16669
+ [
16670
+ t2,
16671
+ api,
16672
+ planPeriod,
16673
+ selectedPlan,
16674
+ addOns,
16675
+ payInAdvanceEntitlements,
16676
+ promoCode
16677
+ ]
16678
+ );
16679
+ const selectPlan = useCallback7(
16680
+ (updates) => {
16681
+ const plan = updates.plan || selectedPlan;
16682
+ if (!plan) {
16683
+ return;
16684
+ }
16685
+ const period = updates.period || planPeriod;
16686
+ const entitlements = plan.entitlements.reduce(
16687
+ createActiveUsageBasedEntitlementsReducer(period),
16688
+ []
16689
+ );
16690
+ if (updates.plan) {
16691
+ setSelectedPlan(plan);
16692
+ setUsageBasedEntitlements(entitlements);
16693
+ }
16694
+ previewCheckout({
16695
+ period,
16696
+ plan: updates.plan,
16697
+ payInAdvanceEntitlements: entitlements.filter(
16698
+ ({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
16699
+ )
16700
+ });
16701
+ },
16702
+ [
16703
+ planPeriod,
16704
+ selectedPlan,
16705
+ createActiveUsageBasedEntitlementsReducer,
16706
+ previewCheckout
16707
+ ]
16708
+ );
16709
+ const changePlanPeriod = useCallback7(
16710
+ (period) => {
16711
+ setPlanPeriod(period);
16712
+ previewCheckout({ period });
16713
+ },
16714
+ [setPlanPeriod, previewCheckout]
16715
+ );
16716
+ const toggleAddOn = (id) => {
16717
+ setAddOns((prev2) => {
16718
+ const updated = prev2.map((addOn) => ({
16719
+ ...addOn,
16720
+ ...addOn.id === id && { isSelected: !addOn.isSelected }
16721
+ }));
16722
+ previewCheckout({ addOns: updated });
16723
+ return updated;
16724
+ });
16725
+ };
16726
+ const updateUsageBasedEntitlementQuantity = useCallback7(
16727
+ (id, updatedQuantity) => {
16728
+ setUsageBasedEntitlements((prev2) => {
16729
+ const updated = prev2.map(
16730
+ ({ entitlement, allocation, quantity, usage }) => entitlement.id === id ? {
16731
+ entitlement,
16732
+ allocation,
16733
+ quantity: updatedQuantity,
16734
+ usage
16735
+ } : { entitlement, allocation, quantity, usage }
16736
+ );
16737
+ previewCheckout({
16738
+ payInAdvanceEntitlements: updated.filter(
16739
+ ({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
16740
+ )
16741
+ });
16742
+ return updated;
16743
+ });
16744
+ },
16745
+ [previewCheckout]
16746
+ );
16627
16747
  const updatePromoCode = (code) => {
16628
16748
  setPromoCode(code);
16749
+ previewCheckout({ promoCode: code });
16629
16750
  };
16630
16751
  useEffect5(() => {
16631
16752
  if (charges) {
@@ -17395,6 +17516,18 @@ var Details = ({
17395
17516
  const { t: t2 } = useTranslation();
17396
17517
  const theme = nt();
17397
17518
  const { data } = useEmbed();
17519
+ const currency = useMemo7(() => {
17520
+ if (data.company?.plan?.planPeriod === "month") {
17521
+ return monthlyUsageBasedPrice?.currency;
17522
+ }
17523
+ if (data.company?.plan?.planPeriod === "year") {
17524
+ return yearlyUsageBasedPrice?.currency;
17525
+ }
17526
+ }, [
17527
+ data.company?.plan?.planPeriod,
17528
+ monthlyUsageBasedPrice,
17529
+ yearlyUsageBasedPrice
17530
+ ]);
17398
17531
  const price = useMemo7(() => {
17399
17532
  if (data.company?.plan?.planPeriod === "month") {
17400
17533
  return monthlyUsageBasedPrice?.price;
@@ -17415,7 +17548,7 @@ var Details = ({
17415
17548
  return `${formatNumber(allocation)} ${(0, import_pluralize4.default)(feature.name, allocation)}`;
17416
17549
  }
17417
17550
  if (priceBehavior === "pay_as_you_go" && typeof price === "number") {
17418
- return `${formatCurrency(price)} ${t2("per")} ${(0, import_pluralize4.default)(feature.name.toLowerCase(), 1)}`;
17551
+ return `${formatCurrency(price, currency)} ${t2("per")} ${(0, import_pluralize4.default)(feature.name.toLowerCase(), 1)}`;
17419
17552
  }
17420
17553
  if (!priceBehavior && typeof allocation === "number") {
17421
17554
  return `${formatNumber(allocation)} ${(0, import_pluralize4.default)(feature.name, allocation)}`;
@@ -17431,15 +17564,15 @@ var Details = ({
17431
17564
  if (usageData) {
17432
17565
  let acc;
17433
17566
  if (priceBehavior === "pay_in_advance" && typeof data.company?.plan?.planPeriod === "string" && typeof price === "number") {
17434
- acc = `${formatCurrency(price)}/${(0, import_pluralize4.default)(feature.name.toLowerCase(), 1)}/${shortenPeriod(data.company.plan.planPeriod)}`;
17567
+ acc = `${formatCurrency(price, currency)}/${(0, import_pluralize4.default)(feature.name.toLowerCase(), 1)}/${shortenPeriod(data.company.plan.planPeriod)}`;
17435
17568
  } else if (priceBehavior === "pay_as_you_go" && typeof usage === "number") {
17436
17569
  acc = `${usage} ${(0, import_pluralize4.default)(feature.name.toLowerCase(), usage)} ${t2("used")}`;
17437
17570
  }
17438
17571
  if (acc) {
17439
17572
  if (usageData?.priceBehavior === "pay_in_advance" && typeof price === "number" && typeof allocation === "number") {
17440
- acc += ` \u2022 ${formatCurrency(price * allocation)}`;
17573
+ acc += ` \u2022 ${formatCurrency(price * allocation, currency)}`;
17441
17574
  } else if (usageData?.priceBehavior === "pay_as_you_go" && typeof price === "number" && typeof usage === "number") {
17442
- acc += ` \u2022 ${formatCurrency(price * usage)}`;
17575
+ acc += ` \u2022 ${formatCurrency(price * usage, currency)}`;
17443
17576
  }
17444
17577
  return acc;
17445
17578
  }
@@ -17741,9 +17874,9 @@ function resolveDesignProps2(props) {
17741
17874
  function formatInvoices(invoices) {
17742
17875
  return (invoices || []).filter(
17743
17876
  ({ url, amountDue, amountPaid }) => url && (amountDue === 0 || amountPaid > 0)
17744
- ).sort((a2, b2) => a2.dueDate && b2.dueDate ? +b2.dueDate - +a2.dueDate : 1).map(({ amountDue, dueDate, url }) => ({
17877
+ ).sort((a2, b2) => a2.dueDate && b2.dueDate ? +b2.dueDate - +a2.dueDate : 1).map(({ amountDue, dueDate, url, currency }) => ({
17745
17878
  ...dueDate && { date: toPrettyDate(dueDate) },
17746
- amount: formatCurrency(amountDue),
17879
+ amount: formatCurrency(amountDue, currency),
17747
17880
  url
17748
17881
  }));
17749
17882
  }
@@ -17926,10 +18059,13 @@ var MeteredFeatures = forwardRef9(({ className, ...rest }, ref) => {
17926
18059
  yearlyUsageBasedPrice
17927
18060
  }, index) => {
17928
18061
  let price;
18062
+ let currency;
17929
18063
  if (planPeriod === "month") {
17930
18064
  price = monthlyUsageBasedPrice?.price;
18065
+ currency = monthlyUsageBasedPrice?.currency;
17931
18066
  } else if (planPeriod === "year") {
17932
18067
  price = yearlyUsageBasedPrice?.price;
18068
+ currency = yearlyUsageBasedPrice?.currency;
17933
18069
  }
17934
18070
  return /* @__PURE__ */ jsxs21(Element, { as: Flex, $gap: "1.5rem", children: [
17935
18071
  props.icon.isVisible && feature?.icon && /* @__PURE__ */ jsx28(
@@ -18003,7 +18139,7 @@ var MeteredFeatures = forwardRef9(({ className, ...rest }, ref) => {
18003
18139
  formatNumber(allocation),
18004
18140
  " ",
18005
18141
  (0, import_pluralize5.default)(feature.name, allocation)
18006
- ] }) : priceBehavior === "pay_as_you_go" ? typeof price === "number" && typeof usage === "number" && formatCurrency(usage * price) : typeof usage === "number" && /* @__PURE__ */ jsxs21(Fragment10, { children: [
18142
+ ] }) : priceBehavior === "pay_as_you_go" ? typeof price === "number" && typeof usage === "number" && formatCurrency(usage * price, currency) : typeof usage === "number" && /* @__PURE__ */ jsxs21(Fragment10, { children: [
18007
18143
  formatNumber(usage),
18008
18144
  " ",
18009
18145
  (0, import_pluralize5.default)(feature.name, usage)
@@ -18495,19 +18631,23 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
18495
18631
  (acc, usage) => {
18496
18632
  const quantity = usage?.allocation ?? 0;
18497
18633
  let price;
18634
+ let currencyCode = "USD";
18498
18635
  if (currentPlan?.planPeriod === "month") {
18499
18636
  price = usage.monthlyUsageBasedPrice?.price;
18637
+ currencyCode = usage.monthlyUsageBasedPrice?.currency ?? "USD";
18500
18638
  } else if (currentPlan?.planPeriod === "year") {
18501
18639
  price = usage.yearlyUsageBasedPrice?.price;
18640
+ currencyCode = usage.yearlyUsageBasedPrice?.currency ?? "USD";
18502
18641
  }
18503
18642
  if (usage.priceBehavior && typeof price === "number" && quantity > 0) {
18504
- acc.push({ ...usage, price, quantity });
18643
+ acc.push({ ...usage, price, quantity, currencyCode });
18505
18644
  }
18506
18645
  return acc;
18507
18646
  },
18508
18647
  []
18509
18648
  );
18510
18649
  const billingSubscription = data.company?.billingSubscription;
18650
+ const subscriptionCurrency = billingSubscription?.currency ?? "USD";
18511
18651
  const showTrialBox = billingSubscription && billingSubscription.status == "trialing";
18512
18652
  const trialEndDate = billingSubscription?.trialEnd ? new Date(billingSubscription.trialEnd * 1e3) : /* @__PURE__ */ new Date();
18513
18653
  const todayDate = /* @__PURE__ */ new Date();
@@ -18601,7 +18741,10 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
18601
18741
  $size: theme.typography[props.header.price.fontStyle].fontSize,
18602
18742
  $weight: theme.typography[props.header.price.fontStyle].fontWeight,
18603
18743
  $color: theme.typography[props.header.price.fontStyle].color,
18604
- children: formatCurrency(currentPlan.planPrice)
18744
+ children: formatCurrency(
18745
+ currentPlan.planPrice,
18746
+ subscriptionCurrency
18747
+ )
18605
18748
  }
18606
18749
  ),
18607
18750
  /* @__PURE__ */ jsx30(
@@ -18659,7 +18802,7 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
18659
18802
  $weight: theme.typography.text.fontWeight,
18660
18803
  $color: theme.typography.text.color,
18661
18804
  children: [
18662
- formatCurrency(addOn.planPrice),
18805
+ formatCurrency(addOn.planPrice, subscriptionCurrency),
18663
18806
  /* @__PURE__ */ jsxs23("sub", { children: [
18664
18807
  "/",
18665
18808
  shortenPeriod(addOn.planPeriod)
@@ -18722,7 +18865,10 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
18722
18865
  $weight: theme.typography.text.fontWeight,
18723
18866
  $color: hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46),
18724
18867
  children: [
18725
- formatCurrency(entitlement.price),
18868
+ formatCurrency(
18869
+ entitlement.price,
18870
+ entitlement.currencyCode
18871
+ ),
18726
18872
  /* @__PURE__ */ jsxs23("sub", { children: [
18727
18873
  "/",
18728
18874
  (0, import_pluralize6.default)(
@@ -18744,7 +18890,8 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
18744
18890
  $color: theme.typography.text.color,
18745
18891
  children: [
18746
18892
  formatCurrency(
18747
- entitlement.price * (entitlement.priceBehavior === "pay_in_advance" ? entitlement.quantity : 1)
18893
+ entitlement.price * (entitlement.priceBehavior === "pay_in_advance" ? entitlement.quantity : 1),
18894
+ entitlement.currencyCode
18748
18895
  ),
18749
18896
  /* @__PURE__ */ jsxs23("sub", { children: [
18750
18897
  "/",
@@ -18924,7 +19071,7 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
18924
19071
  $display: "grid",
18925
19072
  $gridTemplateColumns: "repeat(auto-fill, minmax(320px, 1fr))",
18926
19073
  $gap: "1rem",
18927
- children: plans.map((plan, index, self2) => {
19074
+ children: plans.map((plan, index) => {
18928
19075
  const isActivePlan = plan.current && data.company?.plan?.planPeriod === selectedPeriod;
18929
19076
  const count = entitlementCounts[plan.id];
18930
19077
  let isExpanded = false;
@@ -18984,7 +19131,8 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
18984
19131
  $weight: theme.typography[props.plans.name.fontStyle].fontWeight,
18985
19132
  $color: theme.typography[props.plans.name.fontStyle].color,
18986
19133
  children: formatCurrency(
18987
- (selectedPeriod === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0
19134
+ (selectedPeriod === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0,
19135
+ (selectedPeriod === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.currency
18988
19136
  )
18989
19137
  }
18990
19138
  ),
@@ -19029,18 +19177,6 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
19029
19177
  $padding: `${0.75 * cardPadding}rem ${cardPadding}rem 0`,
19030
19178
  children: [
19031
19179
  props.plans.showEntitlements && /* @__PURE__ */ jsxs24(Flex, { $flexDirection: "column", $gap: "1rem", $flexGrow: "1", children: [
19032
- props.plans.showInclusionText && index > 0 && /* @__PURE__ */ jsx31(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ jsx31(
19033
- Text,
19034
- {
19035
- $font: theme.typography.text.fontFamily,
19036
- $size: theme.typography.text.fontSize,
19037
- $weight: theme.typography.text.fontWeight,
19038
- $color: theme.typography.text.color,
19039
- children: t2("Everything in", {
19040
- plan: self2[index - 1].name
19041
- })
19042
- }
19043
- ) }),
19044
19180
  plan.entitlements.slice().sort((a2, b2) => {
19045
19181
  if (a2.feature?.name && b2.feature?.name && a2.feature?.name > b2.feature?.name) {
19046
19182
  return 1;
@@ -19051,10 +19187,13 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
19051
19187
  return 0;
19052
19188
  }).reduce((acc, entitlement) => {
19053
19189
  let price;
19190
+ let currency;
19054
19191
  if (selectedPeriod === "month") {
19055
19192
  price = entitlement.meteredMonthlyPrice?.price;
19193
+ currency = entitlement.meteredMonthlyPrice?.currency;
19056
19194
  } else if (selectedPeriod === "year") {
19057
19195
  price = entitlement.meteredYearlyPrice?.price;
19196
+ currency = entitlement.meteredYearlyPrice?.currency;
19058
19197
  }
19059
19198
  if (entitlement.priceBehavior && typeof price !== "number") {
19060
19199
  return acc;
@@ -19081,7 +19220,7 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
19081
19220
  $color: theme.typography.text.color,
19082
19221
  $leading: 1.35,
19083
19222
  children: typeof price !== "undefined" ? /* @__PURE__ */ jsxs24(Fragment13, { children: [
19084
- formatCurrency(price),
19223
+ formatCurrency(price, currency),
19085
19224
  " ",
19086
19225
  t2("per"),
19087
19226
  " ",
@@ -19299,7 +19438,8 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
19299
19438
  $weight: theme.typography[props.plans.name.fontStyle].fontWeight,
19300
19439
  $color: theme.typography[props.plans.name.fontStyle].color,
19301
19440
  children: formatCurrency(
19302
- (selectedPeriod === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.price ?? 0
19441
+ (selectedPeriod === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.price ?? 0,
19442
+ (selectedPeriod === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.currency
19303
19443
  )
19304
19444
  }
19305
19445
  ),
@@ -19482,7 +19622,8 @@ var UpcomingBill = forwardRef13(({ className, ...rest }, ref) => {
19482
19622
  },
19483
19623
  ...data.upcomingInvoice?.dueDate && {
19484
19624
  dueDate: toPrettyDate(new Date(data.upcomingInvoice.dueDate))
19485
- }
19625
+ },
19626
+ currency: data.upcomingInvoice?.currency
19486
19627
  }
19487
19628
  };
19488
19629
  }, [data.subscription, data.upcomingInvoice]);
@@ -19521,7 +19662,10 @@ var UpcomingBill = forwardRef13(({ className, ...rest }, ref) => {
19521
19662
  $weight: theme.typography[props.price.fontStyle].fontWeight,
19522
19663
  $color: theme.typography[props.price.fontStyle].color,
19523
19664
  $leading: 1,
19524
- children: formatCurrency(upcomingInvoice.amountDue)
19665
+ children: formatCurrency(
19666
+ upcomingInvoice.amountDue,
19667
+ upcomingInvoice.currency
19668
+ )
19525
19669
  }
19526
19670
  ) }),
19527
19671
  /* @__PURE__ */ jsx32(Box, { $lineHeight: 1.15, $maxWidth: "10rem", $textAlign: "right", children: /* @__PURE__ */ jsx32(
@@ -19536,7 +19680,7 @@ var UpcomingBill = forwardRef13(({ className, ...rest }, ref) => {
19536
19680
  }
19537
19681
  ) })
19538
19682
  ] }),
19539
- /* @__PURE__ */ jsxs25(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
19683
+ discounts.length > 0 && /* @__PURE__ */ jsxs25(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
19540
19684
  /* @__PURE__ */ jsx32(Box, { children: /* @__PURE__ */ jsx32(
19541
19685
  Text,
19542
19686
  {
@@ -19588,7 +19732,7 @@ var UpcomingBill = forwardRef13(({ className, ...rest }, ref) => {
19588
19732
  UpcomingBill.displayName = "UpcomingBill";
19589
19733
 
19590
19734
  // src/components/embed/ComponentTree.tsx
19591
- import { useEffect as useEffect9, useState as useState16, Children as Children2 } from "react";
19735
+ import { useEffect as useEffect9, useState as useState16 } from "react";
19592
19736
 
19593
19737
  // src/components/embed/renderer.ts
19594
19738
  import { createElement as createElement5 } from "react";
@@ -19691,7 +19835,7 @@ var Error2 = ({ message }) => {
19691
19835
  );
19692
19836
  };
19693
19837
  var ComponentTree = () => {
19694
- const { error, nodes } = useEmbed();
19838
+ const { error, nodes, isPending } = useEmbed();
19695
19839
  const [children, setChildren] = useState16(/* @__PURE__ */ jsx33(Loading, {}));
19696
19840
  useEffect9(() => {
19697
19841
  const renderer = createRenderer();
@@ -19701,7 +19845,7 @@ var ComponentTree = () => {
19701
19845
  console.error(error);
19702
19846
  return /* @__PURE__ */ jsx33(Error2, { message: error.message });
19703
19847
  }
19704
- if (Children2.count(children) === 0) {
19848
+ if (isPending) {
19705
19849
  return /* @__PURE__ */ jsx33(Loading, {});
19706
19850
  }
19707
19851
  return /* @__PURE__ */ jsx33(Fragment14, { children });