@schematichq/schematic-components 0.7.11 → 0.7.13

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.
@@ -9656,6 +9656,10 @@ var I18n = class _I18n extends EventEmitter {
9656
9656
  break;
9657
9657
  }
9658
9658
  }
9659
+ if (!this.resolvedLanguage && this.languages.indexOf(l2) < 0 && this.store.hasLanguageSomeTranslations(l2)) {
9660
+ this.resolvedLanguage = l2;
9661
+ if (this.languages.indexOf(l2) < 0) this.languages.unshift(l2);
9662
+ }
9659
9663
  }
9660
9664
  changeLanguage(lng, callback) {
9661
9665
  var _this2 = this;
@@ -9689,7 +9693,8 @@ var I18n = class _I18n extends EventEmitter {
9689
9693
  };
9690
9694
  const setLng = (lngs) => {
9691
9695
  if (!lng && !lngs && this.services.languageDetector) lngs = [];
9692
- const l2 = this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
9696
+ const fl = isString(lngs) ? lngs : lngs && lngs[0];
9697
+ const l2 = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
9693
9698
  if (l2) {
9694
9699
  if (!this.language) {
9695
9700
  setLngProps(l2);
@@ -15829,6 +15834,20 @@ function HydrateComponentResponseFromJSONTyped(json, ignoreDiscriminator) {
15829
15834
  };
15830
15835
  }
15831
15836
 
15837
+ // src/api/checkoutexternal/models/HydrateUpcomingInvoiceResponse.ts
15838
+ function HydrateUpcomingInvoiceResponseFromJSON(json) {
15839
+ return HydrateUpcomingInvoiceResponseFromJSONTyped(json, false);
15840
+ }
15841
+ function HydrateUpcomingInvoiceResponseFromJSONTyped(json, ignoreDiscriminator) {
15842
+ if (json == null) {
15843
+ return json;
15844
+ }
15845
+ return {
15846
+ data: InvoiceResponseDataFromJSON(json["data"]),
15847
+ params: json["params"]
15848
+ };
15849
+ }
15850
+
15832
15851
  // src/api/checkoutexternal/models/ListInvoicesParams.ts
15833
15852
  function ListInvoicesParamsFromJSON(json) {
15834
15853
  return ListInvoicesParamsFromJSONTyped(json, false);
@@ -16165,6 +16184,50 @@ var CheckoutexternalApi = class extends BaseAPI {
16165
16184
  );
16166
16185
  return await response.value();
16167
16186
  }
16187
+ /**
16188
+ * Hydrate upcoming invoice
16189
+ */
16190
+ async hydrateUpcomingInvoiceRaw(requestParameters, initOverrides) {
16191
+ if (requestParameters["componentId"] == null) {
16192
+ throw new RequiredError(
16193
+ "componentId",
16194
+ 'Required parameter "componentId" was null or undefined when calling hydrateUpcomingInvoice().'
16195
+ );
16196
+ }
16197
+ const queryParameters = {};
16198
+ const headerParameters = {};
16199
+ if (this.configuration && this.configuration.apiKey) {
16200
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
16201
+ "X-Schematic-Api-Key"
16202
+ );
16203
+ }
16204
+ const response = await this.request(
16205
+ {
16206
+ path: `/components/{component_id}/hydrate/upcoming-invoice`.replace(
16207
+ `{${"component_id"}}`,
16208
+ encodeURIComponent(String(requestParameters["componentId"]))
16209
+ ),
16210
+ method: "GET",
16211
+ headers: headerParameters,
16212
+ query: queryParameters
16213
+ },
16214
+ initOverrides
16215
+ );
16216
+ return new JSONApiResponse(
16217
+ response,
16218
+ (jsonValue) => HydrateUpcomingInvoiceResponseFromJSON(jsonValue)
16219
+ );
16220
+ }
16221
+ /**
16222
+ * Hydrate upcoming invoice
16223
+ */
16224
+ async hydrateUpcomingInvoice(requestParameters, initOverrides) {
16225
+ const response = await this.hydrateUpcomingInvoiceRaw(
16226
+ requestParameters,
16227
+ initOverrides
16228
+ );
16229
+ return await response.value();
16230
+ }
16168
16231
  /**
16169
16232
  * List invoices
16170
16233
  */
@@ -16353,7 +16416,7 @@ var en_default = {
16353
16416
  Monthly: "Monthly",
16354
16417
  Next: "Next",
16355
16418
  "No limit": "No limit",
16356
- "No payment method selected": "No payment method selected",
16419
+ "No payment method added yet": "No payment method added yet",
16357
16420
  "Not ready to cancel?": "Not ready to cancel?",
16358
16421
  "On demand": "On demand",
16359
16422
  "One time ": "One time",
@@ -16376,6 +16439,7 @@ var en_default = {
16376
16439
  "See less": "See less",
16377
16440
  "See more": "See more",
16378
16441
  "Select add-ons": "Select add-ons",
16442
+ "Select existing payment method": "Select existing payment method",
16379
16443
  "Select payment method": "Select payment method",
16380
16444
  "Select plan": "Select plan",
16381
16445
  "Select quantity": "Select quantity",
@@ -17084,7 +17148,7 @@ var EmbedProvider = ({
17084
17148
  (0, import_react11.useEffect)(() => {
17085
17149
  if (accessToken) {
17086
17150
  const { headers = {} } = apiConfig ?? {};
17087
- headers["X-Schematic-Components-Version"] = "0.7.11";
17151
+ headers["X-Schematic-Components-Version"] = "0.7.13";
17088
17152
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
17089
17153
  const config = new Configuration({
17090
17154
  ...apiConfig,
@@ -19206,7 +19270,8 @@ var Sidebar = ({
19206
19270
  if (typeof entitlement.allocation === "number" && entitlement.feature?.name) {
19207
19271
  const {
19208
19272
  price: entitlementPrice,
19209
- currency: entitlementCurrency
19273
+ currency: entitlementCurrency,
19274
+ packageSize: entitlementPackageSize = 1
19210
19275
  } = getBillingPrice(
19211
19276
  planPeriod === "year" ? entitlement.yearlyUsageBasedPrice : entitlement.monthlyUsageBasedPrice
19212
19277
  ) || {};
@@ -19263,7 +19328,14 @@ var Sidebar = ({
19263
19328
  ),
19264
19329
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
19265
19330
  "/",
19266
- getFeatureName(entitlement.feature, 1)
19331
+ entitlementPackageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
19332
+ entitlementPackageSize,
19333
+ " "
19334
+ ] }),
19335
+ getFeatureName(
19336
+ entitlement.feature,
19337
+ entitlementPackageSize
19338
+ )
19267
19339
  ] })
19268
19340
  ] })
19269
19341
  ]
@@ -19391,7 +19463,8 @@ var Sidebar = ({
19391
19463
  if (entitlement.feature?.name) {
19392
19464
  const {
19393
19465
  price: entitlementPrice,
19394
- currency: entitlementCurrency
19466
+ currency: entitlementCurrency,
19467
+ packageSize: entitlementPackageSize = 1
19395
19468
  } = getBillingPrice(
19396
19469
  planPeriod === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
19397
19470
  ) || {};
@@ -19445,7 +19518,14 @@ var Sidebar = ({
19445
19518
  ),
19446
19519
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
19447
19520
  "/",
19448
- getFeatureName(entitlement.feature, 1)
19521
+ entitlementPackageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
19522
+ entitlementPackageSize,
19523
+ " "
19524
+ ] }),
19525
+ getFeatureName(
19526
+ entitlement.feature,
19527
+ entitlementPackageSize
19528
+ )
19449
19529
  ] })
19450
19530
  ] })
19451
19531
  ]
@@ -20427,9 +20507,10 @@ var Plan = ({
20427
20507
  const limit = entitlement.softLimit ?? entitlement.valueNumeric;
20428
20508
  const entitlementPriceObject = getBillingPrice(
20429
20509
  period === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
20430
- ) || null;
20510
+ );
20431
20511
  let entitlementPrice = entitlementPriceObject?.price;
20432
20512
  const entitlementCurrency = entitlementPriceObject?.currency;
20513
+ const entitlementPackageSize = entitlementPriceObject?.packageSize ?? 1;
20433
20514
  if (entitlement.priceBehavior === "overage" && entitlementPriceObject) {
20434
20515
  const { priceTier } = entitlementPriceObject;
20435
20516
  if (priceTier.length > 1) {
@@ -20484,7 +20565,14 @@ var Plan = ({
20484
20565
  " ",
20485
20566
  t2("per"),
20486
20567
  " ",
20487
- getFeatureName(entitlement.feature, 1),
20568
+ entitlementPackageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
20569
+ entitlementPackageSize,
20570
+ " "
20571
+ ] }),
20572
+ getFeatureName(
20573
+ entitlement.feature,
20574
+ entitlementPackageSize
20575
+ ),
20488
20576
  entitlement.priceBehavior === "pay_in_advance" && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
20489
20577
  " ",
20490
20578
  t2("per"),
@@ -20538,7 +20626,14 @@ var Plan = ({
20538
20626
  entitlementCurrency
20539
20627
  ),
20540
20628
  "/",
20541
- getFeatureName(entitlement.feature, 1),
20629
+ entitlementPackageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
20630
+ entitlementPackageSize,
20631
+ " "
20632
+ ] }),
20633
+ getFeatureName(
20634
+ entitlement.feature,
20635
+ entitlementPackageSize
20636
+ ),
20542
20637
  entitlement.feature.featureType === "trait" && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
20543
20638
  "/",
20544
20639
  shortenPeriod(period)
@@ -20683,7 +20778,11 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
20683
20778
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Flex, { $flexDirection: "column", $gap: "1rem", children: entitlements.reduce(
20684
20779
  (acc, entitlement, index) => {
20685
20780
  if (entitlement.priceBehavior === "pay_in_advance" && entitlement.feature) {
20686
- const { price, currency } = getBillingPrice(
20781
+ const {
20782
+ price,
20783
+ currency,
20784
+ packageSize = 1
20785
+ } = getBillingPrice(
20687
20786
  period === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
20688
20787
  ) || {};
20689
20788
  acc.push(
@@ -20811,7 +20910,11 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
20811
20910
  formatCurrency(price ?? 0, currency),
20812
20911
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("sub", { children: [
20813
20912
  "/",
20814
- getFeatureName(entitlement.feature, 1),
20913
+ packageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
20914
+ packageSize,
20915
+ " "
20916
+ ] }),
20917
+ getFeatureName(entitlement.feature, packageSize),
20815
20918
  "/",
20816
20919
  shortenPeriod(period)
20817
20920
  ] })
@@ -20859,7 +20962,9 @@ var CheckoutDialog = ({ top = 0 }) => {
20859
20962
  const contentRef = (0, import_react26.useRef)(null);
20860
20963
  const checkoutRef = (0, import_react26.useRef)(null);
20861
20964
  const [charges, setCharges] = (0, import_react26.useState)();
20862
- const [paymentMethodId, setPaymentMethodId] = (0, import_react26.useState)();
20965
+ const [paymentMethodId, setPaymentMethodId] = (0, import_react26.useState)(
20966
+ (data.subscription?.paymentMethod || data.company?.defaultPaymentMethod)?.externalId
20967
+ );
20863
20968
  const [isLoading, setIsLoading] = (0, import_react26.useState)(false);
20864
20969
  const [error, setError] = (0, import_react26.useState)();
20865
20970
  const [promoCode, setPromoCode] = (0, import_react26.useState)();
@@ -21349,6 +21454,7 @@ var PaymentForm = ({ onConfirm }) => {
21349
21454
  const [message, setMessage] = (0, import_react27.useState)(null);
21350
21455
  const [isLoading, setIsLoading] = (0, import_react27.useState)(false);
21351
21456
  const [isConfirmed, setIsConfirmed] = (0, import_react27.useState)(false);
21457
+ const [isComplete, setIsComplete] = (0, import_react27.useState)(false);
21352
21458
  const handleSubmit = async (event) => {
21353
21459
  event.preventDefault();
21354
21460
  if (!api || !stripe || !elements) {
@@ -21391,12 +21497,20 @@ var PaymentForm = ({ onConfirm }) => {
21391
21497
  overflowY: "auto"
21392
21498
  },
21393
21499
  children: [
21394
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_stripe_js.PaymentElement, { id: "payment-element" }) }),
21500
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
21501
+ import_react_stripe_js.PaymentElement,
21502
+ {
21503
+ id: "payment-element",
21504
+ onChange: (event) => {
21505
+ setIsComplete(event.complete);
21506
+ }
21507
+ }
21508
+ ) }),
21395
21509
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
21396
21510
  Button,
21397
21511
  {
21398
21512
  id: "submit",
21399
- disabled: isLoading || !stripe || !elements || isConfirmed,
21513
+ disabled: isLoading || !stripe || !elements || isConfirmed || !isComplete,
21400
21514
  style: { flexShrink: 0 },
21401
21515
  $color: "primary",
21402
21516
  $isLoading: isLoading,
@@ -22017,12 +22131,19 @@ var Details = ({
22017
22131
  const { t: t2 } = useTranslation();
22018
22132
  const theme = nt();
22019
22133
  const { data } = useEmbed();
22020
- const { price, priceDecimal, priceTier, currency } = (0, import_react32.useMemo)(() => {
22134
+ const {
22135
+ price,
22136
+ priceDecimal,
22137
+ priceTier,
22138
+ currency,
22139
+ packageSize = 1
22140
+ } = (0, import_react32.useMemo)(() => {
22021
22141
  const {
22022
22142
  price: entitlementPrice,
22023
22143
  priceDecimal: entitlementPriceDecimal,
22024
22144
  priceTier: entitlementPriceTier,
22025
- currency: entitlementCurrency
22145
+ currency: entitlementCurrency,
22146
+ packageSize: entitlementPackageSize
22026
22147
  } = getBillingPrice(
22027
22148
  data.company?.plan?.planPeriod === "year" ? yearlyUsageBasedPrice : monthlyUsageBasedPrice
22028
22149
  ) || {};
@@ -22030,7 +22151,8 @@ var Details = ({
22030
22151
  price: entitlementPrice,
22031
22152
  priceDecimal: entitlementPriceDecimal,
22032
22153
  priceTier: entitlementPriceTier,
22033
- currency: entitlementCurrency
22154
+ currency: entitlementCurrency,
22155
+ packageSize: entitlementPackageSize
22034
22156
  };
22035
22157
  }, [
22036
22158
  data.company?.plan?.planPeriod,
@@ -22042,36 +22164,104 @@ var Details = ({
22042
22164
  return;
22043
22165
  }
22044
22166
  if (priceBehavior === "pay_in_advance" && typeof allocation === "number") {
22045
- return `${formatNumber(allocation)} ${getFeatureName(feature, allocation)}`;
22167
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
22168
+ formatNumber(allocation),
22169
+ " ",
22170
+ getFeatureName(feature, allocation)
22171
+ ] });
22046
22172
  }
22047
22173
  if (priceBehavior === "pay_as_you_go" && typeof price === "number") {
22048
- return `${formatCurrency(price, currency)} ${t2("per")} ${getFeatureName(feature, 1)}`;
22174
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
22175
+ formatCurrency(price, currency),
22176
+ " ",
22177
+ t2("per"),
22178
+ " ",
22179
+ packageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
22180
+ packageSize,
22181
+ " "
22182
+ ] }),
22183
+ getFeatureName(feature, packageSize)
22184
+ ] });
22049
22185
  }
22050
22186
  if (priceBehavior === "overage" && typeof softLimit === "number") {
22051
- return `${formatNumber(softLimit)} ${getFeatureName(feature, softLimit)}`;
22187
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
22188
+ formatNumber(softLimit),
22189
+ " ",
22190
+ getFeatureName(feature, softLimit)
22191
+ ] });
22052
22192
  }
22053
22193
  if (!priceBehavior && typeof allocation === "number") {
22054
- return `${formatNumber(allocation)} ${getFeatureName(feature, allocation)}`;
22194
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
22195
+ formatNumber(allocation),
22196
+ " ",
22197
+ getFeatureName(feature, allocation)
22198
+ ] });
22055
22199
  }
22056
22200
  if (!priceBehavior) {
22057
22201
  return t2("Unlimited", { item: getFeatureName(feature) });
22058
22202
  }
22059
- }, [t2, allocation, feature, price, priceBehavior, currency, softLimit]);
22203
+ }, [
22204
+ t2,
22205
+ allocation,
22206
+ feature,
22207
+ price,
22208
+ priceBehavior,
22209
+ currency,
22210
+ packageSize,
22211
+ softLimit
22212
+ ]);
22060
22213
  const usageText = (0, import_react32.useMemo)(() => {
22061
22214
  if (!feature) {
22062
22215
  return;
22063
22216
  }
22064
- let acc;
22217
+ const acc = [];
22218
+ let index = 0;
22065
22219
  if (priceBehavior === "pay_in_advance" && typeof data.company?.plan?.planPeriod === "string" && typeof price === "number") {
22066
- acc = `${formatCurrency(price, currency)}/${getFeatureName(feature, 1)}/${shortenPeriod(data.company.plan.planPeriod)}`;
22220
+ acc.push(
22221
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22222
+ formatCurrency(price, currency),
22223
+ "/",
22224
+ packageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
22225
+ packageSize,
22226
+ " "
22227
+ ] }),
22228
+ getFeatureName(feature, packageSize),
22229
+ "/",
22230
+ shortenPeriod(data.company.plan.planPeriod)
22231
+ ] }, index)
22232
+ );
22233
+ index += 1;
22067
22234
  } else if ((priceBehavior === "pay_as_you_go" || priceBehavior === "overage") && typeof usage === "number") {
22068
- acc = `${usage} ${getFeatureName(feature, usage)} ${t2("used")}`;
22235
+ acc.push(
22236
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22237
+ usage,
22238
+ " ",
22239
+ getFeatureName(feature, usage),
22240
+ " ",
22241
+ t2("used")
22242
+ ] }, index)
22243
+ );
22244
+ index += 1;
22069
22245
  }
22070
22246
  if (acc) {
22071
22247
  if (priceBehavior === "pay_in_advance" && typeof price === "number" && typeof allocation === "number") {
22072
- acc += ` \u2022 ${formatCurrency(price * allocation, currency)}`;
22248
+ acc.push(
22249
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22250
+ " ",
22251
+ "\u2022 ",
22252
+ formatCurrency(price * allocation, currency)
22253
+ ] }, index)
22254
+ );
22255
+ index += 1;
22073
22256
  } else if (priceBehavior === "pay_as_you_go" && typeof price === "number" && typeof usage === "number") {
22074
- acc += ` \u2022 ${formatCurrency(price * usage, currency)}`;
22257
+ acc.push(
22258
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22259
+ " ",
22260
+ "\u2022 ",
22261
+ formatCurrency(price * usage, currency)
22262
+ ] }, index)
22263
+ );
22264
+ index += 1;
22075
22265
  } else if (priceBehavior === "overage" && typeof price === "number" && typeof usage === "number" && typeof softLimit === "number") {
22076
22266
  let overagePrice = price ?? priceDecimal;
22077
22267
  if (priceTier?.length === 2) {
@@ -22085,7 +22275,16 @@ var Details = ({
22085
22275
  const cost = usage - softLimit < 0 ? 0 : overagePrice * (usage - softLimit);
22086
22276
  const period = feature.featureType === "trait" && typeof data.company?.plan?.planPeriod === "string" ? `/${shortenPeriod(data.company.plan.planPeriod)}` : "";
22087
22277
  if (cost > 0) {
22088
- acc += ` \u2022 ${formatCurrency(cost)}${period}`;
22278
+ acc.push(
22279
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react32.Fragment, { children: [
22280
+ " ",
22281
+ "\u2022 ",
22282
+ formatCurrency(cost),
22283
+ "$",
22284
+ period
22285
+ ] }, index)
22286
+ );
22287
+ index += 1;
22089
22288
  }
22090
22289
  }
22091
22290
  return acc;
@@ -22108,6 +22307,7 @@ var Details = ({
22108
22307
  priceDecimal,
22109
22308
  priceTier,
22110
22309
  currency,
22310
+ packageSize,
22111
22311
  softLimit,
22112
22312
  usage
22113
22313
  ]);
@@ -22568,9 +22768,11 @@ var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, re
22568
22768
  }, index) => {
22569
22769
  const limit = softLimit ?? allocation ?? 0;
22570
22770
  const isOverage = priceBehavior === "overage" && typeof softLimit === "number" && typeof usage === "number" && usage > softLimit;
22571
- let { price, currency } = getBillingPrice(
22771
+ const billingPrice = getBillingPrice(
22572
22772
  planPeriod === "year" ? yearlyUsageBasedPrice : monthlyUsageBasedPrice
22573
- ) || {};
22773
+ );
22774
+ let { price, currency } = billingPrice || {};
22775
+ const packageSize = billingPrice?.packageSize ?? 1;
22574
22776
  if (priceBehavior === "overage") {
22575
22777
  const productId = (yearlyUsageBasedPrice ?? monthlyUsageBasedPrice)?.productId;
22576
22778
  if (productId) {
@@ -22781,7 +22983,11 @@ var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, re
22781
22983
  formatCurrency(price, currency),
22782
22984
  feature && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Box, { as: "sub", $whiteSpace: "nowrap", children: [
22783
22985
  "/",
22784
- getFeatureName(feature, 1),
22986
+ packageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
22987
+ packageSize,
22988
+ " "
22989
+ ] }),
22990
+ getFeatureName(feature, packageSize),
22785
22991
  feature.featureType === "trait" && planPeriod && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
22786
22992
  "/",
22787
22993
  shortenPeriod(planPeriod)
@@ -22847,7 +23053,7 @@ var PaymentElement2 = ({
22847
23053
  };
22848
23054
  var EmptyPaymentElement = () => {
22849
23055
  const theme = nt();
22850
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Text, { $font: theme.typography.text.fontFamily, $size: 16, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Flex, { $flexDirection: "row", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Flex, { $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Box, { $lineHeight: "1", $marginRight: "4px", children: t("No payment method selected") }) }) }) });
23056
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Text, { $font: theme.typography.text.fontFamily, $size: 16, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Flex, { $flexDirection: "row", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Flex, { $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Box, { $lineHeight: "1", $marginRight: "4px", children: t("No payment method added yet") }) }) }) });
22851
23057
  };
22852
23058
  var getPaymentMethodData = ({
22853
23059
  accountLast4,
@@ -23189,7 +23395,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
23189
23395
  }
23190
23396
  stripe._registerWrapper({
23191
23397
  name: "stripe-js",
23192
- version: "7.1.0",
23398
+ version: "7.2.0",
23193
23399
  startTime
23194
23400
  });
23195
23401
  };
@@ -23264,7 +23470,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
23264
23470
  var version = runtimeVersionToUrlVersion(maybeStripe.version);
23265
23471
  var expectedVersion = RELEASE_TRAIN;
23266
23472
  if (isTestKey && version !== expectedVersion) {
23267
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.1.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
23473
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.2.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
23268
23474
  }
23269
23475
  var stripe = maybeStripe.apply(void 0, args);
23270
23476
  registerWrapper(stripe, startTime);
@@ -23329,12 +23535,7 @@ var PaymentMethodDetails = ({
23329
23535
  const [stripe, setStripe] = (0, import_react38.useState)(null);
23330
23536
  const [setupIntent, setSetupIntent] = (0, import_react38.useState)();
23331
23537
  const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react38.useState)(false);
23332
- const [paymentMethod, setPaymentMethod] = (0, import_react38.useState)(void 0);
23333
- (0, import_react38.useEffect)(() => {
23334
- setPaymentMethod(
23335
- data.subscription?.paymentMethod || data.company?.defaultPaymentMethod
23336
- );
23337
- }, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
23538
+ const [paymentMethod, setPaymentMethod] = (0, import_react38.useState)(data.subscription?.paymentMethod || data.company?.defaultPaymentMethod);
23338
23539
  const monthsToExpiration = (0, import_react38.useMemo)(() => {
23339
23540
  let expiration;
23340
23541
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
@@ -23348,33 +23549,25 @@ var PaymentMethodDetails = ({
23348
23549
  }
23349
23550
  return expiration;
23350
23551
  }, [paymentMethod?.cardExpYear, paymentMethod?.cardExpMonth]);
23351
- (0, import_react38.useEffect)(() => {
23352
- if (!stripe && setupIntent?.publishableKey) {
23353
- setStripe(loadStripe(setupIntent.publishableKey));
23354
- }
23355
- }, [stripe, setupIntent?.publishableKey]);
23356
23552
  const createSetupIntent = (0, import_react38.useCallback)(async () => {
23357
23553
  if (!api || !data.component?.id) {
23358
23554
  return;
23359
23555
  }
23360
23556
  try {
23361
23557
  setIsLoading(true);
23362
- const { data: setupIntent2 } = await api.getSetupIntent({
23558
+ const response = await api.getSetupIntent({
23363
23559
  componentId: data.component.id
23364
23560
  });
23365
- setSetupIntent(setupIntent2);
23366
- setShowPaymentForm(true);
23561
+ setSetupIntent(response.data);
23367
23562
  } catch {
23368
23563
  setError(
23369
23564
  t2("Error initializing payment method change. Please try again.")
23370
23565
  );
23371
23566
  } finally {
23567
+ setShowPaymentForm(true);
23372
23568
  setIsLoading(false);
23373
23569
  }
23374
23570
  }, [t2, api, data.component?.id]);
23375
- const dropDownDifferentPaymentMethods = (0, import_react38.useCallback)(() => {
23376
- setShowDifferentPaymentMethods((state) => !state);
23377
- }, []);
23378
23571
  const updatePaymentMethod = (0, import_react38.useCallback)(
23379
23572
  async (externalId) => {
23380
23573
  if (!api || !externalId) {
@@ -23451,33 +23644,43 @@ var PaymentMethodDetails = ({
23451
23644
  },
23452
23645
  [api, data, setData, t2]
23453
23646
  );
23647
+ (0, import_react38.useEffect)(() => {
23648
+ if (!stripe && setupIntent?.publishableKey) {
23649
+ setStripe(loadStripe(setupIntent.publishableKey));
23650
+ }
23651
+ }, [stripe, setupIntent?.publishableKey]);
23652
+ (0, import_react38.useEffect)(() => {
23653
+ if (!setupIntent && (!paymentMethod || showPaymentForm)) {
23654
+ createSetupIntent();
23655
+ }
23656
+ }, [setupIntent, paymentMethod, showPaymentForm, createSetupIntent]);
23454
23657
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Flex, { $position: "relative", children: [
23455
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
23658
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
23456
23659
  Flex,
23457
23660
  {
23458
23661
  $position: "absolute",
23459
- $width: "100%",
23460
- $height: "100%",
23662
+ $zIndex: isLoading ? 1 : 0,
23461
23663
  $justifyContent: "center",
23462
23664
  $alignItems: "center",
23463
- $flexGrow: 1,
23464
- $zIndex: 1,
23465
- $backgroundColor: "black",
23466
- $opacity: 0.5,
23467
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Loader, { $color: theme.primary, $size: "2xl" })
23665
+ $width: "100%",
23666
+ $height: "100%",
23667
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Loader, { $color: theme.primary, $size: "2xl", $isLoading: isLoading })
23468
23668
  }
23469
23669
  ),
23470
23670
  /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
23471
23671
  Flex,
23472
23672
  {
23673
+ $position: "relative",
23674
+ $zIndex: isLoading ? 0 : 1,
23473
23675
  $flexDirection: "column",
23474
- $flexGrow: "1",
23676
+ $flexGrow: 1,
23475
23677
  $gap: "1rem",
23678
+ $overflow: "auto",
23476
23679
  $padding: "2rem 2.5rem 2rem 2.5rem",
23680
+ $visibility: isLoading ? "hidden" : "visible",
23477
23681
  $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.025)" : "hsla(0, 0%, 100%, 0.025)",
23478
- $overflow: "auto",
23479
23682
  children: [
23480
- showPaymentForm ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
23683
+ setupIntent && showPaymentForm ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
23481
23684
  import_react_stripe_js2.Elements,
23482
23685
  {
23483
23686
  stripe,
@@ -23506,16 +23709,32 @@ var PaymentMethodDetails = ({
23506
23709
  },
23507
23710
  clientSecret: setupIntent?.setupIntentClientSecret
23508
23711
  },
23509
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
23510
- PaymentForm,
23511
- {
23512
- onConfirm: async (paymentMethodId) => {
23513
- await updatePaymentMethod(paymentMethodId);
23514
- setShowPaymentForm(false);
23515
- setShowDifferentPaymentMethods(false);
23712
+ children: [
23713
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
23714
+ PaymentForm,
23715
+ {
23716
+ onConfirm: async (paymentMethodId) => {
23717
+ await updatePaymentMethod(paymentMethodId);
23718
+ setShowPaymentForm(false);
23719
+ setShowDifferentPaymentMethods(false);
23720
+ }
23516
23721
  }
23517
- }
23518
- )
23722
+ ),
23723
+ paymentMethod && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
23724
+ Text,
23725
+ {
23726
+ onClick: () => {
23727
+ setShowPaymentForm(false);
23728
+ setShowDifferentPaymentMethods(false);
23729
+ },
23730
+ $font: theme.typography.link.fontFamily,
23731
+ $size: theme.typography.link.fontSize,
23732
+ $weight: theme.typography.link.fontWeight,
23733
+ $color: theme.typography.link.color,
23734
+ children: t2("Select existing payment method")
23735
+ }
23736
+ ) })
23737
+ ]
23519
23738
  }
23520
23739
  ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Flex, { $flexDirection: "column", $gap: "2rem", children: [
23521
23740
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
@@ -23530,7 +23749,9 @@ var PaymentMethodDetails = ({
23530
23749
  (data.company?.paymentMethods || []).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
23531
23750
  Text,
23532
23751
  {
23533
- onClick: dropDownDifferentPaymentMethods,
23752
+ onClick: () => {
23753
+ setShowDifferentPaymentMethods((prev2) => !prev2);
23754
+ },
23534
23755
  $font: theme.typography.link.fontFamily,
23535
23756
  $size: theme.typography.link.fontSize,
23536
23757
  $weight: theme.typography.link.fontWeight,
@@ -23553,18 +23774,20 @@ var PaymentMethodDetails = ({
23553
23774
  ]
23554
23775
  }
23555
23776
  ) }),
23556
- showDifferentPaymentMethods && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Flex, { $flexDirection: "column", $overflowY: "hidden", $height: "10rem", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Flex, { $flexDirection: "column", $overflowY: "scroll", children: (data.company?.paymentMethods.filter(
23557
- (pm) => pm.id !== paymentMethod?.id
23558
- ) || []).map((paymentMethod2) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
23559
- PaymentListElement,
23560
- {
23561
- paymentMethod: paymentMethod2,
23562
- setDefault: updatePaymentMethod,
23563
- handleDelete: deletePaymentMethod
23564
- },
23565
- paymentMethod2.id
23566
- )) }) }),
23567
- (!paymentMethod || showDifferentPaymentMethods) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Button, { onClick: createSetupIntent, $size: "lg", children: t2("Add new payment method") })
23777
+ showDifferentPaymentMethods && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Flex, { $flexDirection: "column", $overflowY: "hidden", children: [
23778
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Flex, { $flexDirection: "column", $overflowY: "scroll", children: (data.company?.paymentMethods.filter(
23779
+ (pm) => pm.id !== paymentMethod?.id
23780
+ ) || []).map((paymentMethod2) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
23781
+ PaymentListElement,
23782
+ {
23783
+ paymentMethod: paymentMethod2,
23784
+ setDefault: updatePaymentMethod,
23785
+ handleDelete: deletePaymentMethod
23786
+ },
23787
+ paymentMethod2.id
23788
+ )) }),
23789
+ (!setupIntent || !paymentMethod || showDifferentPaymentMethods) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Button, { onClick: createSetupIntent, $size: "lg", children: t2("Add new payment method") })
23790
+ ] })
23568
23791
  ] }),
23569
23792
  !isLoading && error && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
23570
23793
  Text,
@@ -23768,10 +23991,12 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
23768
23991
  const limit = entitlement.softLimit ?? entitlement.allocation ?? 0;
23769
23992
  let overageAmount = entitlement.priceBehavior === "overage" && (entitlement?.usage ?? 0) - (entitlement?.softLimit ?? 0);
23770
23993
  const amount = overageAmount || entitlement.allocation || 0;
23994
+ let packageSize = 1;
23771
23995
  if (entitlement.priceBehavior === "overage" && data.subscription) {
23772
23996
  const subscription = data.subscription;
23773
23997
  const entitlementPrice = entitlement.monthlyUsageBasedPrice ?? entitlement.yearlyUsageBasedPrice;
23774
23998
  if (entitlementPrice) {
23999
+ packageSize = entitlementPrice.packageSize;
23775
24000
  const entitlementProduct = subscription.products.find(
23776
24001
  (product) => product.id === entitlementPrice.productId
23777
24002
  );
@@ -23823,7 +24048,14 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
23823
24048
  ),
23824
24049
  /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
23825
24050
  "/",
23826
- getFeatureName(entitlement.feature, 1),
24051
+ packageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
24052
+ packageSize,
24053
+ " "
24054
+ ] }),
24055
+ getFeatureName(
24056
+ entitlement.feature,
24057
+ packageSize
24058
+ ),
23827
24059
  entitlement.feature.featureType === "trait" && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
23828
24060
  "/",
23829
24061
  shortenPeriod(currentPlan.planPeriod)
@@ -23843,7 +24075,14 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
23843
24075
  ),
23844
24076
  /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
23845
24077
  "/",
23846
- getFeatureName(entitlement.feature, 1),
24078
+ packageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
24079
+ packageSize,
24080
+ " "
24081
+ ] }),
24082
+ getFeatureName(
24083
+ entitlement.feature,
24084
+ packageSize
24085
+ ),
23847
24086
  "/",
23848
24087
  shortenPeriod(currentPlan.planPeriod)
23849
24088
  ] })
@@ -23857,7 +24096,16 @@ var PlanManager = (0, import_react39.forwardRef)(({ children, className, portal,
23857
24096
  ),
23858
24097
  (entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior !== "overage") && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("sub", { children: [
23859
24098
  "/",
23860
- currentPlan?.planPeriod && entitlement.priceBehavior === "pay_in_advance" ? shortenPeriod(currentPlan.planPeriod) : getFeatureName(entitlement.feature, 1)
24099
+ currentPlan?.planPeriod && entitlement.priceBehavior === "pay_in_advance" ? shortenPeriod(currentPlan.planPeriod) : /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
24100
+ packageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
24101
+ packageSize,
24102
+ " "
24103
+ ] }),
24104
+ getFeatureName(
24105
+ entitlement.feature,
24106
+ packageSize
24107
+ )
24108
+ ] })
23861
24109
  ] })
23862
24110
  ] })
23863
24111
  ] })
@@ -24180,6 +24428,7 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
24180
24428
  if (entitlement.priceBehavior && typeof entitlementPrice !== "number") {
24181
24429
  return acc;
24182
24430
  }
24431
+ const entitlementPackageSize = entitlementPriceObject?.packageSize ?? 1;
24183
24432
  acc.push(
24184
24433
  /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(Flex, { $gap: "1rem", children: [
24185
24434
  props.plans.showFeatureIcons && entitlement.feature?.icon && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
@@ -24216,9 +24465,13 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
24216
24465
  " ",
24217
24466
  t2("per"),
24218
24467
  " ",
24468
+ entitlementPackageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
24469
+ entitlementPackageSize,
24470
+ " "
24471
+ ] }),
24219
24472
  getFeatureName(
24220
24473
  entitlement.feature,
24221
- 1
24474
+ entitlementPackageSize
24222
24475
  ),
24223
24476
  entitlement.priceBehavior === "pay_in_advance" && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
24224
24477
  " ",
@@ -24280,9 +24533,13 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
24280
24533
  entitlementCurrency
24281
24534
  ),
24282
24535
  "/",
24536
+ entitlementPackageSize > 1 && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
24537
+ entitlementPackageSize,
24538
+ " "
24539
+ ] }),
24283
24540
  getFeatureName(
24284
24541
  entitlement.feature,
24285
- 1
24542
+ entitlementPackageSize
24286
24543
  ),
24287
24544
  entitlement.feature.featureType === "trait" && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
24288
24545
  "/",