@cimplify/sdk 0.100.1 → 0.100.3

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.
Files changed (58) hide show
  1. package/dist/advanced.d.mts +3 -3
  2. package/dist/advanced.d.ts +3 -3
  3. package/dist/advanced.js +20 -20
  4. package/dist/advanced.mjs +1 -1
  5. package/dist/{chunk-BHQCSHIG.js → chunk-CNY2XFN4.js} +266 -84
  6. package/dist/{chunk-PTKAN4SI.mjs → chunk-FFRQNNUQ.mjs} +8 -0
  7. package/dist/{chunk-QGFKIAEM.js → chunk-FWKSBF3F.js} +8 -0
  8. package/dist/{chunk-NKZIXLKW.mjs → chunk-HFTRLRLM.mjs} +3 -3
  9. package/dist/{chunk-NR4Z2SFY.js → chunk-KNCW5DI7.js} +4 -4
  10. package/dist/{chunk-KEC2CX4R.mjs → chunk-NOGCGI4J.mjs} +2 -2
  11. package/dist/{chunk-NH3HYUC3.js → chunk-XCS56XSS.js} +3 -3
  12. package/dist/{chunk-T2B656RS.mjs → chunk-XG4DZT4I.mjs} +221 -39
  13. package/dist/{client-T5c-Nxq-.d.mts → client-BGeSemVv.d.mts} +2 -2
  14. package/dist/{client-DxgC_lXU.d.ts → client-BWdeCgmo.d.ts} +34 -14
  15. package/dist/{client-B0Lku_lc.d.mts → client-Bx4NRdl8.d.mts} +34 -14
  16. package/dist/{client-DRgEa78P.d.ts → client-Cvp8W1r9.d.ts} +2 -2
  17. package/dist/{index-CzKN1hjf.d.ts → index-B_RYmvlF.d.ts} +3 -3
  18. package/dist/{index-DzuLT5wi.d.mts → index-D-LUYk1Y.d.mts} +3 -3
  19. package/dist/index.d.mts +7 -7
  20. package/dist/index.d.ts +7 -7
  21. package/dist/index.js +69 -69
  22. package/dist/index.mjs +3 -3
  23. package/dist/mock/cli.mjs +3 -3
  24. package/dist/mock/library.js +3 -3
  25. package/dist/mock/library.mjs +3 -3
  26. package/dist/mock/msw.js +3 -3
  27. package/dist/mock/msw.mjs +3 -3
  28. package/dist/{payment-D8NEwCna.d.mts → payment-BSzy7sly.d.mts} +1 -1
  29. package/dist/{payment-lZBP7h5M.d.ts → payment-jK8ztICx.d.ts} +1 -1
  30. package/dist/{price-ncQb-TC8.d.ts → price-CJLfcYKd.d.ts} +1 -1
  31. package/dist/{price-DepWAmcL.d.mts → price-D96h6c6L.d.mts} +1 -1
  32. package/dist/{product-B384_Qm2.d.mts → product-CeV8euw4.d.mts} +11 -10
  33. package/dist/{product-B384_Qm2.d.ts → product-CeV8euw4.d.ts} +11 -10
  34. package/dist/react.d.mts +4 -4
  35. package/dist/react.d.ts +4 -4
  36. package/dist/react.js +51 -29
  37. package/dist/react.mjs +28 -6
  38. package/dist/{server-oCGNIO_K.d.mts → server-BRJ61o2J.d.mts} +4 -4
  39. package/dist/{server-B7O4ttpv.d.ts → server-CXrVYtNo.d.ts} +4 -4
  40. package/dist/server.d.mts +4 -4
  41. package/dist/server.d.ts +4 -4
  42. package/dist/server.js +7 -7
  43. package/dist/server.mjs +2 -2
  44. package/dist/testing/msw.d.mts +2 -2
  45. package/dist/testing/msw.d.ts +2 -2
  46. package/dist/testing/msw.js +2 -2
  47. package/dist/testing/msw.mjs +1 -1
  48. package/dist/testing/suite.d.mts +6 -6
  49. package/dist/testing/suite.d.ts +6 -6
  50. package/dist/testing/suite.js +23 -23
  51. package/dist/testing/suite.mjs +4 -4
  52. package/dist/testing.d.mts +5 -5
  53. package/dist/testing.d.ts +5 -5
  54. package/dist/testing.js +79 -79
  55. package/dist/testing.mjs +5 -5
  56. package/dist/utils.d.mts +4 -4
  57. package/dist/utils.d.ts +4 -4
  58. package/package.json +1 -1
package/dist/react.d.mts CHANGED
@@ -2,13 +2,13 @@ import * as React$1 from 'react';
2
2
  import React__default, { ReactNode, PointerEvent, MouseEvent } from 'react';
3
3
  import { d as AdSlot, c as AdPosition, a as AdContextValue, S as SignInOptions } from './sign-in-DQlIdqsi.mjs';
4
4
  export { A as AdConfig, g as getVariantDisplayName } from './sign-in-DQlIdqsi.mjs';
5
- import { af as CimplifyClient, ca as OrderType, cv as ProcessCheckoutResult, ac as CheckoutStatus, ad as CheckoutStatusContext, a_ as EnrichedOrderItem, aZ as EnrichedOrder, w as Business, bz as Location, cM as ReorderResult, c8 as OrderStatus, bP as Order, cx as QuoteBundleSelectionInput, cy as QuoteCompositeSelectionInput, cr as PriceQuote, cB as QuoteUiMessage, d6 as Service, r as AvailableSlot, ay as DayAvailability, aq as CustomerBooking, L as CancelBookingResult, f as ActivityStateResponse, df as SessionMessage, c as ActivityRecommendation, aA as DeliveryFeeResponse, aC as DeliveryOptionsResponse, bc as FxRateResponse, dp as StoreCreditBalance, dr as StorefrontBootstrap, _ as ChatWidgetStarter, W as ChatMessage, Z as ChatUploadAttachment, h as AddressInfo, n as AuthenticatedData, aY as ElementsOptions, cl as PaymentMethodInfo, aW as ElementsCheckoutResult, cu as ProcessCheckoutOptions, ai as CimplifyElements, T as ChatAttachment, bo as LineItem, di as Staff, d1 as Room, Y as ChatReplyContext } from './client-B0Lku_lc.mjs';
5
+ import { af as CimplifyClient, cb as OrderType, cw as ProcessCheckoutResult, ac as CheckoutStatus, ad as CheckoutStatusContext, a$ as EnrichedOrderItem, a_ as EnrichedOrder, w as Business, bA as Location, cN as ReorderResult, c9 as OrderStatus, bQ as Order, cy as QuoteBundleSelectionInput, cz as QuoteCompositeSelectionInput, cs as PriceQuote, cC as QuoteUiMessage, d7 as Service, r as AvailableSlot, ay as DayAvailability, aq as CustomerBooking, L as CancelBookingResult, f as ActivityStateResponse, dg as SessionMessage, c as ActivityRecommendation, aA as DeliveryFeeResponse, aD as DeliveryOptionsResponse, bd as FxRateResponse, dq as StoreCreditBalance, ds as StorefrontBootstrap, _ as ChatWidgetStarter, W as ChatMessage, Z as ChatUploadAttachment, h as AddressInfo, n as AuthenticatedData, aZ as ElementsOptions, cm as PaymentMethodInfo, aX as ElementsCheckoutResult, cv as ProcessCheckoutOptions, ai as CimplifyElements, T as ChatAttachment, bp as LineItem, dj as Staff, d2 as Room, Y as ChatReplyContext } from './client-Bx4NRdl8.mjs';
6
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
- import { ad as CurrencyCode, aZ as Product, aQ as Pagination, V as CimplifyError, bb as ProductWithDetails, S as Category, aO as Money, U as ChosenPrice, E as BundleSelectionInput, a1 as ComponentSelectionInput, D as BundleSelectionData, aa as CompositeSelectionData, W as Collection, b6 as ProductTaxonomy, bx as TaxonomyWithChildren, b7 as ProductTimeProfile, aj as Deal, b2 as ProductDealInfo, ap as DiscountValidation, G as BundleSummary, a8 as CompositePriceResult, bs as SubscriptionWithDetails, br as SubscriptionStatus, bo as Subscription, ae as CustomAttributeDefinition, bc as PropertyFacet, b1 as ProductBillingPlan, bQ as VariantView, bK as VariantAxisWithValues, f as AddOnWithOptions, y as BundleComponentView, z as BundlePriceType, a6 as CompositeGroupView, as as DisplayCart, b3 as ProductInputField, h as AddressValue, bi as SaleInfo, bD as UpcomingSale, av as DurationUnit, t as BoundaryKind, bk as SchedulingMode, al as DepositType, af as CustomAttributeValue, b4 as ProductProperty, be as QuantityPricingTier } from './product-B384_Qm2.mjs';
8
- import { P as ProductWithPrice } from './price-DepWAmcL.mjs';
7
+ import { ad as CurrencyCode, aZ as Product, aQ as Pagination, V as CimplifyError, bb as ProductWithDetails, S as Category, aO as Money, U as ChosenPrice, E as BundleSelectionInput, a1 as ComponentSelectionInput, D as BundleSelectionData, aa as CompositeSelectionData, W as Collection, b6 as ProductTaxonomy, bx as TaxonomyWithChildren, b7 as ProductTimeProfile, aj as Deal, b2 as ProductDealInfo, ap as DiscountValidation, G as BundleSummary, a8 as CompositePriceResult, bs as SubscriptionWithDetails, br as SubscriptionStatus, bo as Subscription, ae as CustomAttributeDefinition, bc as PropertyFacet, b1 as ProductBillingPlan, bQ as VariantView, bK as VariantAxisWithValues, f as AddOnWithOptions, y as BundleComponentView, z as BundlePriceType, a6 as CompositeGroupView, as as DisplayCart, b3 as ProductInputField, h as AddressValue, bi as SaleInfo, bD as UpcomingSale, av as DurationUnit, t as BoundaryKind, bk as SchedulingMode, al as DepositType, af as CustomAttributeValue, b4 as ProductProperty, be as QuantityPricingTier } from './product-CeV8euw4.mjs';
8
+ import { P as ProductWithPrice } from './price-D96h6c6L.mjs';
9
9
  import { ClassValue } from 'clsx';
10
10
  import { Matcher } from 'react-day-picker';
11
- import './payment-D8NEwCna.mjs';
11
+ import './payment-BSzy7sly.mjs';
12
12
 
13
13
  interface UserIdentity {
14
14
  uid: string;
package/dist/react.d.ts CHANGED
@@ -2,13 +2,13 @@ import * as React$1 from 'react';
2
2
  import React__default, { ReactNode, PointerEvent, MouseEvent } from 'react';
3
3
  import { d as AdSlot, c as AdPosition, a as AdContextValue, S as SignInOptions } from './sign-in-DQlIdqsi.js';
4
4
  export { A as AdConfig, g as getVariantDisplayName } from './sign-in-DQlIdqsi.js';
5
- import { af as CimplifyClient, ca as OrderType, cv as ProcessCheckoutResult, ac as CheckoutStatus, ad as CheckoutStatusContext, a_ as EnrichedOrderItem, aZ as EnrichedOrder, w as Business, bz as Location, cM as ReorderResult, c8 as OrderStatus, bP as Order, cx as QuoteBundleSelectionInput, cy as QuoteCompositeSelectionInput, cr as PriceQuote, cB as QuoteUiMessage, d6 as Service, r as AvailableSlot, ay as DayAvailability, aq as CustomerBooking, L as CancelBookingResult, f as ActivityStateResponse, df as SessionMessage, c as ActivityRecommendation, aA as DeliveryFeeResponse, aC as DeliveryOptionsResponse, bc as FxRateResponse, dp as StoreCreditBalance, dr as StorefrontBootstrap, _ as ChatWidgetStarter, W as ChatMessage, Z as ChatUploadAttachment, h as AddressInfo, n as AuthenticatedData, aY as ElementsOptions, cl as PaymentMethodInfo, aW as ElementsCheckoutResult, cu as ProcessCheckoutOptions, ai as CimplifyElements, T as ChatAttachment, bo as LineItem, di as Staff, d1 as Room, Y as ChatReplyContext } from './client-DxgC_lXU.js';
5
+ import { af as CimplifyClient, cb as OrderType, cw as ProcessCheckoutResult, ac as CheckoutStatus, ad as CheckoutStatusContext, a$ as EnrichedOrderItem, a_ as EnrichedOrder, w as Business, bA as Location, cN as ReorderResult, c9 as OrderStatus, bQ as Order, cy as QuoteBundleSelectionInput, cz as QuoteCompositeSelectionInput, cs as PriceQuote, cC as QuoteUiMessage, d7 as Service, r as AvailableSlot, ay as DayAvailability, aq as CustomerBooking, L as CancelBookingResult, f as ActivityStateResponse, dg as SessionMessage, c as ActivityRecommendation, aA as DeliveryFeeResponse, aD as DeliveryOptionsResponse, bd as FxRateResponse, dq as StoreCreditBalance, ds as StorefrontBootstrap, _ as ChatWidgetStarter, W as ChatMessage, Z as ChatUploadAttachment, h as AddressInfo, n as AuthenticatedData, aZ as ElementsOptions, cm as PaymentMethodInfo, aX as ElementsCheckoutResult, cv as ProcessCheckoutOptions, ai as CimplifyElements, T as ChatAttachment, bp as LineItem, dj as Staff, d2 as Room, Y as ChatReplyContext } from './client-BWdeCgmo.js';
6
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
- import { ad as CurrencyCode, aZ as Product, aQ as Pagination, V as CimplifyError, bb as ProductWithDetails, S as Category, aO as Money, U as ChosenPrice, E as BundleSelectionInput, a1 as ComponentSelectionInput, D as BundleSelectionData, aa as CompositeSelectionData, W as Collection, b6 as ProductTaxonomy, bx as TaxonomyWithChildren, b7 as ProductTimeProfile, aj as Deal, b2 as ProductDealInfo, ap as DiscountValidation, G as BundleSummary, a8 as CompositePriceResult, bs as SubscriptionWithDetails, br as SubscriptionStatus, bo as Subscription, ae as CustomAttributeDefinition, bc as PropertyFacet, b1 as ProductBillingPlan, bQ as VariantView, bK as VariantAxisWithValues, f as AddOnWithOptions, y as BundleComponentView, z as BundlePriceType, a6 as CompositeGroupView, as as DisplayCart, b3 as ProductInputField, h as AddressValue, bi as SaleInfo, bD as UpcomingSale, av as DurationUnit, t as BoundaryKind, bk as SchedulingMode, al as DepositType, af as CustomAttributeValue, b4 as ProductProperty, be as QuantityPricingTier } from './product-B384_Qm2.js';
8
- import { P as ProductWithPrice } from './price-ncQb-TC8.js';
7
+ import { ad as CurrencyCode, aZ as Product, aQ as Pagination, V as CimplifyError, bb as ProductWithDetails, S as Category, aO as Money, U as ChosenPrice, E as BundleSelectionInput, a1 as ComponentSelectionInput, D as BundleSelectionData, aa as CompositeSelectionData, W as Collection, b6 as ProductTaxonomy, bx as TaxonomyWithChildren, b7 as ProductTimeProfile, aj as Deal, b2 as ProductDealInfo, ap as DiscountValidation, G as BundleSummary, a8 as CompositePriceResult, bs as SubscriptionWithDetails, br as SubscriptionStatus, bo as Subscription, ae as CustomAttributeDefinition, bc as PropertyFacet, b1 as ProductBillingPlan, bQ as VariantView, bK as VariantAxisWithValues, f as AddOnWithOptions, y as BundleComponentView, z as BundlePriceType, a6 as CompositeGroupView, as as DisplayCart, b3 as ProductInputField, h as AddressValue, bi as SaleInfo, bD as UpcomingSale, av as DurationUnit, t as BoundaryKind, bk as SchedulingMode, al as DepositType, af as CustomAttributeValue, b4 as ProductProperty, be as QuantityPricingTier } from './product-CeV8euw4.js';
8
+ import { P as ProductWithPrice } from './price-CJLfcYKd.js';
9
9
  import { ClassValue } from 'clsx';
10
10
  import { Matcher } from 'react-day-picker';
11
- import './payment-lZBP7h5M.js';
11
+ import './payment-jK8ztICx.js';
12
12
 
13
13
  interface UserIdentity {
14
14
  uid: string;
package/dist/react.js CHANGED
@@ -3,8 +3,8 @@
3
3
 
4
4
  var chunkQPRI2NII_js = require('./chunk-QPRI2NII.js');
5
5
  var chunkXREIZ56K_js = require('./chunk-XREIZ56K.js');
6
- var chunkBHQCSHIG_js = require('./chunk-BHQCSHIG.js');
7
- var chunkQGFKIAEM_js = require('./chunk-QGFKIAEM.js');
6
+ var chunkCNY2XFN4_js = require('./chunk-CNY2XFN4.js');
7
+ var chunkFWKSBF3F_js = require('./chunk-FWKSBF3F.js');
8
8
  var chunkWMEC5JWN_js = require('./chunk-WMEC5JWN.js');
9
9
  var chunkNIOUSKQQ_js = require('./chunk-NIOUSKQQ.js');
10
10
  require('./chunk-OWW5GUSB.js');
@@ -379,6 +379,26 @@ function Ad({
379
379
  }
380
380
 
381
381
  // src/utils/cart-transform.ts
382
+ var DECIMAL_AMOUNT_PATTERN = /^([+-]?)(\d+)(?:\.(\d+))?$/;
383
+ function multiplyDecimalByInteger(value, multiplier) {
384
+ if (!Number.isSafeInteger(multiplier) || multiplier < 0) {
385
+ throw new RangeError("Cart item quantity must be a non-negative safe integer");
386
+ }
387
+ const source = String(value).trim();
388
+ const match = DECIMAL_AMOUNT_PATTERN.exec(source);
389
+ if (!match) {
390
+ throw new TypeError("Cart item price must be a decimal amount");
391
+ }
392
+ const [, sign, whole, fraction = ""] = match;
393
+ const scaledAmount = BigInt(`${sign}${whole}${fraction}`);
394
+ const scaledTotal = scaledAmount * BigInt(multiplier);
395
+ if (fraction.length === 0) return scaledTotal.toString();
396
+ const negative = scaledTotal < 0n;
397
+ const digits = (negative ? -scaledTotal : scaledTotal).toString().padStart(fraction.length + 1, "0");
398
+ const splitAt = digits.length - fraction.length;
399
+ const formatted = `${digits.slice(0, splitAt)}.${digits.slice(splitAt)}`;
400
+ return negative ? `-${formatted}` : formatted;
401
+ }
382
402
  function getSelections(item) {
383
403
  if (item.bundle_resolved?.selections?.length) {
384
404
  return item.bundle_resolved.selections.map((s) => ({
@@ -397,11 +417,12 @@ function getSelections(item) {
397
417
  }
398
418
  function mapItem(item, fx) {
399
419
  const amt = (value) => fx ? String(fx.convertPrice(value)) : String(value);
420
+ const currentUnitPrice = item.total_price;
400
421
  const result = {
401
422
  name: item.name,
402
423
  quantity: item.quantity,
403
- unit_price: amt(item.base_price),
404
- total_price: amt(item.total_price),
424
+ unit_price: amt(currentUnitPrice),
425
+ total_price: amt(multiplyDecimalByInteger(currentUnitPrice, item.quantity)),
405
426
  line_type: item.line_type
406
427
  };
407
428
  if (item.image_url) result.image_url = item.image_url;
@@ -422,9 +443,9 @@ function mapItem(item, fx) {
422
443
  }
423
444
  return result;
424
445
  }
425
- function transformToCheckoutCart(cart, fx) {
446
+ function transformToCheckoutCart(cart, fx, checkout) {
426
447
  const amt = (value) => fx ? String(fx.convertPrice(value)) : String(value);
427
- return {
448
+ const checkoutCart = {
428
449
  items: cart.items.map((item) => mapItem(item, fx)),
429
450
  subtotal: amt(cart.pricing.subtotal),
430
451
  tax_amount: amt(cart.pricing.tax_amount),
@@ -437,6 +458,7 @@ function transformToCheckoutCart(cart, fx) {
437
458
  deposit_amount: cart.pricing.deposit_amount != null ? amt(cart.pricing.deposit_amount) : void 0,
438
459
  requires_delivery: cart.requires_delivery
439
460
  };
461
+ return checkoutCart;
440
462
  }
441
463
 
442
464
  // src/internal/collection.ts
@@ -823,7 +845,7 @@ async function syncFromServer(entry) {
823
845
  return next;
824
846
  }
825
847
  function emitMutationError(entry, operation, opId, idempotencyKey, error) {
826
- entry.client.events.emit(chunkBHQCSHIG_js.MUTATION_ERROR, {
848
+ entry.client.events.emit(chunkCNY2XFN4_js.MUTATION_ERROR, {
827
849
  service: "cart",
828
850
  operation,
829
851
  opId,
@@ -863,10 +885,10 @@ function getOrCreateStore(params) {
863
885
  syncTail: Promise.resolve(),
864
886
  failedOpRemovers: /* @__PURE__ */ new Set()
865
887
  };
866
- client.events.on(chunkBHQCSHIG_js.SESSION_CLAIMED, () => {
888
+ client.events.on(chunkCNY2XFN4_js.SESSION_CLAIMED, () => {
867
889
  if (entry.initialized) void syncFromServer(entry);
868
890
  });
869
- client.events.on(chunkBHQCSHIG_js.SESSION_CLEARED, () => {
891
+ client.events.on(chunkCNY2XFN4_js.SESSION_CLEARED, () => {
870
892
  if (entry.initialized) void syncFromServer(entry);
871
893
  });
872
894
  cartStores.set(storeKey, entry);
@@ -1170,7 +1192,7 @@ var DEFAULT_COUNTRY = "US";
1170
1192
  function createDefaultClient() {
1171
1193
  const processRef = globalThis.process;
1172
1194
  const envPublicKey = processRef?.env?.NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY || "";
1173
- return chunkBHQCSHIG_js.createCimplifyClient({ publicKey: envPublicKey });
1195
+ return chunkCNY2XFN4_js.createCimplifyClient({ publicKey: envPublicKey });
1174
1196
  }
1175
1197
  function getStoredLocationId() {
1176
1198
  if (typeof window === "undefined" || !window.localStorage) {
@@ -3482,7 +3504,7 @@ function CimplifySignInButton({
3482
3504
  const onClick = async () => {
3483
3505
  if (busy || disabled || !signInOpts.clientId) return;
3484
3506
  setBusy(true);
3485
- await chunkQGFKIAEM_js.startSignIn({
3507
+ await chunkFWKSBF3F_js.startSignIn({
3486
3508
  ...signInOpts,
3487
3509
  onSuccess: () => {
3488
3510
  setBusy(false);
@@ -4950,9 +4972,9 @@ function useClientSessionEpoch(client) {
4950
4972
  const subscribe = React14.useCallback(
4951
4973
  (notify) => {
4952
4974
  const unsubscribe = [
4953
- client.events.on(chunkBHQCSHIG_js.AUTH_TOKEN_CHANGED, notify),
4954
- client.events.on(chunkBHQCSHIG_js.SESSION_CLAIMED, notify),
4955
- client.events.on(chunkBHQCSHIG_js.SESSION_CLEARED, notify)
4975
+ client.events.on(chunkCNY2XFN4_js.AUTH_TOKEN_CHANGED, notify),
4976
+ client.events.on(chunkCNY2XFN4_js.SESSION_CLAIMED, notify),
4977
+ client.events.on(chunkCNY2XFN4_js.SESSION_CLEARED, notify)
4956
4978
  ];
4957
4979
  return () => {
4958
4980
  for (const stopListening of unsubscribe) {
@@ -6282,7 +6304,7 @@ function useChat(options = {}) {
6282
6304
  const watchSessionClaims = React14.useCallback(() => {
6283
6305
  const c = clientRef.current;
6284
6306
  if (!c || claimUnsubRef.current) return;
6285
- const unsubClaimed = c.events.on(chunkBHQCSHIG_js.SESSION_CLAIMED, (event) => {
6307
+ const unsubClaimed = c.events.on(chunkCNY2XFN4_js.SESSION_CLAIMED, (event) => {
6286
6308
  setClaimedAs(event.customerName || c.support.claimedCustomerName || null);
6287
6309
  if (!openedRef.current) {
6288
6310
  void openIfExisting();
@@ -6291,7 +6313,7 @@ function useChat(options = {}) {
6291
6313
  connectWebSocket();
6292
6314
  void resyncConversation();
6293
6315
  });
6294
- const unsubCleared = c.events.on(chunkBHQCSHIG_js.SESSION_CLEARED, resetConversation);
6316
+ const unsubCleared = c.events.on(chunkCNY2XFN4_js.SESSION_CLEARED, resetConversation);
6295
6317
  claimUnsubRef.current = () => {
6296
6318
  unsubClaimed();
6297
6319
  unsubCleared();
@@ -6343,7 +6365,7 @@ function useChat(options = {}) {
6343
6365
  if (!openedRef.current) return false;
6344
6366
  }
6345
6367
  const replyTo = opts?.replyTo;
6346
- const clientId = chunkQGFKIAEM_js.generateIdempotencyKey();
6368
+ const clientId = chunkFWKSBF3F_js.generateIdempotencyKey();
6347
6369
  const localId = optimisticId(clientId);
6348
6370
  const optimistic = {
6349
6371
  id: localId,
@@ -6532,15 +6554,15 @@ function AuthElement({
6532
6554
  }, [onReady, onAuthenticated, onError]);
6533
6555
  React14.useEffect(() => {
6534
6556
  if (!elements || !containerRef.current) return;
6535
- const element = elements.create(chunkQGFKIAEM_js.ELEMENT_TYPES.AUTH, { prefillEmail });
6557
+ const element = elements.create(chunkFWKSBF3F_js.ELEMENT_TYPES.AUTH, { prefillEmail });
6536
6558
  elementRef.current = element;
6537
- element.on(chunkQGFKIAEM_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
6559
+ element.on(chunkFWKSBF3F_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
6538
6560
  element.on(
6539
- chunkQGFKIAEM_js.EVENT_TYPES.AUTHENTICATED,
6561
+ chunkFWKSBF3F_js.EVENT_TYPES.AUTHENTICATED,
6540
6562
  (data) => onAuthenticatedRef.current?.(data)
6541
6563
  );
6542
6564
  element.on(
6543
- chunkQGFKIAEM_js.EVENT_TYPES.ERROR,
6565
+ chunkFWKSBF3F_js.EVENT_TYPES.ERROR,
6544
6566
  (data) => onErrorRef.current?.(data)
6545
6567
  );
6546
6568
  element.mount(containerRef.current);
@@ -6569,15 +6591,15 @@ function AddressElement({
6569
6591
  }, [onReady, onChange, onError]);
6570
6592
  React14.useEffect(() => {
6571
6593
  if (!elements || !containerRef.current) return;
6572
- const element = elements.create(chunkQGFKIAEM_js.ELEMENT_TYPES.ADDRESS, { mode });
6594
+ const element = elements.create(chunkFWKSBF3F_js.ELEMENT_TYPES.ADDRESS, { mode });
6573
6595
  elementRef.current = element;
6574
- element.on(chunkQGFKIAEM_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
6596
+ element.on(chunkFWKSBF3F_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
6575
6597
  element.on(
6576
- chunkQGFKIAEM_js.EVENT_TYPES.CHANGE,
6598
+ chunkFWKSBF3F_js.EVENT_TYPES.CHANGE,
6577
6599
  (data) => onChangeRef.current?.(data)
6578
6600
  );
6579
6601
  element.on(
6580
- chunkQGFKIAEM_js.EVENT_TYPES.ERROR,
6602
+ chunkFWKSBF3F_js.EVENT_TYPES.ERROR,
6581
6603
  (data) => onErrorRef.current?.(data)
6582
6604
  );
6583
6605
  element.mount(containerRef.current);
@@ -6607,15 +6629,15 @@ function PaymentElement({
6607
6629
  }, [onReady, onChange, onError]);
6608
6630
  React14.useEffect(() => {
6609
6631
  if (!elements || !containerRef.current) return;
6610
- const element = elements.create(chunkQGFKIAEM_js.ELEMENT_TYPES.PAYMENT, { amount, currency });
6632
+ const element = elements.create(chunkFWKSBF3F_js.ELEMENT_TYPES.PAYMENT, { amount, currency });
6611
6633
  elementRef.current = element;
6612
- element.on(chunkQGFKIAEM_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
6634
+ element.on(chunkFWKSBF3F_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
6613
6635
  element.on(
6614
- chunkQGFKIAEM_js.EVENT_TYPES.CHANGE,
6636
+ chunkFWKSBF3F_js.EVENT_TYPES.CHANGE,
6615
6637
  (data) => onChangeRef.current?.(data)
6616
6638
  );
6617
6639
  element.on(
6618
- chunkQGFKIAEM_js.EVENT_TYPES.ERROR,
6640
+ chunkFWKSBF3F_js.EVENT_TYPES.ERROR,
6619
6641
  (data) => onErrorRef.current?.(data)
6620
6642
  );
6621
6643
  element.mount(containerRef.current);
package/dist/react.mjs CHANGED
@@ -3,8 +3,8 @@ import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, isMultiDayServi
3
3
  export { getVariantDisplayName } from './chunk-4G5UWFC3.mjs';
4
4
  import { splitGenUIContent, messagePreview } from './chunk-U4MW6PYU.mjs';
5
5
  export { messagePreview, splitGenUIContent } from './chunk-U4MW6PYU.mjs';
6
- import { SESSION_CLAIMED, SESSION_CLEARED, createCimplifyClient, AUTH_TOKEN_CHANGED, MUTATION_ERROR } from './chunk-T2B656RS.mjs';
7
- import { generateIdempotencyKey, ELEMENT_TYPES, EVENT_TYPES, startSignIn } from './chunk-PTKAN4SI.mjs';
6
+ import { SESSION_CLAIMED, SESSION_CLEARED, createCimplifyClient, AUTH_TOKEN_CHANGED, MUTATION_ERROR } from './chunk-XG4DZT4I.mjs';
7
+ import { generateIdempotencyKey, ELEMENT_TYPES, EVENT_TYPES, startSignIn } from './chunk-FFRQNNUQ.mjs';
8
8
  import { parsePrice, formatMoney, formatPrice, getVariantUnitPrice, getProductCurrency, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-DLW3RWRK.mjs';
9
9
  import { isSupportedCurrency, currencyCode, CimplifyError } from './chunk-O3YUHLZL.mjs';
10
10
  import './chunk-3G6RQLXK.mjs';
@@ -355,6 +355,26 @@ function Ad({
355
355
  }
356
356
 
357
357
  // src/utils/cart-transform.ts
358
+ var DECIMAL_AMOUNT_PATTERN = /^([+-]?)(\d+)(?:\.(\d+))?$/;
359
+ function multiplyDecimalByInteger(value, multiplier) {
360
+ if (!Number.isSafeInteger(multiplier) || multiplier < 0) {
361
+ throw new RangeError("Cart item quantity must be a non-negative safe integer");
362
+ }
363
+ const source = String(value).trim();
364
+ const match = DECIMAL_AMOUNT_PATTERN.exec(source);
365
+ if (!match) {
366
+ throw new TypeError("Cart item price must be a decimal amount");
367
+ }
368
+ const [, sign, whole, fraction = ""] = match;
369
+ const scaledAmount = BigInt(`${sign}${whole}${fraction}`);
370
+ const scaledTotal = scaledAmount * BigInt(multiplier);
371
+ if (fraction.length === 0) return scaledTotal.toString();
372
+ const negative = scaledTotal < 0n;
373
+ const digits = (negative ? -scaledTotal : scaledTotal).toString().padStart(fraction.length + 1, "0");
374
+ const splitAt = digits.length - fraction.length;
375
+ const formatted = `${digits.slice(0, splitAt)}.${digits.slice(splitAt)}`;
376
+ return negative ? `-${formatted}` : formatted;
377
+ }
358
378
  function getSelections(item) {
359
379
  if (item.bundle_resolved?.selections?.length) {
360
380
  return item.bundle_resolved.selections.map((s) => ({
@@ -373,11 +393,12 @@ function getSelections(item) {
373
393
  }
374
394
  function mapItem(item, fx) {
375
395
  const amt = (value) => fx ? String(fx.convertPrice(value)) : String(value);
396
+ const currentUnitPrice = item.total_price;
376
397
  const result = {
377
398
  name: item.name,
378
399
  quantity: item.quantity,
379
- unit_price: amt(item.base_price),
380
- total_price: amt(item.total_price),
400
+ unit_price: amt(currentUnitPrice),
401
+ total_price: amt(multiplyDecimalByInteger(currentUnitPrice, item.quantity)),
381
402
  line_type: item.line_type
382
403
  };
383
404
  if (item.image_url) result.image_url = item.image_url;
@@ -398,9 +419,9 @@ function mapItem(item, fx) {
398
419
  }
399
420
  return result;
400
421
  }
401
- function transformToCheckoutCart(cart, fx) {
422
+ function transformToCheckoutCart(cart, fx, checkout) {
402
423
  const amt = (value) => fx ? String(fx.convertPrice(value)) : String(value);
403
- return {
424
+ const checkoutCart = {
404
425
  items: cart.items.map((item) => mapItem(item, fx)),
405
426
  subtotal: amt(cart.pricing.subtotal),
406
427
  tax_amount: amt(cart.pricing.tax_amount),
@@ -413,6 +434,7 @@ function transformToCheckoutCart(cart, fx) {
413
434
  deposit_amount: cart.pricing.deposit_amount != null ? amt(cart.pricing.deposit_amount) : void 0,
414
435
  requires_delivery: cart.requires_delivery
415
436
  };
437
+ return checkoutCart;
416
438
  }
417
439
 
418
440
  // src/internal/collection.ts
@@ -1,5 +1,5 @@
1
1
  import { Hono } from 'hono';
2
- import { b3 as ProductInputField } from './product-B384_Qm2.mjs';
2
+ import { b3 as ProductInputField } from './product-CeV8euw4.mjs';
3
3
 
4
4
  interface Clock {
5
5
  now(): Date;
@@ -936,10 +936,10 @@ interface DeliveryService {
936
936
  }
937
937
 
938
938
  interface ActivityService {
939
- recordEvents(businessId: string, sessionId: string | undefined, events: {
940
- event_type: string;
939
+ recordEvents(businessId: string, sessionId: string | undefined, events: Array<{
940
+ type: string;
941
941
  payload?: Record<string, unknown>;
942
- }[]): {
942
+ }>): {
943
943
  recorded: number;
944
944
  };
945
945
  getState(businessId: string, sessionId: string | undefined): unknown;
@@ -1,5 +1,5 @@
1
1
  import { Hono } from 'hono';
2
- import { b3 as ProductInputField } from './product-B384_Qm2.js';
2
+ import { b3 as ProductInputField } from './product-CeV8euw4.js';
3
3
 
4
4
  interface Clock {
5
5
  now(): Date;
@@ -936,10 +936,10 @@ interface DeliveryService {
936
936
  }
937
937
 
938
938
  interface ActivityService {
939
- recordEvents(businessId: string, sessionId: string | undefined, events: {
940
- event_type: string;
939
+ recordEvents(businessId: string, sessionId: string | undefined, events: Array<{
940
+ type: string;
941
941
  payload?: Record<string, unknown>;
942
- }[]): {
942
+ }>): {
943
943
  recorded: number;
944
944
  };
945
945
  getState(businessId: string, sessionId: string | undefined): unknown;
package/dist/server.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { af as CimplifyClient } from './client-B0Lku_lc.mjs';
2
- export { J as CacheOptions, cC as ReadRequestOptions, cZ as Result } from './client-B0Lku_lc.mjs';
3
- export { S as Category, V as CimplifyError, W as Collection, aZ as Product, bb as ProductWithDetails } from './product-B384_Qm2.mjs';
1
+ import { af as CimplifyClient } from './client-Bx4NRdl8.mjs';
2
+ export { J as CacheOptions, cD as ReadRequestOptions, c_ as Result } from './client-Bx4NRdl8.mjs';
3
+ export { S as Category, V as CimplifyError, W as Collection, aZ as Product, bb as ProductWithDetails } from './product-CeV8euw4.mjs';
4
4
  import { JWTVerifyResult } from 'jose';
5
- import './payment-D8NEwCna.mjs';
5
+ import './payment-BSzy7sly.mjs';
6
6
 
7
7
  interface ServerClientOptions {
8
8
  /**
package/dist/server.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { af as CimplifyClient } from './client-DxgC_lXU.js';
2
- export { J as CacheOptions, cC as ReadRequestOptions, cZ as Result } from './client-DxgC_lXU.js';
3
- export { S as Category, V as CimplifyError, W as Collection, aZ as Product, bb as ProductWithDetails } from './product-B384_Qm2.js';
1
+ import { af as CimplifyClient } from './client-BWdeCgmo.js';
2
+ export { J as CacheOptions, cD as ReadRequestOptions, c_ as Result } from './client-BWdeCgmo.js';
3
+ export { S as Category, V as CimplifyError, W as Collection, aZ as Product, bb as ProductWithDetails } from './product-CeV8euw4.js';
4
4
  import { JWTVerifyResult } from 'jose';
5
- import './payment-lZBP7h5M.js';
5
+ import './payment-jK8ztICx.js';
6
6
 
7
7
  interface ServerClientOptions {
8
8
  /**
package/dist/server.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkBHQCSHIG_js = require('./chunk-BHQCSHIG.js');
4
- var chunkQGFKIAEM_js = require('./chunk-QGFKIAEM.js');
3
+ var chunkCNY2XFN4_js = require('./chunk-CNY2XFN4.js');
4
+ var chunkFWKSBF3F_js = require('./chunk-FWKSBF3F.js');
5
5
  require('./chunk-WMEC5JWN.js');
6
6
  var chunkNIOUSKQQ_js = require('./chunk-NIOUSKQQ.js');
7
7
  require('./chunk-OWW5GUSB.js');
@@ -26,7 +26,7 @@ function readEnv(...keys) {
26
26
  var getServerClient = react.cache((opts = {}) => {
27
27
  const baseUrl = opts.apiUrl ?? readEnv("CIMPLIFY_API_URL", "NEXT_PUBLIC_CIMPLIFY_API_URL") ?? defaultBaseUrl();
28
28
  const publicKey = opts.secretKey ?? readEnv("CIMPLIFY_SECRET_KEY", "NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY") ?? "mock-dev";
29
- const client = chunkBHQCSHIG_js.createCimplifyClient({
29
+ const client = chunkCNY2XFN4_js.createCimplifyClient({
30
30
  baseUrl,
31
31
  publicKey,
32
32
  suppressPublicKeyWarning: true
@@ -250,7 +250,7 @@ var QUERY_AUTH_ERROR = "cimplify_auth_error";
250
250
  var discoveryCache = /* @__PURE__ */ new Map();
251
251
  var jwksCache = /* @__PURE__ */ new Map();
252
252
  function issuerBase(cfg) {
253
- return (cfg.issuer ?? cfg.authUrl ?? chunkQGFKIAEM_js.DEFAULT_ISSUER).replace(/\/$/, "");
253
+ return (cfg.issuer ?? cfg.authUrl ?? chunkFWKSBF3F_js.DEFAULT_ISSUER).replace(/\/$/, "");
254
254
  }
255
255
  function cookieName(cfg) {
256
256
  return cfg.cookieName ?? SESSION_COOKIE;
@@ -465,12 +465,12 @@ async function handleOidcCallback(req, opts) {
465
465
  }
466
466
  function readPkceCookie(cookieHeader) {
467
467
  if (!cookieHeader) return null;
468
- const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunkQGFKIAEM_js.PKCE_COOKIE}=`));
468
+ const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunkFWKSBF3F_js.PKCE_COOKIE}=`));
469
469
  if (!match) return null;
470
- return chunkQGFKIAEM_js.decodePkceState(match.slice(chunkQGFKIAEM_js.PKCE_COOKIE.length + 1));
470
+ return chunkFWKSBF3F_js.decodePkceState(match.slice(chunkFWKSBF3F_js.PKCE_COOKIE.length + 1));
471
471
  }
472
472
  function buildPkceClearCookie() {
473
- return `${chunkQGFKIAEM_js.PKCE_COOKIE}=; Path=${chunkQGFKIAEM_js.PKCE_COOKIE_PATH}; Max-Age=0; Secure; SameSite=Lax`;
473
+ return `${chunkFWKSBF3F_js.PKCE_COOKIE}=; Path=${chunkFWKSBF3F_js.PKCE_COOKIE_PATH}; Max-Age=0; Secure; SameSite=Lax`;
474
474
  }
475
475
  function safeReturnPath(returnTo, fallback) {
476
476
  if (returnTo && returnTo.startsWith("/") && !returnTo.startsWith("//")) return returnTo;
package/dist/server.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { createCimplifyClient } from './chunk-T2B656RS.mjs';
2
- import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-PTKAN4SI.mjs';
1
+ import { createCimplifyClient } from './chunk-XG4DZT4I.mjs';
2
+ import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-FFRQNNUQ.mjs';
3
3
  import './chunk-DLW3RWRK.mjs';
4
4
  export { CimplifyError } from './chunk-O3YUHLZL.mjs';
5
5
  import './chunk-3G6RQLXK.mjs';
@@ -1,6 +1,6 @@
1
- import { A as AppHandle, C as CreateAppOptions } from '../server-oCGNIO_K.mjs';
1
+ import { A as AppHandle, C as CreateAppOptions } from '../server-BRJ61o2J.mjs';
2
2
  import 'hono';
3
- import '../product-B384_Qm2.mjs';
3
+ import '../product-CeV8euw4.mjs';
4
4
 
5
5
  interface MswHandlerSetup {
6
6
  handlers: unknown[];
@@ -1,6 +1,6 @@
1
- import { A as AppHandle, C as CreateAppOptions } from '../server-B7O4ttpv.js';
1
+ import { A as AppHandle, C as CreateAppOptions } from '../server-CXrVYtNo.js';
2
2
  import 'hono';
3
- import '../product-B384_Qm2.js';
3
+ import '../product-CeV8euw4.js';
4
4
 
5
5
  interface MswHandlerSetup {
6
6
  handlers: unknown[];
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkNH3HYUC3_js = require('../chunk-NH3HYUC3.js');
3
+ var chunkXCS56XSS_js = require('../chunk-XCS56XSS.js');
4
4
  require('../chunk-XREIZ56K.js');
5
5
  require('../chunk-NIOUSKQQ.js');
6
6
  require('../chunk-OWW5GUSB.js');
@@ -8,7 +8,7 @@ require('../chunk-OWW5GUSB.js');
8
8
  // src/mock/msw.ts
9
9
  async function createMswHandlers(options = {}) {
10
10
  const baseUrl = options.baseUrl ?? "http://localhost:8787";
11
- const handle = chunkNH3HYUC3_js.createMockApp(options);
11
+ const handle = chunkXCS56XSS_js.createMockApp(options);
12
12
  const msw = await import('msw').catch(() => {
13
13
  throw new Error("msw is required to use @cimplify/sdk/mock/msw \u2014 install it as a peer dependency");
14
14
  });
@@ -1,4 +1,4 @@
1
- import { createMockApp } from '../chunk-NKZIXLKW.mjs';
1
+ import { createMockApp } from '../chunk-HFTRLRLM.mjs';
2
2
  import '../chunk-U4MW6PYU.mjs';
3
3
  import '../chunk-O3YUHLZL.mjs';
4
4
  import '../chunk-3G6RQLXK.mjs';
@@ -1,10 +1,10 @@
1
1
  import { TestAPI } from 'vitest';
2
- import { T as TestClientHandle } from '../client-T5c-Nxq-.mjs';
3
- import { C as CreateAppOptions } from '../server-oCGNIO_K.mjs';
4
- export { S as SeedName } from '../server-oCGNIO_K.mjs';
5
- import '../client-B0Lku_lc.mjs';
6
- import '../product-B384_Qm2.mjs';
7
- import '../payment-D8NEwCna.mjs';
2
+ import { T as TestClientHandle } from '../client-BGeSemVv.mjs';
3
+ import { C as CreateAppOptions } from '../server-BRJ61o2J.mjs';
4
+ export { S as SeedName } from '../server-BRJ61o2J.mjs';
5
+ import '../client-Bx4NRdl8.mjs';
6
+ import '../product-CeV8euw4.mjs';
7
+ import '../payment-BSzy7sly.mjs';
8
8
  import 'hono';
9
9
 
10
10
  /**
@@ -1,10 +1,10 @@
1
1
  import { TestAPI } from 'vitest';
2
- import { T as TestClientHandle } from '../client-DRgEa78P.js';
3
- import { C as CreateAppOptions } from '../server-B7O4ttpv.js';
4
- export { S as SeedName } from '../server-B7O4ttpv.js';
5
- import '../client-DxgC_lXU.js';
6
- import '../product-B384_Qm2.js';
7
- import '../payment-lZBP7h5M.js';
2
+ import { T as TestClientHandle } from '../client-Cvp8W1r9.js';
3
+ import { C as CreateAppOptions } from '../server-CXrVYtNo.js';
4
+ export { S as SeedName } from '../server-CXrVYtNo.js';
5
+ import '../client-BWdeCgmo.js';
6
+ import '../product-CeV8euw4.js';
7
+ import '../payment-jK8ztICx.js';
8
8
  import 'hono';
9
9
 
10
10
  /**