@cimplify/sdk 0.31.0 → 0.35.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.
Files changed (33) hide show
  1. package/dist/advanced.d.mts +6 -2
  2. package/dist/advanced.d.ts +6 -2
  3. package/dist/advanced.js +21 -21
  4. package/dist/advanced.mjs +2 -2
  5. package/dist/{chunk-46BDUSJX.mjs → chunk-2X6P5WJZ.mjs} +108 -32
  6. package/dist/{chunk-E3HC2YAE.mjs → chunk-6TVQQYQ5.mjs} +14 -1
  7. package/dist/{chunk-2CGA3MUW.js → chunk-HKVRUGM6.js} +142 -91
  8. package/dist/{chunk-3J4PPSMI.mjs → chunk-TFHKVQLL.mjs} +123 -72
  9. package/dist/{chunk-PEDLCL72.js → chunk-V2O5AO7I.js} +15 -0
  10. package/dist/{chunk-6HCBOIZ4.js → chunk-ZYACIPKO.js} +160 -84
  11. package/dist/{index-BpyFcJVv.d.ts → client-CkGlXZRd.d.mts} +121 -72
  12. package/dist/{index-m8zGQUda.d.mts → client-lvLvB1_K.d.ts} +121 -72
  13. package/dist/{index-D4oNCc37.d.mts → index-CC1JPhB2.d.mts} +2 -2
  14. package/dist/{index-BHVJgyqM.d.ts → index-CPcFayQg.d.ts} +2 -2
  15. package/dist/index.d.mts +6 -5
  16. package/dist/index.d.ts +6 -5
  17. package/dist/index.js +117 -109
  18. package/dist/index.mjs +3 -3
  19. package/dist/{payment-DnU_eLuT.d.ts → payment-DA1i5hhk.d.mts} +13 -12
  20. package/dist/{payment-DnU_eLuT.d.mts → payment-DA1i5hhk.d.ts} +13 -12
  21. package/dist/{price-DUVmRTaz.d.ts → price-Bv4G8aOO.d.ts} +1 -1
  22. package/dist/{price-D-hso3np.d.mts → price-s1XN0edJ.d.mts} +1 -1
  23. package/dist/react.d.mts +21 -4
  24. package/dist/react.d.ts +21 -4
  25. package/dist/react.js +835 -715
  26. package/dist/react.mjs +725 -605
  27. package/dist/styles.css +1 -1
  28. package/dist/utils.d.mts +3 -3
  29. package/dist/utils.d.ts +3 -3
  30. package/dist/utils.js +28 -28
  31. package/dist/utils.mjs +1 -1
  32. package/package.json +8 -8
  33. package/registry/cart-summary.json +1 -1
package/dist/react.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunk6HCBOIZ4_js = require('./chunk-6HCBOIZ4.js');
5
- var chunk2CGA3MUW_js = require('./chunk-2CGA3MUW.js');
6
- var chunkPEDLCL72_js = require('./chunk-PEDLCL72.js');
4
+ var chunkZYACIPKO_js = require('./chunk-ZYACIPKO.js');
5
+ var chunkHKVRUGM6_js = require('./chunk-HKVRUGM6.js');
6
+ var chunkV2O5AO7I_js = require('./chunk-V2O5AO7I.js');
7
7
  var React10 = require('react');
8
8
  var jsxRuntime = require('react/jsx-runtime');
9
9
  var clsx = require('clsx');
@@ -403,19 +403,114 @@ function transformToCheckoutCart(cart, fx) {
403
403
  currency: fx?.displayCurrency ?? cart.pricing.currency
404
404
  };
405
405
  }
406
- var CART_STORAGE_PREFIX = "cimplify:cart:v2";
407
- var DEFAULT_TAX_RATE = 0;
408
- var cartStores = /* @__PURE__ */ new Map();
409
- function clearAllCartStores() {
410
- for (const [, store] of cartStores) {
411
- void store.clearCart();
406
+
407
+ // src/internal/collection.ts
408
+ function newOpId() {
409
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
410
+ return `op_${crypto.randomUUID()}`;
412
411
  }
413
- cartStores.clear();
412
+ return `op_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
414
413
  }
415
- function toNumber(value) {
416
- if (typeof value === "number" && Number.isFinite(value)) {
417
- return value;
414
+ function createCollection(config) {
415
+ let base = config.initialBase ?? null;
416
+ let ops = [];
417
+ const listeners = /* @__PURE__ */ new Set();
418
+ let cachedView;
419
+ let cachedBaseRef;
420
+ let cachedOpsVersion = -1;
421
+ let opsVersion = 0;
422
+ function notify() {
423
+ for (const listener of listeners) {
424
+ listener();
425
+ }
418
426
  }
427
+ function recompute() {
428
+ if (cachedView !== void 0 && cachedBaseRef === base && cachedOpsVersion === opsVersion) {
429
+ return cachedView;
430
+ }
431
+ const view = config.toView(base, ops);
432
+ cachedView = view;
433
+ cachedBaseRef = base;
434
+ cachedOpsVersion = opsVersion;
435
+ return view;
436
+ }
437
+ return {
438
+ subscribe(listener) {
439
+ listeners.add(listener);
440
+ return () => {
441
+ listeners.delete(listener);
442
+ };
443
+ },
444
+ getSnapshot() {
445
+ return recompute();
446
+ },
447
+ setBase(next) {
448
+ base = next;
449
+ opsVersion++;
450
+ notify();
451
+ },
452
+ enqueue(patch, idempotencyKey) {
453
+ const op = {
454
+ id: newOpId(),
455
+ idempotencyKey,
456
+ patch,
457
+ status: "pending",
458
+ attemptCount: 0,
459
+ enqueuedAt: Date.now()
460
+ };
461
+ ops = [...ops, op];
462
+ opsVersion++;
463
+ notify();
464
+ return op.id;
465
+ },
466
+ confirm(opId, newBase) {
467
+ const idx = ops.findIndex((op) => op.id === opId);
468
+ if (idx === -1 && newBase === void 0) {
469
+ return;
470
+ }
471
+ if (idx !== -1) {
472
+ ops = ops.filter((op) => op.id !== opId);
473
+ }
474
+ if (newBase !== void 0) {
475
+ base = newBase;
476
+ }
477
+ opsVersion++;
478
+ notify();
479
+ },
480
+ fail(opId, error) {
481
+ const idx = ops.findIndex((op) => op.id === opId);
482
+ if (idx === -1) return;
483
+ ops = ops.map(
484
+ (op, i) => i === idx ? {
485
+ ...op,
486
+ status: "failed",
487
+ attemptCount: op.attemptCount + 1,
488
+ lastError: error
489
+ } : op
490
+ );
491
+ opsVersion++;
492
+ notify();
493
+ },
494
+ remove(opId) {
495
+ const next = ops.filter((op) => op.id !== opId);
496
+ if (next.length === ops.length) return;
497
+ ops = next;
498
+ opsVersion++;
499
+ notify();
500
+ },
501
+ getOps() {
502
+ return ops;
503
+ },
504
+ getBase() {
505
+ return base;
506
+ }
507
+ };
508
+ }
509
+
510
+ // src/internal/cart-patches.ts
511
+ var DEFAULT_TAX_RATE = 0;
512
+ function toNumber(value) {
513
+ if (typeof value === "number" && Number.isFinite(value)) return value;
419
514
  if (typeof value === "string") {
420
515
  const parsed = Number.parseFloat(value);
421
516
  return Number.isFinite(parsed) ? parsed : 0;
@@ -426,30 +521,20 @@ function roundMoney(value) {
426
521
  return Math.max(0, Number(value.toFixed(2)));
427
522
  }
428
523
  function clampQuantity(quantity) {
429
- if (!Number.isFinite(quantity)) {
430
- return 1;
431
- }
524
+ if (!Number.isFinite(quantity)) return 1;
432
525
  return Math.max(1, Math.floor(quantity));
433
526
  }
434
527
  function normalizeOptionIds(value) {
435
- if (!value || value.length === 0) {
436
- return void 0;
437
- }
528
+ if (!value || value.length === 0) return void 0;
438
529
  const normalized = Array.from(
439
- new Set(
440
- value.map((entry) => entry.trim()).filter((entry) => entry.length > 0)
441
- )
530
+ new Set(value.map((entry) => entry.trim()).filter((entry) => entry.length > 0))
442
531
  ).sort();
443
532
  return normalized.length > 0 ? normalized : void 0;
444
533
  }
445
534
  function buildLineKey(productId, options) {
446
535
  const parts = [productId];
447
- if (options.locationId) {
448
- parts.push(`l:${options.locationId}`);
449
- }
450
- if (options.variantId) {
451
- parts.push(`v:${options.variantId}`);
452
- }
536
+ if (options.locationId) parts.push(`l:${options.locationId}`);
537
+ if (options.variantId) parts.push(`v:${options.variantId}`);
453
538
  const addOnOptionIds = normalizeOptionIds(options.addOnOptionIds);
454
539
  if (addOnOptionIds && addOnOptionIds.length > 0) {
455
540
  parts.push(`a:${addOnOptionIds.join(",")}`);
@@ -460,41 +545,12 @@ function buildLineKey(productId, options) {
460
545
  if (options.compositeSelections && options.compositeSelections.length > 0) {
461
546
  parts.push(`c:${JSON.stringify(options.compositeSelections)}`);
462
547
  }
463
- if (options.quoteId) {
464
- parts.push(`q:${options.quoteId}`);
465
- }
466
- if (options.scheduledStart) {
467
- parts.push(`ss:${options.scheduledStart}`);
468
- }
469
- if (options.staffId) {
470
- parts.push(`st:${options.staffId}`);
471
- }
472
- if (options.resourceId) {
473
- parts.push(`r:${options.resourceId}`);
474
- }
548
+ if (options.quoteId) parts.push(`q:${options.quoteId}`);
549
+ if (options.scheduledStart) parts.push(`ss:${options.scheduledStart}`);
550
+ if (options.staffId) parts.push(`st:${options.staffId}`);
551
+ if (options.resourceId) parts.push(`r:${options.resourceId}`);
475
552
  return parts.join("|");
476
553
  }
477
- function calculateLineSubtotal(item) {
478
- let unitPrice = chunkPEDLCL72_js.parsePrice(item.product.default_price);
479
- if (item.variant?.price_adjustment) {
480
- unitPrice += chunkPEDLCL72_js.parsePrice(item.variant.price_adjustment);
481
- }
482
- for (const option of item.addOnOptions || []) {
483
- if (option.default_price) {
484
- unitPrice += chunkPEDLCL72_js.parsePrice(option.default_price);
485
- }
486
- }
487
- return roundMoney(unitPrice * item.quantity);
488
- }
489
- function calculateSummary(items) {
490
- const subtotal = roundMoney(items.reduce((sum, item) => sum + calculateLineSubtotal(item), 0));
491
- const tax = roundMoney(subtotal * DEFAULT_TAX_RATE);
492
- return {
493
- subtotal,
494
- tax,
495
- total: roundMoney(subtotal + tax)
496
- };
497
- }
498
554
  function lineKeyFromItem(item) {
499
555
  return buildLineKey(item.product.id, {
500
556
  locationId: item.locationId,
@@ -508,13 +564,103 @@ function lineKeyFromItem(item) {
508
564
  });
509
565
  }
510
566
  function attachInternalItemMetadata(item) {
511
- return {
512
- ...item,
513
- _lineKey: lineKeyFromItem(item)
514
- };
567
+ return { ...item, _lineKey: lineKeyFromItem(item) };
568
+ }
569
+ function calculateLineSubtotal(item) {
570
+ let unitPrice = chunkV2O5AO7I_js.parsePrice(item.product.default_price);
571
+ if (item.variant?.price_adjustment) {
572
+ unitPrice += chunkV2O5AO7I_js.parsePrice(item.variant.price_adjustment);
573
+ }
574
+ for (const option of item.addOnOptions || []) {
575
+ if (option.default_price) unitPrice += chunkV2O5AO7I_js.parsePrice(option.default_price);
576
+ }
577
+ return roundMoney(unitPrice * item.quantity);
578
+ }
579
+ function calculateSummary(items) {
580
+ const subtotal = roundMoney(items.reduce((sum, item) => sum + calculateLineSubtotal(item), 0));
581
+ const tax = roundMoney(subtotal * DEFAULT_TAX_RATE);
582
+ return { subtotal, tax, total: roundMoney(subtotal + tax) };
583
+ }
584
+ function applyCartPatch(base, patch) {
585
+ switch (patch.kind) {
586
+ case "add_item": {
587
+ const existingIndex = base.items.findIndex(
588
+ (item) => (item._lineKey ?? lineKeyFromItem(item)) === patch.lineKey
589
+ );
590
+ const nextItems = [...base.items];
591
+ if (existingIndex >= 0) {
592
+ const existing = nextItems[existingIndex];
593
+ nextItems[existingIndex] = {
594
+ ...existing,
595
+ quantity: existing.quantity + patch.tempItem.quantity
596
+ };
597
+ } else {
598
+ nextItems.push(patch.tempItem);
599
+ }
600
+ return { ...base, items: nextItems, ...calculateSummary(nextItems) };
601
+ }
602
+ case "remove_item": {
603
+ const nextItems = base.items.filter((item) => item.id !== patch.itemId);
604
+ return { ...base, items: nextItems, ...calculateSummary(nextItems) };
605
+ }
606
+ case "set_quantity": {
607
+ const resolved = clampQuantity(patch.quantity);
608
+ const nextItems = base.items.map(
609
+ (item) => item.id === patch.itemId ? { ...item, quantity: resolved } : item
610
+ );
611
+ return { ...base, items: nextItems, ...calculateSummary(nextItems) };
612
+ }
613
+ case "clear": {
614
+ return { ...base, items: [], subtotal: 0, tax: 0, total: 0 };
615
+ }
616
+ }
617
+ }
618
+ function useCollectionStore(collection) {
619
+ return React10.useSyncExternalStore(
620
+ (listener) => collection.subscribe(listener),
621
+ () => collection.getSnapshot(),
622
+ () => collection.getSnapshot()
623
+ );
624
+ }
625
+
626
+ // src/react/hooks/use-cart.ts
627
+ var CART_STORAGE_PREFIX = "cimplify:cart:v3";
628
+ var cartStores = /* @__PURE__ */ new Map();
629
+ var ROLLBACK_VISIBLE_DELAY_MS = 3e3;
630
+ function clearAllCartStores() {
631
+ for (const [, entry] of cartStores) {
632
+ entry.collection.setBase(emptyBase(entry.currency));
633
+ for (const handle of entry.failedOpRemovers) {
634
+ clearTimeout(handle);
635
+ }
636
+ entry.failedOpRemovers.clear();
637
+ if (entry.persistTimer) {
638
+ clearTimeout(entry.persistTimer);
639
+ entry.persistTimer = null;
640
+ }
641
+ }
642
+ cartStores.clear();
643
+ }
644
+ function emptyBase(currency, isLoading = true) {
645
+ return { items: [], subtotal: 0, tax: 0, total: 0, currency, isLoading };
646
+ }
647
+ function advanceBaseWithPatch(entry, patch) {
648
+ const current = entry.collection.getBase() ?? emptyBase(entry.currency, false);
649
+ entry.collection.setBase({ ...applyCartPatch(current, patch), isLoading: false });
650
+ persistBase(entry);
651
+ }
652
+ function buildStoreKey(client, locationId, isDemoMode) {
653
+ return [
654
+ client.getPublicKey() || "__demo__",
655
+ locationId || "__no_location__",
656
+ isDemoMode ? "demo" : "live"
657
+ ].join(":");
658
+ }
659
+ function buildStorageKey(storeKey) {
660
+ return `${CART_STORAGE_PREFIX}:${storeKey}`;
515
661
  }
516
662
  function stripInternalItemMetadata(item) {
517
- const { _lineKey, ...rest } = item;
663
+ const { _lineKey, isOptimistic, ...rest } = item;
518
664
  return rest;
519
665
  }
520
666
  function toProductFromServerItem(item, businessId) {
@@ -533,12 +679,10 @@ function toProductFromServerItem(item, businessId) {
533
679
  is_active: item.is_available,
534
680
  created_at: item.created_at,
535
681
  updated_at: item.updated_at,
536
- metadata: {
537
- from_sdk: true
538
- }
682
+ metadata: { from_sdk: true }
539
683
  };
540
684
  }
541
- function mapServerCart(serverCart) {
685
+ function mapServerCart(serverCart, fallbackCurrency) {
542
686
  const items = serverCart.items.map((item) => {
543
687
  const variant = item.variant_info || item.variant_name ? {
544
688
  id: item.variant_info?.id || item.variant_id || "",
@@ -579,207 +723,219 @@ function mapServerCart(serverCart) {
579
723
  subtotal: roundMoney(toNumber(serverCart.pricing.subtotal)),
580
724
  tax: roundMoney(toNumber(serverCart.pricing.tax_amount)),
581
725
  total: roundMoney(toNumber(serverCart.pricing.total_price)),
582
- currency: serverCart.pricing.currency || "USD"
726
+ currency: serverCart.pricing.currency || fallbackCurrency,
727
+ isLoading: false
583
728
  };
584
729
  }
585
- function buildStorageKey(storeKey) {
586
- return `${CART_STORAGE_PREFIX}:${storeKey}`;
587
- }
588
- function createEmptySnapshot(currency) {
730
+ function annotateOptimisticItems(base, ops) {
731
+ if (ops.length === 0) return base;
732
+ const optimisticIds = /* @__PURE__ */ new Set();
733
+ for (const op of ops) {
734
+ if (op.patch.kind === "add_item") {
735
+ optimisticIds.add(op.patch.tempItem.id);
736
+ }
737
+ }
738
+ if (optimisticIds.size === 0) return base;
589
739
  return {
590
- items: [],
591
- subtotal: 0,
592
- tax: 0,
593
- total: 0,
594
- currency,
595
- isLoading: true
740
+ ...base,
741
+ items: base.items.map(
742
+ (item) => optimisticIds.has(item.id) ? { ...item, isOptimistic: true } : item
743
+ )
596
744
  };
597
745
  }
598
- function createCartStore(params) {
599
- const { client, storeKey, locationId, isDemoMode, currency } = params;
600
- const storageKey = buildStorageKey(storeKey);
601
- const listeners = /* @__PURE__ */ new Set();
602
- let snapshot = createEmptySnapshot(currency);
603
- let initialized = false;
604
- let initializePromise = null;
605
- let persistTimer = null;
606
- function emit() {
607
- listeners.forEach((listener) => {
608
- listener();
609
- });
610
- }
611
- function setSnapshot(nextSnapshot) {
612
- snapshot = nextSnapshot;
613
- schedulePersist();
614
- emit();
746
+ function deriveView(base, ops) {
747
+ const start = base ?? emptyBase("USD");
748
+ let folded = start;
749
+ for (const op of ops) {
750
+ folded = applyCartPatch(folded, op.patch);
615
751
  }
616
- function updateSnapshot(updater) {
617
- setSnapshot(updater(snapshot));
618
- }
619
- function persistSnapshot() {
620
- if (typeof window === "undefined" || !window.localStorage) {
621
- return;
622
- }
752
+ folded = annotateOptimisticItems(folded, ops);
753
+ return {
754
+ ...folded,
755
+ isOptimistic: ops.length > 0,
756
+ pendingOpCount: ops.length
757
+ };
758
+ }
759
+ function persistBase(entry) {
760
+ if (typeof window === "undefined" || !window.localStorage) return;
761
+ if (entry.persistTimer) return;
762
+ entry.persistTimer = setTimeout(() => {
763
+ entry.persistTimer = null;
764
+ if (typeof window === "undefined" || !window.localStorage) return;
765
+ const base = entry.collection.getBase();
766
+ if (!base) return;
623
767
  try {
624
768
  window.localStorage.setItem(
625
- storageKey,
769
+ entry.storageKey,
626
770
  JSON.stringify({
627
- items: snapshot.items.map((item) => stripInternalItemMetadata(item)),
628
- subtotal: snapshot.subtotal,
629
- tax: snapshot.tax,
630
- total: snapshot.total,
631
- currency: snapshot.currency
771
+ items: base.items.map((item) => stripInternalItemMetadata(item)),
772
+ subtotal: base.subtotal,
773
+ tax: base.tax,
774
+ total: base.total,
775
+ currency: base.currency
632
776
  })
633
777
  );
634
778
  } catch {
635
779
  }
780
+ }, 100);
781
+ }
782
+ function hydrateFromStorage(entry) {
783
+ if (typeof window === "undefined" || !window.localStorage) return;
784
+ try {
785
+ const raw = window.localStorage.getItem(entry.storageKey);
786
+ if (!raw) return;
787
+ const parsed = JSON.parse(raw);
788
+ if (!parsed || !Array.isArray(parsed.items)) return;
789
+ const items = parsed.items.map((item) => attachInternalItemMetadata(item));
790
+ entry.collection.setBase({
791
+ items,
792
+ subtotal: toNumber(parsed.subtotal),
793
+ tax: toNumber(parsed.tax),
794
+ total: toNumber(parsed.total),
795
+ currency: typeof parsed.currency === "string" && parsed.currency ? parsed.currency : entry.currency,
796
+ isLoading: !entry.isDemoMode
797
+ });
798
+ } catch {
636
799
  }
637
- function schedulePersist() {
638
- if (persistTimer) {
639
- return;
640
- }
641
- persistTimer = setTimeout(() => {
642
- persistTimer = null;
643
- persistSnapshot();
644
- }, 100);
800
+ }
801
+ async function syncFromServer(entry) {
802
+ if (entry.isDemoMode) {
803
+ const base = entry.collection.getBase() ?? emptyBase(entry.currency);
804
+ entry.collection.setBase({ ...base, isLoading: false });
805
+ return;
645
806
  }
646
- function hydrateFromStorage() {
647
- if (typeof window === "undefined" || !window.localStorage) {
648
- return;
649
- }
650
- try {
651
- const raw = window.localStorage.getItem(storageKey);
652
- if (!raw) {
653
- return;
654
- }
655
- const parsed = JSON.parse(raw);
656
- if (!parsed || !Array.isArray(parsed.items)) {
657
- return;
658
- }
659
- snapshot = {
660
- items: parsed.items.map((item) => attachInternalItemMetadata(item)),
661
- subtotal: toNumber(parsed.subtotal),
662
- tax: toNumber(parsed.tax),
663
- total: toNumber(parsed.total),
664
- currency: typeof parsed.currency === "string" && parsed.currency ? parsed.currency : currency,
665
- isLoading: !isDemoMode
666
- };
667
- emit();
668
- } catch {
669
- }
807
+ if (entry.syncing) return;
808
+ entry.syncing = true;
809
+ try {
810
+ const result = await entry.client.cart.get();
811
+ if (!result.ok) throw result.error;
812
+ entry.collection.setBase(mapServerCart(result.value, entry.currency));
813
+ persistBase(entry);
814
+ } finally {
815
+ entry.syncing = false;
816
+ }
817
+ }
818
+ function emitMutationError(entry, operation, opId, idempotencyKey, error) {
819
+ entry.client.events.emit("mutation:error", {
820
+ service: "cart",
821
+ operation,
822
+ opId,
823
+ idempotencyKey,
824
+ error
825
+ });
826
+ }
827
+ function scheduleFailedOpRemoval(entry, opId) {
828
+ const handle = setTimeout(() => {
829
+ entry.failedOpRemovers.delete(handle);
830
+ entry.collection.remove(opId);
831
+ }, ROLLBACK_VISIBLE_DELAY_MS);
832
+ entry.failedOpRemovers.add(handle);
833
+ }
834
+ function getOrCreateStore(params) {
835
+ const { client, locationId, isDemoMode, currency, optimisticEnabled } = params;
836
+ const storeKey = buildStoreKey(client, locationId, isDemoMode);
837
+ const existing = cartStores.get(storeKey);
838
+ if (existing) {
839
+ existing.optimisticEnabled = optimisticEnabled;
840
+ return existing;
670
841
  }
671
- async function sync() {
672
- if (isDemoMode) {
673
- updateSnapshot((current) => ({
674
- ...current,
675
- isLoading: false
676
- }));
677
- return;
678
- }
679
- updateSnapshot((current) => ({
680
- ...current,
681
- isLoading: true
682
- }));
683
- const result = await client.cart.get();
684
- if (!result.ok) {
685
- updateSnapshot((current) => ({
686
- ...current,
687
- isLoading: false
688
- }));
689
- throw result.error;
690
- }
691
- const next = mapServerCart(result.value);
692
- setSnapshot({
693
- ...next,
694
- isLoading: false
695
- });
842
+ const collection = createCollection({
843
+ applyPatch: applyCartPatch,
844
+ toView: (base, ops) => deriveView(base, ops),
845
+ initialBase: emptyBase(currency)
846
+ });
847
+ const entry = {
848
+ collection,
849
+ client,
850
+ storageKey: buildStorageKey(storeKey),
851
+ locationId,
852
+ currency,
853
+ isDemoMode,
854
+ optimisticEnabled,
855
+ initialized: false,
856
+ initializePromise: null,
857
+ persistTimer: null,
858
+ syncing: false,
859
+ failedOpRemovers: /* @__PURE__ */ new Set()
860
+ };
861
+ cartStores.set(storeKey, entry);
862
+ return entry;
863
+ }
864
+ async function ensureInitialized(entry) {
865
+ if (entry.initialized) {
866
+ if (entry.initializePromise) await entry.initializePromise;
867
+ return;
696
868
  }
697
- async function maybeResolveQuoteId(product, quantity, options) {
698
- if (options.quoteId) {
699
- return options.quoteId;
700
- }
701
- const addOnOptionIds = normalizeOptionIds(options.addOnOptionIds);
702
- const requiresQuote = Boolean(
703
- options.variantId || addOnOptionIds && addOnOptionIds.length > 0 || options.bundleSelections && options.bundleSelections.length > 0 || options.compositeSelections && options.compositeSelections.length > 0
704
- );
705
- if (!requiresQuote || isDemoMode) {
706
- return void 0;
707
- }
708
- const quoteResult = await client.catalogue.fetchQuote({
709
- product_id: product.id,
710
- quantity,
711
- location_id: options.locationId || locationId || void 0,
712
- variant_id: options.variantId,
713
- add_on_option_ids: addOnOptionIds,
714
- bundle_selections: options.bundleSelections,
715
- composite_selections: options.compositeSelections
716
- });
717
- if (!quoteResult.ok) {
718
- throw quoteResult.error;
719
- }
720
- return quoteResult.value.quote_id;
869
+ entry.initialized = true;
870
+ hydrateFromStorage(entry);
871
+ if (entry.isDemoMode) {
872
+ const base = entry.collection.getBase() ?? emptyBase(entry.currency);
873
+ entry.collection.setBase({ ...base, isLoading: false });
874
+ return;
721
875
  }
722
- async function addItem(product, quantity = 1, options = {}) {
723
- const resolvedQuantity = clampQuantity(quantity);
724
- const normalizedOptions = {
725
- ...options,
726
- locationId: options.locationId || locationId || void 0,
727
- addOnOptionIds: normalizeOptionIds(options.addOnOptionIds)
728
- };
729
- const maybeProductWithVariants = product;
730
- if (Array.isArray(maybeProductWithVariants.variants) && maybeProductWithVariants.variants.length > 0 && !normalizedOptions.variantId) {
731
- console.warn(
732
- "[Cimplify] addItem() called without variantId for a product that has variants. Default variant pricing will be used."
733
- );
734
- }
735
- const previousSnapshot = snapshot;
736
- const lineKey = buildLineKey(product.id, normalizedOptions);
737
- const optimisticItem = attachInternalItemMetadata({
738
- id: `tmp_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`,
739
- product,
740
- quantity: resolvedQuantity,
741
- locationId: normalizedOptions.locationId,
742
- variantId: normalizedOptions.variantId,
743
- variant: normalizedOptions.variant,
744
- quoteId: normalizedOptions.quoteId,
745
- addOnOptionIds: normalizedOptions.addOnOptionIds,
746
- addOnOptions: normalizedOptions.addOnOptions,
747
- bundleSelections: normalizedOptions.bundleSelections,
748
- compositeSelections: normalizedOptions.compositeSelections,
749
- specialInstructions: normalizedOptions.specialInstructions,
750
- scheduledStart: normalizedOptions.scheduledStart,
751
- scheduledEnd: normalizedOptions.scheduledEnd,
752
- staffId: normalizedOptions.staffId
753
- });
754
- updateSnapshot((current) => {
755
- const existingIndex = current.items.findIndex(
756
- (item) => (item._lineKey ?? lineKeyFromItem(item)) === lineKey
757
- );
758
- const nextItems = [...current.items];
759
- if (existingIndex >= 0) {
760
- const existing = nextItems[existingIndex];
761
- nextItems[existingIndex] = {
762
- ...existing,
763
- quantity: existing.quantity + resolvedQuantity
764
- };
765
- } else {
766
- nextItems.push(optimisticItem);
767
- }
768
- const summary = calculateSummary(nextItems);
769
- return {
770
- ...current,
771
- items: nextItems,
772
- subtotal: summary.subtotal,
773
- tax: summary.tax,
774
- total: summary.total
775
- };
776
- });
777
- if (isDemoMode) {
778
- return;
779
- }
780
- try {
781
- const quoteId = await maybeResolveQuoteId(product, resolvedQuantity, normalizedOptions);
782
- const result = await client.cart.addItem({
876
+ entry.initializePromise = syncFromServer(entry).catch(() => {
877
+ const base = entry.collection.getBase() ?? emptyBase(entry.currency);
878
+ entry.collection.setBase({ ...base, isLoading: false });
879
+ });
880
+ await entry.initializePromise;
881
+ entry.initializePromise = null;
882
+ }
883
+ async function maybeResolveQuoteId(entry, product, quantity, options) {
884
+ if (options.quoteId) return options.quoteId;
885
+ const addOnOptionIds = normalizeOptionIds(options.addOnOptionIds);
886
+ const requiresQuote = Boolean(
887
+ options.variantId || addOnOptionIds && addOnOptionIds.length > 0 || options.bundleSelections && options.bundleSelections.length > 0 || options.compositeSelections && options.compositeSelections.length > 0
888
+ );
889
+ if (!requiresQuote || entry.isDemoMode) return void 0;
890
+ const quoteResult = await entry.client.catalogue.fetchQuote({
891
+ product_id: product.id,
892
+ quantity,
893
+ location_id: options.locationId || entry.locationId || void 0,
894
+ variant_id: options.variantId,
895
+ add_on_option_ids: addOnOptionIds,
896
+ bundle_selections: options.bundleSelections,
897
+ composite_selections: options.compositeSelections
898
+ });
899
+ if (!quoteResult.ok) throw quoteResult.error;
900
+ return quoteResult.value.quote_id;
901
+ }
902
+ async function performAddItem(entry, product, quantity, options) {
903
+ const resolvedQuantity = clampQuantity(quantity);
904
+ const normalizedOptions = {
905
+ ...options,
906
+ locationId: options.locationId || entry.locationId || void 0,
907
+ addOnOptionIds: normalizeOptionIds(options.addOnOptionIds)
908
+ };
909
+ const lineKey = buildLineKey(product.id, normalizedOptions);
910
+ const tempItem = attachInternalItemMetadata({
911
+ id: `tmp_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`,
912
+ product,
913
+ quantity: resolvedQuantity,
914
+ locationId: normalizedOptions.locationId,
915
+ variantId: normalizedOptions.variantId,
916
+ variant: normalizedOptions.variant,
917
+ quoteId: normalizedOptions.quoteId,
918
+ addOnOptionIds: normalizedOptions.addOnOptionIds,
919
+ addOnOptions: normalizedOptions.addOnOptions,
920
+ bundleSelections: normalizedOptions.bundleSelections,
921
+ compositeSelections: normalizedOptions.compositeSelections,
922
+ specialInstructions: normalizedOptions.specialInstructions,
923
+ scheduledStart: normalizedOptions.scheduledStart,
924
+ scheduledEnd: normalizedOptions.scheduledEnd,
925
+ staffId: normalizedOptions.staffId
926
+ });
927
+ const idempotencyKey = `idem_${typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}_${Math.random().toString(36).slice(2, 10)}`}`;
928
+ const patch = { kind: "add_item", tempItem, lineKey };
929
+ if (entry.isDemoMode) {
930
+ advanceBaseWithPatch(entry, patch);
931
+ return;
932
+ }
933
+ const useOptimistic = entry.optimisticEnabled;
934
+ const opId = useOptimistic ? entry.collection.enqueue(patch, idempotencyKey) : null;
935
+ try {
936
+ const quoteId = await maybeResolveQuoteId(entry, product, resolvedQuantity, normalizedOptions);
937
+ const result = await entry.client.cart.addItem(
938
+ {
783
939
  item_id: product.id,
784
940
  quantity: resolvedQuantity,
785
941
  variant_id: normalizedOptions.variantId,
@@ -793,186 +949,103 @@ function createCartStore(params) {
793
949
  staff_id: normalizedOptions.staffId,
794
950
  resource_id: normalizedOptions.resourceId,
795
951
  customer_inputs: normalizedOptions.customerInputs
796
- });
797
- if (!result.ok) {
798
- throw result.error;
799
- }
800
- await sync();
801
- } catch (error) {
802
- snapshot = previousSnapshot;
803
- persistSnapshot();
804
- emit();
805
- throw error;
806
- }
807
- }
808
- async function removeItem(itemId) {
809
- const previousSnapshot = snapshot;
810
- updateSnapshot((current) => {
811
- const nextItems = current.items.filter((item) => item.id !== itemId);
812
- const summary = calculateSummary(nextItems);
813
- return {
814
- ...current,
815
- items: nextItems,
816
- subtotal: summary.subtotal,
817
- tax: summary.tax,
818
- total: summary.total
819
- };
820
- });
821
- if (isDemoMode) {
822
- return;
823
- }
824
- try {
825
- const result = await client.cart.removeItem(itemId);
826
- if (!result.ok) {
827
- throw result.error;
828
- }
829
- await sync();
830
- } catch (error) {
831
- snapshot = previousSnapshot;
832
- persistSnapshot();
833
- emit();
834
- throw error;
835
- }
952
+ },
953
+ { idempotencyKey }
954
+ );
955
+ if (!result.ok) throw result.error;
956
+ await syncFromServer(entry);
957
+ if (opId) entry.collection.confirm(opId);
958
+ } catch (error) {
959
+ const cimplifyError = error;
960
+ if (opId) {
961
+ entry.collection.fail(opId, cimplifyError);
962
+ emitMutationError(entry, "add_item", opId, idempotencyKey, cimplifyError);
963
+ scheduleFailedOpRemoval(entry, opId);
964
+ }
965
+ throw cimplifyError;
966
+ }
967
+ }
968
+ async function performRemoveItem(entry, itemId) {
969
+ const idempotencyKey = "";
970
+ const patch = { kind: "remove_item", itemId };
971
+ if (entry.isDemoMode) {
972
+ advanceBaseWithPatch(entry, patch);
973
+ return;
836
974
  }
837
- async function updateQuantity(itemId, quantity) {
838
- if (quantity <= 0) {
839
- await removeItem(itemId);
840
- return;
841
- }
842
- const resolvedQuantity = clampQuantity(quantity);
843
- const previousSnapshot = snapshot;
844
- updateSnapshot((current) => {
845
- const nextItems = current.items.map(
846
- (item) => item.id === itemId ? {
847
- ...item,
848
- quantity: resolvedQuantity
849
- } : item
850
- );
851
- const summary = calculateSummary(nextItems);
852
- return {
853
- ...current,
854
- items: nextItems,
855
- subtotal: summary.subtotal,
856
- tax: summary.tax,
857
- total: summary.total
858
- };
859
- });
860
- if (isDemoMode) {
861
- return;
862
- }
863
- try {
864
- const result = await client.cart.updateQuantity(itemId, resolvedQuantity);
865
- if (!result.ok) {
866
- throw result.error;
867
- }
868
- await sync();
869
- } catch (error) {
870
- snapshot = previousSnapshot;
871
- persistSnapshot();
872
- emit();
873
- throw error;
874
- }
875
- }
876
- async function clearCart() {
877
- const previousSnapshot = snapshot;
878
- updateSnapshot((current) => ({
879
- ...current,
880
- items: [],
881
- subtotal: 0,
882
- tax: 0,
883
- total: 0
884
- }));
885
- if (isDemoMode) {
886
- return;
887
- }
888
- try {
889
- const result = await client.cart.clear();
890
- if (!result.ok) {
891
- throw result.error;
892
- }
893
- await sync();
894
- } catch (error) {
895
- snapshot = previousSnapshot;
896
- persistSnapshot();
897
- emit();
898
- throw error;
899
- }
975
+ const useOptimistic = entry.optimisticEnabled;
976
+ const opId = useOptimistic ? entry.collection.enqueue(patch, idempotencyKey) : null;
977
+ try {
978
+ const result = await entry.client.cart.removeItem(itemId);
979
+ if (!result.ok) throw result.error;
980
+ await syncFromServer(entry);
981
+ if (opId) entry.collection.confirm(opId);
982
+ } catch (error) {
983
+ const cimplifyError = error;
984
+ if (opId) {
985
+ entry.collection.fail(opId, cimplifyError);
986
+ emitMutationError(entry, "remove_item", opId, idempotencyKey, cimplifyError);
987
+ scheduleFailedOpRemoval(entry, opId);
988
+ }
989
+ throw cimplifyError;
990
+ }
991
+ }
992
+ async function performUpdateQuantity(entry, itemId, quantity) {
993
+ if (quantity <= 0) {
994
+ return performRemoveItem(entry, itemId);
995
+ }
996
+ const resolved = clampQuantity(quantity);
997
+ const idempotencyKey = "";
998
+ const patch = { kind: "set_quantity", itemId, quantity: resolved };
999
+ if (entry.isDemoMode) {
1000
+ advanceBaseWithPatch(entry, patch);
1001
+ return;
900
1002
  }
901
- async function initialize() {
902
- if (initialized) {
903
- if (initializePromise) {
904
- await initializePromise;
905
- }
906
- return;
907
- }
908
- initialized = true;
909
- hydrateFromStorage();
910
- if (isDemoMode) {
911
- updateSnapshot((current) => ({
912
- ...current,
913
- isLoading: false
914
- }));
915
- return;
916
- }
917
- initializePromise = sync().catch(() => {
918
- updateSnapshot((current) => ({
919
- ...current,
920
- isLoading: false
921
- }));
922
- });
923
- await initializePromise;
924
- initializePromise = null;
1003
+ const useOptimistic = entry.optimisticEnabled;
1004
+ const opId = useOptimistic ? entry.collection.enqueue(patch, idempotencyKey) : null;
1005
+ try {
1006
+ const result = await entry.client.cart.updateQuantity(itemId, resolved);
1007
+ if (!result.ok) throw result.error;
1008
+ await syncFromServer(entry);
1009
+ if (opId) entry.collection.confirm(opId);
1010
+ } catch (error) {
1011
+ const cimplifyError = error;
1012
+ if (opId) {
1013
+ entry.collection.fail(opId, cimplifyError);
1014
+ emitMutationError(entry, "update_quantity", opId, idempotencyKey, cimplifyError);
1015
+ scheduleFailedOpRemoval(entry, opId);
1016
+ }
1017
+ throw cimplifyError;
1018
+ }
1019
+ }
1020
+ async function performClear(entry) {
1021
+ const idempotencyKey = "";
1022
+ const patch = { kind: "clear" };
1023
+ if (entry.isDemoMode) {
1024
+ advanceBaseWithPatch(entry, patch);
1025
+ return;
925
1026
  }
926
- async function reorder(orderId) {
927
- const result = await client.cart.reorderFromOrder(orderId);
928
- if (!result.ok) {
929
- throw result.error;
1027
+ const useOptimistic = entry.optimisticEnabled;
1028
+ const opId = useOptimistic ? entry.collection.enqueue(patch, idempotencyKey) : null;
1029
+ try {
1030
+ const result = await entry.client.cart.clear();
1031
+ if (!result.ok) throw result.error;
1032
+ await syncFromServer(entry);
1033
+ if (opId) entry.collection.confirm(opId);
1034
+ } catch (error) {
1035
+ const cimplifyError = error;
1036
+ if (opId) {
1037
+ entry.collection.fail(opId, cimplifyError);
1038
+ emitMutationError(entry, "clear", opId, idempotencyKey, cimplifyError);
1039
+ scheduleFailedOpRemoval(entry, opId);
930
1040
  }
931
- await sync();
932
- return result.value;
1041
+ throw cimplifyError;
933
1042
  }
934
- return {
935
- subscribe(listener) {
936
- listeners.add(listener);
937
- return () => {
938
- listeners.delete(listener);
939
- };
940
- },
941
- getSnapshot() {
942
- return snapshot;
943
- },
944
- initialize,
945
- addItem,
946
- removeItem,
947
- updateQuantity,
948
- clearCart,
949
- sync,
950
- reorder
951
- };
952
- }
953
- function getStoreKey(client, locationId, isDemoMode) {
954
- return [
955
- client.getPublicKey() || "__demo__",
956
- locationId || "__no_location__",
957
- isDemoMode ? "demo" : "live"
958
- ].join(":");
959
1043
  }
960
- function getOrCreateStore(params) {
961
- const { client, locationId, isDemoMode, currency } = params;
962
- const storeKey = getStoreKey(client, locationId, isDemoMode);
963
- const existing = cartStores.get(storeKey);
964
- if (existing) {
965
- return existing;
966
- }
967
- const created = createCartStore({
968
- client,
969
- storeKey,
970
- locationId,
971
- isDemoMode,
972
- currency
973
- });
974
- cartStores.set(storeKey, created);
975
- return created;
1044
+ async function performReorder(entry, orderId) {
1045
+ const result = await entry.client.cart.reorderFromOrder(orderId);
1046
+ if (!result.ok) throw result.error;
1047
+ await syncFromServer(entry);
1048
+ return result.value;
976
1049
  }
977
1050
  function useCart(options = {}) {
978
1051
  const context = useOptionalCimplifyClient();
@@ -983,77 +1056,92 @@ function useCart(options = {}) {
983
1056
  const locationId = options.locationId ?? client.getLocationId();
984
1057
  const isDemoMode = options.demoMode ?? context?.isDemoMode ?? client.getPublicKey().trim().length === 0;
985
1058
  const currency = options.currency ?? context?.currency ?? "USD";
986
- const store = React10.useMemo(
1059
+ const optimisticEnabled = context?.optimistic ?? true;
1060
+ const entry = React10.useMemo(
987
1061
  () => getOrCreateStore({
988
1062
  client,
989
1063
  locationId,
990
1064
  isDemoMode,
991
- currency
1065
+ currency,
1066
+ optimisticEnabled
992
1067
  }),
993
- [client, currency, isDemoMode, locationId]
994
- );
995
- const snapshot = React10.useSyncExternalStore(
996
- store.subscribe,
997
- store.getSnapshot,
998
- store.getSnapshot
1068
+ [client, currency, isDemoMode, locationId, optimisticEnabled]
999
1069
  );
1070
+ const view = useCollectionStore(entry.collection);
1000
1071
  React10.useEffect(() => {
1001
- void store.initialize();
1002
- }, [store]);
1072
+ void ensureInitialized(entry);
1073
+ }, [entry]);
1003
1074
  const addItem = React10.useCallback(
1004
1075
  async (product, quantity, addOptions) => {
1005
- await store.addItem(product, quantity, addOptions);
1076
+ await performAddItem(entry, product, quantity ?? 1, addOptions ?? {});
1006
1077
  },
1007
- [store]
1078
+ [entry]
1008
1079
  );
1009
1080
  const removeItem = React10.useCallback(
1010
1081
  async (itemId) => {
1011
- await store.removeItem(itemId);
1082
+ await performRemoveItem(entry, itemId);
1012
1083
  },
1013
- [store]
1084
+ [entry]
1014
1085
  );
1015
1086
  const updateQuantity = React10.useCallback(
1016
1087
  async (itemId, quantity) => {
1017
- await store.updateQuantity(itemId, quantity);
1088
+ await performUpdateQuantity(entry, itemId, quantity);
1018
1089
  },
1019
- [store]
1090
+ [entry]
1020
1091
  );
1021
1092
  const clearCart = React10.useCallback(async () => {
1022
- await store.clearCart();
1023
- }, [store]);
1093
+ await performClear(entry);
1094
+ }, [entry]);
1024
1095
  const sync = React10.useCallback(async () => {
1025
- try {
1026
- await store.sync();
1027
- } catch (syncError) {
1028
- throw syncError;
1029
- }
1030
- }, [store]);
1096
+ await syncFromServer(entry);
1097
+ }, [entry]);
1031
1098
  const reorder = React10.useCallback(
1032
1099
  async (orderId) => {
1033
- return store.reorder(orderId);
1100
+ return performReorder(entry, orderId);
1034
1101
  },
1035
- [store]
1102
+ [entry]
1036
1103
  );
1037
1104
  const itemCount = React10.useMemo(
1038
- () => snapshot.items.reduce((sum, item) => sum + item.quantity, 0),
1039
- [snapshot.items]
1105
+ () => view.items.reduce((sum, item) => sum + item.quantity, 0),
1106
+ [view.items]
1107
+ );
1108
+ return React10.useMemo(
1109
+ () => ({
1110
+ items: view.items,
1111
+ itemCount,
1112
+ subtotal: view.subtotal,
1113
+ tax: view.tax,
1114
+ total: view.total,
1115
+ currency: view.currency,
1116
+ isEmpty: itemCount === 0,
1117
+ isLoading: view.isLoading,
1118
+ isOptimistic: view.isOptimistic,
1119
+ pendingOpCount: view.pendingOpCount,
1120
+ addItem,
1121
+ removeItem,
1122
+ updateQuantity,
1123
+ clearCart,
1124
+ sync,
1125
+ reorder
1126
+ }),
1127
+ [
1128
+ view.items,
1129
+ itemCount,
1130
+ view.subtotal,
1131
+ view.tax,
1132
+ view.total,
1133
+ view.currency,
1134
+ view.isLoading,
1135
+ view.isOptimistic,
1136
+ view.pendingOpCount,
1137
+ addItem,
1138
+ removeItem,
1139
+ updateQuantity,
1140
+ clearCart,
1141
+ sync,
1142
+ reorder
1143
+ ]
1040
1144
  );
1041
- return React10.useMemo(() => ({
1042
- items: snapshot.items,
1043
- itemCount,
1044
- subtotal: snapshot.subtotal,
1045
- tax: snapshot.tax,
1046
- total: snapshot.total,
1047
- currency: snapshot.currency,
1048
- isEmpty: itemCount === 0,
1049
- isLoading: snapshot.isLoading,
1050
- addItem,
1051
- removeItem,
1052
- updateQuantity,
1053
- clearCart,
1054
- sync,
1055
- reorder
1056
- }), [snapshot.items, itemCount, snapshot.subtotal, snapshot.tax, snapshot.total, snapshot.currency, snapshot.isLoading, addItem, removeItem, updateQuantity, clearCart, sync, reorder]);
1057
1145
  }
1058
1146
  var LOCATION_STORAGE_KEY = "cimplify_location_id";
1059
1147
  var DISPLAY_CURRENCY_STORAGE_KEY = "cimplify_display_currency";
@@ -1063,7 +1151,7 @@ var DEFAULT_COUNTRY = "US";
1063
1151
  function createDefaultClient() {
1064
1152
  const processRef = globalThis.process;
1065
1153
  const envPublicKey = processRef?.env?.NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY || "";
1066
- return chunk6HCBOIZ4_js.createCimplifyClient({ publicKey: envPublicKey });
1154
+ return chunkZYACIPKO_js.createCimplifyClient({ publicKey: envPublicKey });
1067
1155
  }
1068
1156
  function getStoredLocationId() {
1069
1157
  if (typeof window === "undefined" || !window.localStorage) {
@@ -1125,7 +1213,8 @@ var CimplifyStateContext = React10.createContext(null);
1125
1213
  function CimplifyProvider({
1126
1214
  client,
1127
1215
  children,
1128
- onLocationChange
1216
+ onLocationChange,
1217
+ optimistic = true
1129
1218
  }) {
1130
1219
  const resolvedClient = React10.useMemo(() => client ?? createDefaultClient(), [client]);
1131
1220
  const onLocationChangeRef = React10.useRef(onLocationChange);
@@ -1146,7 +1235,7 @@ function CimplifyProvider({
1146
1235
  const setDisplayCurrency = React10.useCallback(
1147
1236
  (currency) => {
1148
1237
  const normalized = currency?.trim().toUpperCase() || null;
1149
- if (normalized && !chunkPEDLCL72_js.isSupportedCurrency(normalized)) {
1238
+ if (normalized && !chunkV2O5AO7I_js.isSupportedCurrency(normalized)) {
1150
1239
  return;
1151
1240
  }
1152
1241
  setDisplayCurrencyOverride(normalized);
@@ -1269,7 +1358,8 @@ function CimplifyProvider({
1269
1358
  locations,
1270
1359
  isReady,
1271
1360
  isDemoMode,
1272
- baseCurrency
1361
+ baseCurrency,
1362
+ optimistic
1273
1363
  }),
1274
1364
  [
1275
1365
  resolvedClient,
@@ -1277,7 +1367,8 @@ function CimplifyProvider({
1277
1367
  baseCurrency,
1278
1368
  locations,
1279
1369
  isReady,
1280
- isDemoMode
1370
+ isDemoMode,
1371
+ optimistic
1281
1372
  ]
1282
1373
  );
1283
1374
  const stateContextValue = React10.useMemo(
@@ -1806,7 +1897,7 @@ function Price({ amount, currency, className, prefix }) {
1806
1897
  const resolvedAmount = typeof convertedAmount === "string" ? parseFloat(convertedAmount) || 0 : convertedAmount;
1807
1898
  return /* @__PURE__ */ jsxRuntime.jsxs("span", { className, children: [
1808
1899
  prefix,
1809
- chunkPEDLCL72_js.formatPrice(resolvedAmount, resolvedCurrency)
1900
+ chunkV2O5AO7I_js.formatPrice(resolvedAmount, resolvedCurrency)
1810
1901
  ] });
1811
1902
  }
1812
1903
  function createCachedQuery(config) {
@@ -2813,16 +2904,16 @@ function useProductPrice(input) {
2813
2904
  if (bundleTotalPrice != null) {
2814
2905
  unitPrice = bundleTotalPrice;
2815
2906
  } else if (compositePrice) {
2816
- unitPrice = chunkPEDLCL72_js.parsePrice(compositePrice.final_price);
2907
+ unitPrice = chunkV2O5AO7I_js.parsePrice(compositePrice.final_price);
2817
2908
  } else {
2818
- unitPrice = chunkPEDLCL72_js.parsePrice(product.default_price);
2909
+ unitPrice = chunkV2O5AO7I_js.parsePrice(product.default_price);
2819
2910
  if (variant?.price_adjustment) {
2820
- unitPrice += chunkPEDLCL72_js.parsePrice(variant.price_adjustment);
2911
+ unitPrice += chunkV2O5AO7I_js.parsePrice(variant.price_adjustment);
2821
2912
  }
2822
2913
  if (addOnOptions) {
2823
2914
  for (const option of addOnOptions) {
2824
2915
  if (option.default_price) {
2825
- unitPrice += chunkPEDLCL72_js.parsePrice(option.default_price);
2916
+ unitPrice += chunkV2O5AO7I_js.parsePrice(option.default_price);
2826
2917
  }
2827
2918
  }
2828
2919
  }
@@ -3566,19 +3657,19 @@ function AuthElement({
3566
3657
  }, [onReady, onAuthenticated, onRequiresOtp, onError]);
3567
3658
  React10.useEffect(() => {
3568
3659
  if (!elements || !containerRef.current) return;
3569
- const element = elements.create(chunk2CGA3MUW_js.ELEMENT_TYPES.AUTH, { prefillEmail });
3660
+ const element = elements.create(chunkHKVRUGM6_js.ELEMENT_TYPES.AUTH, { prefillEmail });
3570
3661
  elementRef.current = element;
3571
- element.on(chunk2CGA3MUW_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
3662
+ element.on(chunkHKVRUGM6_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
3572
3663
  element.on(
3573
- chunk2CGA3MUW_js.EVENT_TYPES.AUTHENTICATED,
3664
+ chunkHKVRUGM6_js.EVENT_TYPES.AUTHENTICATED,
3574
3665
  (data) => onAuthenticatedRef.current?.(data)
3575
3666
  );
3576
3667
  element.on(
3577
- chunk2CGA3MUW_js.EVENT_TYPES.REQUIRES_OTP,
3668
+ chunkHKVRUGM6_js.EVENT_TYPES.REQUIRES_OTP,
3578
3669
  (data) => onRequiresOtpRef.current?.(data)
3579
3670
  );
3580
3671
  element.on(
3581
- chunk2CGA3MUW_js.EVENT_TYPES.ERROR,
3672
+ chunkHKVRUGM6_js.EVENT_TYPES.ERROR,
3582
3673
  (data) => onErrorRef.current?.(data)
3583
3674
  );
3584
3675
  element.mount(containerRef.current);
@@ -3607,15 +3698,15 @@ function AddressElement({
3607
3698
  }, [onReady, onChange, onError]);
3608
3699
  React10.useEffect(() => {
3609
3700
  if (!elements || !containerRef.current) return;
3610
- const element = elements.create(chunk2CGA3MUW_js.ELEMENT_TYPES.ADDRESS, { mode });
3701
+ const element = elements.create(chunkHKVRUGM6_js.ELEMENT_TYPES.ADDRESS, { mode });
3611
3702
  elementRef.current = element;
3612
- element.on(chunk2CGA3MUW_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
3703
+ element.on(chunkHKVRUGM6_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
3613
3704
  element.on(
3614
- chunk2CGA3MUW_js.EVENT_TYPES.CHANGE,
3705
+ chunkHKVRUGM6_js.EVENT_TYPES.CHANGE,
3615
3706
  (data) => onChangeRef.current?.(data)
3616
3707
  );
3617
3708
  element.on(
3618
- chunk2CGA3MUW_js.EVENT_TYPES.ERROR,
3709
+ chunkHKVRUGM6_js.EVENT_TYPES.ERROR,
3619
3710
  (data) => onErrorRef.current?.(data)
3620
3711
  );
3621
3712
  element.mount(containerRef.current);
@@ -3645,15 +3736,15 @@ function PaymentElement({
3645
3736
  }, [onReady, onChange, onError]);
3646
3737
  React10.useEffect(() => {
3647
3738
  if (!elements || !containerRef.current) return;
3648
- const element = elements.create(chunk2CGA3MUW_js.ELEMENT_TYPES.PAYMENT, { amount, currency });
3739
+ const element = elements.create(chunkHKVRUGM6_js.ELEMENT_TYPES.PAYMENT, { amount, currency });
3649
3740
  elementRef.current = element;
3650
- element.on(chunk2CGA3MUW_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
3741
+ element.on(chunkHKVRUGM6_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
3651
3742
  element.on(
3652
- chunk2CGA3MUW_js.EVENT_TYPES.CHANGE,
3743
+ chunkHKVRUGM6_js.EVENT_TYPES.CHANGE,
3653
3744
  (data) => onChangeRef.current?.(data)
3654
3745
  );
3655
3746
  element.on(
3656
- chunk2CGA3MUW_js.EVENT_TYPES.ERROR,
3747
+ chunkHKVRUGM6_js.EVENT_TYPES.ERROR,
3657
3748
  (data) => onErrorRef.current?.(data)
3658
3749
  );
3659
3750
  element.mount(containerRef.current);
@@ -3809,7 +3900,7 @@ function VariantSelector({
3809
3900
  if (!variants || variants.length <= 1) {
3810
3901
  return null;
3811
3902
  }
3812
- basePrice != null ? chunkPEDLCL72_js.parsePrice(basePrice) : 0;
3903
+ basePrice != null ? chunkV2O5AO7I_js.parsePrice(basePrice) : 0;
3813
3904
  if (variantAxes && variantAxes.length > 0) {
3814
3905
  return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-variant-selector": true, className: cn("space-y-5", className, classNames?.root), children: variantAxes.map((axis) => {
3815
3906
  const labelId = `${idPrefix}-axis-${axis.id}`;
@@ -3885,7 +3976,7 @@ function VariantSelector({
3885
3976
  className: cn("divide-y divide-border", classNames?.list),
3886
3977
  children: variants.map((variant) => {
3887
3978
  const isSelected = selectedVariantId === variant.id;
3888
- const adjustment = chunkPEDLCL72_js.parsePrice(variant.price_adjustment);
3979
+ const adjustment = chunkV2O5AO7I_js.parsePrice(variant.price_adjustment);
3889
3980
  return /* @__PURE__ */ jsxRuntime.jsxs(
3890
3981
  radio.Radio.Root,
3891
3982
  {
@@ -3913,7 +4004,7 @@ function VariantSelector({
3913
4004
  {
3914
4005
  "data-cimplify-variant-name": true,
3915
4006
  className: cn("flex-1 min-w-0 text-sm", classNames?.name),
3916
- children: chunk6HCBOIZ4_js.getVariantDisplayName(variant, productName)
4007
+ children: chunkZYACIPKO_js.getVariantDisplayName(variant, productName)
3917
4008
  }
3918
4009
  ),
3919
4010
  /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-variant-pricing": true, className: cn("text-sm text-muted-foreground", classNames?.pricing), children: [
@@ -4151,16 +4242,16 @@ function BundleSelector({
4151
4242
  }, [components, selections, onReady]);
4152
4243
  const totalPrice = React10.useMemo(() => {
4153
4244
  if (pricingType === "fixed" && bundlePrice) {
4154
- return chunkPEDLCL72_js.parsePrice(bundlePrice);
4245
+ return chunkV2O5AO7I_js.parsePrice(bundlePrice);
4155
4246
  }
4156
4247
  const componentsTotal = components.reduce((sum, comp) => {
4157
4248
  return sum + getComponentPrice(comp, variantChoices[comp.id]) * comp.quantity;
4158
4249
  }, 0);
4159
4250
  if (pricingType === "percentage_discount" && discountValue) {
4160
- return componentsTotal * (1 - chunkPEDLCL72_js.parsePrice(discountValue) / 100);
4251
+ return componentsTotal * (1 - chunkV2O5AO7I_js.parsePrice(discountValue) / 100);
4161
4252
  }
4162
4253
  if (pricingType === "fixed_discount" && discountValue) {
4163
- return componentsTotal - chunkPEDLCL72_js.parsePrice(discountValue);
4254
+ return componentsTotal - chunkV2O5AO7I_js.parsePrice(discountValue);
4164
4255
  }
4165
4256
  return componentsTotal;
4166
4257
  }, [components, variantChoices, pricingType, bundlePrice, discountValue]);
@@ -4221,15 +4312,15 @@ function BundleSelector({
4221
4312
  }
4222
4313
  function getComponentPrice(component, selectedVariantId) {
4223
4314
  if (!selectedVariantId || component.available_variants.length === 0) {
4224
- return chunkPEDLCL72_js.parsePrice(component.effective_price);
4315
+ return chunkV2O5AO7I_js.parsePrice(component.effective_price);
4225
4316
  }
4226
4317
  if (selectedVariantId === component.variant_id) {
4227
- return chunkPEDLCL72_js.parsePrice(component.effective_price);
4318
+ return chunkV2O5AO7I_js.parsePrice(component.effective_price);
4228
4319
  }
4229
4320
  const bakedAdj = component.variant_id ? component.available_variants.find((v) => v.id === component.variant_id) : void 0;
4230
4321
  const selectedAdj = component.available_variants.find((v) => v.id === selectedVariantId);
4231
- if (!selectedAdj) return chunkPEDLCL72_js.parsePrice(component.effective_price);
4232
- return chunkPEDLCL72_js.parsePrice(component.effective_price) - chunkPEDLCL72_js.parsePrice(bakedAdj?.price_adjustment ?? "0") + chunkPEDLCL72_js.parsePrice(selectedAdj.price_adjustment);
4322
+ if (!selectedAdj) return chunkV2O5AO7I_js.parsePrice(component.effective_price);
4323
+ return chunkV2O5AO7I_js.parsePrice(component.effective_price) - chunkV2O5AO7I_js.parsePrice(bakedAdj?.price_adjustment ?? "0") + chunkV2O5AO7I_js.parsePrice(selectedAdj.price_adjustment);
4233
4324
  }
4234
4325
  function formatDuration(minutes, unit) {
4235
4326
  if (unit === "hours" || !unit && minutes >= 60 && minutes % 60 === 0) {
@@ -4342,7 +4433,7 @@ function BundleComponentCard({
4342
4433
  className: cn("mt-3 divide-y divide-border", classNames?.variantPicker),
4343
4434
  children: component.available_variants.map((variant) => {
4344
4435
  const isSelected = selectedVariantId === variant.id;
4345
- const adjustment = chunkPEDLCL72_js.parsePrice(variant.price_adjustment);
4436
+ const adjustment = chunkV2O5AO7I_js.parsePrice(variant.price_adjustment);
4346
4437
  return /* @__PURE__ */ jsxRuntime.jsxs(
4347
4438
  radio.Radio.Root,
4348
4439
  {
@@ -4788,7 +4879,7 @@ function CompositeSelector({
4788
4879
  "data-cimplify-composite-summary": true,
4789
4880
  className: cn("border-t border-border pt-4 space-y-1 text-sm", classNames?.summary),
4790
4881
  children: [
4791
- chunkPEDLCL72_js.parsePrice(priceResult.base_price) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(
4882
+ chunkV2O5AO7I_js.parsePrice(priceResult.base_price) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(
4792
4883
  "div",
4793
4884
  {
4794
4885
  "data-cimplify-composite-summary-line": true,
@@ -4799,7 +4890,7 @@ function CompositeSelector({
4799
4890
  ]
4800
4891
  }
4801
4892
  ),
4802
- chunkPEDLCL72_js.parsePrice(priceResult.components_total) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(
4893
+ chunkV2O5AO7I_js.parsePrice(priceResult.components_total) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(
4803
4894
  "div",
4804
4895
  {
4805
4896
  "data-cimplify-composite-summary-line": true,
@@ -5095,7 +5186,7 @@ function InputField({
5095
5186
  onFileUpload,
5096
5187
  classNames
5097
5188
  }) {
5098
- const hasPriceAdjustment = field.price_adjustment != null && chunkPEDLCL72_js.parsePrice(field.price_adjustment) > 0;
5189
+ const hasPriceAdjustment = field.price_adjustment != null && chunkV2O5AO7I_js.parsePrice(field.price_adjustment) > 0;
5099
5190
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-customer-input": true, "data-field-type": field.field_type, className: classNames?.field, children: [
5100
5191
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mb-1.5", children: [
5101
5192
  /* @__PURE__ */ jsxRuntime.jsx("label", { className: cn("text-sm font-semibold", classNames?.label), children: field.name }),
@@ -5130,12 +5221,12 @@ function FieldInput({
5130
5221
  classNames?.input
5131
5222
  );
5132
5223
  switch (field.field_type) {
5133
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Text:
5134
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Url:
5224
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Text:
5225
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Url:
5135
5226
  return /* @__PURE__ */ jsxRuntime.jsx(
5136
5227
  "input",
5137
5228
  {
5138
- type: field.field_type === chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Url ? "url" : "text",
5229
+ type: field.field_type === chunkZYACIPKO_js.INPUT_FIELD_TYPE.Url ? "url" : "text",
5139
5230
  value: typeof value === "string" ? value : "",
5140
5231
  onChange: (e) => onValueChange(e.target.value),
5141
5232
  placeholder: field.placeholder,
@@ -5144,7 +5235,7 @@ function FieldInput({
5144
5235
  className: inputClass
5145
5236
  }
5146
5237
  );
5147
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Textarea:
5238
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Textarea:
5148
5239
  return /* @__PURE__ */ jsxRuntime.jsx(
5149
5240
  "textarea",
5150
5241
  {
@@ -5157,7 +5248,7 @@ function FieldInput({
5157
5248
  className: cn(inputClass, "resize-none", classNames?.textarea)
5158
5249
  }
5159
5250
  );
5160
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Number:
5251
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Number:
5161
5252
  return /* @__PURE__ */ jsxRuntime.jsx(
5162
5253
  "input",
5163
5254
  {
@@ -5171,7 +5262,7 @@ function FieldInput({
5171
5262
  className: inputClass
5172
5263
  }
5173
5264
  );
5174
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Select:
5265
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Select:
5175
5266
  return /* @__PURE__ */ jsxRuntime.jsxs(
5176
5267
  "select",
5177
5268
  {
@@ -5185,7 +5276,7 @@ function FieldInput({
5185
5276
  ]
5186
5277
  }
5187
5278
  );
5188
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Radio:
5279
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Radio:
5189
5280
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("space-y-2", classNames?.radioGroup), children: (field.options || []).map((opt) => /* @__PURE__ */ jsxRuntime.jsxs(
5190
5281
  "label",
5191
5282
  {
@@ -5210,7 +5301,7 @@ function FieldInput({
5210
5301
  },
5211
5302
  opt
5212
5303
  )) });
5213
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Checkbox:
5304
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Checkbox:
5214
5305
  return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: cn("flex items-center gap-2 text-sm cursor-pointer", classNames?.checkboxLabel), children: [
5215
5306
  /* @__PURE__ */ jsxRuntime.jsx(
5216
5307
  "input",
@@ -5223,7 +5314,7 @@ function FieldInput({
5223
5314
  ),
5224
5315
  field.placeholder || field.name
5225
5316
  ] });
5226
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Color:
5317
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Color:
5227
5318
  return /* @__PURE__ */ jsxRuntime.jsx(
5228
5319
  "input",
5229
5320
  {
@@ -5233,7 +5324,7 @@ function FieldInput({
5233
5324
  className: cn("w-12 h-10 rounded-md border border-input cursor-pointer", classNames?.colorInput)
5234
5325
  }
5235
5326
  );
5236
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Date:
5327
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Date:
5237
5328
  return /* @__PURE__ */ jsxRuntime.jsx(
5238
5329
  "input",
5239
5330
  {
@@ -5244,8 +5335,8 @@ function FieldInput({
5244
5335
  className: inputClass
5245
5336
  }
5246
5337
  );
5247
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.File:
5248
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Image:
5338
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.File:
5339
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Image:
5249
5340
  return /* @__PURE__ */ jsxRuntime.jsx(
5250
5341
  FileUploadInput,
5251
5342
  {
@@ -5256,7 +5347,7 @@ function FieldInput({
5256
5347
  classNames
5257
5348
  }
5258
5349
  );
5259
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Email:
5350
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Email:
5260
5351
  return /* @__PURE__ */ jsxRuntime.jsx(
5261
5352
  "input",
5262
5353
  {
@@ -5268,7 +5359,7 @@ function FieldInput({
5268
5359
  className: inputClass
5269
5360
  }
5270
5361
  );
5271
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.DateTime: {
5362
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.DateTime: {
5272
5363
  const dtLocalValue = typeof value === "string" && value.includes("T") ? value.slice(0, 16) : typeof value === "string" ? value : "";
5273
5364
  return /* @__PURE__ */ jsxRuntime.jsx(
5274
5365
  "input",
@@ -5288,7 +5379,7 @@ function FieldInput({
5288
5379
  }
5289
5380
  );
5290
5381
  }
5291
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Time:
5382
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Time:
5292
5383
  return /* @__PURE__ */ jsxRuntime.jsx(
5293
5384
  "input",
5294
5385
  {
@@ -5299,7 +5390,7 @@ function FieldInput({
5299
5390
  className: inputClass
5300
5391
  }
5301
5392
  );
5302
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.MultiSelect:
5393
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.MultiSelect:
5303
5394
  return /* @__PURE__ */ jsxRuntime.jsx(
5304
5395
  MultiSelectInput,
5305
5396
  {
@@ -5309,7 +5400,7 @@ function FieldInput({
5309
5400
  classNames
5310
5401
  }
5311
5402
  );
5312
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.DateRange:
5403
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.DateRange:
5313
5404
  return /* @__PURE__ */ jsxRuntime.jsx(
5314
5405
  DateRangeInput,
5315
5406
  {
@@ -5320,7 +5411,7 @@ function FieldInput({
5320
5411
  inputClass
5321
5412
  }
5322
5413
  );
5323
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Address:
5414
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Address:
5324
5415
  return /* @__PURE__ */ jsxRuntime.jsx(
5325
5416
  AddressInput,
5326
5417
  {
@@ -5331,7 +5422,7 @@ function FieldInput({
5331
5422
  inputClass
5332
5423
  }
5333
5424
  );
5334
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Location:
5425
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Location:
5335
5426
  return /* @__PURE__ */ jsxRuntime.jsx(
5336
5427
  LocationInput,
5337
5428
  {
@@ -5342,7 +5433,7 @@ function FieldInput({
5342
5433
  inputClass
5343
5434
  }
5344
5435
  );
5345
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Phone:
5436
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Phone:
5346
5437
  return /* @__PURE__ */ jsxRuntime.jsx(
5347
5438
  PhoneInput,
5348
5439
  {
@@ -5353,7 +5444,7 @@ function FieldInput({
5353
5444
  inputClass
5354
5445
  }
5355
5446
  );
5356
- case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Signature:
5447
+ case chunkZYACIPKO_js.INPUT_FIELD_TYPE.Signature:
5357
5448
  return /* @__PURE__ */ jsxRuntime.jsx(
5358
5449
  SignatureInput,
5359
5450
  {
@@ -5386,7 +5477,7 @@ function FileUploadInput({
5386
5477
  const [isUploading, setIsUploading] = React10__default.default.useState(false);
5387
5478
  const fileUrl = typeof value === "string" ? value : void 0;
5388
5479
  const acceptedFormats = field.validation?.accepted_formats;
5389
- const accept = acceptedFormats ? acceptedFormats.map((f) => `.${f}`).join(",") : field.field_type === chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Image ? "image/*" : void 0;
5480
+ const accept = acceptedFormats ? acceptedFormats.map((f) => `.${f}`).join(",") : field.field_type === chunkZYACIPKO_js.INPUT_FIELD_TYPE.Image ? "image/*" : void 0;
5390
5481
  const handleFile = async (file) => {
5391
5482
  if (!onFileUpload) return;
5392
5483
  if (field.validation?.max_size_mb) {
@@ -5404,7 +5495,7 @@ function FileUploadInput({
5404
5495
  }
5405
5496
  };
5406
5497
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("space-y-2", classNames?.fileInput), children: fileUrl ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
5407
- field.field_type === chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Image && /* @__PURE__ */ jsxRuntime.jsx("img", { src: fileUrl, alt: "Uploaded", className: "w-16 h-16 object-cover rounded-md border border-border" }),
5498
+ field.field_type === chunkZYACIPKO_js.INPUT_FIELD_TYPE.Image && /* @__PURE__ */ jsxRuntime.jsx("img", { src: fileUrl, alt: "Uploaded", className: "w-16 h-16 object-cover rounded-md border border-border" }),
5408
5499
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-foreground truncate", children: fileUrl.split("/").pop() }) }),
5409
5500
  /* @__PURE__ */ jsxRuntime.jsx(
5410
5501
  "button",
@@ -5430,7 +5521,7 @@ function FileUploadInput({
5430
5521
  }
5431
5522
  ),
5432
5523
  isUploading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "Uploading..." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5433
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: field.placeholder || `Upload ${field.field_type === chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Image ? "image" : "file"}` }),
5524
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: field.placeholder || `Upload ${field.field_type === chunkZYACIPKO_js.INPUT_FIELD_TYPE.Image ? "image" : "file"}` }),
5434
5525
  acceptedFormats && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground/60 mt-1", children: [
5435
5526
  acceptedFormats.map((f) => f.toUpperCase()).join(", "),
5436
5527
  field.validation?.max_size_mb && ` \xB7 Max ${field.validation.max_size_mb}MB`
@@ -5989,18 +6080,18 @@ function ProductCustomizer({
5989
6080
  }, [selectedAddOnOptionIds]);
5990
6081
  const localTotalPrice = React10.useMemo(() => {
5991
6082
  if (isComposite && compositePrice) {
5992
- return chunkPEDLCL72_js.parsePrice(compositePrice.final_price) * quantity;
6083
+ return chunkV2O5AO7I_js.parsePrice(compositePrice.final_price) * quantity;
5993
6084
  }
5994
6085
  if (isBundle && bundleTotalPrice != null) {
5995
6086
  return bundleTotalPrice * quantity;
5996
6087
  }
5997
- let price = chunkPEDLCL72_js.parsePrice(product.default_price);
6088
+ let price = chunkV2O5AO7I_js.parsePrice(product.default_price);
5998
6089
  if (selectedVariant?.price_adjustment) {
5999
- price += chunkPEDLCL72_js.parsePrice(selectedVariant.price_adjustment);
6090
+ price += chunkV2O5AO7I_js.parsePrice(selectedVariant.price_adjustment);
6000
6091
  }
6001
6092
  for (const option of selectedAddOnOptions) {
6002
6093
  if (option.default_price) {
6003
- price += chunkPEDLCL72_js.parsePrice(option.default_price);
6094
+ price += chunkV2O5AO7I_js.parsePrice(option.default_price);
6004
6095
  }
6005
6096
  }
6006
6097
  return price * quantity;
@@ -6049,7 +6140,7 @@ function ProductCustomizer({
6049
6140
  const priceInfo = quote.quoted_total_price_info ?? quote.final_price_info;
6050
6141
  const perUnit = priceInfo.pre_tax_price;
6051
6142
  if (perUnit === void 0 || perUnit === null) return void 0;
6052
- return chunkPEDLCL72_js.parsePrice(perUnit) * quantity;
6143
+ return chunkV2O5AO7I_js.parsePrice(perUnit) * quantity;
6053
6144
  }, [quote, quantity]);
6054
6145
  const displayTotalPrice = quotedTotalPrice ?? localTotalPrice;
6055
6146
  const handleVariantChange = React10.useCallback(
@@ -6171,7 +6262,7 @@ function ProductCustomizer({
6171
6262
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: product.deposit_amount })
6172
6263
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6173
6264
  "Deposit required: ",
6174
- chunkPEDLCL72_js.parsePrice(product.deposit_amount),
6265
+ chunkV2O5AO7I_js.parsePrice(product.deposit_amount),
6175
6266
  "%"
6176
6267
  ] }) }),
6177
6268
  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(
@@ -6232,7 +6323,7 @@ function ProductCustomizer({
6232
6323
  ] })
6233
6324
  ] }),
6234
6325
  product.quantity_pricing && product.quantity_pricing.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-customizer-unit-price": true, className: "text-sm text-muted-foreground text-right shrink-0", children: [
6235
- /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: chunkPEDLCL72_js.getUnitPriceAtQuantity(product.quantity_pricing, quantity, chunkPEDLCL72_js.parsePrice(product.default_price)), className: "font-medium text-foreground" }),
6326
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: chunkV2O5AO7I_js.getUnitPriceAtQuantity(product.quantity_pricing, quantity, chunkV2O5AO7I_js.parsePrice(product.default_price)), className: "font-medium text-foreground" }),
6236
6327
  " ea."
6237
6328
  ] }),
6238
6329
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -6355,85 +6446,94 @@ function CartLineItemRow({
6355
6446
  });
6356
6447
  const hasComposite = item.compositeSelections && item.compositeSelections.length > 0;
6357
6448
  const hasBundle = item.bundleSelections && item.bundleSelections.length > 0;
6358
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item": true, className: classNames?.item, children: [
6359
- /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item-info": true, children: [
6360
- /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-name": true, className: classNames?.itemName, children: item.product.name }),
6361
- item.variant && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-variant": true, children: chunk6HCBOIZ4_js.getVariantDisplayName(item.variant, item.product.name) }),
6362
- item.addOnOptions && item.addOnOptions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-cart-item-addons": true, children: [
6363
- "+ ",
6364
- item.addOnOptions.map((opt) => opt.name).join(", ")
6365
- ] }),
6366
- (hasComposite || hasBundle) && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-badge": true, children: hasComposite ? "Custom" : "Bundle" }),
6367
- item.specialInstructions && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-instructions": true, className: "text-xs text-muted-foreground", children: item.specialInstructions }),
6368
- item.customerInputs && item.customerInputs.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-cart-customer-inputs": true, className: classNames?.customerInputs, children: item.customerInputs.map((input) => /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-input": true, children: [
6369
- /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-input-label": true, children: input.field_name }),
6370
- /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-input-value": true, children: input.field_type === chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.File || input.field_type === chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Image ? String(input.value).split("/").pop() || "Uploaded file" : String(input.value) })
6371
- ] }, input.field_id)) }),
6372
- (item.lineType === "service" || item.product.type === "service") && item.scheduledStart && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-service-info": true, className: classNames?.serviceInfo, children: [
6373
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6374
- "\u{1F4C5}",
6375
- " ",
6376
- new Date(item.scheduledStart).toLocaleDateString(),
6377
- " at ",
6378
- new Date(item.scheduledStart).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })
6379
- ] }),
6380
- item.confirmationCode && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6381
- "Confirmation: ",
6382
- item.confirmationCode
6383
- ] }),
6384
- item.serviceStatus && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-status": item.serviceStatus, children: item.serviceStatus })
6385
- ] }),
6386
- (item.lineType === "digital" || item.product.type === "digital") && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-cart-digital-info": true, className: classNames?.digitalInfo, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6387
- "\u26A1",
6388
- " Instant digital delivery"
6389
- ] }) }),
6390
- item.bundleResolved && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-cart-bundle-breakdown": true, className: classNames?.bundleBreakdown, children: item.bundleResolved.selections.map((sel) => /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-product-type": sel.product_type, children: [
6391
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6392
- sel.quantity,
6393
- "\xD7 ",
6394
- sel.product_name
6395
- ] }),
6396
- sel.product_type === "service" && sel.scheduling?.scheduled_start && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6397
- " \u2014 ",
6398
- new Date(sel.scheduling.scheduled_start).toLocaleDateString()
6399
- ] }),
6400
- sel.product_type === "digital" && /* @__PURE__ */ jsxRuntime.jsx("span", { children: " \u2014 Digital" })
6401
- ] }, sel.component_id)) }),
6402
- item.compositeResolved && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-cart-composite-breakdown": true, className: classNames?.compositeBreakdown, children: item.compositeResolved.selections.map((sel) => /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-product-type": sel.product_type, children: [
6403
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6404
- sel.quantity,
6405
- "\xD7 ",
6406
- sel.component_name
6449
+ const isOptimistic = item.isOptimistic === true;
6450
+ return /* @__PURE__ */ jsxRuntime.jsxs(
6451
+ "div",
6452
+ {
6453
+ "data-cimplify-cart-item": true,
6454
+ "data-optimistic": isOptimistic ? "true" : void 0,
6455
+ className: classNames?.item,
6456
+ children: [
6457
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item-info": true, children: [
6458
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-name": true, className: classNames?.itemName, children: item.product.name }),
6459
+ item.variant && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-variant": true, children: chunkZYACIPKO_js.getVariantDisplayName(item.variant, item.product.name) }),
6460
+ item.addOnOptions && item.addOnOptions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-cart-item-addons": true, children: [
6461
+ "+ ",
6462
+ item.addOnOptions.map((opt) => opt.name).join(", ")
6463
+ ] }),
6464
+ (hasComposite || hasBundle) && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-badge": true, children: hasComposite ? "Custom" : "Bundle" }),
6465
+ item.specialInstructions && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-instructions": true, className: "text-xs text-muted-foreground", children: item.specialInstructions }),
6466
+ item.customerInputs && item.customerInputs.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-cart-customer-inputs": true, className: classNames?.customerInputs, children: item.customerInputs.map((input) => /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-input": true, children: [
6467
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-input-label": true, children: input.field_name }),
6468
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-input-value": true, children: input.field_type === chunkZYACIPKO_js.INPUT_FIELD_TYPE.File || input.field_type === chunkZYACIPKO_js.INPUT_FIELD_TYPE.Image ? String(input.value).split("/").pop() || "Uploaded file" : String(input.value) })
6469
+ ] }, input.field_id)) }),
6470
+ (item.lineType === "service" || item.product.type === "service") && item.scheduledStart && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-service-info": true, className: classNames?.serviceInfo, children: [
6471
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6472
+ "\u{1F4C5}",
6473
+ " ",
6474
+ new Date(item.scheduledStart).toLocaleDateString(),
6475
+ " at ",
6476
+ new Date(item.scheduledStart).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })
6477
+ ] }),
6478
+ item.confirmationCode && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6479
+ "Confirmation: ",
6480
+ item.confirmationCode
6481
+ ] }),
6482
+ item.serviceStatus && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-status": item.serviceStatus, children: item.serviceStatus })
6483
+ ] }),
6484
+ (item.lineType === "digital" || item.product.type === "digital") && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-cart-digital-info": true, className: classNames?.digitalInfo, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6485
+ "\u26A1",
6486
+ " Instant digital delivery"
6487
+ ] }) }),
6488
+ item.bundleResolved && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-cart-bundle-breakdown": true, className: classNames?.bundleBreakdown, children: item.bundleResolved.selections.map((sel) => /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-product-type": sel.product_type, children: [
6489
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6490
+ sel.quantity,
6491
+ "\xD7 ",
6492
+ sel.product_name
6493
+ ] }),
6494
+ sel.product_type === "service" && sel.scheduling?.scheduled_start && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6495
+ " \u2014 ",
6496
+ new Date(sel.scheduling.scheduled_start).toLocaleDateString()
6497
+ ] }),
6498
+ sel.product_type === "digital" && /* @__PURE__ */ jsxRuntime.jsx("span", { children: " \u2014 Digital" })
6499
+ ] }, sel.component_id)) }),
6500
+ item.compositeResolved && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-cart-composite-breakdown": true, className: classNames?.compositeBreakdown, children: item.compositeResolved.selections.map((sel) => /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-product-type": sel.product_type, children: [
6501
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6502
+ sel.quantity,
6503
+ "\xD7 ",
6504
+ sel.component_name
6505
+ ] }),
6506
+ sel.product_type === "service" && sel.scheduling?.scheduled_start && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6507
+ " \u2014 ",
6508
+ new Date(sel.scheduling.scheduled_start).toLocaleDateString()
6509
+ ] })
6510
+ ] }, sel.component_id)) }),
6511
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: unitPrice, className: classNames?.itemPrice })
6407
6512
  ] }),
6408
- sel.product_type === "service" && sel.scheduling?.scheduled_start && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6409
- " \u2014 ",
6410
- new Date(sel.scheduling.scheduled_start).toLocaleDateString()
6513
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item-controls": true, className: classNames?.quantity, children: [
6514
+ /* @__PURE__ */ jsxRuntime.jsx(
6515
+ QuantitySelector,
6516
+ {
6517
+ value: item.quantity,
6518
+ onChange: (qty) => onQuantityChange(item.id, qty),
6519
+ min: 0
6520
+ }
6521
+ ),
6522
+ /* @__PURE__ */ jsxRuntime.jsx(
6523
+ "button",
6524
+ {
6525
+ type: "button",
6526
+ onClick: () => onRemove(item.id),
6527
+ "data-cimplify-cart-item-remove": true,
6528
+ className: classNames?.removeButton,
6529
+ "aria-label": `Remove ${item.product.name}`,
6530
+ children: "Remove"
6531
+ }
6532
+ )
6411
6533
  ] })
6412
- ] }, sel.component_id)) }),
6413
- /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: unitPrice, className: classNames?.itemPrice })
6414
- ] }),
6415
- /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item-controls": true, className: classNames?.quantity, children: [
6416
- /* @__PURE__ */ jsxRuntime.jsx(
6417
- QuantitySelector,
6418
- {
6419
- value: item.quantity,
6420
- onChange: (qty) => onQuantityChange(item.id, qty),
6421
- min: 0
6422
- }
6423
- ),
6424
- /* @__PURE__ */ jsxRuntime.jsx(
6425
- "button",
6426
- {
6427
- type: "button",
6428
- onClick: () => onRemove(item.id),
6429
- "data-cimplify-cart-item-remove": true,
6430
- className: classNames?.removeButton,
6431
- "aria-label": `Remove ${item.product.name}`,
6432
- children: "Remove"
6433
- }
6434
- )
6435
- ] })
6436
- ] });
6534
+ ]
6535
+ }
6536
+ );
6437
6537
  }
6438
6538
  function CartSummary({
6439
6539
  cart: serverCart,
@@ -6444,7 +6544,18 @@ function CartSummary({
6444
6544
  className,
6445
6545
  classNames
6446
6546
  }) {
6447
- const { items, itemCount, subtotal, tax, total, isEmpty, removeItem, updateQuantity } = useCart();
6547
+ const {
6548
+ items,
6549
+ itemCount,
6550
+ subtotal,
6551
+ tax,
6552
+ total,
6553
+ isEmpty,
6554
+ isOptimistic,
6555
+ pendingOpCount,
6556
+ removeItem,
6557
+ updateQuantity
6558
+ } = useCart();
6448
6559
  const deliveryFee = serverCart?.delivery_fee;
6449
6560
  const serviceCharge = serverCart?.service_charge;
6450
6561
  const totalDiscounts = serverCart?.total_discounts;
@@ -6462,60 +6573,69 @@ function CartSummary({
6462
6573
  void updateQuantity(itemId, qty);
6463
6574
  }
6464
6575
  };
6465
- return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-cart-summary": true, className: cn(className, classNames?.root), children: isEmpty ? /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-cart-empty": true, className: classNames?.empty, children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: emptyMessage }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6466
- /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-cart-items": true, children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
6467
- CartLineItemRow,
6468
- {
6469
- item,
6470
- onRemove: handleRemove,
6471
- onQuantityChange: handleQuantityChange,
6472
- classNames
6473
- },
6474
- item.id
6475
- )) }),
6476
- /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-totals": true, className: classNames?.totals, children: [
6477
- /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-subtotal": true, className: classNames?.subtotal, children: [
6478
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6479
- "Subtotal (",
6480
- itemCount,
6481
- " ",
6482
- itemCount === 1 ? "item" : "items",
6483
- ")"
6576
+ return /* @__PURE__ */ jsxRuntime.jsx(
6577
+ "div",
6578
+ {
6579
+ "data-cimplify-cart-summary": true,
6580
+ "data-optimistic": isOptimistic ? "true" : void 0,
6581
+ "data-pending-ops": pendingOpCount > 0 ? pendingOpCount : void 0,
6582
+ className: cn(className, classNames?.root),
6583
+ children: isEmpty ? /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-cart-empty": true, className: classNames?.empty, children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: emptyMessage }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6584
+ /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-cart-items": true, children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
6585
+ CartLineItemRow,
6586
+ {
6587
+ item,
6588
+ onRemove: handleRemove,
6589
+ onQuantityChange: handleQuantityChange,
6590
+ classNames
6591
+ },
6592
+ item.id
6593
+ )) }),
6594
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-totals": true, className: classNames?.totals, children: [
6595
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-subtotal": true, className: classNames?.subtotal, children: [
6596
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
6597
+ "Subtotal (",
6598
+ itemCount,
6599
+ " ",
6600
+ itemCount === 1 ? "item" : "items",
6601
+ ")"
6602
+ ] }),
6603
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: subtotal })
6604
+ ] }),
6605
+ totalDiscounts != null && chunkV2O5AO7I_js.parsePrice(totalDiscounts) > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-discount": true, className: classNames?.discount, children: [
6606
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Discount" }),
6607
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: totalDiscounts, prefix: "-" })
6608
+ ] }),
6609
+ deliveryFee != null && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-delivery-fee": true, className: classNames?.deliveryFee, children: [
6610
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Delivery fee" }),
6611
+ chunkV2O5AO7I_js.parsePrice(deliveryFee) > 0 ? /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: deliveryFee }) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Free delivery" })
6612
+ ] }),
6613
+ serviceCharge != null && chunkV2O5AO7I_js.parsePrice(serviceCharge) > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-service-charge": true, className: classNames?.serviceCharge, children: [
6614
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Service charge" }),
6615
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: serviceCharge })
6616
+ ] }),
6617
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-tax": true, className: classNames?.tax, children: [
6618
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Tax" }),
6619
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: tax })
6620
+ ] }),
6621
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-total": true, className: classNames?.total, children: [
6622
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Total" }),
6623
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: total })
6624
+ ] })
6484
6625
  ] }),
6485
- /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: subtotal })
6486
- ] }),
6487
- totalDiscounts != null && chunkPEDLCL72_js.parsePrice(totalDiscounts) > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-discount": true, className: classNames?.discount, children: [
6488
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Discount" }),
6489
- /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: totalDiscounts, prefix: "-" })
6490
- ] }),
6491
- deliveryFee != null && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-delivery-fee": true, className: classNames?.deliveryFee, children: [
6492
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Delivery fee" }),
6493
- chunkPEDLCL72_js.parsePrice(deliveryFee) > 0 ? /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: deliveryFee }) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Free delivery" })
6494
- ] }),
6495
- serviceCharge != null && chunkPEDLCL72_js.parsePrice(serviceCharge) > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-service-charge": true, className: classNames?.serviceCharge, children: [
6496
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Service charge" }),
6497
- /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: serviceCharge })
6498
- ] }),
6499
- /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-tax": true, className: classNames?.tax, children: [
6500
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Tax" }),
6501
- /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: tax })
6502
- ] }),
6503
- /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-total": true, className: classNames?.total, children: [
6504
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Total" }),
6505
- /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: total })
6626
+ onCheckout && /* @__PURE__ */ jsxRuntime.jsx(
6627
+ "button",
6628
+ {
6629
+ type: "button",
6630
+ onClick: onCheckout,
6631
+ "data-cimplify-cart-checkout": true,
6632
+ className: classNames?.checkout,
6633
+ children: "Proceed to Checkout"
6634
+ }
6635
+ )
6506
6636
  ] })
6507
- ] }),
6508
- onCheckout && /* @__PURE__ */ jsxRuntime.jsx(
6509
- "button",
6510
- {
6511
- type: "button",
6512
- onClick: onCheckout,
6513
- "data-cimplify-cart-checkout": true,
6514
- className: classNames?.checkout,
6515
- children: "Proceed to Checkout"
6516
- }
6517
- )
6518
- ] }) });
6637
+ }
6638
+ );
6519
6639
  }
6520
6640
  function AvailabilityBadge({
6521
6641
  product,
@@ -6575,16 +6695,16 @@ function SaleBadge({
6575
6695
  className,
6576
6696
  classNames
6577
6697
  }) {
6578
- const onSale = chunkPEDLCL72_js.isOnSale(product);
6698
+ const onSale = chunkV2O5AO7I_js.isOnSale(product);
6579
6699
  const hasDeal = dealInfo !== void 0;
6580
6700
  if (!hasDeal && !onSale && !label) {
6581
6701
  return null;
6582
6702
  }
6583
6703
  let percentage = null;
6584
6704
  if (hasDeal && dealInfo.benefit_type === "percentage") {
6585
- percentage = chunkPEDLCL72_js.parsePrice(dealInfo.value);
6705
+ percentage = chunkV2O5AO7I_js.parsePrice(dealInfo.value);
6586
6706
  } else if (onSale) {
6587
- percentage = chunkPEDLCL72_js.getDiscountPercentage(product);
6707
+ percentage = chunkV2O5AO7I_js.getDiscountPercentage(product);
6588
6708
  }
6589
6709
  const badgeText = label ?? dealInfo?.label ?? (percentage != null && percentage > 0 ? `${percentage}% off` : null);
6590
6710
  if (!badgeText) {
@@ -6603,7 +6723,7 @@ function SaleBadge({
6603
6723
  "%"
6604
6724
  ] }),
6605
6725
  /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-sale-label": true, className: classNames?.label, children: badgeText }),
6606
- showOriginalPrice && onSale && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-sale-original-price": true, className: classNames?.originalPrice, children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: chunkPEDLCL72_js.getBasePrice(product) }) })
6726
+ showOriginalPrice && onSale && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-sale-original-price": true, className: classNames?.originalPrice, children: /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: chunkV2O5AO7I_js.getBasePrice(product) }) })
6607
6727
  ]
6608
6728
  }
6609
6729
  );
@@ -6846,8 +6966,8 @@ function SoldOutOverlay() {
6846
6966
  );
6847
6967
  }
6848
6968
  function SaleBadge2({ product }) {
6849
- if (!chunkPEDLCL72_js.isOnSale(product)) return null;
6850
- const pct = chunkPEDLCL72_js.getDiscountPercentage(product);
6969
+ if (!chunkV2O5AO7I_js.isOnSale(product)) return null;
6970
+ const pct = chunkV2O5AO7I_js.getDiscountPercentage(product);
6851
6971
  if (!pct || pct <= 0) return null;
6852
6972
  return /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-card-sale-badge": true, className: "inline-flex items-center text-[11px] font-semibold tracking-wide bg-destructive text-destructive-foreground px-2 py-0.5 rounded-md", children: [
6853
6973
  "-",
@@ -6887,7 +7007,7 @@ function FoodProductCard({
6887
7007
  const tags = product.tags || [];
6888
7008
  const isSignature = product.metadata?.is_signature === true;
6889
7009
  const isNew = product.metadata?.is_new === true;
6890
- const isComposite = product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Composite;
7010
+ const isComposite = product.type === chunkZYACIPKO_js.PRODUCT_TYPE.Composite;
6891
7011
  return /* @__PURE__ */ jsxRuntime.jsxs(CardShell, { product, renderLink, className, children: [
6892
7012
  /* @__PURE__ */ jsxRuntime.jsxs(CardImage, { src: image, alt: product.name, aspectRatio: "square", renderImage, children: [
6893
7013
  isSignature && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "absolute top-3 left-3 inline-flex items-center gap-1 text-[11px] font-semibold tracking-wide bg-amber-50 text-amber-700 border border-amber-200/60 px-2 py-0.5 rounded-md", children: [
@@ -6940,7 +7060,7 @@ function RetailProductCard({
6940
7060
  }) {
6941
7061
  const image = product.image_url || product.images?.[0] || "";
6942
7062
  const outOfStock = product.inventory_status?.in_stock === false;
6943
- const onSale = chunkPEDLCL72_js.isOnSale(product);
7063
+ const onSale = chunkV2O5AO7I_js.isOnSale(product);
6944
7064
  const swatches = getColorSwatches(product);
6945
7065
  return /* @__PURE__ */ jsxRuntime.jsxs(CardShell, { product, renderLink, disabled: outOfStock, className, children: [
6946
7066
  outOfStock && /* @__PURE__ */ jsxRuntime.jsx(SoldOutOverlay, {}),
@@ -6958,7 +7078,7 @@ function RetailProductCard({
6958
7078
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-[14.5px] font-semibold text-foreground leading-snug tracking-tight mt-1 truncate", children: product.name }),
6959
7079
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mt-2", children: [
6960
7080
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: product.default_price, className: "text-sm font-bold" }),
6961
- onSale && /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: chunkPEDLCL72_js.getBasePrice(product), className: "text-xs text-muted-foreground line-through" })
7081
+ onSale && /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: chunkV2O5AO7I_js.getBasePrice(product), className: "text-xs text-muted-foreground line-through" })
6962
7082
  ] }),
6963
7083
  swatches.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-1.5 mt-2.5", children: swatches.map((name) => /* @__PURE__ */ jsxRuntime.jsx(
6964
7084
  "span",
@@ -6975,9 +7095,9 @@ function RetailProductCard({
6975
7095
  function PriceRange({ product, currency, className }) {
6976
7096
  const context = useOptionalCimplify();
6977
7097
  const resolvedCurrency = currency ?? context?.displayCurrency ?? "USD";
6978
- const range = chunkPEDLCL72_js.getPriceRange(product);
7098
+ const range = chunkV2O5AO7I_js.getPriceRange(product);
6979
7099
  if (!range) return null;
6980
- return /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-price-range": true, className, children: chunkPEDLCL72_js.formatPriceRange(range.min, range.max, resolvedCurrency) });
7100
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-price-range": true, className, children: chunkV2O5AO7I_js.formatPriceRange(range.min, range.max, resolvedCurrency) });
6981
7101
  }
6982
7102
  function WholesaleProductCard({
6983
7103
  product,
@@ -7066,8 +7186,8 @@ function BundleProductCard({
7066
7186
  const image = product.image_url || product.images?.[0] || "";
7067
7187
  const components = product.components || [];
7068
7188
  const componentCount = components.length;
7069
- const onSale = chunkPEDLCL72_js.isOnSale(product);
7070
- const discount = chunkPEDLCL72_js.getDiscountPercentage(product);
7189
+ const onSale = chunkV2O5AO7I_js.isOnSale(product);
7190
+ const discount = chunkV2O5AO7I_js.getDiscountPercentage(product);
7071
7191
  const hasVariantChoice = components.some((c) => c.allow_variant_choice);
7072
7192
  return /* @__PURE__ */ jsxRuntime.jsxs(CardShell, { product, renderLink, className, children: [
7073
7193
  /* @__PURE__ */ jsxRuntime.jsxs(CardImage, { src: image, alt: product.name, aspectRatio: "square", renderImage, children: [
@@ -7094,7 +7214,7 @@ function BundleProductCard({
7094
7214
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mt-2.5", children: [
7095
7215
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: product.default_price, className: "text-sm font-bold" }),
7096
7216
  onSale && product.bundle_price && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7097
- /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: chunkPEDLCL72_js.getBasePrice(product), className: "text-xs text-muted-foreground line-through" }),
7217
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: chunkV2O5AO7I_js.getBasePrice(product), className: "text-xs text-muted-foreground line-through" }),
7098
7218
  discount != null && discount > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-[10px] font-semibold text-emerald-600", children: [
7099
7219
  "Save ",
7100
7220
  discount,
@@ -7640,26 +7760,26 @@ var BUILT_IN_CARDS = {
7640
7760
  ["composite" /* Composite */]: CompositeProductCard,
7641
7761
  ["subscription" /* Subscription */]: SubscriptionCard
7642
7762
  };
7643
- var RENTAL_UNITS = /* @__PURE__ */ new Set([chunk6HCBOIZ4_js.DURATION_UNIT.Days, chunk6HCBOIZ4_js.DURATION_UNIT.Hours]);
7644
- var LEASE_UNITS = /* @__PURE__ */ new Set([chunk6HCBOIZ4_js.DURATION_UNIT.Weeks, chunk6HCBOIZ4_js.DURATION_UNIT.Months, chunk6HCBOIZ4_js.DURATION_UNIT.Years]);
7763
+ var RENTAL_UNITS = /* @__PURE__ */ new Set([chunkZYACIPKO_js.DURATION_UNIT.Days, chunkZYACIPKO_js.DURATION_UNIT.Hours]);
7764
+ var LEASE_UNITS = /* @__PURE__ */ new Set([chunkZYACIPKO_js.DURATION_UNIT.Weeks, chunkZYACIPKO_js.DURATION_UNIT.Months, chunkZYACIPKO_js.DURATION_UNIT.Years]);
7645
7765
  function resolveCardVariant(product) {
7646
- if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Bundle) {
7766
+ if (product.type === chunkZYACIPKO_js.PRODUCT_TYPE.Bundle) {
7647
7767
  return "bundle" /* Bundle */;
7648
7768
  }
7649
- if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Composite) {
7769
+ if (product.type === chunkZYACIPKO_js.PRODUCT_TYPE.Composite) {
7650
7770
  return "composite" /* Composite */;
7651
7771
  }
7652
7772
  if (product.quantity_pricing && product.quantity_pricing.length > 1) {
7653
7773
  return "wholesale" /* Wholesale */;
7654
7774
  }
7655
- if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Digital) {
7775
+ if (product.type === chunkZYACIPKO_js.PRODUCT_TYPE.Digital) {
7656
7776
  return "digital" /* Digital */;
7657
7777
  }
7658
- if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Service) {
7778
+ if (product.type === chunkZYACIPKO_js.PRODUCT_TYPE.Service) {
7659
7779
  if (product.duration_unit && RENTAL_UNITS.has(product.duration_unit)) {
7660
7780
  return "rental" /* Rental */;
7661
7781
  }
7662
- if (product.duration_unit === chunk6HCBOIZ4_js.DURATION_UNIT.Nights) {
7782
+ if (product.duration_unit === chunkZYACIPKO_js.DURATION_UNIT.Nights) {
7663
7783
  return "accommodation" /* Accommodation */;
7664
7784
  }
7665
7785
  if (product.duration_unit && LEASE_UNITS.has(product.duration_unit)) {
@@ -7670,10 +7790,10 @@ function resolveCardVariant(product) {
7670
7790
  }
7671
7791
  return "standard" /* Standard */;
7672
7792
  }
7673
- if (product.render_hint === chunk6HCBOIZ4_js.RENDER_HINT.Food) {
7793
+ if (product.render_hint === chunkZYACIPKO_js.RENDER_HINT.Food) {
7674
7794
  return "food" /* Food */;
7675
7795
  }
7676
- if (product.render_hint === chunk6HCBOIZ4_js.RENDER_HINT.Physical) {
7796
+ if (product.render_hint === chunkZYACIPKO_js.RENDER_HINT.Physical) {
7677
7797
  return "retail" /* Retail */;
7678
7798
  }
7679
7799
  return "retail" /* Retail */;
@@ -8006,7 +8126,7 @@ function SearchInput({
8006
8126
  }
8007
8127
  ),
8008
8128
  /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-search-result-name": true, className: classNames?.resultName, style: { flex: 1, textAlign: "left" }, children: product.name }),
8009
- product.default_price !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-search-result-price": true, className: classNames?.resultPrice, style: { flexShrink: 0 }, children: chunkPEDLCL72_js.formatPrice(product.default_price) })
8129
+ product.default_price !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-search-result-price": true, className: classNames?.resultPrice, style: { flexShrink: 0 }, children: chunkV2O5AO7I_js.formatPrice(product.default_price) })
8010
8130
  ] })
8011
8131
  },
8012
8132
  product.id
@@ -8500,19 +8620,19 @@ function OrderSummary({
8500
8620
  order.customer_notes.map((note, index) => /* @__PURE__ */ jsxRuntime.jsx("p", { "data-cimplify-order-note": true, children: note }, index))
8501
8621
  ] }),
8502
8622
  /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-totals": true, className: classNames?.totals, children: [
8503
- order.total_discount != null && chunkPEDLCL72_js.parsePrice(order.total_discount) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-discount": true, children: [
8623
+ order.total_discount != null && chunkV2O5AO7I_js.parsePrice(order.total_discount) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-discount": true, children: [
8504
8624
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Discount" }),
8505
8625
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.total_discount, prefix: "-" })
8506
8626
  ] }),
8507
- order.delivery_fee != null && chunkPEDLCL72_js.parsePrice(order.delivery_fee) > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-delivery-fee": true, children: [
8627
+ order.delivery_fee != null && chunkV2O5AO7I_js.parsePrice(order.delivery_fee) > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-delivery-fee": true, children: [
8508
8628
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Delivery fee" }),
8509
8629
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.delivery_fee })
8510
8630
  ] }),
8511
- order.service_charge != null && chunkPEDLCL72_js.parsePrice(order.service_charge) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-service-charge": true, children: [
8631
+ order.service_charge != null && chunkV2O5AO7I_js.parsePrice(order.service_charge) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-service-charge": true, children: [
8512
8632
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Service charge" }),
8513
8633
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.service_charge })
8514
8634
  ] }),
8515
- order.tax != null && chunkPEDLCL72_js.parsePrice(order.tax) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-tax": true, children: [
8635
+ order.tax != null && chunkV2O5AO7I_js.parsePrice(order.tax) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-tax": true, children: [
8516
8636
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Tax" }),
8517
8637
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.tax })
8518
8638
  ] }),
@@ -9801,7 +9921,7 @@ function DefaultProductLayout({
9801
9921
  }) {
9802
9922
  const images = product.images || (product.image_url ? [product.image_url] : []);
9803
9923
  const hasRange = product.quantity_pricing && product.quantity_pricing.length > 1 || product.variants && product.variants.length > 1;
9804
- const onSale = chunkPEDLCL72_js.isOnSale(product);
9924
+ const onSale = chunkV2O5AO7I_js.isOnSale(product);
9805
9925
  const hasPhysicalDetails = product.sku || product.vendor || product.material;
9806
9926
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-product-layout": "default", className: cn("space-y-8", className), children: [
9807
9927
  renderBreadcrumb?.(product),
@@ -9823,10 +9943,10 @@ function DefaultProductLayout({
9823
9943
  /* @__PURE__ */ jsxRuntime.jsx("h1", { "data-cimplify-product-layout-name": true, className: "text-3xl lg:text-4xl font-extrabold tracking-tight", children: product.name }),
9824
9944
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-baseline gap-3", children: hasRange ? /* @__PURE__ */ jsxRuntime.jsx(PriceRange, { product, className: "text-2xl font-extrabold" }) : onSale ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
9825
9945
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: product.default_price, className: "text-2xl font-extrabold" }),
9826
- /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: chunkPEDLCL72_js.getBasePrice(product), className: "text-lg text-muted-foreground line-through" }),
9946
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: chunkV2O5AO7I_js.getBasePrice(product), className: "text-lg text-muted-foreground line-through" }),
9827
9947
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm font-bold text-destructive bg-destructive/10 px-2 py-0.5", children: [
9828
9948
  "Save ",
9829
- chunkPEDLCL72_js.getDiscountPercentage(product),
9949
+ chunkV2O5AO7I_js.getDiscountPercentage(product),
9830
9950
  "%"
9831
9951
  ] })
9832
9952
  ] }) : /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: product.default_price, className: "text-2xl font-semibold" }) }),
@@ -10045,7 +10165,7 @@ function ServiceProductLayout({
10045
10165
  }) {
10046
10166
  const images = product.images || (product.image_url ? [product.image_url] : []);
10047
10167
  const hasDeposit = product.deposit_type && product.deposit_type !== "none" && product.deposit_amount;
10048
- const depositAmount = hasDeposit ? chunkPEDLCL72_js.parsePrice(product.deposit_amount) : 0;
10168
+ const depositAmount = hasDeposit ? chunkV2O5AO7I_js.parsePrice(product.deposit_amount) : 0;
10049
10169
  const cancellationHours = product.cancellation_window_minutes ? Math.floor(product.cancellation_window_minutes / 60) : null;
10050
10170
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-product-layout": "service", className: cn("space-y-8", className), children: [
10051
10171
  renderBreadcrumb?.(product),
@@ -10113,7 +10233,7 @@ function ServiceProductLayout({
10113
10233
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: depositAmount, className: "font-medium text-foreground" }),
10114
10234
  " deposit charged at booking"
10115
10235
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10116
- chunkPEDLCL72_js.parsePrice(product.deposit_amount),
10236
+ chunkV2O5AO7I_js.parsePrice(product.deposit_amount),
10117
10237
  "% deposit charged at booking"
10118
10238
  ] }) })
10119
10239
  ] })
@@ -10272,13 +10392,13 @@ function BundleProductLayout({
10272
10392
  }) {
10273
10393
  const images = product.images || (product.image_url ? [product.image_url] : []);
10274
10394
  const components = product.components || [];
10275
- const onSale = chunkPEDLCL72_js.isOnSale(product);
10276
- const discount = chunkPEDLCL72_js.getDiscountPercentage(product);
10395
+ const onSale = chunkV2O5AO7I_js.isOnSale(product);
10396
+ const discount = chunkV2O5AO7I_js.getDiscountPercentage(product);
10277
10397
  const baseTotal = components.reduce(
10278
- (sum, c) => sum + chunkPEDLCL72_js.parsePrice(c.effective_price ?? 0) * (c.quantity ?? 1),
10398
+ (sum, c) => sum + chunkV2O5AO7I_js.parsePrice(c.effective_price ?? 0) * (c.quantity ?? 1),
10279
10399
  0
10280
10400
  );
10281
- const bundlePrice = chunkPEDLCL72_js.parsePrice(product.default_price);
10401
+ const bundlePrice = chunkV2O5AO7I_js.parsePrice(product.default_price);
10282
10402
  const savings = baseTotal > bundlePrice ? baseTotal - bundlePrice : 0;
10283
10403
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-product-layout": "bundle", className: cn("space-y-8", className), children: [
10284
10404
  renderBreadcrumb?.(product),
@@ -10434,25 +10554,25 @@ function resolveTemplateKey(product) {
10434
10554
  if (typeof metaTemplate === "string" && metaTemplate.trim()) {
10435
10555
  return metaTemplate.trim();
10436
10556
  }
10437
- if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Bundle) {
10557
+ if (product.type === chunkZYACIPKO_js.PRODUCT_TYPE.Bundle) {
10438
10558
  return "bundle" /* Bundle */;
10439
10559
  }
10440
- if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Composite) {
10560
+ if (product.type === chunkZYACIPKO_js.PRODUCT_TYPE.Composite) {
10441
10561
  return "composite" /* Composite */;
10442
10562
  }
10443
10563
  if (product.quantity_pricing && product.quantity_pricing.length > 1) {
10444
10564
  return "wholesale" /* Wholesale */;
10445
10565
  }
10446
- if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Service) {
10566
+ if (product.type === chunkZYACIPKO_js.PRODUCT_TYPE.Service) {
10447
10567
  return "service" /* Service */;
10448
10568
  }
10449
- if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Digital) {
10569
+ if (product.type === chunkZYACIPKO_js.PRODUCT_TYPE.Digital) {
10450
10570
  return "digital" /* Digital */;
10451
10571
  }
10452
- if (product.render_hint === chunk6HCBOIZ4_js.RENDER_HINT.Food) {
10572
+ if (product.render_hint === chunkZYACIPKO_js.RENDER_HINT.Food) {
10453
10573
  return "food" /* Food */;
10454
10574
  }
10455
- if (product.render_hint === chunk6HCBOIZ4_js.RENDER_HINT.Physical) {
10575
+ if (product.render_hint === chunkZYACIPKO_js.RENDER_HINT.Physical) {
10456
10576
  return "physical" /* Physical */;
10457
10577
  }
10458
10578
  return "default" /* Default */;
@@ -10905,9 +11025,9 @@ function CatalogueCollectionLayout({
10905
11025
  result = result.filter((p) => p.tags?.includes(activeCategory));
10906
11026
  }
10907
11027
  if (sortBy === "price-asc") {
10908
- result = [...result].sort((a, b) => chunkPEDLCL72_js.parsePrice(a.default_price) - chunkPEDLCL72_js.parsePrice(b.default_price));
11028
+ result = [...result].sort((a, b) => chunkV2O5AO7I_js.parsePrice(a.default_price) - chunkV2O5AO7I_js.parsePrice(b.default_price));
10909
11029
  } else if (sortBy === "price-desc") {
10910
- result = [...result].sort((a, b) => chunkPEDLCL72_js.parsePrice(b.default_price) - chunkPEDLCL72_js.parsePrice(a.default_price));
11030
+ result = [...result].sort((a, b) => chunkV2O5AO7I_js.parsePrice(b.default_price) - chunkV2O5AO7I_js.parsePrice(a.default_price));
10911
11031
  } else if (sortBy === "name") {
10912
11032
  result = [...result].sort((a, b) => a.name.localeCompare(b.name));
10913
11033
  }
@@ -12516,7 +12636,7 @@ function SparkleIcon({ className }) {
12516
12636
 
12517
12637
  Object.defineProperty(exports, "getVariantDisplayName", {
12518
12638
  enumerable: true,
12519
- get: function () { return chunk6HCBOIZ4_js.getVariantDisplayName; }
12639
+ get: function () { return chunkZYACIPKO_js.getVariantDisplayName; }
12520
12640
  });
12521
12641
  exports.AccommodationCard = AccommodationCard;
12522
12642
  exports.Ad = Ad;