@schematichq/schematic-components 0.1.0 → 0.2.0

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.
@@ -6750,143 +6750,6 @@ var inflate_1 = inflate;
6750
6750
  // src/context/embed.tsx
6751
6751
  var import_lodash = __toESM(require_lodash());
6752
6752
 
6753
- // node_modules/@stripe/stripe-js/dist/index.mjs
6754
- var V3_URL = "https://js.stripe.com/v3";
6755
- var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
6756
- var EXISTING_SCRIPT_MESSAGE = "loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";
6757
- var findScript = function findScript2() {
6758
- var scripts = document.querySelectorAll('script[src^="'.concat(V3_URL, '"]'));
6759
- for (var i2 = 0; i2 < scripts.length; i2++) {
6760
- var script = scripts[i2];
6761
- if (!V3_URL_REGEX.test(script.src)) {
6762
- continue;
6763
- }
6764
- return script;
6765
- }
6766
- return null;
6767
- };
6768
- var injectScript = function injectScript2(params) {
6769
- var queryString = params && !params.advancedFraudSignals ? "?advancedFraudSignals=false" : "";
6770
- var script = document.createElement("script");
6771
- script.src = "".concat(V3_URL).concat(queryString);
6772
- var headOrBody = document.head || document.body;
6773
- if (!headOrBody) {
6774
- throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
6775
- }
6776
- headOrBody.appendChild(script);
6777
- return script;
6778
- };
6779
- var registerWrapper = function registerWrapper2(stripe, startTime) {
6780
- if (!stripe || !stripe._registerWrapper) {
6781
- return;
6782
- }
6783
- stripe._registerWrapper({
6784
- name: "stripe-js",
6785
- version: "4.4.0",
6786
- startTime
6787
- });
6788
- };
6789
- var stripePromise = null;
6790
- var onErrorListener = null;
6791
- var onLoadListener = null;
6792
- var onError = function onError2(reject) {
6793
- return function() {
6794
- reject(new Error("Failed to load Stripe.js"));
6795
- };
6796
- };
6797
- var onLoad = function onLoad2(resolve, reject) {
6798
- return function() {
6799
- if (window.Stripe) {
6800
- resolve(window.Stripe);
6801
- } else {
6802
- reject(new Error("Stripe.js not available"));
6803
- }
6804
- };
6805
- };
6806
- var loadScript = function loadScript2(params) {
6807
- if (stripePromise !== null) {
6808
- return stripePromise;
6809
- }
6810
- stripePromise = new Promise(function(resolve, reject) {
6811
- if (typeof window === "undefined" || typeof document === "undefined") {
6812
- resolve(null);
6813
- return;
6814
- }
6815
- if (window.Stripe && params) {
6816
- console.warn(EXISTING_SCRIPT_MESSAGE);
6817
- }
6818
- if (window.Stripe) {
6819
- resolve(window.Stripe);
6820
- return;
6821
- }
6822
- try {
6823
- var script = findScript();
6824
- if (script && params) {
6825
- console.warn(EXISTING_SCRIPT_MESSAGE);
6826
- } else if (!script) {
6827
- script = injectScript(params);
6828
- } else if (script && onLoadListener !== null && onErrorListener !== null) {
6829
- var _script$parentNode;
6830
- script.removeEventListener("load", onLoadListener);
6831
- script.removeEventListener("error", onErrorListener);
6832
- (_script$parentNode = script.parentNode) === null || _script$parentNode === void 0 ? void 0 : _script$parentNode.removeChild(script);
6833
- script = injectScript(params);
6834
- }
6835
- onLoadListener = onLoad(resolve, reject);
6836
- onErrorListener = onError(reject);
6837
- script.addEventListener("load", onLoadListener);
6838
- script.addEventListener("error", onErrorListener);
6839
- } catch (error) {
6840
- reject(error);
6841
- return;
6842
- }
6843
- });
6844
- return stripePromise["catch"](function(error) {
6845
- stripePromise = null;
6846
- return Promise.reject(error);
6847
- });
6848
- };
6849
- var initStripe = function initStripe2(maybeStripe, args, startTime) {
6850
- if (maybeStripe === null) {
6851
- return null;
6852
- }
6853
- var stripe = maybeStripe.apply(void 0, args);
6854
- registerWrapper(stripe, startTime);
6855
- return stripe;
6856
- };
6857
- var stripePromise$1;
6858
- var loadCalled = false;
6859
- var getStripePromise = function getStripePromise2() {
6860
- if (stripePromise$1) {
6861
- return stripePromise$1;
6862
- }
6863
- stripePromise$1 = loadScript(null)["catch"](function(error) {
6864
- stripePromise$1 = null;
6865
- return Promise.reject(error);
6866
- });
6867
- return stripePromise$1;
6868
- };
6869
- Promise.resolve().then(function() {
6870
- return getStripePromise();
6871
- })["catch"](function(error) {
6872
- if (!loadCalled) {
6873
- console.warn(error);
6874
- }
6875
- });
6876
- var loadStripe = function loadStripe2() {
6877
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6878
- args[_key] = arguments[_key];
6879
- }
6880
- loadCalled = true;
6881
- var startTime = Date.now();
6882
- return getStripePromise().then(function(maybeStripe) {
6883
- return initStripe(maybeStripe, args, startTime);
6884
- });
6885
- };
6886
-
6887
- // src/context/embed.tsx
6888
- import { Elements } from "@stripe/react-stripe-js";
6889
-
6890
6753
  // src/api/runtime.ts
6891
6754
  var BASE_PATH = "https://api.schematichq.com".replace(/\/+$/, "");
6892
6755
  var Configuration = class {
@@ -7218,10 +7081,10 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
7218
7081
  environmentId: json["environment_id"],
7219
7082
  externalId: json["external_id"],
7220
7083
  id: json["id"],
7221
- interval: json["interval"] == null ? void 0 : json["interval"],
7084
+ interval: json["interval"],
7222
7085
  name: json["name"],
7223
7086
  price: json["price"],
7224
- priceExternalId: json["price_external_id"] == null ? void 0 : json["price_external_id"],
7087
+ priceExternalId: json["price_external_id"],
7225
7088
  quantity: json["quantity"],
7226
7089
  subscriptionId: json["subscription_id"],
7227
7090
  updatedAt: new Date(json["updated_at"])
@@ -7733,6 +7596,7 @@ function CompanySubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator)
7733
7596
  products: json["products"].map(
7734
7597
  BillingProductForSubscriptionResponseDataFromJSON
7735
7598
  ),
7599
+ status: json["status"],
7736
7600
  subscriptionExternalId: json["subscription_external_id"],
7737
7601
  totalPrice: json["total_price"]
7738
7602
  };
@@ -8489,7 +8353,6 @@ var EmbedContext = createContext({
8489
8353
  },
8490
8354
  nodes: [],
8491
8355
  settings: { ...defaultSettings },
8492
- stripe: null,
8493
8356
  layout: "portal",
8494
8357
  error: void 0,
8495
8358
  isPending: false,
@@ -8499,8 +8362,6 @@ var EmbedContext = createContext({
8499
8362
  },
8500
8363
  updateSettings: () => {
8501
8364
  },
8502
- setStripe: () => {
8503
- },
8504
8365
  setLayout: () => {
8505
8366
  }
8506
8367
  });
@@ -8519,7 +8380,6 @@ var EmbedProvider = ({
8519
8380
  },
8520
8381
  nodes: [],
8521
8382
  settings: { ...defaultSettings },
8522
- stripe: null,
8523
8383
  layout: "portal",
8524
8384
  isPending: false,
8525
8385
  error: void 0,
@@ -8529,8 +8389,6 @@ var EmbedProvider = ({
8529
8389
  },
8530
8390
  updateSettings: () => {
8531
8391
  },
8532
- setStripe: () => {
8533
- },
8534
8392
  setLayout: () => {
8535
8393
  }
8536
8394
  };
@@ -8556,16 +8414,11 @@ var EmbedProvider = ({
8556
8414
  nodes.push(...parseEditorState(ast));
8557
8415
  }
8558
8416
  }
8559
- let stripe = null;
8560
- if (data.stripeEmbed?.publishableKey) {
8561
- stripe = loadStripe(data.stripeEmbed.publishableKey);
8562
- }
8563
8417
  setState((prev2) => ({
8564
8418
  ...prev2,
8565
8419
  data,
8566
8420
  nodes,
8567
8421
  settings,
8568
- stripe,
8569
8422
  isPending: false
8570
8423
  }));
8571
8424
  } catch (error) {
@@ -8600,15 +8453,6 @@ var EmbedProvider = ({
8600
8453
  },
8601
8454
  [setState]
8602
8455
  );
8603
- const setStripe = useCallback(
8604
- (stripe) => {
8605
- setState((prev2) => ({
8606
- ...prev2,
8607
- stripe
8608
- }));
8609
- },
8610
- [setState]
8611
- );
8612
8456
  const setLayout = useCallback(
8613
8457
  (layout) => {
8614
8458
  setState((prev2) => ({
@@ -8630,12 +8474,11 @@ var EmbedProvider = ({
8630
8474
  styleRef.current = style;
8631
8475
  }, []);
8632
8476
  useEffect(() => {
8633
- if (!accessToken) {
8634
- return;
8477
+ if (accessToken) {
8478
+ const config = new Configuration({ ...apiConfig, apiKey: accessToken });
8479
+ const api = new CheckoutApi(config);
8480
+ setState((prev2) => ({ ...prev2, api }));
8635
8481
  }
8636
- const config = new Configuration({ ...apiConfig, apiKey: accessToken });
8637
- const api = new CheckoutApi(config);
8638
- setState((prev2) => ({ ...prev2, api }));
8639
8482
  }, [accessToken, apiConfig]);
8640
8483
  useEffect(() => {
8641
8484
  hydrate();
@@ -8652,47 +8495,6 @@ var EmbedProvider = ({
8652
8495
  }
8653
8496
  }
8654
8497
  }, [state.settings.theme.typography]);
8655
- const renderChildren = () => {
8656
- if (state.stripe) {
8657
- return /* @__PURE__ */ jsx(
8658
- Elements,
8659
- {
8660
- stripe: state.stripe,
8661
- options: {
8662
- appearance: {
8663
- theme: "stripe",
8664
- variables: {
8665
- // Base
8666
- fontFamily: '"Public Sans", system-ui, sans-serif',
8667
- spacingUnit: "0.25rem",
8668
- borderRadius: "0.5rem",
8669
- colorText: "#30313D",
8670
- colorBackground: "#FFFFFF",
8671
- colorPrimary: "#0570DE",
8672
- colorDanger: "#DF1B41",
8673
- // Layout
8674
- gridRowSpacing: "1.5rem",
8675
- gridColumnSpacing: "1.5rem"
8676
- },
8677
- rules: {
8678
- ".Label": {
8679
- fontSize: "1rem",
8680
- fontWeight: "400",
8681
- marginBottom: "0.75rem",
8682
- color: state.settings.theme.typography.text.color
8683
- }
8684
- }
8685
- },
8686
- ...state.data.stripeEmbed?.setupIntentClientSecret ? {
8687
- clientSecret: state.data.stripeEmbed?.setupIntentClientSecret
8688
- } : { mode: "payment", currency: "usd", amount: 999999 }
8689
- },
8690
- children
8691
- }
8692
- );
8693
- }
8694
- return children;
8695
- };
8696
8498
  return /* @__PURE__ */ jsx(
8697
8499
  EmbedContext.Provider,
8698
8500
  {
@@ -8701,19 +8503,17 @@ var EmbedProvider = ({
8701
8503
  data: state.data,
8702
8504
  nodes: state.nodes,
8703
8505
  settings: state.settings,
8704
- stripe: state.stripe,
8705
8506
  layout: state.layout,
8706
8507
  error: state.error,
8707
8508
  isPending: state.isPending,
8708
8509
  hydrate,
8709
8510
  setData,
8710
8511
  updateSettings,
8711
- setStripe,
8712
8512
  setLayout
8713
8513
  },
8714
8514
  children: /* @__PURE__ */ jsxs(ot, { theme: state.settings.theme, children: [
8715
8515
  /* @__PURE__ */ jsx(GlobalStyle, {}),
8716
- renderChildren()
8516
+ children
8717
8517
  ] })
8718
8518
  }
8719
8519
  );
@@ -8906,22 +8706,57 @@ var Box = dt.div((props) => {
8906
8706
  }, initialStyles);
8907
8707
  });
8908
8708
 
8909
- // src/components/ui/text/styles.ts
8910
- var Text = dt.span`
8911
- font-family: ${({ $font = "Inter" }) => `${$font}, sans-serif`};
8912
- font-size: ${({ $size = 16 }) => typeof $size === "number" ? `${$size / TEXT_BASE_SIZE}rem` : $size};
8913
- ${({ $weight = 400 }) => lt`
8914
- font-weight: ${$weight};
8915
- font-variation-settings: "wght" ${$weight};
8916
- `};
8917
- line-height: ${({ $lineHeight = 1.25 }) => $lineHeight};
8918
- ${({ $align }) => attr("text-align", $align)};
8919
- color: ${({ $color, theme }) => $color || theme.typography.text.color};
8709
+ // src/components/ui/loader/styles.ts
8710
+ var spin = mt`
8711
+ 0% {
8712
+ transform: rotate(0deg);
8713
+ }
8920
8714
 
8921
- &:focus-visible {
8922
- outline: 2px solid ${({ theme }) => theme.primary};
8923
- outline-offset: 2px;
8715
+ 100% {
8716
+ transform: rotate(360deg);
8717
+ }
8718
+ `;
8719
+ var Loader = dt.div`
8720
+ display: inline-block;
8721
+ border-style: solid;
8722
+ border-color: hsla(0, 0%, 50%, 0.125);
8723
+ border-top-color: ${({ theme, $color }) => $color || theme.primary};
8724
+ border-radius: 50%;
8725
+ transition: all 0.1s;
8726
+ animation: ${spin} 1.5s linear infinite;
8727
+
8728
+ ${({ $size = "md", $isLoading = true }) => {
8729
+ let px;
8730
+ switch ($size) {
8731
+ case "xs":
8732
+ px = 16;
8733
+ break;
8734
+ case "sm":
8735
+ px = 24;
8736
+ break;
8737
+ default:
8738
+ case "md":
8739
+ px = 32;
8740
+ break;
8741
+ case "lg":
8742
+ px = 40;
8743
+ break;
8744
+ case "xl":
8745
+ px = 48;
8746
+ break;
8747
+ case "2xl":
8748
+ px = 56;
8749
+ break;
8750
+ case "3xl":
8751
+ px = 64;
8752
+ break;
8924
8753
  }
8754
+ return lt`
8755
+ width: ${($isLoading ? px : 0) / TEXT_BASE_SIZE}rem;
8756
+ height: ${($isLoading ? px : 0) / TEXT_BASE_SIZE}rem;
8757
+ border-width: ${($isLoading ? px : 0) / 16 / TEXT_BASE_SIZE}rem;
8758
+ `;
8759
+ }}
8925
8760
  `;
8926
8761
 
8927
8762
  // src/components/ui/button/styles.ts
@@ -8930,8 +8765,11 @@ var Button = dt.button`
8930
8765
  font-family: Manrope, Arial, Helvetica, sans-serif;
8931
8766
  font-weight: 800;
8932
8767
  line-height: 1;
8768
+ display: flex;
8769
+ justify-content: center;
8770
+ align-items: center;
8771
+ gap: 0.5rem;
8933
8772
  border: 1px solid transparent;
8934
- transition-property: all;
8935
8773
 
8936
8774
  &:hover {
8937
8775
  cursor: pointer;
@@ -9009,16 +8847,17 @@ var Button = dt.button`
9009
8847
  `;
9010
8848
 
9011
8849
  // src/components/ui/button/Button.tsx
9012
- import { jsx as jsx2 } from "react/jsx-runtime";
8850
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
9013
8851
  var Button2 = ({
9014
8852
  color = "white",
9015
8853
  size = "md",
9016
8854
  variant = "solid",
9017
8855
  disabled = false,
8856
+ isLoading = false,
9018
8857
  children,
9019
8858
  ...props
9020
8859
  }) => {
9021
- return /* @__PURE__ */ jsx2(
8860
+ return /* @__PURE__ */ jsxs2(
9022
8861
  Button,
9023
8862
  {
9024
8863
  $color: color,
@@ -9026,7 +8865,10 @@ var Button2 = ({
9026
8865
  $variant: variant,
9027
8866
  disabled,
9028
8867
  ...props,
9029
- children
8868
+ children: [
8869
+ /* @__PURE__ */ jsx2(Loader, { $size: "sm", $isLoading: isLoading }),
8870
+ children
8871
+ ]
9030
8872
  }
9031
8873
  );
9032
8874
  };
@@ -9120,25 +8962,6 @@ var IconRound = ({
9120
8962
  return /* @__PURE__ */ jsx4(Container, { $size: size, $variant: variant, $colors: colors, ...props, children: /* @__PURE__ */ jsx4(Icon2, { name }) });
9121
8963
  };
9122
8964
 
9123
- // src/components/ui/loader/styles.ts
9124
- var spin = mt`
9125
- 0% {
9126
- transform: rotate(0deg);
9127
- }
9128
- 100% {
9129
- transform: rotate(360deg);
9130
- }
9131
- `;
9132
- var Loader = dt.div`
9133
- border: ${4 / TEXT_BASE_SIZE}rem solid hsla(0, 0%, 50%, 0.125);
9134
- border-top: ${4 / TEXT_BASE_SIZE}rem solid ${({ theme }) => theme.secondary};
9135
- border-radius: 50%;
9136
- width: ${56 / TEXT_BASE_SIZE}rem;
9137
- height: ${56 / TEXT_BASE_SIZE}rem;
9138
- animation: ${spin} 1.5s linear infinite;
9139
- display: inline-block;
9140
- `;
9141
-
9142
8965
  // src/components/ui/modal/Modal.tsx
9143
8966
  import { useCallback as useCallback2, useEffect as useEffect2, useMemo, useRef as useRef2 } from "react";
9144
8967
  import { jsx as jsx5 } from "react/jsx-runtime";
@@ -9192,8 +9015,8 @@ var Modal = ({ children, size = "auto", onClose }) => {
9192
9015
  ...size === "auto" ? { $width: "min-content", $height: "min-content" } : {
9193
9016
  $width: "100%",
9194
9017
  $height: "100%",
9195
- $maxWidth: "1366px",
9196
- $maxHeight: "768px"
9018
+ $maxWidth: "1356px",
9019
+ $maxHeight: "860px"
9197
9020
  },
9198
9021
  $backgroundColor: theme.card.background,
9199
9022
  $borderRadius: "0.5rem",
@@ -9211,7 +9034,7 @@ var Modal = ({ children, size = "auto", onClose }) => {
9211
9034
 
9212
9035
  // src/components/ui/modal/ModalHeader.tsx
9213
9036
  import { useCallback as useCallback3, useMemo as useMemo2 } from "react";
9214
- import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
9037
+ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
9215
9038
  var ModalHeader = ({
9216
9039
  children,
9217
9040
  bordered = false,
@@ -9226,7 +9049,7 @@ var ModalHeader = ({
9226
9049
  setLayout("portal");
9227
9050
  onClose?.();
9228
9051
  }, [setLayout, onClose]);
9229
- return /* @__PURE__ */ jsxs2(
9052
+ return /* @__PURE__ */ jsxs3(
9230
9053
  Flex,
9231
9054
  {
9232
9055
  $justifyContent: children ? "space-between" : "end",
@@ -9263,7 +9086,7 @@ var Container2 = dt(Flex)`
9263
9086
  `;
9264
9087
 
9265
9088
  // src/components/ui/progress-bar/ProgressBar.tsx
9266
- import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
9089
+ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
9267
9090
  var ProgressBar = ({
9268
9091
  progress,
9269
9092
  value,
@@ -9279,7 +9102,7 @@ var ProgressBar = ({
9279
9102
  orange: "#DB6769",
9280
9103
  red: "#EF4444"
9281
9104
  };
9282
- return /* @__PURE__ */ jsxs3(
9105
+ return /* @__PURE__ */ jsxs4(
9283
9106
  Container2,
9284
9107
  {
9285
9108
  $alignItems: "center",
@@ -9315,7 +9138,7 @@ var ProgressBar = ({
9315
9138
  )
9316
9139
  }
9317
9140
  ),
9318
- total !== 0 && /* @__PURE__ */ jsxs3(Text, { $size: 14, $weight: 500, children: [
9141
+ total !== 0 && /* @__PURE__ */ jsxs4(Text, { $size: 14, $weight: 500, children: [
9319
9142
  value,
9320
9143
  "/",
9321
9144
  total
@@ -9325,20 +9148,183 @@ var ProgressBar = ({
9325
9148
  );
9326
9149
  };
9327
9150
 
9151
+ // src/components/ui/text/styles.ts
9152
+ var Text = dt.span`
9153
+ font-family: ${({ $font = "Inter" }) => `${$font}, sans-serif`};
9154
+ font-size: ${({ $size = 16 }) => typeof $size === "number" ? `${$size / TEXT_BASE_SIZE}rem` : $size};
9155
+ ${({ $weight = 400 }) => lt`
9156
+ font-weight: ${$weight};
9157
+ font-variation-settings: "wght" ${$weight};
9158
+ `};
9159
+ line-height: ${({ $lineHeight = 1.25 }) => $lineHeight};
9160
+ ${({ $align }) => attr("text-align", $align)};
9161
+ color: ${({ $color, theme }) => $color || theme.typography.text.color};
9162
+
9163
+ &:focus-visible {
9164
+ outline: 2px solid ${({ theme }) => theme.primary};
9165
+ outline-offset: 2px;
9166
+ }
9167
+ `;
9168
+
9328
9169
  // src/components/elements/plan-manager/CheckoutDialog.tsx
9329
- import { useCallback as useCallback4, useMemo as useMemo4, useState as useState3 } from "react";
9170
+ import {
9171
+ useCallback as useCallback4,
9172
+ useEffect as useEffect3,
9173
+ useLayoutEffect,
9174
+ useMemo as useMemo4,
9175
+ useState as useState3
9176
+ } from "react";
9330
9177
  var import_pluralize = __toESM(require_pluralize());
9331
9178
 
9332
- // src/components/elements/payment-method/PaymentMethod.tsx
9333
- import { forwardRef, useMemo as useMemo3 } from "react";
9334
- import { createPortal } from "react-dom";
9335
-
9336
- // src/components/elements/plan-manager/styles.ts
9337
- var StyledButton = dt(Button2)`
9179
+ // node_modules/@stripe/stripe-js/dist/index.mjs
9180
+ var V3_URL = "https://js.stripe.com/v3";
9181
+ var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
9182
+ var EXISTING_SCRIPT_MESSAGE = "loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";
9183
+ var findScript = function findScript2() {
9184
+ var scripts = document.querySelectorAll('script[src^="'.concat(V3_URL, '"]'));
9185
+ for (var i2 = 0; i2 < scripts.length; i2++) {
9186
+ var script = scripts[i2];
9187
+ if (!V3_URL_REGEX.test(script.src)) {
9188
+ continue;
9189
+ }
9190
+ return script;
9191
+ }
9192
+ return null;
9193
+ };
9194
+ var injectScript = function injectScript2(params) {
9195
+ var queryString = params && !params.advancedFraudSignals ? "?advancedFraudSignals=false" : "";
9196
+ var script = document.createElement("script");
9197
+ script.src = "".concat(V3_URL).concat(queryString);
9198
+ var headOrBody = document.head || document.body;
9199
+ if (!headOrBody) {
9200
+ throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
9201
+ }
9202
+ headOrBody.appendChild(script);
9203
+ return script;
9204
+ };
9205
+ var registerWrapper = function registerWrapper2(stripe, startTime) {
9206
+ if (!stripe || !stripe._registerWrapper) {
9207
+ return;
9208
+ }
9209
+ stripe._registerWrapper({
9210
+ name: "stripe-js",
9211
+ version: "4.4.0",
9212
+ startTime
9213
+ });
9214
+ };
9215
+ var stripePromise = null;
9216
+ var onErrorListener = null;
9217
+ var onLoadListener = null;
9218
+ var onError = function onError2(reject) {
9219
+ return function() {
9220
+ reject(new Error("Failed to load Stripe.js"));
9221
+ };
9222
+ };
9223
+ var onLoad = function onLoad2(resolve, reject) {
9224
+ return function() {
9225
+ if (window.Stripe) {
9226
+ resolve(window.Stripe);
9227
+ } else {
9228
+ reject(new Error("Stripe.js not available"));
9229
+ }
9230
+ };
9231
+ };
9232
+ var loadScript = function loadScript2(params) {
9233
+ if (stripePromise !== null) {
9234
+ return stripePromise;
9235
+ }
9236
+ stripePromise = new Promise(function(resolve, reject) {
9237
+ if (typeof window === "undefined" || typeof document === "undefined") {
9238
+ resolve(null);
9239
+ return;
9240
+ }
9241
+ if (window.Stripe && params) {
9242
+ console.warn(EXISTING_SCRIPT_MESSAGE);
9243
+ }
9244
+ if (window.Stripe) {
9245
+ resolve(window.Stripe);
9246
+ return;
9247
+ }
9248
+ try {
9249
+ var script = findScript();
9250
+ if (script && params) {
9251
+ console.warn(EXISTING_SCRIPT_MESSAGE);
9252
+ } else if (!script) {
9253
+ script = injectScript(params);
9254
+ } else if (script && onLoadListener !== null && onErrorListener !== null) {
9255
+ var _script$parentNode;
9256
+ script.removeEventListener("load", onLoadListener);
9257
+ script.removeEventListener("error", onErrorListener);
9258
+ (_script$parentNode = script.parentNode) === null || _script$parentNode === void 0 ? void 0 : _script$parentNode.removeChild(script);
9259
+ script = injectScript(params);
9260
+ }
9261
+ onLoadListener = onLoad(resolve, reject);
9262
+ onErrorListener = onError(reject);
9263
+ script.addEventListener("load", onLoadListener);
9264
+ script.addEventListener("error", onErrorListener);
9265
+ } catch (error) {
9266
+ reject(error);
9267
+ return;
9268
+ }
9269
+ });
9270
+ return stripePromise["catch"](function(error) {
9271
+ stripePromise = null;
9272
+ return Promise.reject(error);
9273
+ });
9274
+ };
9275
+ var initStripe = function initStripe2(maybeStripe, args, startTime) {
9276
+ if (maybeStripe === null) {
9277
+ return null;
9278
+ }
9279
+ var stripe = maybeStripe.apply(void 0, args);
9280
+ registerWrapper(stripe, startTime);
9281
+ return stripe;
9282
+ };
9283
+ var stripePromise$1;
9284
+ var loadCalled = false;
9285
+ var getStripePromise = function getStripePromise2() {
9286
+ if (stripePromise$1) {
9287
+ return stripePromise$1;
9288
+ }
9289
+ stripePromise$1 = loadScript(null)["catch"](function(error) {
9290
+ stripePromise$1 = null;
9291
+ return Promise.reject(error);
9292
+ });
9293
+ return stripePromise$1;
9294
+ };
9295
+ Promise.resolve().then(function() {
9296
+ return getStripePromise();
9297
+ })["catch"](function(error) {
9298
+ if (!loadCalled) {
9299
+ console.warn(error);
9300
+ }
9301
+ });
9302
+ var loadStripe = function loadStripe2() {
9303
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
9304
+ args[_key] = arguments[_key];
9305
+ }
9306
+ loadCalled = true;
9307
+ var startTime = Date.now();
9308
+ return getStripePromise().then(function(maybeStripe) {
9309
+ return initStripe(maybeStripe, args, startTime);
9310
+ });
9311
+ };
9312
+
9313
+ // src/components/elements/plan-manager/CheckoutDialog.tsx
9314
+ import { Elements } from "@stripe/react-stripe-js";
9315
+
9316
+ // src/components/elements/payment-method/PaymentMethod.tsx
9317
+ import { forwardRef, useMemo as useMemo3 } from "react";
9318
+ import { createPortal } from "react-dom";
9319
+
9320
+ // src/components/elements/plan-manager/styles.ts
9321
+ var StyledButton = dt(Button2)`
9338
9322
  font-family: "Public Sans", sans-serif;
9339
9323
  font-weight: 500;
9340
9324
  text-align: center;
9341
9325
  width: 100%;
9326
+ padding: 0;
9327
+
9342
9328
  ${({ disabled, $color = "primary", theme }) => {
9343
9329
  const { l: l2 } = hexToHSL(theme[$color]);
9344
9330
  let textColor;
@@ -9414,19 +9400,19 @@ var StyledButton = dt(Button2)`
9414
9400
  case "sm":
9415
9401
  return lt`
9416
9402
  font-size: ${15 / TEXT_BASE_SIZE}rem;
9417
- padding: ${12 / TEXT_BASE_SIZE}rem 0;
9403
+ height: ${40 / TEXT_BASE_SIZE}rem;
9418
9404
  border-radius: ${6 / TEXT_BASE_SIZE}rem;
9419
9405
  `;
9420
9406
  case "md":
9421
9407
  return lt`
9422
9408
  font-size: ${17 / TEXT_BASE_SIZE}rem;
9423
- padding: ${16 / TEXT_BASE_SIZE}rem 0;
9409
+ height: ${52 / TEXT_BASE_SIZE}rem;
9424
9410
  border-radius: ${8 / TEXT_BASE_SIZE}rem;
9425
9411
  `;
9426
9412
  case "lg":
9427
9413
  return lt`
9428
9414
  font-size: ${19 / TEXT_BASE_SIZE}rem;
9429
- padding: ${20 / TEXT_BASE_SIZE}rem 0;
9415
+ height: ${64 / TEXT_BASE_SIZE}rem;
9430
9416
  border-radius: ${10 / TEXT_BASE_SIZE}rem;
9431
9417
  `;
9432
9418
  }
@@ -9434,7 +9420,7 @@ var StyledButton = dt(Button2)`
9434
9420
  `;
9435
9421
 
9436
9422
  // src/components/elements/payment-method/PaymentMethod.tsx
9437
- import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
9423
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
9438
9424
  var resolveDesignProps = (props) => {
9439
9425
  return {
9440
9426
  header: {
@@ -9476,8 +9462,8 @@ var PaymentMethod = forwardRef(({ children, className, portal, ...rest }, ref) =
9476
9462
  if (!paymentMethod.paymentMethodType) {
9477
9463
  return null;
9478
9464
  }
9479
- return /* @__PURE__ */ jsxs4("div", { ref, className, children: [
9480
- props.header.isVisible && /* @__PURE__ */ jsxs4(
9465
+ return /* @__PURE__ */ jsxs5("div", { ref, className, children: [
9466
+ props.header.isVisible && /* @__PURE__ */ jsxs5(
9481
9467
  Flex,
9482
9468
  {
9483
9469
  $justifyContent: "space-between",
@@ -9519,9 +9505,9 @@ var PaymentMethod = forwardRef(({ children, className, portal, ...rest }, ref) =
9519
9505
  }
9520
9506
  ),
9521
9507
  layout === "payment" && createPortal(
9522
- /* @__PURE__ */ jsxs4(Modal, { size: "md", children: [
9508
+ /* @__PURE__ */ jsxs5(Modal, { size: "md", children: [
9523
9509
  /* @__PURE__ */ jsx8(ModalHeader, { children: /* @__PURE__ */ jsx8(Box, { $fontWeight: "600", children: "Edit payment method" }) }),
9524
- /* @__PURE__ */ jsxs4(
9510
+ /* @__PURE__ */ jsxs5(
9525
9511
  Flex,
9526
9512
  {
9527
9513
  $flexDirection: "column",
@@ -9538,7 +9524,7 @@ var PaymentMethod = forwardRef(({ children, className, portal, ...rest }, ref) =
9538
9524
  $borderRadius: "0 0 0.5rem 0.5rem",
9539
9525
  $flex: "1",
9540
9526
  $height: "100%",
9541
- children: /* @__PURE__ */ jsxs4(Flex, { $flexDirection: "column", $height: "100%", children: [
9527
+ children: /* @__PURE__ */ jsxs5(Flex, { $flexDirection: "column", $height: "100%", children: [
9542
9528
  /* @__PURE__ */ jsx8(
9543
9529
  Box,
9544
9530
  {
@@ -9549,7 +9535,7 @@ var PaymentMethod = forwardRef(({ children, className, portal, ...rest }, ref) =
9549
9535
  children: "Default"
9550
9536
  }
9551
9537
  ),
9552
- /* @__PURE__ */ jsxs4(Flex, { $gap: "1rem", children: [
9538
+ /* @__PURE__ */ jsxs5(Flex, { $gap: "1rem", children: [
9553
9539
  /* @__PURE__ */ jsx8(
9554
9540
  Flex,
9555
9541
  {
@@ -9560,8 +9546,8 @@ var PaymentMethod = forwardRef(({ children, className, portal, ...rest }, ref) =
9560
9546
  $backgroundColor: "#ffffff",
9561
9547
  $gap: "1rem",
9562
9548
  $width: "100%",
9563
- children: /* @__PURE__ */ jsxs4(Flex, { $justifyContent: "space-between", $flex: "1", children: [
9564
- /* @__PURE__ */ jsxs4(Flex, { $alignItems: "center", $gap: "1rem", children: [
9549
+ children: /* @__PURE__ */ jsxs5(Flex, { $justifyContent: "space-between", $flex: "1", children: [
9550
+ /* @__PURE__ */ jsxs5(Flex, { $alignItems: "center", $gap: "1rem", children: [
9565
9551
  /* @__PURE__ */ jsx8(Box, { $display: "inline-block", children: /* @__PURE__ */ jsx8(
9566
9552
  "svg",
9567
9553
  {
@@ -9570,7 +9556,7 @@ var PaymentMethod = forwardRef(({ children, className, portal, ...rest }, ref) =
9570
9556
  xmlns: "http://www.w3.org/2000/svg",
9571
9557
  width: "26px",
9572
9558
  height: "auto",
9573
- children: /* @__PURE__ */ jsxs4("g", { children: [
9559
+ children: /* @__PURE__ */ jsxs5("g", { children: [
9574
9560
  /* @__PURE__ */ jsx8(
9575
9561
  "rect",
9576
9562
  {
@@ -9626,7 +9612,7 @@ var PaymentMethod = forwardRef(({ children, className, portal, ...rest }, ref) =
9626
9612
  $borderRadius: "0 0 0.5rem 0.5rem",
9627
9613
  $flex: "1",
9628
9614
  $height: "100%",
9629
- children: /* @__PURE__ */ jsxs4(Flex, { $flexDirection: "column", $height: "100%", children: [
9615
+ children: /* @__PURE__ */ jsxs5(Flex, { $flexDirection: "column", $height: "100%", children: [
9630
9616
  /* @__PURE__ */ jsx8(
9631
9617
  Box,
9632
9618
  {
@@ -9637,7 +9623,7 @@ var PaymentMethod = forwardRef(({ children, className, portal, ...rest }, ref) =
9637
9623
  children: "Others"
9638
9624
  }
9639
9625
  ),
9640
- /* @__PURE__ */ jsxs4(Flex, { $gap: "1rem", children: [
9626
+ /* @__PURE__ */ jsxs5(Flex, { $gap: "1rem", children: [
9641
9627
  /* @__PURE__ */ jsx8(
9642
9628
  Flex,
9643
9629
  {
@@ -9648,8 +9634,8 @@ var PaymentMethod = forwardRef(({ children, className, portal, ...rest }, ref) =
9648
9634
  $backgroundColor: "#ffffff",
9649
9635
  $gap: "1rem",
9650
9636
  $width: "100%",
9651
- children: /* @__PURE__ */ jsxs4(Flex, { $justifyContent: "space-between", $flex: "1", children: [
9652
- /* @__PURE__ */ jsxs4(Flex, { $alignItems: "center", $gap: "1rem", children: [
9637
+ children: /* @__PURE__ */ jsxs5(Flex, { $justifyContent: "space-between", $flex: "1", children: [
9638
+ /* @__PURE__ */ jsxs5(Flex, { $alignItems: "center", $gap: "1rem", children: [
9653
9639
  /* @__PURE__ */ jsx8(Box, { $display: "inline-block", children: /* @__PURE__ */ jsx8(
9654
9640
  "svg",
9655
9641
  {
@@ -9658,7 +9644,7 @@ var PaymentMethod = forwardRef(({ children, className, portal, ...rest }, ref) =
9658
9644
  xmlns: "http://www.w3.org/2000/svg",
9659
9645
  width: "26px",
9660
9646
  height: "auto",
9661
- children: /* @__PURE__ */ jsxs4("g", { children: [
9647
+ children: /* @__PURE__ */ jsxs5("g", { children: [
9662
9648
  /* @__PURE__ */ jsx8(
9663
9649
  "rect",
9664
9650
  {
@@ -9687,7 +9673,7 @@ var PaymentMethod = forwardRef(({ children, className, portal, ...rest }, ref) =
9687
9673
  ] })
9688
9674
  }
9689
9675
  ),
9690
- /* @__PURE__ */ jsxs4(Flex, { $gap: "1rem", children: [
9676
+ /* @__PURE__ */ jsxs5(Flex, { $gap: "1rem", children: [
9691
9677
  /* @__PURE__ */ jsx8(
9692
9678
  StyledButton,
9693
9679
  {
@@ -9737,11 +9723,11 @@ import {
9737
9723
  PaymentElement
9738
9724
  } from "@stripe/react-stripe-js";
9739
9725
  import { useStripe, useElements } from "@stripe/react-stripe-js";
9740
- import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
9726
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
9741
9727
  var PaymentForm = ({ plan, period, onConfirm }) => {
9742
9728
  const stripe = useStripe();
9743
9729
  const elements = useElements();
9744
- const { api, data } = useEmbed();
9730
+ const { api } = useEmbed();
9745
9731
  const [message, setMessage] = useState2(null);
9746
9732
  const [isLoading, setIsLoading] = useState2(false);
9747
9733
  const [isConfirmed, setIsConfirmed] = useState2(false);
@@ -9776,7 +9762,7 @@ var PaymentForm = ({ plan, period, onConfirm }) => {
9776
9762
  setIsLoading(false);
9777
9763
  }
9778
9764
  };
9779
- return /* @__PURE__ */ jsxs5(
9765
+ return /* @__PURE__ */ jsxs6(
9780
9766
  "form",
9781
9767
  {
9782
9768
  id: "payment-form",
@@ -9809,8 +9795,8 @@ var PaymentForm = ({ plan, period, onConfirm }) => {
9809
9795
  StyledButton,
9810
9796
  {
9811
9797
  id: "submit",
9812
- disabled: isLoading || !stripe || !elements || !data.stripeEmbed?.publishableKey || !data.stripeEmbed?.setupIntentClientSecret || isConfirmed,
9813
- $size: "md",
9798
+ disabled: isLoading || !stripe || !elements || isConfirmed,
9799
+ isLoading,
9814
9800
  $color: "primary",
9815
9801
  children: /* @__PURE__ */ jsx9(Text, { id: "button-text", children: isLoading ? "Loading" : "Save payment method" })
9816
9802
  }
@@ -9822,7 +9808,7 @@ var PaymentForm = ({ plan, period, onConfirm }) => {
9822
9808
  };
9823
9809
 
9824
9810
  // src/components/elements/plan-manager/CheckoutDialog.tsx
9825
- import { Fragment, jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
9811
+ import { Fragment, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
9826
9812
  var FeatureName = ({
9827
9813
  entitlement
9828
9814
  }) => {
@@ -9839,7 +9825,7 @@ var FeatureName = ({
9839
9825
  current_year: "year"
9840
9826
  }[entitlement.metricPeriod];
9841
9827
  }
9842
- return /* @__PURE__ */ jsx10(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsxs6(
9828
+ return /* @__PURE__ */ jsx10(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsxs7(
9843
9829
  Text,
9844
9830
  {
9845
9831
  $font: theme.typography.text.fontFamily,
@@ -9881,6 +9867,8 @@ var CheckoutDialog = () => {
9881
9867
  const [showPaymentForm, setShowPaymentForm] = useState3(
9882
9868
  () => typeof data.subscription?.paymentMethod === "undefined"
9883
9869
  );
9870
+ const [stripe, setStripe] = useState3(null);
9871
+ const [setupIntent, setSetupIntent] = useState3();
9884
9872
  const { paymentMethod, currentPlan, availablePlans, planPeriodOptions } = useMemo4(() => {
9885
9873
  const showMonthlyPriceOption = data.activePlans.some(
9886
9874
  (plan) => typeof plan.yearlyPrice !== "undefined"
@@ -9958,10 +9946,44 @@ var CheckoutDialog = () => {
9958
9946
  },
9959
9947
  [selectedPlan, selectPlan]
9960
9948
  );
9961
- const allowCheckout = api && selectedPlan && selectedPlan?.id !== currentPlan?.id && (paymentMethod && !showPaymentForm || paymentMethodId) && !isLoading;
9962
- return /* @__PURE__ */ jsxs6(Modal, { size: "lg", children: [
9963
- /* @__PURE__ */ jsx10(ModalHeader, { bordered: true, children: /* @__PURE__ */ jsxs6(Flex, { $gap: "1rem", children: [
9964
- /* @__PURE__ */ jsxs6(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
9949
+ const checkout = useCallback4(async () => {
9950
+ const priceId = (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.id;
9951
+ if (!api || !selectedPlan || !priceId) {
9952
+ return;
9953
+ }
9954
+ try {
9955
+ setIsLoading(true);
9956
+ await api.checkout({
9957
+ changeSubscriptionRequestBody: {
9958
+ newPlanId: selectedPlan.id,
9959
+ newPriceId: priceId,
9960
+ ...paymentMethodId && { paymentMethodId }
9961
+ }
9962
+ });
9963
+ setLayout("success");
9964
+ } catch {
9965
+ setError(
9966
+ "Error processing payment. Please try a different payment method."
9967
+ );
9968
+ } finally {
9969
+ setIsLoading(false);
9970
+ }
9971
+ }, [api, paymentMethodId, planPeriod, selectedPlan, setLayout]);
9972
+ useEffect3(() => {
9973
+ if (!stripe && setupIntent?.publishableKey) {
9974
+ setStripe(loadStripe(setupIntent.publishableKey));
9975
+ }
9976
+ }, [stripe, setupIntent?.publishableKey]);
9977
+ useLayoutEffect(() => {
9978
+ document.body.style.overflow = "hidden";
9979
+ return () => {
9980
+ document.body.style.overflow = "";
9981
+ };
9982
+ }, []);
9983
+ const allowCheckout = api && selectedPlan && (paymentMethod && !showPaymentForm || paymentMethodId) && !isLoading;
9984
+ return /* @__PURE__ */ jsxs7(Modal, { size: "lg", children: [
9985
+ /* @__PURE__ */ jsx10(ModalHeader, { bordered: true, children: /* @__PURE__ */ jsxs7(Flex, { $gap: "1rem", children: [
9986
+ /* @__PURE__ */ jsxs7(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
9965
9987
  checkoutStage === "plan" ? /* @__PURE__ */ jsx10(
9966
9988
  Box,
9967
9989
  {
@@ -10019,7 +10041,7 @@ var CheckoutDialog = () => {
10019
10041
  }
10020
10042
  }
10021
10043
  ),
10022
- /* @__PURE__ */ jsxs6(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
10044
+ /* @__PURE__ */ jsxs7(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
10023
10045
  /* @__PURE__ */ jsx10(
10024
10046
  Box,
10025
10047
  {
@@ -10052,8 +10074,8 @@ var CheckoutDialog = () => {
10052
10074
  )
10053
10075
  ] })
10054
10076
  ] }) }),
10055
- /* @__PURE__ */ jsxs6(Flex, { $position: "relative", $height: "calc(100% - 5rem)", children: [
10056
- /* @__PURE__ */ jsxs6(
10077
+ /* @__PURE__ */ jsxs7(Flex, { $position: "relative", $height: "calc(100% - 5rem)", children: [
10078
+ /* @__PURE__ */ jsxs7(
10057
10079
  Flex,
10058
10080
  {
10059
10081
  $flexDirection: "column",
@@ -10064,8 +10086,8 @@ var CheckoutDialog = () => {
10064
10086
  $flex: "1",
10065
10087
  $overflow: "auto",
10066
10088
  children: [
10067
- checkoutStage === "plan" && /* @__PURE__ */ jsxs6(Fragment, { children: [
10068
- /* @__PURE__ */ jsxs6(Flex, { $flexDirection: "column", $gap: "1rem", $marginBottom: "1rem", children: [
10089
+ checkoutStage === "plan" && /* @__PURE__ */ jsxs7(Fragment, { children: [
10090
+ /* @__PURE__ */ jsxs7(Flex, { $flexDirection: "column", $gap: "1rem", $marginBottom: "1rem", children: [
10069
10091
  /* @__PURE__ */ jsx10(
10070
10092
  Text,
10071
10093
  {
@@ -10093,15 +10115,15 @@ var CheckoutDialog = () => {
10093
10115
  )
10094
10116
  ] }),
10095
10117
  /* @__PURE__ */ jsx10(Flex, { $flexWrap: "wrap", $gap: "1rem", $flexGrow: "1", children: availablePlans.sort((a2, b2) => {
10096
- if (planPeriod === "year" && a2.yearlyPrice && b2.yearlyPrice) {
10097
- return a2.yearlyPrice?.price - b2.yearlyPrice?.price;
10118
+ if (planPeriod === "year") {
10119
+ return (a2.yearlyPrice?.price ?? 0) - (b2.yearlyPrice?.price ?? 0);
10098
10120
  }
10099
- if (planPeriod === "month" && a2.monthlyPrice && b2.monthlyPrice) {
10100
- return a2.monthlyPrice.price - b2.monthlyPrice.price;
10121
+ if (planPeriod === "month") {
10122
+ return (a2.monthlyPrice?.price ?? 0) - (b2.monthlyPrice?.price ?? 0);
10101
10123
  }
10102
10124
  return 0;
10103
10125
  }).map((plan) => {
10104
- return /* @__PURE__ */ jsxs6(
10126
+ return /* @__PURE__ */ jsxs7(
10105
10127
  Flex,
10106
10128
  {
10107
10129
  $flexDirection: "column",
@@ -10117,7 +10139,7 @@ var CheckoutDialog = () => {
10117
10139
  $boxShadow: "0px 1px 3px rgba(16, 24, 40, 0.1), 0px 1px 20px rgba(16, 24, 40, 0.06)"
10118
10140
  },
10119
10141
  children: [
10120
- /* @__PURE__ */ jsxs6(
10142
+ /* @__PURE__ */ jsxs7(
10121
10143
  Flex,
10122
10144
  {
10123
10145
  $flexDirection: "column",
@@ -10132,11 +10154,11 @@ var CheckoutDialog = () => {
10132
10154
  children: [
10133
10155
  /* @__PURE__ */ jsx10(Text, { $size: 20, $weight: 600, children: plan.name }),
10134
10156
  /* @__PURE__ */ jsx10(Text, { $size: 14, children: plan.description }),
10135
- /* @__PURE__ */ jsxs6(Text, { children: [
10157
+ /* @__PURE__ */ jsxs7(Text, { children: [
10136
10158
  /* @__PURE__ */ jsx10(Box, { $display: "inline-block", $fontSize: "1.5rem", children: formatCurrency(
10137
10159
  (planPeriod === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0
10138
10160
  ) }),
10139
- /* @__PURE__ */ jsxs6(Box, { $display: "inline-block", $fontSize: "0.75rem", children: [
10161
+ /* @__PURE__ */ jsxs7(Box, { $display: "inline-block", $fontSize: "0.75rem", children: [
10140
10162
  "/",
10141
10163
  planPeriod
10142
10164
  ] })
@@ -10176,7 +10198,7 @@ var CheckoutDialog = () => {
10176
10198
  $justifyContent: "space-between",
10177
10199
  $alignItems: "center",
10178
10200
  $gap: "1rem",
10179
- children: /* @__PURE__ */ jsxs6(Flex, { $gap: "1rem", children: [
10201
+ children: /* @__PURE__ */ jsxs7(Flex, { $gap: "1rem", children: [
10180
10202
  entitlement.feature?.icon && /* @__PURE__ */ jsx10(
10181
10203
  IconRound,
10182
10204
  {
@@ -10196,7 +10218,7 @@ var CheckoutDialog = () => {
10196
10218
  })
10197
10219
  }
10198
10220
  ),
10199
- /* @__PURE__ */ jsxs6(
10221
+ /* @__PURE__ */ jsxs7(
10200
10222
  Flex,
10201
10223
  {
10202
10224
  $flexDirection: "column",
@@ -10206,7 +10228,7 @@ var CheckoutDialog = () => {
10206
10228
  $height: "auto",
10207
10229
  $padding: "1.5rem",
10208
10230
  children: [
10209
- plan.id === selectedPlan?.id && /* @__PURE__ */ jsxs6(
10231
+ plan.id === selectedPlan?.id && /* @__PURE__ */ jsxs7(
10210
10232
  Flex,
10211
10233
  {
10212
10234
  $justifyContent: "center",
@@ -10237,10 +10259,10 @@ var CheckoutDialog = () => {
10237
10259
  ]
10238
10260
  }
10239
10261
  ),
10240
- !(plan.current || plan.id === currentPlan?.id) && plan.id !== selectedPlan?.id && /* @__PURE__ */ jsx10(
10262
+ plan.id !== selectedPlan?.id && /* @__PURE__ */ jsx10(
10241
10263
  StyledButton,
10242
10264
  {
10243
- disabled: plan.valid === false,
10265
+ disabled: isLoading || plan.valid === false,
10244
10266
  ...plan.valid === true && {
10245
10267
  onClick: () => selectPlan(plan)
10246
10268
  },
@@ -10259,36 +10281,69 @@ var CheckoutDialog = () => {
10259
10281
  );
10260
10282
  }) })
10261
10283
  ] }),
10262
- selectedPlan && checkoutStage === "checkout" && /* @__PURE__ */ jsx10(Fragment, { children: showPaymentForm ? /* @__PURE__ */ jsxs6(Fragment, { children: [
10263
- /* @__PURE__ */ jsx10(
10264
- PaymentForm,
10265
- {
10266
- plan: selectedPlan,
10267
- period: planPeriod,
10268
- onConfirm: (value) => {
10269
- setPaymentMethodId(value);
10270
- }
10271
- }
10272
- ),
10273
- typeof data.subscription?.paymentMethod !== "undefined" && /* @__PURE__ */ jsx10(
10274
- Box,
10275
- {
10276
- tabIndex: 0,
10277
- onClick: () => setShowPaymentForm(false),
10278
- $cursor: "pointer",
10279
- children: /* @__PURE__ */ jsx10(
10280
- Text,
10284
+ selectedPlan && checkoutStage === "checkout" && /* @__PURE__ */ jsx10(Fragment, { children: showPaymentForm && setupIntent?.setupIntentClientSecret ? /* @__PURE__ */ jsxs7(
10285
+ Elements,
10286
+ {
10287
+ stripe,
10288
+ options: {
10289
+ appearance: {
10290
+ theme: "stripe",
10291
+ variables: {
10292
+ // Base
10293
+ fontFamily: '"Public Sans", system-ui, sans-serif',
10294
+ spacingUnit: "0.25rem",
10295
+ borderRadius: "0.5rem",
10296
+ colorText: "#30313D",
10297
+ colorBackground: "#FFFFFF",
10298
+ colorPrimary: "#0570DE",
10299
+ colorDanger: "#DF1B41",
10300
+ // Layout
10301
+ gridRowSpacing: "1.5rem",
10302
+ gridColumnSpacing: "1.5rem"
10303
+ },
10304
+ rules: {
10305
+ ".Label": {
10306
+ fontSize: "1rem",
10307
+ fontWeight: "400",
10308
+ marginBottom: "0.75rem",
10309
+ color: theme.typography.text.color
10310
+ }
10311
+ }
10312
+ },
10313
+ clientSecret: setupIntent.setupIntentClientSecret
10314
+ },
10315
+ children: [
10316
+ /* @__PURE__ */ jsx10(
10317
+ PaymentForm,
10281
10318
  {
10282
- $font: theme.typography.link.fontFamily,
10283
- $size: theme.typography.link.fontSize,
10284
- $weight: theme.typography.link.fontWeight,
10285
- $color: theme.typography.link.color,
10286
- children: "Use existing payment method"
10319
+ plan: selectedPlan,
10320
+ period: planPeriod,
10321
+ onConfirm: (value) => {
10322
+ setPaymentMethodId(value);
10323
+ }
10324
+ }
10325
+ ),
10326
+ data.subscription?.paymentMethod && /* @__PURE__ */ jsx10(
10327
+ Box,
10328
+ {
10329
+ tabIndex: 0,
10330
+ onClick: () => setShowPaymentForm(false),
10331
+ $cursor: "pointer",
10332
+ children: /* @__PURE__ */ jsx10(
10333
+ Text,
10334
+ {
10335
+ $font: theme.typography.link.fontFamily,
10336
+ $size: theme.typography.link.fontSize,
10337
+ $weight: theme.typography.link.fontWeight,
10338
+ $color: theme.typography.link.color,
10339
+ children: "Use existing payment method"
10340
+ }
10341
+ )
10287
10342
  }
10288
10343
  )
10289
- }
10290
- )
10291
- ] }) : /* @__PURE__ */ jsxs6(Fragment, { children: [
10344
+ ]
10345
+ }
10346
+ ) : /* @__PURE__ */ jsxs7(Fragment, { children: [
10292
10347
  /* @__PURE__ */ jsx10(PaymentMethod, {}),
10293
10348
  /* @__PURE__ */ jsx10(
10294
10349
  Box,
@@ -10312,20 +10367,21 @@ var CheckoutDialog = () => {
10312
10367
  ]
10313
10368
  }
10314
10369
  ),
10315
- /* @__PURE__ */ jsxs6(
10370
+ /* @__PURE__ */ jsxs7(
10316
10371
  Flex,
10317
10372
  {
10318
10373
  $flexDirection: "column",
10374
+ $width: "21.5rem",
10375
+ $overflow: "auto",
10319
10376
  $backgroundColor: theme.card.background,
10320
10377
  $borderRadius: "0 0 0.5rem",
10321
- $width: "21.5rem",
10322
10378
  $boxShadow: "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A;",
10323
10379
  children: [
10324
- /* @__PURE__ */ jsxs6(
10380
+ /* @__PURE__ */ jsxs7(
10325
10381
  Flex,
10326
10382
  {
10327
- $flexDirection: "column",
10328
10383
  $position: "relative",
10384
+ $flexDirection: "column",
10329
10385
  $gap: "1rem",
10330
10386
  $width: "100%",
10331
10387
  $height: "auto",
@@ -10345,7 +10401,7 @@ var CheckoutDialog = () => {
10345
10401
  children: "Subscription"
10346
10402
  }
10347
10403
  ) }),
10348
- planPeriodOptions.length > 1 && /* @__PURE__ */ jsxs6(
10404
+ planPeriodOptions.length > 1 && /* @__PURE__ */ jsxs7(
10349
10405
  Flex,
10350
10406
  {
10351
10407
  $borderWidth: "1px",
@@ -10418,7 +10474,7 @@ var CheckoutDialog = () => {
10418
10474
  ]
10419
10475
  }
10420
10476
  ),
10421
- /* @__PURE__ */ jsxs6(
10477
+ /* @__PURE__ */ jsxs7(
10422
10478
  Flex,
10423
10479
  {
10424
10480
  $flexDirection: "column",
@@ -10442,43 +10498,51 @@ var CheckoutDialog = () => {
10442
10498
  children: "Plan"
10443
10499
  }
10444
10500
  ) }),
10445
- /* @__PURE__ */ jsxs6(Flex, { $flexDirection: "column", $gap: "0.5rem", children: [
10446
- currentPlan && /* @__PURE__ */ jsxs6(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
10447
- /* @__PURE__ */ jsx10(
10448
- Flex,
10449
- {
10450
- ...selectedPlan && {
10451
- $opacity: "0.625",
10452
- $textDecoration: "line-through"
10453
- },
10454
- children: /* @__PURE__ */ jsx10(
10501
+ /* @__PURE__ */ jsxs7(Flex, { $flexDirection: "column", $gap: "0.5rem", children: [
10502
+ currentPlan && /* @__PURE__ */ jsxs7(
10503
+ Flex,
10504
+ {
10505
+ $justifyContent: "space-between",
10506
+ $alignItems: "center",
10507
+ $gap: "1rem",
10508
+ children: [
10509
+ /* @__PURE__ */ jsx10(
10510
+ Flex,
10511
+ {
10512
+ ...selectedPlan && {
10513
+ $opacity: "0.625",
10514
+ $textDecoration: "line-through"
10515
+ },
10516
+ children: /* @__PURE__ */ jsx10(
10517
+ Text,
10518
+ {
10519
+ $font: theme.typography.heading4.fontFamily,
10520
+ $size: theme.typography.heading4.fontSize,
10521
+ $weight: theme.typography.heading4.fontWeight,
10522
+ $color: theme.typography.heading4.color,
10523
+ children: currentPlan.name
10524
+ }
10525
+ )
10526
+ }
10527
+ ),
10528
+ typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ jsx10(Flex, { children: /* @__PURE__ */ jsxs7(
10455
10529
  Text,
10456
10530
  {
10457
- $font: theme.typography.heading4.fontFamily,
10458
- $size: theme.typography.heading4.fontSize,
10459
- $weight: theme.typography.heading4.fontWeight,
10460
- $color: theme.typography.heading4.color,
10461
- children: currentPlan.name
10531
+ $font: theme.typography.text.fontFamily,
10532
+ $size: theme.typography.text.fontSize,
10533
+ $weight: theme.typography.text.fontWeight,
10534
+ $color: theme.typography.text.color,
10535
+ children: [
10536
+ formatCurrency(currentPlan.planPrice),
10537
+ "/",
10538
+ currentPlan.planPeriod
10539
+ ]
10462
10540
  }
10463
- )
10464
- }
10465
- ),
10466
- typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ jsx10(Flex, { children: /* @__PURE__ */ jsxs6(
10467
- Text,
10468
- {
10469
- $font: theme.typography.text.fontFamily,
10470
- $size: theme.typography.text.fontSize,
10471
- $weight: theme.typography.text.fontWeight,
10472
- $color: theme.typography.text.color,
10473
- children: [
10474
- formatCurrency(currentPlan.planPrice),
10475
- "/",
10476
- currentPlan.planPeriod
10477
- ]
10478
- }
10479
- ) })
10480
- ] }),
10481
- selectedPlan && /* @__PURE__ */ jsxs6(Box, { $marginBottom: "1rem", children: [
10541
+ ) })
10542
+ ]
10543
+ }
10544
+ ),
10545
+ selectedPlan && /* @__PURE__ */ jsxs7(Box, { $marginBottom: "1rem", children: [
10482
10546
  /* @__PURE__ */ jsx10(
10483
10547
  Box,
10484
10548
  {
@@ -10498,37 +10562,45 @@ var CheckoutDialog = () => {
10498
10562
  )
10499
10563
  }
10500
10564
  ),
10501
- /* @__PURE__ */ jsxs6(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
10502
- /* @__PURE__ */ jsx10(Flex, { children: /* @__PURE__ */ jsx10(
10503
- Text,
10504
- {
10505
- $font: theme.typography.heading4.fontFamily,
10506
- $size: theme.typography.heading4.fontSize,
10507
- $weight: theme.typography.heading4.fontWeight,
10508
- $color: theme.typography.heading4.color,
10509
- children: selectedPlan.name
10510
- }
10511
- ) }),
10512
- /* @__PURE__ */ jsx10(Flex, { children: /* @__PURE__ */ jsxs6(
10513
- Text,
10514
- {
10515
- $font: theme.typography.text.fontFamily,
10516
- $size: theme.typography.text.fontSize,
10517
- $weight: theme.typography.text.fontWeight,
10518
- $color: theme.typography.text.color,
10519
- children: [
10520
- formatCurrency(
10521
- (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
10522
- ),
10523
- "/",
10524
- planPeriod
10525
- ]
10526
- }
10527
- ) })
10528
- ] })
10565
+ /* @__PURE__ */ jsxs7(
10566
+ Flex,
10567
+ {
10568
+ $justifyContent: "space-between",
10569
+ $alignItems: "center",
10570
+ $gap: "1rem",
10571
+ children: [
10572
+ /* @__PURE__ */ jsx10(Flex, { children: /* @__PURE__ */ jsx10(
10573
+ Text,
10574
+ {
10575
+ $font: theme.typography.heading4.fontFamily,
10576
+ $size: theme.typography.heading4.fontSize,
10577
+ $weight: theme.typography.heading4.fontWeight,
10578
+ $color: theme.typography.heading4.color,
10579
+ children: selectedPlan.name
10580
+ }
10581
+ ) }),
10582
+ /* @__PURE__ */ jsx10(Flex, { children: /* @__PURE__ */ jsxs7(
10583
+ Text,
10584
+ {
10585
+ $font: theme.typography.text.fontFamily,
10586
+ $size: theme.typography.text.fontSize,
10587
+ $weight: theme.typography.text.fontWeight,
10588
+ $color: theme.typography.text.color,
10589
+ children: [
10590
+ formatCurrency(
10591
+ (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
10592
+ ),
10593
+ "/",
10594
+ planPeriod
10595
+ ]
10596
+ }
10597
+ ) })
10598
+ ]
10599
+ }
10600
+ )
10529
10601
  ] })
10530
10602
  ] }),
10531
- charges?.proration && /* @__PURE__ */ jsxs6(Fragment, { children: [
10603
+ charges?.proration && /* @__PURE__ */ jsxs7(Fragment, { children: [
10532
10604
  /* @__PURE__ */ jsx10(Box, { $opacity: "0.625", children: /* @__PURE__ */ jsx10(
10533
10605
  Text,
10534
10606
  {
@@ -10539,14 +10611,14 @@ var CheckoutDialog = () => {
10539
10611
  children: charges?.proration && charges.proration > 0 ? "Proration" : "Credits"
10540
10612
  }
10541
10613
  ) }),
10542
- /* @__PURE__ */ jsx10(Flex, { $flexDirection: "column", $gap: "0.5rem", children: currentPlan && /* @__PURE__ */ jsxs6(
10614
+ /* @__PURE__ */ jsx10(Flex, { $flexDirection: "column", $gap: "0.5rem", children: currentPlan && /* @__PURE__ */ jsxs7(
10543
10615
  Flex,
10544
10616
  {
10545
10617
  $justifyContent: "space-between",
10546
10618
  $alignItems: "center",
10547
10619
  $gap: "1rem",
10548
10620
  children: [
10549
- /* @__PURE__ */ jsx10(Flex, { children: /* @__PURE__ */ jsxs6(
10621
+ /* @__PURE__ */ jsx10(Flex, { children: /* @__PURE__ */ jsxs7(
10550
10622
  Text,
10551
10623
  {
10552
10624
  $font: theme.typography.heading4.fontFamily,
@@ -10576,7 +10648,7 @@ var CheckoutDialog = () => {
10576
10648
  ]
10577
10649
  }
10578
10650
  ),
10579
- /* @__PURE__ */ jsxs6(
10651
+ /* @__PURE__ */ jsxs7(
10580
10652
  Flex,
10581
10653
  {
10582
10654
  $flexDirection: "column",
@@ -10586,8 +10658,8 @@ var CheckoutDialog = () => {
10586
10658
  $height: "auto",
10587
10659
  $padding: "1.5rem",
10588
10660
  children: [
10589
- selectedPlan && subscriptionPrice && /* @__PURE__ */ jsxs6(Flex, { $justifyContent: "space-between", children: [
10590
- /* @__PURE__ */ jsx10(Box, { $opacity: "0.625", children: /* @__PURE__ */ jsxs6(
10661
+ selectedPlan && subscriptionPrice && /* @__PURE__ */ jsxs7(Flex, { $justifyContent: "space-between", $gap: "1rem", children: [
10662
+ /* @__PURE__ */ jsx10(Box, { $opacity: "0.625", children: /* @__PURE__ */ jsxs7(
10591
10663
  Text,
10592
10664
  {
10593
10665
  $font: theme.typography.text.fontFamily,
@@ -10600,7 +10672,7 @@ var CheckoutDialog = () => {
10600
10672
  ]
10601
10673
  }
10602
10674
  ) }),
10603
- /* @__PURE__ */ jsx10(Box, { children: /* @__PURE__ */ jsxs6(
10675
+ /* @__PURE__ */ jsx10(Box, { children: /* @__PURE__ */ jsxs7(
10604
10676
  Text,
10605
10677
  {
10606
10678
  $font: theme.typography.text.fontFamily,
@@ -10615,7 +10687,7 @@ var CheckoutDialog = () => {
10615
10687
  }
10616
10688
  ) })
10617
10689
  ] }),
10618
- charges && /* @__PURE__ */ jsxs6(Flex, { $justifyContent: "space-between", children: [
10690
+ charges && /* @__PURE__ */ jsxs7(Flex, { $justifyContent: "space-between", $gap: "1rem", children: [
10619
10691
  /* @__PURE__ */ jsx10(Box, { $opacity: "0.625", children: /* @__PURE__ */ jsx10(
10620
10692
  Text,
10621
10693
  {
@@ -10633,18 +10705,48 @@ var CheckoutDialog = () => {
10633
10705
  $size: theme.typography.text.fontSize,
10634
10706
  $weight: theme.typography.text.fontWeight,
10635
10707
  $color: theme.typography.text.color,
10636
- children: formatCurrency(charges.dueNow)
10708
+ children: formatCurrency(Math.max(0, charges.dueNow))
10709
+ }
10710
+ ) })
10711
+ ] }),
10712
+ charges?.dueNow && charges.dueNow < 0 && /* @__PURE__ */ jsxs7(Flex, { $justifyContent: "space-between", $gap: "1rem", children: [
10713
+ /* @__PURE__ */ jsx10(Box, { $opacity: "0.625", children: /* @__PURE__ */ jsx10(
10714
+ Text,
10715
+ {
10716
+ $font: theme.typography.text.fontFamily,
10717
+ $size: theme.typography.text.fontSize,
10718
+ $weight: theme.typography.text.fontWeight,
10719
+ $color: theme.typography.text.color,
10720
+ children: "Credits to be applied to future invoices:"
10721
+ }
10722
+ ) }),
10723
+ /* @__PURE__ */ jsx10(Box, { children: /* @__PURE__ */ jsx10(
10724
+ Text,
10725
+ {
10726
+ $font: theme.typography.text.fontFamily,
10727
+ $size: theme.typography.text.fontSize,
10728
+ $weight: theme.typography.text.fontWeight,
10729
+ $color: theme.typography.text.color,
10730
+ children: formatCurrency(Math.abs(charges.dueNow))
10637
10731
  }
10638
10732
  ) })
10639
10733
  ] }),
10640
10734
  checkoutStage === "plan" ? /* @__PURE__ */ jsx10(
10641
10735
  StyledButton,
10642
10736
  {
10643
- disabled: !selectedPlan,
10644
- ...selectedPlan && {
10645
- onClick: () => setCheckoutStage("checkout")
10646
- },
10647
- children: /* @__PURE__ */ jsxs6(
10737
+ ...allowCheckout ? {
10738
+ onClick: async () => {
10739
+ if (!data.component?.id) {
10740
+ return;
10741
+ }
10742
+ const { data: setupIntent2 } = await api.getSetupIntent({
10743
+ componentId: data.component.id
10744
+ });
10745
+ setSetupIntent(setupIntent2);
10746
+ setCheckoutStage("checkout");
10747
+ }
10748
+ } : { disabled: true },
10749
+ children: /* @__PURE__ */ jsxs7(
10648
10750
  Flex,
10649
10751
  {
10650
10752
  $gap: "0.5rem",
@@ -10661,31 +10763,9 @@ var CheckoutDialog = () => {
10661
10763
  ) : /* @__PURE__ */ jsx10(
10662
10764
  StyledButton,
10663
10765
  {
10664
- ...allowCheckout ? {
10665
- onClick: async () => {
10666
- const priceId = (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.id;
10667
- if (!priceId) {
10668
- return;
10669
- }
10670
- try {
10671
- setIsLoading(true);
10672
- await api.checkout({
10673
- changeSubscriptionRequestBody: {
10674
- newPlanId: selectedPlan.id,
10675
- newPriceId: priceId,
10676
- ...paymentMethodId && { paymentMethodId }
10677
- }
10678
- });
10679
- setLayout("success");
10680
- } catch {
10681
- setError(
10682
- "Error processing payment. Please try a different payment method."
10683
- );
10684
- } finally {
10685
- setIsLoading(false);
10686
- }
10687
- }
10688
- } : { disabled: true },
10766
+ disabled: isLoading || !allowCheckout,
10767
+ isLoading,
10768
+ ...allowCheckout && { onClick: checkout },
10689
10769
  children: "Pay now"
10690
10770
  }
10691
10771
  ),
@@ -10706,8 +10786,8 @@ var CheckoutDialog = () => {
10706
10786
  $size: theme.typography.text.fontSize,
10707
10787
  $weight: theme.typography.text.fontWeight,
10708
10788
  $color: theme.typography.text.color,
10709
- children: checkoutStage === "plan" ? "Discounts & credits applied at checkout" : subscriptionPrice && `You will be billed ${subscriptionPrice} for this subscription
10710
- every ${planPeriod} on the ${data.subscription?.latestInvoice?.dueDate && formatOrdinal(new Date(data.subscription.latestInvoice.dueDate).getDate())} ${planPeriod === "year" && data.subscription?.latestInvoice?.dueDate ? `of ${getMonthName(data.subscription.latestInvoice.dueDate)}` : ""} unless you unsubscribe.`
10789
+ children: subscriptionPrice && `You will be billed ${subscriptionPrice} for this subscription
10790
+ every ${planPeriod} ${charges?.periodStart ? `on the ${formatOrdinal(charges.periodStart.getDate())}` : ""} ${planPeriod === "year" && charges?.periodStart ? `of ${getMonthName(charges.periodStart)}` : ""} unless you unsubscribe.`
10711
10791
  }
10712
10792
  ) })
10713
10793
  ]
@@ -10721,7 +10801,7 @@ var CheckoutDialog = () => {
10721
10801
  };
10722
10802
 
10723
10803
  // src/components/elements/plan-manager/PlanManager.tsx
10724
- import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
10804
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
10725
10805
  var resolveDesignProps2 = (props) => {
10726
10806
  return {
10727
10807
  header: {
@@ -10745,7 +10825,7 @@ var resolveDesignProps2 = (props) => {
10745
10825
  },
10746
10826
  callToAction: {
10747
10827
  isVisible: props.callToAction?.isVisible ?? true,
10748
- buttonSize: props.callToAction?.buttonSize ?? "lg",
10828
+ buttonSize: props.callToAction?.buttonSize ?? "md",
10749
10829
  buttonStyle: props.callToAction?.buttonStyle ?? "primary"
10750
10830
  }
10751
10831
  };
@@ -10753,21 +10833,21 @@ var resolveDesignProps2 = (props) => {
10753
10833
  var PlanManager = forwardRef2(({ children, className, portal, ...rest }, ref) => {
10754
10834
  const props = resolveDesignProps2(rest);
10755
10835
  const theme = nt();
10756
- const { data, layout, stripe, setLayout } = useEmbed();
10836
+ const { data, layout, setLayout } = useEmbed();
10757
10837
  const { currentPlan, canChangePlan } = useMemo5(() => {
10758
10838
  return {
10759
10839
  currentPlan: data.company?.plan,
10760
- canChangePlan: data.activePlans.length > 0 && data.stripeEmbed?.publishableKey && stripe !== null
10840
+ canChangePlan: data.activePlans.length > 0
10761
10841
  };
10762
- }, [data.company, data.activePlans, data.stripeEmbed, stripe]);
10763
- return /* @__PURE__ */ jsxs7("div", { ref, className, children: [
10842
+ }, [data.company, data.activePlans]);
10843
+ return /* @__PURE__ */ jsxs8("div", { ref, className, children: [
10764
10844
  /* @__PURE__ */ jsx11(
10765
10845
  Flex,
10766
10846
  {
10767
10847
  $flexDirection: "column",
10768
10848
  $gap: "0.75rem",
10769
10849
  ...canChangePlan && { $margin: "0 0 0.5rem" },
10770
- children: props.header.isVisible && currentPlan && /* @__PURE__ */ jsxs7(
10850
+ children: props.header.isVisible && currentPlan && /* @__PURE__ */ jsxs8(
10771
10851
  Flex,
10772
10852
  {
10773
10853
  $justifyContent: "space-between",
@@ -10775,7 +10855,7 @@ var PlanManager = forwardRef2(({ children, className, portal, ...rest }, ref) =>
10775
10855
  $width: "100%",
10776
10856
  ...canChangePlan && { $margin: "0 0 1.5rem" },
10777
10857
  children: [
10778
- /* @__PURE__ */ jsxs7("div", { children: [
10858
+ /* @__PURE__ */ jsxs8("div", { children: [
10779
10859
  /* @__PURE__ */ jsx11(Box, { $margin: "0 0 0.75rem", children: /* @__PURE__ */ jsx11(
10780
10860
  Text,
10781
10861
  {
@@ -10798,7 +10878,7 @@ var PlanManager = forwardRef2(({ children, className, portal, ...rest }, ref) =>
10798
10878
  }
10799
10879
  )
10800
10880
  ] }),
10801
- props.header.price.isVisible && typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ jsxs7(
10881
+ props.header.price.isVisible && typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ jsxs8(
10802
10882
  Text,
10803
10883
  {
10804
10884
  $font: theme.typography[props.header.price.fontStyle].fontFamily,
@@ -10833,9 +10913,9 @@ var PlanManager = forwardRef2(({ children, className, portal, ...rest }, ref) =>
10833
10913
  });
10834
10914
 
10835
10915
  // src/components/elements/included-features/IncludedFeatures.tsx
10836
- import { forwardRef as forwardRef3, useLayoutEffect, useMemo as useMemo6, useRef as useRef3 } from "react";
10916
+ import { forwardRef as forwardRef3, useLayoutEffect as useLayoutEffect2, useMemo as useMemo6, useRef as useRef3 } from "react";
10837
10917
  var import_pluralize2 = __toESM(require_pluralize());
10838
- import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
10918
+ import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
10839
10919
  function resolveDesignProps3(props) {
10840
10920
  return {
10841
10921
  header: {
@@ -10893,7 +10973,7 @@ var IncludedFeatures = forwardRef3(({ className, ...rest }, ref) => {
10893
10973
  const isLightBackground = useMemo6(() => {
10894
10974
  return hexToHSL(theme.card.background).l > 50;
10895
10975
  }, [theme.card.background]);
10896
- useLayoutEffect(() => {
10976
+ useLayoutEffect2(() => {
10897
10977
  const assignRows = (parent) => {
10898
10978
  let isWrapped = true;
10899
10979
  [...parent.children].forEach((el) => {
@@ -10921,7 +11001,7 @@ var IncludedFeatures = forwardRef3(({ className, ...rest }, ref) => {
10921
11001
  assignRows(el);
10922
11002
  });
10923
11003
  }, [elements.current.length]);
10924
- return /* @__PURE__ */ jsxs8(Flex, { ref, className, $flexDirection: "column", $gap: "1.5rem", children: [
11004
+ return /* @__PURE__ */ jsxs9(Flex, { ref, className, $flexDirection: "column", $gap: "1.5rem", children: [
10925
11005
  props.header.isVisible && /* @__PURE__ */ jsx12(Box, { children: /* @__PURE__ */ jsx12(
10926
11006
  Text,
10927
11007
  {
@@ -10939,7 +11019,7 @@ var IncludedFeatures = forwardRef3(({ className, ...rest }, ref) => {
10939
11019
  }
10940
11020
  return [
10941
11021
  ...acc,
10942
- /* @__PURE__ */ jsxs8(
11022
+ /* @__PURE__ */ jsxs9(
10943
11023
  Flex,
10944
11024
  {
10945
11025
  ref: (el) => elements.current.push(el),
@@ -10948,7 +11028,7 @@ var IncludedFeatures = forwardRef3(({ className, ...rest }, ref) => {
10948
11028
  $alignItems: "center",
10949
11029
  $gap: "1rem",
10950
11030
  children: [
10951
- /* @__PURE__ */ jsxs8(Flex, { $gap: "1rem", children: [
11031
+ /* @__PURE__ */ jsxs9(Flex, { $gap: "1rem", children: [
10952
11032
  props.icons.isVisible && feature?.icon && /* @__PURE__ */ jsx12(
10953
11033
  IconRound,
10954
11034
  {
@@ -10971,7 +11051,7 @@ var IncludedFeatures = forwardRef3(({ className, ...rest }, ref) => {
10971
11051
  }
10972
11052
  ) })
10973
11053
  ] }),
10974
- (allocationType === "numeric" || allocationType === "unlimited") && feature?.name && /* @__PURE__ */ jsxs8(Box, { $textAlign: "right", $paddingLeft: "3.5rem", children: [
11054
+ (allocationType === "numeric" || allocationType === "unlimited") && feature?.name && /* @__PURE__ */ jsxs9(Box, { $textAlign: "right", $paddingLeft: "3.5rem", children: [
10975
11055
  props.entitlement.isVisible && /* @__PURE__ */ jsx12(
10976
11056
  Text,
10977
11057
  {
@@ -11010,7 +11090,7 @@ var IncludedFeatures = forwardRef3(({ className, ...rest }, ref) => {
11010
11090
 
11011
11091
  // src/components/elements/metered-features/MeteredFeatures.tsx
11012
11092
  import { forwardRef as forwardRef4, useMemo as useMemo7 } from "react";
11013
- import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
11093
+ import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
11014
11094
  function resolveDesignProps4(props) {
11015
11095
  return {
11016
11096
  isVisible: props.isVisible ?? true,
@@ -11077,11 +11157,11 @@ var MeteredFeatures = forwardRef4(({ className, ...rest }, ref) => {
11077
11157
  }
11078
11158
  return [
11079
11159
  ...acc,
11080
- /* @__PURE__ */ jsxs9(Flex, { $gap: "1.5rem", children: [
11160
+ /* @__PURE__ */ jsxs10(Flex, { $gap: "1.5rem", children: [
11081
11161
  props.icon.isVisible && feature?.icon && /* @__PURE__ */ jsx13(Box, { $flexShrink: "0", children: /* @__PURE__ */ jsx13(IconRound, { name: feature.icon, size: "sm" }) }),
11082
- /* @__PURE__ */ jsxs9(Box, { $flexGrow: "1", children: [
11083
- /* @__PURE__ */ jsxs9(Flex, { children: [
11084
- feature?.name && /* @__PURE__ */ jsxs9(Box, { $flexGrow: "1", children: [
11162
+ /* @__PURE__ */ jsxs10(Box, { $flexGrow: "1", children: [
11163
+ /* @__PURE__ */ jsxs10(Flex, { children: [
11164
+ feature?.name && /* @__PURE__ */ jsxs10(Box, { $flexGrow: "1", children: [
11085
11165
  /* @__PURE__ */ jsx13(
11086
11166
  Text,
11087
11167
  {
@@ -11105,7 +11185,7 @@ var MeteredFeatures = forwardRef4(({ className, ...rest }, ref) => {
11105
11185
  }
11106
11186
  )
11107
11187
  ] }),
11108
- (allocationType === "numeric" || allocationType === "unlimited") && feature?.name && /* @__PURE__ */ jsxs9(Box, { $textAlign: "right", children: [
11188
+ (allocationType === "numeric" || allocationType === "unlimited") && feature?.name && /* @__PURE__ */ jsxs10(Box, { $textAlign: "right", children: [
11109
11189
  props.allocation.isVisible && /* @__PURE__ */ jsx13(
11110
11190
  Text,
11111
11191
  {
@@ -11149,7 +11229,7 @@ var MeteredFeatures = forwardRef4(({ className, ...rest }, ref) => {
11149
11229
 
11150
11230
  // src/components/elements/upcoming-bill/UpcomingBill.tsx
11151
11231
  import { forwardRef as forwardRef5, useMemo as useMemo8 } from "react";
11152
- import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
11232
+ import { jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
11153
11233
  function resolveDesignProps5(props) {
11154
11234
  return {
11155
11235
  header: {
@@ -11171,7 +11251,7 @@ function resolveDesignProps5(props) {
11171
11251
  var UpcomingBill = forwardRef5(({ className, ...rest }, ref) => {
11172
11252
  const props = resolveDesignProps5(rest);
11173
11253
  const theme = nt();
11174
- const { data, stripe } = useEmbed();
11254
+ const { data } = useEmbed();
11175
11255
  const { upcomingInvoice } = useMemo8(() => {
11176
11256
  return {
11177
11257
  upcomingInvoice: {
@@ -11187,17 +11267,17 @@ var UpcomingBill = forwardRef5(({ className, ...rest }, ref) => {
11187
11267
  }
11188
11268
  };
11189
11269
  }, [data.subscription, data.upcomingInvoice]);
11190
- if (!stripe || !upcomingInvoice.amountDue || !upcomingInvoice.dueDate) {
11270
+ if (!upcomingInvoice.amountDue || !upcomingInvoice.dueDate) {
11191
11271
  return null;
11192
11272
  }
11193
- return /* @__PURE__ */ jsxs10("div", { ref, className, children: [
11273
+ return /* @__PURE__ */ jsxs11("div", { ref, className, children: [
11194
11274
  props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */ jsx14(
11195
11275
  Flex,
11196
11276
  {
11197
11277
  $justifyContent: "space-between",
11198
11278
  $alignItems: "center",
11199
11279
  $margin: "0 0 0.75rem",
11200
- children: /* @__PURE__ */ jsxs10(
11280
+ children: /* @__PURE__ */ jsxs11(
11201
11281
  Text,
11202
11282
  {
11203
11283
  $font: theme.typography[props.header.fontStyle].fontFamily,
@@ -11213,7 +11293,7 @@ var UpcomingBill = forwardRef5(({ className, ...rest }, ref) => {
11213
11293
  )
11214
11294
  }
11215
11295
  ),
11216
- upcomingInvoice.amountDue && /* @__PURE__ */ jsxs10(Flex, { $justifyContent: "space-between", $alignItems: "start", $gap: "1rem", children: [
11296
+ upcomingInvoice.amountDue && /* @__PURE__ */ jsxs11(Flex, { $justifyContent: "space-between", $alignItems: "start", $gap: "1rem", children: [
11217
11297
  props.price.isVisible && /* @__PURE__ */ jsx14(Flex, { $alignItems: "end", $flexGrow: "1", children: /* @__PURE__ */ jsx14(
11218
11298
  Text,
11219
11299
  {
@@ -11225,7 +11305,7 @@ var UpcomingBill = forwardRef5(({ className, ...rest }, ref) => {
11225
11305
  children: formatCurrency(upcomingInvoice.amountDue)
11226
11306
  }
11227
11307
  ) }),
11228
- /* @__PURE__ */ jsx14(Box, { $maxWidth: "10rem", $lineHeight: "1", $textAlign: "right", children: /* @__PURE__ */ jsxs10(
11308
+ /* @__PURE__ */ jsx14(Box, { $maxWidth: "10rem", $lineHeight: "1", $textAlign: "right", children: /* @__PURE__ */ jsxs11(
11229
11309
  Text,
11230
11310
  {
11231
11311
  $font: theme.typography[props.contractEndDate.fontStyle].fontFamily,
@@ -11246,7 +11326,7 @@ var UpcomingBill = forwardRef5(({ className, ...rest }, ref) => {
11246
11326
 
11247
11327
  // src/components/elements/invoices/Invoices.tsx
11248
11328
  import { forwardRef as forwardRef6, useMemo as useMemo9 } from "react";
11249
- import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
11329
+ import { jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
11250
11330
  function resolveDesignProps6(props) {
11251
11331
  return {
11252
11332
  header: {
@@ -11288,7 +11368,7 @@ var Invoices = forwardRef6(({ className, ...rest }, ref) => {
11288
11368
  ]
11289
11369
  };
11290
11370
  }, []);
11291
- return /* @__PURE__ */ jsx15("div", { ref, className, children: /* @__PURE__ */ jsxs11(Flex, { $flexDirection: "column", $gap: "1rem", children: [
11371
+ return /* @__PURE__ */ jsx15("div", { ref, className, children: /* @__PURE__ */ jsxs12(Flex, { $flexDirection: "column", $gap: "1rem", children: [
11292
11372
  props.header.isVisible && /* @__PURE__ */ jsx15(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ jsx15(
11293
11373
  Text,
11294
11374
  {
@@ -11303,7 +11383,7 @@ var Invoices = forwardRef6(({ className, ...rest }, ref) => {
11303
11383
  0,
11304
11384
  props.limit.isVisible && props.limit.number || invoices.length
11305
11385
  ).map(({ date, amount }, index) => {
11306
- return /* @__PURE__ */ jsxs11(Flex, { $justifyContent: "space-between", children: [
11386
+ return /* @__PURE__ */ jsxs12(Flex, { $justifyContent: "space-between", children: [
11307
11387
  props.date.isVisible && /* @__PURE__ */ jsx15(
11308
11388
  Text,
11309
11389
  {
@@ -11314,7 +11394,7 @@ var Invoices = forwardRef6(({ className, ...rest }, ref) => {
11314
11394
  children: toPrettyDate(date)
11315
11395
  }
11316
11396
  ),
11317
- props.amount.isVisible && /* @__PURE__ */ jsxs11(
11397
+ props.amount.isVisible && /* @__PURE__ */ jsxs12(
11318
11398
  Text,
11319
11399
  {
11320
11400
  $font: theme.typography[props.amount.fontStyle].fontFamily,
@@ -11329,7 +11409,7 @@ var Invoices = forwardRef6(({ className, ...rest }, ref) => {
11329
11409
  )
11330
11410
  ] }, index);
11331
11411
  }) }),
11332
- props.collapse.isVisible && /* @__PURE__ */ jsxs11(Flex, { $alignItems: "center", $gap: "0.5rem", children: [
11412
+ props.collapse.isVisible && /* @__PURE__ */ jsxs12(Flex, { $alignItems: "center", $gap: "0.5rem", children: [
11333
11413
  /* @__PURE__ */ jsx15(Icon2, { name: "chevron-down", style: { color: "#D0D0D0" } }),
11334
11414
  /* @__PURE__ */ jsx15(
11335
11415
  Text,
@@ -11346,7 +11426,7 @@ var Invoices = forwardRef6(({ className, ...rest }, ref) => {
11346
11426
  });
11347
11427
 
11348
11428
  // src/components/embed/ComponentTree.tsx
11349
- import { useEffect as useEffect4, useState as useState5, Children } from "react";
11429
+ import { useEffect as useEffect5, useState as useState5, Children } from "react";
11350
11430
 
11351
11431
  // src/components/embed/renderer.ts
11352
11432
  import { createElement } from "react";
@@ -11374,7 +11454,7 @@ var StyledViewport = dt.div`
11374
11454
  `;
11375
11455
 
11376
11456
  // src/components/layout/RenderLayout.tsx
11377
- import { useEffect as useEffect3, useState as useState4 } from "react";
11457
+ import { useEffect as useEffect4, useState as useState4 } from "react";
11378
11458
 
11379
11459
  // src/components/layout/card/Card.tsx
11380
11460
  import { forwardRef as forwardRef8 } from "react";
@@ -11458,10 +11538,10 @@ var Card = forwardRef8(
11458
11538
  );
11459
11539
 
11460
11540
  // src/components/layout/RenderLayout.tsx
11461
- import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
11541
+ import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
11462
11542
  var Disabled = () => {
11463
11543
  const theme = nt();
11464
- return /* @__PURE__ */ jsx18(Box, { $width: "max-content", $height: "max-content", $margin: "0 auto", children: /* @__PURE__ */ jsx18(Card, { children: /* @__PURE__ */ jsxs12(
11544
+ return /* @__PURE__ */ jsx18(Box, { $width: "max-content", $height: "max-content", $margin: "0 auto", children: /* @__PURE__ */ jsx18(Card, { children: /* @__PURE__ */ jsxs13(
11465
11545
  Flex,
11466
11546
  {
11467
11547
  $flexDirection: "column",
@@ -11499,18 +11579,18 @@ var Success = () => {
11499
11579
  const theme = nt();
11500
11580
  const { hydrate, data, api, setLayout, isPending } = useEmbed();
11501
11581
  const [isOpen, setIsOpen] = useState4(true);
11502
- useEffect3(() => {
11582
+ useEffect4(() => {
11503
11583
  if (api && data.component?.id) {
11504
11584
  hydrate();
11505
11585
  setTimeout(() => setIsOpen(false), 2e3);
11506
11586
  }
11507
11587
  }, [api, data.component?.id, hydrate]);
11508
- useEffect3(() => {
11588
+ useEffect4(() => {
11509
11589
  if (!isPending && !isOpen) {
11510
11590
  setLayout("portal");
11511
11591
  }
11512
11592
  }, [isPending, isOpen, setLayout]);
11513
- return /* @__PURE__ */ jsx18(Box, { $width: "max-content", $height: "max-content", $margin: "0 auto", children: /* @__PURE__ */ jsx18(Card, { children: /* @__PURE__ */ jsxs12(
11593
+ return /* @__PURE__ */ jsx18(Box, { $width: "max-content", $height: "max-content", $margin: "0 auto", children: /* @__PURE__ */ jsx18(Card, { children: /* @__PURE__ */ jsxs13(
11514
11594
  Flex,
11515
11595
  {
11516
11596
  $flexDirection: "column",
@@ -11588,6 +11668,7 @@ import { forwardRef as forwardRef10 } from "react";
11588
11668
  var StyledColumn = dt.div`
11589
11669
  flex-grow: 1;
11590
11670
  flex-basis: ${({ theme }) => `calc(${100 / theme.numberOfColumns}% - ${(theme.numberOfColumns - 1) / theme.numberOfColumns}rem)`};
11671
+ height: min-content;
11591
11672
  `;
11592
11673
 
11593
11674
  // src/components/layout/column/Column.tsx
@@ -11640,7 +11721,7 @@ function createRenderer(options) {
11640
11721
  }
11641
11722
 
11642
11723
  // src/components/embed/ComponentTree.tsx
11643
- import { Fragment as Fragment3, jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
11724
+ import { Fragment as Fragment3, jsx as jsx21, jsxs as jsxs14 } from "react/jsx-runtime";
11644
11725
  var Loading = () => {
11645
11726
  const theme = nt();
11646
11727
  return /* @__PURE__ */ jsx21(
@@ -11651,13 +11732,13 @@ var Loading = () => {
11651
11732
  $alignItems: "center",
11652
11733
  $justifyContent: "center",
11653
11734
  $padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
11654
- children: /* @__PURE__ */ jsx21(Loader, {})
11735
+ children: /* @__PURE__ */ jsx21(Loader, { $size: "2xl", $color: "#194BFB" })
11655
11736
  }
11656
11737
  );
11657
11738
  };
11658
11739
  var Error2 = ({ message }) => {
11659
11740
  const theme = nt();
11660
- return /* @__PURE__ */ jsxs13(
11741
+ return /* @__PURE__ */ jsxs14(
11661
11742
  Flex,
11662
11743
  {
11663
11744
  $flexDirection: "column",
@@ -11698,7 +11779,7 @@ var Error2 = ({ message }) => {
11698
11779
  var ComponentTree = () => {
11699
11780
  const { error, nodes } = useEmbed();
11700
11781
  const [children, setChildren] = useState5(/* @__PURE__ */ jsx21(Loading, {}));
11701
- useEffect4(() => {
11782
+ useEffect5(() => {
11702
11783
  const renderer = createRenderer();
11703
11784
  setChildren(nodes.map(renderer));
11704
11785
  }, [nodes]);