@cimplify/sdk 0.30.0 → 0.31.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.
@@ -1,2 +1,2 @@
1
- export { A as AuthService, B as BusinessService, j as CartOperations, b as CatalogueQueries, l as CheckoutOperations, l as CheckoutService, a7 as CimplifyElement, a6 as CimplifyElements, ab as ELEMENT_TYPES, aa as EVENT_TYPES, af as ElementEventType, ad as ElementOptions, ae as ElementType, ac as ElementsOptions, F as FetchQuoteInput, s as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, r as LiteService, a9 as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, q as SchedulingService, a8 as createElements, m as generateIdempotencyKey } from './index-DaXyvlxk.mjs';
1
+ export { A as AuthService, B as BusinessService, j as CartOperations, b as CatalogueQueries, l as CheckoutOperations, l as CheckoutService, a7 as CimplifyElement, a6 as CimplifyElements, ab as ELEMENT_TYPES, aa as EVENT_TYPES, af as ElementEventType, ad as ElementOptions, ae as ElementType, ac as ElementsOptions, F as FetchQuoteInput, s as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, r as LiteService, a9 as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, q as SchedulingService, a8 as createElements, m as generateIdempotencyKey } from './index-m8zGQUda.mjs';
2
2
  import './payment-DnU_eLuT.mjs';
@@ -1,2 +1,2 @@
1
- export { A as AuthService, B as BusinessService, j as CartOperations, b as CatalogueQueries, l as CheckoutOperations, l as CheckoutService, a7 as CimplifyElement, a6 as CimplifyElements, ab as ELEMENT_TYPES, aa as EVENT_TYPES, af as ElementEventType, ad as ElementOptions, ae as ElementType, ac as ElementsOptions, F as FetchQuoteInput, s as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, r as LiteService, a9 as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, q as SchedulingService, a8 as createElements, m as generateIdempotencyKey } from './index-DTdtu4OO.js';
1
+ export { A as AuthService, B as BusinessService, j as CartOperations, b as CatalogueQueries, l as CheckoutOperations, l as CheckoutService, a7 as CimplifyElement, a6 as CimplifyElements, ab as ELEMENT_TYPES, aa as EVENT_TYPES, af as ElementEventType, ad as ElementOptions, ae as ElementType, ac as ElementsOptions, F as FetchQuoteInput, s as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, r as LiteService, a9 as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, q as SchedulingService, a8 as createElements, m as generateIdempotencyKey } from './index-BpyFcJVv.js';
2
2
  import './payment-DnU_eLuT.js';
@@ -843,6 +843,15 @@ var CimplifyClient = class {
843
843
  }
844
844
  return this._support;
845
845
  }
846
+ buildWsUrl(path) {
847
+ const protocol = this.baseUrl.startsWith("https") ? "wss:" : "ws:";
848
+ const host = this.baseUrl.replace(/^https?:\/\//, "");
849
+ const params = new URLSearchParams();
850
+ if (this.publicKey) params.set("api_key", this.publicKey);
851
+ if (this.sessionToken) params.set("session_token", this.sessionToken);
852
+ const query = params.toString();
853
+ return `${protocol}//${host}${path}${query ? `?${query}` : ""}`;
854
+ }
846
855
  elements(businessId, options) {
847
856
  if (businessId) {
848
857
  this.setBusinessId(businessId);
@@ -845,6 +845,15 @@ var CimplifyClient = class {
845
845
  }
846
846
  return this._support;
847
847
  }
848
+ buildWsUrl(path) {
849
+ const protocol = this.baseUrl.startsWith("https") ? "wss:" : "ws:";
850
+ const host = this.baseUrl.replace(/^https?:\/\//, "");
851
+ const params = new URLSearchParams();
852
+ if (this.publicKey) params.set("api_key", this.publicKey);
853
+ if (this.sessionToken) params.set("session_token", this.sessionToken);
854
+ const query = params.toString();
855
+ return `${protocol}//${host}${path}${query ? `?${query}` : ""}`;
856
+ }
848
857
  elements(businessId, options) {
849
858
  if (businessId) {
850
859
  this.setBusinessId(businessId);
@@ -2342,6 +2342,7 @@ declare class CimplifyClient {
2342
2342
  get activity(): ActivityService;
2343
2343
  get delivery(): DeliveryService;
2344
2344
  get support(): SupportService;
2345
+ buildWsUrl(path: string): string;
2345
2346
  elements(businessId?: string, options?: ElementsOptions): CimplifyElements;
2346
2347
  }
2347
2348
  declare function createCimplifyClient(config?: CimplifyConfig): CimplifyClient;
@@ -2342,6 +2342,7 @@ declare class CimplifyClient {
2342
2342
  get activity(): ActivityService;
2343
2343
  get delivery(): DeliveryService;
2344
2344
  get support(): SupportService;
2345
+ buildWsUrl(path: string): string;
2345
2346
  elements(businessId?: string, options?: ElementsOptions): CimplifyElements;
2346
2347
  }
2347
2348
  declare function createCimplifyClient(config?: CimplifyConfig): CimplifyClient;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { aD as AUTHORIZATION_TYPE, aI as AUTH_MUTATION, as as AbortablePromise, M as ActivityRecommendation, N as ActivityRecommendationsResponse, t as ActivityService, K as ActivityStateResponse, cN as AddressData, de as AddressInfo, bg as AmountToPay, cY as AuthResponse, A as AuthService, o as AuthStatus, dg as AuthenticatedCustomer, di as AuthenticatedData, y as AutocompletePrediction, z as AutocompleteResponse, cD as AvailabilityResult, cg as AvailableSlot, cj as Booking, ct as BookingModificationType, ci as BookingStatus, ck as BookingWithDetails, bC as BufferTimes, bX as Business, c9 as BusinessHours, bW as BusinessPreferences, B as BusinessService, c8 as BusinessSettings, bV as BusinessType, c6 as BusinessWithLocations, aw as CHECKOUT_MODE, aJ as CHECKOUT_MUTATION, az as CHECKOUT_STEP, aF as CONTACT_TYPE, cr as CancelBookingInput, cs as CancelBookingResult, bw as CancelOrderInput, bE as CancellationPolicy, j as CartOperations, b as CatalogueQueries, b3 as CatalogueResult, b4 as CatalogueSnapshot, ca as CategoryInfo, a0 as ChatAttachment, _ as ChatConversation, $ as ChatConversationResponse, Z as ChatMessage, a1 as ChatWidgetStarter, co as CheckSlotAvailabilityInput, cp as CheckSlotAvailabilityResult, c$ as CheckoutAddressInfo, dm as CheckoutCartData, dl as CheckoutCartItem, d1 as CheckoutCustomerInfo, ak as CheckoutFormData, bu as CheckoutInput, ag as CheckoutMode, l as CheckoutOperations, ah as CheckoutOrderType, ai as CheckoutPaymentMethod, al as CheckoutResult, l as CheckoutService, aq as CheckoutStatus, ar as CheckoutStatusContext, aj as CheckoutStep, C as CimplifyClient, a as CimplifyConfig, a7 as CimplifyElement, a6 as CimplifyElements, av as ContactType, a3 as ContentType, cJ as CreateAddressInput, cL as CreateMobileMoneyInput, cE as Customer, cF as CustomerAddress, cm as CustomerBooking, cl as CustomerBookingServiceItem, cH as CustomerLinkPreferences, cG as CustomerMobileMoney, bB as CustomerServicePreferences, aN as DEFAULT_COUNTRY, aM as DEFAULT_CURRENCY, aE as DEVICE_TYPE, ch as DayAvailability, bQ as DeliveryFeeDetails, X as DeliveryFeeResponse, W as DeliveryService, bL as DepositResult, au as DeviceType, V as DismissMessageResponse, ab as ELEMENT_TYPES, aa as EVENT_TYPES, dd as ElementAppearance, dq as ElementEventHandler, af as ElementEventType, ad as ElementOptions, ae as ElementType, dj as ElementsCheckoutData, dk as ElementsCheckoutResult, dh as ElementsCustomerInfo, ac as ElementsOptions, cP as EnrollAndLinkOrderInput, cS as EnrollAndLinkOrderResult, cM as EnrollmentData, aQ as Err, bf as FeeBearerType, F as FetchQuoteInput, bd as FulfillmentLink, bc as FulfillmentStatus, bb as FulfillmentType, d3 as FxQuote, d2 as FxQuoteRequest, d4 as FxRateResponse, s as FxService, cn as GetAvailableSlotsInput, n as GetOrdersOptions, G as GetProductsOptions, dp as IframeToParentMessage, I as InventoryService, aH as LINK_MUTATION, aG as LINK_QUERY, bh as LineItem, b8 as LineType, cI as LinkData, cR as LinkEnrollResult, L as LinkService, cT as LinkSession, cQ as LinkStatusResult, a4 as LiteBootstrap, r as LiteService, b_ as Location, bO as LocationBooking, cC as LocationStock, bY as LocationTaxBehavior, bZ as LocationTaxOverrides, c1 as LocationTimeProfile, c7 as LocationWithDetails, a9 as MESSAGE_TYPES, aC as MOBILE_MONEY_PROVIDER, cO as MobileMoneyData, d0 as MobileMoneyDetails, at as MobileMoneyProvider, am as NextAction, aL as ORDER_MUTATION, ax as ORDER_TYPE, db as ObservabilityHooks, aP as Ok, bi as Order, b7 as OrderChannel, bt as OrderFilter, be as OrderFulfillmentSummary, bn as OrderGroup, br as OrderGroupDetails, bo as OrderGroupPayment, bl as OrderGroupPaymentState, bm as OrderGroupPaymentStatus, bq as OrderGroupPaymentSummary, bk as OrderGroupStatus, bj as OrderHistory, b9 as OrderLineState, ba as OrderLineStatus, bs as OrderPaymentEvent, O as OrderQueries, bp as OrderSplitDetail, b5 as OrderStatus, dc as OrderType, p as OtpResult, ay as PAYMENT_METHOD, aK as PAYMENT_MUTATION, aA as PAYMENT_STATE, aB as PICKUP_TIME_TYPE, dn as ParentToIframeMessage, df as PaymentMethodInfo, b6 as PaymentState, c_ as PickupTime, cZ as PickupTimeType, D as PlaceDetailsResponse, x as PlacesService, P as PriceQuote, bG as PricingOverrides, ap as ProcessAndResolveOptions, an as ProcessCheckoutOptions, ao as ProcessCheckoutResult, cA as ProductStock, bP as ProviderResolutionSource, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, bx as RefundOrderInput, bT as RelatedCandidate, bS as RelatedProduct, bU as RelatedProductsEnrichment, bR as RelationType, bA as ReminderMethod, bD as ReminderSettings, k as ReorderResult, d5 as RequestContext, d8 as RequestErrorEvent, cW as RequestOtpInput, h as RequestSource, d6 as RequestStartEvent, d7 as RequestSuccessEvent, cq as RescheduleBookingInput, cu as RescheduleBookingResult, cx as RescheduleHistoryRecord, bJ as ResourceAssignment, aO as Result, d9 as RetryEvent, cV as RevokeAllSessionsResult, cU as RevokeSessionResult, c3 as Room, bH as SchedulingMetadata, bK as SchedulingResult, q as SchedulingService, a2 as SenderType, cb as Service, cv as ServiceAvailabilityParams, cw as ServiceAvailabilityResult, c4 as ServiceCharge, bF as ServiceNotes, bM as ServiceScheduleRequest, by as ServiceStatus, J as SessionActivityData, da as SessionChangeEvent, H as SessionMessage, ce as SlotResourceInfo, cf as SlotStaffInfo, cc as Staff, bI as StaffAssignment, bz as StaffRole, bN as StaffScheduleItem, cz as StockLevel, cy as StockStatus, c5 as StorefrontBootstrap, S as SubscriptionService, Y as SupportService, c2 as Table, a5 as TableInfo, b$ as TimeRange, c0 as TimeRanges, cd as TimeSlot, E as TrackCategoryViewOptions, T as TrackProductViewOptions, cK as UpdateAddressInput, bv as UpdateOrderStatusInput, U as UpdateProfileInput, w as UploadInitResponse, v as UploadResult, u as UploadService, cB as VariantStock, cX as VerifyOtpInput, b1 as combine, b2 as combineObject, c as createCimplifyClient, a8 as createElements, aS as err, aX as flatMap, a$ as fromPromise, m as generateIdempotencyKey, aY as getOrElse, aU as isErr, aT as isOk, aW as mapError, aV as mapResult, aR as ok, a_ as toNullable, b0 as tryCatch, aZ as unwrap } from './index-DaXyvlxk.mjs';
1
+ export { aD as AUTHORIZATION_TYPE, aI as AUTH_MUTATION, as as AbortablePromise, M as ActivityRecommendation, N as ActivityRecommendationsResponse, t as ActivityService, K as ActivityStateResponse, cN as AddressData, de as AddressInfo, bg as AmountToPay, cY as AuthResponse, A as AuthService, o as AuthStatus, dg as AuthenticatedCustomer, di as AuthenticatedData, y as AutocompletePrediction, z as AutocompleteResponse, cD as AvailabilityResult, cg as AvailableSlot, cj as Booking, ct as BookingModificationType, ci as BookingStatus, ck as BookingWithDetails, bC as BufferTimes, bX as Business, c9 as BusinessHours, bW as BusinessPreferences, B as BusinessService, c8 as BusinessSettings, bV as BusinessType, c6 as BusinessWithLocations, aw as CHECKOUT_MODE, aJ as CHECKOUT_MUTATION, az as CHECKOUT_STEP, aF as CONTACT_TYPE, cr as CancelBookingInput, cs as CancelBookingResult, bw as CancelOrderInput, bE as CancellationPolicy, j as CartOperations, b as CatalogueQueries, b3 as CatalogueResult, b4 as CatalogueSnapshot, ca as CategoryInfo, a0 as ChatAttachment, _ as ChatConversation, $ as ChatConversationResponse, Z as ChatMessage, a1 as ChatWidgetStarter, co as CheckSlotAvailabilityInput, cp as CheckSlotAvailabilityResult, c$ as CheckoutAddressInfo, dm as CheckoutCartData, dl as CheckoutCartItem, d1 as CheckoutCustomerInfo, ak as CheckoutFormData, bu as CheckoutInput, ag as CheckoutMode, l as CheckoutOperations, ah as CheckoutOrderType, ai as CheckoutPaymentMethod, al as CheckoutResult, l as CheckoutService, aq as CheckoutStatus, ar as CheckoutStatusContext, aj as CheckoutStep, C as CimplifyClient, a as CimplifyConfig, a7 as CimplifyElement, a6 as CimplifyElements, av as ContactType, a3 as ContentType, cJ as CreateAddressInput, cL as CreateMobileMoneyInput, cE as Customer, cF as CustomerAddress, cm as CustomerBooking, cl as CustomerBookingServiceItem, cH as CustomerLinkPreferences, cG as CustomerMobileMoney, bB as CustomerServicePreferences, aN as DEFAULT_COUNTRY, aM as DEFAULT_CURRENCY, aE as DEVICE_TYPE, ch as DayAvailability, bQ as DeliveryFeeDetails, X as DeliveryFeeResponse, W as DeliveryService, bL as DepositResult, au as DeviceType, V as DismissMessageResponse, ab as ELEMENT_TYPES, aa as EVENT_TYPES, dd as ElementAppearance, dq as ElementEventHandler, af as ElementEventType, ad as ElementOptions, ae as ElementType, dj as ElementsCheckoutData, dk as ElementsCheckoutResult, dh as ElementsCustomerInfo, ac as ElementsOptions, cP as EnrollAndLinkOrderInput, cS as EnrollAndLinkOrderResult, cM as EnrollmentData, aQ as Err, bf as FeeBearerType, F as FetchQuoteInput, bd as FulfillmentLink, bc as FulfillmentStatus, bb as FulfillmentType, d3 as FxQuote, d2 as FxQuoteRequest, d4 as FxRateResponse, s as FxService, cn as GetAvailableSlotsInput, n as GetOrdersOptions, G as GetProductsOptions, dp as IframeToParentMessage, I as InventoryService, aH as LINK_MUTATION, aG as LINK_QUERY, bh as LineItem, b8 as LineType, cI as LinkData, cR as LinkEnrollResult, L as LinkService, cT as LinkSession, cQ as LinkStatusResult, a4 as LiteBootstrap, r as LiteService, b_ as Location, bO as LocationBooking, cC as LocationStock, bY as LocationTaxBehavior, bZ as LocationTaxOverrides, c1 as LocationTimeProfile, c7 as LocationWithDetails, a9 as MESSAGE_TYPES, aC as MOBILE_MONEY_PROVIDER, cO as MobileMoneyData, d0 as MobileMoneyDetails, at as MobileMoneyProvider, am as NextAction, aL as ORDER_MUTATION, ax as ORDER_TYPE, db as ObservabilityHooks, aP as Ok, bi as Order, b7 as OrderChannel, bt as OrderFilter, be as OrderFulfillmentSummary, bn as OrderGroup, br as OrderGroupDetails, bo as OrderGroupPayment, bl as OrderGroupPaymentState, bm as OrderGroupPaymentStatus, bq as OrderGroupPaymentSummary, bk as OrderGroupStatus, bj as OrderHistory, b9 as OrderLineState, ba as OrderLineStatus, bs as OrderPaymentEvent, O as OrderQueries, bp as OrderSplitDetail, b5 as OrderStatus, dc as OrderType, p as OtpResult, ay as PAYMENT_METHOD, aK as PAYMENT_MUTATION, aA as PAYMENT_STATE, aB as PICKUP_TIME_TYPE, dn as ParentToIframeMessage, df as PaymentMethodInfo, b6 as PaymentState, c_ as PickupTime, cZ as PickupTimeType, D as PlaceDetailsResponse, x as PlacesService, P as PriceQuote, bG as PricingOverrides, ap as ProcessAndResolveOptions, an as ProcessCheckoutOptions, ao as ProcessCheckoutResult, cA as ProductStock, bP as ProviderResolutionSource, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, bx as RefundOrderInput, bT as RelatedCandidate, bS as RelatedProduct, bU as RelatedProductsEnrichment, bR as RelationType, bA as ReminderMethod, bD as ReminderSettings, k as ReorderResult, d5 as RequestContext, d8 as RequestErrorEvent, cW as RequestOtpInput, h as RequestSource, d6 as RequestStartEvent, d7 as RequestSuccessEvent, cq as RescheduleBookingInput, cu as RescheduleBookingResult, cx as RescheduleHistoryRecord, bJ as ResourceAssignment, aO as Result, d9 as RetryEvent, cV as RevokeAllSessionsResult, cU as RevokeSessionResult, c3 as Room, bH as SchedulingMetadata, bK as SchedulingResult, q as SchedulingService, a2 as SenderType, cb as Service, cv as ServiceAvailabilityParams, cw as ServiceAvailabilityResult, c4 as ServiceCharge, bF as ServiceNotes, bM as ServiceScheduleRequest, by as ServiceStatus, J as SessionActivityData, da as SessionChangeEvent, H as SessionMessage, ce as SlotResourceInfo, cf as SlotStaffInfo, cc as Staff, bI as StaffAssignment, bz as StaffRole, bN as StaffScheduleItem, cz as StockLevel, cy as StockStatus, c5 as StorefrontBootstrap, S as SubscriptionService, Y as SupportService, c2 as Table, a5 as TableInfo, b$ as TimeRange, c0 as TimeRanges, cd as TimeSlot, E as TrackCategoryViewOptions, T as TrackProductViewOptions, cK as UpdateAddressInput, bv as UpdateOrderStatusInput, U as UpdateProfileInput, w as UploadInitResponse, v as UploadResult, u as UploadService, cB as VariantStock, cX as VerifyOtpInput, b1 as combine, b2 as combineObject, c as createCimplifyClient, a8 as createElements, aS as err, aX as flatMap, a$ as fromPromise, m as generateIdempotencyKey, aY as getOrElse, aU as isErr, aT as isOk, aW as mapError, aV as mapResult, aR as ok, a_ as toNullable, b0 as tryCatch, aZ as unwrap } from './index-m8zGQUda.mjs';
2
2
  import { A as ApiError } from './payment-DnU_eLuT.mjs';
3
3
  export { af as AddOn, bc as AddOnDetails, bz as AddOnGroupDetails, ah as AddOnOption, by as AddOnOptionDetails, ai as AddOnOptionPrice, ag as AddOnWithOptions, bE as AddToCartInput, bK as AddressAuthorizationData, W as AddressValue, b2 as AdjustmentType, b8 as AppliedDiscount, x as AttributeAppliesTo, w as AttributeType, B as AttributeValidationRules, y as AttributeVisibility, bL as AuthorizationType, b7 as BenefitType, bU as BillingFrequency, bW as BillingMarkupType, bV as BillingPlanType, aq as Bundle, au as BundleComponentData, av as BundleComponentInfo, ax as BundleComponentVariantView, aw as BundleComponentView, ap as BundlePriceType, as as BundleProduct, bi as BundleSelectionData, bf as BundleSelectionInput, bh as BundleStoredSelection, ar as BundleSummary, at as BundleWithDetails, bn as Cart, bd as CartAddOn, b0 as CartChannel, bo as CartItem, bB as CartItemDetails, a$ as CartStatus, bG as CartSummary, bp as CartTotals, ak as Category, al as CategorySummary, C as ChosenPrice, h as CimplifyError, am as Collection, ao as CollectionProduct, an as CollectionSummary, aF as ComponentGroup, aG as ComponentGroupWithComponents, aM as ComponentPriceBreakdown, bg as ComponentSchedulingData, aK as ComponentSelectionInput, aC as ComponentSourceType, aD as Composite, aJ as CompositeComponent, aI as CompositeComponentView, aH as CompositeGroupView, bk as CompositePriceBreakdown, aL as CompositePriceResult, aA as CompositePricingMode, bl as CompositeSelectionData, aK as CompositeSelectionInput, bj as CompositeStoredSelection, aE as CompositeWithDetails, a as CurrencyCode, F as CustomAttributeDefinition, G as CustomAttributeValue, a2 as CustomerInputValue, u as DURATION_UNIT, Y as DateRangeValue, aW as Deal, aV as DealBenefitType, s as DepositType, r as DigitalProductType, b9 as DiscountBreakdown, ba as DiscountDetails, aY as DiscountValidation, bs as DisplayAddOn, bt as DisplayAddOnOption, bq as DisplayCart, br as DisplayCartItem, D as DisplayMode, t as DurationUnit, g as ERROR_HINTS, bY as EligiblePlansQuery, E as ErrorCode, e as ErrorCodeType, f as ErrorHint, L as FacetValue, bZ as FormattedPlanOption, aB as GroupPricingBehavior, U as INPUT_FIELD_TYPE, bP as InitializePaymentResult, Q as InputFieldType, a0 as InputFieldValidation, I as InventoryType, N as KnowledgeArticle, bm as LineConfiguration, aP as LocationProductPrice, _ as LocationValue, z as MeasurementValue, M as Money, p as PRODUCT_TYPE, d as Pagination, P as PaginationParams, bO as Payment, bS as PaymentErrorDetails, bN as PaymentMethod, bJ as PaymentMethodType, bM as PaymentProcessingState, bI as PaymentProvider, bQ as PaymentResponse, bH as PaymentStatus, bR as PaymentStatusResponse, X as PhoneValue, aO as Price, b3 as PriceAdjustment, b6 as PriceDecisionPath, aN as PriceEntryType, b5 as PricePathTaxInfo, b1 as PriceSource, O as Product, aj as ProductAddOn, aQ as ProductAvailability, aU as ProductAvailabilityNow, bX as ProductBillingPlan, aX as ProductDealInfo, a1 as ProductInputField, J as ProductProperty, q as ProductRenderHint, aS as ProductTaxonomy, aR as ProductTimeProfile, o as ProductType, a7 as ProductVariant, ac as ProductVariantValue, a5 as ProductWithDetails, K as PropertyFacet, H as PropertySource, a3 as QuantityPricingTier, R as RENDER_HINT, a4 as RelatedProductView, v as SalesChannel, S as SchedulingMode, bb as SelectedAddOnOption, $ as SignatureValue, bT as SubmitAuthorizationInput, b$ as Subscription, c1 as SubscriptionInvoice, c0 as SubscriptionItem, b_ as SubscriptionStatus, c2 as SubscriptionWithDetails, aZ as Tag, a_ as TagsResponse, b4 as TaxPathComponent, T as TaxonomyAttributeTemplate, aT as TaxonomyWithChildren, bC as UICart, bu as UICartBusiness, bw as UICartCustomer, bv as UICartLocation, bx as UICartPricing, bD as UICartResponse, bF as UpdateCartItemInput, a9 as VariantAxis, ae as VariantAxisSelection, ab as VariantAxisValue, az as VariantAxisValueView, ay as VariantAxisView, aa as VariantAxisWithValues, be as VariantDetails, bA as VariantDetailsDTO, a8 as VariantDisplayAttribute, ad as VariantLocationAvailability, V as VariantStrategy, a6 as VariantView, Z as ZERO, c as currencyCode, l as enrichError, k as getErrorHint, j as isCimplifyError, n as isRetryableError, i as isSupportedCurrency, m as money, b as moneyFromNumber } from './payment-DnU_eLuT.mjs';
4
4
  export { C as CURRENCY_SYMBOLS, M as MOBILE_MONEY_PROVIDERS, v as categorizePaymentError, B as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, u as formatPriceRange, j as formatPriceWithTax, e as formatProductPrice, m as getBasePrice, k as getCurrencySymbol, o as getDiscountPercentage, l as getDisplayPrice, q as getMarkupPercentage, t as getPriceRange, r as getProductCurrency, g as getTaxAmount, s as getUnitPriceAtQuantity, h as hasTaxInfo, n as isOnSale, y as isPaymentStatusFailure, z as isPaymentStatusRequiresAction, A as isPaymentStatusSuccess, i as isTaxInclusive, F as isValidPhoneForContext, w as normalizePaymentResponse, D as normalizePhoneToE164, x as normalizeStatusResponse, p as parsePrice, E as resolvePhoneCountryCode } from './index-D4oNCc37.mjs';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { aD as AUTHORIZATION_TYPE, aI as AUTH_MUTATION, as as AbortablePromise, M as ActivityRecommendation, N as ActivityRecommendationsResponse, t as ActivityService, K as ActivityStateResponse, cN as AddressData, de as AddressInfo, bg as AmountToPay, cY as AuthResponse, A as AuthService, o as AuthStatus, dg as AuthenticatedCustomer, di as AuthenticatedData, y as AutocompletePrediction, z as AutocompleteResponse, cD as AvailabilityResult, cg as AvailableSlot, cj as Booking, ct as BookingModificationType, ci as BookingStatus, ck as BookingWithDetails, bC as BufferTimes, bX as Business, c9 as BusinessHours, bW as BusinessPreferences, B as BusinessService, c8 as BusinessSettings, bV as BusinessType, c6 as BusinessWithLocations, aw as CHECKOUT_MODE, aJ as CHECKOUT_MUTATION, az as CHECKOUT_STEP, aF as CONTACT_TYPE, cr as CancelBookingInput, cs as CancelBookingResult, bw as CancelOrderInput, bE as CancellationPolicy, j as CartOperations, b as CatalogueQueries, b3 as CatalogueResult, b4 as CatalogueSnapshot, ca as CategoryInfo, a0 as ChatAttachment, _ as ChatConversation, $ as ChatConversationResponse, Z as ChatMessage, a1 as ChatWidgetStarter, co as CheckSlotAvailabilityInput, cp as CheckSlotAvailabilityResult, c$ as CheckoutAddressInfo, dm as CheckoutCartData, dl as CheckoutCartItem, d1 as CheckoutCustomerInfo, ak as CheckoutFormData, bu as CheckoutInput, ag as CheckoutMode, l as CheckoutOperations, ah as CheckoutOrderType, ai as CheckoutPaymentMethod, al as CheckoutResult, l as CheckoutService, aq as CheckoutStatus, ar as CheckoutStatusContext, aj as CheckoutStep, C as CimplifyClient, a as CimplifyConfig, a7 as CimplifyElement, a6 as CimplifyElements, av as ContactType, a3 as ContentType, cJ as CreateAddressInput, cL as CreateMobileMoneyInput, cE as Customer, cF as CustomerAddress, cm as CustomerBooking, cl as CustomerBookingServiceItem, cH as CustomerLinkPreferences, cG as CustomerMobileMoney, bB as CustomerServicePreferences, aN as DEFAULT_COUNTRY, aM as DEFAULT_CURRENCY, aE as DEVICE_TYPE, ch as DayAvailability, bQ as DeliveryFeeDetails, X as DeliveryFeeResponse, W as DeliveryService, bL as DepositResult, au as DeviceType, V as DismissMessageResponse, ab as ELEMENT_TYPES, aa as EVENT_TYPES, dd as ElementAppearance, dq as ElementEventHandler, af as ElementEventType, ad as ElementOptions, ae as ElementType, dj as ElementsCheckoutData, dk as ElementsCheckoutResult, dh as ElementsCustomerInfo, ac as ElementsOptions, cP as EnrollAndLinkOrderInput, cS as EnrollAndLinkOrderResult, cM as EnrollmentData, aQ as Err, bf as FeeBearerType, F as FetchQuoteInput, bd as FulfillmentLink, bc as FulfillmentStatus, bb as FulfillmentType, d3 as FxQuote, d2 as FxQuoteRequest, d4 as FxRateResponse, s as FxService, cn as GetAvailableSlotsInput, n as GetOrdersOptions, G as GetProductsOptions, dp as IframeToParentMessage, I as InventoryService, aH as LINK_MUTATION, aG as LINK_QUERY, bh as LineItem, b8 as LineType, cI as LinkData, cR as LinkEnrollResult, L as LinkService, cT as LinkSession, cQ as LinkStatusResult, a4 as LiteBootstrap, r as LiteService, b_ as Location, bO as LocationBooking, cC as LocationStock, bY as LocationTaxBehavior, bZ as LocationTaxOverrides, c1 as LocationTimeProfile, c7 as LocationWithDetails, a9 as MESSAGE_TYPES, aC as MOBILE_MONEY_PROVIDER, cO as MobileMoneyData, d0 as MobileMoneyDetails, at as MobileMoneyProvider, am as NextAction, aL as ORDER_MUTATION, ax as ORDER_TYPE, db as ObservabilityHooks, aP as Ok, bi as Order, b7 as OrderChannel, bt as OrderFilter, be as OrderFulfillmentSummary, bn as OrderGroup, br as OrderGroupDetails, bo as OrderGroupPayment, bl as OrderGroupPaymentState, bm as OrderGroupPaymentStatus, bq as OrderGroupPaymentSummary, bk as OrderGroupStatus, bj as OrderHistory, b9 as OrderLineState, ba as OrderLineStatus, bs as OrderPaymentEvent, O as OrderQueries, bp as OrderSplitDetail, b5 as OrderStatus, dc as OrderType, p as OtpResult, ay as PAYMENT_METHOD, aK as PAYMENT_MUTATION, aA as PAYMENT_STATE, aB as PICKUP_TIME_TYPE, dn as ParentToIframeMessage, df as PaymentMethodInfo, b6 as PaymentState, c_ as PickupTime, cZ as PickupTimeType, D as PlaceDetailsResponse, x as PlacesService, P as PriceQuote, bG as PricingOverrides, ap as ProcessAndResolveOptions, an as ProcessCheckoutOptions, ao as ProcessCheckoutResult, cA as ProductStock, bP as ProviderResolutionSource, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, bx as RefundOrderInput, bT as RelatedCandidate, bS as RelatedProduct, bU as RelatedProductsEnrichment, bR as RelationType, bA as ReminderMethod, bD as ReminderSettings, k as ReorderResult, d5 as RequestContext, d8 as RequestErrorEvent, cW as RequestOtpInput, h as RequestSource, d6 as RequestStartEvent, d7 as RequestSuccessEvent, cq as RescheduleBookingInput, cu as RescheduleBookingResult, cx as RescheduleHistoryRecord, bJ as ResourceAssignment, aO as Result, d9 as RetryEvent, cV as RevokeAllSessionsResult, cU as RevokeSessionResult, c3 as Room, bH as SchedulingMetadata, bK as SchedulingResult, q as SchedulingService, a2 as SenderType, cb as Service, cv as ServiceAvailabilityParams, cw as ServiceAvailabilityResult, c4 as ServiceCharge, bF as ServiceNotes, bM as ServiceScheduleRequest, by as ServiceStatus, J as SessionActivityData, da as SessionChangeEvent, H as SessionMessage, ce as SlotResourceInfo, cf as SlotStaffInfo, cc as Staff, bI as StaffAssignment, bz as StaffRole, bN as StaffScheduleItem, cz as StockLevel, cy as StockStatus, c5 as StorefrontBootstrap, S as SubscriptionService, Y as SupportService, c2 as Table, a5 as TableInfo, b$ as TimeRange, c0 as TimeRanges, cd as TimeSlot, E as TrackCategoryViewOptions, T as TrackProductViewOptions, cK as UpdateAddressInput, bv as UpdateOrderStatusInput, U as UpdateProfileInput, w as UploadInitResponse, v as UploadResult, u as UploadService, cB as VariantStock, cX as VerifyOtpInput, b1 as combine, b2 as combineObject, c as createCimplifyClient, a8 as createElements, aS as err, aX as flatMap, a$ as fromPromise, m as generateIdempotencyKey, aY as getOrElse, aU as isErr, aT as isOk, aW as mapError, aV as mapResult, aR as ok, a_ as toNullable, b0 as tryCatch, aZ as unwrap } from './index-DTdtu4OO.js';
1
+ export { aD as AUTHORIZATION_TYPE, aI as AUTH_MUTATION, as as AbortablePromise, M as ActivityRecommendation, N as ActivityRecommendationsResponse, t as ActivityService, K as ActivityStateResponse, cN as AddressData, de as AddressInfo, bg as AmountToPay, cY as AuthResponse, A as AuthService, o as AuthStatus, dg as AuthenticatedCustomer, di as AuthenticatedData, y as AutocompletePrediction, z as AutocompleteResponse, cD as AvailabilityResult, cg as AvailableSlot, cj as Booking, ct as BookingModificationType, ci as BookingStatus, ck as BookingWithDetails, bC as BufferTimes, bX as Business, c9 as BusinessHours, bW as BusinessPreferences, B as BusinessService, c8 as BusinessSettings, bV as BusinessType, c6 as BusinessWithLocations, aw as CHECKOUT_MODE, aJ as CHECKOUT_MUTATION, az as CHECKOUT_STEP, aF as CONTACT_TYPE, cr as CancelBookingInput, cs as CancelBookingResult, bw as CancelOrderInput, bE as CancellationPolicy, j as CartOperations, b as CatalogueQueries, b3 as CatalogueResult, b4 as CatalogueSnapshot, ca as CategoryInfo, a0 as ChatAttachment, _ as ChatConversation, $ as ChatConversationResponse, Z as ChatMessage, a1 as ChatWidgetStarter, co as CheckSlotAvailabilityInput, cp as CheckSlotAvailabilityResult, c$ as CheckoutAddressInfo, dm as CheckoutCartData, dl as CheckoutCartItem, d1 as CheckoutCustomerInfo, ak as CheckoutFormData, bu as CheckoutInput, ag as CheckoutMode, l as CheckoutOperations, ah as CheckoutOrderType, ai as CheckoutPaymentMethod, al as CheckoutResult, l as CheckoutService, aq as CheckoutStatus, ar as CheckoutStatusContext, aj as CheckoutStep, C as CimplifyClient, a as CimplifyConfig, a7 as CimplifyElement, a6 as CimplifyElements, av as ContactType, a3 as ContentType, cJ as CreateAddressInput, cL as CreateMobileMoneyInput, cE as Customer, cF as CustomerAddress, cm as CustomerBooking, cl as CustomerBookingServiceItem, cH as CustomerLinkPreferences, cG as CustomerMobileMoney, bB as CustomerServicePreferences, aN as DEFAULT_COUNTRY, aM as DEFAULT_CURRENCY, aE as DEVICE_TYPE, ch as DayAvailability, bQ as DeliveryFeeDetails, X as DeliveryFeeResponse, W as DeliveryService, bL as DepositResult, au as DeviceType, V as DismissMessageResponse, ab as ELEMENT_TYPES, aa as EVENT_TYPES, dd as ElementAppearance, dq as ElementEventHandler, af as ElementEventType, ad as ElementOptions, ae as ElementType, dj as ElementsCheckoutData, dk as ElementsCheckoutResult, dh as ElementsCustomerInfo, ac as ElementsOptions, cP as EnrollAndLinkOrderInput, cS as EnrollAndLinkOrderResult, cM as EnrollmentData, aQ as Err, bf as FeeBearerType, F as FetchQuoteInput, bd as FulfillmentLink, bc as FulfillmentStatus, bb as FulfillmentType, d3 as FxQuote, d2 as FxQuoteRequest, d4 as FxRateResponse, s as FxService, cn as GetAvailableSlotsInput, n as GetOrdersOptions, G as GetProductsOptions, dp as IframeToParentMessage, I as InventoryService, aH as LINK_MUTATION, aG as LINK_QUERY, bh as LineItem, b8 as LineType, cI as LinkData, cR as LinkEnrollResult, L as LinkService, cT as LinkSession, cQ as LinkStatusResult, a4 as LiteBootstrap, r as LiteService, b_ as Location, bO as LocationBooking, cC as LocationStock, bY as LocationTaxBehavior, bZ as LocationTaxOverrides, c1 as LocationTimeProfile, c7 as LocationWithDetails, a9 as MESSAGE_TYPES, aC as MOBILE_MONEY_PROVIDER, cO as MobileMoneyData, d0 as MobileMoneyDetails, at as MobileMoneyProvider, am as NextAction, aL as ORDER_MUTATION, ax as ORDER_TYPE, db as ObservabilityHooks, aP as Ok, bi as Order, b7 as OrderChannel, bt as OrderFilter, be as OrderFulfillmentSummary, bn as OrderGroup, br as OrderGroupDetails, bo as OrderGroupPayment, bl as OrderGroupPaymentState, bm as OrderGroupPaymentStatus, bq as OrderGroupPaymentSummary, bk as OrderGroupStatus, bj as OrderHistory, b9 as OrderLineState, ba as OrderLineStatus, bs as OrderPaymentEvent, O as OrderQueries, bp as OrderSplitDetail, b5 as OrderStatus, dc as OrderType, p as OtpResult, ay as PAYMENT_METHOD, aK as PAYMENT_MUTATION, aA as PAYMENT_STATE, aB as PICKUP_TIME_TYPE, dn as ParentToIframeMessage, df as PaymentMethodInfo, b6 as PaymentState, c_ as PickupTime, cZ as PickupTimeType, D as PlaceDetailsResponse, x as PlacesService, P as PriceQuote, bG as PricingOverrides, ap as ProcessAndResolveOptions, an as ProcessCheckoutOptions, ao as ProcessCheckoutResult, cA as ProductStock, bP as ProviderResolutionSource, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, bx as RefundOrderInput, bT as RelatedCandidate, bS as RelatedProduct, bU as RelatedProductsEnrichment, bR as RelationType, bA as ReminderMethod, bD as ReminderSettings, k as ReorderResult, d5 as RequestContext, d8 as RequestErrorEvent, cW as RequestOtpInput, h as RequestSource, d6 as RequestStartEvent, d7 as RequestSuccessEvent, cq as RescheduleBookingInput, cu as RescheduleBookingResult, cx as RescheduleHistoryRecord, bJ as ResourceAssignment, aO as Result, d9 as RetryEvent, cV as RevokeAllSessionsResult, cU as RevokeSessionResult, c3 as Room, bH as SchedulingMetadata, bK as SchedulingResult, q as SchedulingService, a2 as SenderType, cb as Service, cv as ServiceAvailabilityParams, cw as ServiceAvailabilityResult, c4 as ServiceCharge, bF as ServiceNotes, bM as ServiceScheduleRequest, by as ServiceStatus, J as SessionActivityData, da as SessionChangeEvent, H as SessionMessage, ce as SlotResourceInfo, cf as SlotStaffInfo, cc as Staff, bI as StaffAssignment, bz as StaffRole, bN as StaffScheduleItem, cz as StockLevel, cy as StockStatus, c5 as StorefrontBootstrap, S as SubscriptionService, Y as SupportService, c2 as Table, a5 as TableInfo, b$ as TimeRange, c0 as TimeRanges, cd as TimeSlot, E as TrackCategoryViewOptions, T as TrackProductViewOptions, cK as UpdateAddressInput, bv as UpdateOrderStatusInput, U as UpdateProfileInput, w as UploadInitResponse, v as UploadResult, u as UploadService, cB as VariantStock, cX as VerifyOtpInput, b1 as combine, b2 as combineObject, c as createCimplifyClient, a8 as createElements, aS as err, aX as flatMap, a$ as fromPromise, m as generateIdempotencyKey, aY as getOrElse, aU as isErr, aT as isOk, aW as mapError, aV as mapResult, aR as ok, a_ as toNullable, b0 as tryCatch, aZ as unwrap } from './index-BpyFcJVv.js';
2
2
  import { A as ApiError } from './payment-DnU_eLuT.js';
3
3
  export { af as AddOn, bc as AddOnDetails, bz as AddOnGroupDetails, ah as AddOnOption, by as AddOnOptionDetails, ai as AddOnOptionPrice, ag as AddOnWithOptions, bE as AddToCartInput, bK as AddressAuthorizationData, W as AddressValue, b2 as AdjustmentType, b8 as AppliedDiscount, x as AttributeAppliesTo, w as AttributeType, B as AttributeValidationRules, y as AttributeVisibility, bL as AuthorizationType, b7 as BenefitType, bU as BillingFrequency, bW as BillingMarkupType, bV as BillingPlanType, aq as Bundle, au as BundleComponentData, av as BundleComponentInfo, ax as BundleComponentVariantView, aw as BundleComponentView, ap as BundlePriceType, as as BundleProduct, bi as BundleSelectionData, bf as BundleSelectionInput, bh as BundleStoredSelection, ar as BundleSummary, at as BundleWithDetails, bn as Cart, bd as CartAddOn, b0 as CartChannel, bo as CartItem, bB as CartItemDetails, a$ as CartStatus, bG as CartSummary, bp as CartTotals, ak as Category, al as CategorySummary, C as ChosenPrice, h as CimplifyError, am as Collection, ao as CollectionProduct, an as CollectionSummary, aF as ComponentGroup, aG as ComponentGroupWithComponents, aM as ComponentPriceBreakdown, bg as ComponentSchedulingData, aK as ComponentSelectionInput, aC as ComponentSourceType, aD as Composite, aJ as CompositeComponent, aI as CompositeComponentView, aH as CompositeGroupView, bk as CompositePriceBreakdown, aL as CompositePriceResult, aA as CompositePricingMode, bl as CompositeSelectionData, aK as CompositeSelectionInput, bj as CompositeStoredSelection, aE as CompositeWithDetails, a as CurrencyCode, F as CustomAttributeDefinition, G as CustomAttributeValue, a2 as CustomerInputValue, u as DURATION_UNIT, Y as DateRangeValue, aW as Deal, aV as DealBenefitType, s as DepositType, r as DigitalProductType, b9 as DiscountBreakdown, ba as DiscountDetails, aY as DiscountValidation, bs as DisplayAddOn, bt as DisplayAddOnOption, bq as DisplayCart, br as DisplayCartItem, D as DisplayMode, t as DurationUnit, g as ERROR_HINTS, bY as EligiblePlansQuery, E as ErrorCode, e as ErrorCodeType, f as ErrorHint, L as FacetValue, bZ as FormattedPlanOption, aB as GroupPricingBehavior, U as INPUT_FIELD_TYPE, bP as InitializePaymentResult, Q as InputFieldType, a0 as InputFieldValidation, I as InventoryType, N as KnowledgeArticle, bm as LineConfiguration, aP as LocationProductPrice, _ as LocationValue, z as MeasurementValue, M as Money, p as PRODUCT_TYPE, d as Pagination, P as PaginationParams, bO as Payment, bS as PaymentErrorDetails, bN as PaymentMethod, bJ as PaymentMethodType, bM as PaymentProcessingState, bI as PaymentProvider, bQ as PaymentResponse, bH as PaymentStatus, bR as PaymentStatusResponse, X as PhoneValue, aO as Price, b3 as PriceAdjustment, b6 as PriceDecisionPath, aN as PriceEntryType, b5 as PricePathTaxInfo, b1 as PriceSource, O as Product, aj as ProductAddOn, aQ as ProductAvailability, aU as ProductAvailabilityNow, bX as ProductBillingPlan, aX as ProductDealInfo, a1 as ProductInputField, J as ProductProperty, q as ProductRenderHint, aS as ProductTaxonomy, aR as ProductTimeProfile, o as ProductType, a7 as ProductVariant, ac as ProductVariantValue, a5 as ProductWithDetails, K as PropertyFacet, H as PropertySource, a3 as QuantityPricingTier, R as RENDER_HINT, a4 as RelatedProductView, v as SalesChannel, S as SchedulingMode, bb as SelectedAddOnOption, $ as SignatureValue, bT as SubmitAuthorizationInput, b$ as Subscription, c1 as SubscriptionInvoice, c0 as SubscriptionItem, b_ as SubscriptionStatus, c2 as SubscriptionWithDetails, aZ as Tag, a_ as TagsResponse, b4 as TaxPathComponent, T as TaxonomyAttributeTemplate, aT as TaxonomyWithChildren, bC as UICart, bu as UICartBusiness, bw as UICartCustomer, bv as UICartLocation, bx as UICartPricing, bD as UICartResponse, bF as UpdateCartItemInput, a9 as VariantAxis, ae as VariantAxisSelection, ab as VariantAxisValue, az as VariantAxisValueView, ay as VariantAxisView, aa as VariantAxisWithValues, be as VariantDetails, bA as VariantDetailsDTO, a8 as VariantDisplayAttribute, ad as VariantLocationAvailability, V as VariantStrategy, a6 as VariantView, Z as ZERO, c as currencyCode, l as enrichError, k as getErrorHint, j as isCimplifyError, n as isRetryableError, i as isSupportedCurrency, m as money, b as moneyFromNumber } from './payment-DnU_eLuT.js';
4
4
  export { C as CURRENCY_SYMBOLS, M as MOBILE_MONEY_PROVIDERS, v as categorizePaymentError, B as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, u as formatPriceRange, j as formatPriceWithTax, e as formatProductPrice, m as getBasePrice, k as getCurrencySymbol, o as getDiscountPercentage, l as getDisplayPrice, q as getMarkupPercentage, t as getPriceRange, r as getProductCurrency, g as getTaxAmount, s as getUnitPriceAtQuantity, h as hasTaxInfo, n as isOnSale, y as isPaymentStatusFailure, z as isPaymentStatusRequiresAction, A as isPaymentStatusSuccess, i as isTaxInclusive, F as isValidPhoneForContext, w as normalizePaymentResponse, D as normalizePhoneToE164, x as normalizeStatusResponse, p as parsePrice, E as resolvePhoneCountryCode } from './index-BHVJgyqM.js';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkF47XFKYP_js = require('./chunk-F47XFKYP.js');
3
+ var chunk6HCBOIZ4_js = require('./chunk-6HCBOIZ4.js');
4
4
  var chunkL5GKVQVJ_js = require('./chunk-L5GKVQVJ.js');
5
5
  var chunk2CGA3MUW_js = require('./chunk-2CGA3MUW.js');
6
6
  var chunkPEDLCL72_js = require('./chunk-PEDLCL72.js');
@@ -9,55 +9,55 @@ var chunkPEDLCL72_js = require('./chunk-PEDLCL72.js');
9
9
 
10
10
  Object.defineProperty(exports, "ActivityService", {
11
11
  enumerable: true,
12
- get: function () { return chunkF47XFKYP_js.ActivityService; }
12
+ get: function () { return chunk6HCBOIZ4_js.ActivityService; }
13
13
  });
14
14
  Object.defineProperty(exports, "CimplifyClient", {
15
15
  enumerable: true,
16
- get: function () { return chunkF47XFKYP_js.CimplifyClient; }
16
+ get: function () { return chunk6HCBOIZ4_js.CimplifyClient; }
17
17
  });
18
18
  Object.defineProperty(exports, "DURATION_UNIT", {
19
19
  enumerable: true,
20
- get: function () { return chunkF47XFKYP_js.DURATION_UNIT; }
20
+ get: function () { return chunk6HCBOIZ4_js.DURATION_UNIT; }
21
21
  });
22
22
  Object.defineProperty(exports, "DeliveryService", {
23
23
  enumerable: true,
24
- get: function () { return chunkF47XFKYP_js.DeliveryService; }
24
+ get: function () { return chunk6HCBOIZ4_js.DeliveryService; }
25
25
  });
26
26
  Object.defineProperty(exports, "INPUT_FIELD_TYPE", {
27
27
  enumerable: true,
28
- get: function () { return chunkF47XFKYP_js.INPUT_FIELD_TYPE; }
28
+ get: function () { return chunk6HCBOIZ4_js.INPUT_FIELD_TYPE; }
29
29
  });
30
30
  Object.defineProperty(exports, "PRODUCT_TYPE", {
31
31
  enumerable: true,
32
- get: function () { return chunkF47XFKYP_js.PRODUCT_TYPE; }
32
+ get: function () { return chunk6HCBOIZ4_js.PRODUCT_TYPE; }
33
33
  });
34
34
  Object.defineProperty(exports, "PlacesService", {
35
35
  enumerable: true,
36
- get: function () { return chunkF47XFKYP_js.PlacesService; }
36
+ get: function () { return chunk6HCBOIZ4_js.PlacesService; }
37
37
  });
38
38
  Object.defineProperty(exports, "RENDER_HINT", {
39
39
  enumerable: true,
40
- get: function () { return chunkF47XFKYP_js.RENDER_HINT; }
40
+ get: function () { return chunk6HCBOIZ4_js.RENDER_HINT; }
41
41
  });
42
42
  Object.defineProperty(exports, "SubscriptionService", {
43
43
  enumerable: true,
44
- get: function () { return chunkF47XFKYP_js.SubscriptionService; }
44
+ get: function () { return chunk6HCBOIZ4_js.SubscriptionService; }
45
45
  });
46
46
  Object.defineProperty(exports, "SupportService", {
47
47
  enumerable: true,
48
- get: function () { return chunkF47XFKYP_js.SupportService; }
48
+ get: function () { return chunk6HCBOIZ4_js.SupportService; }
49
49
  });
50
50
  Object.defineProperty(exports, "UploadService", {
51
51
  enumerable: true,
52
- get: function () { return chunkF47XFKYP_js.UploadService; }
52
+ get: function () { return chunk6HCBOIZ4_js.UploadService; }
53
53
  });
54
54
  Object.defineProperty(exports, "createCimplifyClient", {
55
55
  enumerable: true,
56
- get: function () { return chunkF47XFKYP_js.createCimplifyClient; }
56
+ get: function () { return chunk6HCBOIZ4_js.createCimplifyClient; }
57
57
  });
58
58
  Object.defineProperty(exports, "getVariantDisplayName", {
59
59
  enumerable: true,
60
- get: function () { return chunkF47XFKYP_js.getVariantDisplayName; }
60
+ get: function () { return chunk6HCBOIZ4_js.getVariantDisplayName; }
61
61
  });
62
62
  Object.defineProperty(exports, "isValidPhoneForContext", {
63
63
  enumerable: true,
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { ActivityService, CimplifyClient, DURATION_UNIT, DeliveryService, INPUT_FIELD_TYPE, PRODUCT_TYPE, PlacesService, RENDER_HINT, SubscriptionService, SupportService, UploadService, createCimplifyClient, getVariantDisplayName } from './chunk-WGAVNFEQ.mjs';
1
+ export { ActivityService, CimplifyClient, DURATION_UNIT, DeliveryService, INPUT_FIELD_TYPE, PRODUCT_TYPE, PlacesService, RENDER_HINT, SubscriptionService, SupportService, UploadService, createCimplifyClient, getVariantDisplayName } from './chunk-46BDUSJX.mjs';
2
2
  export { isValidPhoneForContext, normalizePhoneToE164, resolvePhoneCountryCode } from './chunk-YOIVZ6OA.mjs';
3
3
  export { AUTHORIZATION_TYPE, AUTH_MUTATION, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CONTACT_TYPE, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, DEFAULT_COUNTRY, DEFAULT_CURRENCY, DEVICE_TYPE, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MESSAGE_TYPES, MOBILE_MONEY_PROVIDER, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, SchedulingService, combine, combineObject, createElements, err, flatMap, fromPromise, generateIdempotencyKey, getOrElse, isErr, isOk, mapError, mapResult, ok, toNullable, tryCatch, unwrap } from './chunk-3J4PPSMI.mjs';
4
4
  export { CURRENCY_SYMBOLS, CimplifyError, ERROR_HINTS, ErrorCode, MOBILE_MONEY_PROVIDERS, ZERO, categorizePaymentError, currencyCode, detectMobileMoneyProvider, enrichError, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatPriceRange, formatPriceWithTax, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getErrorHint, getMarkupPercentage, getPriceRange, getProductCurrency, getTaxAmount, getUnitPriceAtQuantity, hasTaxInfo, isCimplifyError, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isRetryableError, isSupportedCurrency, isTaxInclusive, money, moneyFromNumber, normalizePaymentResponse, normalizeStatusResponse, parsePrice } from './chunk-E3HC2YAE.mjs';
package/dist/react.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React$1, { ReactNode } from 'react';
2
2
  import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-BxbWrwqp.mjs';
3
3
  export { c as AdConfig, g as getVariantDisplayName } from './ads-BxbWrwqp.mjs';
4
- import { C as CimplifyClient, ao as ProcessCheckoutResult, aq as CheckoutStatus, ar as CheckoutStatusContext, b_ as Location, bX as Business, k as ReorderResult, b5 as OrderStatus, bi as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, cb as Service, cg as AvailableSlot, ch as DayAvailability, cm as CustomerBooking, cs as CancelBookingResult, K as ActivityStateResponse, H as SessionMessage, M as ActivityRecommendation, X as DeliveryFeeResponse, d4 as FxRateResponse, c5 as StorefrontBootstrap, a1 as ChatWidgetStarter, Z as ChatMessage, ac as ElementsOptions, di as AuthenticatedData, de as AddressInfo, df as PaymentMethodInfo, a6 as CimplifyElements, dk as ElementsCheckoutResult, an as ProcessCheckoutOptions, bh as LineItem, cc as Staff, c3 as Room } from './index-DaXyvlxk.mjs';
4
+ import { C as CimplifyClient, ao as ProcessCheckoutResult, aq as CheckoutStatus, ar as CheckoutStatusContext, b_ as Location, bX as Business, k as ReorderResult, b5 as OrderStatus, bi as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, cb as Service, cg as AvailableSlot, ch as DayAvailability, cm as CustomerBooking, cs as CancelBookingResult, K as ActivityStateResponse, H as SessionMessage, M as ActivityRecommendation, X as DeliveryFeeResponse, d4 as FxRateResponse, c5 as StorefrontBootstrap, a1 as ChatWidgetStarter, Z as ChatMessage, ac as ElementsOptions, di as AuthenticatedData, de as AddressInfo, df as PaymentMethodInfo, a6 as CimplifyElements, dk as ElementsCheckoutResult, an as ProcessCheckoutOptions, bh as LineItem, cc as Staff, c3 as Room } from './index-m8zGQUda.mjs';
5
5
  import { a as CurrencyCode, O as Product, d as Pagination, h as CimplifyError, a5 as ProductWithDetails, ak as Category, M as Money, bf as BundleSelectionInput, aK as ComponentSelectionInput, bi as BundleSelectionData, bl as CompositeSelectionData, am as Collection, aS as ProductTaxonomy, aT as TaxonomyWithChildren, aR as ProductTimeProfile, aW as Deal, aX as ProductDealInfo, aY as DiscountValidation, ar as BundleSummary, aL as CompositePriceResult, b_ as SubscriptionStatus, b$ as Subscription, c2 as SubscriptionWithDetails, F as CustomAttributeDefinition, K as PropertyFacet, bX as ProductBillingPlan, a6 as VariantView, aa as VariantAxisWithValues, ag as AddOnWithOptions, aw as BundleComponentView, ap as BundlePriceType, aH as CompositeGroupView, bq as DisplayCart, a1 as ProductInputField, G as CustomAttributeValue, J as ProductProperty, a3 as QuantityPricingTier } from './payment-DnU_eLuT.mjs';
6
6
  import { P as ProductWithPrice } from './price-D-hso3np.mjs';
7
7
  import { ClassValue } from 'clsx';
@@ -749,7 +749,6 @@ interface UseChatResult {
749
749
  isLoading: boolean;
750
750
  isSending: boolean;
751
751
  error: CimplifyError | null;
752
- /** True once the conversation has been opened and has messages */
753
752
  isActive: boolean;
754
753
  send: (content: string) => Promise<void>;
755
754
  startConversation: (starterText?: string) => Promise<void>;
package/dist/react.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React$1, { ReactNode } from 'react';
2
2
  import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-BxbWrwqp.js';
3
3
  export { c as AdConfig, g as getVariantDisplayName } from './ads-BxbWrwqp.js';
4
- import { C as CimplifyClient, ao as ProcessCheckoutResult, aq as CheckoutStatus, ar as CheckoutStatusContext, b_ as Location, bX as Business, k as ReorderResult, b5 as OrderStatus, bi as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, cb as Service, cg as AvailableSlot, ch as DayAvailability, cm as CustomerBooking, cs as CancelBookingResult, K as ActivityStateResponse, H as SessionMessage, M as ActivityRecommendation, X as DeliveryFeeResponse, d4 as FxRateResponse, c5 as StorefrontBootstrap, a1 as ChatWidgetStarter, Z as ChatMessage, ac as ElementsOptions, di as AuthenticatedData, de as AddressInfo, df as PaymentMethodInfo, a6 as CimplifyElements, dk as ElementsCheckoutResult, an as ProcessCheckoutOptions, bh as LineItem, cc as Staff, c3 as Room } from './index-DTdtu4OO.js';
4
+ import { C as CimplifyClient, ao as ProcessCheckoutResult, aq as CheckoutStatus, ar as CheckoutStatusContext, b_ as Location, bX as Business, k as ReorderResult, b5 as OrderStatus, bi as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, cb as Service, cg as AvailableSlot, ch as DayAvailability, cm as CustomerBooking, cs as CancelBookingResult, K as ActivityStateResponse, H as SessionMessage, M as ActivityRecommendation, X as DeliveryFeeResponse, d4 as FxRateResponse, c5 as StorefrontBootstrap, a1 as ChatWidgetStarter, Z as ChatMessage, ac as ElementsOptions, di as AuthenticatedData, de as AddressInfo, df as PaymentMethodInfo, a6 as CimplifyElements, dk as ElementsCheckoutResult, an as ProcessCheckoutOptions, bh as LineItem, cc as Staff, c3 as Room } from './index-BpyFcJVv.js';
5
5
  import { a as CurrencyCode, O as Product, d as Pagination, h as CimplifyError, a5 as ProductWithDetails, ak as Category, M as Money, bf as BundleSelectionInput, aK as ComponentSelectionInput, bi as BundleSelectionData, bl as CompositeSelectionData, am as Collection, aS as ProductTaxonomy, aT as TaxonomyWithChildren, aR as ProductTimeProfile, aW as Deal, aX as ProductDealInfo, aY as DiscountValidation, ar as BundleSummary, aL as CompositePriceResult, b_ as SubscriptionStatus, b$ as Subscription, c2 as SubscriptionWithDetails, F as CustomAttributeDefinition, K as PropertyFacet, bX as ProductBillingPlan, a6 as VariantView, aa as VariantAxisWithValues, ag as AddOnWithOptions, aw as BundleComponentView, ap as BundlePriceType, aH as CompositeGroupView, bq as DisplayCart, a1 as ProductInputField, G as CustomAttributeValue, J as ProductProperty, a3 as QuantityPricingTier } from './payment-DnU_eLuT.js';
6
6
  import { P as ProductWithPrice } from './price-DUVmRTaz.js';
7
7
  import { ClassValue } from 'clsx';
@@ -749,7 +749,6 @@ interface UseChatResult {
749
749
  isLoading: boolean;
750
750
  isSending: boolean;
751
751
  error: CimplifyError | null;
752
- /** True once the conversation has been opened and has messages */
753
752
  isActive: boolean;
754
753
  send: (content: string) => Promise<void>;
755
754
  startConversation: (starterText?: string) => Promise<void>;
package/dist/react.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkF47XFKYP_js = require('./chunk-F47XFKYP.js');
4
+ var chunk6HCBOIZ4_js = require('./chunk-6HCBOIZ4.js');
5
5
  var chunk2CGA3MUW_js = require('./chunk-2CGA3MUW.js');
6
6
  var chunkPEDLCL72_js = require('./chunk-PEDLCL72.js');
7
7
  var React10 = require('react');
@@ -1063,7 +1063,7 @@ var DEFAULT_COUNTRY = "US";
1063
1063
  function createDefaultClient() {
1064
1064
  const processRef = globalThis.process;
1065
1065
  const envPublicKey = processRef?.env?.NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY || "";
1066
- return chunkF47XFKYP_js.createCimplifyClient({ publicKey: envPublicKey });
1066
+ return chunk6HCBOIZ4_js.createCimplifyClient({ publicKey: envPublicKey });
1067
1067
  }
1068
1068
  function getStoredLocationId() {
1069
1069
  if (typeof window === "undefined" || !window.localStorage) {
@@ -3318,6 +3318,8 @@ function useBootstrap(options = {}) {
3318
3318
  var POLL_INTERVAL_MS = 3e3;
3319
3319
  var POLL_IDLE_INTERVAL_MS = 15e3;
3320
3320
  var IDLE_TIMEOUT_MS = 6e4;
3321
+ var WS_MAX_RECONNECT_ATTEMPTS = 10;
3322
+ var WS_PATH = "/api/v1/support/conversation/ws";
3321
3323
  function useChat(options = {}) {
3322
3324
  const context = useOptionalCimplifyClient();
3323
3325
  const client = options.client ?? context?.client;
@@ -3330,26 +3332,34 @@ function useChat(options = {}) {
3330
3332
  const lastActivityRef = React10.useRef(Date.now());
3331
3333
  const openedRef = React10.useRef(false);
3332
3334
  const messagesRef = React10.useRef([]);
3335
+ const clientRef = React10.useRef(client);
3336
+ const wsRef = React10.useRef(null);
3337
+ const wsReconnectAttemptRef = React10.useRef(0);
3338
+ const wsReconnectTimerRef = React10.useRef(null);
3333
3339
  messagesRef.current = messages;
3340
+ clientRef.current = client;
3334
3341
  const pollInterval = options.pollInterval ?? POLL_INTERVAL_MS;
3335
3342
  const pollIdleInterval = options.pollIdleInterval ?? POLL_IDLE_INTERVAL_MS;
3343
+ const appendMessages = React10.useCallback((incoming) => {
3344
+ setMessages((prev) => {
3345
+ const ids = new Set(prev.map((m) => m.id));
3346
+ const fresh = incoming.filter((m) => !ids.has(m.id));
3347
+ return fresh.length > 0 ? [...prev, ...fresh] : prev;
3348
+ });
3349
+ }, []);
3336
3350
  const pollMessages = React10.useCallback(async () => {
3337
- if (!client) return;
3338
- const isIdle = Date.now() - lastActivityRef.current > IDLE_TIMEOUT_MS;
3339
- if (isIdle) return;
3351
+ const c = clientRef.current;
3352
+ if (!c) return;
3353
+ if (Date.now() - lastActivityRef.current > IDLE_TIMEOUT_MS) return;
3340
3354
  const last = messagesRef.current[messagesRef.current.length - 1];
3341
- const result = await client.support.getMessages({
3355
+ const result = await c.support.getMessages({
3342
3356
  after: last?.created_at,
3343
3357
  limit: 50
3344
3358
  });
3345
3359
  if (result.ok && result.value.length > 0) {
3346
- setMessages((prev) => {
3347
- const ids = new Set(prev.map((m) => m.id));
3348
- const fresh = result.value.filter((m) => !ids.has(m.id));
3349
- return fresh.length > 0 ? [...prev, ...fresh] : prev;
3350
- });
3360
+ appendMessages(result.value);
3351
3361
  }
3352
- }, [client]);
3362
+ }, [appendMessages]);
3353
3363
  const startPolling = React10.useCallback(() => {
3354
3364
  if (pollRef.current) clearInterval(pollRef.current);
3355
3365
  const interval = Date.now() - lastActivityRef.current > IDLE_TIMEOUT_MS ? pollIdleInterval : pollInterval;
@@ -3361,7 +3371,57 @@ function useChat(options = {}) {
3361
3371
  pollRef.current = null;
3362
3372
  }
3363
3373
  }, []);
3364
- React10.useEffect(() => stopPolling, [stopPolling]);
3374
+ const connectWebSocket = React10.useCallback(() => {
3375
+ const c = clientRef.current;
3376
+ if (!c || typeof WebSocket === "undefined") {
3377
+ startPolling();
3378
+ return;
3379
+ }
3380
+ if (wsRef.current) {
3381
+ wsRef.current.close();
3382
+ wsRef.current = null;
3383
+ }
3384
+ const url = c.buildWsUrl(WS_PATH);
3385
+ const ws = new WebSocket(url);
3386
+ ws.onopen = () => {
3387
+ wsReconnectAttemptRef.current = 0;
3388
+ stopPolling();
3389
+ };
3390
+ ws.onmessage = (event) => {
3391
+ try {
3392
+ const envelope = JSON.parse(event.data);
3393
+ if (envelope.type === "message.created" && envelope.data) {
3394
+ appendMessages([envelope.data]);
3395
+ }
3396
+ } catch {
3397
+ }
3398
+ };
3399
+ ws.onclose = () => {
3400
+ wsRef.current = null;
3401
+ if (!openedRef.current) return;
3402
+ pollMessages();
3403
+ if (wsReconnectAttemptRef.current < WS_MAX_RECONNECT_ATTEMPTS) {
3404
+ const attempt = wsReconnectAttemptRef.current++;
3405
+ const delay = Math.min(1e3 * Math.pow(2, attempt) + Math.random() * 500, 3e4);
3406
+ wsReconnectTimerRef.current = setTimeout(connectWebSocket, delay);
3407
+ } else {
3408
+ startPolling();
3409
+ }
3410
+ };
3411
+ ws.onerror = () => {
3412
+ };
3413
+ wsRef.current = ws;
3414
+ }, [appendMessages, startPolling, stopPolling, pollMessages]);
3415
+ React10.useEffect(() => {
3416
+ return () => {
3417
+ if (pollRef.current) clearInterval(pollRef.current);
3418
+ if (wsReconnectTimerRef.current) clearTimeout(wsReconnectTimerRef.current);
3419
+ if (wsRef.current) {
3420
+ wsRef.current.onclose = null;
3421
+ wsRef.current.close();
3422
+ }
3423
+ };
3424
+ }, []);
3365
3425
  const openConversation = React10.useCallback(async () => {
3366
3426
  if (openedRef.current || !client) return;
3367
3427
  openedRef.current = true;
@@ -3371,13 +3431,13 @@ function useChat(options = {}) {
3371
3431
  if (result.ok) {
3372
3432
  setMessages(result.value.messages);
3373
3433
  setConversationOpened(true);
3374
- startPolling();
3434
+ connectWebSocket();
3375
3435
  } else {
3376
3436
  openedRef.current = false;
3377
3437
  setError(result.error);
3378
3438
  }
3379
3439
  setIsLoading(false);
3380
- }, [client, startPolling]);
3440
+ }, [client, connectWebSocket]);
3381
3441
  const send = React10.useCallback(
3382
3442
  async (content) => {
3383
3443
  if (!client || !content.trim()) return;
@@ -3853,7 +3913,7 @@ function VariantSelector({
3853
3913
  {
3854
3914
  "data-cimplify-variant-name": true,
3855
3915
  className: cn("flex-1 min-w-0 text-sm", classNames?.name),
3856
- children: chunkF47XFKYP_js.getVariantDisplayName(variant, productName)
3916
+ children: chunk6HCBOIZ4_js.getVariantDisplayName(variant, productName)
3857
3917
  }
3858
3918
  ),
3859
3919
  /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-variant-pricing": true, className: cn("text-sm text-muted-foreground", classNames?.pricing), children: [
@@ -5070,12 +5130,12 @@ function FieldInput({
5070
5130
  classNames?.input
5071
5131
  );
5072
5132
  switch (field.field_type) {
5073
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Text:
5074
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Url:
5133
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Text:
5134
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Url:
5075
5135
  return /* @__PURE__ */ jsxRuntime.jsx(
5076
5136
  "input",
5077
5137
  {
5078
- type: field.field_type === chunkF47XFKYP_js.INPUT_FIELD_TYPE.Url ? "url" : "text",
5138
+ type: field.field_type === chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Url ? "url" : "text",
5079
5139
  value: typeof value === "string" ? value : "",
5080
5140
  onChange: (e) => onValueChange(e.target.value),
5081
5141
  placeholder: field.placeholder,
@@ -5084,7 +5144,7 @@ function FieldInput({
5084
5144
  className: inputClass
5085
5145
  }
5086
5146
  );
5087
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Textarea:
5147
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Textarea:
5088
5148
  return /* @__PURE__ */ jsxRuntime.jsx(
5089
5149
  "textarea",
5090
5150
  {
@@ -5097,7 +5157,7 @@ function FieldInput({
5097
5157
  className: cn(inputClass, "resize-none", classNames?.textarea)
5098
5158
  }
5099
5159
  );
5100
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Number:
5160
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Number:
5101
5161
  return /* @__PURE__ */ jsxRuntime.jsx(
5102
5162
  "input",
5103
5163
  {
@@ -5111,7 +5171,7 @@ function FieldInput({
5111
5171
  className: inputClass
5112
5172
  }
5113
5173
  );
5114
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Select:
5174
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Select:
5115
5175
  return /* @__PURE__ */ jsxRuntime.jsxs(
5116
5176
  "select",
5117
5177
  {
@@ -5125,7 +5185,7 @@ function FieldInput({
5125
5185
  ]
5126
5186
  }
5127
5187
  );
5128
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Radio:
5188
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Radio:
5129
5189
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("space-y-2", classNames?.radioGroup), children: (field.options || []).map((opt) => /* @__PURE__ */ jsxRuntime.jsxs(
5130
5190
  "label",
5131
5191
  {
@@ -5150,7 +5210,7 @@ function FieldInput({
5150
5210
  },
5151
5211
  opt
5152
5212
  )) });
5153
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Checkbox:
5213
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Checkbox:
5154
5214
  return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: cn("flex items-center gap-2 text-sm cursor-pointer", classNames?.checkboxLabel), children: [
5155
5215
  /* @__PURE__ */ jsxRuntime.jsx(
5156
5216
  "input",
@@ -5163,7 +5223,7 @@ function FieldInput({
5163
5223
  ),
5164
5224
  field.placeholder || field.name
5165
5225
  ] });
5166
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Color:
5226
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Color:
5167
5227
  return /* @__PURE__ */ jsxRuntime.jsx(
5168
5228
  "input",
5169
5229
  {
@@ -5173,7 +5233,7 @@ function FieldInput({
5173
5233
  className: cn("w-12 h-10 rounded-md border border-input cursor-pointer", classNames?.colorInput)
5174
5234
  }
5175
5235
  );
5176
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Date:
5236
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Date:
5177
5237
  return /* @__PURE__ */ jsxRuntime.jsx(
5178
5238
  "input",
5179
5239
  {
@@ -5184,8 +5244,8 @@ function FieldInput({
5184
5244
  className: inputClass
5185
5245
  }
5186
5246
  );
5187
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.File:
5188
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Image:
5247
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.File:
5248
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Image:
5189
5249
  return /* @__PURE__ */ jsxRuntime.jsx(
5190
5250
  FileUploadInput,
5191
5251
  {
@@ -5196,7 +5256,7 @@ function FieldInput({
5196
5256
  classNames
5197
5257
  }
5198
5258
  );
5199
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Email:
5259
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Email:
5200
5260
  return /* @__PURE__ */ jsxRuntime.jsx(
5201
5261
  "input",
5202
5262
  {
@@ -5208,7 +5268,7 @@ function FieldInput({
5208
5268
  className: inputClass
5209
5269
  }
5210
5270
  );
5211
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.DateTime: {
5271
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.DateTime: {
5212
5272
  const dtLocalValue = typeof value === "string" && value.includes("T") ? value.slice(0, 16) : typeof value === "string" ? value : "";
5213
5273
  return /* @__PURE__ */ jsxRuntime.jsx(
5214
5274
  "input",
@@ -5228,7 +5288,7 @@ function FieldInput({
5228
5288
  }
5229
5289
  );
5230
5290
  }
5231
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Time:
5291
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Time:
5232
5292
  return /* @__PURE__ */ jsxRuntime.jsx(
5233
5293
  "input",
5234
5294
  {
@@ -5239,7 +5299,7 @@ function FieldInput({
5239
5299
  className: inputClass
5240
5300
  }
5241
5301
  );
5242
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.MultiSelect:
5302
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.MultiSelect:
5243
5303
  return /* @__PURE__ */ jsxRuntime.jsx(
5244
5304
  MultiSelectInput,
5245
5305
  {
@@ -5249,7 +5309,7 @@ function FieldInput({
5249
5309
  classNames
5250
5310
  }
5251
5311
  );
5252
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.DateRange:
5312
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.DateRange:
5253
5313
  return /* @__PURE__ */ jsxRuntime.jsx(
5254
5314
  DateRangeInput,
5255
5315
  {
@@ -5260,7 +5320,7 @@ function FieldInput({
5260
5320
  inputClass
5261
5321
  }
5262
5322
  );
5263
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Address:
5323
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Address:
5264
5324
  return /* @__PURE__ */ jsxRuntime.jsx(
5265
5325
  AddressInput,
5266
5326
  {
@@ -5271,7 +5331,7 @@ function FieldInput({
5271
5331
  inputClass
5272
5332
  }
5273
5333
  );
5274
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Location:
5334
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Location:
5275
5335
  return /* @__PURE__ */ jsxRuntime.jsx(
5276
5336
  LocationInput,
5277
5337
  {
@@ -5282,7 +5342,7 @@ function FieldInput({
5282
5342
  inputClass
5283
5343
  }
5284
5344
  );
5285
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Phone:
5345
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Phone:
5286
5346
  return /* @__PURE__ */ jsxRuntime.jsx(
5287
5347
  PhoneInput,
5288
5348
  {
@@ -5293,7 +5353,7 @@ function FieldInput({
5293
5353
  inputClass
5294
5354
  }
5295
5355
  );
5296
- case chunkF47XFKYP_js.INPUT_FIELD_TYPE.Signature:
5356
+ case chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Signature:
5297
5357
  return /* @__PURE__ */ jsxRuntime.jsx(
5298
5358
  SignatureInput,
5299
5359
  {
@@ -5326,7 +5386,7 @@ function FileUploadInput({
5326
5386
  const [isUploading, setIsUploading] = React10__default.default.useState(false);
5327
5387
  const fileUrl = typeof value === "string" ? value : void 0;
5328
5388
  const acceptedFormats = field.validation?.accepted_formats;
5329
- const accept = acceptedFormats ? acceptedFormats.map((f) => `.${f}`).join(",") : field.field_type === chunkF47XFKYP_js.INPUT_FIELD_TYPE.Image ? "image/*" : void 0;
5389
+ const accept = acceptedFormats ? acceptedFormats.map((f) => `.${f}`).join(",") : field.field_type === chunk6HCBOIZ4_js.INPUT_FIELD_TYPE.Image ? "image/*" : void 0;
5330
5390
  const handleFile = async (file) => {
5331
5391
  if (!onFileUpload) return;
5332
5392
  if (field.validation?.max_size_mb) {
@@ -5344,7 +5404,7 @@ function FileUploadInput({
5344
5404
  }
5345
5405
  };
5346
5406
  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: [
5347
- field.field_type === chunkF47XFKYP_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" }),
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" }),
5348
5408
  /* @__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() }) }),
5349
5409
  /* @__PURE__ */ jsxRuntime.jsx(
5350
5410
  "button",
@@ -5370,7 +5430,7 @@ function FileUploadInput({
5370
5430
  }
5371
5431
  ),
5372
5432
  isUploading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "Uploading..." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5373
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: field.placeholder || `Upload ${field.field_type === chunkF47XFKYP_js.INPUT_FIELD_TYPE.Image ? "image" : "file"}` }),
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"}` }),
5374
5434
  acceptedFormats && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground/60 mt-1", children: [
5375
5435
  acceptedFormats.map((f) => f.toUpperCase()).join(", "),
5376
5436
  field.validation?.max_size_mb && ` \xB7 Max ${field.validation.max_size_mb}MB`
@@ -6298,7 +6358,7 @@ function CartLineItemRow({
6298
6358
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item": true, className: classNames?.item, children: [
6299
6359
  /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item-info": true, children: [
6300
6360
  /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-name": true, className: classNames?.itemName, children: item.product.name }),
6301
- item.variant && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-variant": true, children: chunkF47XFKYP_js.getVariantDisplayName(item.variant, 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) }),
6302
6362
  item.addOnOptions && item.addOnOptions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-cart-item-addons": true, children: [
6303
6363
  "+ ",
6304
6364
  item.addOnOptions.map((opt) => opt.name).join(", ")
@@ -6307,7 +6367,7 @@ function CartLineItemRow({
6307
6367
  item.specialInstructions && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-instructions": true, className: "text-xs text-muted-foreground", children: item.specialInstructions }),
6308
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: [
6309
6369
  /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-input-label": true, children: input.field_name }),
6310
- /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-input-value": true, children: input.field_type === chunkF47XFKYP_js.INPUT_FIELD_TYPE.File || input.field_type === chunkF47XFKYP_js.INPUT_FIELD_TYPE.Image ? String(input.value).split("/").pop() || "Uploaded file" : String(input.value) })
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) })
6311
6371
  ] }, input.field_id)) }),
6312
6372
  (item.lineType === "service" || item.product.type === "service") && item.scheduledStart && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-service-info": true, className: classNames?.serviceInfo, children: [
6313
6373
  /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
@@ -6827,7 +6887,7 @@ function FoodProductCard({
6827
6887
  const tags = product.tags || [];
6828
6888
  const isSignature = product.metadata?.is_signature === true;
6829
6889
  const isNew = product.metadata?.is_new === true;
6830
- const isComposite = product.type === chunkF47XFKYP_js.PRODUCT_TYPE.Composite;
6890
+ const isComposite = product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Composite;
6831
6891
  return /* @__PURE__ */ jsxRuntime.jsxs(CardShell, { product, renderLink, className, children: [
6832
6892
  /* @__PURE__ */ jsxRuntime.jsxs(CardImage, { src: image, alt: product.name, aspectRatio: "square", renderImage, children: [
6833
6893
  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: [
@@ -7580,26 +7640,26 @@ var BUILT_IN_CARDS = {
7580
7640
  ["composite" /* Composite */]: CompositeProductCard,
7581
7641
  ["subscription" /* Subscription */]: SubscriptionCard
7582
7642
  };
7583
- var RENTAL_UNITS = /* @__PURE__ */ new Set([chunkF47XFKYP_js.DURATION_UNIT.Days, chunkF47XFKYP_js.DURATION_UNIT.Hours]);
7584
- var LEASE_UNITS = /* @__PURE__ */ new Set([chunkF47XFKYP_js.DURATION_UNIT.Weeks, chunkF47XFKYP_js.DURATION_UNIT.Months, chunkF47XFKYP_js.DURATION_UNIT.Years]);
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]);
7585
7645
  function resolveCardVariant(product) {
7586
- if (product.type === chunkF47XFKYP_js.PRODUCT_TYPE.Bundle) {
7646
+ if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Bundle) {
7587
7647
  return "bundle" /* Bundle */;
7588
7648
  }
7589
- if (product.type === chunkF47XFKYP_js.PRODUCT_TYPE.Composite) {
7649
+ if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Composite) {
7590
7650
  return "composite" /* Composite */;
7591
7651
  }
7592
7652
  if (product.quantity_pricing && product.quantity_pricing.length > 1) {
7593
7653
  return "wholesale" /* Wholesale */;
7594
7654
  }
7595
- if (product.type === chunkF47XFKYP_js.PRODUCT_TYPE.Digital) {
7655
+ if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Digital) {
7596
7656
  return "digital" /* Digital */;
7597
7657
  }
7598
- if (product.type === chunkF47XFKYP_js.PRODUCT_TYPE.Service) {
7658
+ if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Service) {
7599
7659
  if (product.duration_unit && RENTAL_UNITS.has(product.duration_unit)) {
7600
7660
  return "rental" /* Rental */;
7601
7661
  }
7602
- if (product.duration_unit === chunkF47XFKYP_js.DURATION_UNIT.Nights) {
7662
+ if (product.duration_unit === chunk6HCBOIZ4_js.DURATION_UNIT.Nights) {
7603
7663
  return "accommodation" /* Accommodation */;
7604
7664
  }
7605
7665
  if (product.duration_unit && LEASE_UNITS.has(product.duration_unit)) {
@@ -7610,10 +7670,10 @@ function resolveCardVariant(product) {
7610
7670
  }
7611
7671
  return "standard" /* Standard */;
7612
7672
  }
7613
- if (product.render_hint === chunkF47XFKYP_js.RENDER_HINT.Food) {
7673
+ if (product.render_hint === chunk6HCBOIZ4_js.RENDER_HINT.Food) {
7614
7674
  return "food" /* Food */;
7615
7675
  }
7616
- if (product.render_hint === chunkF47XFKYP_js.RENDER_HINT.Physical) {
7676
+ if (product.render_hint === chunk6HCBOIZ4_js.RENDER_HINT.Physical) {
7617
7677
  return "retail" /* Retail */;
7618
7678
  }
7619
7679
  return "retail" /* Retail */;
@@ -10374,25 +10434,25 @@ function resolveTemplateKey(product) {
10374
10434
  if (typeof metaTemplate === "string" && metaTemplate.trim()) {
10375
10435
  return metaTemplate.trim();
10376
10436
  }
10377
- if (product.type === chunkF47XFKYP_js.PRODUCT_TYPE.Bundle) {
10437
+ if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Bundle) {
10378
10438
  return "bundle" /* Bundle */;
10379
10439
  }
10380
- if (product.type === chunkF47XFKYP_js.PRODUCT_TYPE.Composite) {
10440
+ if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Composite) {
10381
10441
  return "composite" /* Composite */;
10382
10442
  }
10383
10443
  if (product.quantity_pricing && product.quantity_pricing.length > 1) {
10384
10444
  return "wholesale" /* Wholesale */;
10385
10445
  }
10386
- if (product.type === chunkF47XFKYP_js.PRODUCT_TYPE.Service) {
10446
+ if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Service) {
10387
10447
  return "service" /* Service */;
10388
10448
  }
10389
- if (product.type === chunkF47XFKYP_js.PRODUCT_TYPE.Digital) {
10449
+ if (product.type === chunk6HCBOIZ4_js.PRODUCT_TYPE.Digital) {
10390
10450
  return "digital" /* Digital */;
10391
10451
  }
10392
- if (product.render_hint === chunkF47XFKYP_js.RENDER_HINT.Food) {
10452
+ if (product.render_hint === chunk6HCBOIZ4_js.RENDER_HINT.Food) {
10393
10453
  return "food" /* Food */;
10394
10454
  }
10395
- if (product.render_hint === chunkF47XFKYP_js.RENDER_HINT.Physical) {
10455
+ if (product.render_hint === chunk6HCBOIZ4_js.RENDER_HINT.Physical) {
10396
10456
  return "physical" /* Physical */;
10397
10457
  }
10398
10458
  return "default" /* Default */;
@@ -12456,7 +12516,7 @@ function SparkleIcon({ className }) {
12456
12516
 
12457
12517
  Object.defineProperty(exports, "getVariantDisplayName", {
12458
12518
  enumerable: true,
12459
- get: function () { return chunkF47XFKYP_js.getVariantDisplayName; }
12519
+ get: function () { return chunk6HCBOIZ4_js.getVariantDisplayName; }
12460
12520
  });
12461
12521
  exports.AccommodationCard = AccommodationCard;
12462
12522
  exports.Ad = Ad;
package/dist/react.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, PRODUCT_TYPE, createCimplifyClient, RENDER_HINT } from './chunk-WGAVNFEQ.mjs';
3
- export { getVariantDisplayName } from './chunk-WGAVNFEQ.mjs';
2
+ import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, PRODUCT_TYPE, createCimplifyClient, RENDER_HINT } from './chunk-46BDUSJX.mjs';
3
+ export { getVariantDisplayName } from './chunk-46BDUSJX.mjs';
4
4
  import { ELEMENT_TYPES, EVENT_TYPES } from './chunk-3J4PPSMI.mjs';
5
5
  import { isSupportedCurrency, formatPrice, parsePrice, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-E3HC2YAE.mjs';
6
6
  import React10, { createContext, useRef, useState, useCallback, useEffect, useContext, useMemo, useSyncExternalStore, useId } from 'react';
@@ -3313,6 +3313,8 @@ function useBootstrap(options = {}) {
3313
3313
  var POLL_INTERVAL_MS = 3e3;
3314
3314
  var POLL_IDLE_INTERVAL_MS = 15e3;
3315
3315
  var IDLE_TIMEOUT_MS = 6e4;
3316
+ var WS_MAX_RECONNECT_ATTEMPTS = 10;
3317
+ var WS_PATH = "/api/v1/support/conversation/ws";
3316
3318
  function useChat(options = {}) {
3317
3319
  const context = useOptionalCimplifyClient();
3318
3320
  const client = options.client ?? context?.client;
@@ -3325,26 +3327,34 @@ function useChat(options = {}) {
3325
3327
  const lastActivityRef = useRef(Date.now());
3326
3328
  const openedRef = useRef(false);
3327
3329
  const messagesRef = useRef([]);
3330
+ const clientRef = useRef(client);
3331
+ const wsRef = useRef(null);
3332
+ const wsReconnectAttemptRef = useRef(0);
3333
+ const wsReconnectTimerRef = useRef(null);
3328
3334
  messagesRef.current = messages;
3335
+ clientRef.current = client;
3329
3336
  const pollInterval = options.pollInterval ?? POLL_INTERVAL_MS;
3330
3337
  const pollIdleInterval = options.pollIdleInterval ?? POLL_IDLE_INTERVAL_MS;
3338
+ const appendMessages = useCallback((incoming) => {
3339
+ setMessages((prev) => {
3340
+ const ids = new Set(prev.map((m) => m.id));
3341
+ const fresh = incoming.filter((m) => !ids.has(m.id));
3342
+ return fresh.length > 0 ? [...prev, ...fresh] : prev;
3343
+ });
3344
+ }, []);
3331
3345
  const pollMessages = useCallback(async () => {
3332
- if (!client) return;
3333
- const isIdle = Date.now() - lastActivityRef.current > IDLE_TIMEOUT_MS;
3334
- if (isIdle) return;
3346
+ const c = clientRef.current;
3347
+ if (!c) return;
3348
+ if (Date.now() - lastActivityRef.current > IDLE_TIMEOUT_MS) return;
3335
3349
  const last = messagesRef.current[messagesRef.current.length - 1];
3336
- const result = await client.support.getMessages({
3350
+ const result = await c.support.getMessages({
3337
3351
  after: last?.created_at,
3338
3352
  limit: 50
3339
3353
  });
3340
3354
  if (result.ok && result.value.length > 0) {
3341
- setMessages((prev) => {
3342
- const ids = new Set(prev.map((m) => m.id));
3343
- const fresh = result.value.filter((m) => !ids.has(m.id));
3344
- return fresh.length > 0 ? [...prev, ...fresh] : prev;
3345
- });
3355
+ appendMessages(result.value);
3346
3356
  }
3347
- }, [client]);
3357
+ }, [appendMessages]);
3348
3358
  const startPolling = useCallback(() => {
3349
3359
  if (pollRef.current) clearInterval(pollRef.current);
3350
3360
  const interval = Date.now() - lastActivityRef.current > IDLE_TIMEOUT_MS ? pollIdleInterval : pollInterval;
@@ -3356,7 +3366,57 @@ function useChat(options = {}) {
3356
3366
  pollRef.current = null;
3357
3367
  }
3358
3368
  }, []);
3359
- useEffect(() => stopPolling, [stopPolling]);
3369
+ const connectWebSocket = useCallback(() => {
3370
+ const c = clientRef.current;
3371
+ if (!c || typeof WebSocket === "undefined") {
3372
+ startPolling();
3373
+ return;
3374
+ }
3375
+ if (wsRef.current) {
3376
+ wsRef.current.close();
3377
+ wsRef.current = null;
3378
+ }
3379
+ const url = c.buildWsUrl(WS_PATH);
3380
+ const ws = new WebSocket(url);
3381
+ ws.onopen = () => {
3382
+ wsReconnectAttemptRef.current = 0;
3383
+ stopPolling();
3384
+ };
3385
+ ws.onmessage = (event) => {
3386
+ try {
3387
+ const envelope = JSON.parse(event.data);
3388
+ if (envelope.type === "message.created" && envelope.data) {
3389
+ appendMessages([envelope.data]);
3390
+ }
3391
+ } catch {
3392
+ }
3393
+ };
3394
+ ws.onclose = () => {
3395
+ wsRef.current = null;
3396
+ if (!openedRef.current) return;
3397
+ pollMessages();
3398
+ if (wsReconnectAttemptRef.current < WS_MAX_RECONNECT_ATTEMPTS) {
3399
+ const attempt = wsReconnectAttemptRef.current++;
3400
+ const delay = Math.min(1e3 * Math.pow(2, attempt) + Math.random() * 500, 3e4);
3401
+ wsReconnectTimerRef.current = setTimeout(connectWebSocket, delay);
3402
+ } else {
3403
+ startPolling();
3404
+ }
3405
+ };
3406
+ ws.onerror = () => {
3407
+ };
3408
+ wsRef.current = ws;
3409
+ }, [appendMessages, startPolling, stopPolling, pollMessages]);
3410
+ useEffect(() => {
3411
+ return () => {
3412
+ if (pollRef.current) clearInterval(pollRef.current);
3413
+ if (wsReconnectTimerRef.current) clearTimeout(wsReconnectTimerRef.current);
3414
+ if (wsRef.current) {
3415
+ wsRef.current.onclose = null;
3416
+ wsRef.current.close();
3417
+ }
3418
+ };
3419
+ }, []);
3360
3420
  const openConversation = useCallback(async () => {
3361
3421
  if (openedRef.current || !client) return;
3362
3422
  openedRef.current = true;
@@ -3366,13 +3426,13 @@ function useChat(options = {}) {
3366
3426
  if (result.ok) {
3367
3427
  setMessages(result.value.messages);
3368
3428
  setConversationOpened(true);
3369
- startPolling();
3429
+ connectWebSocket();
3370
3430
  } else {
3371
3431
  openedRef.current = false;
3372
3432
  setError(result.error);
3373
3433
  }
3374
3434
  setIsLoading(false);
3375
- }, [client, startPolling]);
3435
+ }, [client, connectWebSocket]);
3376
3436
  const send = useCallback(
3377
3437
  async (content) => {
3378
3438
  if (!client || !content.trim()) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimplify/sdk",
3
- "version": "0.30.0",
3
+ "version": "0.31.0",
4
4
  "description": "Cimplify Commerce SDK for storefronts",
5
5
  "keywords": [
6
6
  "cimplify",