@schematichq/schematic-components 0.7.15 → 0.7.16

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.
@@ -5981,10 +5981,10 @@ var require_classnames = __commonJS({
5981
5981
  });
5982
5982
 
5983
5983
  // src/components/elements/button/Button.tsx
5984
- import { forwardRef as forwardRef6 } from "react";
5984
+ import { forwardRef as forwardRef7 } from "react";
5985
5985
 
5986
5986
  // src/components/layout/card/Card.tsx
5987
- import { forwardRef as forwardRef2 } from "react";
5987
+ import { forwardRef as forwardRef3 } from "react";
5988
5988
 
5989
5989
  // node_modules/styled-components/node_modules/tslib/tslib.es6.mjs
5990
5990
  var __assign = function() {
@@ -16288,6 +16288,7 @@ var en_default = {
16288
16288
  "After the trial, cancel no default": "After the trial, you will be lose access to {{planName}} plan and your subscription will be cancelled.",
16289
16289
  "After the trial, cancel": "After the trial, you will be downgraded to the {{defaultPlanName}} plan and your subscription will be cancelled.",
16290
16290
  "After the trial, subscribe": "After the trial, subscription starts and you will be billed.",
16291
+ "Amount off": "{{amount}} off",
16291
16292
  Billed: "Billed {{period}}",
16292
16293
  "billing period": "billing period",
16293
16294
  "Cancel subscription": "Cancel subscription",
@@ -16369,11 +16370,13 @@ var en_default = {
16369
16370
  "Subscription canceled": "Subscription canceled",
16370
16371
  Subscription: "Subscription",
16371
16372
  "Talk to support": "Talk to support",
16373
+ "There was a problem retrieving your upcoming invoice.": "There was a problem retrieving your upcoming invoice.",
16372
16374
  Total: "Total",
16373
16375
  "Trial ends in": "Trial ends in {{days}} days",
16374
16376
  "Trial in progress": "Trial in progress",
16375
16377
  "Trial selected": "Trial selected",
16376
16378
  Trial: "Trial",
16379
+ "Try again": "Try again",
16377
16380
  Unlimited: "Unlimited {{item}}",
16378
16381
  "Unsubscribe failed": "Unsubscribe failed",
16379
16382
  Unsubscribe: "Unsubscribe",
@@ -17067,7 +17070,7 @@ var EmbedProvider = ({
17067
17070
  useEffect2(() => {
17068
17071
  if (accessToken) {
17069
17072
  const { headers = {} } = apiConfig ?? {};
17070
- headers["X-Schematic-Components-Version"] = "0.7.15";
17073
+ headers["X-Schematic-Components-Version"] = "0.7.16";
17071
17074
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
17072
17075
  const config = new Configuration({
17073
17076
  ...apiConfig,
@@ -17147,6 +17150,36 @@ function usePrevious2(value) {
17147
17150
  return ref.current;
17148
17151
  }
17149
17152
 
17153
+ // src/hooks/useRequest.ts
17154
+ import { useCallback as useCallback4, useMemo as useMemo4, useState as useState3 } from "react";
17155
+ function useRequest(fn) {
17156
+ const [isLoading, setIsLoading] = useState3(false);
17157
+ const [error, setError] = useState3(null);
17158
+ const [data, setData] = useState3(void 0);
17159
+ const request = useCallback4(async () => {
17160
+ try {
17161
+ setError(null);
17162
+ setIsLoading(true);
17163
+ const response = await fn();
17164
+ if (!response) {
17165
+ return;
17166
+ }
17167
+ setData(response.data);
17168
+ } catch (e2) {
17169
+ if (e2 instanceof Error) {
17170
+ setError(e2);
17171
+ }
17172
+ } finally {
17173
+ setIsLoading(false);
17174
+ }
17175
+ }, [fn]);
17176
+ const value = useMemo4(() => {
17177
+ const state = { isLoading, error, data };
17178
+ return [state, request];
17179
+ }, [isLoading, error, data, request]);
17180
+ return value;
17181
+ }
17182
+
17150
17183
  // src/hooks/useTrialEnd.ts
17151
17184
  function useTrialEnd() {
17152
17185
  const { data } = useEmbed();
@@ -17162,9 +17195,9 @@ function useTrialEnd() {
17162
17195
  }
17163
17196
 
17164
17197
  // src/hooks/useWrapChildren.ts
17165
- import { useLayoutEffect, useState as useState3 } from "react";
17198
+ import { useLayoutEffect, useState as useState4 } from "react";
17166
17199
  function useWrapChildren(elements) {
17167
- const [shouldWrap, setShouldWrap] = useState3(
17200
+ const [shouldWrap, setShouldWrap] = useState4(
17168
17201
  () => new Array(elements.length).fill(false)
17169
17202
  );
17170
17203
  useLayoutEffect(() => {
@@ -17361,7 +17394,7 @@ var Button = dt.button(
17361
17394
  $isLoading = false,
17362
17395
  $alignment = "center",
17363
17396
  $selfAlignment = "center",
17364
- $fullWidth = true,
17397
+ $fullWidth = false,
17365
17398
  disabled,
17366
17399
  theme
17367
17400
  }) => {
@@ -17404,7 +17437,7 @@ var Button = dt.button(
17404
17437
  return lt`
17405
17438
  color: ${textColor};
17406
17439
 
17407
- ${Icon} {
17440
+ ${Text}, ${Icon} {
17408
17441
  color: ${textColor};
17409
17442
  }
17410
17443
  `;
@@ -17423,7 +17456,7 @@ var Button = dt.button(
17423
17456
  border-color: ${color};
17424
17457
  color: ${color};
17425
17458
 
17426
- ${Icon} {
17459
+ ${Text}, ${Icon} {
17427
17460
  color: ${color};
17428
17461
  }
17429
17462
  `;
@@ -17434,7 +17467,7 @@ var Button = dt.button(
17434
17467
  border-color: ${l2 > 50 ? darken(theme.card.background, 0.2) : lighten(theme.card.background, 0.2)};
17435
17468
  color: ${color};
17436
17469
 
17437
- ${Icon} {
17470
+ ${Text}, ${Icon} {
17438
17471
  color: ${color};
17439
17472
  }
17440
17473
  `;
@@ -17449,7 +17482,7 @@ var Button = dt.button(
17449
17482
  text-decoration: underline;
17450
17483
  }
17451
17484
 
17452
- ${Icon} {
17485
+ ${Text}, ${Icon} {
17453
17486
  color: ${color};
17454
17487
  }
17455
17488
  `;
@@ -17490,7 +17523,7 @@ var Button = dt.button(
17490
17523
  border-color: ${color};
17491
17524
  color: ${textColor};
17492
17525
 
17493
- ${Icon} {
17526
+ ${Text}, ${Icon} {
17494
17527
  color: ${textColor};
17495
17528
  }
17496
17529
  `;
@@ -17822,7 +17855,7 @@ var Input = dt.input(({ theme, $size = "md", $variant = "filled" }) => {
17822
17855
  });
17823
17856
 
17824
17857
  // src/components/ui/modal/Modal.tsx
17825
- import { forwardRef, useCallback as useCallback4, useLayoutEffect as useLayoutEffect2 } from "react";
17858
+ import { forwardRef, useCallback as useCallback5, useLayoutEffect as useLayoutEffect2 } from "react";
17826
17859
 
17827
17860
  // src/components/ui/modal/styles.ts
17828
17861
  var Modal = dt(Box).attrs({
@@ -17865,7 +17898,7 @@ var Modal2 = forwardRef(
17865
17898
  ({ children, contentRef, size = "auto", top = 0, onClose, ...rest }, ref) => {
17866
17899
  const { setLayout } = useEmbed();
17867
17900
  const isLightBackground = useIsLightBackground();
17868
- const handleClose = useCallback4(() => {
17901
+ const handleClose = useCallback5(() => {
17869
17902
  setLayout("portal");
17870
17903
  onClose?.();
17871
17904
  }, [setLayout, onClose]);
@@ -17909,7 +17942,7 @@ var Modal2 = forwardRef(
17909
17942
  Modal2.displayName = "Modal";
17910
17943
 
17911
17944
  // src/components/ui/modal/ModalHeader.tsx
17912
- import { useCallback as useCallback5 } from "react";
17945
+ import { useCallback as useCallback6 } from "react";
17913
17946
  import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
17914
17947
  var ModalHeader = ({
17915
17948
  children,
@@ -17919,7 +17952,7 @@ var ModalHeader = ({
17919
17952
  const theme = nt();
17920
17953
  const { setLayout } = useEmbed();
17921
17954
  const isLightBackground = useIsLightBackground();
17922
- const handleClose = useCallback5(() => {
17955
+ const handleClose = useCallback6(() => {
17923
17956
  setLayout("portal");
17924
17957
  onClose?.();
17925
17958
  }, [setLayout, onClose]);
@@ -17967,6 +18000,7 @@ var ModalHeader = ({
17967
18000
  };
17968
18001
 
17969
18002
  // src/components/ui/progress-bar/ProgressBar.tsx
18003
+ import { forwardRef as forwardRef2 } from "react";
17970
18004
  import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
17971
18005
  var progressColorMap = [
17972
18006
  "blue",
@@ -17976,68 +18010,72 @@ var progressColorMap = [
17976
18010
  "red",
17977
18011
  "red"
17978
18012
  ];
17979
- var ProgressBar = ({
17980
- progress,
17981
- value,
17982
- total = 0,
17983
- color = "gray",
17984
- bgColor = "#F2F4F7",
17985
- ...props
17986
- }) => {
17987
- const theme = nt();
17988
- const barColorMap = {
17989
- gray: "#9CA3AF",
17990
- blue: "#2563EB",
17991
- yellow: "#FFAA06",
17992
- orange: "#DB6769",
17993
- red: "#EF4444"
17994
- };
17995
- return /* @__PURE__ */ jsxs3(
17996
- Flex,
17997
- {
17998
- $position: "relative",
17999
- $alignItems: "center",
18000
- $gap: "1rem",
18001
- $width: "100%",
18002
- ...props,
18003
- children: [
18004
- /* @__PURE__ */ jsx6(
18005
- Box,
18006
- {
18007
- $overflow: "hidden",
18008
- $width: "100%",
18009
- $minWidth: "6rem",
18010
- $height: `${8 / TEXT_BASE_SIZE}rem`,
18011
- $backgroundColor: bgColor,
18012
- $borderRadius: "9999px",
18013
- children: /* @__PURE__ */ jsx6(
18014
- Box,
18015
- {
18016
- $width: `${Math.min(progress, 100)}%`,
18017
- $height: "100%",
18018
- $backgroundColor: barColorMap[color]
18019
- }
18020
- )
18021
- }
18022
- ),
18023
- total && /* @__PURE__ */ jsxs3(
18024
- Text,
18025
- {
18026
- $font: theme.typography.text.fontFamily,
18027
- $size: 14,
18028
- $weight: 500,
18029
- $color: theme.typography.text.color,
18030
- children: [
18031
- formatNumber(value),
18032
- "/",
18033
- formatNumber(total)
18034
- ]
18035
- }
18036
- )
18037
- ]
18038
- }
18039
- );
18040
- };
18013
+ var ProgressBar = forwardRef2(
18014
+ ({
18015
+ progress,
18016
+ value,
18017
+ total = 0,
18018
+ color = "gray",
18019
+ bgColor = "#F2F4F7",
18020
+ ...props
18021
+ }, ref) => {
18022
+ const theme = nt();
18023
+ const barColorMap = {
18024
+ gray: "#9CA3AF",
18025
+ blue: "#2563EB",
18026
+ yellow: "#FFAA06",
18027
+ orange: "#DB6769",
18028
+ red: "#EF4444"
18029
+ };
18030
+ return /* @__PURE__ */ jsxs3(
18031
+ Flex,
18032
+ {
18033
+ ref,
18034
+ $position: "relative",
18035
+ $alignItems: "center",
18036
+ $gap: "1rem",
18037
+ $width: "100%",
18038
+ ...props,
18039
+ children: [
18040
+ /* @__PURE__ */ jsx6(
18041
+ Box,
18042
+ {
18043
+ $overflow: "hidden",
18044
+ $width: "100%",
18045
+ $minWidth: "6rem",
18046
+ $height: `${8 / TEXT_BASE_SIZE}rem`,
18047
+ $backgroundColor: bgColor,
18048
+ $borderRadius: "9999px",
18049
+ children: /* @__PURE__ */ jsx6(
18050
+ Box,
18051
+ {
18052
+ $width: `${Math.min(progress, 100)}%`,
18053
+ $height: "100%",
18054
+ $backgroundColor: barColorMap[color]
18055
+ }
18056
+ )
18057
+ }
18058
+ ),
18059
+ total && /* @__PURE__ */ jsxs3(
18060
+ Text,
18061
+ {
18062
+ $font: theme.typography.text.fontFamily,
18063
+ $size: 14,
18064
+ $weight: 500,
18065
+ $color: theme.typography.text.color,
18066
+ children: [
18067
+ formatNumber(value),
18068
+ "/",
18069
+ formatNumber(total)
18070
+ ]
18071
+ }
18072
+ )
18073
+ ]
18074
+ }
18075
+ );
18076
+ }
18077
+ );
18078
+ ProgressBar.displayName = "ProgressBar";
18041
18079
 
18042
18080
  // src/components/ui/text/styles.ts
18043
18081
  var TextPropNames = /* @__PURE__ */ ((TextPropNames2) => {
@@ -18104,12 +18142,13 @@ var Text = dt.span.withConfig({
18104
18142
 
18105
18143
  // src/components/ui/tooltip/Tooltip.tsx
18106
18144
  var import_lodash2 = __toESM(require_lodash());
18107
- import { useCallback as useCallback6, useLayoutEffect as useLayoutEffect3, useRef as useRef4, useState as useState4 } from "react";
18145
+ import { useCallback as useCallback7, useLayoutEffect as useLayoutEffect3, useRef as useRef4, useState as useState5 } from "react";
18108
18146
  import { createPortal } from "react-dom";
18109
18147
 
18110
18148
  // src/components/ui/tooltip/styles.ts
18111
18149
  var Trigger = dt.div`
18112
18150
  width: 100%;
18151
+ flex-grow: 1;
18113
18152
  `;
18114
18153
  var coords = (position2) => {
18115
18154
  let x2 = 0;
@@ -18241,13 +18280,13 @@ var Tooltip = ({
18241
18280
  trigger,
18242
18281
  content,
18243
18282
  position: position2 = "top",
18244
- zIndex = 1,
18283
+ zIndex = 9999999,
18245
18284
  ...rest
18246
18285
  }) => {
18247
18286
  const ref = useRef4(null);
18248
- const [show, setShow] = useState4(false);
18249
- const [coords2, setCoords] = useState4({ x: 0, y: 0 });
18250
- const updateCoords = useCallback6(() => {
18287
+ const [show, setShow] = useState5(false);
18288
+ const [coords2, setCoords] = useState5({ x: 0, y: 0 });
18289
+ const updateCoords = useCallback7(() => {
18251
18290
  if (ref.current) {
18252
18291
  const { top: offsetTop, left: offsetLeft } = document.body.getBoundingClientRect();
18253
18292
  const rect = ref.current.getBoundingClientRect();
@@ -18334,7 +18373,7 @@ var StyledCard = dt.div(({ theme }) => {
18334
18373
 
18335
18374
  // src/components/layout/card/Card.tsx
18336
18375
  import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
18337
- var Card = forwardRef2(
18376
+ var Card = forwardRef3(
18338
18377
  ({ children, className }, ref) => {
18339
18378
  const { isPending } = useEmbed();
18340
18379
  const theme = nt();
@@ -18363,7 +18402,7 @@ var Card = forwardRef2(
18363
18402
  Card.displayName = "Card";
18364
18403
 
18365
18404
  // src/components/layout/column/Column.tsx
18366
- import { Children as Children2, forwardRef as forwardRef3 } from "react";
18405
+ import { Children as Children2, forwardRef as forwardRef4 } from "react";
18367
18406
 
18368
18407
  // src/components/layout/column/styles.ts
18369
18408
  var StyledColumn = dt.div`
@@ -18372,7 +18411,7 @@ var StyledColumn = dt.div`
18372
18411
 
18373
18412
  // src/components/layout/column/Column.tsx
18374
18413
  import { jsx as jsx9 } from "react/jsx-runtime";
18375
- var Column = forwardRef3(
18414
+ var Column = forwardRef4(
18376
18415
  ({ children, basis, ...props }, ref) => {
18377
18416
  return /* @__PURE__ */ jsx9(StyledColumn, { ref, ...props, children: Children2.count(children) > 0 ? /* @__PURE__ */ jsx9(Card, { children }) : children });
18378
18417
  }
@@ -18380,7 +18419,7 @@ var Column = forwardRef3(
18380
18419
  Column.displayName = "Column";
18381
18420
 
18382
18421
  // src/components/layout/root/Root.tsx
18383
- import { forwardRef as forwardRef4 } from "react";
18422
+ import { forwardRef as forwardRef5 } from "react";
18384
18423
 
18385
18424
  // src/components/layout/root/styles.ts
18386
18425
  var Container2 = dt.div`
@@ -18392,6 +18431,7 @@ var Container2 = dt.div`
18392
18431
  width: 100%;
18393
18432
  height: 100%;
18394
18433
  container-type: inline-size;
18434
+ interpolate-size: allow-keywords;
18395
18435
 
18396
18436
  *,
18397
18437
  *::before,
@@ -18416,7 +18456,7 @@ var Container2 = dt.div`
18416
18456
 
18417
18457
  // src/components/layout/root/Root.tsx
18418
18458
  import { jsx as jsx10 } from "react/jsx-runtime";
18419
- var Root = forwardRef4(
18459
+ var Root = forwardRef5(
18420
18460
  ({ data, settings, ...props }, ref) => {
18421
18461
  return /* @__PURE__ */ jsx10(Container2, { ref, ...props });
18422
18462
  }
@@ -18425,27 +18465,27 @@ Root.displayName = "Root";
18425
18465
 
18426
18466
  // src/components/layout/viewport/Viewport.tsx
18427
18467
  var import_lodash3 = __toESM(require_lodash());
18428
- import { forwardRef as forwardRef5, useLayoutEffect as useLayoutEffect6, useState as useState12 } from "react";
18468
+ import { forwardRef as forwardRef6, useLayoutEffect as useLayoutEffect6, useState as useState13 } from "react";
18429
18469
  import { createPortal as createPortal2 } from "react-dom";
18430
18470
 
18431
18471
  // src/components/shared/checkout-dialog/CheckoutDialog.tsx
18432
18472
  import {
18433
- useCallback as useCallback8,
18473
+ useCallback as useCallback9,
18434
18474
  useEffect as useEffect4,
18435
18475
  useLayoutEffect as useLayoutEffect4,
18436
- useMemo as useMemo6,
18476
+ useMemo as useMemo7,
18437
18477
  useRef as useRef5,
18438
- useState as useState8
18478
+ useState as useState9
18439
18479
  } from "react";
18440
18480
 
18441
18481
  // src/components/shared/sidebar/Sidebar.tsx
18442
18482
  import {
18443
- useCallback as useCallback7,
18444
- useMemo as useMemo4
18483
+ useCallback as useCallback8,
18484
+ useMemo as useMemo5
18445
18485
  } from "react";
18446
18486
 
18447
18487
  // src/components/shared/sidebar/Proration.tsx
18448
- import { useState as useState5 } from "react";
18488
+ import { useState as useState6 } from "react";
18449
18489
  import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
18450
18490
  var Proration = ({
18451
18491
  currency,
@@ -18454,7 +18494,7 @@ var Proration = ({
18454
18494
  }) => {
18455
18495
  const { t: t2 } = useTranslation();
18456
18496
  const theme = nt();
18457
- const [open, setOpen] = useState5(false);
18497
+ const [open, setOpen] = useState6(false);
18458
18498
  const toggle = (e2) => {
18459
18499
  e2.preventDefault();
18460
18500
  e2.stopPropagation();
@@ -18510,21 +18550,29 @@ var Proration = ({
18510
18550
  children: t2("Total")
18511
18551
  }
18512
18552
  ),
18513
- /* @__PURE__ */ jsxs6(Button, { onClick: toggle, $variant: "text", children: [
18514
- /* @__PURE__ */ jsx11(Icon2, { name: open ? "chevron-up" : "chevron-down" }),
18515
- /* @__PURE__ */ jsx11(
18516
- Text,
18517
- {
18518
- $font: theme.typography.link.fontFamily,
18519
- $size: theme.typography.link.fontSize,
18520
- $weight: theme.typography.link.fontWeight,
18521
- $color: theme.typography.link.color,
18522
- $leading: 1,
18523
- style: { cursor: "pointer" },
18524
- children: open ? t2("Hide details") : t2("Show details")
18525
- }
18526
- )
18527
- ] })
18553
+ /* @__PURE__ */ jsxs6(
18554
+ Button,
18555
+ {
18556
+ onClick: toggle,
18557
+ style: { height: "auto", padding: 0 },
18558
+ $variant: "text",
18559
+ children: [
18560
+ /* @__PURE__ */ jsx11(Icon2, { name: open ? "chevron-up" : "chevron-down" }),
18561
+ /* @__PURE__ */ jsx11(
18562
+ Text,
18563
+ {
18564
+ $font: theme.typography.link.fontFamily,
18565
+ $size: theme.typography.link.fontSize,
18566
+ $weight: theme.typography.link.fontWeight,
18567
+ $color: theme.typography.link.color,
18568
+ $leading: 1,
18569
+ style: { cursor: "pointer" },
18570
+ children: open ? t2("Hide details") : t2("Show details")
18571
+ }
18572
+ )
18573
+ ]
18574
+ }
18575
+ )
18528
18576
  ] }),
18529
18577
  /* @__PURE__ */ jsx11(Flex, { children: /* @__PURE__ */ jsx11(
18530
18578
  Text,
@@ -18568,6 +18616,7 @@ var StageButton = ({
18568
18616
  disabled: isLoading || !hasUnstagedChanges || !canUpdateSubscription,
18569
18617
  onClick: checkout,
18570
18618
  $isLoading: isLoading,
18619
+ $fullWidth: true,
18571
18620
  children: t2("Subscribe and close")
18572
18621
  }
18573
18622
  );
@@ -18583,6 +18632,7 @@ var StageButton = ({
18583
18632
  setCheckoutStage?.("checkout");
18584
18633
  },
18585
18634
  $isLoading: isLoading,
18635
+ $fullWidth: true,
18586
18636
  children: /* @__PURE__ */ jsxs7(
18587
18637
  Flex,
18588
18638
  {
@@ -18617,6 +18667,7 @@ var StageButton = ({
18617
18667
  );
18618
18668
  },
18619
18669
  $isLoading: isLoading,
18670
+ $fullWidth: true,
18620
18671
  children: /* @__PURE__ */ jsxs7(Flex, { $gap: "0.5rem", $justifyContent: "center", $alignItems: "center", children: [
18621
18672
  t2("Next"),
18622
18673
  ":",
@@ -18640,6 +18691,7 @@ var StageButton = ({
18640
18691
  setCheckoutStage?.(hasAddOns ? "addons" : "checkout");
18641
18692
  },
18642
18693
  $isLoading: isLoading,
18694
+ $fullWidth: true,
18643
18695
  children: /* @__PURE__ */ jsxs7(
18644
18696
  Flex,
18645
18697
  {
@@ -18671,6 +18723,7 @@ var StageButton = ({
18671
18723
  setCheckoutStage?.("checkout");
18672
18724
  },
18673
18725
  $isLoading: isLoading,
18726
+ $fullWidth: true,
18674
18727
  children: /* @__PURE__ */ jsxs7(
18675
18728
  Flex,
18676
18729
  {
@@ -18700,6 +18753,7 @@ var StageButton = ({
18700
18753
  disabled: isLoading || !hasUnstagedChanges || !canCheckout,
18701
18754
  onClick: checkout,
18702
18755
  $isLoading: isLoading,
18756
+ $fullWidth: true,
18703
18757
  children: willTrial ? t2("Start trial") : t2("Pay now")
18704
18758
  }
18705
18759
  );
@@ -18735,7 +18789,7 @@ var Sidebar = ({
18735
18789
  const isLightBackground = useIsLightBackground();
18736
18790
  const currentPlan = data.company?.plan;
18737
18791
  const currentAddOns = data.company?.addOns || [];
18738
- const currentUsageBasedEntitlements = useMemo4(() => {
18792
+ const currentUsageBasedEntitlements = useMemo5(() => {
18739
18793
  return (data.featureUsage?.features || []).reduce(
18740
18794
  (acc, entitlement) => {
18741
18795
  if (entitlement.priceBehavior && (planPeriod === "month" && entitlement.monthlyUsageBasedPrice || planPeriod === "year" && entitlement.yearlyUsageBasedPrice)) {
@@ -18753,7 +18807,7 @@ var Sidebar = ({
18753
18807
  []
18754
18808
  );
18755
18809
  }, [data.featureUsage?.features, planPeriod]);
18756
- const { payAsYouGoEntitlements, payInAdvanceEntitlements } = useMemo4(() => {
18810
+ const { payAsYouGoEntitlements, payInAdvanceEntitlements } = useMemo5(() => {
18757
18811
  const payAsYouGoEntitlements2 = [];
18758
18812
  const payInAdvanceEntitlements2 = usageBasedEntitlements.filter(
18759
18813
  (entitlement) => {
@@ -18765,7 +18819,7 @@ var Sidebar = ({
18765
18819
  );
18766
18820
  return { payAsYouGoEntitlements: payAsYouGoEntitlements2, payInAdvanceEntitlements: payInAdvanceEntitlements2 };
18767
18821
  }, [usageBasedEntitlements]);
18768
- const subscriptionPrice = useMemo4(() => {
18822
+ const subscriptionPrice = useMemo5(() => {
18769
18823
  let planPrice;
18770
18824
  let currency;
18771
18825
  if (selectedPlan) {
@@ -18799,7 +18853,7 @@ var Sidebar = ({
18799
18853
  total += payInAdvanceCost;
18800
18854
  return formatCurrency(total, currency);
18801
18855
  }, [selectedPlan, currentPlan, planPeriod, addOns, payInAdvanceEntitlements]);
18802
- const { amountOff, dueNow, newCharges, percentOff, periodStart, proration } = useMemo4(() => {
18856
+ const { amountOff, dueNow, newCharges, percentOff, periodStart, proration } = useMemo5(() => {
18803
18857
  return {
18804
18858
  amountOff: charges?.amountOff ?? 0,
18805
18859
  dueNow: charges?.dueNow ?? 0,
@@ -18816,7 +18870,7 @@ var Sidebar = ({
18816
18870
  });
18817
18871
  window.dispatchEvent(event);
18818
18872
  };
18819
- const checkout = useCallback7(async () => {
18873
+ const checkout = useCallback8(async () => {
18820
18874
  const priceId = (planPeriod === "year" ? selectedPlan?.yearlyPrice : selectedPlan?.monthlyPrice)?.id;
18821
18875
  if (!api || !selectedPlan || !priceId) {
18822
18876
  return;
@@ -18883,7 +18937,7 @@ var Sidebar = ({
18883
18937
  payInAdvanceEntitlements,
18884
18938
  promoCode
18885
18939
  ]);
18886
- const unsubscribe = useCallback7(async () => {
18940
+ const unsubscribe = useCallback8(async () => {
18887
18941
  if (!api) {
18888
18942
  return;
18889
18943
  }
@@ -18907,7 +18961,7 @@ var Sidebar = ({
18907
18961
  addedUsageBasedEntitlements,
18908
18962
  removedUsageBasedEntitlements,
18909
18963
  willUsageBasedEntitlementsChange
18910
- } = useMemo4(() => {
18964
+ } = useMemo5(() => {
18911
18965
  const changedUsageBasedEntitlements2 = [];
18912
18966
  const addedUsageBasedEntitlements2 = selectedPlan ? usageBasedEntitlements.reduce(
18913
18967
  (acc, selected) => {
@@ -18971,7 +19025,7 @@ var Sidebar = ({
18971
19025
  const hasUnstagedChanges = willPeriodChange || willPlanChange || willAddOnsChange || willPayInAdvanceEntitlementsChange;
18972
19026
  const canUpdateSubscription = mode === "edit" || api !== null && !isLoading;
18973
19027
  const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
18974
- const isTrialable = selectedPlan?.companyCanTrial === true;
19028
+ const isTrialable = selectedPlan?.companyCanTrial === true && selectedPlan?.isTrialable === true;
18975
19029
  const today = /* @__PURE__ */ new Date();
18976
19030
  const trialEndsOn = new Date(today);
18977
19031
  if (isTrialable && selectedPlan.trialDays) {
@@ -19865,7 +19919,7 @@ var Sidebar = ({
19865
19919
  willTrial
19866
19920
  }
19867
19921
  ),
19868
- layout === "unsubscribe" && /* @__PURE__ */ jsx13(Button, { onClick: unsubscribe, $isLoading: isLoading, children: t2("Cancel subscription") }),
19922
+ layout === "unsubscribe" && /* @__PURE__ */ jsx13(Button, { onClick: unsubscribe, $isLoading: isLoading, $fullWidth: true, children: t2("Cancel subscription") }),
19869
19923
  !isLoading && error && /* @__PURE__ */ jsx13(Box, { children: /* @__PURE__ */ jsx13(
19870
19924
  Text,
19871
19925
  {
@@ -20002,6 +20056,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
20002
20056
  $size: "sm",
20003
20057
  $color: "primary",
20004
20058
  $variant: "outline",
20059
+ $fullWidth: true,
20005
20060
  children: t2("Choose add-on")
20006
20061
  }
20007
20062
  ) : /* @__PURE__ */ jsx14(
@@ -20013,6 +20068,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
20013
20068
  $size: "sm",
20014
20069
  $color: addOn.current ? "danger" : "primary",
20015
20070
  $variant: addOn.current ? "ghost" : "text",
20071
+ $fullWidth: true,
20016
20072
  children: addOn.current ? t2("Remove add-on") : /* @__PURE__ */ jsxs9(Fragment5, { children: [
20017
20073
  /* @__PURE__ */ jsx14(
20018
20074
  Icon2,
@@ -20038,7 +20094,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
20038
20094
  };
20039
20095
 
20040
20096
  // src/components/shared/checkout-dialog/Checkout.tsx
20041
- import { useState as useState6 } from "react";
20097
+ import { useState as useState7 } from "react";
20042
20098
  import { Fragment as Fragment6, jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
20043
20099
  var Checkout = ({
20044
20100
  requiresPayment,
@@ -20048,7 +20104,7 @@ var Checkout = ({
20048
20104
  const { t: t2 } = useTranslation();
20049
20105
  const theme = nt();
20050
20106
  const isLightBackground = useIsLightBackground();
20051
- const [discount, setDiscount] = useState6("");
20107
+ const [discount, setDiscount] = useState7("");
20052
20108
  if (!requiresPayment) {
20053
20109
  return null;
20054
20110
  }
@@ -20216,7 +20272,7 @@ var Navigation = ({
20216
20272
  };
20217
20273
 
20218
20274
  // src/components/shared/checkout-dialog/Plan.tsx
20219
- import { useMemo as useMemo5, useState as useState7 } from "react";
20275
+ import { useMemo as useMemo6, useState as useState8 } from "react";
20220
20276
 
20221
20277
  // src/components/elements/pricing-table/styles.ts
20222
20278
  var ButtonLink = dt.a`
@@ -20232,7 +20288,7 @@ import { Fragment as Fragment8, jsx as jsx17, jsxs as jsxs12 } from "react/jsx-r
20232
20288
  var Selected = ({ isCurrent = false, isTrial = false }) => {
20233
20289
  const { t: t2 } = useTranslation();
20234
20290
  const theme = nt();
20235
- const text = useMemo5(() => {
20291
+ const text = useMemo6(() => {
20236
20292
  if (isCurrent) {
20237
20293
  return isTrial ? t2("Trial in progress") : t2("Current plan");
20238
20294
  }
@@ -20282,15 +20338,9 @@ var PlanButtonGroup = ({
20282
20338
  const { t: t2 } = useTranslation();
20283
20339
  const { data } = useEmbed();
20284
20340
  const isCurrent = plan.id === data.company?.plan?.id;
20285
- if (plan.companyCanTrial) {
20341
+ if (plan.companyCanTrial && plan.isTrialable) {
20286
20342
  return /* @__PURE__ */ jsxs12(Flex, { $flexDirection: "column", $gap: "1.5rem", children: [
20287
- data.subscription?.status !== "trialing" && /* @__PURE__ */ jsx17(Fragment8, { children: isSelected && willTrial ? /* @__PURE__ */ jsx17(
20288
- Selected,
20289
- {
20290
- isCurrent,
20291
- isTrial: plan.companyCanTrial && willTrial
20292
- }
20293
- ) : /* @__PURE__ */ jsx17(
20343
+ data.subscription?.status !== "trialing" && /* @__PURE__ */ jsx17(Fragment8, { children: isSelected && willTrial ? /* @__PURE__ */ jsx17(Selected, { isCurrent, isTrial: willTrial }) : /* @__PURE__ */ jsx17(
20294
20344
  Button,
20295
20345
  {
20296
20346
  type: "button",
@@ -20306,6 +20356,7 @@ var PlanButtonGroup = ({
20306
20356
  $size: "sm",
20307
20357
  $color: "primary",
20308
20358
  $variant: "filled",
20359
+ $fullWidth: true,
20309
20360
  children: plan.custom ? /* @__PURE__ */ jsx17(
20310
20361
  ButtonLink,
20311
20362
  {
@@ -20316,8 +20367,8 @@ var PlanButtonGroup = ({
20316
20367
  ) : !plan.valid ? /* @__PURE__ */ jsx17(
20317
20368
  Tooltip,
20318
20369
  {
20319
- trigger: t2("Over usage limit"),
20320
- content: t2("Current usage exceeds the limit of this plan.")
20370
+ trigger: /* @__PURE__ */ jsx17(Text, { children: t2("Over usage limit") }),
20371
+ content: /* @__PURE__ */ jsx17(Text, { children: t2("Current usage exceeds the limit of this plan.") })
20321
20372
  }
20322
20373
  ) : t2("Start X day trial", { days: plan.trialDays })
20323
20374
  }
@@ -20333,11 +20384,12 @@ var PlanButtonGroup = ({
20333
20384
  $size: "sm",
20334
20385
  $color: "primary",
20335
20386
  $variant: data.subscription?.status === "trialing" ? "filled" : "text",
20387
+ $fullWidth: true,
20336
20388
  children: !plan.valid ? /* @__PURE__ */ jsx17(
20337
20389
  Tooltip,
20338
20390
  {
20339
- trigger: t2("Over usage limit"),
20340
- content: t2("Current usage exceeds the limit of this plan.")
20391
+ trigger: /* @__PURE__ */ jsx17(Text, { children: t2("Over usage limit") }),
20392
+ content: /* @__PURE__ */ jsx17(Text, { children: t2("Current usage exceeds the limit of this plan.") })
20341
20393
  }
20342
20394
  ) : t2("Choose plan")
20343
20395
  }
@@ -20357,6 +20409,7 @@ var PlanButtonGroup = ({
20357
20409
  $size: "sm",
20358
20410
  $color: "primary",
20359
20411
  $variant: "filled",
20412
+ $fullWidth: true,
20360
20413
  children: plan.custom ? /* @__PURE__ */ jsx17(
20361
20414
  ButtonLink,
20362
20415
  {
@@ -20367,8 +20420,8 @@ var PlanButtonGroup = ({
20367
20420
  ) : !plan.valid ? /* @__PURE__ */ jsx17(
20368
20421
  Tooltip,
20369
20422
  {
20370
- trigger: t2("Over usage limit"),
20371
- content: t2("Current usage exceeds the limit of this plan.")
20423
+ trigger: /* @__PURE__ */ jsx17(Text, { children: t2("Over usage limit") }),
20424
+ content: /* @__PURE__ */ jsx17(Text, { children: t2("Current usage exceeds the limit of this plan.") })
20372
20425
  }
20373
20426
  ) : t2("Choose plan")
20374
20427
  }
@@ -20386,7 +20439,7 @@ var Plan = ({
20386
20439
  const theme = nt();
20387
20440
  const { data } = useEmbed();
20388
20441
  const isLightBackground = useIsLightBackground();
20389
- const [entitlementCounts, setEntitlementCounts] = useState7(
20442
+ const [entitlementCounts, setEntitlementCounts] = useState8(
20390
20443
  () => plans.reduce(
20391
20444
  (acc, plan) => {
20392
20445
  acc[plan.id] = {
@@ -20950,13 +21003,13 @@ var CheckoutDialog = ({ top = 0 }) => {
20950
21003
  const modalRef = useRef5(null);
20951
21004
  const contentRef = useRef5(null);
20952
21005
  const checkoutRef = useRef5(null);
20953
- const [charges, setCharges] = useState8();
20954
- const [paymentMethodId, setPaymentMethodId] = useState8(
21006
+ const [charges, setCharges] = useState9();
21007
+ const [paymentMethodId, setPaymentMethodId] = useState9(
20955
21008
  (data.subscription?.paymentMethod || data.company?.defaultPaymentMethod)?.externalId
20956
21009
  );
20957
- const [isLoading, setIsLoading] = useState8(false);
20958
- const [error, setError] = useState8();
20959
- const [planPeriod, setPlanPeriod] = useState8(
21010
+ const [isLoading, setIsLoading] = useState9(false);
21011
+ const [error, setError] = useState9();
21012
+ const [planPeriod, setPlanPeriod] = useState9(
20960
21013
  selected.period || data.company?.plan?.planPeriod || "month"
20961
21014
  );
20962
21015
  const {
@@ -20964,15 +21017,13 @@ var CheckoutDialog = ({ top = 0 }) => {
20964
21017
  addOns: availableAddOns,
20965
21018
  periods: availablePeriods
20966
21019
  } = useAvailablePlans(planPeriod);
20967
- const [selectedPlan, setSelectedPlan] = useState8(
21020
+ const [selectedPlan, setSelectedPlan] = useState9(
20968
21021
  () => availablePlans.find(
20969
21022
  (plan) => selected.planId ? plan.id === selected.planId : plan.current
20970
21023
  )
20971
21024
  );
20972
- const [willTrial, setWillTrial] = useState8(
20973
- data.subscription?.status !== "trialing" && !data.trialPaymentMethodRequired
20974
- );
20975
- const [addOns, setAddOns] = useState8(
21025
+ const [willTrial, setWillTrial] = useState9(false);
21026
+ const [addOns, setAddOns] = useState9(
20976
21027
  () => availableAddOns.map((addOn) => ({
20977
21028
  ...addOn,
20978
21029
  isSelected: typeof selected.addOnId !== "undefined" ? addOn.id === selected.addOnId : (data.company?.addOns || []).some(
@@ -20981,10 +21032,10 @@ var CheckoutDialog = ({ top = 0 }) => {
20981
21032
  }))
20982
21033
  );
20983
21034
  const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected);
20984
- const currentEntitlements = useMemo6(() => {
21035
+ const currentEntitlements = useMemo7(() => {
20985
21036
  return data.featureUsage?.features || [];
20986
21037
  }, [data.featureUsage?.features]);
20987
- const [usageBasedEntitlements, setUsageBasedEntitlements] = useState8(
21038
+ const [usageBasedEntitlements, setUsageBasedEntitlements] = useState9(
20988
21039
  () => (selectedPlan?.entitlements || []).reduce(
20989
21040
  createActiveUsageBasedEntitlementsReducer(
20990
21041
  currentEntitlements,
@@ -20993,7 +21044,7 @@ var CheckoutDialog = ({ top = 0 }) => {
20993
21044
  []
20994
21045
  )
20995
21046
  );
20996
- const payInAdvanceEntitlements = useMemo6(
21047
+ const payInAdvanceEntitlements = useMemo7(
20997
21048
  () => usageBasedEntitlements.filter(
20998
21049
  (entitlement) => entitlement.priceBehavior === "pay_in_advance"
20999
21050
  ),
@@ -21002,12 +21053,12 @@ var CheckoutDialog = ({ top = 0 }) => {
21002
21053
  const hasActivePayInAdvanceEntitlements = payInAdvanceEntitlements.some(
21003
21054
  ({ quantity }) => quantity > 0
21004
21055
  );
21005
- const [promoCode, setPromoCode] = useState8();
21056
+ const [promoCode, setPromoCode] = useState9();
21006
21057
  const isTrialable = selectedPlan?.isTrialable === true && selectedPlan?.companyCanTrial === true;
21007
21058
  const isTrialableAndFree = isTrialable && data.trialPaymentMethodRequired !== true;
21008
21059
  const planRequiresPayment = !isTrialableAndFree || !isTrialable && selectedPlan?.isFree !== true;
21009
21060
  const requiresPayment = planRequiresPayment || hasActiveAddOns || hasActivePayInAdvanceEntitlements;
21010
- const checkoutStages = useMemo6(() => {
21061
+ const checkoutStages = useMemo7(() => {
21011
21062
  const stages = [
21012
21063
  {
21013
21064
  id: "plan",
@@ -21048,7 +21099,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21048
21099
  availableAddOns,
21049
21100
  requiresPayment
21050
21101
  ]);
21051
- const [checkoutStage, setCheckoutStage] = useState8(() => {
21102
+ const [checkoutStage, setCheckoutStage] = useState9(() => {
21052
21103
  if (selected.addOnId) {
21053
21104
  return "addons";
21054
21105
  }
@@ -21061,7 +21112,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21061
21112
  return "plan";
21062
21113
  });
21063
21114
  const isLightBackground = useIsLightBackground();
21064
- const previewCheckout = useCallback8(
21115
+ const previewCheckout = useCallback9(
21065
21116
  async (updates) => {
21066
21117
  const period = updates.period || planPeriod;
21067
21118
  const plan = updates.plan || selectedPlan;
@@ -21135,7 +21186,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21135
21186
  promoCode
21136
21187
  ]
21137
21188
  );
21138
- const selectPlan = useCallback8(
21189
+ const selectPlan = useCallback9(
21139
21190
  (updates) => {
21140
21191
  const plan = updates.plan || selectedPlan;
21141
21192
  if (!plan) {
@@ -21168,7 +21219,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21168
21219
  previewCheckout
21169
21220
  ]
21170
21221
  );
21171
- const changePlanPeriod = useCallback8(
21222
+ const changePlanPeriod = useCallback9(
21172
21223
  (period) => {
21173
21224
  setPlanPeriod(period);
21174
21225
  previewCheckout({ period });
@@ -21185,7 +21236,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21185
21236
  return updated;
21186
21237
  });
21187
21238
  };
21188
- const updateUsageBasedEntitlementQuantity = useCallback8(
21239
+ const updateUsageBasedEntitlementQuantity = useCallback9(
21189
21240
  (id, updatedQuantity) => {
21190
21241
  setUsageBasedEntitlements((prev2) => {
21191
21242
  const updated = prev2.map(
@@ -21455,7 +21506,7 @@ import {
21455
21506
  useElements,
21456
21507
  useStripe
21457
21508
  } from "@stripe/react-stripe-js";
21458
- import { useState as useState9 } from "react";
21509
+ import { useState as useState10 } from "react";
21459
21510
  import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
21460
21511
  var PaymentForm = ({ onConfirm }) => {
21461
21512
  const { t: t2 } = useTranslation();
@@ -21463,10 +21514,10 @@ var PaymentForm = ({ onConfirm }) => {
21463
21514
  const stripe = useStripe();
21464
21515
  const elements = useElements();
21465
21516
  const { api } = useEmbed();
21466
- const [message, setMessage] = useState9(null);
21467
- const [isLoading, setIsLoading] = useState9(false);
21468
- const [isConfirmed, setIsConfirmed] = useState9(false);
21469
- const [isComplete, setIsComplete] = useState9(false);
21517
+ const [message, setMessage] = useState10(null);
21518
+ const [isLoading, setIsLoading] = useState10(false);
21519
+ const [isConfirmed, setIsConfirmed] = useState10(false);
21520
+ const [isComplete, setIsComplete] = useState10(false);
21470
21521
  const handleSubmit = async (event) => {
21471
21522
  event.preventDefault();
21472
21523
  if (!api || !stripe || !elements) {
@@ -21526,6 +21577,7 @@ var PaymentForm = ({ onConfirm }) => {
21526
21577
  style: { flexShrink: 0 },
21527
21578
  $color: "primary",
21528
21579
  $isLoading: isLoading,
21580
+ $fullWidth: true,
21529
21581
  children: isLoading ? t2("Loading") : t2("Save payment method")
21530
21582
  }
21531
21583
  ),
@@ -21546,7 +21598,7 @@ var PaymentForm = ({ onConfirm }) => {
21546
21598
  };
21547
21599
 
21548
21600
  // src/components/shared/period-toggle/PeriodToggle.tsx
21549
- import { useLayoutEffect as useLayoutEffect5, useMemo as useMemo7, useState as useState10 } from "react";
21601
+ import { useLayoutEffect as useLayoutEffect5, useMemo as useMemo8, useState as useState11 } from "react";
21550
21602
  import { jsx as jsx22 } from "react/jsx-runtime";
21551
21603
  var PeriodToggle = ({
21552
21604
  options: options2,
@@ -21558,8 +21610,8 @@ var PeriodToggle = ({
21558
21610
  const { t: t2 } = useTranslation();
21559
21611
  const theme = nt();
21560
21612
  const isLightBackground = useIsLightBackground();
21561
- const [tooltipZIndex, setTooltipZIndex] = useState10(1);
21562
- const savingsPercentage = useMemo7(() => {
21613
+ const [tooltipZIndex, setTooltipZIndex] = useState11(1);
21614
+ const savingsPercentage = useMemo8(() => {
21563
21615
  if (selectedPlan) {
21564
21616
  const monthlyBillingPrice = getBillingPrice(selectedPlan?.monthlyPrice);
21565
21617
  const yearlyBillingPrice = getBillingPrice(selectedPlan?.yearlyPrice);
@@ -21659,21 +21711,21 @@ var PeriodToggle = ({
21659
21711
  };
21660
21712
 
21661
21713
  // src/components/shared/unsubscribe-dialog/UnsubscribeDialog.tsx
21662
- import { useCallback as useCallback9, useMemo as useMemo8, useRef as useRef6, useState as useState11 } from "react";
21714
+ import { useCallback as useCallback10, useMemo as useMemo9, useRef as useRef6, useState as useState12 } from "react";
21663
21715
  import { jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
21664
21716
  var UnsubscribeDialog = ({ top = 0 }) => {
21665
21717
  const { t: t2 } = useTranslation();
21666
21718
  const theme = nt();
21667
21719
  const { data, setLayout, setSelected } = useEmbed();
21668
21720
  const contentRef = useRef6(null);
21669
- const [error, setError] = useState11();
21670
- const [isLoading, setIsLoading] = useState11(false);
21671
- const planPeriod = useMemo8(
21721
+ const [error, setError] = useState12();
21722
+ const [isLoading, setIsLoading] = useState12(false);
21723
+ const planPeriod = useMemo9(
21672
21724
  () => data.company?.plan?.planPeriod ?? "month",
21673
21725
  [data.company?.plan?.planPeriod]
21674
21726
  );
21675
21727
  const { plans: availablePlans, addOns: availableAddOns } = useAvailablePlans(planPeriod);
21676
- const selectedPlan = useMemo8(
21728
+ const selectedPlan = useMemo9(
21677
21729
  () => availablePlans.find(
21678
21730
  (plan) => plan.id === data.company?.plan?.id && data.company?.plan.planPeriod === planPeriod
21679
21731
  ),
@@ -21684,7 +21736,7 @@ var UnsubscribeDialog = ({ top = 0 }) => {
21684
21736
  createActiveUsageBasedEntitlementsReducer(currentEntitlements, planPeriod),
21685
21737
  []
21686
21738
  );
21687
- const addOns = useMemo8(
21739
+ const addOns = useMemo9(
21688
21740
  () => availableAddOns.map((available) => ({
21689
21741
  ...available,
21690
21742
  isSelected: data.company?.addOns.some((current) => available.id === current.id) ?? false
@@ -21695,7 +21747,7 @@ var UnsubscribeDialog = ({ top = 0 }) => {
21695
21747
  data.subscription?.cancelAt || data.upcomingInvoice?.dueDate || Date.now()
21696
21748
  );
21697
21749
  const isLightBackground = useIsLightBackground();
21698
- const handleClose = useCallback9(() => {
21750
+ const handleClose = useCallback10(() => {
21699
21751
  setLayout("portal");
21700
21752
  }, [setLayout]);
21701
21753
  return /* @__PURE__ */ jsxs17(
@@ -21808,7 +21860,6 @@ var UnsubscribeDialog = ({ top = 0 }) => {
21808
21860
  $size: "sm",
21809
21861
  $color: "secondary",
21810
21862
  $variant: "ghost",
21811
- $fullWidth: false,
21812
21863
  children: t2("Manage plan")
21813
21864
  }
21814
21865
  )
@@ -22023,10 +22074,10 @@ var StyledViewport = dt.div.withConfig({
22023
22074
 
22024
22075
  // src/components/layout/viewport/Viewport.tsx
22025
22076
  import { Fragment as Fragment10, jsx as jsx26, jsxs as jsxs20 } from "react/jsx-runtime";
22026
- var Viewport = forwardRef5(
22077
+ var Viewport = forwardRef6(
22027
22078
  ({ children, portal, ...props }, ref) => {
22028
22079
  const { data, layout, settings } = useEmbed();
22029
- const [top, setTop] = useState12(0);
22080
+ const [top, setTop] = useState13(0);
22030
22081
  const canCheckout = data.capabilities?.checkout ?? true;
22031
22082
  useLayoutEffect6(() => {
22032
22083
  const parent = portal || document.body;
@@ -22075,7 +22126,7 @@ var resolveDesignProps = (props) => {
22075
22126
  }
22076
22127
  };
22077
22128
  };
22078
- var ButtonElement = forwardRef6(({ children, className, ...rest }, ref) => {
22129
+ var ButtonElement = forwardRef7(({ children, className, ...rest }, ref) => {
22079
22130
  const props = resolveDesignProps(rest);
22080
22131
  const buttonStyles = {
22081
22132
  primary: {
@@ -22120,10 +22171,10 @@ var ButtonElement = forwardRef6(({ children, className, ...rest }, ref) => {
22120
22171
  ButtonElement.displayName = "Button";
22121
22172
 
22122
22173
  // src/components/elements/included-features/IncludedFeatures.tsx
22123
- import { forwardRef as forwardRef7, useMemo as useMemo10, useRef as useRef7, useState as useState13 } from "react";
22174
+ import { forwardRef as forwardRef8, useMemo as useMemo11, useRef as useRef7, useState as useState14 } from "react";
22124
22175
 
22125
22176
  // src/components/elements/included-features/Details.tsx
22126
- import { Fragment as Fragment11, useMemo as useMemo9 } from "react";
22177
+ import { Fragment as Fragment11, useMemo as useMemo10 } from "react";
22127
22178
  import { Fragment as Fragment12, jsx as jsx28, jsxs as jsxs21 } from "react/jsx-runtime";
22128
22179
  var Details = ({
22129
22180
  shouldWrapChildren,
@@ -22148,7 +22199,7 @@ var Details = ({
22148
22199
  priceTier,
22149
22200
  currency,
22150
22201
  packageSize = 1
22151
- } = useMemo9(() => {
22202
+ } = useMemo10(() => {
22152
22203
  const {
22153
22204
  price: entitlementPrice,
22154
22205
  priceDecimal: entitlementPriceDecimal,
@@ -22170,7 +22221,7 @@ var Details = ({
22170
22221
  monthlyUsageBasedPrice,
22171
22222
  yearlyUsageBasedPrice
22172
22223
  ]);
22173
- const text = useMemo9(() => {
22224
+ const text = useMemo10(() => {
22174
22225
  if (!feature) {
22175
22226
  return;
22176
22227
  }
@@ -22221,7 +22272,7 @@ var Details = ({
22221
22272
  packageSize,
22222
22273
  softLimit
22223
22274
  ]);
22224
- const usageText = useMemo9(() => {
22275
+ const usageText = useMemo10(() => {
22225
22276
  if (!feature) {
22226
22277
  return;
22227
22278
  }
@@ -22389,7 +22440,7 @@ function resolveDesignProps2(props) {
22389
22440
  visibleFeatures: props.visibleFeatures
22390
22441
  };
22391
22442
  }
22392
- var IncludedFeatures = forwardRef7(({ className, ...rest }, ref) => {
22443
+ var IncludedFeatures = forwardRef8(({ className, ...rest }, ref) => {
22393
22444
  const props = resolveDesignProps2(rest);
22394
22445
  const { t: t2 } = useTranslation();
22395
22446
  const theme = nt();
@@ -22397,8 +22448,8 @@ var IncludedFeatures = forwardRef7(({ className, ...rest }, ref) => {
22397
22448
  const elements = useRef7([]);
22398
22449
  const shouldWrapChildren = useWrapChildren(elements.current);
22399
22450
  const isLightBackground = useIsLightBackground();
22400
- const [showCount, setShowCount] = useState13(VISIBLE_ENTITLEMENT_COUNT);
22401
- const featureUsage = useMemo10(() => {
22451
+ const [showCount, setShowCount] = useState14(VISIBLE_ENTITLEMENT_COUNT);
22452
+ const featureUsage = useMemo11(() => {
22402
22453
  const orderedFeatureUsage = props.visibleFeatures?.reduce(
22403
22454
  (acc, id) => {
22404
22455
  const mappedFeatureUsage = data.featureUsage?.features.find(
@@ -22556,7 +22607,7 @@ var IncludedFeatures = forwardRef7(({ className, ...rest }, ref) => {
22556
22607
  IncludedFeatures.displayName = "IncludedFeatures";
22557
22608
 
22558
22609
  // src/components/elements/invoices/Invoices.tsx
22559
- import { forwardRef as forwardRef8, useEffect as useEffect5, useState as useState14 } from "react";
22610
+ import { forwardRef as forwardRef9, useEffect as useEffect5, useState as useState15 } from "react";
22560
22611
  import { Fragment as Fragment13, jsx as jsx30, jsxs as jsxs23 } from "react/jsx-runtime";
22561
22612
  function resolveDesignProps3(props) {
22562
22613
  return {
@@ -22608,13 +22659,13 @@ var InvoiceDate = ({ date, fontStyle, url }) => {
22608
22659
  }
22609
22660
  return dateText;
22610
22661
  };
22611
- var Invoices = forwardRef8(({ className, data, ...rest }, ref) => {
22662
+ var Invoices = forwardRef9(({ className, data, ...rest }, ref) => {
22612
22663
  const props = resolveDesignProps3(rest);
22613
22664
  const { t: t2 } = useTranslation();
22614
22665
  const theme = nt();
22615
22666
  const { api } = useEmbed();
22616
- const [invoices, setInvoices] = useState14(() => formatInvoices(data));
22617
- const [listSize, setListSize] = useState14(props.limit.number);
22667
+ const [invoices, setInvoices] = useState15(() => formatInvoices(data));
22668
+ const [listSize, setListSize] = useState15(props.limit.number);
22618
22669
  const toggleListSize = () => {
22619
22670
  setListSize(
22620
22671
  (prev2) => prev2 !== props.limit.number ? props.limit.number : MAX_VISIBLE_INVOICE_COUNT
@@ -22688,7 +22739,7 @@ var Invoices = forwardRef8(({ className, data, ...rest }, ref) => {
22688
22739
  Invoices.displayName = "Invoices";
22689
22740
 
22690
22741
  // src/components/elements/metered-features/MeteredFeatures.tsx
22691
- import { forwardRef as forwardRef9, useMemo as useMemo11, useRef as useRef8 } from "react";
22742
+ import { forwardRef as forwardRef10, useMemo as useMemo12, useRef as useRef8 } from "react";
22692
22743
 
22693
22744
  // src/components/elements/metered-features/styles.ts
22694
22745
  var Container3 = dt.div`
@@ -22734,7 +22785,7 @@ function resolveDesignProps4(props) {
22734
22785
  visibleFeatures: props.visibleFeatures
22735
22786
  };
22736
22787
  }
22737
- var MeteredFeatures = forwardRef9(({ className, ...rest }, ref) => {
22788
+ var MeteredFeatures = forwardRef10(({ className, ...rest }, ref) => {
22738
22789
  const props = resolveDesignProps4(rest);
22739
22790
  const elements = useRef8([]);
22740
22791
  const shouldWrapChildren = useWrapChildren(elements.current);
@@ -22742,7 +22793,7 @@ var MeteredFeatures = forwardRef9(({ className, ...rest }, ref) => {
22742
22793
  const theme = nt();
22743
22794
  const { data, setLayout, setSelected } = useEmbed();
22744
22795
  const isLightBackground = useIsLightBackground();
22745
- const featureUsage = useMemo11(() => {
22796
+ const featureUsage = useMemo12(() => {
22746
22797
  const orderedFeatureUsage = props.visibleFeatures?.reduce(
22747
22798
  (acc, id) => {
22748
22799
  const mappedFeatureUsage = data.featureUsage?.features.find(
@@ -22928,7 +22979,7 @@ var MeteredFeatures = forwardRef9(({ className, ...rest }, ref) => {
22928
22979
  }
22929
22980
  ),
22930
22981
  props.isVisible && typeof usage === "number" && priceBehavior !== "pay_as_you_go" && /* @__PURE__ */ jsxs24(Flex, { $flexWrap: "wrap", $justifyContent: "end", $gap: "2rem", children: [
22931
- typeof allocation === "number" ? /* @__PURE__ */ jsx31(
22982
+ typeof allocation === "number" && progressBar ? /* @__PURE__ */ jsx31(
22932
22983
  Tooltip,
22933
22984
  {
22934
22985
  trigger: progressBar,
@@ -22956,7 +23007,6 @@ var MeteredFeatures = forwardRef9(({ className, ...rest }, ref) => {
22956
23007
  setSelected({ usage: true });
22957
23008
  setLayout("checkout");
22958
23009
  },
22959
- $fullWidth: false,
22960
23010
  style: { whiteSpace: "nowrap" },
22961
23011
  children: t2("Add More")
22962
23012
  }
@@ -23039,10 +23089,10 @@ var MeteredFeatures = forwardRef9(({ className, ...rest }, ref) => {
23039
23089
  MeteredFeatures.displayName = "MeteredFeatures";
23040
23090
 
23041
23091
  // src/components/elements/payment-method/PaymentMethod.tsx
23042
- import { forwardRef as forwardRef10, useMemo as useMemo13 } from "react";
23092
+ import { forwardRef as forwardRef11, useMemo as useMemo14 } from "react";
23043
23093
 
23044
23094
  // src/components/elements/payment-method/PaymentMethodElement.tsx
23045
- import { useMemo as useMemo12 } from "react";
23095
+ import { useMemo as useMemo13 } from "react";
23046
23096
  import { jsx as jsx32, jsxs as jsxs25 } from "react/jsx-runtime";
23047
23097
  var PaymentElement2 = ({
23048
23098
  iconName,
@@ -23217,7 +23267,7 @@ var PaymentListElement = ({
23217
23267
  const isLightBackground = useIsLightBackground();
23218
23268
  const { iconName, iconTitle, label, paymentLast4 } = getPaymentMethodData(paymentMethod);
23219
23269
  const iconStyles = getIconStyles({ size: "lg", theme });
23220
- const expirationDate = useMemo12(() => {
23270
+ const expirationDate = useMemo13(() => {
23221
23271
  const { cardExpMonth, cardExpYear } = paymentMethod;
23222
23272
  if (!cardExpMonth && !cardExpYear) {
23223
23273
  return "";
@@ -23329,13 +23379,13 @@ var resolveDesignProps5 = (props) => {
23329
23379
  }
23330
23380
  };
23331
23381
  };
23332
- var PaymentMethod = forwardRef10(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
23382
+ var PaymentMethod = forwardRef11(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
23333
23383
  const props = resolveDesignProps5(rest);
23334
23384
  const { data, setLayout } = useEmbed();
23335
- const paymentMethod = useMemo13(() => {
23385
+ const paymentMethod = useMemo14(() => {
23336
23386
  return data.subscription?.paymentMethod || data.company?.defaultPaymentMethod;
23337
23387
  }, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
23338
- const monthsToExpiration = useMemo13(() => {
23388
+ const monthsToExpiration = useMemo14(() => {
23339
23389
  let expiration;
23340
23390
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
23341
23391
  const today = /* @__PURE__ */ new Date();
@@ -23516,7 +23566,7 @@ var loadStripe = function loadStripe2() {
23516
23566
  };
23517
23567
 
23518
23568
  // src/components/elements/payment-method/PaymentMethodDetails.tsx
23519
- import { useCallback as useCallback10, useEffect as useEffect6, useMemo as useMemo14, useState as useState15 } from "react";
23569
+ import { useCallback as useCallback11, useEffect as useEffect6, useMemo as useMemo15, useState as useState16 } from "react";
23520
23570
  import { jsx as jsx34, jsxs as jsxs26 } from "react/jsx-runtime";
23521
23571
  var resolveDesignProps6 = () => {
23522
23572
  return {
@@ -23538,14 +23588,14 @@ var PaymentMethodDetails = ({
23538
23588
  const theme = nt();
23539
23589
  const { api, data, setData } = useEmbed();
23540
23590
  const isLightBackground = useIsLightBackground();
23541
- const [isLoading, setIsLoading] = useState15(false);
23542
- const [error, setError] = useState15();
23543
- const [showPaymentForm, setShowPaymentForm] = useState15(false);
23544
- const [stripe, setStripe] = useState15(null);
23545
- const [setupIntent, setSetupIntent] = useState15();
23546
- const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = useState15(false);
23547
- const [paymentMethod, setPaymentMethod] = useState15(data.subscription?.paymentMethod || data.company?.defaultPaymentMethod);
23548
- const monthsToExpiration = useMemo14(() => {
23591
+ const [isLoading, setIsLoading] = useState16(false);
23592
+ const [error, setError] = useState16();
23593
+ const [showPaymentForm, setShowPaymentForm] = useState16(false);
23594
+ const [stripe, setStripe] = useState16(null);
23595
+ const [setupIntent, setSetupIntent] = useState16();
23596
+ const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = useState16(false);
23597
+ const [paymentMethod, setPaymentMethod] = useState16(data.subscription?.paymentMethod || data.company?.defaultPaymentMethod);
23598
+ const monthsToExpiration = useMemo15(() => {
23549
23599
  let expiration;
23550
23600
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
23551
23601
  const today = /* @__PURE__ */ new Date();
@@ -23558,7 +23608,7 @@ var PaymentMethodDetails = ({
23558
23608
  }
23559
23609
  return expiration;
23560
23610
  }, [paymentMethod?.cardExpYear, paymentMethod?.cardExpMonth]);
23561
- const createSetupIntent = useCallback10(async () => {
23611
+ const createSetupIntent = useCallback11(async () => {
23562
23612
  if (!api || !data.component?.id) {
23563
23613
  return;
23564
23614
  }
@@ -23577,7 +23627,7 @@ var PaymentMethodDetails = ({
23577
23627
  setIsLoading(false);
23578
23628
  }
23579
23629
  }, [t2, api, data.component?.id]);
23580
- const updatePaymentMethod = useCallback10(
23630
+ const updatePaymentMethod = useCallback11(
23581
23631
  async (externalId) => {
23582
23632
  if (!api || !externalId) {
23583
23633
  return;
@@ -23626,7 +23676,7 @@ var PaymentMethodDetails = ({
23626
23676
  },
23627
23677
  [api, data, setData, setPaymentMethodId, t2]
23628
23678
  );
23629
- const deletePaymentMethod = useCallback10(
23679
+ const deletePaymentMethod = useCallback11(
23630
23680
  async (id) => {
23631
23681
  if (!api || !id) {
23632
23682
  return;
@@ -23795,7 +23845,7 @@ var PaymentMethodDetails = ({
23795
23845
  },
23796
23846
  paymentMethod2.id
23797
23847
  )) }),
23798
- (!setupIntent || !paymentMethod || showDifferentPaymentMethods) && /* @__PURE__ */ jsx34(Button, { onClick: createSetupIntent, $size: "lg", children: t2("Add new payment method") })
23848
+ (!setupIntent || !paymentMethod || showDifferentPaymentMethods) && /* @__PURE__ */ jsx34(Button, { onClick: createSetupIntent, $size: "lg", $fullWidth: true, children: t2("Add new payment method") })
23799
23849
  ] })
23800
23850
  ] }),
23801
23851
  !isLoading && error && /* @__PURE__ */ jsx34(Box, { children: /* @__PURE__ */ jsx34(
@@ -23815,7 +23865,7 @@ var PaymentMethodDetails = ({
23815
23865
  };
23816
23866
 
23817
23867
  // src/components/elements/plan-manager/PlanManager.tsx
23818
- import { forwardRef as forwardRef11, useMemo as useMemo15 } from "react";
23868
+ import { forwardRef as forwardRef12, useMemo as useMemo16 } from "react";
23819
23869
  import { Fragment as Fragment15, jsx as jsx35, jsxs as jsxs27 } from "react/jsx-runtime";
23820
23870
  var resolveDesignProps7 = (props) => {
23821
23871
  return {
@@ -23845,7 +23895,7 @@ var resolveDesignProps7 = (props) => {
23845
23895
  }
23846
23896
  };
23847
23897
  };
23848
- var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) => {
23898
+ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) => {
23849
23899
  const props = resolveDesignProps7(rest);
23850
23900
  const theme = nt();
23851
23901
  const { t: t2 } = useTranslation();
@@ -23871,7 +23921,7 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
23871
23921
  []
23872
23922
  );
23873
23923
  const billingSubscription = data.company?.billingSubscription;
23874
- const trialEndDays = useMemo15(() => {
23924
+ const trialEndDays = useMemo16(() => {
23875
23925
  const trialEnd = billingSubscription?.trialEnd;
23876
23926
  const trialEndDate = trialEnd ? new Date(trialEnd * 1e3) : /* @__PURE__ */ new Date();
23877
23927
  const todayDate = /* @__PURE__ */ new Date();
@@ -24143,6 +24193,7 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
24143
24193
  },
24144
24194
  $size: props.callToAction.buttonSize,
24145
24195
  $color: props.callToAction.buttonStyle,
24196
+ $fullWidth: true,
24146
24197
  children: t2("Change plan")
24147
24198
  }
24148
24199
  )
@@ -24154,7 +24205,7 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
24154
24205
  PlanManager.displayName = "PlanManager";
24155
24206
 
24156
24207
  // src/components/elements/pricing-table/PricingTable.tsx
24157
- import { forwardRef as forwardRef12, useState as useState16 } from "react";
24208
+ import { forwardRef as forwardRef13, useState as useState17 } from "react";
24158
24209
  import { Fragment as Fragment16, jsx as jsx36, jsxs as jsxs28 } from "react/jsx-runtime";
24159
24210
  var resolveDesignProps8 = (props) => {
24160
24211
  return {
@@ -24195,18 +24246,18 @@ var resolveDesignProps8 = (props) => {
24195
24246
  }
24196
24247
  };
24197
24248
  };
24198
- var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
24249
+ var PricingTable = forwardRef13(({ children, className, ...rest }, ref) => {
24199
24250
  const props = resolveDesignProps8(rest);
24200
24251
  const { t: t2 } = useTranslation();
24201
24252
  const theme = nt();
24202
24253
  const { data, setLayout, setSelected } = useEmbed();
24203
24254
  const trialEndDays = useTrialEnd();
24204
- const [selectedPeriod, setSelectedPeriod] = useState16(
24255
+ const [selectedPeriod, setSelectedPeriod] = useState17(
24205
24256
  () => data.company?.plan?.planPeriod || "month"
24206
24257
  );
24207
24258
  const { plans, addOns, periods } = useAvailablePlans(selectedPeriod);
24208
24259
  const isLightBackground = useIsLightBackground();
24209
- const [entitlementCounts, setEntitlementCounts] = useState16(
24260
+ const [entitlementCounts, setEntitlementCounts] = useState17(
24210
24261
  () => plans.reduce(
24211
24262
  (acc, plan) => {
24212
24263
  acc[plan.id] = {
@@ -24660,6 +24711,7 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
24660
24711
  $color: props.downgrade.buttonStyle,
24661
24712
  $variant: "outline"
24662
24713
  },
24714
+ $fullWidth: true,
24663
24715
  children: plan.custom ? /* @__PURE__ */ jsx36(
24664
24716
  ButtonLink,
24665
24717
  {
@@ -24670,12 +24722,12 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
24670
24722
  ) : !plan.valid ? /* @__PURE__ */ jsx36(
24671
24723
  Tooltip,
24672
24724
  {
24673
- trigger: t2("Over usage limit"),
24674
- content: t2(
24725
+ trigger: /* @__PURE__ */ jsx36(Text, { children: t2("Over usage limit") }),
24726
+ content: /* @__PURE__ */ jsx36(Text, { children: t2(
24675
24727
  "Current usage exceeds the limit of this plan."
24676
- )
24728
+ ) })
24677
24729
  }
24678
- ) : plan.companyCanTrial ? t2("Start X day trial", { days: plan.trialDays }) : t2("Choose plan")
24730
+ ) : plan.companyCanTrial && plan.isTrialable ? t2("Start X day trial", { days: plan.trialDays }) : t2("Choose plan")
24679
24731
  }
24680
24732
  )
24681
24733
  ]
@@ -24897,6 +24949,7 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
24897
24949
  $size: props.upgrade.buttonSize,
24898
24950
  $color: isActiveAddOn ? "danger" : props.upgrade.buttonStyle,
24899
24951
  $variant: isActiveAddOn ? "ghost" : addOn.current ? "outline" : "filled",
24952
+ $fullWidth: true,
24900
24953
  children: isActiveAddOn ? t2("Remove add-on") : addOn.current ? t2("Change add-on") : t2("Choose add-on")
24901
24954
  }
24902
24955
  )
@@ -24918,7 +24971,7 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
24918
24971
  PricingTable.displayName = "PricingTable";
24919
24972
 
24920
24973
  // src/components/elements/text/Text.tsx
24921
- import { forwardRef as forwardRef13 } from "react";
24974
+ import { forwardRef as forwardRef14 } from "react";
24922
24975
  import { jsx as jsx37 } from "react/jsx-runtime";
24923
24976
  var resolveDesignProps9 = (props) => {
24924
24977
  return {
@@ -24929,7 +24982,7 @@ var resolveDesignProps9 = (props) => {
24929
24982
  }
24930
24983
  };
24931
24984
  };
24932
- var TextElement = forwardRef13(({ children, className, ...rest }, ref) => {
24985
+ var TextElement = forwardRef14(({ children, className, ...rest }, ref) => {
24933
24986
  const props = resolveDesignProps9(rest);
24934
24987
  const theme = nt();
24935
24988
  return /* @__PURE__ */ jsx37(Element, { as: Flex, ref, className, children: /* @__PURE__ */ jsx37(
@@ -24948,7 +25001,7 @@ var TextElement = forwardRef13(({ children, className, ...rest }, ref) => {
24948
25001
  TextElement.displayName = "Text";
24949
25002
 
24950
25003
  // src/components/elements/unsubscribe-button/UnsubscribeButton.tsx
24951
- import { forwardRef as forwardRef14 } from "react";
25004
+ import { forwardRef as forwardRef15 } from "react";
24952
25005
  import { jsx as jsx38 } from "react/jsx-runtime";
24953
25006
  var resolveDesignProps10 = (props) => {
24954
25007
  return {
@@ -24961,7 +25014,7 @@ var resolveDesignProps10 = (props) => {
24961
25014
  }
24962
25015
  };
24963
25016
  };
24964
- var UnsubscribeButton = forwardRef14(({ children, className, ...rest }, ref) => {
25017
+ var UnsubscribeButton = forwardRef15(({ children, className, ...rest }, ref) => {
24965
25018
  const props = resolveDesignProps10(rest);
24966
25019
  const { t: t2 } = useTranslation();
24967
25020
  const { data, setLayout } = useEmbed();
@@ -25009,8 +25062,22 @@ var UnsubscribeButton = forwardRef14(({ children, className, ...rest }, ref) =>
25009
25062
  UnsubscribeButton.displayName = "UnsubscribeButton";
25010
25063
 
25011
25064
  // src/components/elements/upcoming-bill/UpcomingBill.tsx
25012
- import { forwardRef as forwardRef15, useMemo as useMemo16 } from "react";
25013
- import { Fragment as Fragment17, jsx as jsx39, jsxs as jsxs29 } from "react/jsx-runtime";
25065
+ import { forwardRef as forwardRef16, useCallback as useCallback12, useEffect as useEffect7, useMemo as useMemo17, useState as useState18 } from "react";
25066
+
25067
+ // src/components/elements/upcoming-bill/styles.ts
25068
+ var Container4 = dt.div`
25069
+ height: auto;
25070
+ opacity: 1;
25071
+ transition: 0.1s;
25072
+
25073
+ @starting-style {
25074
+ height: 0;
25075
+ opacity: 0;
25076
+ }
25077
+ `;
25078
+
25079
+ // src/components/elements/upcoming-bill/UpcomingBill.tsx
25080
+ import { jsx as jsx39, jsxs as jsxs29 } from "react/jsx-runtime";
25014
25081
  function resolveDesignProps11(props) {
25015
25082
  return {
25016
25083
  header: {
@@ -25029,136 +25096,176 @@ function resolveDesignProps11(props) {
25029
25096
  }
25030
25097
  };
25031
25098
  }
25032
- var UpcomingBill = forwardRef15(({ className, ...rest }, ref) => {
25099
+ var UpcomingBill = forwardRef16(({ className, ...rest }, ref) => {
25033
25100
  const props = resolveDesignProps11(rest);
25034
25101
  const { t: t2 } = useTranslation();
25035
25102
  const theme = nt();
25036
- const { data } = useEmbed();
25103
+ const { api, data } = useEmbed();
25037
25104
  const isLightBackground = useIsLightBackground();
25038
- const { discounts, upcomingInvoice } = useMemo16(() => {
25039
- const discounts2 = (data.subscription?.discounts || []).map((discount) => ({
25040
- amountOff: discount.amountOff,
25105
+ const [isLoading, setIsLoading] = useState18(false);
25106
+ const [error, setError] = useState18();
25107
+ const [upcomingInvoice, setUpcomingInvoice] = useState18();
25108
+ const discounts = useMemo17(() => {
25109
+ return (data.subscription?.discounts || []).map((discount) => ({
25041
25110
  couponId: discount.couponId,
25042
- customerFacingCode: discount.customerFacingCode,
25043
- isActive: discount.isActive,
25044
- percentOff: discount.percentOff
25111
+ customerFacingCode: discount.customerFacingCode || void 0,
25112
+ currency: discount.currency || void 0,
25113
+ amountOff: discount.amountOff ?? void 0,
25114
+ percentOff: discount.percentOff ?? void 0,
25115
+ isActive: discount.isActive
25045
25116
  }));
25046
- return {
25047
- discounts: discounts2,
25048
- upcomingInvoice: data.upcomingInvoice
25049
- };
25050
- }, [data.subscription, data.upcomingInvoice]);
25051
- return /* @__PURE__ */ jsx39(
25052
- Element,
25053
- {
25054
- as: Flex,
25055
- ref,
25056
- className,
25057
- $flexDirection: "column",
25058
- $gap: "1rem",
25059
- children: upcomingInvoice ? /* @__PURE__ */ jsxs29(Fragment17, { children: [
25060
- props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */ jsx39(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ jsxs29(
25061
- Text,
25062
- {
25063
- $font: theme.typography[props.header.fontStyle].fontFamily,
25064
- $size: theme.typography[props.header.fontStyle].fontSize,
25065
- $weight: theme.typography[props.header.fontStyle].fontWeight,
25066
- $color: theme.typography[props.header.fontStyle].color,
25067
- children: [
25068
- props.header.prefix,
25069
- " ",
25070
- toPrettyDate(upcomingInvoice.dueDate)
25071
- ]
25072
- }
25073
- ) }),
25074
- /* @__PURE__ */ jsxs29(Flex, { $justifyContent: "space-between", $alignItems: "start", $gap: "1rem", children: [
25075
- props.price.isVisible && /* @__PURE__ */ jsx39(Flex, { $alignItems: "end", $flexGrow: "1", children: /* @__PURE__ */ jsx39(
25076
- Text,
25077
- {
25078
- $font: theme.typography[props.price.fontStyle].fontFamily,
25079
- $size: theme.typography[props.price.fontStyle].fontSize,
25080
- $weight: theme.typography[props.price.fontStyle].fontWeight,
25081
- $color: theme.typography[props.price.fontStyle].color,
25082
- $leading: 1,
25083
- children: formatCurrency(
25084
- upcomingInvoice.amountDue,
25085
- upcomingInvoice.currency
25086
- )
25087
- }
25088
- ) }),
25089
- /* @__PURE__ */ jsx39(Box, { $lineHeight: 1.15, $maxWidth: "10rem", $textAlign: "right", children: /* @__PURE__ */ jsx39(
25090
- Text,
25091
- {
25092
- $font: theme.typography[props.contractEndDate.fontStyle].fontFamily,
25093
- $size: theme.typography[props.contractEndDate.fontStyle].fontSize,
25094
- $weight: theme.typography[props.contractEndDate.fontStyle].fontWeight,
25095
- $color: theme.typography[props.contractEndDate.fontStyle].color,
25096
- $leading: 1,
25097
- children: t2("Estimated bill.")
25098
- }
25099
- ) })
25100
- ] }),
25101
- discounts.length > 0 && /* @__PURE__ */ jsxs29(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
25102
- /* @__PURE__ */ jsx39(Box, { children: /* @__PURE__ */ jsx39(
25103
- Text,
25117
+ }, [data.subscription]);
25118
+ const loadInvoice = useCallback12(async () => {
25119
+ if (!api || !data.component?.id) {
25120
+ return;
25121
+ }
25122
+ try {
25123
+ setError(void 0);
25124
+ setIsLoading(true);
25125
+ const response = await api.hydrateUpcomingInvoice({
25126
+ componentId: data.component.id
25127
+ });
25128
+ setUpcomingInvoice(response.data);
25129
+ } catch (e2) {
25130
+ if (e2 instanceof Error) {
25131
+ setError(e2);
25132
+ }
25133
+ } finally {
25134
+ setIsLoading(false);
25135
+ }
25136
+ }, [api, data.component?.id]);
25137
+ useEffect7(() => {
25138
+ loadInvoice();
25139
+ }, [loadInvoice]);
25140
+ return /* @__PURE__ */ jsxs29(Element, { ref, className, children: [
25141
+ /* @__PURE__ */ jsx39(Flex, { as: Container4, $justifyContent: "center", $alignItems: "center", children: /* @__PURE__ */ jsx39(Loader, { $color: theme.primary, $isLoading: isLoading }) }),
25142
+ error ? /* @__PURE__ */ jsxs29(
25143
+ Flex,
25144
+ {
25145
+ as: Container4,
25146
+ $flexDirection: "column",
25147
+ $justifyContent: "center",
25148
+ $alignItems: "center",
25149
+ $gap: "1rem",
25150
+ children: [
25151
+ /* @__PURE__ */ jsx39(Text, { $weight: 500, $color: "#DB6669", children: t2("There was a problem retrieving your upcoming invoice.") }),
25152
+ /* @__PURE__ */ jsx39(
25153
+ Button,
25104
25154
  {
25105
- $font: theme.typography.text.fontFamily,
25106
- $size: theme.typography.text.fontSize,
25107
- $weight: 600,
25108
- $color: theme.typography.text.color,
25109
- children: t2("Discount")
25155
+ onClick: () => loadInvoice(),
25156
+ $size: "sm",
25157
+ $variant: "ghost",
25158
+ $fullWidth: false,
25159
+ children: t2("Try again")
25110
25160
  }
25111
- ) }),
25112
- /* @__PURE__ */ jsx39(Box, { children: discounts.map((discount) => /* @__PURE__ */ jsxs29(
25113
- Flex,
25114
- {
25115
- $alignItems: "center",
25116
- $gap: "0.5rem",
25117
- children: [
25118
- /* @__PURE__ */ jsx39(
25119
- Flex,
25120
- {
25121
- $alignItems: "center",
25122
- $padding: "0.1875rem 0.375rem",
25123
- $borderWidth: "1px",
25124
- $borderStyle: "solid",
25125
- $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.15)" : "hsla(0, 0%, 100%, 0.15)",
25126
- $borderRadius: "0.3125rem",
25127
- children: /* @__PURE__ */ jsx39(
25128
- Text,
25129
- {
25130
- $font: theme.typography.text.fontFamily,
25131
- $size: 0.75 * theme.typography.text.fontSize,
25132
- $weight: theme.typography.text.fontWeight,
25133
- $color: theme.typography.text.color,
25134
- children: discount.customerFacingCode
25135
- }
25136
- )
25137
- }
25138
- ),
25139
- /* @__PURE__ */ jsx39(Box, { children: /* @__PURE__ */ jsx39(
25140
- Text,
25141
- {
25142
- $font: theme.typography.text.fontFamily,
25143
- $size: theme.typography.text.fontSize,
25144
- $weight: theme.typography.text.fontWeight,
25145
- $color: theme.typography.text.color,
25146
- children: t2("Percent off", { percent: discount.percentOff })
25147
- }
25148
- ) })
25149
- ]
25150
- },
25151
- discount.couponId
25152
- )) })
25153
- ] })
25154
- ] }) : /* @__PURE__ */ jsx39(Text, { display: "heading2", children: t2("No upcoming invoice") })
25155
- }
25156
- );
25161
+ )
25162
+ ]
25163
+ }
25164
+ ) : !isLoading && /* @__PURE__ */ jsx39(Container4, { children: upcomingInvoice ? /* @__PURE__ */ jsxs29(Flex, { $flexDirection: "column", $gap: "1rem", children: [
25165
+ props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */ jsxs29(Text, { display: props.header.fontStyle, children: [
25166
+ props.header.prefix,
25167
+ " ",
25168
+ toPrettyDate(upcomingInvoice.dueDate)
25169
+ ] }),
25170
+ /* @__PURE__ */ jsxs29(
25171
+ Flex,
25172
+ {
25173
+ $justifyContent: "space-between",
25174
+ $alignItems: "start",
25175
+ $gap: "1rem",
25176
+ children: [
25177
+ props.price.isVisible && /* @__PURE__ */ jsx39(Text, { display: props.price.fontStyle, $leading: 1, children: formatCurrency(
25178
+ upcomingInvoice.amountDue,
25179
+ upcomingInvoice.currency
25180
+ ) }),
25181
+ /* @__PURE__ */ jsx39(Box, { $maxWidth: "10rem", $textAlign: "right", children: /* @__PURE__ */ jsx39(Text, { display: props.contractEndDate.fontStyle, children: t2("Estimated bill.") }) })
25182
+ ]
25183
+ }
25184
+ ),
25185
+ /* @__PURE__ */ jsxs29(
25186
+ Flex,
25187
+ {
25188
+ $justifyContent: "space-between",
25189
+ $alignItems: "center",
25190
+ $gap: "1rem",
25191
+ children: [
25192
+ /* @__PURE__ */ jsx39(Text, { $weight: 600, children: t2("Remaining balance") }),
25193
+ /* @__PURE__ */ jsx39(Text, { children: formatCurrency(5e3, upcomingInvoice.currency) })
25194
+ ]
25195
+ }
25196
+ ),
25197
+ discounts.length > 0 && /* @__PURE__ */ jsxs29(
25198
+ Flex,
25199
+ {
25200
+ $justifyContent: "space-between",
25201
+ $alignItems: "start",
25202
+ $gap: "1rem",
25203
+ children: [
25204
+ /* @__PURE__ */ jsx39(Text, { $weight: 600, children: t2("Discount") }),
25205
+ /* @__PURE__ */ jsx39(
25206
+ Flex,
25207
+ {
25208
+ $flexDirection: "column",
25209
+ $alignItems: "end",
25210
+ $gap: "0.5rem",
25211
+ children: discounts.reduce(
25212
+ (acc, discount) => {
25213
+ if (typeof discount.customerFacingCode === "string" && (typeof discount.percentOff === "number" || typeof discount.amountOff === "number")) {
25214
+ acc.push(
25215
+ /* @__PURE__ */ jsxs29(
25216
+ Flex,
25217
+ {
25218
+ $alignItems: "center",
25219
+ $gap: "0.5rem",
25220
+ children: [
25221
+ /* @__PURE__ */ jsx39(
25222
+ Flex,
25223
+ {
25224
+ $alignItems: "center",
25225
+ $padding: "0.1875rem 0.375rem",
25226
+ $borderWidth: "1px",
25227
+ $borderStyle: "solid",
25228
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.15)" : "hsla(0, 0%, 100%, 0.15)",
25229
+ $borderRadius: "0.3125rem",
25230
+ children: /* @__PURE__ */ jsx39(
25231
+ Text,
25232
+ {
25233
+ $size: 0.75 * theme.typography.text.fontSize,
25234
+ children: discount.customerFacingCode
25235
+ }
25236
+ )
25237
+ }
25238
+ ),
25239
+ /* @__PURE__ */ jsx39(Box, { children: /* @__PURE__ */ jsx39(Text, { children: typeof discount.percentOff === "number" ? t2("Percent off", {
25240
+ percent: discount.percentOff
25241
+ }) : t2("Amount off", {
25242
+ amount: formatCurrency(
25243
+ discount.amountOff,
25244
+ discount?.currency
25245
+ )
25246
+ }) }) })
25247
+ ]
25248
+ },
25249
+ discount.couponId
25250
+ )
25251
+ );
25252
+ }
25253
+ return acc;
25254
+ },
25255
+ []
25256
+ )
25257
+ }
25258
+ )
25259
+ ]
25260
+ }
25261
+ )
25262
+ ] }) : /* @__PURE__ */ jsx39(Text, { display: "heading2", children: t2("No upcoming invoice") }) })
25263
+ ] });
25157
25264
  });
25158
25265
  UpcomingBill.displayName = "UpcomingBill";
25159
25266
 
25160
25267
  // src/components/embed/ComponentTree.tsx
25161
- import { useEffect as useEffect7, useState as useState17 } from "react";
25268
+ import { useEffect as useEffect8, useState as useState19 } from "react";
25162
25269
 
25163
25270
  // src/components/embed/renderer.ts
25164
25271
  import { createElement as createElement5 } from "react";
@@ -25209,7 +25316,7 @@ function createRenderer(options2) {
25209
25316
  }
25210
25317
 
25211
25318
  // src/components/embed/ComponentTree.tsx
25212
- import { Fragment as Fragment18, jsx as jsx40, jsxs as jsxs30 } from "react/jsx-runtime";
25319
+ import { Fragment as Fragment17, jsx as jsx40, jsxs as jsxs30 } from "react/jsx-runtime";
25213
25320
  var Loading = () => {
25214
25321
  const theme = nt();
25215
25322
  return /* @__PURE__ */ jsx40(
@@ -25265,8 +25372,8 @@ var Error2 = ({ message }) => {
25265
25372
  };
25266
25373
  var ComponentTree = () => {
25267
25374
  const { error, nodes, isPending } = useEmbed();
25268
- const [children, setChildren] = useState17(/* @__PURE__ */ jsx40(Loading, {}));
25269
- useEffect7(() => {
25375
+ const [children, setChildren] = useState19(/* @__PURE__ */ jsx40(Loading, {}));
25376
+ useEffect8(() => {
25270
25377
  const renderer = createRenderer();
25271
25378
  setChildren(nodes.map(renderer));
25272
25379
  }, [nodes]);
@@ -25277,7 +25384,7 @@ var ComponentTree = () => {
25277
25384
  if (isPending) {
25278
25385
  return /* @__PURE__ */ jsx40(Loading, {});
25279
25386
  }
25280
- return /* @__PURE__ */ jsx40(Fragment18, { children });
25387
+ return /* @__PURE__ */ jsx40(Fragment17, { children });
25281
25388
  };
25282
25389
 
25283
25390
  // src/components/embed/Embed.tsx
@@ -25351,6 +25458,7 @@ export {
25351
25458
  useEmbed,
25352
25459
  useIsLightBackground,
25353
25460
  usePrevious2 as usePrevious,
25461
+ useRequest,
25354
25462
  useTrialEnd,
25355
25463
  useWrapChildren
25356
25464
  };