@cimplify/sdk 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkAVVLN353_js = require('./chunk-AVVLN353.js');
5
- var chunkKSN3RJFL_js = require('./chunk-KSN3RJFL.js');
6
- var chunk2BSYTQAY_js = require('./chunk-2BSYTQAY.js');
4
+ var chunkA7IQN5EK_js = require('./chunk-A7IQN5EK.js');
5
+ var chunkVYSXEDBV_js = require('./chunk-VYSXEDBV.js');
6
+ var chunk64OCG2TJ_js = require('./chunk-64OCG2TJ.js');
7
7
  var React3 = require('react');
8
8
  var jsxRuntime = require('react/jsx-runtime');
9
9
  var numberField = require('@base-ui/react/number-field');
@@ -379,7 +379,7 @@ function transformToCheckoutCart(cart, fx) {
379
379
  };
380
380
  }
381
381
  var CART_STORAGE_PREFIX = "cimplify:cart:v2";
382
- var DEFAULT_TAX_RATE = 0.08875;
382
+ var DEFAULT_TAX_RATE = 0;
383
383
  var cartStores = /* @__PURE__ */ new Map();
384
384
  function clearAllCartStores() {
385
385
  for (const [, store] of cartStores) {
@@ -447,13 +447,13 @@ function buildLineKey(productId, options) {
447
447
  return parts.join("|");
448
448
  }
449
449
  function calculateLineSubtotal(item) {
450
- let unitPrice = chunk2BSYTQAY_js.parsePrice(item.product.default_price);
450
+ let unitPrice = chunk64OCG2TJ_js.parsePrice(item.product.default_price);
451
451
  if (item.variant?.price_adjustment) {
452
- unitPrice += chunk2BSYTQAY_js.parsePrice(item.variant.price_adjustment);
452
+ unitPrice += chunk64OCG2TJ_js.parsePrice(item.variant.price_adjustment);
453
453
  }
454
454
  for (const option of item.addOnOptions || []) {
455
455
  if (option.default_price) {
456
- unitPrice += chunk2BSYTQAY_js.parsePrice(option.default_price);
456
+ unitPrice += chunk64OCG2TJ_js.parsePrice(option.default_price);
457
457
  }
458
458
  }
459
459
  return roundMoney(unitPrice * item.quantity);
@@ -892,6 +892,14 @@ function createCartStore(params) {
892
892
  await initializePromise;
893
893
  initializePromise = null;
894
894
  }
895
+ async function reorder(orderId) {
896
+ const result = await client.cart.reorderFromOrder(orderId);
897
+ if (!result.ok) {
898
+ throw result.error;
899
+ }
900
+ await sync();
901
+ return result.value;
902
+ }
895
903
  return {
896
904
  subscribe(listener) {
897
905
  listeners.add(listener);
@@ -907,7 +915,8 @@ function createCartStore(params) {
907
915
  removeItem,
908
916
  updateQuantity,
909
917
  clearCart,
910
- sync
918
+ sync,
919
+ reorder
911
920
  };
912
921
  }
913
922
  function getStoreKey(client, locationId, isDemoMode) {
@@ -988,6 +997,12 @@ function useCart(options = {}) {
988
997
  throw syncError;
989
998
  }
990
999
  }, [store]);
1000
+ const reorder = React3.useCallback(
1001
+ async (orderId) => {
1002
+ return store.reorder(orderId);
1003
+ },
1004
+ [store]
1005
+ );
991
1006
  const itemCount = React3.useMemo(
992
1007
  () => snapshot.items.reduce((sum, item) => sum + item.quantity, 0),
993
1008
  [snapshot.items]
@@ -1005,7 +1020,8 @@ function useCart(options = {}) {
1005
1020
  removeItem,
1006
1021
  updateQuantity,
1007
1022
  clearCart,
1008
- sync
1023
+ sync,
1024
+ reorder
1009
1025
  };
1010
1026
  }
1011
1027
  var LOCATION_STORAGE_KEY = "cimplify_location_id";
@@ -1016,7 +1032,7 @@ var DEFAULT_COUNTRY = "US";
1016
1032
  function createDefaultClient() {
1017
1033
  const processRef = globalThis.process;
1018
1034
  const envPublicKey = processRef?.env?.NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY || "";
1019
- return chunkAVVLN353_js.createCimplifyClient({ publicKey: envPublicKey });
1035
+ return chunkA7IQN5EK_js.createCimplifyClient({ publicKey: envPublicKey });
1020
1036
  }
1021
1037
  function getStoredLocationId() {
1022
1038
  if (typeof window === "undefined" || !window.localStorage) {
@@ -1099,7 +1115,7 @@ function CimplifyProvider({
1099
1115
  const setDisplayCurrency = React3.useCallback(
1100
1116
  (currency) => {
1101
1117
  const normalized = currency?.trim().toUpperCase() || null;
1102
- if (normalized && !chunk2BSYTQAY_js.isSupportedCurrency(normalized)) {
1118
+ if (normalized && !chunk64OCG2TJ_js.isSupportedCurrency(normalized)) {
1103
1119
  return;
1104
1120
  }
1105
1121
  setDisplayCurrencyOverride(normalized);
@@ -1661,7 +1677,7 @@ function Price({ amount, className, prefix }) {
1661
1677
  const { displayCurrency, convertPrice } = useCimplify();
1662
1678
  return /* @__PURE__ */ jsxRuntime.jsxs("span", { className, children: [
1663
1679
  prefix,
1664
- chunk2BSYTQAY_js.formatPrice(convertPrice(amount), displayCurrency)
1680
+ chunk64OCG2TJ_js.formatPrice(convertPrice(amount), displayCurrency)
1665
1681
  ] });
1666
1682
  }
1667
1683
  var productsCache = /* @__PURE__ */ new Map();
@@ -1696,6 +1712,7 @@ function useProducts(options = {}) {
1696
1712
  const previousLocationIdRef = React3.useRef(locationId);
1697
1713
  const requestIdRef = React3.useRef(0);
1698
1714
  const tagsSignature = options.tags?.join(",") ?? "";
1715
+ const propertiesSignature = options.properties ? JSON.stringify(options.properties) : "";
1699
1716
  const queryOptions = React3.useMemo(
1700
1717
  () => ({
1701
1718
  category: options.category,
@@ -1725,7 +1742,7 @@ function useProducts(options = {}) {
1725
1742
  options.min_price,
1726
1743
  options.max_price,
1727
1744
  options.page,
1728
- options.properties
1745
+ propertiesSignature
1729
1746
  ]
1730
1747
  );
1731
1748
  const cacheKey = React3.useMemo(
@@ -2007,6 +2024,7 @@ function useCategories(options = {}) {
2007
2024
  }, [cacheKey, load]);
2008
2025
  return { categories, isLoading, error, refetch };
2009
2026
  }
2027
+ var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["completed", "cancelled", "refunded"]);
2010
2028
  var orderCache = /* @__PURE__ */ new Map();
2011
2029
  var orderInflight = /* @__PURE__ */ new Map();
2012
2030
  function buildOrderCacheKey(client, orderId) {
@@ -2023,6 +2041,9 @@ function useOrder(orderId, options = {}) {
2023
2041
  const poll = options.poll ?? false;
2024
2042
  const pollInterval = options.pollInterval ?? 5e3;
2025
2043
  const requestIdRef = React3.useRef(0);
2044
+ const previousStatusRef = React3.useRef(null);
2045
+ const onStatusChangeRef = React3.useRef(options.onStatusChange);
2046
+ onStatusChangeRef.current = options.onStatusChange;
2026
2047
  const cacheKey = React3.useMemo(
2027
2048
  () => buildOrderCacheKey(client, normalizedOrderId),
2028
2049
  [client, normalizedOrderId]
@@ -2073,6 +2094,12 @@ function useOrder(orderId, options = {}) {
2073
2094
  if (nextRequestId === requestIdRef.current) {
2074
2095
  setOrder(value);
2075
2096
  setError(null);
2097
+ if (value && previousStatusRef.current !== null && previousStatusRef.current !== value.status) {
2098
+ onStatusChangeRef.current?.(previousStatusRef.current, value.status, value);
2099
+ }
2100
+ if (value) {
2101
+ previousStatusRef.current = value.status;
2102
+ }
2076
2103
  }
2077
2104
  } catch (loadError) {
2078
2105
  if (nextRequestId === requestIdRef.current) {
@@ -2089,8 +2116,9 @@ function useOrder(orderId, options = {}) {
2089
2116
  React3.useEffect(() => {
2090
2117
  void load(false);
2091
2118
  }, [load]);
2119
+ const isTerminal = order ? TERMINAL_STATUSES.has(order.status) : false;
2092
2120
  React3.useEffect(() => {
2093
- if (!poll || !enabled || normalizedOrderId.length === 0) {
2121
+ if (!poll || !enabled || normalizedOrderId.length === 0 || isTerminal) {
2094
2122
  return;
2095
2123
  }
2096
2124
  const timer = window.setInterval(() => {
@@ -2099,12 +2127,12 @@ function useOrder(orderId, options = {}) {
2099
2127
  return () => {
2100
2128
  window.clearInterval(timer);
2101
2129
  };
2102
- }, [enabled, load, normalizedOrderId, poll, pollInterval]);
2130
+ }, [enabled, isTerminal, load, normalizedOrderId, poll, pollInterval]);
2103
2131
  const refetch = React3.useCallback(async () => {
2104
2132
  orderCache.delete(cacheKey);
2105
2133
  await load(true);
2106
2134
  }, [cacheKey, load]);
2107
- return { order, isLoading, error, refetch };
2135
+ return { order, isLoading, error, refetch, isTerminal };
2108
2136
  }
2109
2137
  var LOCATION_STORAGE_KEY2 = "cimplify_location_id";
2110
2138
  function readStoredLocationId() {
@@ -3504,16 +3532,16 @@ function useProductPrice(input) {
3504
3532
  if (bundleTotalPrice != null) {
3505
3533
  unitPrice = bundleTotalPrice;
3506
3534
  } else if (compositePrice) {
3507
- unitPrice = chunk2BSYTQAY_js.parsePrice(compositePrice.final_price);
3535
+ unitPrice = chunk64OCG2TJ_js.parsePrice(compositePrice.final_price);
3508
3536
  } else {
3509
- unitPrice = chunk2BSYTQAY_js.parsePrice(product.default_price);
3537
+ unitPrice = chunk64OCG2TJ_js.parsePrice(product.default_price);
3510
3538
  if (variant?.price_adjustment) {
3511
- unitPrice += chunk2BSYTQAY_js.parsePrice(variant.price_adjustment);
3539
+ unitPrice += chunk64OCG2TJ_js.parsePrice(variant.price_adjustment);
3512
3540
  }
3513
3541
  if (addOnOptions) {
3514
3542
  for (const option of addOnOptions) {
3515
3543
  if (option.default_price) {
3516
- unitPrice += chunk2BSYTQAY_js.parsePrice(option.default_price);
3544
+ unitPrice += chunk64OCG2TJ_js.parsePrice(option.default_price);
3517
3545
  }
3518
3546
  }
3519
3547
  }
@@ -4750,19 +4778,19 @@ function AuthElement({
4750
4778
  }, [onReady, onAuthenticated, onRequiresOtp, onError]);
4751
4779
  React3.useEffect(() => {
4752
4780
  if (!elements || !containerRef.current) return;
4753
- const element = elements.create(chunkKSN3RJFL_js.ELEMENT_TYPES.AUTH, { prefillEmail });
4781
+ const element = elements.create(chunkVYSXEDBV_js.ELEMENT_TYPES.AUTH, { prefillEmail });
4754
4782
  elementRef.current = element;
4755
- element.on(chunkKSN3RJFL_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
4783
+ element.on(chunkVYSXEDBV_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
4756
4784
  element.on(
4757
- chunkKSN3RJFL_js.EVENT_TYPES.AUTHENTICATED,
4785
+ chunkVYSXEDBV_js.EVENT_TYPES.AUTHENTICATED,
4758
4786
  (data) => onAuthenticatedRef.current?.(data)
4759
4787
  );
4760
4788
  element.on(
4761
- chunkKSN3RJFL_js.EVENT_TYPES.REQUIRES_OTP,
4789
+ chunkVYSXEDBV_js.EVENT_TYPES.REQUIRES_OTP,
4762
4790
  (data) => onRequiresOtpRef.current?.(data)
4763
4791
  );
4764
4792
  element.on(
4765
- chunkKSN3RJFL_js.EVENT_TYPES.ERROR,
4793
+ chunkVYSXEDBV_js.EVENT_TYPES.ERROR,
4766
4794
  (data) => onErrorRef.current?.(data)
4767
4795
  );
4768
4796
  element.mount(containerRef.current);
@@ -4791,15 +4819,15 @@ function AddressElement({
4791
4819
  }, [onReady, onChange, onError]);
4792
4820
  React3.useEffect(() => {
4793
4821
  if (!elements || !containerRef.current) return;
4794
- const element = elements.create(chunkKSN3RJFL_js.ELEMENT_TYPES.ADDRESS, { mode });
4822
+ const element = elements.create(chunkVYSXEDBV_js.ELEMENT_TYPES.ADDRESS, { mode });
4795
4823
  elementRef.current = element;
4796
- element.on(chunkKSN3RJFL_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
4824
+ element.on(chunkVYSXEDBV_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
4797
4825
  element.on(
4798
- chunkKSN3RJFL_js.EVENT_TYPES.CHANGE,
4826
+ chunkVYSXEDBV_js.EVENT_TYPES.CHANGE,
4799
4827
  (data) => onChangeRef.current?.(data)
4800
4828
  );
4801
4829
  element.on(
4802
- chunkKSN3RJFL_js.EVENT_TYPES.ERROR,
4830
+ chunkVYSXEDBV_js.EVENT_TYPES.ERROR,
4803
4831
  (data) => onErrorRef.current?.(data)
4804
4832
  );
4805
4833
  element.mount(containerRef.current);
@@ -4829,15 +4857,15 @@ function PaymentElement({
4829
4857
  }, [onReady, onChange, onError]);
4830
4858
  React3.useEffect(() => {
4831
4859
  if (!elements || !containerRef.current) return;
4832
- const element = elements.create(chunkKSN3RJFL_js.ELEMENT_TYPES.PAYMENT, { amount, currency });
4860
+ const element = elements.create(chunkVYSXEDBV_js.ELEMENT_TYPES.PAYMENT, { amount, currency });
4833
4861
  elementRef.current = element;
4834
- element.on(chunkKSN3RJFL_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
4862
+ element.on(chunkVYSXEDBV_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
4835
4863
  element.on(
4836
- chunkKSN3RJFL_js.EVENT_TYPES.CHANGE,
4864
+ chunkVYSXEDBV_js.EVENT_TYPES.CHANGE,
4837
4865
  (data) => onChangeRef.current?.(data)
4838
4866
  );
4839
4867
  element.on(
4840
- chunkKSN3RJFL_js.EVENT_TYPES.ERROR,
4868
+ chunkVYSXEDBV_js.EVENT_TYPES.ERROR,
4841
4869
  (data) => onErrorRef.current?.(data)
4842
4870
  );
4843
4871
  element.mount(containerRef.current);
@@ -4996,7 +5024,7 @@ function VariantSelector({
4996
5024
  if (!variants || variants.length <= 1) {
4997
5025
  return null;
4998
5026
  }
4999
- basePrice != null ? chunk2BSYTQAY_js.parsePrice(basePrice) : 0;
5027
+ basePrice != null ? chunk64OCG2TJ_js.parsePrice(basePrice) : 0;
5000
5028
  if (variantAxes && variantAxes.length > 0) {
5001
5029
  return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-variant-selector": true, className: cn("space-y-5", className, classNames?.root), children: variantAxes.map((axis) => {
5002
5030
  const labelId = `${idPrefix}-axis-${axis.id}`;
@@ -5072,7 +5100,7 @@ function VariantSelector({
5072
5100
  className: cn("divide-y divide-border", classNames?.list),
5073
5101
  children: variants.map((variant) => {
5074
5102
  const isSelected = selectedVariantId === variant.id;
5075
- const adjustment = chunk2BSYTQAY_js.parsePrice(variant.price_adjustment);
5103
+ const adjustment = chunk64OCG2TJ_js.parsePrice(variant.price_adjustment);
5076
5104
  return /* @__PURE__ */ jsxRuntime.jsxs(
5077
5105
  radio.Radio.Root,
5078
5106
  {
@@ -5100,7 +5128,7 @@ function VariantSelector({
5100
5128
  {
5101
5129
  "data-cimplify-variant-name": true,
5102
5130
  className: cn("flex-1 min-w-0 text-sm", classNames?.name),
5103
- children: chunkAVVLN353_js.getVariantDisplayName(variant, productName)
5131
+ children: chunkA7IQN5EK_js.getVariantDisplayName(variant, productName)
5104
5132
  }
5105
5133
  ),
5106
5134
  /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-variant-pricing": true, className: cn("text-sm text-muted-foreground", classNames?.pricing), children: [
@@ -5338,16 +5366,16 @@ function BundleSelector({
5338
5366
  }, [components, selections, onReady]);
5339
5367
  const totalPrice = React3.useMemo(() => {
5340
5368
  if (pricingType === "fixed" && bundlePrice) {
5341
- return chunk2BSYTQAY_js.parsePrice(bundlePrice);
5369
+ return chunk64OCG2TJ_js.parsePrice(bundlePrice);
5342
5370
  }
5343
5371
  const componentsTotal = components.reduce((sum, comp) => {
5344
5372
  return sum + getComponentPrice(comp, variantChoices[comp.id]) * comp.quantity;
5345
5373
  }, 0);
5346
5374
  if (pricingType === "percentage_discount" && discountValue) {
5347
- return componentsTotal * (1 - chunk2BSYTQAY_js.parsePrice(discountValue) / 100);
5375
+ return componentsTotal * (1 - chunk64OCG2TJ_js.parsePrice(discountValue) / 100);
5348
5376
  }
5349
5377
  if (pricingType === "fixed_discount" && discountValue) {
5350
- return componentsTotal - chunk2BSYTQAY_js.parsePrice(discountValue);
5378
+ return componentsTotal - chunk64OCG2TJ_js.parsePrice(discountValue);
5351
5379
  }
5352
5380
  return componentsTotal;
5353
5381
  }, [components, variantChoices, pricingType, bundlePrice, discountValue]);
@@ -5408,15 +5436,15 @@ function BundleSelector({
5408
5436
  }
5409
5437
  function getComponentPrice(component, selectedVariantId) {
5410
5438
  if (!selectedVariantId || component.available_variants.length === 0) {
5411
- return chunk2BSYTQAY_js.parsePrice(component.effective_price);
5439
+ return chunk64OCG2TJ_js.parsePrice(component.effective_price);
5412
5440
  }
5413
5441
  if (selectedVariantId === component.variant_id) {
5414
- return chunk2BSYTQAY_js.parsePrice(component.effective_price);
5442
+ return chunk64OCG2TJ_js.parsePrice(component.effective_price);
5415
5443
  }
5416
5444
  const bakedAdj = component.variant_id ? component.available_variants.find((v) => v.id === component.variant_id) : void 0;
5417
5445
  const selectedAdj = component.available_variants.find((v) => v.id === selectedVariantId);
5418
- if (!selectedAdj) return chunk2BSYTQAY_js.parsePrice(component.effective_price);
5419
- return chunk2BSYTQAY_js.parsePrice(component.effective_price) - chunk2BSYTQAY_js.parsePrice(bakedAdj?.price_adjustment ?? "0") + chunk2BSYTQAY_js.parsePrice(selectedAdj.price_adjustment);
5446
+ if (!selectedAdj) return chunk64OCG2TJ_js.parsePrice(component.effective_price);
5447
+ return chunk64OCG2TJ_js.parsePrice(component.effective_price) - chunk64OCG2TJ_js.parsePrice(bakedAdj?.price_adjustment ?? "0") + chunk64OCG2TJ_js.parsePrice(selectedAdj.price_adjustment);
5420
5448
  }
5421
5449
  function formatDuration(minutes, unit) {
5422
5450
  if (unit === "hours" || !unit && minutes >= 60 && minutes % 60 === 0) {
@@ -5529,7 +5557,7 @@ function BundleComponentCard({
5529
5557
  className: cn("mt-3 divide-y divide-border", classNames?.variantPicker),
5530
5558
  children: component.available_variants.map((variant) => {
5531
5559
  const isSelected = selectedVariantId === variant.id;
5532
- const adjustment = chunk2BSYTQAY_js.parsePrice(variant.price_adjustment);
5560
+ const adjustment = chunk64OCG2TJ_js.parsePrice(variant.price_adjustment);
5533
5561
  return /* @__PURE__ */ jsxRuntime.jsxs(
5534
5562
  radio.Radio.Root,
5535
5563
  {
@@ -5975,7 +6003,7 @@ function CompositeSelector({
5975
6003
  "data-cimplify-composite-summary": true,
5976
6004
  className: cn("border-t border-border pt-4 space-y-1 text-sm", classNames?.summary),
5977
6005
  children: [
5978
- chunk2BSYTQAY_js.parsePrice(priceResult.base_price) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(
6006
+ chunk64OCG2TJ_js.parsePrice(priceResult.base_price) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(
5979
6007
  "div",
5980
6008
  {
5981
6009
  "data-cimplify-composite-summary-line": true,
@@ -5986,7 +6014,7 @@ function CompositeSelector({
5986
6014
  ]
5987
6015
  }
5988
6016
  ),
5989
- chunk2BSYTQAY_js.parsePrice(priceResult.components_total) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(
6017
+ chunk64OCG2TJ_js.parsePrice(priceResult.components_total) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(
5990
6018
  "div",
5991
6019
  {
5992
6020
  "data-cimplify-composite-summary-line": true,
@@ -6091,18 +6119,18 @@ function ProductCustomizer({
6091
6119
  }, [selectedAddOnOptionIds]);
6092
6120
  const localTotalPrice = React3.useMemo(() => {
6093
6121
  if (isComposite && compositePrice) {
6094
- return chunk2BSYTQAY_js.parsePrice(compositePrice.final_price) * quantity;
6122
+ return chunk64OCG2TJ_js.parsePrice(compositePrice.final_price) * quantity;
6095
6123
  }
6096
6124
  if (isBundle && bundleTotalPrice != null) {
6097
6125
  return bundleTotalPrice * quantity;
6098
6126
  }
6099
- let price = chunk2BSYTQAY_js.parsePrice(product.default_price);
6127
+ let price = chunk64OCG2TJ_js.parsePrice(product.default_price);
6100
6128
  if (selectedVariant?.price_adjustment) {
6101
- price += chunk2BSYTQAY_js.parsePrice(selectedVariant.price_adjustment);
6129
+ price += chunk64OCG2TJ_js.parsePrice(selectedVariant.price_adjustment);
6102
6130
  }
6103
6131
  for (const option of selectedAddOnOptions) {
6104
6132
  if (option.default_price) {
6105
- price += chunk2BSYTQAY_js.parsePrice(option.default_price);
6133
+ price += chunk64OCG2TJ_js.parsePrice(option.default_price);
6106
6134
  }
6107
6135
  }
6108
6136
  return price * quantity;
@@ -6143,7 +6171,7 @@ function ProductCustomizer({
6143
6171
  const priceInfo = quote.quoted_total_price_info ?? quote.final_price_info;
6144
6172
  const perUnit = priceInfo.pre_tax_price;
6145
6173
  if (perUnit === void 0 || perUnit === null) return void 0;
6146
- return chunk2BSYTQAY_js.parsePrice(perUnit) * quantity;
6174
+ return chunk64OCG2TJ_js.parsePrice(perUnit) * quantity;
6147
6175
  }, [quote, quantity]);
6148
6176
  const displayTotalPrice = quotedTotalPrice ?? localTotalPrice;
6149
6177
  const handleVariantChange = React3.useCallback(
@@ -6235,7 +6263,7 @@ function ProductCustomizer({
6235
6263
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: product.deposit_amount })
6236
6264
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6237
6265
  "Deposit required: ",
6238
- chunk2BSYTQAY_js.parsePrice(product.deposit_amount),
6266
+ chunk64OCG2TJ_js.parsePrice(product.deposit_amount),
6239
6267
  "%"
6240
6268
  ] }) }),
6241
6269
  product.allergies && product.allergies.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-customizer-allergens": true, className: cn("flex flex-wrap gap-1.5", classNames?.allergens), children: product.allergies.map((allergen) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -6414,7 +6442,7 @@ function CartLineItemRow({
6414
6442
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item": true, className: classNames?.item, children: [
6415
6443
  /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item-info": true, children: [
6416
6444
  /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-name": true, className: classNames?.itemName, children: item.product.name }),
6417
- item.variant && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-variant": true, children: chunkAVVLN353_js.getVariantDisplayName(item.variant, item.product.name) }),
6445
+ item.variant && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-variant": true, children: chunkA7IQN5EK_js.getVariantDisplayName(item.variant, item.product.name) }),
6418
6446
  item.addOnOptions && item.addOnOptions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-cart-item-addons": true, children: [
6419
6447
  "+ ",
6420
6448
  item.addOnOptions.map((opt) => opt.name).join(", ")
@@ -6536,15 +6564,15 @@ function CartSummary({
6536
6564
  ] }),
6537
6565
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: subtotal })
6538
6566
  ] }),
6539
- totalDiscounts != null && chunk2BSYTQAY_js.parsePrice(totalDiscounts) > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-discount": true, className: classNames?.discount, children: [
6567
+ totalDiscounts != null && chunk64OCG2TJ_js.parsePrice(totalDiscounts) > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-discount": true, className: classNames?.discount, children: [
6540
6568
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Discount" }),
6541
6569
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: totalDiscounts, prefix: "-" })
6542
6570
  ] }),
6543
6571
  deliveryFee != null && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-delivery-fee": true, className: classNames?.deliveryFee, children: [
6544
6572
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Delivery fee" }),
6545
- chunk2BSYTQAY_js.parsePrice(deliveryFee) > 0 ? /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: deliveryFee }) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Free delivery" })
6573
+ chunk64OCG2TJ_js.parsePrice(deliveryFee) > 0 ? /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: deliveryFee }) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Free delivery" })
6546
6574
  ] }),
6547
- serviceCharge != null && chunk2BSYTQAY_js.parsePrice(serviceCharge) > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-service-charge": true, className: classNames?.serviceCharge, children: [
6575
+ serviceCharge != null && chunk64OCG2TJ_js.parsePrice(serviceCharge) > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-service-charge": true, className: classNames?.serviceCharge, children: [
6548
6576
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Service charge" }),
6549
6577
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: serviceCharge })
6550
6578
  ] }),
@@ -6627,16 +6655,16 @@ function SaleBadge({
6627
6655
  className,
6628
6656
  classNames
6629
6657
  }) {
6630
- const onSale = chunk2BSYTQAY_js.isOnSale(product);
6658
+ const onSale = chunk64OCG2TJ_js.isOnSale(product);
6631
6659
  const hasDeal = dealInfo !== void 0;
6632
6660
  if (!hasDeal && !onSale && !label) {
6633
6661
  return null;
6634
6662
  }
6635
6663
  let percentage = null;
6636
6664
  if (hasDeal && dealInfo.benefit_type === "percentage") {
6637
- percentage = chunk2BSYTQAY_js.parsePrice(dealInfo.value);
6665
+ percentage = chunk64OCG2TJ_js.parsePrice(dealInfo.value);
6638
6666
  } else if (onSale) {
6639
- percentage = chunk2BSYTQAY_js.getDiscountPercentage(product);
6667
+ percentage = chunk64OCG2TJ_js.getDiscountPercentage(product);
6640
6668
  }
6641
6669
  const badgeText = label ?? dealInfo?.label ?? (percentage != null && percentage > 0 ? `${percentage}% off` : null);
6642
6670
  if (!badgeText) {
@@ -6655,7 +6683,7 @@ function SaleBadge({
6655
6683
  "%"
6656
6684
  ] }),
6657
6685
  /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-sale-label": true, className: classNames?.label, children: badgeText }),
6658
- showOriginalPrice && onSale && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-sale-original-price": true, className: classNames?.originalPrice, children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: chunk2BSYTQAY_js.getBasePrice(product) }) })
6686
+ showOriginalPrice && onSale && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-sale-original-price": true, className: classNames?.originalPrice, children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: chunk64OCG2TJ_js.getBasePrice(product) }) })
6659
6687
  ]
6660
6688
  }
6661
6689
  );
@@ -7171,7 +7199,7 @@ function SearchInput({
7171
7199
  }
7172
7200
  ),
7173
7201
  /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-search-result-name": true, className: classNames?.resultName, style: { flex: 1, textAlign: "left" }, children: product.name }),
7174
- product.default_price !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-search-result-price": true, className: classNames?.resultPrice, style: { flexShrink: 0 }, children: chunk2BSYTQAY_js.formatPrice(product.default_price) })
7202
+ product.default_price !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-search-result-price": true, className: classNames?.resultPrice, style: { flexShrink: 0 }, children: chunk64OCG2TJ_js.formatPrice(product.default_price) })
7175
7203
  ] })
7176
7204
  },
7177
7205
  product.id
@@ -7522,12 +7550,15 @@ function OrderSummary({
7522
7550
  orderId,
7523
7551
  poll = false,
7524
7552
  renderLineItem,
7553
+ onReorder,
7554
+ onStatusChange,
7525
7555
  className,
7526
7556
  classNames
7527
7557
  }) {
7528
7558
  const { order: fetched, isLoading } = useOrder(orderProp ? null : orderId, {
7529
7559
  enabled: !orderProp && !!orderId,
7530
- poll
7560
+ poll,
7561
+ onStatusChange
7531
7562
  });
7532
7563
  const order = orderProp ?? fetched;
7533
7564
  if (isLoading && !order) {
@@ -7662,19 +7693,19 @@ function OrderSummary({
7662
7693
  order.customer_notes.map((note, index) => /* @__PURE__ */ jsxRuntime.jsx("p", { "data-cimplify-order-note": true, children: note }, index))
7663
7694
  ] }),
7664
7695
  /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-totals": true, className: classNames?.totals, children: [
7665
- order.total_discount != null && chunk2BSYTQAY_js.parsePrice(order.total_discount) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-discount": true, children: [
7696
+ order.total_discount != null && chunk64OCG2TJ_js.parsePrice(order.total_discount) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-discount": true, children: [
7666
7697
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Discount" }),
7667
7698
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.total_discount, prefix: "-" })
7668
7699
  ] }),
7669
- order.delivery_fee != null && chunk2BSYTQAY_js.parsePrice(order.delivery_fee) > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-delivery-fee": true, children: [
7700
+ order.delivery_fee != null && chunk64OCG2TJ_js.parsePrice(order.delivery_fee) > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-delivery-fee": true, children: [
7670
7701
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Delivery fee" }),
7671
7702
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.delivery_fee })
7672
7703
  ] }),
7673
- order.service_charge != null && chunk2BSYTQAY_js.parsePrice(order.service_charge) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-service-charge": true, children: [
7704
+ order.service_charge != null && chunk64OCG2TJ_js.parsePrice(order.service_charge) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-service-charge": true, children: [
7674
7705
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Service charge" }),
7675
7706
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.service_charge })
7676
7707
  ] }),
7677
- order.tax != null && chunk2BSYTQAY_js.parsePrice(order.tax) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-tax": true, children: [
7708
+ order.tax != null && chunk64OCG2TJ_js.parsePrice(order.tax) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-tax": true, children: [
7678
7709
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Tax" }),
7679
7710
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.tax })
7680
7711
  ] }),
@@ -7693,6 +7724,16 @@ function OrderSummary({
7693
7724
  className: classNames?.trackingLink,
7694
7725
  children: "Track your order"
7695
7726
  }
7727
+ ),
7728
+ onReorder && /* @__PURE__ */ jsxRuntime.jsx(
7729
+ "button",
7730
+ {
7731
+ type: "button",
7732
+ onClick: () => onReorder(order),
7733
+ "data-cimplify-order-reorder": true,
7734
+ className: classNames?.reorderButton,
7735
+ children: "Reorder"
7736
+ }
7696
7737
  )
7697
7738
  ] });
7698
7739
  }
@@ -7716,6 +7757,7 @@ function OrderHistory({
7716
7757
  limit,
7717
7758
  onOrderClick,
7718
7759
  renderOrder,
7760
+ onReorder,
7719
7761
  emptyMessage = "No orders yet",
7720
7762
  className,
7721
7763
  classNames
@@ -7787,7 +7829,20 @@ function OrderHistory({
7787
7829
  order.total_quantity === 1 ? "item" : "items"
7788
7830
  ] }),
7789
7831
  /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-order-history-total": true, className: classNames?.total, children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.total_price }) })
7790
- ] })
7832
+ ] }),
7833
+ onReorder && /* @__PURE__ */ jsxRuntime.jsx(
7834
+ "button",
7835
+ {
7836
+ type: "button",
7837
+ onClick: (e) => {
7838
+ e.stopPropagation();
7839
+ onReorder(order);
7840
+ },
7841
+ "data-cimplify-order-reorder": true,
7842
+ className: classNames?.reorderButton,
7843
+ children: "Reorder"
7844
+ }
7845
+ )
7791
7846
  ] })
7792
7847
  },
7793
7848
  order.id
@@ -8979,6 +9034,8 @@ function OrderDetailPage({
8979
9034
  poll = true,
8980
9035
  onBack,
8981
9036
  renderLineItem,
9037
+ onReorder,
9038
+ onStatusChange,
8982
9039
  backLabel = "Back to orders",
8983
9040
  className,
8984
9041
  classNames
@@ -9003,7 +9060,9 @@ function OrderDetailPage({
9003
9060
  order,
9004
9061
  orderId: order ? void 0 : orderId,
9005
9062
  poll,
9006
- renderLineItem
9063
+ renderLineItem,
9064
+ onReorder,
9065
+ onStatusChange
9007
9066
  }
9008
9067
  ) })
9009
9068
  ] });
@@ -9019,6 +9078,7 @@ function OrderHistoryPage({
9019
9078
  orders: ordersProp,
9020
9079
  limit = 20,
9021
9080
  onOrderNavigate,
9081
+ onReorder,
9022
9082
  showFilters = true,
9023
9083
  renderOrder,
9024
9084
  className,
@@ -9056,7 +9116,7 @@ function OrderHistoryPage({
9056
9116
  children: "Back to orders"
9057
9117
  }
9058
9118
  ),
9059
- /* @__PURE__ */ jsxRuntime.jsx(OrderSummary, { order: selectedOrder })
9119
+ /* @__PURE__ */ jsxRuntime.jsx(OrderSummary, { order: selectedOrder, onReorder })
9060
9120
  ] }) });
9061
9121
  }
9062
9122
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-history-page": true, className: cn(className, classNames?.root), children: [
@@ -9079,7 +9139,8 @@ function OrderHistoryPage({
9079
9139
  status: statusFilter,
9080
9140
  limit,
9081
9141
  onOrderClick: handleOrderClick,
9082
- renderOrder
9142
+ renderOrder,
9143
+ onReorder
9083
9144
  }
9084
9145
  ) })
9085
9146
  ] });
@@ -9228,7 +9289,7 @@ function BookingPage({
9228
9289
  const hasStaffStep = staff && staff.length > 0;
9229
9290
  const depositType = product?.deposit_type;
9230
9291
  const depositAmount = product?.deposit_amount;
9231
- const hasDeposit = depositType !== void 0 && depositType !== "none" && depositAmount !== void 0 && chunk2BSYTQAY_js.parsePrice(depositAmount) !== 0;
9292
+ const hasDeposit = depositType !== void 0 && depositType !== "none" && depositAmount !== void 0 && chunk64OCG2TJ_js.parsePrice(depositAmount) !== 0;
9232
9293
  const cancellationMinutes = product?.cancellation_window_minutes;
9233
9294
  const noShowFee = product?.no_show_fee;
9234
9295
  const handleSlotSelect = React3.useCallback(
@@ -9342,14 +9403,14 @@ function BookingPage({
9342
9403
  service.price && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-booking-service-price": true, children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: service.price }) }),
9343
9404
  hasDeposit && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-booking-deposit-info": true, className: classNames?.depositInfo, children: [
9344
9405
  "Deposit: ",
9345
- depositType === "percentage" ? `${chunk2BSYTQAY_js.parsePrice(depositAmount)}%` : /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: depositAmount })
9406
+ depositType === "percentage" ? `${chunk64OCG2TJ_js.parsePrice(depositAmount)}%` : /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: depositAmount })
9346
9407
  ] }),
9347
9408
  cancellationMinutes !== void 0 && cancellationMinutes > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-booking-cancellation-policy": true, className: classNames?.cancellationPolicy, children: [
9348
9409
  "Free cancellation up to ",
9349
9410
  cancellationMinutes >= 60 ? `${Math.floor(cancellationMinutes / 60)} hour${Math.floor(cancellationMinutes / 60) !== 1 ? "s" : ""}` : `${cancellationMinutes} minute${cancellationMinutes !== 1 ? "s" : ""}`,
9350
9411
  " before"
9351
9412
  ] }),
9352
- noShowFee !== void 0 && chunk2BSYTQAY_js.parsePrice(noShowFee) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-booking-no-show-fee": true, className: classNames?.cancellationPolicy, children: [
9413
+ noShowFee !== void 0 && chunk64OCG2TJ_js.parsePrice(noShowFee) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-booking-no-show-fee": true, className: classNames?.cancellationPolicy, children: [
9353
9414
  "No-show fee: ",
9354
9415
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: noShowFee })
9355
9416
  ] })
@@ -9411,7 +9472,7 @@ function BookingPage({
9411
9472
  ] }),
9412
9473
  hasDeposit && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-booking-summary-row": true, className: cn(classNames?.summaryRow, classNames?.depositInfo), children: [
9413
9474
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Deposit" }),
9414
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: depositType === "percentage" ? `${chunk2BSYTQAY_js.parsePrice(depositAmount)}%` : /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: depositAmount }) })
9475
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: depositType === "percentage" ? `${chunk64OCG2TJ_js.parsePrice(depositAmount)}%` : /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: depositAmount }) })
9415
9476
  ] })
9416
9477
  ] }),
9417
9478
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -9971,7 +10032,7 @@ function CurrencySelector({
9971
10032
 
9972
10033
  Object.defineProperty(exports, "getVariantDisplayName", {
9973
10034
  enumerable: true,
9974
- get: function () { return chunkAVVLN353_js.getVariantDisplayName; }
10035
+ get: function () { return chunkA7IQN5EK_js.getVariantDisplayName; }
9975
10036
  });
9976
10037
  exports.Ad = Ad;
9977
10038
  exports.AdProvider = AdProvider;