@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.
@@ -6028,16 +6028,17 @@ __export(index_exports, {
6028
6028
  useEmbed: () => useEmbed,
6029
6029
  useIsLightBackground: () => useIsLightBackground,
6030
6030
  usePrevious: () => usePrevious2,
6031
+ useRequest: () => useRequest,
6031
6032
  useTrialEnd: () => useTrialEnd,
6032
6033
  useWrapChildren: () => useWrapChildren
6033
6034
  });
6034
6035
  module.exports = __toCommonJS(index_exports);
6035
6036
 
6036
6037
  // src/components/elements/button/Button.tsx
6037
- var import_react31 = require("react");
6038
+ var import_react33 = require("react");
6038
6039
 
6039
6040
  // src/components/layout/card/Card.tsx
6040
- var import_react19 = require("react");
6041
+ var import_react21 = require("react");
6041
6042
 
6042
6043
  // node_modules/styled-components/node_modules/tslib/tslib.es6.mjs
6043
6044
  var __assign = function() {
@@ -16341,6 +16342,7 @@ var en_default = {
16341
16342
  "After the trial, cancel no default": "After the trial, you will be lose access to {{planName}} plan and your subscription will be cancelled.",
16342
16343
  "After the trial, cancel": "After the trial, you will be downgraded to the {{defaultPlanName}} plan and your subscription will be cancelled.",
16343
16344
  "After the trial, subscribe": "After the trial, subscription starts and you will be billed.",
16345
+ "Amount off": "{{amount}} off",
16344
16346
  Billed: "Billed {{period}}",
16345
16347
  "billing period": "billing period",
16346
16348
  "Cancel subscription": "Cancel subscription",
@@ -16422,11 +16424,13 @@ var en_default = {
16422
16424
  "Subscription canceled": "Subscription canceled",
16423
16425
  Subscription: "Subscription",
16424
16426
  "Talk to support": "Talk to support",
16427
+ "There was a problem retrieving your upcoming invoice.": "There was a problem retrieving your upcoming invoice.",
16425
16428
  Total: "Total",
16426
16429
  "Trial ends in": "Trial ends in {{days}} days",
16427
16430
  "Trial in progress": "Trial in progress",
16428
16431
  "Trial selected": "Trial selected",
16429
16432
  Trial: "Trial",
16433
+ "Try again": "Try again",
16430
16434
  Unlimited: "Unlimited {{item}}",
16431
16435
  "Unsubscribe failed": "Unsubscribe failed",
16432
16436
  Unsubscribe: "Unsubscribe",
@@ -17120,7 +17124,7 @@ var EmbedProvider = ({
17120
17124
  (0, import_react11.useEffect)(() => {
17121
17125
  if (accessToken) {
17122
17126
  const { headers = {} } = apiConfig ?? {};
17123
- headers["X-Schematic-Components-Version"] = "0.7.15";
17127
+ headers["X-Schematic-Components-Version"] = "0.7.16";
17124
17128
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
17125
17129
  const config = new Configuration({
17126
17130
  ...apiConfig,
@@ -17200,6 +17204,36 @@ function usePrevious2(value) {
17200
17204
  return ref.current;
17201
17205
  }
17202
17206
 
17207
+ // src/hooks/useRequest.ts
17208
+ var import_react15 = require("react");
17209
+ function useRequest(fn) {
17210
+ const [isLoading, setIsLoading] = (0, import_react15.useState)(false);
17211
+ const [error, setError] = (0, import_react15.useState)(null);
17212
+ const [data, setData] = (0, import_react15.useState)(void 0);
17213
+ const request = (0, import_react15.useCallback)(async () => {
17214
+ try {
17215
+ setError(null);
17216
+ setIsLoading(true);
17217
+ const response = await fn();
17218
+ if (!response) {
17219
+ return;
17220
+ }
17221
+ setData(response.data);
17222
+ } catch (e2) {
17223
+ if (e2 instanceof Error) {
17224
+ setError(e2);
17225
+ }
17226
+ } finally {
17227
+ setIsLoading(false);
17228
+ }
17229
+ }, [fn]);
17230
+ const value = (0, import_react15.useMemo)(() => {
17231
+ const state = { isLoading, error, data };
17232
+ return [state, request];
17233
+ }, [isLoading, error, data, request]);
17234
+ return value;
17235
+ }
17236
+
17203
17237
  // src/hooks/useTrialEnd.ts
17204
17238
  function useTrialEnd() {
17205
17239
  const { data } = useEmbed();
@@ -17215,12 +17249,12 @@ function useTrialEnd() {
17215
17249
  }
17216
17250
 
17217
17251
  // src/hooks/useWrapChildren.ts
17218
- var import_react15 = require("react");
17252
+ var import_react16 = require("react");
17219
17253
  function useWrapChildren(elements) {
17220
- const [shouldWrap, setShouldWrap] = (0, import_react15.useState)(
17254
+ const [shouldWrap, setShouldWrap] = (0, import_react16.useState)(
17221
17255
  () => new Array(elements.length).fill(false)
17222
17256
  );
17223
- (0, import_react15.useLayoutEffect)(() => {
17257
+ (0, import_react16.useLayoutEffect)(() => {
17224
17258
  const rowShouldWrap = (parent) => [...parent.children].some(
17225
17259
  (el) => el instanceof HTMLElement && el.previousElementSibling instanceof HTMLElement && el.offsetLeft <= el.previousElementSibling.offsetLeft
17226
17260
  );
@@ -17414,7 +17448,7 @@ var Button = dt.button(
17414
17448
  $isLoading = false,
17415
17449
  $alignment = "center",
17416
17450
  $selfAlignment = "center",
17417
- $fullWidth = true,
17451
+ $fullWidth = false,
17418
17452
  disabled,
17419
17453
  theme
17420
17454
  }) => {
@@ -17457,7 +17491,7 @@ var Button = dt.button(
17457
17491
  return lt`
17458
17492
  color: ${textColor};
17459
17493
 
17460
- ${Icon} {
17494
+ ${Text}, ${Icon} {
17461
17495
  color: ${textColor};
17462
17496
  }
17463
17497
  `;
@@ -17476,7 +17510,7 @@ var Button = dt.button(
17476
17510
  border-color: ${color};
17477
17511
  color: ${color};
17478
17512
 
17479
- ${Icon} {
17513
+ ${Text}, ${Icon} {
17480
17514
  color: ${color};
17481
17515
  }
17482
17516
  `;
@@ -17487,7 +17521,7 @@ var Button = dt.button(
17487
17521
  border-color: ${l2 > 50 ? darken(theme.card.background, 0.2) : lighten(theme.card.background, 0.2)};
17488
17522
  color: ${color};
17489
17523
 
17490
- ${Icon} {
17524
+ ${Text}, ${Icon} {
17491
17525
  color: ${color};
17492
17526
  }
17493
17527
  `;
@@ -17502,7 +17536,7 @@ var Button = dt.button(
17502
17536
  text-decoration: underline;
17503
17537
  }
17504
17538
 
17505
- ${Icon} {
17539
+ ${Text}, ${Icon} {
17506
17540
  color: ${color};
17507
17541
  }
17508
17542
  `;
@@ -17543,7 +17577,7 @@ var Button = dt.button(
17543
17577
  border-color: ${color};
17544
17578
  color: ${textColor};
17545
17579
 
17546
- ${Icon} {
17580
+ ${Text}, ${Icon} {
17547
17581
  color: ${textColor};
17548
17582
  }
17549
17583
  `;
@@ -17875,7 +17909,7 @@ var Input = dt.input(({ theme, $size = "md", $variant = "filled" }) => {
17875
17909
  });
17876
17910
 
17877
17911
  // src/components/ui/modal/Modal.tsx
17878
- var import_react16 = require("react");
17912
+ var import_react17 = require("react");
17879
17913
 
17880
17914
  // src/components/ui/modal/styles.ts
17881
17915
  var Modal = dt(Box).attrs({
@@ -17914,15 +17948,15 @@ var Modal = dt(Box).attrs({
17914
17948
 
17915
17949
  // src/components/ui/modal/Modal.tsx
17916
17950
  var import_jsx_runtime4 = require("react/jsx-runtime");
17917
- var Modal2 = (0, import_react16.forwardRef)(
17951
+ var Modal2 = (0, import_react17.forwardRef)(
17918
17952
  ({ children, contentRef, size = "auto", top = 0, onClose, ...rest }, ref) => {
17919
17953
  const { setLayout } = useEmbed();
17920
17954
  const isLightBackground = useIsLightBackground();
17921
- const handleClose = (0, import_react16.useCallback)(() => {
17955
+ const handleClose = (0, import_react17.useCallback)(() => {
17922
17956
  setLayout("portal");
17923
17957
  onClose?.();
17924
17958
  }, [setLayout, onClose]);
17925
- (0, import_react16.useLayoutEffect)(() => {
17959
+ (0, import_react17.useLayoutEffect)(() => {
17926
17960
  contentRef?.current?.focus({ preventScroll: true });
17927
17961
  }, [contentRef]);
17928
17962
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
@@ -17962,7 +17996,7 @@ var Modal2 = (0, import_react16.forwardRef)(
17962
17996
  Modal2.displayName = "Modal";
17963
17997
 
17964
17998
  // src/components/ui/modal/ModalHeader.tsx
17965
- var import_react17 = require("react");
17999
+ var import_react18 = require("react");
17966
18000
  var import_jsx_runtime5 = require("react/jsx-runtime");
17967
18001
  var ModalHeader = ({
17968
18002
  children,
@@ -17972,7 +18006,7 @@ var ModalHeader = ({
17972
18006
  const theme = nt();
17973
18007
  const { setLayout } = useEmbed();
17974
18008
  const isLightBackground = useIsLightBackground();
17975
- const handleClose = (0, import_react17.useCallback)(() => {
18009
+ const handleClose = (0, import_react18.useCallback)(() => {
17976
18010
  setLayout("portal");
17977
18011
  onClose?.();
17978
18012
  }, [setLayout, onClose]);
@@ -18020,6 +18054,7 @@ var ModalHeader = ({
18020
18054
  };
18021
18055
 
18022
18056
  // src/components/ui/progress-bar/ProgressBar.tsx
18057
+ var import_react19 = require("react");
18023
18058
  var import_jsx_runtime6 = require("react/jsx-runtime");
18024
18059
  var progressColorMap = [
18025
18060
  "blue",
@@ -18029,68 +18064,72 @@ var progressColorMap = [
18029
18064
  "red",
18030
18065
  "red"
18031
18066
  ];
18032
- var ProgressBar = ({
18033
- progress,
18034
- value,
18035
- total = 0,
18036
- color = "gray",
18037
- bgColor = "#F2F4F7",
18038
- ...props
18039
- }) => {
18040
- const theme = nt();
18041
- const barColorMap = {
18042
- gray: "#9CA3AF",
18043
- blue: "#2563EB",
18044
- yellow: "#FFAA06",
18045
- orange: "#DB6769",
18046
- red: "#EF4444"
18047
- };
18048
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
18049
- Flex,
18050
- {
18051
- $position: "relative",
18052
- $alignItems: "center",
18053
- $gap: "1rem",
18054
- $width: "100%",
18055
- ...props,
18056
- children: [
18057
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
18058
- Box,
18059
- {
18060
- $overflow: "hidden",
18061
- $width: "100%",
18062
- $minWidth: "6rem",
18063
- $height: `${8 / TEXT_BASE_SIZE}rem`,
18064
- $backgroundColor: bgColor,
18065
- $borderRadius: "9999px",
18066
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
18067
- Box,
18068
- {
18069
- $width: `${Math.min(progress, 100)}%`,
18070
- $height: "100%",
18071
- $backgroundColor: barColorMap[color]
18072
- }
18073
- )
18074
- }
18075
- ),
18076
- total && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
18077
- Text,
18078
- {
18079
- $font: theme.typography.text.fontFamily,
18080
- $size: 14,
18081
- $weight: 500,
18082
- $color: theme.typography.text.color,
18083
- children: [
18084
- formatNumber(value),
18085
- "/",
18086
- formatNumber(total)
18087
- ]
18088
- }
18089
- )
18090
- ]
18091
- }
18092
- );
18093
- };
18067
+ var ProgressBar = (0, import_react19.forwardRef)(
18068
+ ({
18069
+ progress,
18070
+ value,
18071
+ total = 0,
18072
+ color = "gray",
18073
+ bgColor = "#F2F4F7",
18074
+ ...props
18075
+ }, ref) => {
18076
+ const theme = nt();
18077
+ const barColorMap = {
18078
+ gray: "#9CA3AF",
18079
+ blue: "#2563EB",
18080
+ yellow: "#FFAA06",
18081
+ orange: "#DB6769",
18082
+ red: "#EF4444"
18083
+ };
18084
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
18085
+ Flex,
18086
+ {
18087
+ ref,
18088
+ $position: "relative",
18089
+ $alignItems: "center",
18090
+ $gap: "1rem",
18091
+ $width: "100%",
18092
+ ...props,
18093
+ children: [
18094
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
18095
+ Box,
18096
+ {
18097
+ $overflow: "hidden",
18098
+ $width: "100%",
18099
+ $minWidth: "6rem",
18100
+ $height: `${8 / TEXT_BASE_SIZE}rem`,
18101
+ $backgroundColor: bgColor,
18102
+ $borderRadius: "9999px",
18103
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
18104
+ Box,
18105
+ {
18106
+ $width: `${Math.min(progress, 100)}%`,
18107
+ $height: "100%",
18108
+ $backgroundColor: barColorMap[color]
18109
+ }
18110
+ )
18111
+ }
18112
+ ),
18113
+ total && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
18114
+ Text,
18115
+ {
18116
+ $font: theme.typography.text.fontFamily,
18117
+ $size: 14,
18118
+ $weight: 500,
18119
+ $color: theme.typography.text.color,
18120
+ children: [
18121
+ formatNumber(value),
18122
+ "/",
18123
+ formatNumber(total)
18124
+ ]
18125
+ }
18126
+ )
18127
+ ]
18128
+ }
18129
+ );
18130
+ }
18131
+ );
18132
+ ProgressBar.displayName = "ProgressBar";
18094
18133
 
18095
18134
  // src/components/ui/text/styles.ts
18096
18135
  var TextPropNames = /* @__PURE__ */ ((TextPropNames2) => {
@@ -18157,12 +18196,13 @@ var Text = dt.span.withConfig({
18157
18196
 
18158
18197
  // src/components/ui/tooltip/Tooltip.tsx
18159
18198
  var import_lodash2 = __toESM(require_lodash());
18160
- var import_react18 = require("react");
18199
+ var import_react20 = require("react");
18161
18200
  var import_react_dom = require("react-dom");
18162
18201
 
18163
18202
  // src/components/ui/tooltip/styles.ts
18164
18203
  var Trigger = dt.div`
18165
18204
  width: 100%;
18205
+ flex-grow: 1;
18166
18206
  `;
18167
18207
  var coords = (position2) => {
18168
18208
  let x2 = 0;
@@ -18294,13 +18334,13 @@ var Tooltip = ({
18294
18334
  trigger,
18295
18335
  content,
18296
18336
  position: position2 = "top",
18297
- zIndex = 1,
18337
+ zIndex = 9999999,
18298
18338
  ...rest
18299
18339
  }) => {
18300
- const ref = (0, import_react18.useRef)(null);
18301
- const [show, setShow] = (0, import_react18.useState)(false);
18302
- const [coords2, setCoords] = (0, import_react18.useState)({ x: 0, y: 0 });
18303
- const updateCoords = (0, import_react18.useCallback)(() => {
18340
+ const ref = (0, import_react20.useRef)(null);
18341
+ const [show, setShow] = (0, import_react20.useState)(false);
18342
+ const [coords2, setCoords] = (0, import_react20.useState)({ x: 0, y: 0 });
18343
+ const updateCoords = (0, import_react20.useCallback)(() => {
18304
18344
  if (ref.current) {
18305
18345
  const { top: offsetTop, left: offsetLeft } = document.body.getBoundingClientRect();
18306
18346
  const rect = ref.current.getBoundingClientRect();
@@ -18318,14 +18358,14 @@ var Tooltip = ({
18318
18358
  });
18319
18359
  }
18320
18360
  }, [position2]);
18321
- (0, import_react18.useLayoutEffect)(() => {
18361
+ (0, import_react20.useLayoutEffect)(() => {
18322
18362
  const handleResize = (0, import_lodash2.debounce)(updateCoords, DEBOUNCE_TIMEOUT);
18323
18363
  window.addEventListener("resize", handleResize);
18324
18364
  return () => {
18325
18365
  window.removeEventListener("resize", handleResize);
18326
18366
  };
18327
18367
  }, [updateCoords]);
18328
- (0, import_react18.useLayoutEffect)(() => {
18368
+ (0, import_react20.useLayoutEffect)(() => {
18329
18369
  updateCoords();
18330
18370
  }, [updateCoords, show]);
18331
18371
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
@@ -18387,7 +18427,7 @@ var StyledCard = dt.div(({ theme }) => {
18387
18427
 
18388
18428
  // src/components/layout/card/Card.tsx
18389
18429
  var import_jsx_runtime8 = require("react/jsx-runtime");
18390
- var Card = (0, import_react19.forwardRef)(
18430
+ var Card = (0, import_react21.forwardRef)(
18391
18431
  ({ children, className }, ref) => {
18392
18432
  const { isPending } = useEmbed();
18393
18433
  const theme = nt();
@@ -18416,7 +18456,7 @@ var Card = (0, import_react19.forwardRef)(
18416
18456
  Card.displayName = "Card";
18417
18457
 
18418
18458
  // src/components/layout/column/Column.tsx
18419
- var import_react20 = require("react");
18459
+ var import_react22 = require("react");
18420
18460
 
18421
18461
  // src/components/layout/column/styles.ts
18422
18462
  var StyledColumn = dt.div`
@@ -18425,15 +18465,15 @@ var StyledColumn = dt.div`
18425
18465
 
18426
18466
  // src/components/layout/column/Column.tsx
18427
18467
  var import_jsx_runtime9 = require("react/jsx-runtime");
18428
- var Column = (0, import_react20.forwardRef)(
18468
+ var Column = (0, import_react22.forwardRef)(
18429
18469
  ({ children, basis, ...props }, ref) => {
18430
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyledColumn, { ref, ...props, children: import_react20.Children.count(children) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Card, { children }) : children });
18470
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyledColumn, { ref, ...props, children: import_react22.Children.count(children) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Card, { children }) : children });
18431
18471
  }
18432
18472
  );
18433
18473
  Column.displayName = "Column";
18434
18474
 
18435
18475
  // src/components/layout/root/Root.tsx
18436
- var import_react21 = require("react");
18476
+ var import_react23 = require("react");
18437
18477
 
18438
18478
  // src/components/layout/root/styles.ts
18439
18479
  var Container2 = dt.div`
@@ -18445,6 +18485,7 @@ var Container2 = dt.div`
18445
18485
  width: 100%;
18446
18486
  height: 100%;
18447
18487
  container-type: inline-size;
18488
+ interpolate-size: allow-keywords;
18448
18489
 
18449
18490
  *,
18450
18491
  *::before,
@@ -18469,7 +18510,7 @@ var Container2 = dt.div`
18469
18510
 
18470
18511
  // src/components/layout/root/Root.tsx
18471
18512
  var import_jsx_runtime10 = require("react/jsx-runtime");
18472
- var Root = (0, import_react21.forwardRef)(
18513
+ var Root = (0, import_react23.forwardRef)(
18473
18514
  ({ data, settings, ...props }, ref) => {
18474
18515
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Container2, { ref, ...props });
18475
18516
  }
@@ -18478,17 +18519,17 @@ Root.displayName = "Root";
18478
18519
 
18479
18520
  // src/components/layout/viewport/Viewport.tsx
18480
18521
  var import_lodash3 = __toESM(require_lodash());
18481
- var import_react30 = require("react");
18522
+ var import_react32 = require("react");
18482
18523
  var import_react_dom2 = require("react-dom");
18483
18524
 
18484
18525
  // src/components/shared/checkout-dialog/CheckoutDialog.tsx
18485
- var import_react26 = require("react");
18526
+ var import_react28 = require("react");
18486
18527
 
18487
18528
  // src/components/shared/sidebar/Sidebar.tsx
18488
- var import_react23 = require("react");
18529
+ var import_react25 = require("react");
18489
18530
 
18490
18531
  // src/components/shared/sidebar/Proration.tsx
18491
- var import_react22 = require("react");
18532
+ var import_react24 = require("react");
18492
18533
  var import_jsx_runtime11 = require("react/jsx-runtime");
18493
18534
  var Proration = ({
18494
18535
  currency,
@@ -18497,7 +18538,7 @@ var Proration = ({
18497
18538
  }) => {
18498
18539
  const { t: t2 } = useTranslation();
18499
18540
  const theme = nt();
18500
- const [open, setOpen] = (0, import_react22.useState)(false);
18541
+ const [open, setOpen] = (0, import_react24.useState)(false);
18501
18542
  const toggle = (e2) => {
18502
18543
  e2.preventDefault();
18503
18544
  e2.stopPropagation();
@@ -18553,21 +18594,29 @@ var Proration = ({
18553
18594
  children: t2("Total")
18554
18595
  }
18555
18596
  ),
18556
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Button, { onClick: toggle, $variant: "text", children: [
18557
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon2, { name: open ? "chevron-up" : "chevron-down" }),
18558
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
18559
- Text,
18560
- {
18561
- $font: theme.typography.link.fontFamily,
18562
- $size: theme.typography.link.fontSize,
18563
- $weight: theme.typography.link.fontWeight,
18564
- $color: theme.typography.link.color,
18565
- $leading: 1,
18566
- style: { cursor: "pointer" },
18567
- children: open ? t2("Hide details") : t2("Show details")
18568
- }
18569
- )
18570
- ] })
18597
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
18598
+ Button,
18599
+ {
18600
+ onClick: toggle,
18601
+ style: { height: "auto", padding: 0 },
18602
+ $variant: "text",
18603
+ children: [
18604
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon2, { name: open ? "chevron-up" : "chevron-down" }),
18605
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
18606
+ Text,
18607
+ {
18608
+ $font: theme.typography.link.fontFamily,
18609
+ $size: theme.typography.link.fontSize,
18610
+ $weight: theme.typography.link.fontWeight,
18611
+ $color: theme.typography.link.color,
18612
+ $leading: 1,
18613
+ style: { cursor: "pointer" },
18614
+ children: open ? t2("Hide details") : t2("Show details")
18615
+ }
18616
+ )
18617
+ ]
18618
+ }
18619
+ )
18571
18620
  ] }),
18572
18621
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Flex, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
18573
18622
  Text,
@@ -18611,6 +18660,7 @@ var StageButton = ({
18611
18660
  disabled: isLoading || !hasUnstagedChanges || !canUpdateSubscription,
18612
18661
  onClick: checkout,
18613
18662
  $isLoading: isLoading,
18663
+ $fullWidth: true,
18614
18664
  children: t2("Subscribe and close")
18615
18665
  }
18616
18666
  );
@@ -18626,6 +18676,7 @@ var StageButton = ({
18626
18676
  setCheckoutStage?.("checkout");
18627
18677
  },
18628
18678
  $isLoading: isLoading,
18679
+ $fullWidth: true,
18629
18680
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
18630
18681
  Flex,
18631
18682
  {
@@ -18660,6 +18711,7 @@ var StageButton = ({
18660
18711
  );
18661
18712
  },
18662
18713
  $isLoading: isLoading,
18714
+ $fullWidth: true,
18663
18715
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Flex, { $gap: "0.5rem", $justifyContent: "center", $alignItems: "center", children: [
18664
18716
  t2("Next"),
18665
18717
  ":",
@@ -18683,6 +18735,7 @@ var StageButton = ({
18683
18735
  setCheckoutStage?.(hasAddOns ? "addons" : "checkout");
18684
18736
  },
18685
18737
  $isLoading: isLoading,
18738
+ $fullWidth: true,
18686
18739
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
18687
18740
  Flex,
18688
18741
  {
@@ -18714,6 +18767,7 @@ var StageButton = ({
18714
18767
  setCheckoutStage?.("checkout");
18715
18768
  },
18716
18769
  $isLoading: isLoading,
18770
+ $fullWidth: true,
18717
18771
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
18718
18772
  Flex,
18719
18773
  {
@@ -18743,6 +18797,7 @@ var StageButton = ({
18743
18797
  disabled: isLoading || !hasUnstagedChanges || !canCheckout,
18744
18798
  onClick: checkout,
18745
18799
  $isLoading: isLoading,
18800
+ $fullWidth: true,
18746
18801
  children: willTrial ? t2("Start trial") : t2("Pay now")
18747
18802
  }
18748
18803
  );
@@ -18778,7 +18833,7 @@ var Sidebar = ({
18778
18833
  const isLightBackground = useIsLightBackground();
18779
18834
  const currentPlan = data.company?.plan;
18780
18835
  const currentAddOns = data.company?.addOns || [];
18781
- const currentUsageBasedEntitlements = (0, import_react23.useMemo)(() => {
18836
+ const currentUsageBasedEntitlements = (0, import_react25.useMemo)(() => {
18782
18837
  return (data.featureUsage?.features || []).reduce(
18783
18838
  (acc, entitlement) => {
18784
18839
  if (entitlement.priceBehavior && (planPeriod === "month" && entitlement.monthlyUsageBasedPrice || planPeriod === "year" && entitlement.yearlyUsageBasedPrice)) {
@@ -18796,7 +18851,7 @@ var Sidebar = ({
18796
18851
  []
18797
18852
  );
18798
18853
  }, [data.featureUsage?.features, planPeriod]);
18799
- const { payAsYouGoEntitlements, payInAdvanceEntitlements } = (0, import_react23.useMemo)(() => {
18854
+ const { payAsYouGoEntitlements, payInAdvanceEntitlements } = (0, import_react25.useMemo)(() => {
18800
18855
  const payAsYouGoEntitlements2 = [];
18801
18856
  const payInAdvanceEntitlements2 = usageBasedEntitlements.filter(
18802
18857
  (entitlement) => {
@@ -18808,7 +18863,7 @@ var Sidebar = ({
18808
18863
  );
18809
18864
  return { payAsYouGoEntitlements: payAsYouGoEntitlements2, payInAdvanceEntitlements: payInAdvanceEntitlements2 };
18810
18865
  }, [usageBasedEntitlements]);
18811
- const subscriptionPrice = (0, import_react23.useMemo)(() => {
18866
+ const subscriptionPrice = (0, import_react25.useMemo)(() => {
18812
18867
  let planPrice;
18813
18868
  let currency;
18814
18869
  if (selectedPlan) {
@@ -18842,7 +18897,7 @@ var Sidebar = ({
18842
18897
  total += payInAdvanceCost;
18843
18898
  return formatCurrency(total, currency);
18844
18899
  }, [selectedPlan, currentPlan, planPeriod, addOns, payInAdvanceEntitlements]);
18845
- const { amountOff, dueNow, newCharges, percentOff, periodStart, proration } = (0, import_react23.useMemo)(() => {
18900
+ const { amountOff, dueNow, newCharges, percentOff, periodStart, proration } = (0, import_react25.useMemo)(() => {
18846
18901
  return {
18847
18902
  amountOff: charges?.amountOff ?? 0,
18848
18903
  dueNow: charges?.dueNow ?? 0,
@@ -18859,7 +18914,7 @@ var Sidebar = ({
18859
18914
  });
18860
18915
  window.dispatchEvent(event);
18861
18916
  };
18862
- const checkout = (0, import_react23.useCallback)(async () => {
18917
+ const checkout = (0, import_react25.useCallback)(async () => {
18863
18918
  const priceId = (planPeriod === "year" ? selectedPlan?.yearlyPrice : selectedPlan?.monthlyPrice)?.id;
18864
18919
  if (!api || !selectedPlan || !priceId) {
18865
18920
  return;
@@ -18926,7 +18981,7 @@ var Sidebar = ({
18926
18981
  payInAdvanceEntitlements,
18927
18982
  promoCode
18928
18983
  ]);
18929
- const unsubscribe = (0, import_react23.useCallback)(async () => {
18984
+ const unsubscribe = (0, import_react25.useCallback)(async () => {
18930
18985
  if (!api) {
18931
18986
  return;
18932
18987
  }
@@ -18950,7 +19005,7 @@ var Sidebar = ({
18950
19005
  addedUsageBasedEntitlements,
18951
19006
  removedUsageBasedEntitlements,
18952
19007
  willUsageBasedEntitlementsChange
18953
- } = (0, import_react23.useMemo)(() => {
19008
+ } = (0, import_react25.useMemo)(() => {
18954
19009
  const changedUsageBasedEntitlements2 = [];
18955
19010
  const addedUsageBasedEntitlements2 = selectedPlan ? usageBasedEntitlements.reduce(
18956
19011
  (acc, selected) => {
@@ -19014,7 +19069,7 @@ var Sidebar = ({
19014
19069
  const hasUnstagedChanges = willPeriodChange || willPlanChange || willAddOnsChange || willPayInAdvanceEntitlementsChange;
19015
19070
  const canUpdateSubscription = mode === "edit" || api !== null && !isLoading;
19016
19071
  const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
19017
- const isTrialable = selectedPlan?.companyCanTrial === true;
19072
+ const isTrialable = selectedPlan?.companyCanTrial === true && selectedPlan?.isTrialable === true;
19018
19073
  const today = /* @__PURE__ */ new Date();
19019
19074
  const trialEndsOn = new Date(today);
19020
19075
  if (isTrialable && selectedPlan.trialDays) {
@@ -19908,7 +19963,7 @@ var Sidebar = ({
19908
19963
  willTrial
19909
19964
  }
19910
19965
  ),
19911
- layout === "unsubscribe" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { onClick: unsubscribe, $isLoading: isLoading, children: t2("Cancel subscription") }),
19966
+ layout === "unsubscribe" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { onClick: unsubscribe, $isLoading: isLoading, $fullWidth: true, children: t2("Cancel subscription") }),
19912
19967
  !isLoading && error && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
19913
19968
  Text,
19914
19969
  {
@@ -20045,6 +20100,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
20045
20100
  $size: "sm",
20046
20101
  $color: "primary",
20047
20102
  $variant: "outline",
20103
+ $fullWidth: true,
20048
20104
  children: t2("Choose add-on")
20049
20105
  }
20050
20106
  ) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
@@ -20056,6 +20112,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
20056
20112
  $size: "sm",
20057
20113
  $color: addOn.current ? "danger" : "primary",
20058
20114
  $variant: addOn.current ? "ghost" : "text",
20115
+ $fullWidth: true,
20059
20116
  children: addOn.current ? t2("Remove add-on") : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
20060
20117
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
20061
20118
  Icon2,
@@ -20081,7 +20138,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
20081
20138
  };
20082
20139
 
20083
20140
  // src/components/shared/checkout-dialog/Checkout.tsx
20084
- var import_react24 = require("react");
20141
+ var import_react26 = require("react");
20085
20142
  var import_jsx_runtime15 = require("react/jsx-runtime");
20086
20143
  var Checkout = ({
20087
20144
  requiresPayment,
@@ -20091,7 +20148,7 @@ var Checkout = ({
20091
20148
  const { t: t2 } = useTranslation();
20092
20149
  const theme = nt();
20093
20150
  const isLightBackground = useIsLightBackground();
20094
- const [discount, setDiscount] = (0, import_react24.useState)("");
20151
+ const [discount, setDiscount] = (0, import_react26.useState)("");
20095
20152
  if (!requiresPayment) {
20096
20153
  return null;
20097
20154
  }
@@ -20259,7 +20316,7 @@ var Navigation = ({
20259
20316
  };
20260
20317
 
20261
20318
  // src/components/shared/checkout-dialog/Plan.tsx
20262
- var import_react25 = require("react");
20319
+ var import_react27 = require("react");
20263
20320
 
20264
20321
  // src/components/elements/pricing-table/styles.ts
20265
20322
  var ButtonLink = dt.a`
@@ -20275,7 +20332,7 @@ var import_jsx_runtime17 = require("react/jsx-runtime");
20275
20332
  var Selected = ({ isCurrent = false, isTrial = false }) => {
20276
20333
  const { t: t2 } = useTranslation();
20277
20334
  const theme = nt();
20278
- const text = (0, import_react25.useMemo)(() => {
20335
+ const text = (0, import_react27.useMemo)(() => {
20279
20336
  if (isCurrent) {
20280
20337
  return isTrial ? t2("Trial in progress") : t2("Current plan");
20281
20338
  }
@@ -20325,15 +20382,9 @@ var PlanButtonGroup = ({
20325
20382
  const { t: t2 } = useTranslation();
20326
20383
  const { data } = useEmbed();
20327
20384
  const isCurrent = plan.id === data.company?.plan?.id;
20328
- if (plan.companyCanTrial) {
20385
+ if (plan.companyCanTrial && plan.isTrialable) {
20329
20386
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Flex, { $flexDirection: "column", $gap: "1.5rem", children: [
20330
- data.subscription?.status !== "trialing" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: isSelected && willTrial ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20331
- Selected,
20332
- {
20333
- isCurrent,
20334
- isTrial: plan.companyCanTrial && willTrial
20335
- }
20336
- ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20387
+ data.subscription?.status !== "trialing" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: isSelected && willTrial ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Selected, { isCurrent, isTrial: willTrial }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20337
20388
  Button,
20338
20389
  {
20339
20390
  type: "button",
@@ -20349,6 +20400,7 @@ var PlanButtonGroup = ({
20349
20400
  $size: "sm",
20350
20401
  $color: "primary",
20351
20402
  $variant: "filled",
20403
+ $fullWidth: true,
20352
20404
  children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20353
20405
  ButtonLink,
20354
20406
  {
@@ -20359,8 +20411,8 @@ var PlanButtonGroup = ({
20359
20411
  ) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20360
20412
  Tooltip,
20361
20413
  {
20362
- trigger: t2("Over usage limit"),
20363
- content: t2("Current usage exceeds the limit of this plan.")
20414
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { children: t2("Over usage limit") }),
20415
+ content: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { children: t2("Current usage exceeds the limit of this plan.") })
20364
20416
  }
20365
20417
  ) : t2("Start X day trial", { days: plan.trialDays })
20366
20418
  }
@@ -20376,11 +20428,12 @@ var PlanButtonGroup = ({
20376
20428
  $size: "sm",
20377
20429
  $color: "primary",
20378
20430
  $variant: data.subscription?.status === "trialing" ? "filled" : "text",
20431
+ $fullWidth: true,
20379
20432
  children: !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20380
20433
  Tooltip,
20381
20434
  {
20382
- trigger: t2("Over usage limit"),
20383
- content: t2("Current usage exceeds the limit of this plan.")
20435
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { children: t2("Over usage limit") }),
20436
+ content: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { children: t2("Current usage exceeds the limit of this plan.") })
20384
20437
  }
20385
20438
  ) : t2("Choose plan")
20386
20439
  }
@@ -20400,6 +20453,7 @@ var PlanButtonGroup = ({
20400
20453
  $size: "sm",
20401
20454
  $color: "primary",
20402
20455
  $variant: "filled",
20456
+ $fullWidth: true,
20403
20457
  children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20404
20458
  ButtonLink,
20405
20459
  {
@@ -20410,8 +20464,8 @@ var PlanButtonGroup = ({
20410
20464
  ) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
20411
20465
  Tooltip,
20412
20466
  {
20413
- trigger: t2("Over usage limit"),
20414
- content: t2("Current usage exceeds the limit of this plan.")
20467
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { children: t2("Over usage limit") }),
20468
+ content: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text, { children: t2("Current usage exceeds the limit of this plan.") })
20415
20469
  }
20416
20470
  ) : t2("Choose plan")
20417
20471
  }
@@ -20429,7 +20483,7 @@ var Plan = ({
20429
20483
  const theme = nt();
20430
20484
  const { data } = useEmbed();
20431
20485
  const isLightBackground = useIsLightBackground();
20432
- const [entitlementCounts, setEntitlementCounts] = (0, import_react25.useState)(
20486
+ const [entitlementCounts, setEntitlementCounts] = (0, import_react27.useState)(
20433
20487
  () => plans.reduce(
20434
20488
  (acc, plan) => {
20435
20489
  acc[plan.id] = {
@@ -20990,16 +21044,16 @@ var CheckoutDialog = ({ top = 0 }) => {
20990
21044
  const { t: t2 } = useTranslation();
20991
21045
  const theme = nt();
20992
21046
  const { api, data, selected } = useEmbed();
20993
- const modalRef = (0, import_react26.useRef)(null);
20994
- const contentRef = (0, import_react26.useRef)(null);
20995
- const checkoutRef = (0, import_react26.useRef)(null);
20996
- const [charges, setCharges] = (0, import_react26.useState)();
20997
- const [paymentMethodId, setPaymentMethodId] = (0, import_react26.useState)(
21047
+ const modalRef = (0, import_react28.useRef)(null);
21048
+ const contentRef = (0, import_react28.useRef)(null);
21049
+ const checkoutRef = (0, import_react28.useRef)(null);
21050
+ const [charges, setCharges] = (0, import_react28.useState)();
21051
+ const [paymentMethodId, setPaymentMethodId] = (0, import_react28.useState)(
20998
21052
  (data.subscription?.paymentMethod || data.company?.defaultPaymentMethod)?.externalId
20999
21053
  );
21000
- const [isLoading, setIsLoading] = (0, import_react26.useState)(false);
21001
- const [error, setError] = (0, import_react26.useState)();
21002
- const [planPeriod, setPlanPeriod] = (0, import_react26.useState)(
21054
+ const [isLoading, setIsLoading] = (0, import_react28.useState)(false);
21055
+ const [error, setError] = (0, import_react28.useState)();
21056
+ const [planPeriod, setPlanPeriod] = (0, import_react28.useState)(
21003
21057
  selected.period || data.company?.plan?.planPeriod || "month"
21004
21058
  );
21005
21059
  const {
@@ -21007,15 +21061,13 @@ var CheckoutDialog = ({ top = 0 }) => {
21007
21061
  addOns: availableAddOns,
21008
21062
  periods: availablePeriods
21009
21063
  } = useAvailablePlans(planPeriod);
21010
- const [selectedPlan, setSelectedPlan] = (0, import_react26.useState)(
21064
+ const [selectedPlan, setSelectedPlan] = (0, import_react28.useState)(
21011
21065
  () => availablePlans.find(
21012
21066
  (plan) => selected.planId ? plan.id === selected.planId : plan.current
21013
21067
  )
21014
21068
  );
21015
- const [willTrial, setWillTrial] = (0, import_react26.useState)(
21016
- data.subscription?.status !== "trialing" && !data.trialPaymentMethodRequired
21017
- );
21018
- const [addOns, setAddOns] = (0, import_react26.useState)(
21069
+ const [willTrial, setWillTrial] = (0, import_react28.useState)(false);
21070
+ const [addOns, setAddOns] = (0, import_react28.useState)(
21019
21071
  () => availableAddOns.map((addOn) => ({
21020
21072
  ...addOn,
21021
21073
  isSelected: typeof selected.addOnId !== "undefined" ? addOn.id === selected.addOnId : (data.company?.addOns || []).some(
@@ -21024,10 +21076,10 @@ var CheckoutDialog = ({ top = 0 }) => {
21024
21076
  }))
21025
21077
  );
21026
21078
  const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected);
21027
- const currentEntitlements = (0, import_react26.useMemo)(() => {
21079
+ const currentEntitlements = (0, import_react28.useMemo)(() => {
21028
21080
  return data.featureUsage?.features || [];
21029
21081
  }, [data.featureUsage?.features]);
21030
- const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react26.useState)(
21082
+ const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react28.useState)(
21031
21083
  () => (selectedPlan?.entitlements || []).reduce(
21032
21084
  createActiveUsageBasedEntitlementsReducer(
21033
21085
  currentEntitlements,
@@ -21036,7 +21088,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21036
21088
  []
21037
21089
  )
21038
21090
  );
21039
- const payInAdvanceEntitlements = (0, import_react26.useMemo)(
21091
+ const payInAdvanceEntitlements = (0, import_react28.useMemo)(
21040
21092
  () => usageBasedEntitlements.filter(
21041
21093
  (entitlement) => entitlement.priceBehavior === "pay_in_advance"
21042
21094
  ),
@@ -21045,12 +21097,12 @@ var CheckoutDialog = ({ top = 0 }) => {
21045
21097
  const hasActivePayInAdvanceEntitlements = payInAdvanceEntitlements.some(
21046
21098
  ({ quantity }) => quantity > 0
21047
21099
  );
21048
- const [promoCode, setPromoCode] = (0, import_react26.useState)();
21100
+ const [promoCode, setPromoCode] = (0, import_react28.useState)();
21049
21101
  const isTrialable = selectedPlan?.isTrialable === true && selectedPlan?.companyCanTrial === true;
21050
21102
  const isTrialableAndFree = isTrialable && data.trialPaymentMethodRequired !== true;
21051
21103
  const planRequiresPayment = !isTrialableAndFree || !isTrialable && selectedPlan?.isFree !== true;
21052
21104
  const requiresPayment = planRequiresPayment || hasActiveAddOns || hasActivePayInAdvanceEntitlements;
21053
- const checkoutStages = (0, import_react26.useMemo)(() => {
21105
+ const checkoutStages = (0, import_react28.useMemo)(() => {
21054
21106
  const stages = [
21055
21107
  {
21056
21108
  id: "plan",
@@ -21091,7 +21143,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21091
21143
  availableAddOns,
21092
21144
  requiresPayment
21093
21145
  ]);
21094
- const [checkoutStage, setCheckoutStage] = (0, import_react26.useState)(() => {
21146
+ const [checkoutStage, setCheckoutStage] = (0, import_react28.useState)(() => {
21095
21147
  if (selected.addOnId) {
21096
21148
  return "addons";
21097
21149
  }
@@ -21104,7 +21156,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21104
21156
  return "plan";
21105
21157
  });
21106
21158
  const isLightBackground = useIsLightBackground();
21107
- const previewCheckout = (0, import_react26.useCallback)(
21159
+ const previewCheckout = (0, import_react28.useCallback)(
21108
21160
  async (updates) => {
21109
21161
  const period = updates.period || planPeriod;
21110
21162
  const plan = updates.plan || selectedPlan;
@@ -21178,7 +21230,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21178
21230
  promoCode
21179
21231
  ]
21180
21232
  );
21181
- const selectPlan = (0, import_react26.useCallback)(
21233
+ const selectPlan = (0, import_react28.useCallback)(
21182
21234
  (updates) => {
21183
21235
  const plan = updates.plan || selectedPlan;
21184
21236
  if (!plan) {
@@ -21211,7 +21263,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21211
21263
  previewCheckout
21212
21264
  ]
21213
21265
  );
21214
- const changePlanPeriod = (0, import_react26.useCallback)(
21266
+ const changePlanPeriod = (0, import_react28.useCallback)(
21215
21267
  (period) => {
21216
21268
  setPlanPeriod(period);
21217
21269
  previewCheckout({ period });
@@ -21228,7 +21280,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21228
21280
  return updated;
21229
21281
  });
21230
21282
  };
21231
- const updateUsageBasedEntitlementQuantity = (0, import_react26.useCallback)(
21283
+ const updateUsageBasedEntitlementQuantity = (0, import_react28.useCallback)(
21232
21284
  (id, updatedQuantity) => {
21233
21285
  setUsageBasedEntitlements((prev2) => {
21234
21286
  const updated = prev2.map(
@@ -21251,7 +21303,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21251
21303
  setPromoCode(code);
21252
21304
  previewCheckout({ promoCode: code });
21253
21305
  };
21254
- (0, import_react26.useEffect)(() => {
21306
+ (0, import_react28.useEffect)(() => {
21255
21307
  if (charges) {
21256
21308
  checkoutRef.current?.scrollIntoView({
21257
21309
  behavior: "smooth",
@@ -21259,7 +21311,7 @@ var CheckoutDialog = ({ top = 0 }) => {
21259
21311
  });
21260
21312
  }
21261
21313
  }, [charges]);
21262
- (0, import_react26.useLayoutEffect)(() => {
21314
+ (0, import_react28.useLayoutEffect)(() => {
21263
21315
  if (contentRef.current) {
21264
21316
  contentRef.current.scrollTo({
21265
21317
  top: 0,
@@ -21494,7 +21546,7 @@ var PaymentDialog = ({ top = 0 }) => {
21494
21546
 
21495
21547
  // src/components/shared/payment-form/PaymentForm.tsx
21496
21548
  var import_react_stripe_js = require("@stripe/react-stripe-js");
21497
- var import_react27 = require("react");
21549
+ var import_react29 = require("react");
21498
21550
  var import_jsx_runtime21 = require("react/jsx-runtime");
21499
21551
  var PaymentForm = ({ onConfirm }) => {
21500
21552
  const { t: t2 } = useTranslation();
@@ -21502,10 +21554,10 @@ var PaymentForm = ({ onConfirm }) => {
21502
21554
  const stripe = (0, import_react_stripe_js.useStripe)();
21503
21555
  const elements = (0, import_react_stripe_js.useElements)();
21504
21556
  const { api } = useEmbed();
21505
- const [message, setMessage] = (0, import_react27.useState)(null);
21506
- const [isLoading, setIsLoading] = (0, import_react27.useState)(false);
21507
- const [isConfirmed, setIsConfirmed] = (0, import_react27.useState)(false);
21508
- const [isComplete, setIsComplete] = (0, import_react27.useState)(false);
21557
+ const [message, setMessage] = (0, import_react29.useState)(null);
21558
+ const [isLoading, setIsLoading] = (0, import_react29.useState)(false);
21559
+ const [isConfirmed, setIsConfirmed] = (0, import_react29.useState)(false);
21560
+ const [isComplete, setIsComplete] = (0, import_react29.useState)(false);
21509
21561
  const handleSubmit = async (event) => {
21510
21562
  event.preventDefault();
21511
21563
  if (!api || !stripe || !elements) {
@@ -21565,6 +21617,7 @@ var PaymentForm = ({ onConfirm }) => {
21565
21617
  style: { flexShrink: 0 },
21566
21618
  $color: "primary",
21567
21619
  $isLoading: isLoading,
21620
+ $fullWidth: true,
21568
21621
  children: isLoading ? t2("Loading") : t2("Save payment method")
21569
21622
  }
21570
21623
  ),
@@ -21585,7 +21638,7 @@ var PaymentForm = ({ onConfirm }) => {
21585
21638
  };
21586
21639
 
21587
21640
  // src/components/shared/period-toggle/PeriodToggle.tsx
21588
- var import_react28 = require("react");
21641
+ var import_react30 = require("react");
21589
21642
  var import_jsx_runtime22 = require("react/jsx-runtime");
21590
21643
  var PeriodToggle = ({
21591
21644
  options: options2,
@@ -21597,8 +21650,8 @@ var PeriodToggle = ({
21597
21650
  const { t: t2 } = useTranslation();
21598
21651
  const theme = nt();
21599
21652
  const isLightBackground = useIsLightBackground();
21600
- const [tooltipZIndex, setTooltipZIndex] = (0, import_react28.useState)(1);
21601
- const savingsPercentage = (0, import_react28.useMemo)(() => {
21653
+ const [tooltipZIndex, setTooltipZIndex] = (0, import_react30.useState)(1);
21654
+ const savingsPercentage = (0, import_react30.useMemo)(() => {
21602
21655
  if (selectedPlan) {
21603
21656
  const monthlyBillingPrice = getBillingPrice(selectedPlan?.monthlyPrice);
21604
21657
  const yearlyBillingPrice = getBillingPrice(selectedPlan?.yearlyPrice);
@@ -21608,7 +21661,7 @@ var PeriodToggle = ({
21608
21661
  }
21609
21662
  return 0;
21610
21663
  }, [selectedPlan]);
21611
- (0, import_react28.useLayoutEffect)(() => {
21664
+ (0, import_react30.useLayoutEffect)(() => {
21612
21665
  const element = layerRef?.current;
21613
21666
  if (element) {
21614
21667
  const style = getComputedStyle(element);
@@ -21698,21 +21751,21 @@ var PeriodToggle = ({
21698
21751
  };
21699
21752
 
21700
21753
  // src/components/shared/unsubscribe-dialog/UnsubscribeDialog.tsx
21701
- var import_react29 = require("react");
21754
+ var import_react31 = require("react");
21702
21755
  var import_jsx_runtime23 = require("react/jsx-runtime");
21703
21756
  var UnsubscribeDialog = ({ top = 0 }) => {
21704
21757
  const { t: t2 } = useTranslation();
21705
21758
  const theme = nt();
21706
21759
  const { data, setLayout, setSelected } = useEmbed();
21707
- const contentRef = (0, import_react29.useRef)(null);
21708
- const [error, setError] = (0, import_react29.useState)();
21709
- const [isLoading, setIsLoading] = (0, import_react29.useState)(false);
21710
- const planPeriod = (0, import_react29.useMemo)(
21760
+ const contentRef = (0, import_react31.useRef)(null);
21761
+ const [error, setError] = (0, import_react31.useState)();
21762
+ const [isLoading, setIsLoading] = (0, import_react31.useState)(false);
21763
+ const planPeriod = (0, import_react31.useMemo)(
21711
21764
  () => data.company?.plan?.planPeriod ?? "month",
21712
21765
  [data.company?.plan?.planPeriod]
21713
21766
  );
21714
21767
  const { plans: availablePlans, addOns: availableAddOns } = useAvailablePlans(planPeriod);
21715
- const selectedPlan = (0, import_react29.useMemo)(
21768
+ const selectedPlan = (0, import_react31.useMemo)(
21716
21769
  () => availablePlans.find(
21717
21770
  (plan) => plan.id === data.company?.plan?.id && data.company?.plan.planPeriod === planPeriod
21718
21771
  ),
@@ -21723,7 +21776,7 @@ var UnsubscribeDialog = ({ top = 0 }) => {
21723
21776
  createActiveUsageBasedEntitlementsReducer(currentEntitlements, planPeriod),
21724
21777
  []
21725
21778
  );
21726
- const addOns = (0, import_react29.useMemo)(
21779
+ const addOns = (0, import_react31.useMemo)(
21727
21780
  () => availableAddOns.map((available) => ({
21728
21781
  ...available,
21729
21782
  isSelected: data.company?.addOns.some((current) => available.id === current.id) ?? false
@@ -21734,7 +21787,7 @@ var UnsubscribeDialog = ({ top = 0 }) => {
21734
21787
  data.subscription?.cancelAt || data.upcomingInvoice?.dueDate || Date.now()
21735
21788
  );
21736
21789
  const isLightBackground = useIsLightBackground();
21737
- const handleClose = (0, import_react29.useCallback)(() => {
21790
+ const handleClose = (0, import_react31.useCallback)(() => {
21738
21791
  setLayout("portal");
21739
21792
  }, [setLayout]);
21740
21793
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
@@ -21847,7 +21900,6 @@ var UnsubscribeDialog = ({ top = 0 }) => {
21847
21900
  $size: "sm",
21848
21901
  $color: "secondary",
21849
21902
  $variant: "ghost",
21850
- $fullWidth: false,
21851
21903
  children: t2("Manage plan")
21852
21904
  }
21853
21905
  )
@@ -22062,12 +22114,12 @@ var StyledViewport = dt.div.withConfig({
22062
22114
 
22063
22115
  // src/components/layout/viewport/Viewport.tsx
22064
22116
  var import_jsx_runtime26 = require("react/jsx-runtime");
22065
- var Viewport = (0, import_react30.forwardRef)(
22117
+ var Viewport = (0, import_react32.forwardRef)(
22066
22118
  ({ children, portal, ...props }, ref) => {
22067
22119
  const { data, layout, settings } = useEmbed();
22068
- const [top, setTop] = (0, import_react30.useState)(0);
22120
+ const [top, setTop] = (0, import_react32.useState)(0);
22069
22121
  const canCheckout = data.capabilities?.checkout ?? true;
22070
- (0, import_react30.useLayoutEffect)(() => {
22122
+ (0, import_react32.useLayoutEffect)(() => {
22071
22123
  const parent = portal || document.body;
22072
22124
  const setModalY = (0, import_lodash3.debounce)(() => {
22073
22125
  const value = Math.abs(
@@ -22114,7 +22166,7 @@ var resolveDesignProps = (props) => {
22114
22166
  }
22115
22167
  };
22116
22168
  };
22117
- var ButtonElement = (0, import_react31.forwardRef)(({ children, className, ...rest }, ref) => {
22169
+ var ButtonElement = (0, import_react33.forwardRef)(({ children, className, ...rest }, ref) => {
22118
22170
  const props = resolveDesignProps(rest);
22119
22171
  const buttonStyles = {
22120
22172
  primary: {
@@ -22159,10 +22211,10 @@ var ButtonElement = (0, import_react31.forwardRef)(({ children, className, ...re
22159
22211
  ButtonElement.displayName = "Button";
22160
22212
 
22161
22213
  // src/components/elements/included-features/IncludedFeatures.tsx
22162
- var import_react33 = require("react");
22214
+ var import_react35 = require("react");
22163
22215
 
22164
22216
  // src/components/elements/included-features/Details.tsx
22165
- var import_react32 = require("react");
22217
+ var import_react34 = require("react");
22166
22218
  var import_jsx_runtime28 = require("react/jsx-runtime");
22167
22219
  var Details = ({
22168
22220
  shouldWrapChildren,
@@ -22187,7 +22239,7 @@ var Details = ({
22187
22239
  priceTier,
22188
22240
  currency,
22189
22241
  packageSize = 1
22190
- } = (0, import_react32.useMemo)(() => {
22242
+ } = (0, import_react34.useMemo)(() => {
22191
22243
  const {
22192
22244
  price: entitlementPrice,
22193
22245
  priceDecimal: entitlementPriceDecimal,
@@ -22209,7 +22261,7 @@ var Details = ({
22209
22261
  monthlyUsageBasedPrice,
22210
22262
  yearlyUsageBasedPrice
22211
22263
  ]);
22212
- const text = (0, import_react32.useMemo)(() => {
22264
+ const text = (0, import_react34.useMemo)(() => {
22213
22265
  if (!feature) {
22214
22266
  return;
22215
22267
  }
@@ -22260,7 +22312,7 @@ var Details = ({
22260
22312
  packageSize,
22261
22313
  softLimit
22262
22314
  ]);
22263
- const usageText = (0, import_react32.useMemo)(() => {
22315
+ const usageText = (0, import_react34.useMemo)(() => {
22264
22316
  if (!feature) {
22265
22317
  return;
22266
22318
  }
@@ -22268,7 +22320,7 @@ var Details = ({
22268
22320
  let index = 0;
22269
22321
  if (priceBehavior === "pay_in_advance" && typeof data.company?.plan?.planPeriod === "string" && typeof price === "number") {
22270
22322
  acc.push(
22271
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22323
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react34.Fragment, { children: [
22272
22324
  formatCurrency(price, currency),
22273
22325
  "/",
22274
22326
  packageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
@@ -22283,7 +22335,7 @@ var Details = ({
22283
22335
  index += 1;
22284
22336
  } else if ((priceBehavior === "pay_as_you_go" || priceBehavior === "overage") && typeof usage === "number") {
22285
22337
  acc.push(
22286
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22338
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react34.Fragment, { children: [
22287
22339
  usage,
22288
22340
  " ",
22289
22341
  getFeatureName(feature, usage),
@@ -22296,7 +22348,7 @@ var Details = ({
22296
22348
  if (acc) {
22297
22349
  if (priceBehavior === "pay_in_advance" && typeof price === "number" && typeof allocation === "number") {
22298
22350
  acc.push(
22299
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22351
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react34.Fragment, { children: [
22300
22352
  " ",
22301
22353
  "\u2022 ",
22302
22354
  formatCurrency(price * allocation, currency)
@@ -22305,7 +22357,7 @@ var Details = ({
22305
22357
  index += 1;
22306
22358
  } else if (priceBehavior === "pay_as_you_go" && typeof price === "number" && typeof usage === "number") {
22307
22359
  acc.push(
22308
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22360
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react34.Fragment, { children: [
22309
22361
  " ",
22310
22362
  "\u2022 ",
22311
22363
  formatCurrency(price * usage, currency)
@@ -22326,7 +22378,7 @@ var Details = ({
22326
22378
  const period = feature.featureType === "trait" && typeof data.company?.plan?.planPeriod === "string" ? `/${shortenPeriod(data.company.plan.planPeriod)}` : "";
22327
22379
  if (cost > 0) {
22328
22380
  acc.push(
22329
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22381
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react34.Fragment, { children: [
22330
22382
  " ",
22331
22383
  "\u2022 ",
22332
22384
  formatCurrency(cost),
@@ -22428,16 +22480,16 @@ function resolveDesignProps2(props) {
22428
22480
  visibleFeatures: props.visibleFeatures
22429
22481
  };
22430
22482
  }
22431
- var IncludedFeatures = (0, import_react33.forwardRef)(({ className, ...rest }, ref) => {
22483
+ var IncludedFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, ref) => {
22432
22484
  const props = resolveDesignProps2(rest);
22433
22485
  const { t: t2 } = useTranslation();
22434
22486
  const theme = nt();
22435
22487
  const { data } = useEmbed();
22436
- const elements = (0, import_react33.useRef)([]);
22488
+ const elements = (0, import_react35.useRef)([]);
22437
22489
  const shouldWrapChildren = useWrapChildren(elements.current);
22438
22490
  const isLightBackground = useIsLightBackground();
22439
- const [showCount, setShowCount] = (0, import_react33.useState)(VISIBLE_ENTITLEMENT_COUNT);
22440
- const featureUsage = (0, import_react33.useMemo)(() => {
22491
+ const [showCount, setShowCount] = (0, import_react35.useState)(VISIBLE_ENTITLEMENT_COUNT);
22492
+ const featureUsage = (0, import_react35.useMemo)(() => {
22441
22493
  const orderedFeatureUsage = props.visibleFeatures?.reduce(
22442
22494
  (acc, id) => {
22443
22495
  const mappedFeatureUsage = data.featureUsage?.features.find(
@@ -22595,7 +22647,7 @@ var IncludedFeatures = (0, import_react33.forwardRef)(({ className, ...rest }, r
22595
22647
  IncludedFeatures.displayName = "IncludedFeatures";
22596
22648
 
22597
22649
  // src/components/elements/invoices/Invoices.tsx
22598
- var import_react34 = require("react");
22650
+ var import_react36 = require("react");
22599
22651
  var import_jsx_runtime30 = require("react/jsx-runtime");
22600
22652
  function resolveDesignProps3(props) {
22601
22653
  return {
@@ -22647,24 +22699,24 @@ var InvoiceDate = ({ date, fontStyle, url }) => {
22647
22699
  }
22648
22700
  return dateText;
22649
22701
  };
22650
- var Invoices = (0, import_react34.forwardRef)(({ className, data, ...rest }, ref) => {
22702
+ var Invoices = (0, import_react36.forwardRef)(({ className, data, ...rest }, ref) => {
22651
22703
  const props = resolveDesignProps3(rest);
22652
22704
  const { t: t2 } = useTranslation();
22653
22705
  const theme = nt();
22654
22706
  const { api } = useEmbed();
22655
- const [invoices, setInvoices] = (0, import_react34.useState)(() => formatInvoices(data));
22656
- const [listSize, setListSize] = (0, import_react34.useState)(props.limit.number);
22707
+ const [invoices, setInvoices] = (0, import_react36.useState)(() => formatInvoices(data));
22708
+ const [listSize, setListSize] = (0, import_react36.useState)(props.limit.number);
22657
22709
  const toggleListSize = () => {
22658
22710
  setListSize(
22659
22711
  (prev2) => prev2 !== props.limit.number ? props.limit.number : MAX_VISIBLE_INVOICE_COUNT
22660
22712
  );
22661
22713
  };
22662
- (0, import_react34.useEffect)(() => {
22714
+ (0, import_react36.useEffect)(() => {
22663
22715
  api?.listInvoices().then((response) => {
22664
22716
  setInvoices(formatInvoices(response.data));
22665
22717
  });
22666
22718
  }, [api]);
22667
- (0, import_react34.useEffect)(() => {
22719
+ (0, import_react36.useEffect)(() => {
22668
22720
  setInvoices(formatInvoices(data));
22669
22721
  }, [data]);
22670
22722
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Element, { ref, className, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Flex, { $flexDirection: "column", $gap: "1rem", children: [
@@ -22727,7 +22779,7 @@ var Invoices = (0, import_react34.forwardRef)(({ className, data, ...rest }, ref
22727
22779
  Invoices.displayName = "Invoices";
22728
22780
 
22729
22781
  // src/components/elements/metered-features/MeteredFeatures.tsx
22730
- var import_react35 = require("react");
22782
+ var import_react37 = require("react");
22731
22783
 
22732
22784
  // src/components/elements/metered-features/styles.ts
22733
22785
  var Container3 = dt.div`
@@ -22773,15 +22825,15 @@ function resolveDesignProps4(props) {
22773
22825
  visibleFeatures: props.visibleFeatures
22774
22826
  };
22775
22827
  }
22776
- var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, ref) => {
22828
+ var MeteredFeatures = (0, import_react37.forwardRef)(({ className, ...rest }, ref) => {
22777
22829
  const props = resolveDesignProps4(rest);
22778
- const elements = (0, import_react35.useRef)([]);
22830
+ const elements = (0, import_react37.useRef)([]);
22779
22831
  const shouldWrapChildren = useWrapChildren(elements.current);
22780
22832
  const { t: t2 } = useTranslation();
22781
22833
  const theme = nt();
22782
22834
  const { data, setLayout, setSelected } = useEmbed();
22783
22835
  const isLightBackground = useIsLightBackground();
22784
- const featureUsage = (0, import_react35.useMemo)(() => {
22836
+ const featureUsage = (0, import_react37.useMemo)(() => {
22785
22837
  const orderedFeatureUsage = props.visibleFeatures?.reduce(
22786
22838
  (acc, id) => {
22787
22839
  const mappedFeatureUsage = data.featureUsage?.features.find(
@@ -22967,7 +23019,7 @@ var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, re
22967
23019
  }
22968
23020
  ),
22969
23021
  props.isVisible && typeof usage === "number" && priceBehavior !== "pay_as_you_go" && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Flex, { $flexWrap: "wrap", $justifyContent: "end", $gap: "2rem", children: [
22970
- typeof allocation === "number" ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
23022
+ typeof allocation === "number" && progressBar ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
22971
23023
  Tooltip,
22972
23024
  {
22973
23025
  trigger: progressBar,
@@ -22995,7 +23047,6 @@ var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, re
22995
23047
  setSelected({ usage: true });
22996
23048
  setLayout("checkout");
22997
23049
  },
22998
- $fullWidth: false,
22999
23050
  style: { whiteSpace: "nowrap" },
23000
23051
  children: t2("Add More")
23001
23052
  }
@@ -23078,10 +23129,10 @@ var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, re
23078
23129
  MeteredFeatures.displayName = "MeteredFeatures";
23079
23130
 
23080
23131
  // src/components/elements/payment-method/PaymentMethod.tsx
23081
- var import_react37 = require("react");
23132
+ var import_react39 = require("react");
23082
23133
 
23083
23134
  // src/components/elements/payment-method/PaymentMethodElement.tsx
23084
- var import_react36 = require("react");
23135
+ var import_react38 = require("react");
23085
23136
  var import_jsx_runtime32 = require("react/jsx-runtime");
23086
23137
  var PaymentElement2 = ({
23087
23138
  iconName,
@@ -23256,7 +23307,7 @@ var PaymentListElement = ({
23256
23307
  const isLightBackground = useIsLightBackground();
23257
23308
  const { iconName, iconTitle, label, paymentLast4 } = getPaymentMethodData(paymentMethod);
23258
23309
  const iconStyles = getIconStyles({ size: "lg", theme });
23259
- const expirationDate = (0, import_react36.useMemo)(() => {
23310
+ const expirationDate = (0, import_react38.useMemo)(() => {
23260
23311
  const { cardExpMonth, cardExpYear } = paymentMethod;
23261
23312
  if (!cardExpMonth && !cardExpYear) {
23262
23313
  return "";
@@ -23368,13 +23419,13 @@ var resolveDesignProps5 = (props) => {
23368
23419
  }
23369
23420
  };
23370
23421
  };
23371
- var PaymentMethod = (0, import_react37.forwardRef)(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
23422
+ var PaymentMethod = (0, import_react39.forwardRef)(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
23372
23423
  const props = resolveDesignProps5(rest);
23373
23424
  const { data, setLayout } = useEmbed();
23374
- const paymentMethod = (0, import_react37.useMemo)(() => {
23425
+ const paymentMethod = (0, import_react39.useMemo)(() => {
23375
23426
  return data.subscription?.paymentMethod || data.company?.defaultPaymentMethod;
23376
23427
  }, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
23377
- const monthsToExpiration = (0, import_react37.useMemo)(() => {
23428
+ const monthsToExpiration = (0, import_react39.useMemo)(() => {
23378
23429
  let expiration;
23379
23430
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
23380
23431
  const today = /* @__PURE__ */ new Date();
@@ -23555,7 +23606,7 @@ var loadStripe = function loadStripe2() {
23555
23606
  };
23556
23607
 
23557
23608
  // src/components/elements/payment-method/PaymentMethodDetails.tsx
23558
- var import_react38 = require("react");
23609
+ var import_react40 = require("react");
23559
23610
  var import_jsx_runtime34 = require("react/jsx-runtime");
23560
23611
  var resolveDesignProps6 = () => {
23561
23612
  return {
@@ -23577,14 +23628,14 @@ var PaymentMethodDetails = ({
23577
23628
  const theme = nt();
23578
23629
  const { api, data, setData } = useEmbed();
23579
23630
  const isLightBackground = useIsLightBackground();
23580
- const [isLoading, setIsLoading] = (0, import_react38.useState)(false);
23581
- const [error, setError] = (0, import_react38.useState)();
23582
- const [showPaymentForm, setShowPaymentForm] = (0, import_react38.useState)(false);
23583
- const [stripe, setStripe] = (0, import_react38.useState)(null);
23584
- const [setupIntent, setSetupIntent] = (0, import_react38.useState)();
23585
- const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react38.useState)(false);
23586
- const [paymentMethod, setPaymentMethod] = (0, import_react38.useState)(data.subscription?.paymentMethod || data.company?.defaultPaymentMethod);
23587
- const monthsToExpiration = (0, import_react38.useMemo)(() => {
23631
+ const [isLoading, setIsLoading] = (0, import_react40.useState)(false);
23632
+ const [error, setError] = (0, import_react40.useState)();
23633
+ const [showPaymentForm, setShowPaymentForm] = (0, import_react40.useState)(false);
23634
+ const [stripe, setStripe] = (0, import_react40.useState)(null);
23635
+ const [setupIntent, setSetupIntent] = (0, import_react40.useState)();
23636
+ const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react40.useState)(false);
23637
+ const [paymentMethod, setPaymentMethod] = (0, import_react40.useState)(data.subscription?.paymentMethod || data.company?.defaultPaymentMethod);
23638
+ const monthsToExpiration = (0, import_react40.useMemo)(() => {
23588
23639
  let expiration;
23589
23640
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
23590
23641
  const today = /* @__PURE__ */ new Date();
@@ -23597,7 +23648,7 @@ var PaymentMethodDetails = ({
23597
23648
  }
23598
23649
  return expiration;
23599
23650
  }, [paymentMethod?.cardExpYear, paymentMethod?.cardExpMonth]);
23600
- const createSetupIntent = (0, import_react38.useCallback)(async () => {
23651
+ const createSetupIntent = (0, import_react40.useCallback)(async () => {
23601
23652
  if (!api || !data.component?.id) {
23602
23653
  return;
23603
23654
  }
@@ -23616,7 +23667,7 @@ var PaymentMethodDetails = ({
23616
23667
  setIsLoading(false);
23617
23668
  }
23618
23669
  }, [t2, api, data.component?.id]);
23619
- const updatePaymentMethod = (0, import_react38.useCallback)(
23670
+ const updatePaymentMethod = (0, import_react40.useCallback)(
23620
23671
  async (externalId) => {
23621
23672
  if (!api || !externalId) {
23622
23673
  return;
@@ -23665,7 +23716,7 @@ var PaymentMethodDetails = ({
23665
23716
  },
23666
23717
  [api, data, setData, setPaymentMethodId, t2]
23667
23718
  );
23668
- const deletePaymentMethod = (0, import_react38.useCallback)(
23719
+ const deletePaymentMethod = (0, import_react40.useCallback)(
23669
23720
  async (id) => {
23670
23721
  if (!api || !id) {
23671
23722
  return;
@@ -23692,12 +23743,12 @@ var PaymentMethodDetails = ({
23692
23743
  },
23693
23744
  [api, data, setData, t2]
23694
23745
  );
23695
- (0, import_react38.useEffect)(() => {
23746
+ (0, import_react40.useEffect)(() => {
23696
23747
  if (!stripe && setupIntent?.publishableKey) {
23697
23748
  setStripe(loadStripe(setupIntent.publishableKey));
23698
23749
  }
23699
23750
  }, [stripe, setupIntent?.publishableKey]);
23700
- (0, import_react38.useEffect)(() => {
23751
+ (0, import_react40.useEffect)(() => {
23701
23752
  if (!setupIntent && (!paymentMethod || showPaymentForm)) {
23702
23753
  createSetupIntent();
23703
23754
  }
@@ -23834,7 +23885,7 @@ var PaymentMethodDetails = ({
23834
23885
  },
23835
23886
  paymentMethod2.id
23836
23887
  )) }),
23837
- (!setupIntent || !paymentMethod || showDifferentPaymentMethods) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Button, { onClick: createSetupIntent, $size: "lg", children: t2("Add new payment method") })
23888
+ (!setupIntent || !paymentMethod || showDifferentPaymentMethods) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Button, { onClick: createSetupIntent, $size: "lg", $fullWidth: true, children: t2("Add new payment method") })
23838
23889
  ] })
23839
23890
  ] }),
23840
23891
  !isLoading && error && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
@@ -23854,7 +23905,7 @@ var PaymentMethodDetails = ({
23854
23905
  };
23855
23906
 
23856
23907
  // src/components/elements/plan-manager/PlanManager.tsx
23857
- var import_react39 = require("react");
23908
+ var import_react41 = require("react");
23858
23909
  var import_jsx_runtime35 = require("react/jsx-runtime");
23859
23910
  var resolveDesignProps7 = (props) => {
23860
23911
  return {
@@ -23884,7 +23935,7 @@ var resolveDesignProps7 = (props) => {
23884
23935
  }
23885
23936
  };
23886
23937
  };
23887
- var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal, ...rest }, ref) => {
23938
+ var PlanManager = (0, import_react41.forwardRef)(({ children, className, portal, ...rest }, ref) => {
23888
23939
  const props = resolveDesignProps7(rest);
23889
23940
  const theme = nt();
23890
23941
  const { t: t2 } = useTranslation();
@@ -23910,7 +23961,7 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
23910
23961
  []
23911
23962
  );
23912
23963
  const billingSubscription = data.company?.billingSubscription;
23913
- const trialEndDays = (0, import_react39.useMemo)(() => {
23964
+ const trialEndDays = (0, import_react41.useMemo)(() => {
23914
23965
  const trialEnd = billingSubscription?.trialEnd;
23915
23966
  const trialEndDate = trialEnd ? new Date(trialEnd * 1e3) : /* @__PURE__ */ new Date();
23916
23967
  const todayDate = /* @__PURE__ */ new Date();
@@ -24182,6 +24233,7 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
24182
24233
  },
24183
24234
  $size: props.callToAction.buttonSize,
24184
24235
  $color: props.callToAction.buttonStyle,
24236
+ $fullWidth: true,
24185
24237
  children: t2("Change plan")
24186
24238
  }
24187
24239
  )
@@ -24193,7 +24245,7 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
24193
24245
  PlanManager.displayName = "PlanManager";
24194
24246
 
24195
24247
  // src/components/elements/pricing-table/PricingTable.tsx
24196
- var import_react40 = require("react");
24248
+ var import_react42 = require("react");
24197
24249
  var import_jsx_runtime36 = require("react/jsx-runtime");
24198
24250
  var resolveDesignProps8 = (props) => {
24199
24251
  return {
@@ -24234,18 +24286,18 @@ var resolveDesignProps8 = (props) => {
24234
24286
  }
24235
24287
  };
24236
24288
  };
24237
- var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...rest }, ref) => {
24289
+ var PricingTable = (0, import_react42.forwardRef)(({ children, className, ...rest }, ref) => {
24238
24290
  const props = resolveDesignProps8(rest);
24239
24291
  const { t: t2 } = useTranslation();
24240
24292
  const theme = nt();
24241
24293
  const { data, setLayout, setSelected } = useEmbed();
24242
24294
  const trialEndDays = useTrialEnd();
24243
- const [selectedPeriod, setSelectedPeriod] = (0, import_react40.useState)(
24295
+ const [selectedPeriod, setSelectedPeriod] = (0, import_react42.useState)(
24244
24296
  () => data.company?.plan?.planPeriod || "month"
24245
24297
  );
24246
24298
  const { plans, addOns, periods } = useAvailablePlans(selectedPeriod);
24247
24299
  const isLightBackground = useIsLightBackground();
24248
- const [entitlementCounts, setEntitlementCounts] = (0, import_react40.useState)(
24300
+ const [entitlementCounts, setEntitlementCounts] = (0, import_react42.useState)(
24249
24301
  () => plans.reduce(
24250
24302
  (acc, plan) => {
24251
24303
  acc[plan.id] = {
@@ -24699,6 +24751,7 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
24699
24751
  $color: props.downgrade.buttonStyle,
24700
24752
  $variant: "outline"
24701
24753
  },
24754
+ $fullWidth: true,
24702
24755
  children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
24703
24756
  ButtonLink,
24704
24757
  {
@@ -24709,12 +24762,12 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
24709
24762
  ) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
24710
24763
  Tooltip,
24711
24764
  {
24712
- trigger: t2("Over usage limit"),
24713
- content: t2(
24765
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Text, { children: t2("Over usage limit") }),
24766
+ content: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Text, { children: t2(
24714
24767
  "Current usage exceeds the limit of this plan."
24715
- )
24768
+ ) })
24716
24769
  }
24717
- ) : plan.companyCanTrial ? t2("Start X day trial", { days: plan.trialDays }) : t2("Choose plan")
24770
+ ) : plan.companyCanTrial && plan.isTrialable ? t2("Start X day trial", { days: plan.trialDays }) : t2("Choose plan")
24718
24771
  }
24719
24772
  )
24720
24773
  ]
@@ -24936,6 +24989,7 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
24936
24989
  $size: props.upgrade.buttonSize,
24937
24990
  $color: isActiveAddOn ? "danger" : props.upgrade.buttonStyle,
24938
24991
  $variant: isActiveAddOn ? "ghost" : addOn.current ? "outline" : "filled",
24992
+ $fullWidth: true,
24939
24993
  children: isActiveAddOn ? t2("Remove add-on") : addOn.current ? t2("Change add-on") : t2("Choose add-on")
24940
24994
  }
24941
24995
  )
@@ -24957,7 +25011,7 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
24957
25011
  PricingTable.displayName = "PricingTable";
24958
25012
 
24959
25013
  // src/components/elements/text/Text.tsx
24960
- var import_react41 = require("react");
25014
+ var import_react43 = require("react");
24961
25015
  var import_jsx_runtime37 = require("react/jsx-runtime");
24962
25016
  var resolveDesignProps9 = (props) => {
24963
25017
  return {
@@ -24968,7 +25022,7 @@ var resolveDesignProps9 = (props) => {
24968
25022
  }
24969
25023
  };
24970
25024
  };
24971
- var TextElement = (0, import_react41.forwardRef)(({ children, className, ...rest }, ref) => {
25025
+ var TextElement = (0, import_react43.forwardRef)(({ children, className, ...rest }, ref) => {
24972
25026
  const props = resolveDesignProps9(rest);
24973
25027
  const theme = nt();
24974
25028
  return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Element, { as: Flex, ref, className, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
@@ -24987,7 +25041,7 @@ var TextElement = (0, import_react41.forwardRef)(({ children, className, ...rest
24987
25041
  TextElement.displayName = "Text";
24988
25042
 
24989
25043
  // src/components/elements/unsubscribe-button/UnsubscribeButton.tsx
24990
- var import_react42 = require("react");
25044
+ var import_react44 = require("react");
24991
25045
  var import_jsx_runtime38 = require("react/jsx-runtime");
24992
25046
  var resolveDesignProps10 = (props) => {
24993
25047
  return {
@@ -25000,7 +25054,7 @@ var resolveDesignProps10 = (props) => {
25000
25054
  }
25001
25055
  };
25002
25056
  };
25003
- var UnsubscribeButton = (0, import_react42.forwardRef)(({ children, className, ...rest }, ref) => {
25057
+ var UnsubscribeButton = (0, import_react44.forwardRef)(({ children, className, ...rest }, ref) => {
25004
25058
  const props = resolveDesignProps10(rest);
25005
25059
  const { t: t2 } = useTranslation();
25006
25060
  const { data, setLayout } = useEmbed();
@@ -25048,7 +25102,21 @@ var UnsubscribeButton = (0, import_react42.forwardRef)(({ children, className, .
25048
25102
  UnsubscribeButton.displayName = "UnsubscribeButton";
25049
25103
 
25050
25104
  // src/components/elements/upcoming-bill/UpcomingBill.tsx
25051
- var import_react43 = require("react");
25105
+ var import_react45 = require("react");
25106
+
25107
+ // src/components/elements/upcoming-bill/styles.ts
25108
+ var Container4 = dt.div`
25109
+ height: auto;
25110
+ opacity: 1;
25111
+ transition: 0.1s;
25112
+
25113
+ @starting-style {
25114
+ height: 0;
25115
+ opacity: 0;
25116
+ }
25117
+ `;
25118
+
25119
+ // src/components/elements/upcoming-bill/UpcomingBill.tsx
25052
25120
  var import_jsx_runtime39 = require("react/jsx-runtime");
25053
25121
  function resolveDesignProps11(props) {
25054
25122
  return {
@@ -25068,139 +25136,179 @@ function resolveDesignProps11(props) {
25068
25136
  }
25069
25137
  };
25070
25138
  }
25071
- var UpcomingBill = (0, import_react43.forwardRef)(({ className, ...rest }, ref) => {
25139
+ var UpcomingBill = (0, import_react45.forwardRef)(({ className, ...rest }, ref) => {
25072
25140
  const props = resolveDesignProps11(rest);
25073
25141
  const { t: t2 } = useTranslation();
25074
25142
  const theme = nt();
25075
- const { data } = useEmbed();
25143
+ const { api, data } = useEmbed();
25076
25144
  const isLightBackground = useIsLightBackground();
25077
- const { discounts, upcomingInvoice } = (0, import_react43.useMemo)(() => {
25078
- const discounts2 = (data.subscription?.discounts || []).map((discount) => ({
25079
- amountOff: discount.amountOff,
25145
+ const [isLoading, setIsLoading] = (0, import_react45.useState)(false);
25146
+ const [error, setError] = (0, import_react45.useState)();
25147
+ const [upcomingInvoice, setUpcomingInvoice] = (0, import_react45.useState)();
25148
+ const discounts = (0, import_react45.useMemo)(() => {
25149
+ return (data.subscription?.discounts || []).map((discount) => ({
25080
25150
  couponId: discount.couponId,
25081
- customerFacingCode: discount.customerFacingCode,
25082
- isActive: discount.isActive,
25083
- percentOff: discount.percentOff
25151
+ customerFacingCode: discount.customerFacingCode || void 0,
25152
+ currency: discount.currency || void 0,
25153
+ amountOff: discount.amountOff ?? void 0,
25154
+ percentOff: discount.percentOff ?? void 0,
25155
+ isActive: discount.isActive
25084
25156
  }));
25085
- return {
25086
- discounts: discounts2,
25087
- upcomingInvoice: data.upcomingInvoice
25088
- };
25089
- }, [data.subscription, data.upcomingInvoice]);
25090
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25091
- Element,
25092
- {
25093
- as: Flex,
25094
- ref,
25095
- className,
25096
- $flexDirection: "column",
25097
- $gap: "1rem",
25098
- children: upcomingInvoice ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
25099
- props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
25100
- Text,
25101
- {
25102
- $font: theme.typography[props.header.fontStyle].fontFamily,
25103
- $size: theme.typography[props.header.fontStyle].fontSize,
25104
- $weight: theme.typography[props.header.fontStyle].fontWeight,
25105
- $color: theme.typography[props.header.fontStyle].color,
25106
- children: [
25107
- props.header.prefix,
25108
- " ",
25109
- toPrettyDate(upcomingInvoice.dueDate)
25110
- ]
25111
- }
25112
- ) }),
25113
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Flex, { $justifyContent: "space-between", $alignItems: "start", $gap: "1rem", children: [
25114
- props.price.isVisible && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Flex, { $alignItems: "end", $flexGrow: "1", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25115
- Text,
25116
- {
25117
- $font: theme.typography[props.price.fontStyle].fontFamily,
25118
- $size: theme.typography[props.price.fontStyle].fontSize,
25119
- $weight: theme.typography[props.price.fontStyle].fontWeight,
25120
- $color: theme.typography[props.price.fontStyle].color,
25121
- $leading: 1,
25122
- children: formatCurrency(
25123
- upcomingInvoice.amountDue,
25124
- upcomingInvoice.currency
25125
- )
25126
- }
25127
- ) }),
25128
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { $lineHeight: 1.15, $maxWidth: "10rem", $textAlign: "right", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25129
- Text,
25130
- {
25131
- $font: theme.typography[props.contractEndDate.fontStyle].fontFamily,
25132
- $size: theme.typography[props.contractEndDate.fontStyle].fontSize,
25133
- $weight: theme.typography[props.contractEndDate.fontStyle].fontWeight,
25134
- $color: theme.typography[props.contractEndDate.fontStyle].color,
25135
- $leading: 1,
25136
- children: t2("Estimated bill.")
25137
- }
25138
- ) })
25139
- ] }),
25140
- discounts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
25141
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25142
- Text,
25157
+ }, [data.subscription]);
25158
+ const loadInvoice = (0, import_react45.useCallback)(async () => {
25159
+ if (!api || !data.component?.id) {
25160
+ return;
25161
+ }
25162
+ try {
25163
+ setError(void 0);
25164
+ setIsLoading(true);
25165
+ const response = await api.hydrateUpcomingInvoice({
25166
+ componentId: data.component.id
25167
+ });
25168
+ setUpcomingInvoice(response.data);
25169
+ } catch (e2) {
25170
+ if (e2 instanceof Error) {
25171
+ setError(e2);
25172
+ }
25173
+ } finally {
25174
+ setIsLoading(false);
25175
+ }
25176
+ }, [api, data.component?.id]);
25177
+ (0, import_react45.useEffect)(() => {
25178
+ loadInvoice();
25179
+ }, [loadInvoice]);
25180
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Element, { ref, className, children: [
25181
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Flex, { as: Container4, $justifyContent: "center", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { $color: theme.primary, $isLoading: isLoading }) }),
25182
+ error ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
25183
+ Flex,
25184
+ {
25185
+ as: Container4,
25186
+ $flexDirection: "column",
25187
+ $justifyContent: "center",
25188
+ $alignItems: "center",
25189
+ $gap: "1rem",
25190
+ children: [
25191
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { $weight: 500, $color: "#DB6669", children: t2("There was a problem retrieving your upcoming invoice.") }),
25192
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25193
+ Button,
25143
25194
  {
25144
- $font: theme.typography.text.fontFamily,
25145
- $size: theme.typography.text.fontSize,
25146
- $weight: 600,
25147
- $color: theme.typography.text.color,
25148
- children: t2("Discount")
25195
+ onClick: () => loadInvoice(),
25196
+ $size: "sm",
25197
+ $variant: "ghost",
25198
+ $fullWidth: false,
25199
+ children: t2("Try again")
25149
25200
  }
25150
- ) }),
25151
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { children: discounts.map((discount) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
25152
- Flex,
25153
- {
25154
- $alignItems: "center",
25155
- $gap: "0.5rem",
25156
- children: [
25157
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25158
- Flex,
25159
- {
25160
- $alignItems: "center",
25161
- $padding: "0.1875rem 0.375rem",
25162
- $borderWidth: "1px",
25163
- $borderStyle: "solid",
25164
- $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.15)" : "hsla(0, 0%, 100%, 0.15)",
25165
- $borderRadius: "0.3125rem",
25166
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25167
- Text,
25168
- {
25169
- $font: theme.typography.text.fontFamily,
25170
- $size: 0.75 * theme.typography.text.fontSize,
25171
- $weight: theme.typography.text.fontWeight,
25172
- $color: theme.typography.text.color,
25173
- children: discount.customerFacingCode
25174
- }
25175
- )
25176
- }
25177
- ),
25178
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25179
- Text,
25180
- {
25181
- $font: theme.typography.text.fontFamily,
25182
- $size: theme.typography.text.fontSize,
25183
- $weight: theme.typography.text.fontWeight,
25184
- $color: theme.typography.text.color,
25185
- children: t2("Percent off", { percent: discount.percentOff })
25186
- }
25187
- ) })
25188
- ]
25189
- },
25190
- discount.couponId
25191
- )) })
25192
- ] })
25193
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { display: "heading2", children: t2("No upcoming invoice") })
25194
- }
25195
- );
25201
+ )
25202
+ ]
25203
+ }
25204
+ ) : !isLoading && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Container4, { children: upcomingInvoice ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Flex, { $flexDirection: "column", $gap: "1rem", children: [
25205
+ props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Text, { display: props.header.fontStyle, children: [
25206
+ props.header.prefix,
25207
+ " ",
25208
+ toPrettyDate(upcomingInvoice.dueDate)
25209
+ ] }),
25210
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
25211
+ Flex,
25212
+ {
25213
+ $justifyContent: "space-between",
25214
+ $alignItems: "start",
25215
+ $gap: "1rem",
25216
+ children: [
25217
+ props.price.isVisible && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { display: props.price.fontStyle, $leading: 1, children: formatCurrency(
25218
+ upcomingInvoice.amountDue,
25219
+ upcomingInvoice.currency
25220
+ ) }),
25221
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { $maxWidth: "10rem", $textAlign: "right", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { display: props.contractEndDate.fontStyle, children: t2("Estimated bill.") }) })
25222
+ ]
25223
+ }
25224
+ ),
25225
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
25226
+ Flex,
25227
+ {
25228
+ $justifyContent: "space-between",
25229
+ $alignItems: "center",
25230
+ $gap: "1rem",
25231
+ children: [
25232
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { $weight: 600, children: t2("Remaining balance") }),
25233
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { children: formatCurrency(5e3, upcomingInvoice.currency) })
25234
+ ]
25235
+ }
25236
+ ),
25237
+ discounts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
25238
+ Flex,
25239
+ {
25240
+ $justifyContent: "space-between",
25241
+ $alignItems: "start",
25242
+ $gap: "1rem",
25243
+ children: [
25244
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { $weight: 600, children: t2("Discount") }),
25245
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25246
+ Flex,
25247
+ {
25248
+ $flexDirection: "column",
25249
+ $alignItems: "end",
25250
+ $gap: "0.5rem",
25251
+ children: discounts.reduce(
25252
+ (acc, discount) => {
25253
+ if (typeof discount.customerFacingCode === "string" && (typeof discount.percentOff === "number" || typeof discount.amountOff === "number")) {
25254
+ acc.push(
25255
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
25256
+ Flex,
25257
+ {
25258
+ $alignItems: "center",
25259
+ $gap: "0.5rem",
25260
+ children: [
25261
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25262
+ Flex,
25263
+ {
25264
+ $alignItems: "center",
25265
+ $padding: "0.1875rem 0.375rem",
25266
+ $borderWidth: "1px",
25267
+ $borderStyle: "solid",
25268
+ $borderColor: isLightBackground ? "hsla(0, 0%, 0%, 0.15)" : "hsla(0, 0%, 100%, 0.15)",
25269
+ $borderRadius: "0.3125rem",
25270
+ children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
25271
+ Text,
25272
+ {
25273
+ $size: 0.75 * theme.typography.text.fontSize,
25274
+ children: discount.customerFacingCode
25275
+ }
25276
+ )
25277
+ }
25278
+ ),
25279
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { children: typeof discount.percentOff === "number" ? t2("Percent off", {
25280
+ percent: discount.percentOff
25281
+ }) : t2("Amount off", {
25282
+ amount: formatCurrency(
25283
+ discount.amountOff,
25284
+ discount?.currency
25285
+ )
25286
+ }) }) })
25287
+ ]
25288
+ },
25289
+ discount.couponId
25290
+ )
25291
+ );
25292
+ }
25293
+ return acc;
25294
+ },
25295
+ []
25296
+ )
25297
+ }
25298
+ )
25299
+ ]
25300
+ }
25301
+ )
25302
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Text, { display: "heading2", children: t2("No upcoming invoice") }) })
25303
+ ] });
25196
25304
  });
25197
25305
  UpcomingBill.displayName = "UpcomingBill";
25198
25306
 
25199
25307
  // src/components/embed/ComponentTree.tsx
25200
- var import_react45 = require("react");
25308
+ var import_react47 = require("react");
25201
25309
 
25202
25310
  // src/components/embed/renderer.ts
25203
- var import_react44 = require("react");
25311
+ var import_react46 = require("react");
25204
25312
  var components = {
25205
25313
  Root,
25206
25314
  Viewport,
@@ -25235,7 +25343,7 @@ function createRenderer(options2) {
25235
25343
  const { className, ...rest } = props;
25236
25344
  const resolvedProps = component === "div" ? rest : props;
25237
25345
  const resolvedChildren = children.map(renderNode);
25238
- return (0, import_react44.createElement)(
25346
+ return (0, import_react46.createElement)(
25239
25347
  component,
25240
25348
  {
25241
25349
  key: index,
@@ -25304,8 +25412,8 @@ var Error2 = ({ message }) => {
25304
25412
  };
25305
25413
  var ComponentTree = () => {
25306
25414
  const { error, nodes, isPending } = useEmbed();
25307
- const [children, setChildren] = (0, import_react45.useState)(/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Loading, {}));
25308
- (0, import_react45.useEffect)(() => {
25415
+ const [children, setChildren] = (0, import_react47.useState)(/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Loading, {}));
25416
+ (0, import_react47.useEffect)(() => {
25309
25417
  const renderer = createRenderer();
25310
25418
  setChildren(nodes.map(renderer));
25311
25419
  }, [nodes]);