@schematichq/schematic-components 1.1.0 → 1.1.1

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.
@@ -1900,15 +1900,21 @@ __export(index_exports, {
1900
1900
  module.exports = __toCommonJS(index_exports);
1901
1901
 
1902
1902
  // src/components/elements/button/Button.tsx
1903
- var import_react38 = require("react");
1903
+ var import_react39 = require("react");
1904
1904
 
1905
1905
  // src/components/layout/card/Card.tsx
1906
- var import_react22 = require("react");
1906
+ var import_react23 = require("react");
1907
1907
 
1908
1908
  // src/const/components.ts
1909
1909
  var VISIBLE_ENTITLEMENT_COUNT = 4;
1910
1910
  var MAX_VISIBLE_INVOICE_COUNT = 12;
1911
1911
 
1912
+ // src/const/date.ts
1913
+ var SECONDS_IN_MS = 1e3;
1914
+ var MINUTES_IN_MS = SECONDS_IN_MS * 60;
1915
+ var HOURS_IN_MS = MINUTES_IN_MS * 60;
1916
+ var DAYS_IN_MS = HOURS_IN_MS * 24;
1917
+
1912
1918
  // src/const/debounce.ts
1913
1919
  var debounceOptions = {
1914
1920
  leading: true,
@@ -6746,7 +6752,7 @@ var en_default = {
6746
6752
  "There was a problem retrieving your invoices.": "There was a problem retrieving your invoices.",
6747
6753
  "Tiers apply progressively as quantity increases.": "Tiers apply progressively as quantity increases.",
6748
6754
  Total: "Total",
6749
- "Trial ends in": "Trial ends in {{days}} days",
6755
+ "Trial ends in": "Trial ends in {{amount}} {{units}}",
6750
6756
  "Trial in progress": "Trial in progress",
6751
6757
  "Trial selected": "Trial selected",
6752
6758
  Trial: "Trial",
@@ -10143,7 +10149,7 @@ var EmbedProvider = ({
10143
10149
  });
10144
10150
  const customHeaders = (0, import_react12.useMemo)(
10145
10151
  () => ({
10146
- "X-Schematic-Components-Version": "1.1.0",
10152
+ "X-Schematic-Components-Version": "1.1.1",
10147
10153
  "X-Schematic-Session-ID": sessionIdRef.current
10148
10154
  }),
10149
10155
  []
@@ -10538,26 +10544,49 @@ function useRequest(fn) {
10538
10544
  }
10539
10545
 
10540
10546
  // src/hooks/useTrialEnd.ts
10547
+ var import_react17 = require("react");
10541
10548
  function useTrialEnd() {
10549
+ const { t: t2 } = useTranslation();
10542
10550
  const { data } = useEmbed();
10543
- const billingSubscription = isCheckoutData(data) ? data.company?.billingSubscription : void 0;
10544
- const trialEndDate = typeof billingSubscription?.trialEnd === "number" ? new Date(billingSubscription.trialEnd * 1e3) : void 0;
10545
- if (trialEndDate) {
10546
- const todayDate = /* @__PURE__ */ new Date();
10547
- const trialEndDays = Math.floor(
10548
- (trialEndDate.getTime() - todayDate.getTime()) / (1e3 * 60 * 60 * 24)
10549
- );
10550
- return trialEndDays;
10551
- }
10551
+ const { endDate, formatted } = (0, import_react17.useMemo)(() => {
10552
+ const billingSubscription = isCheckoutData(data) ? data.company?.billingSubscription : void 0;
10553
+ const end = typeof billingSubscription?.trialEnd === "number" ? new Date(billingSubscription.trialEnd * 1e3) : void 0;
10554
+ let formatted2;
10555
+ if (end) {
10556
+ const today = /* @__PURE__ */ new Date();
10557
+ const difference = end.getTime() - today.getTime();
10558
+ let amount;
10559
+ let unit;
10560
+ if (difference >= DAYS_IN_MS) {
10561
+ amount = Math.floor(difference / DAYS_IN_MS);
10562
+ unit = "day";
10563
+ } else if (difference >= HOURS_IN_MS) {
10564
+ amount = Math.floor(difference / HOURS_IN_MS);
10565
+ unit = "hour";
10566
+ } else if (difference >= MINUTES_IN_MS) {
10567
+ amount = Math.floor(difference / MINUTES_IN_MS);
10568
+ unit = "minute";
10569
+ } else {
10570
+ amount = Math.floor(difference / SECONDS_IN_MS);
10571
+ unit = "second";
10572
+ }
10573
+ formatted2 = t2("Trial ends in", {
10574
+ amount,
10575
+ units: pluralize(unit, amount)
10576
+ });
10577
+ }
10578
+ return { endDate: end, formatted: formatted2 };
10579
+ }, [t2, data]);
10580
+ return { endDate, formatted };
10552
10581
  }
10553
10582
 
10554
10583
  // src/hooks/useWrapChildren.ts
10555
- var import_react17 = require("react");
10584
+ var import_react18 = require("react");
10556
10585
  function useWrapChildren(elements) {
10557
- const [shouldWrap, setShouldWrap] = (0, import_react17.useState)(
10586
+ const [shouldWrap, setShouldWrap] = (0, import_react18.useState)(
10558
10587
  () => new Array(elements.length).fill(false)
10559
10588
  );
10560
- (0, import_react17.useLayoutEffect)(() => {
10589
+ (0, import_react18.useLayoutEffect)(() => {
10561
10590
  const rowShouldWrap = (parent) => [...parent.children].some(
10562
10591
  (el) => el instanceof HTMLElement && el.previousElementSibling instanceof HTMLElement && el.offsetLeft <= el.previousElementSibling.offsetLeft
10563
10592
  );
@@ -11068,7 +11097,7 @@ var Input = dt.input(({ theme, $size = "md", $variant = "filled" }) => {
11068
11097
  });
11069
11098
 
11070
11099
  // src/components/ui/modal/Modal.tsx
11071
- var import_react18 = require("react");
11100
+ var import_react19 = require("react");
11072
11101
 
11073
11102
  // src/components/ui/modal/styles.ts
11074
11103
  var Overlay = dt(Box)`
@@ -11133,12 +11162,12 @@ var Modal2 = ({
11133
11162
  }) => {
11134
11163
  const { setLayout } = useEmbed();
11135
11164
  const isLightBackground = useIsLightBackground();
11136
- const ref = (0, import_react18.useRef)(null);
11137
- const handleClose = (0, import_react18.useCallback)(() => {
11165
+ const ref = (0, import_react19.useRef)(null);
11166
+ const handleClose = (0, import_react19.useCallback)(() => {
11138
11167
  setLayout("portal");
11139
11168
  onClose?.();
11140
11169
  }, [setLayout, onClose]);
11141
- (0, import_react18.useLayoutEffect)(() => {
11170
+ (0, import_react19.useLayoutEffect)(() => {
11142
11171
  contentRef?.current?.focus({ preventScroll: true });
11143
11172
  }, [contentRef]);
11144
11173
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Container, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
@@ -11168,7 +11197,7 @@ var Modal2 = ({
11168
11197
  Modal2.displayName = "Modal";
11169
11198
 
11170
11199
  // src/components/ui/modal/ModalHeader.tsx
11171
- var import_react19 = require("react");
11200
+ var import_react20 = require("react");
11172
11201
  var import_jsx_runtime5 = require("react/jsx-runtime");
11173
11202
  var ModalHeader = ({
11174
11203
  children,
@@ -11177,7 +11206,7 @@ var ModalHeader = ({
11177
11206
  }) => {
11178
11207
  const { settings, setLayout } = useEmbed();
11179
11208
  const isLightBackground = useIsLightBackground();
11180
- const handleClose = (0, import_react19.useCallback)(() => {
11209
+ const handleClose = (0, import_react20.useCallback)(() => {
11181
11210
  setLayout("portal");
11182
11211
  onClose?.();
11183
11212
  }, [setLayout, onClose]);
@@ -11234,7 +11263,7 @@ var ModalHeader = ({
11234
11263
  };
11235
11264
 
11236
11265
  // src/components/ui/progress-bar/ProgressBar.tsx
11237
- var import_react20 = require("react");
11266
+ var import_react21 = require("react");
11238
11267
  var import_jsx_runtime6 = require("react/jsx-runtime");
11239
11268
  var progressColorMap = [
11240
11269
  "blue",
@@ -11244,7 +11273,7 @@ var progressColorMap = [
11244
11273
  "red",
11245
11274
  "red"
11246
11275
  ];
11247
- var ProgressBar = (0, import_react20.forwardRef)(
11276
+ var ProgressBar = (0, import_react21.forwardRef)(
11248
11277
  ({
11249
11278
  progress,
11250
11279
  value,
@@ -11289,7 +11318,7 @@ var ProgressBar = (0, import_react20.forwardRef)(
11289
11318
  )
11290
11319
  }
11291
11320
  ),
11292
- total && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { $size: 14, $weight: 500, children: [
11321
+ total > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { $size: 14, $weight: 500, children: [
11293
11322
  formatNumber(value),
11294
11323
  "/",
11295
11324
  formatNumber(total)
@@ -11366,7 +11395,7 @@ var Text = dt.span.withConfig({
11366
11395
 
11367
11396
  // src/components/ui/tooltip/Tooltip.tsx
11368
11397
  var import_debounce2 = __toESM(require_debounce());
11369
- var import_react21 = require("react");
11398
+ var import_react22 = require("react");
11370
11399
  var import_react_dom = require("react-dom");
11371
11400
 
11372
11401
  // src/components/ui/tooltip/styles.ts
@@ -11520,10 +11549,10 @@ var Tooltip = ({
11520
11549
  position: position2 = "top",
11521
11550
  ...rest
11522
11551
  }) => {
11523
- const ref = (0, import_react21.useRef)(null);
11524
- const [show, setShow] = (0, import_react21.useState)(false);
11525
- const [coords2, setCoords] = (0, import_react21.useState)({ x: 0, y: 0 });
11526
- const updateCoords = (0, import_react21.useCallback)(() => {
11552
+ const ref = (0, import_react22.useRef)(null);
11553
+ const [show, setShow] = (0, import_react22.useState)(false);
11554
+ const [coords2, setCoords] = (0, import_react22.useState)({ x: 0, y: 0 });
11555
+ const updateCoords = (0, import_react22.useCallback)(() => {
11527
11556
  if (ref.current) {
11528
11557
  const { top: offsetTop, left: offsetLeft } = document.body.getBoundingClientRect();
11529
11558
  const rect = ref.current.getBoundingClientRect();
@@ -11541,14 +11570,14 @@ var Tooltip = ({
11541
11570
  });
11542
11571
  }
11543
11572
  }, [position2]);
11544
- (0, import_react21.useLayoutEffect)(() => {
11573
+ (0, import_react22.useLayoutEffect)(() => {
11545
11574
  const handleResize = (0, import_debounce2.default)(updateCoords, EVENT_DEBOUNCE_TIMEOUT);
11546
11575
  window.addEventListener("resize", handleResize);
11547
11576
  return () => {
11548
11577
  window.removeEventListener("resize", handleResize);
11549
11578
  };
11550
11579
  }, [updateCoords]);
11551
- (0, import_react21.useLayoutEffect)(() => {
11580
+ (0, import_react22.useLayoutEffect)(() => {
11552
11581
  updateCoords();
11553
11582
  }, [updateCoords, show]);
11554
11583
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
@@ -11610,7 +11639,7 @@ var StyledCard = dt.div(({ theme }) => {
11610
11639
 
11611
11640
  // src/components/layout/card/Card.tsx
11612
11641
  var import_jsx_runtime8 = require("react/jsx-runtime");
11613
- var Card = (0, import_react22.forwardRef)(
11642
+ var Card = (0, import_react23.forwardRef)(
11614
11643
  ({ children, className }, ref) => {
11615
11644
  const { settings, isPending } = useEmbed();
11616
11645
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(StyledCard, { ref, className, children: [
@@ -11638,7 +11667,7 @@ var Card = (0, import_react22.forwardRef)(
11638
11667
  Card.displayName = "Card";
11639
11668
 
11640
11669
  // src/components/layout/column/Column.tsx
11641
- var import_react23 = require("react");
11670
+ var import_react24 = require("react");
11642
11671
 
11643
11672
  // src/components/layout/column/styles.ts
11644
11673
  var StyledColumn = dt.div`
@@ -11647,15 +11676,15 @@ var StyledColumn = dt.div`
11647
11676
 
11648
11677
  // src/components/layout/column/Column.tsx
11649
11678
  var import_jsx_runtime9 = require("react/jsx-runtime");
11650
- var Column = (0, import_react23.forwardRef)(
11679
+ var Column = (0, import_react24.forwardRef)(
11651
11680
  ({ children, basis, ...props }, ref) => {
11652
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyledColumn, { ref, ...props, children: import_react23.Children.count(children) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Card, { children }) : children });
11681
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyledColumn, { ref, ...props, children: import_react24.Children.count(children) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Card, { children }) : children });
11653
11682
  }
11654
11683
  );
11655
11684
  Column.displayName = "Column";
11656
11685
 
11657
11686
  // src/components/layout/root/Root.tsx
11658
- var import_react24 = require("react");
11687
+ var import_react25 = require("react");
11659
11688
 
11660
11689
  // src/components/layout/root/styles.ts
11661
11690
  var Container = dt.div`
@@ -11692,7 +11721,7 @@ var Container = dt.div`
11692
11721
 
11693
11722
  // src/components/layout/root/Root.tsx
11694
11723
  var import_jsx_runtime10 = require("react/jsx-runtime");
11695
- var Root = (0, import_react24.forwardRef)(
11724
+ var Root = (0, import_react25.forwardRef)(
11696
11725
  ({ data, settings, ...props }, ref) => {
11697
11726
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Container, { ref, ...props });
11698
11727
  }
@@ -11701,14 +11730,14 @@ Root.displayName = "Root";
11701
11730
 
11702
11731
  // src/components/layout/viewport/Viewport.tsx
11703
11732
  var import_debounce3 = __toESM(require_debounce());
11704
- var import_react37 = require("react");
11733
+ var import_react38 = require("react");
11705
11734
  var import_react_dom2 = require("react-dom");
11706
11735
 
11707
11736
  // src/components/shared/checkout-dialog/CheckoutDialog.tsx
11708
- var import_react29 = require("react");
11737
+ var import_react30 = require("react");
11709
11738
 
11710
11739
  // src/components/shared/sidebar/Sidebar.tsx
11711
- var import_react26 = require("react");
11740
+ var import_react27 = require("react");
11712
11741
 
11713
11742
  // src/components/shared/sidebar/EntitlementRow.tsx
11714
11743
  var import_jsx_runtime11 = require("react/jsx-runtime");
@@ -11782,7 +11811,7 @@ var EntitlementRow = (entitlement) => {
11782
11811
  };
11783
11812
 
11784
11813
  // src/components/shared/sidebar/Proration.tsx
11785
- var import_react25 = require("react");
11814
+ var import_react26 = require("react");
11786
11815
  var import_jsx_runtime12 = require("react/jsx-runtime");
11787
11816
  var Proration = ({
11788
11817
  currency,
@@ -11790,7 +11819,7 @@ var Proration = ({
11790
11819
  selectedPlan
11791
11820
  }) => {
11792
11821
  const { t: t2 } = useTranslation();
11793
- const [open, setOpen] = (0, import_react25.useState)(false);
11822
+ const [open, setOpen] = (0, import_react26.useState)(false);
11794
11823
  const toggle = (e2) => {
11795
11824
  e2.preventDefault();
11796
11825
  e2.stopPropagation();
@@ -12038,7 +12067,7 @@ var Sidebar = ({
12038
12067
  billingSubscription,
12039
12068
  paymentMethod,
12040
12069
  trialPaymentMethodRequired
12041
- } = (0, import_react26.useMemo)(() => {
12070
+ } = (0, import_react27.useMemo)(() => {
12042
12071
  if (isCheckoutData(data)) {
12043
12072
  const currentEntitlements2 = data.featureUsage?.features || [];
12044
12073
  return {
@@ -12076,7 +12105,7 @@ var Sidebar = ({
12076
12105
  trialPaymentMethodRequired: false
12077
12106
  };
12078
12107
  }, [data, planPeriod]);
12079
- const { payInAdvanceEntitlements } = (0, import_react26.useMemo)(() => {
12108
+ const { payInAdvanceEntitlements } = (0, import_react27.useMemo)(() => {
12080
12109
  const payAsYouGoEntitlements = [];
12081
12110
  const payInAdvanceEntitlements2 = usageBasedEntitlements.filter(
12082
12111
  (entitlement) => {
@@ -12088,7 +12117,7 @@ var Sidebar = ({
12088
12117
  );
12089
12118
  return { payAsYouGoEntitlements, payInAdvanceEntitlements: payInAdvanceEntitlements2 };
12090
12119
  }, [usageBasedEntitlements]);
12091
- const subscriptionPrice = (0, import_react26.useMemo)(() => {
12120
+ const subscriptionPrice = (0, import_react27.useMemo)(() => {
12092
12121
  let planPrice;
12093
12122
  let currency;
12094
12123
  if (selectedPlan) {
@@ -12116,7 +12145,7 @@ var Sidebar = ({
12116
12145
  total += payInAdvanceCost;
12117
12146
  return formatCurrency(total, currency);
12118
12147
  }, [selectedPlan, currentPlan, planPeriod, addOns, payInAdvanceEntitlements]);
12119
- const { amountOff, dueNow, newCharges, percentOff, periodStart, proration } = (0, import_react26.useMemo)(() => {
12148
+ const { amountOff, dueNow, newCharges, percentOff, periodStart, proration } = (0, import_react27.useMemo)(() => {
12120
12149
  return {
12121
12150
  amountOff: charges?.amountOff ?? 0,
12122
12151
  dueNow: charges?.dueNow ?? 0,
@@ -12126,7 +12155,7 @@ var Sidebar = ({
12126
12155
  proration: charges?.proration ?? 0
12127
12156
  };
12128
12157
  }, [charges]);
12129
- const handleCheckout = (0, import_react26.useCallback)(async () => {
12158
+ const handleCheckout = (0, import_react27.useCallback)(async () => {
12130
12159
  const planId = selectedPlan?.id;
12131
12160
  const priceId = (planPeriod === "year" ? selectedPlan?.yearlyPrice : selectedPlan?.monthlyPrice)?.id;
12132
12161
  try {
@@ -12191,7 +12220,7 @@ var Sidebar = ({
12191
12220
  willTrialWithoutPaymentMethod,
12192
12221
  promoCode
12193
12222
  ]);
12194
- const handleUnsubscribe = (0, import_react26.useCallback)(async () => {
12223
+ const handleUnsubscribe = (0, import_react27.useCallback)(async () => {
12195
12224
  try {
12196
12225
  setError(void 0);
12197
12226
  setIsLoading(true);
@@ -12205,7 +12234,7 @@ var Sidebar = ({
12205
12234
  }
12206
12235
  }, [t2, unsubscribe, setError, setIsLoading, setLayout]);
12207
12236
  const selectedAddOns = addOns.filter((addOn) => addOn.isSelected);
12208
- const updatedUsageBasedEntitlements = (0, import_react26.useMemo)(() => {
12237
+ const updatedUsageBasedEntitlements = (0, import_react27.useMemo)(() => {
12209
12238
  const changedUsageBasedEntitlements = [];
12210
12239
  const addedUsageBasedEntitlements = selectedPlan ? usageBasedEntitlements.reduce(
12211
12240
  (acc, selected) => {
@@ -12840,7 +12869,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
12840
12869
  };
12841
12870
 
12842
12871
  // src/components/shared/checkout-dialog/Checkout.tsx
12843
- var import_react27 = require("react");
12872
+ var import_react28 = require("react");
12844
12873
  var import_jsx_runtime16 = require("react/jsx-runtime");
12845
12874
  var Checkout = ({
12846
12875
  isPaymentMethodRequired,
@@ -12849,7 +12878,7 @@ var Checkout = ({
12849
12878
  }) => {
12850
12879
  const { t: t2 } = useTranslation();
12851
12880
  const isLightBackground = useIsLightBackground();
12852
- const [discount, setDiscount] = (0, import_react27.useState)("");
12881
+ const [discount, setDiscount] = (0, import_react28.useState)("");
12853
12882
  if (!isPaymentMethodRequired) {
12854
12883
  return null;
12855
12884
  }
@@ -12988,12 +13017,12 @@ var Navigation = ({
12988
13017
  };
12989
13018
 
12990
13019
  // src/components/shared/checkout-dialog/Plan.tsx
12991
- var import_react28 = require("react");
13020
+ var import_react29 = require("react");
12992
13021
  var import_jsx_runtime18 = require("react/jsx-runtime");
12993
13022
  var Selected = ({ isCurrent = false, isTrial = false }) => {
12994
13023
  const { t: t2 } = useTranslation();
12995
13024
  const { settings } = useEmbed();
12996
- const text = (0, import_react28.useMemo)(() => {
13025
+ const text = (0, import_react29.useMemo)(() => {
12997
13026
  if (isCurrent) {
12998
13027
  return isTrial ? t2("Trial in progress") : t2("Current plan");
12999
13028
  }
@@ -13029,7 +13058,7 @@ var PlanButtonGroup = ({
13029
13058
  }) => {
13030
13059
  const { t: t2 } = useTranslation();
13031
13060
  const { data } = useEmbed();
13032
- const { isCurrentPlan, isValidPlan, isTrialing } = (0, import_react28.useMemo)(() => {
13061
+ const { isCurrentPlan, isValidPlan, isTrialing } = (0, import_react29.useMemo)(() => {
13033
13062
  if (isCheckoutData(data)) {
13034
13063
  return {
13035
13064
  isCurrentPlan: data.company?.plan?.id === plan.id,
@@ -13139,10 +13168,10 @@ var Plan = ({
13139
13168
  const { t: t2 } = useTranslation();
13140
13169
  const { data, settings } = useEmbed();
13141
13170
  const isLightBackground = useIsLightBackground();
13142
- const [entitlementCounts, setEntitlementCounts] = (0, import_react28.useState)(
13171
+ const [entitlementCounts, setEntitlementCounts] = (0, import_react29.useState)(
13143
13172
  () => plans.reduce(entitlementCountsReducer, {})
13144
13173
  );
13145
- const isTrialing = (0, import_react28.useMemo)(
13174
+ const isTrialing = (0, import_react29.useMemo)(
13146
13175
  () => isCheckoutData(data) && data.subscription?.status === "trialing",
13147
13176
  [data]
13148
13177
  );
@@ -13161,7 +13190,7 @@ var Plan = ({
13161
13190
  return prev2;
13162
13191
  });
13163
13192
  };
13164
- (0, import_react28.useEffect)(() => {
13193
+ (0, import_react29.useEffect)(() => {
13165
13194
  setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
13166
13195
  }, [plans]);
13167
13196
  const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
@@ -13631,29 +13660,29 @@ var CheckoutDialog = ({ top = 0 }) => {
13631
13660
  const { t: t2 } = useTranslation();
13632
13661
  const { data, checkoutState, previewCheckout } = useEmbed();
13633
13662
  const isLightBackground = useIsLightBackground();
13634
- const contentRef = (0, import_react29.useRef)(null);
13635
- const checkoutRef = (0, import_react29.useRef)(null);
13636
- const [charges, setCharges] = (0, import_react29.useState)();
13637
- const [paymentMethodId, setPaymentMethodId] = (0, import_react29.useState)(
13663
+ const contentRef = (0, import_react30.useRef)(null);
13664
+ const checkoutRef = (0, import_react30.useRef)(null);
13665
+ const [charges, setCharges] = (0, import_react30.useState)();
13666
+ const [paymentMethodId, setPaymentMethodId] = (0, import_react30.useState)(
13638
13667
  () => {
13639
13668
  if (isCheckoutData(data)) {
13640
13669
  return (data.subscription?.paymentMethod || data.company?.defaultPaymentMethod)?.externalId;
13641
13670
  }
13642
13671
  }
13643
13672
  );
13644
- const [isLoading, setIsLoading] = (0, import_react29.useState)(false);
13645
- const [error, setError] = (0, import_react29.useState)();
13646
- const currentPeriod = (0, import_react29.useMemo)(
13673
+ const [isLoading, setIsLoading] = (0, import_react30.useState)(false);
13674
+ const [error, setError] = (0, import_react30.useState)();
13675
+ const currentPeriod = (0, import_react30.useMemo)(
13647
13676
  () => checkoutState?.period || isCheckoutData(data) && data.company?.plan?.planPeriod || "month",
13648
13677
  [data, checkoutState?.period]
13649
13678
  );
13650
- const [planPeriod, setPlanPeriod] = (0, import_react29.useState)(currentPeriod);
13679
+ const [planPeriod, setPlanPeriod] = (0, import_react30.useState)(currentPeriod);
13651
13680
  const {
13652
13681
  plans: availablePlans,
13653
13682
  addOns: availableAddOns,
13654
13683
  periods: availablePeriods
13655
13684
  } = useAvailablePlans(planPeriod);
13656
- const { currentPlanId, currentEntitlements, trialPaymentMethodRequired } = (0, import_react29.useMemo)(() => {
13685
+ const { currentPlanId, currentEntitlements, trialPaymentMethodRequired } = (0, import_react30.useMemo)(() => {
13657
13686
  if (isCheckoutData(data)) {
13658
13687
  return {
13659
13688
  currentPlanId: data.company?.plan?.id,
@@ -13667,7 +13696,7 @@ var CheckoutDialog = ({ top = 0 }) => {
13667
13696
  trialPaymentMethodRequired: false
13668
13697
  };
13669
13698
  }, [data]);
13670
- const [selectedPlan, setSelectedPlan] = (0, import_react29.useState)(
13699
+ const [selectedPlan, setSelectedPlan] = (0, import_react30.useState)(
13671
13700
  () => {
13672
13701
  const currentSelectedPlan = availablePlans.find(
13673
13702
  (plan) => checkoutState?.planId ? plan.id === checkoutState.planId : isHydratedPlan(plan) && plan.current
@@ -13675,8 +13704,8 @@ var CheckoutDialog = ({ top = 0 }) => {
13675
13704
  return currentSelectedPlan;
13676
13705
  }
13677
13706
  );
13678
- const [shouldTrial, setShouldTrial] = (0, import_react29.useState)(false);
13679
- const [addOns, setAddOns] = (0, import_react29.useState)(() => {
13707
+ const [shouldTrial, setShouldTrial] = (0, import_react30.useState)(false);
13708
+ const [addOns, setAddOns] = (0, import_react30.useState)(() => {
13680
13709
  if (isCheckoutData(data)) {
13681
13710
  return availableAddOns.map((addOn) => ({
13682
13711
  ...addOn,
@@ -13687,7 +13716,7 @@ var CheckoutDialog = ({ top = 0 }) => {
13687
13716
  }
13688
13717
  return [];
13689
13718
  });
13690
- const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react29.useState)(
13719
+ const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react30.useState)(
13691
13720
  () => (selectedPlan?.entitlements || []).reduce(
13692
13721
  createActiveUsageBasedEntitlementsReducer(
13693
13722
  currentEntitlements,
@@ -13696,20 +13725,20 @@ var CheckoutDialog = ({ top = 0 }) => {
13696
13725
  []
13697
13726
  )
13698
13727
  );
13699
- const payInAdvanceEntitlements = (0, import_react29.useMemo)(
13728
+ const payInAdvanceEntitlements = (0, import_react30.useMemo)(
13700
13729
  () => usageBasedEntitlements.filter(
13701
13730
  (entitlement) => entitlement.priceBehavior === "pay_in_advance" /* PayInAdvance */
13702
13731
  ),
13703
13732
  [usageBasedEntitlements]
13704
13733
  );
13705
- const [promoCode, setPromoCode] = (0, import_react29.useState)(null);
13706
- const [isPaymentMethodRequired, setIsPaymentMethodRequired] = (0, import_react29.useState)(false);
13707
- const willTrialWithoutPaymentMethod = (0, import_react29.useMemo)(
13734
+ const [promoCode, setPromoCode] = (0, import_react30.useState)(null);
13735
+ const [isPaymentMethodRequired, setIsPaymentMethodRequired] = (0, import_react30.useState)(false);
13736
+ const willTrialWithoutPaymentMethod = (0, import_react30.useMemo)(
13708
13737
  () => shouldTrial && !trialPaymentMethodRequired,
13709
13738
  [shouldTrial, trialPaymentMethodRequired]
13710
13739
  );
13711
13740
  const isSelectedPlanTrialable = isHydratedPlan(selectedPlan) && selectedPlan.isTrialable && selectedPlan.companyCanTrial;
13712
- const checkoutStages = (0, import_react29.useMemo)(() => {
13741
+ const checkoutStages = (0, import_react30.useMemo)(() => {
13713
13742
  const stages = [];
13714
13743
  if (availablePlans) {
13715
13744
  stages.push({
@@ -13754,7 +13783,7 @@ var CheckoutDialog = ({ top = 0 }) => {
13754
13783
  isSelectedPlanTrialable,
13755
13784
  isPaymentMethodRequired
13756
13785
  ]);
13757
- const [checkoutStage, setCheckoutStage] = (0, import_react29.useState)(() => {
13786
+ const [checkoutStage, setCheckoutStage] = (0, import_react30.useState)(() => {
13758
13787
  if (checkoutState?.addOnId) {
13759
13788
  return "addons";
13760
13789
  }
@@ -13766,7 +13795,7 @@ var CheckoutDialog = ({ top = 0 }) => {
13766
13795
  }
13767
13796
  return "plan";
13768
13797
  });
13769
- const handlePreviewCheckout = (0, import_react29.useCallback)(
13798
+ const handlePreviewCheckout = (0, import_react30.useCallback)(
13770
13799
  async (updates) => {
13771
13800
  const period = updates.period || planPeriod;
13772
13801
  const plan = updates.plan || selectedPlan;
@@ -13862,7 +13891,7 @@ var CheckoutDialog = ({ top = 0 }) => {
13862
13891
  promoCode
13863
13892
  ]
13864
13893
  );
13865
- const selectPlan = (0, import_react29.useCallback)(
13894
+ const selectPlan = (0, import_react30.useCallback)(
13866
13895
  (updates) => {
13867
13896
  const plan = updates.plan;
13868
13897
  const period = updates.period || planPeriod;
@@ -13913,7 +13942,7 @@ var CheckoutDialog = ({ top = 0 }) => {
13913
13942
  handlePreviewCheckout
13914
13943
  ]
13915
13944
  );
13916
- const changePlanPeriod = (0, import_react29.useCallback)(
13945
+ const changePlanPeriod = (0, import_react30.useCallback)(
13917
13946
  (period) => {
13918
13947
  if (period !== planPeriod) {
13919
13948
  setPlanPeriod(period);
@@ -13922,7 +13951,7 @@ var CheckoutDialog = ({ top = 0 }) => {
13922
13951
  },
13923
13952
  [planPeriod, setPlanPeriod, handlePreviewCheckout]
13924
13953
  );
13925
- const toggleAddOn = (0, import_react29.useCallback)(
13954
+ const toggleAddOn = (0, import_react30.useCallback)(
13926
13955
  (id) => {
13927
13956
  setAddOns((prev2) => {
13928
13957
  const updated = prev2.map((addOn) => ({
@@ -13935,7 +13964,7 @@ var CheckoutDialog = ({ top = 0 }) => {
13935
13964
  },
13936
13965
  [handlePreviewCheckout]
13937
13966
  );
13938
- const updateUsageBasedEntitlementQuantity = (0, import_react29.useCallback)(
13967
+ const updateUsageBasedEntitlementQuantity = (0, import_react30.useCallback)(
13939
13968
  (id, updatedQuantity) => {
13940
13969
  setUsageBasedEntitlements((prev2) => {
13941
13970
  const updated = prev2.map(
@@ -13954,18 +13983,18 @@ var CheckoutDialog = ({ top = 0 }) => {
13954
13983
  },
13955
13984
  [handlePreviewCheckout]
13956
13985
  );
13957
- const updatePromoCode = (0, import_react29.useCallback)(
13986
+ const updatePromoCode = (0, import_react30.useCallback)(
13958
13987
  async (code) => {
13959
13988
  handlePreviewCheckout({ promoCode: code });
13960
13989
  },
13961
13990
  [handlePreviewCheckout]
13962
13991
  );
13963
- (0, import_react29.useEffect)(() => {
13992
+ (0, import_react30.useEffect)(() => {
13964
13993
  if (selectedPlan) {
13965
13994
  selectPlan({ plan: selectedPlan, period: currentPeriod });
13966
13995
  }
13967
13996
  }, []);
13968
- (0, import_react29.useEffect)(() => {
13997
+ (0, import_react30.useEffect)(() => {
13969
13998
  setAddOns((prevAddOns) => {
13970
13999
  return availableAddOns.filter((availAddOn) => {
13971
14000
  if (!selectedPlan) {
@@ -13987,7 +14016,7 @@ var CheckoutDialog = ({ top = 0 }) => {
13987
14016
  });
13988
14017
  });
13989
14018
  }, [availableAddOns, data?.addOnCompatibilities, selectedPlan]);
13990
- (0, import_react29.useEffect)(() => {
14019
+ (0, import_react30.useEffect)(() => {
13991
14020
  if (charges) {
13992
14021
  checkoutRef.current?.scrollTo({
13993
14022
  top: 0,
@@ -13996,7 +14025,7 @@ var CheckoutDialog = ({ top = 0 }) => {
13996
14025
  });
13997
14026
  }
13998
14027
  }, [charges]);
13999
- (0, import_react29.useLayoutEffect)(() => {
14028
+ (0, import_react30.useLayoutEffect)(() => {
14000
14029
  contentRef.current?.scrollTo({
14001
14030
  top: 0,
14002
14031
  left: 0,
@@ -14171,11 +14200,11 @@ var CheckoutDialog = ({ top = 0 }) => {
14171
14200
  };
14172
14201
 
14173
14202
  // src/components/shared/payment-dialog/PaymentDialog.tsx
14174
- var import_react30 = require("react");
14203
+ var import_react31 = require("react");
14175
14204
  var import_jsx_runtime21 = require("react/jsx-runtime");
14176
14205
  var PaymentDialog = ({ top = 0 }) => {
14177
14206
  const { t: t2 } = useTranslation();
14178
- const contentRef = (0, import_react30.useRef)(null);
14207
+ const contentRef = (0, import_react31.useRef)(null);
14179
14208
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Modal2, { size: "md", top, contentRef, children: [
14180
14209
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ModalHeader, { bordered: true, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Text, { $size: 18, children: t2("Edit payment method") }) }),
14181
14210
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PaymentMethodDetails, {})
@@ -14184,16 +14213,16 @@ var PaymentDialog = ({ top = 0 }) => {
14184
14213
 
14185
14214
  // src/components/shared/payment-form/PaymentForm.tsx
14186
14215
  var import_react_stripe_js = require("@stripe/react-stripe-js");
14187
- var import_react31 = require("react");
14216
+ var import_react32 = require("react");
14188
14217
  var import_jsx_runtime22 = require("react/jsx-runtime");
14189
14218
  var PaymentForm = ({ onConfirm }) => {
14190
14219
  const { t: t2 } = useTranslation();
14191
14220
  const stripe = (0, import_react_stripe_js.useStripe)();
14192
14221
  const elements = (0, import_react_stripe_js.useElements)();
14193
- const [message, setMessage] = (0, import_react31.useState)();
14194
- const [isLoading, setIsLoading] = (0, import_react31.useState)(false);
14195
- const [isConfirmed, setIsConfirmed] = (0, import_react31.useState)(false);
14196
- const [isComplete, setIsComplete] = (0, import_react31.useState)(false);
14222
+ const [message, setMessage] = (0, import_react32.useState)();
14223
+ const [isLoading, setIsLoading] = (0, import_react32.useState)(false);
14224
+ const [isConfirmed, setIsConfirmed] = (0, import_react32.useState)(false);
14225
+ const [isComplete, setIsComplete] = (0, import_react32.useState)(false);
14197
14226
  const handleSubmit = async (event) => {
14198
14227
  event.preventDefault();
14199
14228
  if (!stripe || !elements) {
@@ -14264,7 +14293,7 @@ var PaymentForm = ({ onConfirm }) => {
14264
14293
  };
14265
14294
 
14266
14295
  // src/components/shared/period-toggle/PeriodToggle.tsx
14267
- var import_react32 = require("react");
14296
+ var import_react33 = require("react");
14268
14297
  var import_jsx_runtime23 = require("react/jsx-runtime");
14269
14298
  var PeriodToggle = ({
14270
14299
  options: options2,
@@ -14275,7 +14304,7 @@ var PeriodToggle = ({
14275
14304
  const { t: t2 } = useTranslation();
14276
14305
  const { settings } = useEmbed();
14277
14306
  const isLightBackground = useIsLightBackground();
14278
- const savingsPercentage = (0, import_react32.useMemo)(() => {
14307
+ const savingsPercentage = (0, import_react33.useMemo)(() => {
14279
14308
  if (selectedPlan) {
14280
14309
  const monthlyBillingPrice = getPlanPrice(selectedPlan, "month");
14281
14310
  const yearlyBillingPrice = getPlanPrice(selectedPlan, "year");
@@ -14355,10 +14384,10 @@ var PeriodToggle = ({
14355
14384
  };
14356
14385
 
14357
14386
  // src/components/shared/pricing-tiers-tooltip/PricingTiersTooltip.tsx
14358
- var import_react34 = require("react");
14387
+ var import_react35 = require("react");
14359
14388
 
14360
14389
  // src/components/shared/pricing-tiers-tooltip/PriceText.tsx
14361
- var import_react33 = require("react");
14390
+ var import_react34 = require("react");
14362
14391
  var import_jsx_runtime24 = require("react/jsx-runtime");
14363
14392
  var PriceText = ({
14364
14393
  feature,
@@ -14367,7 +14396,7 @@ var PriceText = ({
14367
14396
  flatAmount = 0,
14368
14397
  perUnitPrice = 0
14369
14398
  }) => {
14370
- const text = (0, import_react33.useMemo)(() => {
14399
+ const text = (0, import_react34.useMemo)(() => {
14371
14400
  if (!flatAmount && perUnitPrice) {
14372
14401
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
14373
14402
  formatCurrency(perUnitPrice, currency),
@@ -14415,7 +14444,7 @@ var PricingTiersTooltip = ({
14415
14444
  const { t: t2 } = useTranslation();
14416
14445
  const { settings } = useEmbed();
14417
14446
  const isLightBackground = useIsLightBackground();
14418
- const tiers = (0, import_react34.useMemo)(() => {
14447
+ const tiers = (0, import_react35.useMemo)(() => {
14419
14448
  let start = 1;
14420
14449
  return priceTiers.map((tier) => {
14421
14450
  const { upTo, ...rest } = tier;
@@ -14474,7 +14503,7 @@ var PricingTiersTooltip = ({
14474
14503
  index
14475
14504
  );
14476
14505
  }) }),
14477
- tiersMode && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
14506
+ (tiersMode === "volume" /* Volume */ || tiersMode === "graduated" /* Graduated */) && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
14478
14507
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
14479
14508
  "hr",
14480
14509
  {
@@ -14488,7 +14517,7 @@ var PricingTiersTooltip = ({
14488
14517
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Text, { children: [
14489
14518
  "\u2139\uFE0F",
14490
14519
  " ",
14491
- tiersMode === "volume" ? t2("Price by unit based on final tier reached.") : t2("Tiers apply progressively as quantity increases.")
14520
+ tiersMode === "volume" /* Volume */ ? t2("Price by unit based on final tier reached.") : t2("Tiers apply progressively as quantity increases.")
14492
14521
  ] }) })
14493
14522
  ] })
14494
14523
  ] }),
@@ -14499,13 +14528,13 @@ var PricingTiersTooltip = ({
14499
14528
  };
14500
14529
 
14501
14530
  // src/components/shared/tiered-pricing-details/TieredPricingDetails.tsx
14502
- var import_react35 = require("react");
14531
+ var import_react36 = require("react");
14503
14532
  var TieredPricingDetails = ({
14504
14533
  entitlement,
14505
14534
  period
14506
14535
  }) => {
14507
14536
  const { t: t2 } = useTranslation();
14508
- const { currency, flatAmount, perUnitPrice, upTo } = (0, import_react35.useMemo)(() => {
14537
+ const { currency, flatAmount, perUnitPrice, upTo } = (0, import_react36.useMemo)(() => {
14509
14538
  const { currency: currency2, priceTier } = getEntitlementPrice(entitlement, period) || {};
14510
14539
  const { flatAmount: flatAmount2, perUnitPrice: perUnitPrice2, perUnitPriceDecimal, upTo: upTo2 } = priceTier?.[0] || {};
14511
14540
  return {
@@ -14553,15 +14582,15 @@ var TieredPricingDetails = ({
14553
14582
  };
14554
14583
 
14555
14584
  // src/components/shared/unsubscribe-dialog/UnsubscribeDialog.tsx
14556
- var import_react36 = require("react");
14585
+ var import_react37 = require("react");
14557
14586
  var import_jsx_runtime26 = require("react/jsx-runtime");
14558
14587
  var UnsubscribeDialog = ({ top = 0 }) => {
14559
14588
  const { t: t2 } = useTranslation();
14560
14589
  const { data, setCheckoutState } = useEmbed();
14561
- const contentRef = (0, import_react36.useRef)(null);
14562
- const [error, setError] = (0, import_react36.useState)();
14563
- const [isLoading, setIsLoading] = (0, import_react36.useState)(false);
14564
- const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = (0, import_react36.useMemo)(() => {
14590
+ const contentRef = (0, import_react37.useRef)(null);
14591
+ const [error, setError] = (0, import_react37.useState)();
14592
+ const [isLoading, setIsLoading] = (0, import_react37.useState)(false);
14593
+ const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = (0, import_react37.useMemo)(() => {
14565
14594
  if (isCheckoutData(data)) {
14566
14595
  return {
14567
14596
  planPeriod: data.company?.plan?.planPeriod || "month",
@@ -14582,7 +14611,7 @@ var UnsubscribeDialog = ({ top = 0 }) => {
14582
14611
  };
14583
14612
  }, [data]);
14584
14613
  const { plans: availablePlans, addOns: availableAddOns } = useAvailablePlans(planPeriod);
14585
- const selectedPlan = (0, import_react36.useMemo)(
14614
+ const selectedPlan = (0, import_react37.useMemo)(
14586
14615
  () => availablePlans.find((plan) => plan.id === currentPlan?.id),
14587
14616
  [currentPlan?.id, availablePlans]
14588
14617
  );
@@ -14591,7 +14620,7 @@ var UnsubscribeDialog = ({ top = 0 }) => {
14591
14620
  createActiveUsageBasedEntitlementsReducer(currentEntitlements, planPeriod),
14592
14621
  []
14593
14622
  );
14594
- const addOns = (0, import_react36.useMemo)(
14623
+ const addOns = (0, import_react37.useMemo)(
14595
14624
  () => availableAddOns.map((available) => ({
14596
14625
  ...available,
14597
14626
  isSelected: currentAddOns.some((current) => available.id === current.id) ?? false
@@ -14628,9 +14657,9 @@ var UnsubscribeDialog = ({ top = 0 }) => {
14628
14657
  "You will retain access to your plan until the end of the billing period, on"
14629
14658
  ),
14630
14659
  " ",
14631
- cancelDate ? toPrettyDate(cancelDate, {
14660
+ toPrettyDate(cancelDate, {
14632
14661
  month: "numeric"
14633
- }) : ""
14662
+ })
14634
14663
  ] })
14635
14664
  ] }),
14636
14665
  /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(Flex, { $flexDirection: "column", $flexWrap: "wrap", $gap: "0.5rem", children: [
@@ -14830,17 +14859,17 @@ var StyledViewport = dt.div.withConfig({
14830
14859
 
14831
14860
  // src/components/layout/viewport/Viewport.tsx
14832
14861
  var import_jsx_runtime29 = require("react/jsx-runtime");
14833
- var Viewport = (0, import_react37.forwardRef)(
14862
+ var Viewport = (0, import_react38.forwardRef)(
14834
14863
  ({ children, portal, ...props }, ref) => {
14835
14864
  const { data, layout, settings } = useEmbed();
14836
- const [top, setTop] = (0, import_react37.useState)(0);
14837
- const { canCheckout, isBadgeVisible } = (0, import_react37.useMemo)(() => {
14865
+ const [top, setTop] = (0, import_react38.useState)(0);
14866
+ const { canCheckout, isBadgeVisible } = (0, import_react38.useMemo)(() => {
14838
14867
  return {
14839
14868
  canCheckout: data?.capabilities?.checkout ?? true,
14840
14869
  isBadgeVisible: !data?.capabilities?.badgeVisibility || settings.badge?.visibility !== "hidden"
14841
14870
  };
14842
14871
  }, [data, settings]);
14843
- (0, import_react37.useLayoutEffect)(() => {
14872
+ (0, import_react38.useLayoutEffect)(() => {
14844
14873
  const parent = portal || document.body;
14845
14874
  const setModalY = (0, import_debounce3.default)(() => {
14846
14875
  const value = Math.abs(
@@ -14887,7 +14916,7 @@ var resolveDesignProps = (props) => {
14887
14916
  }
14888
14917
  };
14889
14918
  };
14890
- var ButtonElement = (0, import_react38.forwardRef)(({ children, className, ...rest }, ref) => {
14919
+ var ButtonElement = (0, import_react39.forwardRef)(({ children, className, ...rest }, ref) => {
14891
14920
  const props = resolveDesignProps(rest);
14892
14921
  const buttonStyles2 = {
14893
14922
  primary: {
@@ -14932,10 +14961,10 @@ var ButtonElement = (0, import_react38.forwardRef)(({ children, className, ...re
14932
14961
  ButtonElement.displayName = "Button";
14933
14962
 
14934
14963
  // src/components/elements/included-features/IncludedFeatures.tsx
14935
- var import_react40 = require("react");
14964
+ var import_react41 = require("react");
14936
14965
 
14937
14966
  // src/components/elements/included-features/UsageDetails.tsx
14938
- var import_react39 = require("react");
14967
+ var import_react40 = require("react");
14939
14968
  var import_jsx_runtime31 = require("react/jsx-runtime");
14940
14969
  var UsageDetails = ({
14941
14970
  entitlement,
@@ -14952,14 +14981,14 @@ var UsageDetails = ({
14952
14981
  } = entitlement;
14953
14982
  const { t: t2 } = useTranslation();
14954
14983
  const { data } = useEmbed();
14955
- const period = (0, import_react39.useMemo)(() => {
14984
+ const period = (0, import_react40.useMemo)(() => {
14956
14985
  return isCheckoutData(data) && typeof data.company?.plan?.planPeriod === "string" ? data.company.plan.planPeriod : void 0;
14957
14986
  }, [data]);
14958
- const { billingPrice, cost, currentTier } = (0, import_react39.useMemo)(
14987
+ const { billingPrice, cost, currentTier } = (0, import_react40.useMemo)(
14959
14988
  () => getUsageDetails(entitlement, period),
14960
14989
  [entitlement, period]
14961
14990
  );
14962
- const text = (0, import_react39.useMemo)(() => {
14991
+ const text = (0, import_react40.useMemo)(() => {
14963
14992
  if (!feature) {
14964
14993
  return;
14965
14994
  }
@@ -15019,7 +15048,7 @@ var UsageDetails = ({
15019
15048
  billingPrice,
15020
15049
  currentTier?.to
15021
15050
  ]);
15022
- const usageText = (0, import_react39.useMemo)(() => {
15051
+ const usageText = (0, import_react40.useMemo)(() => {
15023
15052
  if (!feature) {
15024
15053
  return;
15025
15054
  }
@@ -15028,7 +15057,7 @@ var UsageDetails = ({
15028
15057
  let index = 0;
15029
15058
  if (priceBehavior === "pay_in_advance" /* PayInAdvance */ && typeof period === "string" && typeof price === "number") {
15030
15059
  acc.push(
15031
- /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react39.Fragment, { children: [
15060
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react40.Fragment, { children: [
15032
15061
  formatCurrency(price, currency),
15033
15062
  "/",
15034
15063
  packageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
@@ -15043,7 +15072,7 @@ var UsageDetails = ({
15043
15072
  index += 1;
15044
15073
  } else if ((priceBehavior === "pay_as_you_go" /* PayAsYouGo */ || priceBehavior === "overage" /* Overage */ || priceBehavior === "tier" /* Tiered */) && typeof usage === "number") {
15045
15074
  acc.push(
15046
- /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react39.Fragment, { children: [
15075
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react40.Fragment, { children: [
15047
15076
  usage,
15048
15077
  " ",
15049
15078
  getFeatureName(feature, usage),
@@ -15056,14 +15085,14 @@ var UsageDetails = ({
15056
15085
  if (acc) {
15057
15086
  if (typeof cost === "number" && cost > 0) {
15058
15087
  acc.push(
15059
- /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react39.Fragment, { children: [
15088
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react40.Fragment, { children: [
15060
15089
  " \u2022 ",
15061
15090
  formatCurrency(cost, currency)
15062
15091
  ] }, index)
15063
15092
  );
15064
15093
  index += 1;
15065
15094
  if (feature.featureType === "trait" /* Trait */ && typeof period === "string") {
15066
- acc.push(/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react39.Fragment, { children: [
15095
+ acc.push(/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react40.Fragment, { children: [
15067
15096
  "/",
15068
15097
  shortenPeriod(period)
15069
15098
  ] }, index));
@@ -15148,15 +15177,15 @@ function resolveDesignProps2(props) {
15148
15177
  visibleFeatures: props.visibleFeatures
15149
15178
  };
15150
15179
  }
15151
- var IncludedFeatures = (0, import_react40.forwardRef)(({ className, ...rest }, ref) => {
15180
+ var IncludedFeatures = (0, import_react41.forwardRef)(({ className, ...rest }, ref) => {
15152
15181
  const props = resolveDesignProps2(rest);
15153
15182
  const { t: t2 } = useTranslation();
15154
15183
  const { data, settings } = useEmbed();
15155
- const elements = (0, import_react40.useRef)([]);
15184
+ const elements = (0, import_react41.useRef)([]);
15156
15185
  const shouldWrapChildren = useWrapChildren(elements.current);
15157
15186
  const isLightBackground = useIsLightBackground();
15158
- const [showCount, setShowCount] = (0, import_react40.useState)(VISIBLE_ENTITLEMENT_COUNT);
15159
- const { plan, addOns, featureUsage } = (0, import_react40.useMemo)(() => {
15187
+ const [showCount, setShowCount] = (0, import_react41.useState)(VISIBLE_ENTITLEMENT_COUNT);
15188
+ const { plan, addOns, featureUsage } = (0, import_react41.useMemo)(() => {
15160
15189
  if (isCheckoutData(data)) {
15161
15190
  const orderedFeatureUsage = props.visibleFeatures?.reduce(
15162
15191
  (acc, id) => {
@@ -15292,7 +15321,7 @@ var IncludedFeatures = (0, import_react40.forwardRef)(({ className, ...rest }, r
15292
15321
  IncludedFeatures.displayName = "IncludedFeatures";
15293
15322
 
15294
15323
  // src/components/elements/invoices/Invoices.tsx
15295
- var import_react41 = require("react");
15324
+ var import_react42 = require("react");
15296
15325
  var import_jsx_runtime33 = require("react/jsx-runtime");
15297
15326
  function resolveDesignProps3(props) {
15298
15327
  return {
@@ -15325,15 +15354,15 @@ function formatInvoices(invoices) {
15325
15354
  url: url || void 0
15326
15355
  }));
15327
15356
  }
15328
- var Invoices = (0, import_react41.forwardRef)(({ className, data, ...rest }, ref) => {
15357
+ var Invoices = (0, import_react42.forwardRef)(({ className, data, ...rest }, ref) => {
15329
15358
  const props = resolveDesignProps3(rest);
15330
15359
  const { t: t2 } = useTranslation();
15331
15360
  const { listInvoices, settings } = useEmbed();
15332
- const [isLoading, setIsLoading] = (0, import_react41.useState)(false);
15333
- const [error, setError] = (0, import_react41.useState)();
15334
- const [invoices, setInvoices] = (0, import_react41.useState)(() => formatInvoices(data));
15335
- const [listSize, setListSize] = (0, import_react41.useState)(props.limit.number);
15336
- const getInvoices = (0, import_react41.useCallback)(async () => {
15361
+ const [isLoading, setIsLoading] = (0, import_react42.useState)(false);
15362
+ const [error, setError] = (0, import_react42.useState)();
15363
+ const [invoices, setInvoices] = (0, import_react42.useState)(() => formatInvoices(data));
15364
+ const [listSize, setListSize] = (0, import_react42.useState)(props.limit.number);
15365
+ const getInvoices = (0, import_react42.useCallback)(async () => {
15337
15366
  try {
15338
15367
  setError(void 0);
15339
15368
  setIsLoading(true);
@@ -15352,10 +15381,10 @@ var Invoices = (0, import_react41.forwardRef)(({ className, data, ...rest }, ref
15352
15381
  (prev2) => prev2 !== props.limit.number ? props.limit.number : MAX_VISIBLE_INVOICE_COUNT
15353
15382
  );
15354
15383
  };
15355
- (0, import_react41.useEffect)(() => {
15384
+ (0, import_react42.useEffect)(() => {
15356
15385
  getInvoices();
15357
15386
  }, [getInvoices]);
15358
- (0, import_react41.useEffect)(() => {
15387
+ (0, import_react42.useEffect)(() => {
15359
15388
  setInvoices(formatInvoices(data));
15360
15389
  }, [data]);
15361
15390
  if (invoices.length === 0) {
@@ -15435,7 +15464,7 @@ var Invoices = (0, import_react41.forwardRef)(({ className, data, ...rest }, ref
15435
15464
  Invoices.displayName = "Invoices";
15436
15465
 
15437
15466
  // src/components/elements/metered-features/MeteredFeatures.tsx
15438
- var import_react42 = require("react");
15467
+ var import_react43 = require("react");
15439
15468
 
15440
15469
  // src/components/elements/metered-features/Meter.tsx
15441
15470
  var import_jsx_runtime34 = require("react/jsx-runtime");
@@ -15486,7 +15515,7 @@ var PriceDetails = ({
15486
15515
  tiersMode: billingPrice?.tiersMode || void 0,
15487
15516
  currentTierPerUnitPrice: typeof currentTier?.perUnitPriceDecimal === "string" ? Number(currentTier?.perUnitPriceDecimal) : currentTier?.perUnitPrice
15488
15517
  };
15489
- if (typeof feature === "undefined" || typeof currentTierPerUnitPrice !== "number") {
15518
+ if (!feature || typeof currentTierPerUnitPrice !== "number") {
15490
15519
  return null;
15491
15520
  }
15492
15521
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
@@ -15633,14 +15662,14 @@ function resolveDesignProps4(props) {
15633
15662
  visibleFeatures: props.visibleFeatures
15634
15663
  };
15635
15664
  }
15636
- var MeteredFeatures = (0, import_react42.forwardRef)(({ className, ...rest }, ref) => {
15665
+ var MeteredFeatures = (0, import_react43.forwardRef)(({ className, ...rest }, ref) => {
15637
15666
  const props = resolveDesignProps4(rest);
15638
- const elements = (0, import_react42.useRef)([]);
15667
+ const elements = (0, import_react43.useRef)([]);
15639
15668
  const shouldWrapChildren = useWrapChildren(elements.current);
15640
15669
  const { t: t2 } = useTranslation();
15641
15670
  const { data, settings, setCheckoutState } = useEmbed();
15642
15671
  const isLightBackground = useIsLightBackground();
15643
- const { meteredFeatures, period } = (0, import_react42.useMemo)(() => {
15672
+ const { meteredFeatures, period } = (0, import_react43.useMemo)(() => {
15644
15673
  if (isCheckoutData(data)) {
15645
15674
  const period2 = typeof data.company?.plan?.planPeriod === "string" ? data.company?.plan?.planPeriod : void 0;
15646
15675
  const orderedFeatureUsage = props.visibleFeatures?.reduce(
@@ -15776,10 +15805,10 @@ var MeteredFeatures = (0, import_react42.forwardRef)(({ className, ...rest }, re
15776
15805
  MeteredFeatures.displayName = "MeteredFeatures";
15777
15806
 
15778
15807
  // src/components/elements/payment-method/PaymentMethod.tsx
15779
- var import_react44 = require("react");
15808
+ var import_react45 = require("react");
15780
15809
 
15781
15810
  // src/components/elements/payment-method/PaymentMethodElement.tsx
15782
- var import_react43 = require("react");
15811
+ var import_react44 = require("react");
15783
15812
  var import_jsx_runtime37 = require("react/jsx-runtime");
15784
15813
  var PaymentElement2 = ({
15785
15814
  iconName,
@@ -15899,7 +15928,7 @@ var PaymentListElement = ({
15899
15928
  }) => {
15900
15929
  const isLightBackground = useIsLightBackground();
15901
15930
  const { iconName, iconTitle, label, paymentLast4 } = getPaymentMethodData(paymentMethod);
15902
- const expirationDate = (0, import_react43.useMemo)(() => {
15931
+ const expirationDate = (0, import_react44.useMemo)(() => {
15903
15932
  const { cardExpMonth, cardExpYear } = paymentMethod;
15904
15933
  if (!cardExpMonth || !cardExpYear) {
15905
15934
  return;
@@ -15984,10 +16013,10 @@ var resolveDesignProps5 = (props) => {
15984
16013
  }
15985
16014
  };
15986
16015
  };
15987
- var PaymentMethod = (0, import_react44.forwardRef)(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
16016
+ var PaymentMethod = (0, import_react45.forwardRef)(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
15988
16017
  const props = resolveDesignProps5(rest);
15989
16018
  const { data, setLayout } = useEmbed();
15990
- const { paymentMethod, monthsToExpiration } = (0, import_react44.useMemo)(() => {
16019
+ const { paymentMethod, monthsToExpiration } = (0, import_react45.useMemo)(() => {
15991
16020
  if (isCheckoutData(data)) {
15992
16021
  const paymentMethod2 = data.subscription?.paymentMethod || data.company?.defaultPaymentMethod;
15993
16022
  let monthsToExpiration2;
@@ -16180,7 +16209,7 @@ var loadStripe = function loadStripe2() {
16180
16209
  };
16181
16210
 
16182
16211
  // src/components/elements/payment-method/PaymentMethodDetails.tsx
16183
- var import_react45 = require("react");
16212
+ var import_react46 = require("react");
16184
16213
  var import_jsx_runtime39 = require("react/jsx-runtime");
16185
16214
  var resolveDesignProps6 = () => {
16186
16215
  return {
@@ -16206,7 +16235,7 @@ var PaymentMethodDetails = ({
16206
16235
  updatePaymentMethod,
16207
16236
  deletePaymentMethod
16208
16237
  } = useEmbed();
16209
- const { defaultPaymentMethod, paymentMethods, subscription } = (0, import_react45.useMemo)(() => {
16238
+ const { defaultPaymentMethod, paymentMethods, subscription } = (0, import_react46.useMemo)(() => {
16210
16239
  if (isCheckoutData(data)) {
16211
16240
  return {
16212
16241
  defaultPaymentMethod: data.company?.defaultPaymentMethod,
@@ -16221,14 +16250,14 @@ var PaymentMethodDetails = ({
16221
16250
  };
16222
16251
  }, [data]);
16223
16252
  const isLightBackground = useIsLightBackground();
16224
- const [isLoading, setIsLoading] = (0, import_react45.useState)(false);
16225
- const [error, setError] = (0, import_react45.useState)();
16226
- const [showPaymentForm, setShowPaymentForm] = (0, import_react45.useState)(false);
16227
- const [stripe, setStripe] = (0, import_react45.useState)(null);
16228
- const [setupIntent, setSetupIntent] = (0, import_react45.useState)();
16229
- const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react45.useState)(false);
16230
- const [currentPaymentMethod, setCurrentPaymentMethod] = (0, import_react45.useState)(subscription?.paymentMethod || defaultPaymentMethod);
16231
- const monthsToExpiration = (0, import_react45.useMemo)(() => {
16253
+ const [isLoading, setIsLoading] = (0, import_react46.useState)(false);
16254
+ const [error, setError] = (0, import_react46.useState)();
16255
+ const [showPaymentForm, setShowPaymentForm] = (0, import_react46.useState)(false);
16256
+ const [stripe, setStripe] = (0, import_react46.useState)(null);
16257
+ const [setupIntent, setSetupIntent] = (0, import_react46.useState)();
16258
+ const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react46.useState)(false);
16259
+ const [currentPaymentMethod, setCurrentPaymentMethod] = (0, import_react46.useState)(subscription?.paymentMethod || defaultPaymentMethod);
16260
+ const monthsToExpiration = (0, import_react46.useMemo)(() => {
16232
16261
  let expiration;
16233
16262
  if (typeof currentPaymentMethod?.cardExpYear === "number" && typeof currentPaymentMethod?.cardExpMonth === "number") {
16234
16263
  const today = /* @__PURE__ */ new Date();
@@ -16251,7 +16280,7 @@ var PaymentMethodDetails = ({
16251
16280
  const toggleShowPaymentMethods = () => {
16252
16281
  setShowDifferentPaymentMethods((prev2) => !prev2);
16253
16282
  };
16254
- const initializePaymentMethod = (0, import_react45.useCallback)(async () => {
16283
+ const initializePaymentMethod = (0, import_react46.useCallback)(async () => {
16255
16284
  try {
16256
16285
  setIsLoading(true);
16257
16286
  const response = await createSetupIntent();
@@ -16267,7 +16296,7 @@ var PaymentMethodDetails = ({
16267
16296
  setIsLoading(false);
16268
16297
  }
16269
16298
  }, [t2, createSetupIntent]);
16270
- const handleUpdatePaymentMethod = (0, import_react45.useCallback)(
16299
+ const handleUpdatePaymentMethod = (0, import_react46.useCallback)(
16271
16300
  async (paymentMethodId) => {
16272
16301
  try {
16273
16302
  setIsLoading(true);
@@ -16286,7 +16315,7 @@ var PaymentMethodDetails = ({
16286
16315
  },
16287
16316
  [t2, setPaymentMethodId, updatePaymentMethod]
16288
16317
  );
16289
- const handleDeletePaymentMethod = (0, import_react45.useCallback)(
16318
+ const handleDeletePaymentMethod = (0, import_react46.useCallback)(
16290
16319
  async (paymentMethodId) => {
16291
16320
  try {
16292
16321
  setIsLoading(true);
@@ -16299,12 +16328,12 @@ var PaymentMethodDetails = ({
16299
16328
  },
16300
16329
  [t2, deletePaymentMethod]
16301
16330
  );
16302
- (0, import_react45.useEffect)(() => {
16331
+ (0, import_react46.useEffect)(() => {
16303
16332
  if (!stripe && setupIntent?.publishableKey) {
16304
16333
  setStripe(loadStripe(setupIntent.publishableKey));
16305
16334
  }
16306
16335
  }, [stripe, setupIntent?.publishableKey]);
16307
- (0, import_react45.useEffect)(() => {
16336
+ (0, import_react46.useEffect)(() => {
16308
16337
  if (!setupIntent && (!currentPaymentMethod || showPaymentForm)) {
16309
16338
  initializePaymentMethod();
16310
16339
  }
@@ -16440,7 +16469,7 @@ var PaymentMethodDetails = ({
16440
16469
  },
16441
16470
  paymentMethod.id
16442
16471
  )) }),
16443
- (!setupIntent || !currentPaymentMethod || showDifferentPaymentMethods) && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
16472
+ (!setupIntent || !currentPaymentMethod) && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
16444
16473
  Button,
16445
16474
  {
16446
16475
  type: "button",
@@ -16460,7 +16489,7 @@ var PaymentMethodDetails = ({
16460
16489
  };
16461
16490
 
16462
16491
  // src/components/elements/plan-manager/PlanManager.tsx
16463
- var import_react47 = require("react");
16492
+ var import_react48 = require("react");
16464
16493
 
16465
16494
  // src/components/elements/plan-manager/AddOn.tsx
16466
16495
  var import_jsx_runtime40 = require("react/jsx-runtime");
@@ -16474,7 +16503,7 @@ var AddOn = ({ addOn, currency, layout }) => {
16474
16503
  $gap: "1rem",
16475
16504
  children: [
16476
16505
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Text, { display: layout.addOns.fontStyle, children: addOn.name }),
16477
- addOn.planPrice && addOn.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(Text, { children: [
16506
+ typeof addOn.planPrice === "number" && addOn.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(Text, { children: [
16478
16507
  formatCurrency(addOn.planPrice, currency),
16479
16508
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("sub", { children: addOn.planPeriod == "one-time" ? shortenPeriod(addOn.planPeriod) : `/${shortenPeriod(addOn.planPeriod)}` })
16480
16509
  ] })
@@ -16484,7 +16513,7 @@ var AddOn = ({ addOn, currency, layout }) => {
16484
16513
  };
16485
16514
 
16486
16515
  // src/components/elements/plan-manager/UsageDetails.tsx
16487
- var import_react46 = require("react");
16516
+ var import_react47 = require("react");
16488
16517
  var import_jsx_runtime41 = require("react/jsx-runtime");
16489
16518
  var UsageDetails2 = ({
16490
16519
  entitlement,
@@ -16498,18 +16527,18 @@ var UsageDetails2 = ({
16498
16527
  limit,
16499
16528
  amount = 0,
16500
16529
  cost = 0
16501
- } = (0, import_react46.useMemo)(
16530
+ } = (0, import_react47.useMemo)(
16502
16531
  () => getUsageDetails(entitlement, period),
16503
16532
  [entitlement, period]
16504
16533
  );
16505
- const description = (0, import_react46.useMemo)(() => {
16534
+ const description = (0, import_react47.useMemo)(() => {
16506
16535
  const acc = [];
16507
16536
  let index = 0;
16508
16537
  if (entitlement.priceBehavior === "overage" /* Overage */) {
16509
16538
  acc.push(
16510
- amount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_react46.Fragment, { children: t2("X additional", {
16539
+ amount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_react47.Fragment, { children: t2("X additional", {
16511
16540
  amount
16512
- }) }, index) : /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_react46.Fragment, { children: [
16541
+ }) }, index) : /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_react47.Fragment, { children: [
16513
16542
  t2("Additional"),
16514
16543
  ": "
16515
16544
  ] }, index)
@@ -16520,7 +16549,7 @@ var UsageDetails2 = ({
16520
16549
  if (entitlement.priceBehavior !== "tier" /* Tiered */ && entitlement.feature && typeof price === "number" && !amount) {
16521
16550
  const packageSize = billingPrice?.packageSize ?? 1;
16522
16551
  acc.push(
16523
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_react46.Fragment, { children: [
16552
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_react47.Fragment, { children: [
16524
16553
  formatCurrency(price, billingPrice?.currency),
16525
16554
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("sub", { children: [
16526
16555
  "/",
@@ -16621,12 +16650,12 @@ var resolveDesignProps7 = (props) => {
16621
16650
  }
16622
16651
  };
16623
16652
  };
16624
- var PlanManager = (0, import_react47.forwardRef)(({ children, className, portal, ...rest }, ref) => {
16653
+ var PlanManager = (0, import_react48.forwardRef)(({ children, className, portal, ...rest }, ref) => {
16625
16654
  const props = resolveDesignProps7(rest);
16626
16655
  const { t: t2 } = useTranslation();
16627
16656
  const { data, settings, setCheckoutState } = useEmbed();
16628
16657
  const isLightBackground = useIsLightBackground();
16629
- const trialEndDays = useTrialEnd();
16658
+ const trialEnd = useTrialEnd();
16630
16659
  const {
16631
16660
  currentPlan,
16632
16661
  currentAddOns,
@@ -16635,7 +16664,7 @@ var PlanManager = (0, import_react47.forwardRef)(({ children, className, portal,
16635
16664
  defaultPlan,
16636
16665
  featureUsage,
16637
16666
  trialPaymentMethodRequired
16638
- } = (0, import_react47.useMemo)(() => {
16667
+ } = (0, import_react48.useMemo)(() => {
16639
16668
  if (isCheckoutData(data)) {
16640
16669
  return {
16641
16670
  currentPlan: data.company?.plan,
@@ -16657,11 +16686,11 @@ var PlanManager = (0, import_react47.forwardRef)(({ children, className, portal,
16657
16686
  trialPaymentMethodRequired: false
16658
16687
  };
16659
16688
  }, [data]);
16660
- const usageBasedEntitlements = (0, import_react47.useMemo)(
16689
+ const usageBasedEntitlements = (0, import_react48.useMemo)(
16661
16690
  () => featureUsage.filter((usage) => typeof usage.priceBehavior === "string"),
16662
16691
  [featureUsage]
16663
16692
  );
16664
- const { subscriptionCurrency, willSubscriptionCancel, isTrialSubscription } = (0, import_react47.useMemo)(() => {
16693
+ const { subscriptionCurrency, willSubscriptionCancel, isTrialSubscription } = (0, import_react48.useMemo)(() => {
16665
16694
  const subscriptionCurrency2 = billingSubscription?.currency;
16666
16695
  const isTrialSubscription2 = billingSubscription?.status === "trialing";
16667
16696
  const willSubscriptionCancel2 = typeof billingSubscription?.cancelAt === "number" && billingSubscription?.cancelAtPeriodEnd === true;
@@ -16683,7 +16712,7 @@ var PlanManager = (0, import_react47.forwardRef)(({ children, className, portal,
16683
16712
  $textAlign: "center",
16684
16713
  $backgroundColor: isLightBackground ? darken(settings.theme.card.background, 0.04) : lighten(settings.theme.card.background, 0.04),
16685
16714
  children: [
16686
- trialEndDays && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Text, { as: "h3", display: "heading3", children: t2("Trial ends in", { days: trialEndDays }) }),
16715
+ typeof trialEnd.formatted !== "undefined" && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Text, { as: "h3", display: "heading3", children: trialEnd.formatted }),
16687
16716
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Text, { as: "p", $size: 0.8125 * settings.theme.typography.text.fontSize, children: trialPaymentMethodRequired ? t2("After the trial, subscribe") : defaultPlan ? t2("After the trial, cancel", {
16688
16717
  defaultPlanName: defaultPlan?.name
16689
16718
  }) : t2("After the trial, cancel no default", {
@@ -16702,7 +16731,7 @@ var PlanManager = (0, import_react47.forwardRef)(({ children, className, portal,
16702
16731
  $backgroundColor: isLightBackground ? darken(settings.theme.card.background, 0.04) : lighten(settings.theme.card.background, 0.04),
16703
16732
  children: [
16704
16733
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Text, { as: "h3", display: "heading3", children: t2("Subscription canceled") }),
16705
- billingSubscription?.cancelAt && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
16734
+ typeof billingSubscription?.cancelAt === "number" && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
16706
16735
  Text,
16707
16736
  {
16708
16737
  as: "p",
@@ -16825,17 +16854,17 @@ var PlanManager = (0, import_react47.forwardRef)(({ children, className, portal,
16825
16854
  PlanManager.displayName = "PlanManager";
16826
16855
 
16827
16856
  // src/components/elements/pricing-table/PricingTable.tsx
16828
- var import_react50 = require("react");
16857
+ var import_react51 = require("react");
16829
16858
 
16830
16859
  // src/components/elements/pricing-table/AddOn.tsx
16831
- var import_react48 = require("react");
16860
+ var import_react49 = require("react");
16832
16861
  var import_jsx_runtime43 = require("react/jsx-runtime");
16833
16862
  var AddOn2 = ({ addOn, sharedProps, selectedPeriod }) => {
16834
16863
  const { layout } = sharedProps;
16835
16864
  const { t: t2 } = useTranslation();
16836
16865
  const { data, settings, setCheckoutState } = useEmbed();
16837
16866
  const isLightBackground = useIsLightBackground();
16838
- const { currentAddOns, canCheckout, isStandalone, showCallToAction } = (0, import_react48.useMemo)(() => {
16867
+ const { currentAddOns, canCheckout, isStandalone, showCallToAction } = (0, import_react49.useMemo)(() => {
16839
16868
  if (isCheckoutData(data)) {
16840
16869
  return {
16841
16870
  currentAddOns: data.company?.addOns || [],
@@ -16998,7 +17027,7 @@ var AddOn2 = ({ addOn, sharedProps, selectedPeriod }) => {
16998
17027
  };
16999
17028
 
17000
17029
  // src/components/elements/pricing-table/Plan.tsx
17001
- var import_react49 = require("react");
17030
+ var import_react50 = require("react");
17002
17031
 
17003
17032
  // src/components/elements/pricing-table/Entitlement.tsx
17004
17033
  var import_jsx_runtime44 = require("react/jsx-runtime");
@@ -17130,7 +17159,7 @@ var Plan2 = ({
17130
17159
  const { t: t2 } = useTranslation();
17131
17160
  const { data, settings, setCheckoutState } = useEmbed();
17132
17161
  const isLightBackground = useIsLightBackground();
17133
- const trialEndDays = useTrialEnd();
17162
+ const trialEnd = useTrialEnd();
17134
17163
  const {
17135
17164
  currentPeriod,
17136
17165
  canCheckout,
@@ -17138,11 +17167,11 @@ var Plan2 = ({
17138
17167
  willSubscriptionCancel,
17139
17168
  isStandalone,
17140
17169
  showCallToAction
17141
- } = (0, import_react49.useMemo)(() => {
17170
+ } = (0, import_react50.useMemo)(() => {
17142
17171
  if (isCheckoutData(data)) {
17143
17172
  const billingSubscription = data.company?.billingSubscription;
17144
17173
  const isTrialSubscription2 = billingSubscription?.status === "trialing";
17145
- const willSubscriptionCancel2 = billingSubscription?.cancelAt;
17174
+ const willSubscriptionCancel2 = typeof billingSubscription?.cancelAt === "number";
17146
17175
  return {
17147
17176
  currentPeriod: data.company?.plan?.planPeriod || "month",
17148
17177
  canCheckout: data.capabilities?.checkout ?? true,
@@ -17234,7 +17263,7 @@ var Plan2 = ({
17234
17263
  {
17235
17264
  $size: 0.75 * settings.theme.typography.text.fontSize,
17236
17265
  $color: hexToHSL(settings.theme.primary).l > 50 ? "#000000" : "#FFFFFF",
17237
- children: isTrialSubscription && !willSubscriptionCancel && trialEndDays ? t2("Trial ends in", { days: trialEndDays }) : t2("Active")
17266
+ children: isTrialSubscription && !willSubscriptionCancel && typeof trialEnd !== "undefined" ? trialEnd.formatted : t2("Active")
17238
17267
  }
17239
17268
  )
17240
17269
  }
@@ -17413,11 +17442,11 @@ var resolveDesignProps8 = (props) => {
17413
17442
  }
17414
17443
  };
17415
17444
  };
17416
- var PricingTable = (0, import_react50.forwardRef)(({ className, callToActionUrl, onCallToAction, ...rest }, ref) => {
17445
+ var PricingTable = (0, import_react51.forwardRef)(({ className, callToActionUrl, onCallToAction, ...rest }, ref) => {
17417
17446
  const props = resolveDesignProps8(rest);
17418
17447
  const { t: t2 } = useTranslation();
17419
17448
  const { data, settings, hydratePublic } = useEmbed();
17420
- const { currentPeriod, isStandalone } = (0, import_react50.useMemo)(() => {
17449
+ const { currentPeriod, isStandalone } = (0, import_react51.useMemo)(() => {
17421
17450
  if (isCheckoutData(data)) {
17422
17451
  const billingSubscription = data.company?.billingSubscription;
17423
17452
  const isTrialSubscription = billingSubscription?.status === "trialing";
@@ -17442,9 +17471,9 @@ var PricingTable = (0, import_react50.forwardRef)(({ className, callToActionUrl,
17442
17471
  showCallToAction: typeof callToActionUrl === "string"
17443
17472
  };
17444
17473
  }, [data, callToActionUrl]);
17445
- const [selectedPeriod, setSelectedPeriod] = (0, import_react50.useState)(currentPeriod);
17474
+ const [selectedPeriod, setSelectedPeriod] = (0, import_react51.useState)(currentPeriod);
17446
17475
  const { plans, addOns, periods } = useAvailablePlans(selectedPeriod);
17447
- const [entitlementCounts, setEntitlementCounts] = (0, import_react50.useState)(
17476
+ const [entitlementCounts, setEntitlementCounts] = (0, import_react51.useState)(
17448
17477
  () => plans.reduce(entitlementCountsReducer, {})
17449
17478
  );
17450
17479
  const handleToggleShowAll = (id) => {
@@ -17462,15 +17491,15 @@ var PricingTable = (0, import_react50.forwardRef)(({ className, callToActionUrl,
17462
17491
  return prev2;
17463
17492
  });
17464
17493
  };
17465
- (0, import_react50.useEffect)(() => {
17494
+ (0, import_react51.useEffect)(() => {
17466
17495
  if (isStandalone) {
17467
17496
  hydratePublic();
17468
17497
  }
17469
17498
  }, [isStandalone, hydratePublic]);
17470
- (0, import_react50.useEffect)(() => {
17499
+ (0, import_react51.useEffect)(() => {
17471
17500
  setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
17472
17501
  }, [plans]);
17473
- const Wrapper = isStandalone ? Container : import_react50.Fragment;
17502
+ const Wrapper = isStandalone ? Container : import_react51.Fragment;
17474
17503
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
17475
17504
  FussyChild,
17476
17505
  {
@@ -17591,7 +17620,7 @@ var PricingTable = (0, import_react50.forwardRef)(({ className, callToActionUrl,
17591
17620
  PricingTable.displayName = "PricingTable";
17592
17621
 
17593
17622
  // src/components/elements/text/Text.tsx
17594
- var import_react51 = require("react");
17623
+ var import_react52 = require("react");
17595
17624
  var import_jsx_runtime47 = require("react/jsx-runtime");
17596
17625
  var resolveDesignProps9 = (props) => {
17597
17626
  return {
@@ -17602,7 +17631,7 @@ var resolveDesignProps9 = (props) => {
17602
17631
  }
17603
17632
  };
17604
17633
  };
17605
- var TextElement = (0, import_react51.forwardRef)(({ children, className, ...rest }, ref) => {
17634
+ var TextElement = (0, import_react52.forwardRef)(({ children, className, ...rest }, ref) => {
17606
17635
  const props = resolveDesignProps9(rest);
17607
17636
  return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Element, { as: Flex, ref, className, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
17608
17637
  Text,
@@ -17617,7 +17646,7 @@ var TextElement = (0, import_react51.forwardRef)(({ children, className, ...rest
17617
17646
  TextElement.displayName = "Text";
17618
17647
 
17619
17648
  // src/components/elements/unsubscribe-button/UnsubscribeButton.tsx
17620
- var import_react52 = require("react");
17649
+ var import_react53 = require("react");
17621
17650
  var import_jsx_runtime48 = require("react/jsx-runtime");
17622
17651
  var buttonStyles = {
17623
17652
  primary: {
@@ -17644,11 +17673,11 @@ var resolveDesignProps10 = (props) => {
17644
17673
  }
17645
17674
  };
17646
17675
  };
17647
- var UnsubscribeButton = (0, import_react52.forwardRef)(({ children, className, ...rest }, ref) => {
17676
+ var UnsubscribeButton = (0, import_react53.forwardRef)(({ children, className, ...rest }, ref) => {
17648
17677
  const props = resolveDesignProps10(rest);
17649
17678
  const { t: t2 } = useTranslation();
17650
17679
  const { data, setLayout } = useEmbed();
17651
- const hasActiveSubscription = (0, import_react52.useMemo)(() => {
17680
+ const hasActiveSubscription = (0, import_react53.useMemo)(() => {
17652
17681
  return isCheckoutData(data) && data.subscription && data.subscription.status !== "cancelled" && !data.subscription.cancelAt;
17653
17682
  }, [data]);
17654
17683
  if (!hasActiveSubscription) {
@@ -17683,7 +17712,7 @@ var UnsubscribeButton = (0, import_react52.forwardRef)(({ children, className, .
17683
17712
  UnsubscribeButton.displayName = "UnsubscribeButton";
17684
17713
 
17685
17714
  // src/components/elements/upcoming-bill/UpcomingBill.tsx
17686
- var import_react53 = require("react");
17715
+ var import_react54 = require("react");
17687
17716
  var import_jsx_runtime49 = require("react/jsx-runtime");
17688
17717
  function resolveDesignProps11(props) {
17689
17718
  return {
@@ -17703,15 +17732,15 @@ function resolveDesignProps11(props) {
17703
17732
  }
17704
17733
  };
17705
17734
  }
17706
- var UpcomingBill = (0, import_react53.forwardRef)(({ className, ...rest }, ref) => {
17735
+ var UpcomingBill = (0, import_react54.forwardRef)(({ className, ...rest }, ref) => {
17707
17736
  const props = resolveDesignProps11(rest);
17708
17737
  const { t: t2 } = useTranslation();
17709
17738
  const { data, settings, getUpcomingInvoice } = useEmbed();
17710
17739
  const isLightBackground = useIsLightBackground();
17711
- const [isLoading, setIsLoading] = (0, import_react53.useState)(false);
17712
- const [error, setError] = (0, import_react53.useState)();
17713
- const [upcomingInvoice, setUpcomingInvoice] = (0, import_react53.useState)();
17714
- const discounts = (0, import_react53.useMemo)(() => {
17740
+ const [isLoading, setIsLoading] = (0, import_react54.useState)(false);
17741
+ const [error, setError] = (0, import_react54.useState)();
17742
+ const [upcomingInvoice, setUpcomingInvoice] = (0, import_react54.useState)();
17743
+ const discounts = (0, import_react54.useMemo)(() => {
17715
17744
  return (isCheckoutData(data) && data.subscription?.discounts || []).map(
17716
17745
  (discount) => ({
17717
17746
  couponId: discount.couponId,
@@ -17723,7 +17752,7 @@ var UpcomingBill = (0, import_react53.forwardRef)(({ className, ...rest }, ref)
17723
17752
  })
17724
17753
  );
17725
17754
  }, [data]);
17726
- const getInvoice = (0, import_react53.useCallback)(async () => {
17755
+ const getInvoice = (0, import_react54.useCallback)(async () => {
17727
17756
  if (isCheckoutData(data) && data.component?.id && data.subscription && !data.subscription.cancelAt) {
17728
17757
  try {
17729
17758
  setError(void 0);
@@ -17739,7 +17768,7 @@ var UpcomingBill = (0, import_react53.forwardRef)(({ className, ...rest }, ref)
17739
17768
  }
17740
17769
  }
17741
17770
  }, [data, getUpcomingInvoice]);
17742
- (0, import_react53.useEffect)(() => {
17771
+ (0, import_react54.useEffect)(() => {
17743
17772
  getInvoice();
17744
17773
  }, [getInvoice]);
17745
17774
  if (!isCheckoutData(data) || !data.subscription || data.subscription.cancelAt) {
@@ -17839,6 +17868,7 @@ var UpcomingBill = (0, import_react53.forwardRef)(({ className, ...rest }, ref)
17839
17868
  }) : t2("Amount off", {
17840
17869
  amount: formatCurrency(
17841
17870
  discount.amountOff,
17871
+ // we already checked for `number` type
17842
17872
  discount?.currency
17843
17873
  )
17844
17874
  }) }) })
@@ -22037,10 +22067,10 @@ var { Inflate, inflate, inflateRaw, ungzip } = inflate_1$1;
22037
22067
  var inflate_1 = inflate;
22038
22068
 
22039
22069
  // src/components/embed/Embed.tsx
22040
- var import_react55 = require("react");
22070
+ var import_react56 = require("react");
22041
22071
 
22042
22072
  // src/components/embed/renderer.ts
22043
- var import_react54 = require("react");
22073
+ var import_react55 = require("react");
22044
22074
  var components = {
22045
22075
  Root,
22046
22076
  Viewport,
@@ -22104,7 +22134,7 @@ function createRenderer(options2) {
22104
22134
  const { className, ...rest } = props;
22105
22135
  const resolvedProps = component === "div" ? rest : props;
22106
22136
  const resolvedChildren = children.map(renderNode);
22107
- return (0, import_react54.createElement)(
22137
+ return (0, import_react55.createElement)(
22108
22138
  component,
22109
22139
  {
22110
22140
  key: index,
@@ -22152,8 +22182,8 @@ var Error2 = ({ message }) => {
22152
22182
  );
22153
22183
  };
22154
22184
  var SchematicEmbed = ({ id, accessToken }) => {
22155
- const [children, setChildren] = (0, import_react55.useState)(/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Loading, {}));
22156
- const theme = (0, import_react55.useContext)(et);
22185
+ const [children, setChildren] = (0, import_react56.useState)(/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Loading, {}));
22186
+ const theme = (0, import_react56.useContext)(et);
22157
22187
  const {
22158
22188
  data,
22159
22189
  error,
@@ -22164,17 +22194,17 @@ var SchematicEmbed = ({ id, accessToken }) => {
22164
22194
  setAccessToken,
22165
22195
  updateSettings
22166
22196
  } = useEmbed();
22167
- (0, import_react55.useEffect)(() => {
22197
+ (0, import_react56.useEffect)(() => {
22168
22198
  if (accessToken) {
22169
22199
  setAccessToken(accessToken);
22170
22200
  }
22171
22201
  }, [accessToken, setAccessToken]);
22172
- (0, import_react55.useEffect)(() => {
22202
+ (0, import_react56.useEffect)(() => {
22173
22203
  if (id && stale) {
22174
22204
  hydrateComponent(id);
22175
22205
  }
22176
22206
  }, [id, hydrateComponent, stale]);
22177
- (0, import_react55.useEffect)(() => {
22207
+ (0, import_react56.useEffect)(() => {
22178
22208
  const renderer = createRenderer();
22179
22209
  try {
22180
22210
  if (isCheckoutData(data) && data.component?.ast) {