@schematichq/schematic-components 2.1.1 → 2.1.2

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.
@@ -4321,6 +4321,7 @@ var initialContext = {
4321
4321
  setAccessToken: stub,
4322
4322
  setLayout: stub,
4323
4323
  setCheckoutState: stub,
4324
+ initializeWithPlan: stub,
4324
4325
  setData: stub,
4325
4326
  updateSettings: stub,
4326
4327
  debug: stub,
@@ -6443,7 +6444,9 @@ var I18n = class _I18n extends EventEmitter {
6443
6444
  return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
6444
6445
  }
6445
6446
  static createInstance(options = {}, callback) {
6446
- return new _I18n(options, callback);
6447
+ const instance2 = new _I18n(options, callback);
6448
+ instance2.createInstance = _I18n.createInstance;
6449
+ return instance2;
6447
6450
  }
6448
6451
  cloneInstance(options = {}, callback = noop) {
6449
6452
  const forkResourceStore = options.forkResourceStore;
@@ -6507,7 +6510,6 @@ var I18n = class _I18n extends EventEmitter {
6507
6510
  }
6508
6511
  };
6509
6512
  var instance = I18n.createInstance();
6510
- instance.createInstance = I18n.createInstance;
6511
6513
  var createInstance = instance.createInstance;
6512
6514
  var dir = instance.dir;
6513
6515
  var init = instance.init;
@@ -8057,6 +8059,13 @@ function BillingPlanCreditGrantResponseDataFromJSONTyped(json, ignoreDiscriminat
8057
8059
  return json;
8058
8060
  }
8059
8061
  return {
8062
+ autoTopupAmount: json["auto_topup_amount"] == null ? void 0 : json["auto_topup_amount"],
8063
+ autoTopupAmountType: json["auto_topup_amount_type"] == null ? void 0 : json["auto_topup_amount_type"],
8064
+ autoTopupEnabled: json["auto_topup_enabled"],
8065
+ autoTopupExpiryType: json["auto_topup_expiry_type"] == null ? void 0 : json["auto_topup_expiry_type"],
8066
+ autoTopupExpiryUnit: json["auto_topup_expiry_unit"] == null ? void 0 : json["auto_topup_expiry_unit"],
8067
+ autoTopupExpiryUnitCount: json["auto_topup_expiry_unit_count"] == null ? void 0 : json["auto_topup_expiry_unit_count"],
8068
+ autoTopupThresholdPercent: json["auto_topup_threshold_percent"] == null ? void 0 : json["auto_topup_threshold_percent"],
8060
8069
  createdAt: new Date(json["created_at"]),
8061
8070
  creditAmount: json["credit_amount"],
8062
8071
  creditId: json["credit_id"],
@@ -8283,6 +8292,7 @@ function BillingSubscriptionViewFromJSONTyped(json, ignoreDiscriminator) {
8283
8292
  return json;
8284
8293
  }
8285
8294
  return {
8295
+ applicationId: json["application_id"] == null ? void 0 : json["application_id"],
8286
8296
  cancelAt: json["cancel_at"] == null ? void 0 : json["cancel_at"],
8287
8297
  cancelAtPeriodEnd: json["cancel_at_period_end"],
8288
8298
  companyId: json["company_id"] == null ? void 0 : json["company_id"],
@@ -8378,6 +8388,7 @@ function CheckoutResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8378
8388
  return json;
8379
8389
  }
8380
8390
  return {
8391
+ applicationId: json["application_id"] == null ? void 0 : json["application_id"],
8381
8392
  cancelAt: json["cancel_at"] == null ? void 0 : json["cancel_at"],
8382
8393
  cancelAtPeriodEnd: json["cancel_at_period_end"],
8383
8394
  companyId: json["company_id"] == null ? void 0 : json["company_id"],
@@ -8492,6 +8503,43 @@ function CompanyEventPeriodMetricsResponseDataFromJSONTyped(json, ignoreDiscrimi
8492
8503
  };
8493
8504
  }
8494
8505
 
8506
+ // src/api/checkoutexternal/models/PlanCreditGrantView.ts
8507
+ function PlanCreditGrantViewFromJSON(json) {
8508
+ return PlanCreditGrantViewFromJSONTyped(json, false);
8509
+ }
8510
+ function PlanCreditGrantViewFromJSONTyped(json, ignoreDiscriminator) {
8511
+ if (json == null) {
8512
+ return json;
8513
+ }
8514
+ return {
8515
+ billingCreditAutoTopupAmount: json["billing_credit_auto_topup_amount"] == null ? void 0 : json["billing_credit_auto_topup_amount"],
8516
+ billingCreditAutoTopupAmountType: json["billing_credit_auto_topup_amount_type"] == null ? void 0 : json["billing_credit_auto_topup_amount_type"],
8517
+ billingCreditAutoTopupEnabled: json["billing_credit_auto_topup_enabled"],
8518
+ billingCreditAutoTopupExpiryType: json["billing_credit_auto_topup_expiry_type"] == null ? void 0 : json["billing_credit_auto_topup_expiry_type"],
8519
+ billingCreditAutoTopupExpiryUnit: json["billing_credit_auto_topup_expiry_unit"] == null ? void 0 : json["billing_credit_auto_topup_expiry_unit"],
8520
+ billingCreditAutoTopupExpiryUnitCount: json["billing_credit_auto_topup_expiry_unit_count"] == null ? void 0 : json["billing_credit_auto_topup_expiry_unit_count"],
8521
+ billingCreditAutoTopupThresholdPercent: json["billing_credit_auto_topup_threshold_percent"] == null ? void 0 : json["billing_credit_auto_topup_threshold_percent"],
8522
+ createdAt: new Date(json["created_at"]),
8523
+ creditAmount: json["credit_amount"],
8524
+ creditDescription: json["credit_description"],
8525
+ creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
8526
+ creditId: json["credit_id"],
8527
+ creditName: json["credit_name"],
8528
+ expiryType: json["expiry_type"] == null ? void 0 : json["expiry_type"],
8529
+ expiryUnit: json["expiry_unit"] == null ? void 0 : json["expiry_unit"],
8530
+ expiryUnitCount: json["expiry_unit_count"] == null ? void 0 : json["expiry_unit_count"],
8531
+ id: json["id"],
8532
+ planId: json["plan_id"],
8533
+ planName: json["plan_name"],
8534
+ pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
8535
+ resetCadence: json["reset_cadence"],
8536
+ resetStart: json["reset_start"],
8537
+ resetType: json["reset_type"],
8538
+ singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
8539
+ updatedAt: new Date(json["updated_at"])
8540
+ };
8541
+ }
8542
+
8495
8543
  // src/api/checkoutexternal/models/CompanyPlanWithBillingSubView.ts
8496
8544
  function CompanyPlanWithBillingSubViewFromJSON(json) {
8497
8545
  return CompanyPlanWithBillingSubViewFromJSONTyped(json, false);
@@ -8507,6 +8555,9 @@ function CompanyPlanWithBillingSubViewFromJSONTyped(json, ignoreDiscriminator) {
8507
8555
  description: json["description"] == null ? void 0 : json["description"],
8508
8556
  id: json["id"],
8509
8557
  imageUrl: json["image_url"] == null ? void 0 : json["image_url"],
8558
+ includedCreditGrants: json["included_credit_grants"].map(
8559
+ PlanCreditGrantViewFromJSON
8560
+ ),
8510
8561
  name: json["name"],
8511
8562
  planPeriod: json["plan_period"] == null ? void 0 : json["plan_period"],
8512
8563
  planPrice: json["plan_price"] == null ? void 0 : json["plan_price"]
@@ -8992,36 +9043,6 @@ function FeatureDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8992
9043
  };
8993
9044
  }
8994
9045
 
8995
- // src/api/checkoutexternal/models/PlanCreditGrantView.ts
8996
- function PlanCreditGrantViewFromJSON(json) {
8997
- return PlanCreditGrantViewFromJSONTyped(json, false);
8998
- }
8999
- function PlanCreditGrantViewFromJSONTyped(json, ignoreDiscriminator) {
9000
- if (json == null) {
9001
- return json;
9002
- }
9003
- return {
9004
- createdAt: new Date(json["created_at"]),
9005
- creditAmount: json["credit_amount"],
9006
- creditDescription: json["credit_description"],
9007
- creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
9008
- creditId: json["credit_id"],
9009
- creditName: json["credit_name"],
9010
- expiryType: json["expiry_type"] == null ? void 0 : json["expiry_type"],
9011
- expiryUnit: json["expiry_unit"] == null ? void 0 : json["expiry_unit"],
9012
- expiryUnitCount: json["expiry_unit_count"] == null ? void 0 : json["expiry_unit_count"],
9013
- id: json["id"],
9014
- planId: json["plan_id"],
9015
- planName: json["plan_name"],
9016
- pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
9017
- resetCadence: json["reset_cadence"],
9018
- resetStart: json["reset_start"],
9019
- resetType: json["reset_type"],
9020
- singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
9021
- updatedAt: new Date(json["updated_at"])
9022
- };
9023
- }
9024
-
9025
9046
  // src/api/checkoutexternal/models/PlanResponseData.ts
9026
9047
  function PlanResponseDataFromJSON(json) {
9027
9048
  return PlanResponseDataFromJSONTyped(json, false);
@@ -10876,13 +10897,20 @@ function FeatureDetailResponseDataFromJSONTyped6(json, ignoreDiscriminator) {
10876
10897
 
10877
10898
  // src/api/componentspublic/models/PlanCreditGrantView.ts
10878
10899
  function PlanCreditGrantViewFromJSON2(json) {
10879
- return PlanCreditGrantViewFromJSONTyped3(json, false);
10900
+ return PlanCreditGrantViewFromJSONTyped4(json, false);
10880
10901
  }
10881
- function PlanCreditGrantViewFromJSONTyped3(json, ignoreDiscriminator) {
10902
+ function PlanCreditGrantViewFromJSONTyped4(json, ignoreDiscriminator) {
10882
10903
  if (json == null) {
10883
10904
  return json;
10884
10905
  }
10885
10906
  return {
10907
+ billingCreditAutoTopupAmount: json["billing_credit_auto_topup_amount"] == null ? void 0 : json["billing_credit_auto_topup_amount"],
10908
+ billingCreditAutoTopupAmountType: json["billing_credit_auto_topup_amount_type"] == null ? void 0 : json["billing_credit_auto_topup_amount_type"],
10909
+ billingCreditAutoTopupEnabled: json["billing_credit_auto_topup_enabled"],
10910
+ billingCreditAutoTopupExpiryType: json["billing_credit_auto_topup_expiry_type"] == null ? void 0 : json["billing_credit_auto_topup_expiry_type"],
10911
+ billingCreditAutoTopupExpiryUnit: json["billing_credit_auto_topup_expiry_unit"] == null ? void 0 : json["billing_credit_auto_topup_expiry_unit"],
10912
+ billingCreditAutoTopupExpiryUnitCount: json["billing_credit_auto_topup_expiry_unit_count"] == null ? void 0 : json["billing_credit_auto_topup_expiry_unit_count"],
10913
+ billingCreditAutoTopupThresholdPercent: json["billing_credit_auto_topup_threshold_percent"] == null ? void 0 : json["billing_credit_auto_topup_threshold_percent"],
10886
10914
  createdAt: new Date(json["created_at"]),
10887
10915
  creditAmount: json["credit_amount"],
10888
10916
  creditDescription: json["credit_description"],
@@ -11233,13 +11261,23 @@ var reducer = (state, action) => {
11233
11261
  checkoutState: { ...action.state }
11234
11262
  };
11235
11263
  }
11264
+ case "SET_PLANID_BYPASS": {
11265
+ return {
11266
+ ...state,
11267
+ layout: "checkout",
11268
+ checkoutState: {
11269
+ planId: action.planId,
11270
+ bypassPlanSelection: true
11271
+ }
11272
+ };
11273
+ }
11236
11274
  }
11237
11275
  };
11238
11276
 
11239
11277
  // src/context/EmbedProvider.tsx
11240
11278
  var import_jsx_runtime2 = require("react/jsx-runtime");
11241
11279
  var getCustomHeaders = (sessionId) => ({
11242
- "X-Schematic-Components-Version": "2.1.1",
11280
+ "X-Schematic-Components-Version": "2.1.2",
11243
11281
  "X-Schematic-Session-ID": sessionId
11244
11282
  });
11245
11283
  var EmbedProvider = ({
@@ -11531,6 +11569,9 @@ var EmbedProvider = ({
11531
11569
  const setCheckoutState = (0, import_react15.useCallback)((state2) => {
11532
11570
  dispatch({ type: "SET_CHECKOUT_STATE", state: state2 });
11533
11571
  }, []);
11572
+ const initializeWithPlan = (0, import_react15.useCallback)((planId) => {
11573
+ dispatch({ type: "SET_PLANID_BYPASS", planId });
11574
+ }, []);
11534
11575
  (0, import_react15.useEffect)(() => {
11535
11576
  const element = document.getElementById(
11536
11577
  "schematic-fonts"
@@ -11653,6 +11694,7 @@ var EmbedProvider = ({
11653
11694
  setAccessToken,
11654
11695
  setLayout,
11655
11696
  setCheckoutState,
11697
+ initializeWithPlan,
11656
11698
  setData,
11657
11699
  updateSettings,
11658
11700
  debug
@@ -12387,7 +12429,7 @@ var Overlay = dt(Box)`
12387
12429
  left: 0;
12388
12430
  z-index: 999999;
12389
12431
  width: 100%;
12390
- height: 100vh;
12432
+ height: 100dvh;
12391
12433
  overflow: hidden;
12392
12434
  scrollbar-width: thin;
12393
12435
  scrollbar-gutter: stable both-edges;
@@ -12404,7 +12446,7 @@ var Modal = dt.div.attrs({
12404
12446
  flex-direction: column;
12405
12447
  width: 100%;
12406
12448
  height: fit-content;
12407
- max-height: 100vh;
12449
+ max-height: 100dvh;
12408
12450
  overflow: auto;
12409
12451
  background-color: ${({ theme }) => theme.card.background};
12410
12452
  box-shadow:
@@ -12486,7 +12528,7 @@ var ModalContent = (0, import_react23.forwardRef)(({ children }, ref) => {
12486
12528
  md: {
12487
12529
  $flexDirection: "row",
12488
12530
  $height: "calc(100% - 5rem + 3px)",
12489
- $maxHeight: "calc(100vh - 5rem + 3px)"
12531
+ $maxHeight: "calc(100dvh - 5rem + 3px)"
12490
12532
  }
12491
12533
  },
12492
12534
  children
@@ -13037,7 +13079,7 @@ Root.displayName = "Root";
13037
13079
  // src/components/layout/viewport/Viewport.tsx
13038
13080
  var import_debounce3 = __toESM(require_debounce());
13039
13081
  var import_react42 = require("react");
13040
- var import_react_dom2 = require("react-dom");
13082
+ var import_react_dom3 = require("react-dom");
13041
13083
 
13042
13084
  // src/components/shared/billing-threshold-tooltip/BillingThresholdTooltip.tsx
13043
13085
  var import_jsx_runtime12 = require("react/jsx-runtime");
@@ -13073,6 +13115,7 @@ var import_react34 = require("react");
13073
13115
 
13074
13116
  // src/components/shared/sidebar/Sidebar.tsx
13075
13117
  var import_react31 = require("react");
13118
+ var import_react_dom2 = require("react-dom");
13076
13119
 
13077
13120
  // src/components/shared/sidebar/EntitlementRow.tsx
13078
13121
  var import_jsx_runtime13 = require("react/jsx-runtime");
@@ -13195,6 +13238,7 @@ var import_jsx_runtime15 = require("react/jsx-runtime");
13195
13238
  var NoPaymentRequired = ({
13196
13239
  isDisabled,
13197
13240
  isLoading,
13241
+ isSticky,
13198
13242
  onClick
13199
13243
  }) => {
13200
13244
  const { t: t2 } = useTranslation();
@@ -13205,6 +13249,7 @@ var NoPaymentRequired = ({
13205
13249
  disabled: isDisabled,
13206
13250
  onClick,
13207
13251
  $isLoading: isLoading,
13252
+ $size: isSticky ? "sm" : "md",
13208
13253
  $fullWidth: true,
13209
13254
  children: t2("Subscribe and close")
13210
13255
  }
@@ -13221,6 +13266,7 @@ var StageButton = ({
13221
13266
  hasPlan,
13222
13267
  inEditMode,
13223
13268
  isLoading,
13269
+ isSticky,
13224
13270
  isPaymentMethodRequired,
13225
13271
  isSelectedPlanTrialable,
13226
13272
  setCheckoutStage,
@@ -13268,7 +13314,8 @@ var StageButton = ({
13268
13314
  {
13269
13315
  isDisabled,
13270
13316
  isLoading,
13271
- onClick: checkout
13317
+ onClick: checkout,
13318
+ isSticky
13272
13319
  }
13273
13320
  );
13274
13321
  }
@@ -13284,6 +13331,7 @@ var StageButton = ({
13284
13331
  },
13285
13332
  $isLoading: isLoading,
13286
13333
  $fullWidth: true,
13334
+ $size: isSticky ? "sm" : "md",
13287
13335
  children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Flex, { $gap: "0.5rem", $justifyContent: "center", $alignItems: "center", children: [
13288
13336
  t2("Next"),
13289
13337
  ":",
@@ -13303,7 +13351,8 @@ var StageButton = ({
13303
13351
  {
13304
13352
  isDisabled,
13305
13353
  isLoading,
13306
- onClick: checkout
13354
+ onClick: checkout,
13355
+ isSticky
13307
13356
  }
13308
13357
  );
13309
13358
  }
@@ -13319,6 +13368,7 @@ var StageButton = ({
13319
13368
  },
13320
13369
  $isLoading: isLoading,
13321
13370
  $fullWidth: true,
13371
+ $size: isSticky ? "sm" : "md",
13322
13372
  children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
13323
13373
  Flex,
13324
13374
  {
@@ -13351,7 +13401,8 @@ var StageButton = ({
13351
13401
  {
13352
13402
  isDisabled,
13353
13403
  isLoading,
13354
- onClick: checkout
13404
+ onClick: checkout,
13405
+ isSticky
13355
13406
  }
13356
13407
  );
13357
13408
  }
@@ -13393,7 +13444,8 @@ var StageButton = ({
13393
13444
  {
13394
13445
  isDisabled,
13395
13446
  isLoading,
13396
- onClick: checkout
13447
+ onClick: checkout,
13448
+ isSticky
13397
13449
  }
13398
13450
  );
13399
13451
  }
@@ -13407,6 +13459,7 @@ var StageButton = ({
13407
13459
  },
13408
13460
  $isLoading: isLoading,
13409
13461
  $fullWidth: true,
13462
+ $size: isSticky ? "sm" : "md",
13410
13463
  children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
13411
13464
  Flex,
13412
13465
  {
@@ -13432,7 +13485,8 @@ var StageButton = ({
13432
13485
  {
13433
13486
  isDisabled,
13434
13487
  isLoading,
13435
- onClick: checkout
13488
+ onClick: checkout,
13489
+ isSticky
13436
13490
  }
13437
13491
  );
13438
13492
  }
@@ -13471,7 +13525,8 @@ var StageButton = ({
13471
13525
  {
13472
13526
  isDisabled,
13473
13527
  isLoading,
13474
- onClick: checkout
13528
+ onClick: checkout,
13529
+ isSticky
13475
13530
  }
13476
13531
  );
13477
13532
  }
@@ -13843,6 +13898,42 @@ var Sidebar = (0, import_react31.forwardRef)(
13843
13898
  trialEndsOn.setDate(trialEndsOn.getDate() + selectedPlan.trialDays);
13844
13899
  }
13845
13900
  const { price: selectedPlanPrice, currency: selectedPlanCurrency } = selectedPlan ? getPlanPrice(selectedPlan, planPeriod) || {} : {};
13901
+ const buttonRef = (0, import_react31.useRef)(null);
13902
+ const [checkoutButtonInView, setCheckoutButtonInView] = (0, import_react31.useState)(false);
13903
+ (0, import_react31.useEffect)(() => {
13904
+ const observer = new IntersectionObserver(
13905
+ ([entry]) => setCheckoutButtonInView(entry.isIntersecting),
13906
+ { threshold: 0 }
13907
+ );
13908
+ if (buttonRef.current) {
13909
+ observer.observe(buttonRef.current);
13910
+ }
13911
+ return () => observer.disconnect();
13912
+ }, []);
13913
+ const StageButtonComponent = () => {
13914
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
13915
+ StageButton,
13916
+ {
13917
+ checkout: handleCheckout,
13918
+ checkoutStage,
13919
+ checkoutStages,
13920
+ hasAddOns: addOns.length > 0,
13921
+ hasPayInAdvanceEntitlements: payInAdvanceEntitlements.length > 0,
13922
+ hasCreditBundles: creditBundles.length > 0,
13923
+ hasPaymentMethod: typeof paymentMethod !== "undefined" || typeof paymentMethodId === "string",
13924
+ hasPlan: typeof selectedPlan !== "undefined",
13925
+ inEditMode: settings.mode === "edit",
13926
+ isLoading,
13927
+ isPaymentMethodRequired,
13928
+ isSelectedPlanTrialable,
13929
+ isSticky: !checkoutButtonInView,
13930
+ setCheckoutStage,
13931
+ trialPaymentMethodRequired,
13932
+ shouldTrial,
13933
+ willTrialWithoutPaymentMethod
13934
+ }
13935
+ );
13936
+ };
13846
13937
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
13847
13938
  Flex,
13848
13939
  {
@@ -14328,27 +14419,42 @@ var Sidebar = (0, import_react31.forwardRef)(
14328
14419
  ] }) }),
14329
14420
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text, { children: formatCurrency(Math.abs(dueNow), selectedPlanCurrency) }) })
14330
14421
  ] }),
14331
- layout === "checkout" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
14332
- StageButton,
14333
- {
14334
- checkout: handleCheckout,
14335
- checkoutStage,
14336
- checkoutStages,
14337
- hasAddOns: addOns.length > 0,
14338
- hasPayInAdvanceEntitlements: payInAdvanceEntitlements.length > 0,
14339
- hasCreditBundles: creditBundles.length > 0,
14340
- hasPaymentMethod: typeof paymentMethod !== "undefined" || typeof paymentMethodId === "string",
14341
- hasPlan: typeof selectedPlan !== "undefined",
14342
- inEditMode: settings.mode === "edit",
14343
- isLoading,
14344
- isPaymentMethodRequired,
14345
- isSelectedPlanTrialable,
14346
- setCheckoutStage,
14347
- trialPaymentMethodRequired,
14348
- shouldTrial,
14349
- willTrialWithoutPaymentMethod
14350
- }
14351
- ),
14422
+ layout === "checkout" && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { ref: buttonRef, children: [
14423
+ checkoutButtonInView && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(StageButtonComponent, {}),
14424
+ !checkoutButtonInView && (0, import_react_dom2.createPortal)(
14425
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
14426
+ "div",
14427
+ {
14428
+ style: {
14429
+ position: "fixed",
14430
+ bottom: "-1px",
14431
+ left: "0px",
14432
+ zIndex: 9999999,
14433
+ width: "100%",
14434
+ overflow: "hidden",
14435
+ backgroundColor: settings.theme.card.background,
14436
+ borderTopWidth: "1px",
14437
+ borderTopStyle: "solid",
14438
+ borderTopColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)"
14439
+ },
14440
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
14441
+ "div",
14442
+ {
14443
+ style: {
14444
+ display: "flex",
14445
+ justifyContent: "center",
14446
+ alignItems: "center",
14447
+ padding: "1rem 1.5rem",
14448
+ backgroundColor: settings.theme.card.background
14449
+ },
14450
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(StageButtonComponent, {})
14451
+ }
14452
+ )
14453
+ }
14454
+ ),
14455
+ document.body
14456
+ )
14457
+ ] }),
14352
14458
  layout === "unsubscribe" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
14353
14459
  Button,
14354
14460
  {
@@ -15781,6 +15887,7 @@ var CheckoutDialog = ({ top = 0 }) => {
15781
15887
  creditBundles,
15782
15888
  isPaymentMethodRequired
15783
15889
  ]);
15890
+ const [hasSkippedInitialPlan, setHasSkippedInitialPlan] = (0, import_react34.useState)(false);
15784
15891
  const [checkoutStage, setCheckoutStage] = (0, import_react34.useState)(() => {
15785
15892
  if (checkoutState?.addOnId) {
15786
15893
  return "addons";
@@ -15794,11 +15901,25 @@ var CheckoutDialog = ({ top = 0 }) => {
15794
15901
  if (checkoutState?.credits) {
15795
15902
  return "credits";
15796
15903
  }
15797
- if (typeof checkoutState?.planId !== "undefined" && checkoutState.planId !== currentPlanId) {
15798
- return checkoutStages.some((stage) => stage.id === "usage") ? "usage" : checkoutStages.some((stage) => stage.id === "addons") ? "addons" : checkoutStages.some((stage) => stage.id === "addonsUsage") ? "addonsUsage" : checkoutStages.some((stage) => stage.id === "credits") ? "credits" : "plan";
15904
+ if (typeof checkoutState?.planId !== "undefined" && checkoutState.planId !== currentPlanId || checkoutState?.bypassPlanSelection) {
15905
+ return checkoutStages.some((stage) => stage.id === "usage") ? "usage" : checkoutStages.some((stage) => stage.id === "addons") ? "addons" : checkoutStages.some((stage) => stage.id === "addonsUsage") ? "addonsUsage" : checkoutStages.some((stage) => stage.id === "credits") ? "credits" : checkoutStages.some((stage) => stage.id === "checkout") ? "checkout" : checkoutStages[0]?.id || "plan";
15799
15906
  }
15800
15907
  return "plan";
15801
15908
  });
15909
+ (0, import_react34.useEffect)(() => {
15910
+ if (checkoutState?.bypassPlanSelection && checkoutStage === "plan" && !hasSkippedInitialPlan) {
15911
+ const nextStage = checkoutStages.find((stage) => stage.id !== "plan");
15912
+ if (nextStage) {
15913
+ setHasSkippedInitialPlan(true);
15914
+ setCheckoutStage(nextStage.id);
15915
+ }
15916
+ }
15917
+ }, [
15918
+ checkoutStages,
15919
+ checkoutState?.bypassPlanSelection,
15920
+ checkoutStage,
15921
+ hasSkippedInitialPlan
15922
+ ]);
15802
15923
  const handlePreviewCheckout = (0, import_react34.useCallback)(
15803
15924
  async (updates) => {
15804
15925
  const period = updates.period || planPeriod;
@@ -15926,14 +16047,19 @@ var CheckoutDialog = ({ top = 0 }) => {
15926
16047
  const selectPlan = (0, import_react34.useCallback)(
15927
16048
  (updates) => {
15928
16049
  const plan = updates.plan;
15929
- const period = updates.period || planPeriod;
16050
+ const period = showPeriodToggle ? updates.period || planPeriod : plan.yearlyPrice && !plan.monthlyPrice ? "year" /* Year */ : "month" /* Month */;
15930
16051
  const updatedUsageBasedEntitlements = plan.entitlements.reduce(
15931
16052
  createActiveUsageBasedEntitlementsReducer(currentEntitlements, period),
15932
16053
  []
15933
16054
  );
16055
+ if (period !== planPeriod || plan.id !== selectedPlan?.id) {
16056
+ setUsageBasedEntitlements(updatedUsageBasedEntitlements);
16057
+ }
16058
+ if (period !== planPeriod) {
16059
+ setPlanPeriod(period);
16060
+ }
15934
16061
  if (plan.id !== selectedPlan?.id) {
15935
16062
  setSelectedPlan(plan);
15936
- setUsageBasedEntitlements(updatedUsageBasedEntitlements);
15937
16063
  }
15938
16064
  const updatedShouldTrial = updates.shouldTrial ?? shouldTrial;
15939
16065
  setShouldTrial(updatedShouldTrial);
@@ -15962,6 +16088,7 @@ var CheckoutDialog = ({ top = 0 }) => {
15962
16088
  [
15963
16089
  selectedPlan?.id,
15964
16090
  planPeriod,
16091
+ showPeriodToggle,
15965
16092
  currentEntitlements,
15966
16093
  shouldTrial,
15967
16094
  willTrialWithoutPaymentMethod,
@@ -16067,11 +16194,28 @@ var CheckoutDialog = ({ top = 0 }) => {
16067
16194
  }
16068
16195
  }, []);
16069
16196
  (0, import_react34.useEffect)(() => {
16070
- const plan = availablePlans.find(
16071
- (plan2) => checkoutState?.planId ? plan2.id === checkoutState.planId : plan2.current
16072
- );
16073
- setSelectedPlan(plan);
16197
+ if (checkoutState?.planId) {
16198
+ const plan = availablePlans.find(
16199
+ (plan2) => plan2.id === checkoutState.planId
16200
+ );
16201
+ setSelectedPlan(plan);
16202
+ }
16074
16203
  }, [availablePlans, checkoutState?.planId]);
16204
+ (0, import_react34.useEffect)(() => {
16205
+ if (checkoutState?.addOnId) {
16206
+ const checkoutStateAddOn = availableAddOns.find(
16207
+ (addOn) => addOn.id === checkoutState.addOnId
16208
+ );
16209
+ setAddOns(
16210
+ (prev2) => prev2.map((addOn) => ({
16211
+ ...addOn,
16212
+ ...addOn.id === checkoutStateAddOn?.id && {
16213
+ isSelected: true
16214
+ }
16215
+ }))
16216
+ );
16217
+ }
16218
+ }, [availableAddOns, checkoutState?.addOnId]);
16075
16219
  (0, import_react34.useEffect)(() => {
16076
16220
  setAddOns((prevAddOns) => {
16077
16221
  return availableAddOns.filter((availAddOn) => {
@@ -16113,7 +16257,30 @@ var CheckoutDialog = ({ top = 0 }) => {
16113
16257
  const activeCheckoutStage = checkoutStages.find(
16114
16258
  (stage) => stage.id === checkoutStage
16115
16259
  );
16260
+ const shouldShowBypassOverlay = checkoutState?.bypassPlanSelection && checkoutStage === "plan" && !hasSkippedInitialPlan;
16116
16261
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Modal2, { ref: modalRef, size: "lg", top, children: [
16262
+ shouldShowBypassOverlay && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
16263
+ Flex,
16264
+ {
16265
+ $position: "absolute",
16266
+ $top: 0,
16267
+ $left: 0,
16268
+ $zIndex: 3,
16269
+ $width: "100%",
16270
+ $height: "100dvh",
16271
+ $justifyContent: "center",
16272
+ $alignItems: "center",
16273
+ $backgroundColor: isLightBackground ? "hsla(0, 0%, 100%, 0.9)" : "hsla(0, 0%, 0%, 0.9)",
16274
+ $backdropFilter: "blur(8px)",
16275
+ $padding: "1rem",
16276
+ $viewport: {
16277
+ md: {
16278
+ $padding: "1.5rem"
16279
+ }
16280
+ },
16281
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Loader, { $color: settings.theme.primary, $size: "2xl" })
16282
+ }
16283
+ ),
16117
16284
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ModalHeader, { bordered: true, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
16118
16285
  Flex,
16119
16286
  {
@@ -16503,7 +16670,6 @@ var PeriodToggle = ({
16503
16670
  const yearly = yearlyBillingPrice?.price ?? 0;
16504
16671
  return Math.round((monthly - yearly) / monthly * 1e4) / 100;
16505
16672
  }
16506
- return 0;
16507
16673
  }, [selectedPlan]);
16508
16674
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
16509
16675
  Flex,
@@ -16558,7 +16724,7 @@ var PeriodToggle = ({
16558
16724
  },
16559
16725
  option
16560
16726
  );
16561
- if (option === "year") {
16727
+ if (option === "year" && typeof savingsPercentage === "number") {
16562
16728
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
16563
16729
  Tooltip,
16564
16730
  {
@@ -17107,12 +17273,12 @@ var Viewport = (0, import_react42.forwardRef)(
17107
17273
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(RenderLayout, { children }),
17108
17274
  isBadgeVisible && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Badge, {})
17109
17275
  ] }),
17110
- canCheckout && layout === "checkout" && (0, import_react_dom2.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(CheckoutDialog, { top }), portal || document.body),
17111
- layout === "unsubscribe" && (0, import_react_dom2.createPortal)(
17276
+ canCheckout && layout === "checkout" && (0, import_react_dom3.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(CheckoutDialog, { top }), portal || document.body),
17277
+ layout === "unsubscribe" && (0, import_react_dom3.createPortal)(
17112
17278
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(UnsubscribeDialog, { top }),
17113
17279
  portal || document.body
17114
17280
  ),
17115
- layout === "payment" && (0, import_react_dom2.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(PaymentDialog, { top }), portal || document.body)
17281
+ layout === "payment" && (0, import_react_dom3.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(PaymentDialog, { top }), portal || document.body)
17116
17282
  ] });
17117
17283
  }
17118
17284
  );
@@ -19113,7 +19279,7 @@ var resolveDesignProps7 = (props) => {
19113
19279
  var PlanManager = (0, import_react52.forwardRef)(({ children, className, portal, ...rest }, ref) => {
19114
19280
  const props = resolveDesignProps7(rest);
19115
19281
  const { t: t2 } = useTranslation();
19116
- const { data, settings, setCheckoutState } = useEmbed();
19282
+ const { data, settings, setLayout } = useEmbed();
19117
19283
  const isLightBackground = useIsLightBackground();
19118
19284
  const trialEnd = useTrialEnd();
19119
19285
  const {
@@ -19474,11 +19640,7 @@ var PlanManager = (0, import_react52.forwardRef)(({ children, className, portal,
19474
19640
  {
19475
19641
  type: "button",
19476
19642
  onClick: () => {
19477
- setCheckoutState({
19478
- planId: currentPlan?.id,
19479
- addOnId: void 0,
19480
- usage: false
19481
- });
19643
+ setLayout("checkout");
19482
19644
  },
19483
19645
  $size: props.callToAction.buttonSize,
19484
19646
  $color: props.callToAction.buttonStyle,
@@ -20311,25 +20473,9 @@ var PricingTable = (0, import_react55.forwardRef)(({ className, ...rest }, ref)
20311
20473
  },
20312
20474
  []
20313
20475
  );
20314
- const { currentPeriod, isStandalone } = (0, import_react55.useMemo)(() => {
20315
- const isStandalone2 = typeof data?.component === "undefined";
20316
- return {
20317
- currentPeriod: data?.company?.plan?.planPeriod || "month",
20318
- currentAddOns: data?.company?.addOns || [],
20319
- canCheckout: isStandalone2 ?? data?.capabilities?.checkout ?? true,
20320
- isTrialSubscription: data?.company?.billingSubscription?.status === "trialing",
20321
- willSubscriptionCancel: data?.company?.billingSubscription?.cancelAt,
20322
- isStandalone: isStandalone2
20323
- };
20324
- }, [
20325
- data?.capabilities?.checkout,
20326
- data?.company?.addOns,
20327
- data?.company?.billingSubscription?.cancelAt,
20328
- data?.company?.billingSubscription?.status,
20329
- data?.company?.plan?.planPeriod,
20330
- data?.component
20331
- ]);
20332
- const [selectedPeriod, setSelectedPeriod] = (0, import_react55.useState)(currentPeriod);
20476
+ const [selectedPeriod, setSelectedPeriod] = (0, import_react55.useState)(
20477
+ () => data?.company?.plan?.planPeriod || "month"
20478
+ );
20333
20479
  const showPeriodToggle = rest.showPeriodToggle ?? data?.showPeriodToggle ?? true;
20334
20480
  const { plans, addOns, periods } = useAvailablePlans(selectedPeriod, {
20335
20481
  useSelectedPeriod: showPeriodToggle
@@ -20353,10 +20499,10 @@ var PricingTable = (0, import_react55.forwardRef)(({ className, ...rest }, ref)
20353
20499
  });
20354
20500
  };
20355
20501
  (0, import_react55.useEffect)(() => {
20356
- if (isStandalone) {
20502
+ if (typeof data?.component === "undefined") {
20357
20503
  hydratePublic();
20358
20504
  }
20359
- }, [isStandalone, hydratePublic]);
20505
+ }, [data?.component, hydratePublic]);
20360
20506
  (0, import_react55.useEffect)(() => {
20361
20507
  setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
20362
20508
  }, [plans]);
@@ -20373,12 +20519,13 @@ var PricingTable = (0, import_react55.forwardRef)(({ className, ...rest }, ref)
20373
20519
  }
20374
20520
  );
20375
20521
  }
20522
+ const currentPlan = plans.find((plan) => plan.id === data?.company?.plan?.id);
20376
20523
  const showCallToAction = typeof data?.component !== "undefined" || typeof rest.callToActionUrl === "string" || typeof rest.onCallToAction === "function";
20377
20524
  const callToActionTarget = getCallToActionTarget(
20378
20525
  rest.callToActionUrl,
20379
20526
  rest.callToActionTarget
20380
20527
  );
20381
- const Wrapper = isStandalone ? Container : import_react55.Fragment;
20528
+ const Wrapper = typeof data?.component === "undefined" ? Container : import_react55.Fragment;
20382
20529
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
20383
20530
  FussyChild,
20384
20531
  {
@@ -20411,6 +20558,7 @@ var PricingTable = (0, import_react55.forwardRef)(({ className, ...rest }, ref)
20411
20558
  {
20412
20559
  options: periods,
20413
20560
  selectedOption: selectedPeriod,
20561
+ selectedPlan: currentPlan,
20414
20562
  onSelect: (period) => {
20415
20563
  if (period !== selectedPeriod) {
20416
20564
  setSelectedPeriod(period);