@anker-in/shopify-react 0.1.1-beta.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.
@@ -0,0 +1,1936 @@
1
+ import * as swr_mutation from 'swr/mutation';
2
+ import { SWRMutationConfiguration } from 'swr/mutation';
3
+ import { CartLineInput as CartLineInput$1, NormalizedCart, NormalizedProductVariant, MoneyV2, UpdateCartLinesOptions, HasMetafieldsIdentifier, NormalizedProduct, NormalizedLineItem, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle } from '@anker-in/shopify-sdk';
4
+ import { G as GtmParams, B as BuyNowTrackConfig, c as PlusMemberShippingMethodConfig, d as PlusMemberSettingsMetafields, D as DeliveryPlusType, e as SelectedPlusMemberProduct, h as DeliveryData } from './types-CMA6_FML.js';
5
+ import Decimal from 'decimal.js';
6
+ import * as swr from 'swr';
7
+ import swr__default, { SWRConfiguration } from 'swr';
8
+ import * as swr__internal from 'swr/_internal';
9
+ import * as React$1 from 'react';
10
+ import { PropsWithChildren, Dispatch, SetStateAction, RefObject } from 'react';
11
+ import * as react_jsx_runtime from 'react/jsx-runtime';
12
+
13
+ interface CreateCartInput {
14
+ /** Lines to add to the cart */
15
+ lines?: CartLineInput$1[];
16
+ /** Buyer identity for cart creation */
17
+ buyerIdentity?: {
18
+ email?: string;
19
+ countryCode?: string;
20
+ };
21
+ /** Discount codes */
22
+ discountCodes?: string[];
23
+ /** Custom attributes */
24
+ customAttributes?: Array<{
25
+ key: string;
26
+ value: string;
27
+ }>;
28
+ }
29
+ /**
30
+ * Hook for creating a new cart
31
+ *
32
+ * Automatically removes invalid discount codes after creating cart
33
+ *
34
+ * @param options - SWR mutation configuration
35
+ * @returns SWR mutation with trigger function
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * const { trigger, isMutating } = useCreateCart()
40
+ *
41
+ * // Create empty cart
42
+ * await trigger({})
43
+ *
44
+ * // Create cart with items
45
+ * await trigger({
46
+ * lines: [{
47
+ * merchandiseId: 'gid://shopify/ProductVariant/123',
48
+ * quantity: 1
49
+ * }],
50
+ * buyerIdentity: {
51
+ * email: 'customer@example.com',
52
+ * countryCode: 'US'
53
+ * },
54
+ * discountCodes: ['SUMMER2024']
55
+ * })
56
+ * ```
57
+ */
58
+ declare function useCreateCart(options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'create-cart', CreateCartInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "create-cart", CreateCartInput>;
59
+
60
+ interface AddCartLinesInput {
61
+ /** Cart ID (optional, will use cookie or create new cart) */
62
+ cartId?: string;
63
+ /** Lines to add */
64
+ lines: CartLineInput$1[];
65
+ /** Buyer identity for new cart */
66
+ buyerIdentity?: {
67
+ email?: string;
68
+ countryCode?: string;
69
+ };
70
+ }
71
+ /**
72
+ * Hook for adding lines to cart
73
+ *
74
+ * Automatically removes invalid discount codes after adding items
75
+ *
76
+ * @param options - SWR mutation configuration
77
+ * @returns SWR mutation with trigger function
78
+ *
79
+ * @example
80
+ * ```tsx
81
+ * const { trigger, isMutating } = useAddCartLines()
82
+ *
83
+ * await trigger({
84
+ * lines: [{
85
+ * merchandiseId: 'gid://shopify/ProductVariant/123',
86
+ * quantity: 1
87
+ * }]
88
+ * })
89
+ * ```
90
+ */
91
+ declare function useAddCartLines(options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'add-cart-lines', AddCartLinesInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "add-cart-lines", AddCartLinesInput>;
92
+
93
+ interface AddToCartInput {
94
+ /** Lines to add */
95
+ lineItems: Array<{
96
+ variant?: NormalizedProductVariant;
97
+ finalPrice?: MoneyV2;
98
+ sellingPlanId?: string;
99
+ quantity?: number;
100
+ attributes?: Array<{
101
+ key: string;
102
+ value: string;
103
+ }>;
104
+ }>;
105
+ /** Cart ID (optional) */
106
+ cartId?: string;
107
+ /** Discount codes to apply */
108
+ discountCodes?: string[];
109
+ /** Custom attributes for the cart */
110
+ customAttributes?: Array<{
111
+ key: string;
112
+ value: string;
113
+ }>;
114
+ /** 全量更新 codes,默认是追加 */
115
+ replaceExistingCodes?: boolean;
116
+ /** Buyer identity for cart creation */
117
+ buyerIdentity?: {
118
+ email?: string;
119
+ countryCode?: string;
120
+ };
121
+ /** GTM tracking parameters */
122
+ gtmParams?: Omit<GtmParams, 'brand'>;
123
+ /** Force create new cart */
124
+ needCreateCart?: boolean;
125
+ /** Callback when discount codes are invalid */
126
+ onCodesInvalid?: (updatedCart: NormalizedCart, invalidCodes: string[]) => Promise<NormalizedCart | undefined>;
127
+ }
128
+ interface UseAddToCartOptions {
129
+ /** Enable tracking (GA and FBQ) */
130
+ withTrack?: boolean;
131
+ /** Brand name for tracking */
132
+ brand?: string;
133
+ }
134
+ /**
135
+ * Hook for adding items to cart with tracking support
136
+ *
137
+ * This is the enhanced version that includes:
138
+ * - Automatic cart creation if needed
139
+ * - Discount code validation
140
+ * - Google Analytics tracking
141
+ * - Facebook Pixel tracking
142
+ * - Invalid code handling
143
+ *
144
+ * @param options - Hook configuration
145
+ * @param swrOptions - SWR mutation configuration
146
+ * @returns SWR mutation with trigger function
147
+ *
148
+ * @example
149
+ * ```tsx
150
+ * const { trigger, isMutating } = useAddToCart({ withTrack: true, brand: 'Anker' })
151
+ *
152
+ * await trigger({
153
+ * lineItems: [{
154
+ * variantId: 'gid://shopify/ProductVariant/123',
155
+ * quantity: 2
156
+ * }],
157
+ * gtmParams: {
158
+ * pageGroup: 'PDP',
159
+ * position: 'Add to Cart Button'
160
+ * }
161
+ * })
162
+ * ```
163
+ */
164
+ declare function useAddToCart({ withTrack, brand }?: UseAddToCartOptions, swrOptions?: SWRMutationConfiguration<NormalizedCart | undefined, Error, string, AddToCartInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, string, AddToCartInput>;
165
+
166
+ /**
167
+ * Hook for updating cart line quantities
168
+ *
169
+ * @param options - SWR mutation configuration
170
+ * @returns SWR mutation with trigger function
171
+ *
172
+ * @example
173
+ * ```tsx
174
+ * const { trigger, isMutating } = useUpdateCartLines()
175
+ *
176
+ * await trigger({
177
+ * lines: [{
178
+ * id: 'gid://shopify/CartLine/123',
179
+ * quantity: 2
180
+ * }]
181
+ * })
182
+ * ```
183
+ */
184
+ declare function useUpdateCartLines(options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'update-cart-lines', UpdateCartLinesOptions>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-cart-lines", UpdateCartLinesOptions>;
185
+
186
+ interface RemoveCartLinesInput {
187
+ /** Cart ID (optional, will use cookie) */
188
+ cartId?: string;
189
+ /** Line IDs to remove */
190
+ lineIds: string[];
191
+ /** Whether to automatically remove invalid discount codes (default: true) */
192
+ autoRemoveInvalidCodes?: boolean;
193
+ /** Callback when discount codes are removed */
194
+ onCodesRemoved?: (updatedCart: NormalizedCart, removedCodes: string[]) => Promise<NormalizedCart | undefined>;
195
+ }
196
+ /**
197
+ * Hook for removing lines from cart
198
+ *
199
+ * Automatically removes invalid discount codes after removing items
200
+ *
201
+ * @param options - SWR mutation configuration
202
+ * @returns SWR mutation with trigger function
203
+ *
204
+ * @example
205
+ * ```tsx
206
+ * const { trigger, isMutating } = useRemoveCartLines()
207
+ *
208
+ * await trigger({
209
+ * lineIds: ['gid://shopify/CartLine/123']
210
+ * })
211
+ * ```
212
+ */
213
+ declare function useRemoveCartLines(options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'remove-cart-lines', RemoveCartLinesInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "remove-cart-lines", RemoveCartLinesInput>;
214
+
215
+ interface ApplyCartCodesInput {
216
+ /** Cart ID (required) */
217
+ cartId?: string;
218
+ /** Discount codes to apply (added to existing applicable codes) */
219
+ discountCodes: string[];
220
+ /** Replace existing applicable codes */
221
+ replaceExistingCodes?: boolean;
222
+ }
223
+ /**
224
+ * Hook for applying discount codes to cart
225
+ *
226
+ * Merges new codes with existing applicable codes and validates them
227
+ *
228
+ * @param options - SWR mutation configuration
229
+ * @returns SWR mutation with trigger function
230
+ *
231
+ * @example
232
+ * ```tsx
233
+ * const { trigger, isMutating, error } = useApplyCartCodes()
234
+ *
235
+ * try {
236
+ * await trigger({
237
+ * cartId: 'gid://shopify/Cart/123',
238
+ * discountCodes: ['SUMMER2024']
239
+ * })
240
+ * } catch (error) {
241
+ * // Handle unapplicable codes
242
+ * }
243
+ * ```
244
+ */
245
+ declare function useApplyCartCodes(options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'apply-codes', ApplyCartCodesInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "apply-codes", ApplyCartCodesInput>;
246
+
247
+ interface RemoveCartCodesInput {
248
+ /** Cart ID (required) */
249
+ cartId?: string;
250
+ /** Discount codes to remove */
251
+ discountCodes: string[];
252
+ }
253
+ /**
254
+ * Hook for removing discount codes from cart
255
+ *
256
+ * @param options - SWR mutation configuration
257
+ * @returns SWR mutation with trigger function
258
+ *
259
+ * @example
260
+ * ```tsx
261
+ * const { trigger, isMutating } = useRemoveCartCodes()
262
+ *
263
+ * await trigger({
264
+ * cartId: 'gid://shopify/Cart/123',
265
+ * discountCodes: ['EXPIRED_CODE']
266
+ * })
267
+ * ```
268
+ */
269
+ declare function useRemoveCartCodes(options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'remove-codes', RemoveCartCodesInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "remove-codes", RemoveCartCodesInput>;
270
+
271
+ interface UpdateCartAttributesInput {
272
+ /** Cart ID (optional, will use cookie) */
273
+ cartId?: string;
274
+ /** Custom attributes to set on cart */
275
+ attributes: Array<{
276
+ key: string;
277
+ value: string;
278
+ }>;
279
+ }
280
+ /**
281
+ * Hook for updating cart attributes (custom key-value pairs)
282
+ *
283
+ * @param options - SWR mutation configuration
284
+ * @returns SWR mutation with trigger function
285
+ *
286
+ * @example
287
+ * ```tsx
288
+ * const { trigger, isMutating } = useUpdateCartAttributes()
289
+ *
290
+ * await trigger({
291
+ * attributes: [
292
+ * { key: 'gift_message', value: 'Happy Birthday!' },
293
+ * { key: 'gift_wrap', value: 'true' }
294
+ * ]
295
+ * })
296
+ * ```
297
+ */
298
+ declare function useUpdateCartAttributes(mutate: (cart: NormalizedCart | undefined) => void, metafieldIdentifiers?: {
299
+ variant: HasMetafieldsIdentifier[];
300
+ product: HasMetafieldsIdentifier[];
301
+ }, options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'update-cart-attributes', UpdateCartAttributesInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-cart-attributes", UpdateCartAttributesInput>;
302
+
303
+ interface BuyNowInput {
304
+ /** Metafield identifiers */
305
+ metafieldIdentifiers?: {
306
+ variant: HasMetafieldsIdentifier[];
307
+ product: HasMetafieldsIdentifier[];
308
+ };
309
+ /** Line items to add to the new cart */
310
+ lineItems: Array<{
311
+ variant?: {
312
+ id: string;
313
+ };
314
+ variantId?: string;
315
+ quantity?: number;
316
+ attributes?: Array<{
317
+ key: string;
318
+ value: string;
319
+ }>;
320
+ }>;
321
+ /** Discount codes to apply */
322
+ discountCodes?: string[];
323
+ /** Custom attributes for the cart */
324
+ customAttributes?: Array<{
325
+ key: string;
326
+ value: string;
327
+ }>;
328
+ /** Buyer identity */
329
+ buyerIdentity?: {
330
+ email?: string;
331
+ countryCode?: string;
332
+ };
333
+ /** GTM tracking parameters */
334
+ gtmParams?: Omit<GtmParams, 'brand'>;
335
+ /** Facebook Pixel tracking configuration */
336
+ fbqTrackConfig?: BuyNowTrackConfig;
337
+ /** Whether to redirect to checkout page (default: true) */
338
+ redirectToCheckout?: boolean;
339
+ }
340
+ interface UseBuyNowOptions {
341
+ /** Enable tracking (GA and FBQ) */
342
+ withTrack?: boolean;
343
+ /** Brand name for tracking */
344
+ brand?: string;
345
+ }
346
+ /**
347
+ * Hook for buy now functionality
348
+ *
349
+ * Creates a new cart with the specified items and redirects to checkout.
350
+ * Includes automatic tracking for GA4 and Facebook Pixel.
351
+ *
352
+ * @param options - Hook configuration
353
+ * @param swrOptions - SWR mutation configuration
354
+ * @returns SWR mutation with trigger function
355
+ *
356
+ * @example
357
+ * ```tsx
358
+ * const { trigger, isMutating } = useBuyNow({
359
+ * withTrack: true,
360
+ * redirectToCheckout: true,
361
+ * brand: 'Anker'
362
+ * })
363
+ *
364
+ * await trigger({
365
+ * lineItems: [{
366
+ * variantId: 'gid://shopify/ProductVariant/123',
367
+ * quantity: 1
368
+ * }],
369
+ * gtmParams: {
370
+ * pageGroup: 'PDP',
371
+ * position: 'Buy Now Button'
372
+ * }
373
+ * })
374
+ * ```
375
+ */
376
+ declare function useBuyNow({ withTrack, brand }?: UseBuyNowOptions, swrOptions?: SWRMutationConfiguration<NormalizedCart | undefined, Error, string, BuyNowInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, string, BuyNowInput>;
377
+
378
+ type AutoFreeGift = {
379
+ currentTier: {
380
+ amount: number;
381
+ gift?: NormalizedProductVariant;
382
+ };
383
+ nextTierGoal: {
384
+ amount: number;
385
+ gift?: NormalizedProductVariant;
386
+ };
387
+ };
388
+ type DiscountLabel = {
389
+ cart_checkout_label: string;
390
+ product_label: string;
391
+ sold_out_label: string;
392
+ };
393
+ type AutoFreeGiftMainProduct = {
394
+ spend_money_type: number;
395
+ variant_id_list: string[];
396
+ all_store_variant: boolean;
397
+ };
398
+ type GiftProduct = {
399
+ spend_sum_money: number;
400
+ gift_type: number;
401
+ reward_list: {
402
+ get_unit: number;
403
+ variant_id: string;
404
+ bak_variant_id_list: null;
405
+ }[];
406
+ };
407
+ type AutoFreeGiftConfig = Config[];
408
+ type RuleCondition = {
409
+ with_special_url_params: string[];
410
+ without_special_url_params: string[];
411
+ with_user_tags: string[];
412
+ without_user_tags: string[];
413
+ };
414
+ type MainProductInfo = {
415
+ spend_money_type: SpendMoneyType;
416
+ variant_list: VariantItem[];
417
+ all_store_variant: boolean;
418
+ };
419
+ type Config = {
420
+ rule_id: number;
421
+ rule_type: RuleType;
422
+ discount_label: {
423
+ cart_checkout_label: string;
424
+ product_label: string;
425
+ sold_out_label: string;
426
+ };
427
+ frontend_labels: {
428
+ key: string;
429
+ label: string;
430
+ desc: string;
431
+ }[];
432
+ apply_unit: number;
433
+ rule_result: {
434
+ buy_rule_type: BuyRuleType;
435
+ spend_get_reward: {
436
+ main_product: MainProductInfo;
437
+ gift_product: GiftProductItem[];
438
+ };
439
+ buy_get_reward: {
440
+ main_product: MainProductInfo;
441
+ gift_product: GiftProductItem[] | null;
442
+ };
443
+ };
444
+ rule_conditions?: RuleCondition[];
445
+ };
446
+ interface GiftTier {
447
+ spend_sum_money: number;
448
+ gift_type: number;
449
+ reward_list: RewardItem[];
450
+ }
451
+ interface RewardItem {
452
+ get_unit: number;
453
+ variant_list: VariantItem[];
454
+ }
455
+ interface VariantItem {
456
+ variant_id: string;
457
+ sku: string;
458
+ handle: string;
459
+ discount_value: number;
460
+ }
461
+ interface GiftProductItem {
462
+ spend_sum_money: number;
463
+ gift_type: number;
464
+ reward_list: RewardItem[];
465
+ }
466
+ declare enum RuleType {
467
+ AUTO_FREE_GIFT = 1,// 自动赠品
468
+ BUNDLE = 2,// 组合
469
+ VOLUME_DISCOUNT = 3,// 量价折扣
470
+ ORDER_DISCOUNT = 4,// 订单折扣
471
+ PRICE_DISCOUNT = 5
472
+ }
473
+ declare enum BuyRuleType {
474
+ BUY_GET_GIFT = 1,// 买赠
475
+ SPEND_GET_GIFT = 2
476
+ }
477
+ declare enum SpendMoneyType {
478
+ ORIGIN_PRICE = 1,// 原价
479
+ DISCOUNT_PRICE = 2
480
+ }
481
+ interface FunctionGiftResult {
482
+ qualifyingGift: FormattedGift | null;
483
+ nextTierGoal: GiftTier | null;
484
+ activeCampaign: Config | null;
485
+ isLoading: boolean;
486
+ giftProductsResult?: NormalizedProduct[] | [];
487
+ }
488
+ interface FormattedGift {
489
+ tier: GiftTier;
490
+ itemsToAdd: CartLineInput[];
491
+ }
492
+ interface CartLineInput {
493
+ variant: {
494
+ id: string;
495
+ handle: string;
496
+ sku: string;
497
+ };
498
+ quantity: number;
499
+ attributes: {
500
+ key: string;
501
+ value: string;
502
+ }[];
503
+ }
504
+ type AutoFreeGiftItem = {
505
+ line: NormalizedLineItem;
506
+ isSoldOut: boolean;
507
+ };
508
+ type AutoFreeGiftList = AutoFreeGiftItem[] | [];
509
+
510
+ /**
511
+ * [计算型 Hook]
512
+ * 根据购物车、活动配置和用户信息,计算出应得的赠品和下一个目标。
513
+ * 此 Hook 不产生任何副作用。
514
+ * 使用示例:
515
+ * const { qualifyingGift, nextTierGoal, activeCampaign, isLoading } = useCalcAutoFreeGift(cart, autoFreeGiftConfig);
516
+ */
517
+ declare const useCalcAutoFreeGift: (cart: any, autoFreeGiftConfig: AutoFreeGiftConfig, customer: any) => FunctionGiftResult;
518
+
519
+ declare enum OrderDiscountType {
520
+ PERCENTAGE = 1,// 百分比折扣
521
+ FIXED_AMOUNT = 2,// 固定金额折扣
522
+ REDUCE_PRICE = 3
523
+ }
524
+ declare enum OrderBasePriceType {
525
+ ORIGIN_PRICE = 1,// 原价
526
+ MIN_DISCOUNTED_PRICE = 2
527
+ }
528
+ type TieredDiscount = {
529
+ amount: number;
530
+ discount: number;
531
+ discount_type: OrderDiscountType;
532
+ };
533
+ type OrderDiscountConfig = {
534
+ rule_id: number;
535
+ rule_type: number;
536
+ rule_conditions?: RuleCondition[];
537
+ result_detail: {
538
+ main_product: {
539
+ variant_list: Array<{
540
+ variant_id: string;
541
+ sku: string;
542
+ handle: string;
543
+ }>;
544
+ all_store_variant: boolean;
545
+ };
546
+ order_discount_conf: {
547
+ base_price: OrderBasePriceType;
548
+ tiered_discounts: TieredDiscount[];
549
+ };
550
+ };
551
+ };
552
+
553
+ interface OrderDiscountResult {
554
+ qualifyingDiscount: TieredDiscount | null;
555
+ nextTierGoal: TieredDiscount | null;
556
+ activeCampaign: OrderDiscountConfig | null;
557
+ discountAmount: number;
558
+ cartTotalForDiscount: number;
559
+ isLoading: boolean;
560
+ }
561
+ /**
562
+ * [计算型 Hook]
563
+ * 根据购物车、活动配置和用户信息,计算出应得的订单折扣和下一个目标。
564
+ * 此 Hook 不产生任何副作用。
565
+ * 使用示例:
566
+ * const { qualifyingDiscount, nextTierGoal, activeCampaign, discountAmount, isLoading } = useCalcOrderDiscount(cart, orderDiscountConfig);
567
+ * @param cart - 购物车
568
+ * @param orderDiscountConfig - 订单折扣配置
569
+ * @returns { OrderDiscountResult }
570
+ */
571
+ declare const useCalcOrderDiscount: (cart: any, orderDiscountConfig: OrderDiscountConfig[], customer: any) => OrderDiscountResult;
572
+
573
+ interface ShippingMethodsContext {
574
+ freeShippingMethods: PlusMemberShippingMethodConfig[];
575
+ paymentShippingMethods: PlusMemberShippingMethodConfig[];
576
+ nddOverweight: boolean;
577
+ tddOverweight: boolean;
578
+ }
579
+ interface PlusMemberContextValue<TProduct = any, TVariant = any, TProfile = any> {
580
+ plusMemberMetafields: PlusMemberSettingsMetafields;
581
+ shopCommon?: Record<string, any>;
582
+ zipCode: string;
583
+ setZipCode: (value: string) => void;
584
+ allowNextDayDelivery: boolean;
585
+ setAllowNextDayDelivery: (value: boolean) => void;
586
+ allowThirdDayDelivery: boolean;
587
+ setAllowThirdDayDelivery: (value: boolean) => void;
588
+ selectedPlusMemberMode: DeliveryPlusType;
589
+ setSelectedPlusMemberMode: (value: DeliveryPlusType) => void;
590
+ showAreaCheckModal: boolean;
591
+ setShowAreaCheckModal: (value: boolean) => void;
592
+ selectedShippingMethod?: PlusMemberShippingMethodConfig;
593
+ setSelectedShippingMethod: (value: PlusMemberShippingMethodConfig) => void;
594
+ showTip: boolean;
595
+ setShowTip: (value: boolean) => void;
596
+ showMoreShippingMethod: boolean;
597
+ setShowMoreShippingMethod: (value: boolean) => void;
598
+ variant: TVariant;
599
+ product: TProduct;
600
+ shippingMethodsContext: ShippingMethodsContext;
601
+ selectedPlusMemberProduct: SelectedPlusMemberProduct;
602
+ plusMemberProducts: NormalizedProduct[];
603
+ showPlusMemberBenefit: boolean;
604
+ setShowPlusMemberBenefit: (value: boolean) => void;
605
+ deleteMarginBottom: boolean;
606
+ setDeleteMarginBottom: (value: boolean) => void;
607
+ profile?: TProfile;
608
+ locale?: string;
609
+ }
610
+ declare const PlusMemberContext: React$1.Context<PlusMemberContextValue<any, any, any>>;
611
+
612
+ /**
613
+ * Hook to access Plus Member Context
614
+ */
615
+ declare function usePlusMemberContext<TProduct = any, TVariant = any>(): PlusMemberContextValue<any, any, any>;
616
+
617
+ /**
618
+ * Hook to get Plus Monthly Product Variant
619
+ */
620
+ declare function usePlusMonthlyProductVariant<TVariant = any>(): TVariant | undefined;
621
+
622
+ /**
623
+ * Hook to get Plus Annual Product Variant
624
+ */
625
+ declare function usePlusAnnualProductVariant<TVariant = any>(): TVariant | undefined;
626
+
627
+ /**
628
+ * Hook to calculate available shipping methods based on product weight and member status
629
+ */
630
+
631
+ interface UseShippingMethodsOptions<TVariant = any> {
632
+ /** Product variant with weight information */
633
+ variant: TVariant;
634
+ /** Zip code for delivery */
635
+ zipCode: string;
636
+ /** Whether next day delivery is allowed */
637
+ allowNextDayDelivery: boolean;
638
+ /** Whether third day delivery is allowed */
639
+ allowThirdDayDelivery: boolean;
640
+ /** Plus member metafields configuration */
641
+ plusMemberMetafields: PlusMemberSettingsMetafields;
642
+ /** Selected plus member mode */
643
+ selectedPlusMemberMode: DeliveryPlusType;
644
+ /** Whether user is a plus member */
645
+ isPlus?: boolean;
646
+ /** Available NDD coupon code */
647
+ nddCoupon?: string;
648
+ /** Available TDD coupon code */
649
+ tddCoupon?: string;
650
+ }
651
+ interface UseShippingMethodsResult {
652
+ freeShippingMethods: PlusMemberShippingMethodConfig[];
653
+ paymentShippingMethods: PlusMemberShippingMethodConfig[];
654
+ nddOverweight: boolean;
655
+ tddOverweight: boolean;
656
+ }
657
+ /**
658
+ * Calculate available shipping methods based on product weight, member status, and available coupons
659
+ *
660
+ * @param options - Configuration options
661
+ * @returns Shipping methods categorized by free/payment and overweight status
662
+ *
663
+ * @example
664
+ * ```tsx
665
+ * const { freeShippingMethods, paymentShippingMethods, nddOverweight, tddOverweight } = useShippingMethods({
666
+ * variant,
667
+ * zipCode,
668
+ * allowNextDayDelivery,
669
+ * allowThirdDayDelivery,
670
+ * plusMemberMetafields,
671
+ * selectedPlusMemberMode,
672
+ * isPlus: profile?.isPlus,
673
+ * nddCoupon,
674
+ * tddCoupon,
675
+ * })
676
+ * ```
677
+ */
678
+ declare function useShippingMethods<TVariant extends {
679
+ weight?: number;
680
+ } = any>(options: UseShippingMethodsOptions<TVariant>): UseShippingMethodsResult;
681
+
682
+ /**
683
+ * Hook to check shipping method availability and automatically adjust selection
684
+ */
685
+ declare function useShippingMethodAvailableCheck(): void;
686
+
687
+ /**
688
+ * Hook to replace cart plus member product
689
+ *
690
+ * When adding a monthly membership while an annual membership exists in cart,
691
+ * the annual membership will be replaced and vice versa.
692
+ *
693
+ * @returns Handler function to replace conflicting membership products
694
+ *
695
+ * @example
696
+ * ```tsx
697
+ * const replaceCartPlusMember = useReplaceCartPlusMember()
698
+ *
699
+ * // Call before adding new membership product
700
+ * await replaceCartPlusMember()
701
+ * ```
702
+ */
703
+ declare const useReplaceCartPlusMember: () => () => Promise<void>;
704
+
705
+ /**
706
+ * Hook to get delivery discount codes from delivery data
707
+ *
708
+ * Extracts and returns the discount codes from the delivery custom data.
709
+ *
710
+ * @param deliveryData - Delivery data containing custom attributes
711
+ * @returns Array of discount codes or undefined
712
+ *
713
+ * @example
714
+ * ```tsx
715
+ * const deliveryCodes = usePlusMemberDeliveryCodes({ deliveryData })
716
+ * ```
717
+ */
718
+ declare const usePlusMemberDeliveryCodes: ({ deliveryData, }: {
719
+ deliveryData?: DeliveryData;
720
+ }) => string[] | undefined;
721
+
722
+ type Attribute = {
723
+ key: string;
724
+ value: string;
725
+ };
726
+ type Discount = {
727
+ amount: number;
728
+ code?: string;
729
+ };
730
+ type Image = {
731
+ url: string;
732
+ altText?: string;
733
+ width?: number;
734
+ height?: number;
735
+ };
736
+ type Measurement = {
737
+ value: number;
738
+ unit: string;
739
+ };
740
+ type ExportSelectedOption = {
741
+ id?: string;
742
+ name: string;
743
+ value: string;
744
+ };
745
+ type ExportProductVariant = {
746
+ id: string;
747
+ sku: string;
748
+ name: string;
749
+ requiresShipping: boolean;
750
+ price: number;
751
+ listPrice: number;
752
+ image?: Image;
753
+ isInStock?: boolean;
754
+ availableForSale?: boolean;
755
+ weight?: number;
756
+ height?: Measurement;
757
+ width?: Measurement;
758
+ depth?: Measurement;
759
+ metafields?: any;
760
+ quantityAvailable: number;
761
+ currentlyNotInStock: boolean;
762
+ };
763
+ type ExportDiscountAllocations = {
764
+ amount: number;
765
+ code: string;
766
+ };
767
+ type ExportLineItem = {
768
+ id: string;
769
+ variantId: string;
770
+ productId: string;
771
+ name: string;
772
+ quantity: number;
773
+ discounts: Discount[];
774
+ path: string;
775
+ variant: ExportProductVariant;
776
+ totalAmount: number;
777
+ subtotalAmount: number;
778
+ options?: ExportSelectedOption[];
779
+ discountAllocations?: ExportDiscountAllocations[];
780
+ product?: any;
781
+ weight?: number;
782
+ customAttributes?: Array<Omit<Attribute, '__typename'>>;
783
+ freeGiftVariant?: ExportLineItem;
784
+ relatedVariant?: ExportLineItem;
785
+ };
786
+ type ExportDiscounts = {
787
+ applicable: boolean;
788
+ code: string;
789
+ };
790
+ type ExportCart = {
791
+ id: string;
792
+ customerId?: string;
793
+ email?: string;
794
+ createdAt: string;
795
+ currency: {
796
+ code: string;
797
+ };
798
+ taxesIncluded?: boolean;
799
+ lineItems: ExportLineItem[];
800
+ totallineItemsDiscount?: number;
801
+ orderDiscounts?: number;
802
+ lineItemsSubtotalPrice: number;
803
+ subtotalPrice: number;
804
+ totalPrice: number;
805
+ totalTaxAmount: number;
806
+ discountCodes: ExportDiscounts[];
807
+ discountAllocations?: ExportDiscountAllocations[];
808
+ discounts?: Discount[];
809
+ url?: string;
810
+ ready: boolean;
811
+ orderStatusUrl?: any;
812
+ customAttributes?: any;
813
+ maxNum?: number;
814
+ };
815
+
816
+ /**
817
+ * Hook to generate custom attributes for cart line items
818
+ *
819
+ * Creates custom attributes based on delivery data to be attached to line items.
820
+ *
821
+ * @param deliveryData - Delivery data containing custom attributes
822
+ * @returns Array of custom attributes for line items
823
+ *
824
+ * @example
825
+ * ```tsx
826
+ * const itemAttributes = usePlusMemberItemCustomAttributes({ deliveryData })
827
+ *
828
+ * // Use in addToCart
829
+ * await addToCart({
830
+ * lineItems: lineItems.map(item => ({
831
+ * ...item,
832
+ * customAttributes: [...(item.customAttributes || []), ...itemAttributes]
833
+ * }))
834
+ * })
835
+ * ```
836
+ */
837
+ declare const usePlusMemberItemCustomAttributes: ({ deliveryData, }: {
838
+ deliveryData?: DeliveryData;
839
+ }) => Attribute[];
840
+
841
+ interface CustomerOrder {
842
+ edges?: Array<any>;
843
+ }
844
+ interface Customer {
845
+ orders?: CustomerOrder;
846
+ }
847
+ /**
848
+ * Hook to generate custom attributes for checkout
849
+ *
850
+ * Creates custom attributes based on delivery data, profile, and customer information
851
+ * to be attached to the checkout.
852
+ *
853
+ * Requires profile to be provided via PlusMemberContext.
854
+ *
855
+ * @param deliveryData - Delivery data containing custom attributes
856
+ * @param product - Product information (optional, for hiding shipping benefits check)
857
+ * @param variant - Variant information (optional, for presale and hiding shipping benefits check)
858
+ * @param customer - Customer information (optional, for user type determination)
859
+ * @param isShowShippingBenefits - Function to check if shipping benefits should be shown (optional)
860
+ * @returns Array of custom attributes for checkout
861
+ *
862
+ * @example
863
+ * ```tsx
864
+ * const checkoutAttributes = usePlusMemberCheckoutCustomAttributes({
865
+ * deliveryData,
866
+ * product,
867
+ * variant,
868
+ * customer,
869
+ * isShowShippingBenefits
870
+ * })
871
+ *
872
+ * // Use in checkout
873
+ * await createCheckout({
874
+ * lineItems,
875
+ * customAttributes: checkoutAttributes
876
+ * })
877
+ * ```
878
+ */
879
+ declare const usePlusMemberCheckoutCustomAttributes: <TProduct = any, TVariant = any>({ deliveryData, product, variant, customer, isShowShippingBenefits, }: {
880
+ deliveryData?: DeliveryData;
881
+ product?: TProduct;
882
+ variant?: TVariant;
883
+ customer?: Customer;
884
+ isShowShippingBenefits?: (args: {
885
+ variant?: TVariant;
886
+ product?: TProduct;
887
+ setting: any;
888
+ }) => boolean;
889
+ }) => Attribute[];
890
+
891
+ /**
892
+ * useAutoRemovePlusMemberInCart Hook
893
+ * 自动移除购物车中的会员产品
894
+ * 年费会员删除月费会员产品,月费会员删除年费会员产品
895
+ */
896
+
897
+ interface UseAutoRemovePlusMemberInCartProps {
898
+ /** Plus Member 配置 */
899
+ metafields: PlusMemberSettingsMetafields;
900
+ /** 用户是否是月费会员 */
901
+ isMonthlyPlus?: boolean;
902
+ /** 用户是否是年费会员 */
903
+ isAnnualPlus?: boolean;
904
+ }
905
+ /**
906
+ * 自动移除购物车中的会员产品
907
+ *
908
+ * @param props - Hook 参数
909
+ * @param props.metafields - Plus Member 配置
910
+ * @param props.isMonthlyPlus - 用户是否是月费会员
911
+ * @param props.isAnnualPlus - 用户是否是年费会员
912
+ *
913
+ * @example
914
+ * ```tsx
915
+ * const { profile } = useProfile()
916
+ *
917
+ * useAutoRemovePlusMemberInCart({
918
+ * metafields: plusMemberSettings,
919
+ * isMonthlyPlus: profile?.isMonthlyPlus,
920
+ * isAnnualPlus: profile?.isAnnualPlus,
921
+ * })
922
+ * ```
923
+ */
924
+ declare function useAutoRemovePlusMemberInCart({ metafields, isMonthlyPlus, isAnnualPlus, }: UseAutoRemovePlusMemberInCartProps): void;
925
+
926
+ /**
927
+ * useHasPlusMemberInCart Hook
928
+ * 判断购物车中是否包含年费会员或月费会员产品
929
+ */
930
+
931
+ interface UseHasPlusMemberInCartProps {
932
+ /** Plus Member 配置 */
933
+ memberSetting?: PlusMemberSettingsMetafields;
934
+ /** 购物车数据 */
935
+ cart?: NormalizedCart;
936
+ }
937
+ interface HasPlusMemberInCartResult {
938
+ /** 购物车中是否有任何会员产品 */
939
+ hasPlusMember: boolean;
940
+ /** 购物车中是否有月费会员产品 */
941
+ hasMonthlyPlus: boolean;
942
+ /** 购物车中是否有年费会员产品 */
943
+ hasAnnualPlus: boolean;
944
+ /** 月费会员产品的 line item */
945
+ monthlyPlusItem?: {
946
+ id: string;
947
+ quantity: number;
948
+ handle?: string;
949
+ sku?: string;
950
+ };
951
+ /** 年费会员产品的 line item */
952
+ annualPlusItem?: {
953
+ id: string;
954
+ quantity: number;
955
+ handle?: string;
956
+ sku?: string;
957
+ };
958
+ }
959
+ /**
960
+ * 判断购物车中是否包含年费会员或月费会员产品
961
+ *
962
+ * @param props - Hook 参数
963
+ * @param props.metafields - Plus Member 配置
964
+ * @returns 会员产品信息
965
+ *
966
+ * @example
967
+ * ```tsx
968
+ * const {
969
+ * hasPlusMember,
970
+ * hasMonthlyPlus,
971
+ * hasAnnualPlus,
972
+ * monthlyPlusItem,
973
+ * annualPlusItem,
974
+ * } = useHasPlusMemberInCart({
975
+ * memberSetting: plusMemberSettings,
976
+ * })
977
+ *
978
+ * if (hasPlusMember) {
979
+ * console.log('购物车中有会员产品')
980
+ * }
981
+ * ```
982
+ */
983
+ declare function useHasPlusMemberInCart({ memberSetting, cart, }: UseHasPlusMemberInCartProps): HasPlusMemberInCartResult;
984
+
985
+ interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any> {
986
+ variant: TVariant;
987
+ product: TProduct;
988
+ metafields: PlusMemberSettingsMetafields;
989
+ shopCommon?: Record<string, any>;
990
+ initialSelectedPlusMemberMode?: DeliveryPlusType;
991
+ profile?: TProfile;
992
+ locale?: string;
993
+ }
994
+ /**
995
+ * Plus Member Provider Component
996
+ *
997
+ * Provides Plus Member context and state management to child components.
998
+ *
999
+ * @param variant - Product variant
1000
+ * @param product - Product
1001
+ * @param metafields - Plus member settings from metafields
1002
+ * @param shopCommon - Shop common settings
1003
+ * @param initialSelectedPlusMemberMode - Initial selected mode (default: 'free')
1004
+ * @param profile - User profile
1005
+ * @param locale - Locale code
1006
+ * @param children - Child components
1007
+ *
1008
+ * @example
1009
+ * ```tsx
1010
+ * <PlusMemberProvider
1011
+ * variant={variant}
1012
+ * product={product}
1013
+ * metafields={memberSettings}
1014
+ * shopCommon={shopCommon}
1015
+ * profile={profile}
1016
+ * locale={locale}
1017
+ * >
1018
+ * <YourComponent />
1019
+ * </PlusMemberProvider>
1020
+ * ```
1021
+ */
1022
+ declare const PlusMemberProvider: <TProduct = any, TVariant = any, TProfile = any>({ variant, product, shopCommon, metafields, initialSelectedPlusMemberMode, profile, locale, children, }: PropsWithChildren<PlusMemberProviderProps<TProduct, TVariant, TProfile>>) => react_jsx_runtime.JSX.Element;
1023
+
1024
+ declare const getReferralAttributes: () => {
1025
+ key: string;
1026
+ value: string;
1027
+ }[];
1028
+ declare const useCartAttributes: ({ profile, customer, cart, memberSetting, }: {
1029
+ profile: any;
1030
+ customer: any;
1031
+ cart?: NormalizedCart;
1032
+ memberSetting?: PlusMemberSettingsMetafields;
1033
+ }) => {
1034
+ attributes: Array<{
1035
+ key: string;
1036
+ value: any;
1037
+ }>;
1038
+ };
1039
+
1040
+ declare const useCartItemQuantityLimit: ({ cart, cartItem, config, }: {
1041
+ cart?: NormalizedCart;
1042
+ cartItem: NormalizedLineItem;
1043
+ config: {
1044
+ handle: Record<string, {
1045
+ min: number;
1046
+ max: number;
1047
+ }>;
1048
+ sku: Record<string, {
1049
+ min: number;
1050
+ max: number;
1051
+ }>;
1052
+ };
1053
+ }) => {
1054
+ min: number;
1055
+ max: number;
1056
+ };
1057
+
1058
+ interface GiveawayProduct {
1059
+ handle: string;
1060
+ sku: string;
1061
+ }
1062
+ interface Breakpoint {
1063
+ breakpoint: string;
1064
+ giveawayProducts: GiveawayProduct[];
1065
+ }
1066
+ interface Campaign {
1067
+ activityAvailableQuery?: string;
1068
+ activityQroperty?: string;
1069
+ breakpoints?: Array<{
1070
+ breakpoint: string;
1071
+ giveawayProducts: GiveawayProduct[];
1072
+ }>;
1073
+ includeTags?: string[];
1074
+ useTotalAmount?: boolean;
1075
+ }
1076
+ interface UseScriptAutoFreeGiftResult {
1077
+ involvedLines: NormalizedLineItem[];
1078
+ reorder: (a: NormalizedLineItem, b: NormalizedLineItem) => number;
1079
+ disableCodeRemove: boolean;
1080
+ nextFreeGiftLevel: Breakpoint | null;
1081
+ freeGiftLevel: Breakpoint | null;
1082
+ involvedSubTotal: Decimal;
1083
+ giftProductsResult?: NormalizedProduct[];
1084
+ }
1085
+ declare const useScriptAutoFreeGift: ({ campaign, _giveaway, cart, locale: providedLocale, }: {
1086
+ campaign: Campaign | null;
1087
+ _giveaway: string;
1088
+ cart: NormalizedCart | undefined;
1089
+ locale?: string;
1090
+ }) => UseScriptAutoFreeGiftResult;
1091
+
1092
+ declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoading, setLoadingState, metafieldIdentifiers, }: {
1093
+ cart?: NormalizedCart;
1094
+ mutateCart: (cart: NormalizedCart | undefined) => void;
1095
+ isCartLoading: boolean;
1096
+ setLoadingState: React.Dispatch<React.SetStateAction<any>>;
1097
+ metafieldIdentifiers?: {
1098
+ variant: HasMetafieldsIdentifier[];
1099
+ product: HasMetafieldsIdentifier[];
1100
+ };
1101
+ }) => void;
1102
+
1103
+ declare enum PriceDiscountType {
1104
+ PERCENTAGE = 1,// 百分比折扣
1105
+ FIXED_AMOUNT = 2
1106
+ }
1107
+ declare enum PriceBasePriceType {
1108
+ MIN_DISCOUNTED_PRICE = 1,// 最低折扣价
1109
+ MIN_TOTAL_PRICE = 2
1110
+ }
1111
+ type PriceDiscountConfig = {
1112
+ rule_id: number;
1113
+ rule_type: number;
1114
+ discount_type: PriceDiscountType;
1115
+ discount_value: number;
1116
+ base_price_type: PriceBasePriceType;
1117
+ applicable_products: Array<{
1118
+ product_id: string;
1119
+ variant_id?: string;
1120
+ }>;
1121
+ };
1122
+
1123
+ declare const currencyCodeMapping: Record<string, string>;
1124
+ declare const defaultSWRMutationConfiguration: SWRMutationConfiguration<any, any, any, any, any> & {
1125
+ throwOnError?: boolean;
1126
+ };
1127
+ declare const CUSTOMER_ATTRIBUTE_KEY = "_discounts_function_env";
1128
+ declare const CUSTOMER_SCRIPT_GIFT_KEY = "_giveaway_gradient_gifts";
1129
+ declare const CODE_AMOUNT_KEY = "_sku_code_money";
1130
+ declare const SCRIPT_CODE_AMOUNT_KEY = "_code_money";
1131
+ declare const MAIN_PRODUCT_CODE: string[];
1132
+
1133
+ declare const getQuery: () => Record<string, string>;
1134
+ declare function atobID(id: string): string | undefined;
1135
+ declare function btoaID(id: string, type?: 'ProductVariant' | 'Product'): string;
1136
+
1137
+ declare const getMatchedMainProductSubTotal: (cartData: any, variant_list: AutoFreeGiftMainProduct["variant_id_list"], main_product: AutoFreeGiftMainProduct) => any;
1138
+ declare const getDiscountEnvAttributeValue: (attributes?: {
1139
+ key: string;
1140
+ value: string;
1141
+ }[]) => any;
1142
+ declare const isAttributesEqual: (attrs1?: {
1143
+ key: string;
1144
+ value: string;
1145
+ }[], attrs2?: {
1146
+ key: string;
1147
+ value: string;
1148
+ }[]) => boolean;
1149
+ declare const safeParseJson: (str: string) => any;
1150
+ declare function preCheck(rule_conditions: RuleCondition[], userTags: string[], currentDealsTypes: string[]): boolean;
1151
+ declare const formatScriptAutoFreeGift: ({ scriptAutoFreeGiftResult, gradient_gifts, locale, }: {
1152
+ scriptAutoFreeGiftResult: UseScriptAutoFreeGiftResult;
1153
+ gradient_gifts: any;
1154
+ locale: string;
1155
+ }) => any[];
1156
+ declare const formatFunctionAutoFreeGift: ({ qualifyingGift, giftProductsResult, locale, }: {
1157
+ locale: string;
1158
+ qualifyingGift?: FormattedGift | null;
1159
+ giftProductsResult?: NormalizedProduct[] | [];
1160
+ }) => any[];
1161
+
1162
+ interface UseProductOptions extends SWRConfiguration<NormalizedProduct | undefined> {
1163
+ handle?: string;
1164
+ metafieldIdentifiers?: Array<{
1165
+ namespace: string;
1166
+ key: string;
1167
+ }>;
1168
+ }
1169
+ /**
1170
+ * Hook to fetch a single product by handle
1171
+ *
1172
+ * @param options - Hook options including handle and SWR configuration
1173
+ * @returns SWR response with product data
1174
+ *
1175
+ * @example
1176
+ * ```typescript
1177
+ * function ProductPage() {
1178
+ * const { data: product, error, isLoading } = useProduct({
1179
+ * handle: 'my-product'
1180
+ * })
1181
+ *
1182
+ * if (isLoading) return <div>Loading...</div>
1183
+ * if (error) return <div>Error loading product</div>
1184
+ * if (!product) return <div>Product not found</div>
1185
+ *
1186
+ * return (
1187
+ * <div>
1188
+ * <h1>{product.title}</h1>
1189
+ * <p>{product.description}</p>
1190
+ * <p>${product.price.amount}</p>
1191
+ * </div>
1192
+ * )
1193
+ * }
1194
+ * ```
1195
+ */
1196
+ declare function useProduct(options?: UseProductOptions): swr.SWRResponse<NormalizedProduct | undefined, any, SWRConfiguration<NormalizedProduct | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedProduct | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedProduct | undefined>)> | undefined>;
1197
+
1198
+ interface UseAllProductsOptions extends SWRConfiguration<NormalizedProduct[]> {
1199
+ first?: number;
1200
+ query?: string;
1201
+ sortKey?: 'TITLE' | 'PRODUCT_TYPE' | 'VENDOR' | 'UPDATED_AT' | 'CREATED_AT' | 'BEST_SELLING' | 'PRICE' | 'RELEVANCE';
1202
+ reverse?: boolean;
1203
+ metafieldIdentifiers?: Array<{
1204
+ namespace: string;
1205
+ key: string;
1206
+ }>;
1207
+ }
1208
+ /**
1209
+ * Hook to fetch all products
1210
+ *
1211
+ * This hook automatically handles pagination and fetches all products.
1212
+ * Use with caution on stores with many products.
1213
+ *
1214
+ * @param options - Hook options including query parameters and SWR configuration
1215
+ * @returns SWR response with products array
1216
+ *
1217
+ * @example
1218
+ * ```typescript
1219
+ * function ProductList() {
1220
+ * const { data: products, error, isLoading } = useAllProducts({
1221
+ * sortKey: 'TITLE',
1222
+ * reverse: false
1223
+ * })
1224
+ *
1225
+ * if (isLoading) return <div>Loading...</div>
1226
+ * if (error) return <div>Error loading products</div>
1227
+ *
1228
+ * return (
1229
+ * <div>
1230
+ * {products?.map(product => (
1231
+ * <div key={product.id}>
1232
+ * <h2>{product.title}</h2>
1233
+ * <p>${product.price.amount}</p>
1234
+ * </div>
1235
+ * ))}
1236
+ * </div>
1237
+ * )
1238
+ * }
1239
+ * ```
1240
+ */
1241
+ declare function useAllProducts(options?: UseAllProductsOptions): swr.SWRResponse<NormalizedProduct[], any, SWRConfiguration<NormalizedProduct[], any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedProduct[]>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedProduct[]>)> | undefined>;
1242
+
1243
+ interface UseProductsByHandlesOptions extends SWRConfiguration<NormalizedProduct[]> {
1244
+ handles?: string[];
1245
+ metafieldIdentifiers?: {
1246
+ product: HasMetafieldsIdentifier[];
1247
+ variant: HasMetafieldsIdentifier[];
1248
+ };
1249
+ }
1250
+ /**
1251
+ * Hook to fetch multiple products by their handles
1252
+ *
1253
+ * @param options - Hook options including handles array and SWR configuration
1254
+ * @returns SWR response with products array
1255
+ *
1256
+ * @example
1257
+ * ```typescript
1258
+ * function FeaturedProducts() {
1259
+ * const { data: products, error, isLoading } = useProductsByHandles({
1260
+ * handles: ['product-1', 'product-2', 'product-3']
1261
+ * })
1262
+ *
1263
+ * if (isLoading) return <div>Loading...</div>
1264
+ * if (error) return <div>Error loading products</div>
1265
+ *
1266
+ * return (
1267
+ * <div>
1268
+ * {products?.map(product => (
1269
+ * <div key={product.id}>
1270
+ * <h2>{product.title}</h2>
1271
+ * <p>${product.price.amount}</p>
1272
+ * </div>
1273
+ * ))}
1274
+ * </div>
1275
+ * )
1276
+ * }
1277
+ * ```
1278
+ */
1279
+ declare function useProductsByHandles(options?: UseProductsByHandlesOptions): swr.SWRResponse<NormalizedProduct[], any, SWRConfiguration<NormalizedProduct[], any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedProduct[]>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedProduct[]>)> | undefined>;
1280
+
1281
+ /**
1282
+ * useVariant Hook
1283
+ *
1284
+ * Client-side hook to get the selected variant based on selected options
1285
+ */
1286
+
1287
+ type Options = Record<string, string>;
1288
+ /**
1289
+ * Hook to manage variant selection based on selected options
1290
+ *
1291
+ * @param product - The product object
1292
+ * @param selectedOptions - Currently selected options { Color: 'Red', Size: 'M' }
1293
+ * @returns The matching variant
1294
+ *
1295
+ * @example
1296
+ * ```typescript
1297
+ * function ProductDetail() {
1298
+ * const { data: product } = useProduct({ handle: 'my-product' })
1299
+ * const [selectedOptions, setSelectedOptions] = useState({ Color: 'Red', Size: 'M' })
1300
+ * const variant = useVariant({ product, selectedOptions })
1301
+ *
1302
+ * return (
1303
+ * <div>
1304
+ * <h1>{product.title}</h1>
1305
+ * <p>Selected: {variant.title}</p>
1306
+ * <p>Price: ${variant.price.amount}</p>
1307
+ * <p>Available: {variant.availableForSale ? 'Yes' : 'No'}</p>
1308
+ * </div>
1309
+ * )
1310
+ * }
1311
+ * ```
1312
+ */
1313
+ declare function useVariant({ product, selectedOptions, }: {
1314
+ product?: NormalizedProduct;
1315
+ selectedOptions: Options;
1316
+ }): NormalizedProductVariant | undefined;
1317
+
1318
+ /**
1319
+ * usePrice Hook
1320
+ *
1321
+ * Client-side hook to format price for display
1322
+ */
1323
+ interface UsePriceOptions {
1324
+ amount: number;
1325
+ baseAmount?: number;
1326
+ currencyCode: string;
1327
+ soldOutDescription?: string;
1328
+ maximumFractionDigits?: number;
1329
+ minimumFractionDigits?: number;
1330
+ removeTrailingZeros?: boolean;
1331
+ }
1332
+ interface UsePriceResult {
1333
+ price: string;
1334
+ basePrice?: string;
1335
+ free: boolean;
1336
+ }
1337
+ /**
1338
+ * Hook to format price for display
1339
+ *
1340
+ * @param options - Price formatting options
1341
+ * @returns Formatted price object
1342
+ *
1343
+ * @example
1344
+ * ```typescript
1345
+ * function ProductPrice({ variant }) {
1346
+ * const { price, basePrice, free } = usePrice({
1347
+ * amount: variant.price.amount,
1348
+ * baseAmount: variant.compareAtPrice?.amount,
1349
+ * currencyCode: variant.price.currencyCode
1350
+ * })
1351
+ *
1352
+ * return (
1353
+ * <div>
1354
+ * {free ? (
1355
+ * <span>Free</span>
1356
+ * ) : (
1357
+ * <>
1358
+ * <span className="price">{price}</span>
1359
+ * {basePrice && <span className="original">{basePrice}</span>}
1360
+ * </>
1361
+ * )}
1362
+ * </div>
1363
+ * )
1364
+ * }
1365
+ * ```
1366
+ */
1367
+ declare function usePrice({ amount, baseAmount, currencyCode, soldOutDescription, maximumFractionDigits, minimumFractionDigits, removeTrailingZeros, }: UsePriceOptions): UsePriceResult;
1368
+
1369
+ /**
1370
+ * useSelectedOptions Hook
1371
+ *
1372
+ * Client-side hook to manage selected product options
1373
+ */
1374
+
1375
+ type SelectedOptionsResult = [Options, Dispatch<SetStateAction<Options>>];
1376
+ /**
1377
+ * Hook to manage selected product options based on URL query or SKU
1378
+ *
1379
+ * @param product - The product object
1380
+ * @param sku - Optional SKU to match variant
1381
+ * @returns Tuple of [options, setOptions]
1382
+ *
1383
+ * @example
1384
+ * ```typescript
1385
+ * function ProductDetail() {
1386
+ * const { data: product } = useProduct({ handle: 'my-product' })
1387
+ * const [selectedOptions, setSelectedOptions] = useSelectedOptions(product)
1388
+ * const variant = useVariant({ product, selectedOptions })
1389
+ *
1390
+ * const handleOptionChange = (name: string, value: string) => {
1391
+ * setSelectedOptions(prev => ({ ...prev, [name]: value }))
1392
+ * }
1393
+ *
1394
+ * return (
1395
+ * <div>
1396
+ * {product?.options.map(option => (
1397
+ * <select
1398
+ * key={option.id}
1399
+ * value={selectedOptions[option.name] || ''}
1400
+ * onChange={(e) => handleOptionChange(option.name, e.target.value)}
1401
+ * >
1402
+ * {option.values.map(value => (
1403
+ * <option key={value.label} value={value.label}>
1404
+ * {value.label}
1405
+ * </option>
1406
+ * ))}
1407
+ * </select>
1408
+ * ))}
1409
+ * <p>Selected: {variant?.title}</p>
1410
+ * </div>
1411
+ * )
1412
+ * }
1413
+ * ```
1414
+ */
1415
+ declare function useSelectedOptions(product?: NormalizedProduct, sku?: string): SelectedOptionsResult;
1416
+
1417
+ /**
1418
+ * useProductUrl Hook
1419
+ *
1420
+ * Hook to generate product URLs with variant query params
1421
+ * Requires routerAdapter to be configured in ShopifyProvider
1422
+ */
1423
+
1424
+ /**
1425
+ * Hook to generate product URLs
1426
+ *
1427
+ * @param otherQuery - Additional query parameters to include
1428
+ * @returns Function to generate product URL
1429
+ *
1430
+ * @example
1431
+ * ```typescript
1432
+ * function ProductCard({ product, variant }) {
1433
+ * const getProductUrl = useProductUrl()
1434
+ *
1435
+ * const url = getProductUrl({ product, variant })
1436
+ *
1437
+ * return (
1438
+ * <a href={url}>
1439
+ * <h2>{product.title}</h2>
1440
+ * <p>{variant.title}</p>
1441
+ * </a>
1442
+ * )
1443
+ * }
1444
+ * ```
1445
+ *
1446
+ * @example With additional query params
1447
+ * ```typescript
1448
+ * function ProductCard({ product, variant }) {
1449
+ * const getProductUrl = useProductUrl({ utm_source: 'email' })
1450
+ *
1451
+ * const url = getProductUrl({ product, variant })
1452
+ * // URL will include: ?variant=123&utm_source=email
1453
+ *
1454
+ * return <a href={url}>{product.title}</a>
1455
+ * }
1456
+ * ```
1457
+ */
1458
+ declare function useProductUrl(otherQuery?: Record<string, string>): ({ product, variant }: {
1459
+ product?: NormalizedProduct;
1460
+ variant?: NormalizedProductVariant;
1461
+ }) => string;
1462
+
1463
+ /**
1464
+ * useUpdateVariantQuery Hook
1465
+ *
1466
+ * Hook to automatically update URL query string when variant changes
1467
+ */
1468
+
1469
+ /**
1470
+ * Hook to update URL query string when variant changes
1471
+ *
1472
+ * This hook automatically updates the browser URL with the selected variant ID
1473
+ * without causing a page reload. Useful for shareable URLs and browser history.
1474
+ *
1475
+ * @param variant - The selected variant
1476
+ *
1477
+ * @example
1478
+ * ```typescript
1479
+ * function ProductDetail() {
1480
+ * const { data: product } = useProduct({ handle: 'my-product' })
1481
+ * const [selectedOptions, setSelectedOptions] = useSelectedOptions(product)
1482
+ * const variant = useVariant({ product, selectedOptions })
1483
+ *
1484
+ * // Automatically updates URL when variant changes
1485
+ * useUpdateVariantQuery(variant)
1486
+ *
1487
+ * return (
1488
+ * <div>
1489
+ * <h1>{product?.title}</h1>
1490
+ * <p>Current variant: {variant?.title}</p>
1491
+ * {/* URL will be: /products/my-product?variant=123456 *\/}
1492
+ * </div>
1493
+ * )
1494
+ * }
1495
+ * ```
1496
+ */
1497
+ declare function useUpdateVariantQuery(variant?: NormalizedProductVariant): void;
1498
+
1499
+ /**
1500
+ * useVariantMedia Hook
1501
+ *
1502
+ * Hook to get media (images and videos) for the selected variant
1503
+ */
1504
+
1505
+ type ImageMedia = Media & {
1506
+ mediaContentType: 'IMAGE';
1507
+ };
1508
+ type VideoMedia = Media & {
1509
+ mediaContentType: 'VIDEO' | 'EXTERNAL_VIDEO';
1510
+ };
1511
+ interface VariantMedia {
1512
+ productList: ImageMedia[];
1513
+ sceneList: ImageMedia[];
1514
+ videoList: VideoMedia[];
1515
+ }
1516
+ /**
1517
+ * Hook to get media for the selected variant
1518
+ *
1519
+ * @param product - The product object
1520
+ * @param variant - The selected variant
1521
+ * @returns Object with productList (first image), sceneList (other images), videoList
1522
+ *
1523
+ * @example
1524
+ * ```typescript
1525
+ * function ProductGallery() {
1526
+ * const { data: product } = useProduct({ handle: 'my-product' })
1527
+ * const [selectedOptions, setSelectedOptions] = useSelectedOptions(product)
1528
+ * const variant = useVariant({ product, selectedOptions })
1529
+ * const { productList, sceneList, videoList } = useVariantMedia({ product, variant })
1530
+ *
1531
+ * return (
1532
+ * <div>
1533
+ * {/* Main product image *\/}
1534
+ * {productList.map(media => (
1535
+ * <img key={media.id} src={media.image?.url} alt={media.alt} />
1536
+ * ))}
1537
+ *
1538
+ * {/* Scene/detail images *\/}
1539
+ * {sceneList.map(media => (
1540
+ * <img key={media.id} src={media.image?.url} alt={media.alt} />
1541
+ * ))}
1542
+ *
1543
+ * {/* Videos *\/}
1544
+ * {videoList.map(media => (
1545
+ * <video key={media.id} src={media.sources?.[0]?.url} controls />
1546
+ * ))}
1547
+ * </div>
1548
+ * )
1549
+ * }
1550
+ * ```
1551
+ */
1552
+ declare function useVariantMedia({ product, variant, }: {
1553
+ product?: NormalizedProduct;
1554
+ variant?: NormalizedProductVariant;
1555
+ }): VariantMedia;
1556
+
1557
+ interface UseCollectionOptions extends SWRConfiguration<NormalizedCollection | undefined> {
1558
+ handle?: string;
1559
+ metafieldIdentifiers?: Array<{
1560
+ namespace: string;
1561
+ key: string;
1562
+ }>;
1563
+ }
1564
+ declare function useCollection(options?: UseCollectionOptions): swr.SWRResponse<NormalizedCollection | undefined, any, SWRConfiguration<NormalizedCollection | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedCollection | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedCollection | undefined>)> | undefined>;
1565
+
1566
+ interface UseAllCollectionsOptions extends SWRConfiguration<NormalizedCollection[]> {
1567
+ first?: number;
1568
+ query?: string;
1569
+ sortKey?: 'TITLE' | 'UPDATED_AT' | 'ID' | 'RELEVANCE';
1570
+ reverse?: boolean;
1571
+ metafieldIdentifiers?: Array<{
1572
+ namespace: string;
1573
+ key: string;
1574
+ }>;
1575
+ }
1576
+ declare function useAllCollections(options?: UseAllCollectionsOptions): swr.SWRResponse<NormalizedCollection[], any, SWRConfiguration<NormalizedCollection[], any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedCollection[]>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedCollection[]>)> | undefined>;
1577
+
1578
+ interface UseCollectionsOptions extends SWRConfiguration<CollectionsConnection> {
1579
+ first?: number;
1580
+ after?: string;
1581
+ query?: string;
1582
+ sortKey?: 'TITLE' | 'UPDATED_AT' | 'ID' | 'RELEVANCE';
1583
+ reverse?: boolean;
1584
+ metafieldIdentifiers?: Array<{
1585
+ namespace: string;
1586
+ key: string;
1587
+ }>;
1588
+ }
1589
+ declare function useCollections(options?: UseCollectionsOptions): swr.SWRResponse<CollectionsConnection, any, SWRConfiguration<CollectionsConnection, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<CollectionsConnection>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<CollectionsConnection>)> | undefined>;
1590
+
1591
+ interface UseBlogOptions extends SWRConfiguration<NormalizedBlog | undefined> {
1592
+ handle?: string;
1593
+ metafieldIdentifiers?: Array<{
1594
+ namespace: string;
1595
+ key: string;
1596
+ }>;
1597
+ }
1598
+ declare function useBlog(options?: UseBlogOptions): swr.SWRResponse<NormalizedBlog | undefined, any, SWRConfiguration<NormalizedBlog | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedBlog | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedBlog | undefined>)> | undefined>;
1599
+
1600
+ interface UseAllBlogsOptions extends SWRConfiguration<NormalizedBlog[]> {
1601
+ first?: number;
1602
+ query?: string;
1603
+ metafieldIdentifiers?: Array<{
1604
+ namespace: string;
1605
+ key: string;
1606
+ }>;
1607
+ }
1608
+ declare function useAllBlogs(options?: UseAllBlogsOptions): swr.SWRResponse<NormalizedBlog[], any, SWRConfiguration<NormalizedBlog[], any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedBlog[]>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedBlog[]>)> | undefined>;
1609
+
1610
+ interface UseArticleOptions extends SWRConfiguration<NormalizedArticle | undefined> {
1611
+ blogHandle?: string;
1612
+ articleHandle?: string;
1613
+ metafieldIdentifiers?: Array<{
1614
+ namespace: string;
1615
+ key: string;
1616
+ }>;
1617
+ }
1618
+ declare function useArticle(options?: UseArticleOptions): swr.SWRResponse<NormalizedArticle | undefined, any, SWRConfiguration<NormalizedArticle | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedArticle | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedArticle | undefined>)> | undefined>;
1619
+
1620
+ interface UseArticlesOptions extends SWRConfiguration<NormalizedArticle[]> {
1621
+ first?: number;
1622
+ query?: string;
1623
+ sortKey?: 'PUBLISHED_AT' | 'UPDATED_AT' | 'TITLE' | 'ID' | 'RELEVANCE';
1624
+ reverse?: boolean;
1625
+ metafieldIdentifiers?: Array<{
1626
+ namespace: string;
1627
+ key: string;
1628
+ }>;
1629
+ }
1630
+ declare function useArticles(options?: UseArticlesOptions): swr.SWRResponse<NormalizedArticle[], any, SWRConfiguration<NormalizedArticle[], any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedArticle[]>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedArticle[]>)> | undefined>;
1631
+
1632
+ interface UseArticlesInBlogOptions extends SWRConfiguration<NormalizedArticle[]> {
1633
+ blogHandle?: string;
1634
+ first?: number;
1635
+ sortKey?: 'PUBLISHED_AT' | 'UPDATED_AT' | 'TITLE' | 'ID' | 'RELEVANCE';
1636
+ reverse?: boolean;
1637
+ metafieldIdentifiers?: Array<{
1638
+ namespace: string;
1639
+ key: string;
1640
+ }>;
1641
+ }
1642
+ declare function useArticlesInBlog(options?: UseArticlesInBlogOptions): swr.SWRResponse<NormalizedArticle[], any, SWRConfiguration<NormalizedArticle[], any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedArticle[]>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<NormalizedArticle[]>)> | undefined>;
1643
+
1644
+ type SearchResultType = 'ARTICLE' | 'PAGE' | 'PRODUCT';
1645
+ interface SearchResultItem {
1646
+ type: SearchResultType;
1647
+ id?: string;
1648
+ handle?: string;
1649
+ title?: string;
1650
+ description?: string;
1651
+ url?: string;
1652
+ image?: {
1653
+ url: string;
1654
+ altText?: string;
1655
+ };
1656
+ }
1657
+ interface SearchResult {
1658
+ items: SearchResultItem[];
1659
+ totalCount: number;
1660
+ pageInfo?: {
1661
+ hasNextPage: boolean;
1662
+ endCursor?: string;
1663
+ };
1664
+ }
1665
+ interface UseSearchOptions extends SWRConfiguration<SearchResult | undefined> {
1666
+ query?: string;
1667
+ first?: number;
1668
+ types?: SearchResultType[];
1669
+ productFilters?: any[];
1670
+ }
1671
+ declare function useSearch(options?: UseSearchOptions): swr.SWRResponse<SearchResult | undefined, any, SWRConfiguration<SearchResult | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<SearchResult | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<SearchResult | undefined>)> | undefined>;
1672
+
1673
+ interface SiteInfo {
1674
+ name: string;
1675
+ description?: string;
1676
+ primaryDomain: {
1677
+ url: string;
1678
+ host: string;
1679
+ };
1680
+ brand?: {
1681
+ logo?: {
1682
+ image?: {
1683
+ url: string;
1684
+ };
1685
+ };
1686
+ colors?: {
1687
+ primary?: string;
1688
+ secondary?: string;
1689
+ };
1690
+ };
1691
+ metafields?: Record<string, any>;
1692
+ }
1693
+ interface UseSiteOptions extends SWRConfiguration<SiteInfo | undefined> {
1694
+ metafieldIdentifiers?: Array<{
1695
+ namespace: string;
1696
+ key: string;
1697
+ }>;
1698
+ }
1699
+ declare function useSite(options?: UseSiteOptions): swr.SWRResponse<SiteInfo | undefined, any, SWRConfiguration<SiteInfo | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<SiteInfo | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<SiteInfo | undefined>)> | undefined>;
1700
+
1701
+ /**
1702
+ * useIntersection Hook
1703
+ *
1704
+ * Observes element visibility using IntersectionObserver API
1705
+ */
1706
+
1707
+ interface UseIntersectionOptions {
1708
+ /** Callback function when element becomes visible */
1709
+ callback: () => void;
1710
+ /** Only trigger callback once (default: false) */
1711
+ once?: boolean;
1712
+ /** Root element for intersection (default: viewport) */
1713
+ root?: Element | null;
1714
+ /** Margin around root (default: '0px') */
1715
+ rootMargin?: string;
1716
+ /** Visibility threshold 0-1 (default: 0.8) */
1717
+ threshold?: number;
1718
+ }
1719
+ /**
1720
+ * Hook to observe element visibility with IntersectionObserver
1721
+ *
1722
+ * Triggers a callback when the target element becomes visible in the viewport
1723
+ *
1724
+ * @param targetRef - React ref to the target element
1725
+ * @param options - Intersection observer options
1726
+ *
1727
+ * @example
1728
+ * ```typescript
1729
+ * function LazyImage() {
1730
+ * const imageRef = useRef<HTMLImageElement>(null)
1731
+ * const [loaded, setLoaded] = useState(false)
1732
+ *
1733
+ * useIntersection(imageRef, {
1734
+ * callback: () => setLoaded(true),
1735
+ * once: true,
1736
+ * threshold: 0.5
1737
+ * })
1738
+ *
1739
+ * return (
1740
+ * <img
1741
+ * ref={imageRef}
1742
+ * src={loaded ? actualSrc : placeholderSrc}
1743
+ * alt="Lazy loaded"
1744
+ * />
1745
+ * )
1746
+ * }
1747
+ * ```
1748
+ */
1749
+ declare function useIntersection(targetRef: RefObject<Element> | undefined, options: UseIntersectionOptions): void;
1750
+
1751
+ /**
1752
+ * useExposure Hook
1753
+ *
1754
+ * Tracks element exposure (visibility + duration) for analytics/tracking
1755
+ */
1756
+
1757
+ interface UseExposureOptions {
1758
+ /** Visibility threshold 0-1 (default: 0.5, meaning 50% visible) */
1759
+ threshold?: number;
1760
+ /** Duration in milliseconds element must be visible (default: 2000ms) */
1761
+ duration?: number;
1762
+ /** Only trigger callback once (default: true) */
1763
+ once?: boolean;
1764
+ /** Callback when element has been exposed for the required duration */
1765
+ onExposure: () => void;
1766
+ }
1767
+ /**
1768
+ * Hook to track element exposure (visibility + duration threshold)
1769
+ *
1770
+ * Useful for tracking ad impressions, product views, or any analytics
1771
+ * that require an element to be visible for a certain duration
1772
+ *
1773
+ * @param targetRef - React ref to the target element
1774
+ * @param options - Exposure tracking options
1775
+ * @returns Current visibility state
1776
+ *
1777
+ * @example
1778
+ * ```typescript
1779
+ * function ProductCard({ product }) {
1780
+ * const cardRef = useRef<HTMLDivElement>(null)
1781
+ *
1782
+ * const isVisible = useExposure(cardRef, {
1783
+ * threshold: 0.5, // 50% visible
1784
+ * duration: 2000, // 2 seconds
1785
+ * once: true, // Only track once
1786
+ * onExposure: () => {
1787
+ * // Track product impression
1788
+ * analytics.track('Product Viewed', {
1789
+ * productId: product.id,
1790
+ * productName: product.title
1791
+ * })
1792
+ * }
1793
+ * })
1794
+ *
1795
+ * return (
1796
+ * <div ref={cardRef}>
1797
+ * {product.title}
1798
+ * {isVisible && <div className="viewing-indicator" />}
1799
+ * </div>
1800
+ * )
1801
+ * }
1802
+ * ```
1803
+ */
1804
+ declare function useExposure(targetRef: RefObject<Element>, options: UseExposureOptions): boolean;
1805
+
1806
+ /**
1807
+ * useGeoLocation Hook
1808
+ *
1809
+ * Fetches and caches user's geographic location
1810
+ */
1811
+
1812
+ interface GeoLocationData {
1813
+ /** Geographic information */
1814
+ geo: {
1815
+ /** Country information */
1816
+ country?: {
1817
+ /** Country code (e.g., 'US', 'GB') */
1818
+ code?: string;
1819
+ /** Country name */
1820
+ name?: string;
1821
+ };
1822
+ /** Region/state information */
1823
+ region?: {
1824
+ code?: string;
1825
+ name?: string;
1826
+ };
1827
+ /** City name */
1828
+ city?: string;
1829
+ /** Coordinates */
1830
+ latitude?: number;
1831
+ longitude?: number;
1832
+ /** Timezone */
1833
+ timezone?: string;
1834
+ };
1835
+ /** Suggested locale based on location */
1836
+ suggestLocale?: string;
1837
+ }
1838
+ interface LocaleMapping {
1839
+ /** Countries that should map to EU locale */
1840
+ euCountries?: string[];
1841
+ /** Countries that should map to DE locale */
1842
+ deCountries?: string[];
1843
+ /** Countries that should map to AU locale */
1844
+ auCountries?: string[];
1845
+ /** Countries that should map to AE-EN locale */
1846
+ aeEnCountries?: string[];
1847
+ /** Custom country to locale mapping */
1848
+ customMapping?: Record<string, string>;
1849
+ }
1850
+ interface UseGeoLocationOptions extends SWRConfiguration<GeoLocationData | undefined> {
1851
+ /** API endpoint for fetching geo data (default: '/geolocation') */
1852
+ endpoint?: string;
1853
+ /** Cache key for localStorage (default: 'geoLocation') */
1854
+ cacheKey?: string;
1855
+ /** Cache duration in milliseconds (default: 24 hours) */
1856
+ cacheDuration?: number;
1857
+ /** Locale mapping configuration */
1858
+ localeMapping?: LocaleMapping;
1859
+ /** Enable automatic caching (default: true) */
1860
+ enableCache?: boolean;
1861
+ }
1862
+ /**
1863
+ * Hook to fetch and cache user's geographic location
1864
+ *
1865
+ * Fetches geo data from an API endpoint and caches it in localStorage
1866
+ * Automatically determines suggested locale based on country
1867
+ *
1868
+ * @param options - Geo location options
1869
+ * @returns SWR response with geo location data
1870
+ *
1871
+ * @example
1872
+ * ```typescript
1873
+ * function LocaleSwitcher() {
1874
+ * const { data: geoData, error, isLoading } = useGeoLocation({
1875
+ * endpoint: '/api/geolocation',
1876
+ * localeMapping: {
1877
+ * euCountries: ['FR', 'DE', 'IT', 'ES'],
1878
+ * auCountries: ['AU', 'NZ']
1879
+ * }
1880
+ * })
1881
+ *
1882
+ * if (isLoading) return <div>Loading...</div>
1883
+ * if (error) return <div>Error loading location</div>
1884
+ *
1885
+ * return (
1886
+ * <div>
1887
+ * <p>Country: {geoData?.geo.country?.code}</p>
1888
+ * <p>Suggested Locale: {geoData?.suggestLocale}</p>
1889
+ * </div>
1890
+ * )
1891
+ * }
1892
+ * ```
1893
+ *
1894
+ * @example
1895
+ * ```typescript
1896
+ * // With custom locale mapping
1897
+ * const { data } = useGeoLocation({
1898
+ * localeMapping: {
1899
+ * customMapping: {
1900
+ * 'JP': 'ja',
1901
+ * 'CN': 'zh-cn',
1902
+ * 'TW': 'zh-tw'
1903
+ * }
1904
+ * }
1905
+ * })
1906
+ * ```
1907
+ */
1908
+ declare function useGeoLocation(options?: UseGeoLocationOptions): ReturnType<typeof swr__default<GeoLocationData | undefined>>;
1909
+ /**
1910
+ * Get cached geo location data without fetching
1911
+ *
1912
+ * @param cacheKey - Cache key (default: 'geoLocation')
1913
+ * @returns Cached geo data or undefined
1914
+ *
1915
+ * @example
1916
+ * ```typescript
1917
+ * const cachedGeo = getCachedGeoLocation()
1918
+ * if (cachedGeo) {
1919
+ * console.log('Country:', cachedGeo.geo.country?.code)
1920
+ * }
1921
+ * ```
1922
+ */
1923
+ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | undefined;
1924
+ /**
1925
+ * Clear cached geo location data
1926
+ *
1927
+ * @param cacheKey - Cache key (default: 'geoLocation')
1928
+ *
1929
+ * @example
1930
+ * ```typescript
1931
+ * clearGeoLocationCache()
1932
+ * ```
1933
+ */
1934
+ declare function clearGeoLocationCache(cacheKey?: string): void;
1935
+
1936
+ export { PriceBasePriceType as $, type AddCartLinesInput as A, type BuyNowInput as B, type CreateCartInput as C, type DiscountLabel as D, type Config as E, type GiftTier as F, type GiftProduct as G, type RewardItem as H, type GiftProductItem as I, RuleType as J, BuyRuleType as K, type FunctionGiftResult as L, type MainProductInfo as M, type FormattedGift as N, type OrderDiscountResult as O, type CartLineInput as P, type AutoFreeGiftItem as Q, type RemoveCartLinesInput as R, SpendMoneyType as S, type AutoFreeGiftList as T, type UseAddToCartOptions as U, type VariantItem as V, OrderDiscountType as W, OrderBasePriceType as X, type TieredDiscount as Y, type OrderDiscountConfig as Z, PriceDiscountType as _, useAddCartLines as a, PlusMemberContext as a$, type PriceDiscountConfig as a0, currencyCodeMapping as a1, defaultSWRMutationConfiguration as a2, CUSTOMER_ATTRIBUTE_KEY as a3, CUSTOMER_SCRIPT_GIFT_KEY as a4, CODE_AMOUNT_KEY as a5, SCRIPT_CODE_AMOUNT_KEY as a6, MAIN_PRODUCT_CODE as a7, getQuery as a8, atobID as a9, useVariantMedia as aA, type UseCollectionOptions as aB, useCollection as aC, type UseAllCollectionsOptions as aD, useAllCollections as aE, type UseCollectionsOptions as aF, useCollections as aG, type UseBlogOptions as aH, useBlog as aI, type UseAllBlogsOptions as aJ, useAllBlogs as aK, type UseArticleOptions as aL, useArticle as aM, type UseArticlesOptions as aN, useArticles as aO, type UseArticlesInBlogOptions as aP, useArticlesInBlog as aQ, type SearchResultType as aR, type SearchResultItem as aS, type SearchResult as aT, type UseSearchOptions as aU, useSearch as aV, type SiteInfo as aW, type UseSiteOptions as aX, useSite as aY, type ShippingMethodsContext as aZ, type PlusMemberContextValue as a_, btoaID as aa, getMatchedMainProductSubTotal as ab, getDiscountEnvAttributeValue as ac, isAttributesEqual as ad, safeParseJson as ae, preCheck as af, formatScriptAutoFreeGift as ag, formatFunctionAutoFreeGift as ah, useSelectedOptions as ai, type SelectedOptionsResult as aj, type UseProductOptions as ak, useProduct as al, type UseAllProductsOptions as am, useAllProducts as an, type UseProductsByHandlesOptions as ao, useProductsByHandles as ap, type Options as aq, useVariant as ar, type UsePriceOptions as as, type UsePriceResult as at, usePrice as au, useProductUrl as av, useUpdateVariantQuery as aw, type ImageMedia as ax, type VideoMedia as ay, type VariantMedia as az, type AddToCartInput as b, usePlusMemberContext as b0, usePlusMonthlyProductVariant as b1, usePlusAnnualProductVariant as b2, type UseShippingMethodsOptions as b3, type UseShippingMethodsResult as b4, useShippingMethods as b5, useShippingMethodAvailableCheck as b6, useReplaceCartPlusMember as b7, usePlusMemberDeliveryCodes as b8, usePlusMemberItemCustomAttributes as b9, type ExportDiscountAllocations as bA, type ExportLineItem as bB, type ExportDiscounts as bC, type ExportCart as bD, type CustomerOrder as ba, type Customer as bb, usePlusMemberCheckoutCustomAttributes as bc, type UseAutoRemovePlusMemberInCartProps as bd, useAutoRemovePlusMemberInCart as be, type UseHasPlusMemberInCartProps as bf, type HasPlusMemberInCartResult as bg, useHasPlusMemberInCart as bh, type PlusMemberProviderProps as bi, PlusMemberProvider as bj, type UseIntersectionOptions as bk, useIntersection as bl, type UseExposureOptions as bm, useExposure as bn, type GeoLocationData as bo, type LocaleMapping as bp, type UseGeoLocationOptions as bq, useGeoLocation as br, getCachedGeoLocation as bs, clearGeoLocationCache as bt, type Attribute as bu, type Discount as bv, type Image as bw, type Measurement as bx, type ExportSelectedOption as by, type ExportProductVariant as bz, useAddToCart as c, useUpdateCartLines as d, useRemoveCartLines as e, type ApplyCartCodesInput as f, useApplyCartCodes as g, type RemoveCartCodesInput as h, useRemoveCartCodes as i, type UpdateCartAttributesInput as j, useUpdateCartAttributes as k, type UseBuyNowOptions as l, useBuyNow as m, useCalcAutoFreeGift as n, useCalcOrderDiscount as o, getReferralAttributes as p, useCartAttributes as q, useCartItemQuantityLimit as r, type UseScriptAutoFreeGiftResult as s, useScriptAutoFreeGift as t, useCreateCart as u, useUpdateLineCodeAmountAttributes as v, type AutoFreeGift as w, type AutoFreeGiftMainProduct as x, type AutoFreeGiftConfig as y, type RuleCondition as z };