@schematichq/schematic-components 0.3.9 → 0.3.11

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.
@@ -2641,7 +2641,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
2641
2641
  }
2642
2642
  stripe._registerWrapper({
2643
2643
  name: "stripe-js",
2644
- version: "4.7.0",
2644
+ version: "4.8.0",
2645
2645
  startTime
2646
2646
  });
2647
2647
  };
@@ -7264,9 +7264,6 @@ function BillingProductDetailResponseDataFromJSONTyped(json, ignoreDiscriminator
7264
7264
  return json;
7265
7265
  }
7266
7266
  return {
7267
- prices: json["Prices"].map(
7268
- BillingPriceResponseDataFromJSON
7269
- ),
7270
7267
  accountId: json["account_id"],
7271
7268
  createdAt: new Date(json["created_at"]),
7272
7269
  currency: json["currency"],
@@ -7274,6 +7271,9 @@ function BillingProductDetailResponseDataFromJSONTyped(json, ignoreDiscriminator
7274
7271
  externalId: json["external_id"],
7275
7272
  name: json["name"],
7276
7273
  price: json["price"],
7274
+ prices: json["prices"].map(
7275
+ BillingPriceResponseDataFromJSON
7276
+ ),
7277
7277
  productId: json["product_id"],
7278
7278
  quantity: json["quantity"],
7279
7279
  updatedAt: new Date(json["updated_at"])
@@ -7289,7 +7289,6 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
7289
7289
  return json;
7290
7290
  }
7291
7291
  return {
7292
- accountId: json["account_id"],
7293
7292
  createdAt: new Date(json["created_at"]),
7294
7293
  currency: json["currency"],
7295
7294
  environmentId: json["environment_id"],
@@ -7314,16 +7313,111 @@ function BillingSubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator)
7314
7313
  return json;
7315
7314
  }
7316
7315
  return {
7316
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
7317
+ createdAt: new Date(json["created_at"]),
7317
7318
  currency: json["currency"],
7319
+ customerExternalId: json["customer_external_id"],
7318
7320
  expiredAt: json["expired_at"] == null ? void 0 : new Date(json["expired_at"]),
7319
- externalId: json["external_id"],
7320
7321
  id: json["id"],
7321
7322
  interval: json["interval"],
7322
- totalPrice: json["total_price"],
7323
+ metadata: json["metadata"] == null ? void 0 : json["metadata"],
7324
+ periodEnd: json["period_end"],
7325
+ periodStart: json["period_start"],
7326
+ status: json["status"],
7327
+ subscriptionExternalId: json["subscription_external_id"],
7328
+ totalPrice: json["total_price"]
7329
+ };
7330
+ }
7331
+
7332
+ // src/api/models/InvoiceResponseData.ts
7333
+ function InvoiceResponseDataFromJSON(json) {
7334
+ return InvoiceResponseDataFromJSONTyped(json, false);
7335
+ }
7336
+ function InvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7337
+ if (json == null) {
7338
+ return json;
7339
+ }
7340
+ return {
7341
+ amountDue: json["amount_due"],
7342
+ amountPaid: json["amount_paid"],
7343
+ amountRemaining: json["amount_remaining"],
7344
+ collectionMethod: json["collection_method"],
7345
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
7346
+ createdAt: new Date(json["created_at"]),
7347
+ currency: json["currency"],
7348
+ customerExternalId: json["customer_external_id"],
7349
+ dueDate: json["due_date"] == null ? void 0 : new Date(json["due_date"]),
7350
+ environmentId: json["environment_id"],
7351
+ externalId: json["external_id"] == null ? void 0 : json["external_id"],
7352
+ id: json["id"],
7353
+ paymentMethodExternalId: json["payment_method_external_id"] == null ? void 0 : json["payment_method_external_id"],
7354
+ subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7355
+ subtotal: json["subtotal"],
7356
+ updatedAt: new Date(json["updated_at"]),
7357
+ url: json["url"] == null ? void 0 : json["url"]
7358
+ };
7359
+ }
7360
+
7361
+ // src/api/models/PaymentMethodResponseData.ts
7362
+ function PaymentMethodResponseDataFromJSON(json) {
7363
+ return PaymentMethodResponseDataFromJSONTyped(json, false);
7364
+ }
7365
+ function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7366
+ if (json == null) {
7367
+ return json;
7368
+ }
7369
+ return {
7370
+ accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
7371
+ accountName: json["account_name"] == null ? void 0 : json["account_name"],
7372
+ bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
7373
+ billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
7374
+ billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
7375
+ cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
7376
+ cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
7377
+ cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
7378
+ cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
7379
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
7380
+ createdAt: new Date(json["created_at"]),
7381
+ customerExternalId: json["customer_external_id"],
7382
+ environmentId: json["environment_id"],
7383
+ externalId: json["external_id"],
7384
+ id: json["id"],
7385
+ paymentMethodType: json["payment_method_type"],
7386
+ subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7323
7387
  updatedAt: new Date(json["updated_at"])
7324
7388
  };
7325
7389
  }
7326
7390
 
7391
+ // src/api/models/BillingSubscriptionView.ts
7392
+ function BillingSubscriptionViewFromJSON(json) {
7393
+ return BillingSubscriptionViewFromJSONTyped(json, false);
7394
+ }
7395
+ function BillingSubscriptionViewFromJSONTyped(json, ignoreDiscriminator) {
7396
+ if (json == null) {
7397
+ return json;
7398
+ }
7399
+ return {
7400
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
7401
+ createdAt: new Date(json["created_at"]),
7402
+ currency: json["currency"],
7403
+ customerExternalId: json["customer_external_id"],
7404
+ expiredAt: json["expired_at"] == null ? void 0 : new Date(json["expired_at"]),
7405
+ id: json["id"],
7406
+ interval: json["interval"],
7407
+ latestInvoice: json["latest_invoice"] == null ? void 0 : InvoiceResponseDataFromJSON(json["latest_invoice"]),
7408
+ metadata: json["metadata"] == null ? void 0 : json["metadata"],
7409
+ paymentMethod: json["payment_method"] == null ? void 0 : PaymentMethodResponseDataFromJSON(json["payment_method"]),
7410
+ periodEnd: json["period_end"],
7411
+ periodStart: json["period_start"],
7412
+ products: json["products"].map(
7413
+ BillingProductForSubscriptionResponseDataFromJSON
7414
+ ),
7415
+ status: json["status"],
7416
+ subscriptionExternalId: json["subscription_external_id"],
7417
+ totalPrice: json["total_price"]
7418
+ };
7419
+ }
7420
+
7327
7421
  // src/api/models/ChangeSubscriptionRequestBody.ts
7328
7422
  function ChangeSubscriptionRequestBodyToJSON(value) {
7329
7423
  if (value == null) {
@@ -7475,7 +7569,7 @@ function CompanyDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7475
7569
  CompanyPlanWithBillingSubViewFromJSON
7476
7570
  ),
7477
7571
  billingSubscriptions: json["billing_subscriptions"].map(
7478
- BillingSubscriptionResponseDataFromJSON
7572
+ BillingSubscriptionViewFromJSON
7479
7573
  ),
7480
7574
  createdAt: new Date(json["created_at"]),
7481
7575
  entityTraits: json["entity_traits"].map(
@@ -7783,65 +7877,6 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7783
7877
  };
7784
7878
  }
7785
7879
 
7786
- // src/api/models/InvoiceResponseData.ts
7787
- function InvoiceResponseDataFromJSON(json) {
7788
- return InvoiceResponseDataFromJSONTyped(json, false);
7789
- }
7790
- function InvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7791
- if (json == null) {
7792
- return json;
7793
- }
7794
- return {
7795
- amountDue: json["amount_due"],
7796
- amountPaid: json["amount_paid"],
7797
- amountRemaining: json["amount_remaining"],
7798
- collectionMethod: json["collection_method"],
7799
- companyId: json["company_id"] == null ? void 0 : json["company_id"],
7800
- createdAt: new Date(json["created_at"]),
7801
- currency: json["currency"],
7802
- customerExternalId: json["customer_external_id"],
7803
- dueDate: json["due_date"] == null ? void 0 : new Date(json["due_date"]),
7804
- environmentId: json["environment_id"],
7805
- externalId: json["external_id"] == null ? void 0 : json["external_id"],
7806
- id: json["id"],
7807
- paymentMethodExternalId: json["payment_method_external_id"] == null ? void 0 : json["payment_method_external_id"],
7808
- subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7809
- subtotal: json["subtotal"],
7810
- updatedAt: new Date(json["updated_at"]),
7811
- url: json["url"] == null ? void 0 : json["url"]
7812
- };
7813
- }
7814
-
7815
- // src/api/models/PaymentMethodResponseData.ts
7816
- function PaymentMethodResponseDataFromJSON(json) {
7817
- return PaymentMethodResponseDataFromJSONTyped(json, false);
7818
- }
7819
- function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7820
- if (json == null) {
7821
- return json;
7822
- }
7823
- return {
7824
- accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
7825
- accountName: json["account_name"] == null ? void 0 : json["account_name"],
7826
- bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
7827
- billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
7828
- billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
7829
- cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
7830
- cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
7831
- cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
7832
- cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
7833
- companyId: json["company_id"] == null ? void 0 : json["company_id"],
7834
- createdAt: new Date(json["created_at"]),
7835
- customerExternalId: json["customer_external_id"],
7836
- environmentId: json["environment_id"],
7837
- externalId: json["external_id"],
7838
- id: json["id"],
7839
- paymentMethodType: json["payment_method_type"],
7840
- subscriptionExternalId: json["subscription_external_id"] == null ? void 0 : json["subscription_external_id"],
7841
- updatedAt: new Date(json["updated_at"])
7842
- };
7843
- }
7844
-
7845
7880
  // src/api/models/CompanySubscriptionResponseData.ts
7846
7881
  function CompanySubscriptionResponseDataFromJSON(json) {
7847
7882
  return CompanySubscriptionResponseDataFromJSONTyped(json, false);
@@ -7866,6 +7901,19 @@ function CompanySubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator)
7866
7901
  };
7867
7902
  }
7868
7903
 
7904
+ // src/api/models/ComponentCapabilities.ts
7905
+ function ComponentCapabilitiesFromJSON(json) {
7906
+ return ComponentCapabilitiesFromJSONTyped(json, false);
7907
+ }
7908
+ function ComponentCapabilitiesFromJSONTyped(json, ignoreDiscriminator) {
7909
+ if (json == null) {
7910
+ return json;
7911
+ }
7912
+ return {
7913
+ checkout: json["checkout"]
7914
+ };
7915
+ }
7916
+
7869
7917
  // src/api/models/ComponentResponseData.ts
7870
7918
  function ComponentResponseDataFromJSON(json) {
7871
7919
  return ComponentResponseDataFromJSONTyped(json, false);
@@ -7944,9 +7992,13 @@ function ComponentHydrateResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7944
7992
  return json;
7945
7993
  }
7946
7994
  return {
7995
+ activeAddOns: json["active_add_ons"].map(
7996
+ CompanyPlanDetailResponseDataFromJSON
7997
+ ),
7947
7998
  activePlans: json["active_plans"].map(
7948
7999
  CompanyPlanDetailResponseDataFromJSON
7949
8000
  ),
8001
+ capabilities: json["capabilities"] == null ? void 0 : ComponentCapabilitiesFromJSON(json["capabilities"]),
7950
8002
  company: json["company"] == null ? void 0 : CompanyDetailResponseDataFromJSON(json["company"]),
7951
8003
  component: json["component"] == null ? void 0 : ComponentResponseDataFromJSON(json["component"]),
7952
8004
  featureUsage: json["feature_usage"] == null ? void 0 : FeatureUsageDetailResponseDataFromJSON(json["feature_usage"]),
@@ -8751,6 +8803,7 @@ function parseEditorState(data) {
8751
8803
  var EmbedContext = (0, import_react2.createContext)({
8752
8804
  api: null,
8753
8805
  data: {
8806
+ activeAddOns: [],
8754
8807
  activePlans: []
8755
8808
  },
8756
8809
  nodes: [],
@@ -8781,6 +8834,7 @@ var EmbedProvider = ({
8781
8834
  return {
8782
8835
  api: null,
8783
8836
  data: {
8837
+ activeAddOns: [],
8784
8838
  activePlans: []
8785
8839
  },
8786
8840
  nodes: [],
@@ -8882,7 +8936,7 @@ var EmbedProvider = ({
8882
8936
  (0, import_react2.useEffect)(() => {
8883
8937
  if (accessToken) {
8884
8938
  const { headers = {} } = apiConfig ?? {};
8885
- headers["X-Schematic-Components-Version"] = "0.3.9";
8939
+ headers["X-Schematic-Components-Version"] = "0.3.11";
8886
8940
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
8887
8941
  const config = new Configuration({
8888
8942
  ...apiConfig,
@@ -9946,7 +10000,8 @@ var CheckoutDialog = () => {
9946
10000
  document.body.style.overflow = "";
9947
10001
  };
9948
10002
  }, []);
9949
- const allowCheckout = api && selectedPlan && (selectedPlan.id !== currentPlan?.id || planPeriod !== currentPlan.planPeriod) && (paymentMethod && !showPaymentForm || paymentMethodId) && !isLoading;
10003
+ const canUpdateSubscription = api && selectedPlan && (selectedPlan.id !== currentPlan?.id || planPeriod !== currentPlan.planPeriod) && !isLoading;
10004
+ const canCheckout = canUpdateSubscription && (paymentMethod && !showPaymentForm || paymentMethodId);
9950
10005
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Modal, { size: "lg", children: [
9951
10006
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ModalHeader, { bordered: true, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Flex, { $gap: "1rem", children: [
9952
10007
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Flex, { $gap: "0.5rem", $alignItems: "center", children: [
@@ -10467,7 +10522,7 @@ var CheckoutDialog = () => {
10467
10522
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
10468
10523
  Flex,
10469
10524
  {
10470
- ...allowCheckout && {
10525
+ ...canCheckout && {
10471
10526
  $opacity: "0.625",
10472
10527
  $textDecoration: "line-through"
10473
10528
  },
@@ -10500,7 +10555,7 @@ var CheckoutDialog = () => {
10500
10555
  ]
10501
10556
  }
10502
10557
  ),
10503
- allowCheckout && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Box, { $marginBottom: "1rem", children: [
10558
+ canCheckout && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Box, { $marginBottom: "1rem", children: [
10504
10559
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
10505
10560
  Box,
10506
10561
  {
@@ -10693,7 +10748,7 @@ var CheckoutDialog = () => {
10693
10748
  EmbedButton,
10694
10749
  {
10695
10750
  isLoading,
10696
- ...allowCheckout ? {
10751
+ ...canUpdateSubscription ? {
10697
10752
  onClick: async () => {
10698
10753
  if (!data.component?.id) {
10699
10754
  return;
@@ -10722,9 +10777,9 @@ var CheckoutDialog = () => {
10722
10777
  ) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
10723
10778
  EmbedButton,
10724
10779
  {
10725
- disabled: isLoading || !allowCheckout,
10780
+ disabled: isLoading || !canCheckout,
10726
10781
  isLoading,
10727
- ...allowCheckout && { onClick: checkout },
10782
+ ...canCheckout && { onClick: checkout },
10728
10783
  children: "Pay now"
10729
10784
  }
10730
10785
  ),
@@ -11004,7 +11059,9 @@ function resolveDesignProps(props) {
11004
11059
  usage: {
11005
11060
  isVisible: props.usage?.isVisible ?? true,
11006
11061
  fontStyle: props.usage?.fontStyle ?? "heading6"
11007
- }
11062
+ },
11063
+ // there is a typescript bug with `RecursivePartial` so we must cast to `string[] | undefined`
11064
+ visibleFeatures: props.visibleFeatures
11008
11065
  };
11009
11066
  }
11010
11067
  var IncludedFeatures = (0, import_react14.forwardRef)(({ className, ...rest }, ref) => {
@@ -11014,7 +11071,16 @@ var IncludedFeatures = (0, import_react14.forwardRef)(({ className, ...rest }, r
11014
11071
  const elements = (0, import_react14.useRef)([]);
11015
11072
  const shouldWrapChildren = useWrapChildren(elements.current);
11016
11073
  const isLightBackground = useIsLightBackground();
11017
- const shouldShowFeatures = (data.featureUsage?.features ?? []).length > 0 || data.company?.plan || (data.company?.addOns ?? []).length > 0 || false;
11074
+ const featureUsage = props.visibleFeatures ? props.visibleFeatures.reduce((acc, id) => {
11075
+ const mappedFeatureUsage = data.featureUsage?.features.find(
11076
+ (usage) => usage.feature?.id === id
11077
+ );
11078
+ if (mappedFeatureUsage) {
11079
+ acc.push(mappedFeatureUsage);
11080
+ }
11081
+ return acc;
11082
+ }, []) : data.featureUsage?.features || [];
11083
+ const shouldShowFeatures = featureUsage.length > 0 || data.company?.plan || (data.company?.addOns ?? []).length > 0 || false;
11018
11084
  if (!shouldShowFeatures) {
11019
11085
  return null;
11020
11086
  }
@@ -11037,82 +11103,76 @@ var IncludedFeatures = (0, import_react14.forwardRef)(({ className, ...rest }, r
11037
11103
  children: props.header.text
11038
11104
  }
11039
11105
  ) }),
11040
- (data.featureUsage?.features || []).reduce(
11041
- (acc, { allocation, feature, usage }, index) => {
11042
- return [
11043
- ...acc,
11044
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
11045
- Flex,
11046
- {
11047
- ref: (el) => el && elements.current.push(el),
11048
- $flexWrap: "wrap",
11049
- $justifyContent: "space-between",
11050
- $alignItems: "center",
11051
- $gap: "1rem",
11052
- children: [
11053
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Flex, { $flexGrow: "1", $flexBasis: "min-content", $gap: "1rem", children: [
11054
- props.icons.isVisible && feature?.icon && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
11055
- IconRound,
11106
+ featureUsage.map(({ allocation, feature, usage }, index) => {
11107
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
11108
+ Flex,
11109
+ {
11110
+ ref: (el) => el && elements.current.push(el),
11111
+ $flexWrap: "wrap",
11112
+ $justifyContent: "space-between",
11113
+ $alignItems: "center",
11114
+ $gap: "1rem",
11115
+ children: [
11116
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Flex, { $flexGrow: "1", $flexBasis: "min-content", $gap: "1rem", children: [
11117
+ props.icons.isVisible && feature?.icon && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
11118
+ IconRound,
11119
+ {
11120
+ name: feature.icon,
11121
+ size: "sm",
11122
+ colors: [
11123
+ theme.primary,
11124
+ isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.25)"
11125
+ ]
11126
+ }
11127
+ ),
11128
+ feature?.name && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Flex, { $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
11129
+ Text,
11130
+ {
11131
+ $font: theme.typography[props.icons.fontStyle].fontFamily,
11132
+ $size: theme.typography[props.icons.fontStyle].fontSize,
11133
+ $weight: theme.typography[props.icons.fontStyle].fontWeight,
11134
+ $color: theme.typography[props.icons.fontStyle].color,
11135
+ children: feature.name
11136
+ }
11137
+ ) })
11138
+ ] }),
11139
+ (feature?.featureType === "event" || feature?.featureType === "trait") && feature?.name && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
11140
+ Box,
11141
+ {
11142
+ $flexBasis: "min-content",
11143
+ $flexGrow: "1",
11144
+ $textAlign: shouldWrapChildren ? "left" : "right",
11145
+ children: [
11146
+ props.entitlement.isVisible && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
11147
+ Text,
11056
11148
  {
11057
- name: feature.icon,
11058
- size: "sm",
11059
- colors: [
11060
- theme.primary,
11061
- isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.25)"
11062
- ]
11149
+ $font: theme.typography[props.entitlement.fontStyle].fontFamily,
11150
+ $size: theme.typography[props.entitlement.fontStyle].fontSize,
11151
+ $weight: theme.typography[props.entitlement.fontStyle].fontWeight,
11152
+ $lineHeight: 1.25,
11153
+ $color: theme.typography[props.entitlement.fontStyle].color,
11154
+ children: typeof allocation === "number" ? `${formatNumber(allocation)} ${(0, import_pluralize2.default)(feature.name, allocation)}` : `Unlimited ${(0, import_pluralize2.default)(feature.name)}`
11063
11155
  }
11064
- ),
11065
- feature?.name && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Flex, { $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
11156
+ ) }),
11157
+ props.usage.isVisible && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
11066
11158
  Text,
11067
11159
  {
11068
- $font: theme.typography[props.icons.fontStyle].fontFamily,
11069
- $size: theme.typography[props.icons.fontStyle].fontSize,
11070
- $weight: theme.typography[props.icons.fontStyle].fontWeight,
11071
- $color: theme.typography[props.icons.fontStyle].color,
11072
- children: feature.name
11160
+ $font: theme.typography[props.usage.fontStyle].fontFamily,
11161
+ $size: theme.typography[props.usage.fontStyle].fontSize,
11162
+ $weight: theme.typography[props.usage.fontStyle].fontWeight,
11163
+ $lineHeight: 1.5,
11164
+ $color: theme.typography[props.usage.fontStyle].color,
11165
+ children: typeof usage === "number" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: typeof allocation === "number" ? `${formatNumber(usage)} of ${formatNumber(allocation)} used` : `${formatNumber(usage)} used` })
11073
11166
  }
11074
11167
  ) })
11075
- ] }),
11076
- (feature?.featureType === "event" || feature?.featureType === "trait") && feature?.name && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
11077
- Box,
11078
- {
11079
- $flexBasis: "min-content",
11080
- $flexGrow: "1",
11081
- $textAlign: shouldWrapChildren ? "left" : "right",
11082
- children: [
11083
- props.entitlement.isVisible && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
11084
- Text,
11085
- {
11086
- $font: theme.typography[props.entitlement.fontStyle].fontFamily,
11087
- $size: theme.typography[props.entitlement.fontStyle].fontSize,
11088
- $weight: theme.typography[props.entitlement.fontStyle].fontWeight,
11089
- $lineHeight: 1.25,
11090
- $color: theme.typography[props.entitlement.fontStyle].color,
11091
- children: typeof allocation === "number" ? `${formatNumber(allocation)} ${(0, import_pluralize2.default)(feature.name, allocation)}` : `Unlimited ${(0, import_pluralize2.default)(feature.name)}`
11092
- }
11093
- ) }),
11094
- props.usage.isVisible && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
11095
- Text,
11096
- {
11097
- $font: theme.typography[props.usage.fontStyle].fontFamily,
11098
- $size: theme.typography[props.usage.fontStyle].fontSize,
11099
- $weight: theme.typography[props.usage.fontStyle].fontWeight,
11100
- $lineHeight: 1.5,
11101
- $color: theme.typography[props.usage.fontStyle].color,
11102
- children: typeof usage === "number" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: typeof allocation === "number" ? `${formatNumber(usage)} of ${formatNumber(allocation)} used` : `${formatNumber(usage)} used` })
11103
- }
11104
- ) })
11105
- ]
11106
- }
11107
- )
11108
- ]
11109
- },
11110
- index
11111
- )
11112
- ];
11113
- },
11114
- []
11115
- )
11168
+ ]
11169
+ }
11170
+ )
11171
+ ]
11172
+ },
11173
+ index
11174
+ );
11175
+ })
11116
11176
  ]
11117
11177
  }
11118
11178
  );
@@ -11257,7 +11317,9 @@ function resolveDesignProps3(props) {
11257
11317
  usage: {
11258
11318
  isVisible: props.usage?.isVisible ?? true,
11259
11319
  fontStyle: props.usage?.fontStyle ?? "heading5"
11260
- }
11320
+ },
11321
+ // there is a typescript bug with `RecursivePartial` so we must cast to `string[] | undefined`
11322
+ visibleFeatures: props.visibleFeatures
11261
11323
  };
11262
11324
  }
11263
11325
  var MeteredFeatures = (0, import_react16.forwardRef)(({ className, ...rest }, ref) => {
@@ -11267,13 +11329,22 @@ var MeteredFeatures = (0, import_react16.forwardRef)(({ className, ...rest }, re
11267
11329
  const theme = nt();
11268
11330
  const { data } = useEmbed();
11269
11331
  const isLightBackground = useIsLightBackground();
11270
- const features = (data.featureUsage?.features || []).filter(({ feature }) => {
11271
- return feature?.featureType === "event" || feature?.featureType === "trait";
11272
- });
11273
- if (features.length === 0) {
11332
+ const featureUsage = props.visibleFeatures ? props.visibleFeatures.reduce((acc, id) => {
11333
+ const mappedFeatureUsage = data.featureUsage?.features.find(
11334
+ (usage) => usage.feature?.id === id
11335
+ );
11336
+ if (mappedFeatureUsage?.feature?.featureType === "event" || mappedFeatureUsage?.feature?.featureType === "trait") {
11337
+ acc.push(mappedFeatureUsage);
11338
+ }
11339
+ return acc;
11340
+ }, []) : (data.featureUsage?.features || []).filter(
11341
+ (usage) => usage.feature?.featureType === "event" || usage.feature?.featureType === "trait"
11342
+ );
11343
+ const shouldShowFeatures = featureUsage.length > 0 || data.company?.plan || (data.company?.addOns ?? []).length > 0 || false;
11344
+ if (!shouldShowFeatures) {
11274
11345
  return null;
11275
11346
  }
11276
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Flex, { ref, className, $flexDirection: "column", children: features.map(({ allocation, feature, usage }, index) => {
11347
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Flex, { ref, className, $flexDirection: "column", children: featureUsage.map(({ allocation, feature, usage }, index) => {
11277
11348
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Element, { as: Flex, $gap: "1.5rem", children: [
11278
11349
  props.icon.isVisible && feature?.icon && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
11279
11350
  IconRound,
@@ -11752,12 +11823,12 @@ var resolveDesignProps5 = (props) => {
11752
11823
  var PlanManager = (0, import_react19.forwardRef)(({ children, className, portal, ...rest }, ref) => {
11753
11824
  const props = resolveDesignProps5(rest);
11754
11825
  const theme = nt();
11755
- const { data, layout, mode, setLayout } = useEmbed();
11826
+ const { data, layout, setLayout } = useEmbed();
11756
11827
  const isLightBackground = useIsLightBackground();
11757
11828
  const { currentPlan, canChangePlan, addOns } = {
11758
- currentPlan: data.company?.plan,
11759
- canChangePlan: (mode === "edit" || data.stripeEmbed?.publishableKey && data.company?.plan?.billingProductId) && data.activePlans.length > 0,
11760
- addOns: data.company?.addOns || []
11829
+ addOns: data.company?.addOns || [],
11830
+ canChangePlan: data.capabilities?.checkout ?? true,
11831
+ currentPlan: data.company?.plan
11761
11832
  };
11762
11833
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
11763
11834
  Element,
@@ -12088,6 +12159,7 @@ var ComponentTree = () => {
12088
12159
  setChildren(nodes.map(renderer));
12089
12160
  }, [nodes]);
12090
12161
  if (error) {
12162
+ console.error(error);
12091
12163
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Error2, { message: error.message });
12092
12164
  }
12093
12165
  if (import_react22.Children.count(children) === 0) {