@anker-in/headless-ui 1.3.60 → 1.3.61-alpha.1787560985870

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/dist/cjs/biz-components/BuyOneGetOneShelf/ProductCard.d.ts +2 -0
  2. package/dist/cjs/biz-components/BuyOneGetOneShelf/ProductCard.js +1 -1
  3. package/dist/cjs/biz-components/BuyOneGetOneShelf/ProductCard.js.map +3 -3
  4. package/dist/cjs/biz-components/BuyOneGetOneShelf/index.d.ts +1 -1
  5. package/dist/cjs/biz-components/BuyOneGetOneShelf/index.js +1 -1
  6. package/dist/cjs/biz-components/BuyOneGetOneShelf/index.js.map +1 -1
  7. package/dist/cjs/biz-components/BuyOneGetOneShelf/types.d.ts +12 -0
  8. package/dist/cjs/biz-components/BuyOneGetOneShelf/types.js +1 -1
  9. package/dist/cjs/biz-components/BuyOneGetOneShelf/types.js.map +1 -1
  10. package/dist/cjs/biz-components/HeaderNavigation/index.js +1 -1
  11. package/dist/cjs/biz-components/HeaderNavigation/index.js.map +2 -2
  12. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.d.ts +6 -0
  13. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js +4 -4
  14. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js.map +3 -3
  15. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CouponInit.d.ts +13 -0
  16. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CouponInit.js +2 -0
  17. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CouponInit.js.map +7 -0
  18. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CouponSuccess.d.ts +11 -0
  19. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CouponSuccess.js +2 -0
  20. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CouponSuccess.js.map +7 -0
  21. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CreditCouponListItem.d.ts +19 -0
  22. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CreditCouponListItem.js +2 -0
  23. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CreditCouponListItem.js.map +7 -0
  24. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/RedeemCouponModal.d.ts +16 -0
  25. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/RedeemCouponModal.js +2 -0
  26. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/RedeemCouponModal.js.map +7 -0
  27. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/index.d.ts +7 -0
  28. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/index.js +2 -0
  29. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/index.js.map +7 -0
  30. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/tracking.d.ts +33 -0
  31. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/tracking.js +2 -0
  32. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/tracking.js.map +7 -0
  33. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/types.d.ts +70 -0
  34. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/types.js +2 -0
  35. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/types.js.map +7 -0
  36. package/dist/cjs/biz-components/SecondaryBanner/index.d.ts +10 -0
  37. package/dist/cjs/biz-components/SecondaryBanner/index.js +1 -1
  38. package/dist/cjs/biz-components/SecondaryBanner/index.js.map +3 -3
  39. package/dist/cjs/biz-components/ShelfDisplay/index.js +1 -1
  40. package/dist/cjs/biz-components/ShelfDisplay/index.js.map +3 -3
  41. package/dist/cjs/biz-components/ShelfDisplay/shelfDisplay.d.ts +25 -0
  42. package/dist/cjs/biz-components/ShelfDisplay/shelfDisplay.js +1 -1
  43. package/dist/cjs/biz-components/ShelfDisplay/shelfDisplay.js.map +1 -1
  44. package/dist/cjs/biz-components/ShelfDisplay/shelfDisplayItem.js +1 -1
  45. package/dist/cjs/biz-components/ShelfDisplay/shelfDisplayItem.js.map +3 -3
  46. package/dist/cjs/biz-components/ShelfDisplayHorizontal/index.d.ts +7 -0
  47. package/dist/cjs/biz-components/ShelfDisplayHorizontal/index.js +2 -0
  48. package/dist/cjs/biz-components/ShelfDisplayHorizontal/index.js.map +7 -0
  49. package/dist/cjs/biz-components/ShelfDisplayHorizontal/shelfDisplayHorizontalItem.d.ts +8 -0
  50. package/dist/cjs/biz-components/ShelfDisplayHorizontal/shelfDisplayHorizontalItem.js +2 -0
  51. package/dist/cjs/biz-components/ShelfDisplayHorizontal/shelfDisplayHorizontalItem.js.map +7 -0
  52. package/dist/cjs/biz-components/Specs/dropdown.d.ts +2 -1
  53. package/dist/cjs/biz-components/Specs/dropdown.js +2 -2
  54. package/dist/cjs/biz-components/Specs/dropdown.js.map +3 -3
  55. package/dist/cjs/biz-components/Specs/index.js +1 -1
  56. package/dist/cjs/biz-components/Specs/index.js.map +3 -3
  57. package/dist/cjs/biz-components/SwiperBox/index.js +1 -1
  58. package/dist/cjs/biz-components/SwiperBox/index.js.map +3 -3
  59. package/dist/cjs/biz-components/SwiperBox/types.d.ts +6 -0
  60. package/dist/cjs/biz-components/SwiperBox/types.js +1 -1
  61. package/dist/cjs/biz-components/SwiperBox/types.js.map +1 -1
  62. package/dist/cjs/biz-components/index.d.ts +6 -0
  63. package/dist/cjs/biz-components/index.js +1 -1
  64. package/dist/cjs/biz-components/index.js.map +3 -3
  65. package/dist/cjs/hooks/useDraggableScroll.js +1 -1
  66. package/dist/cjs/hooks/useDraggableScroll.js.map +2 -2
  67. package/dist/cjs/hooks/useExposure.d.ts +1 -1
  68. package/dist/cjs/hooks/useExposure.js +1 -1
  69. package/dist/cjs/hooks/useExposure.js.map +2 -2
  70. package/dist/cjs/hooks/useViewItemList.d.ts +1 -1
  71. package/dist/cjs/hooks/useViewItemList.js.map +2 -2
  72. package/dist/esm/biz-components/BuyOneGetOneShelf/ProductCard.d.ts +2 -0
  73. package/dist/esm/biz-components/BuyOneGetOneShelf/ProductCard.js +1 -1
  74. package/dist/esm/biz-components/BuyOneGetOneShelf/ProductCard.js.map +3 -3
  75. package/dist/esm/biz-components/BuyOneGetOneShelf/index.d.ts +1 -1
  76. package/dist/esm/biz-components/BuyOneGetOneShelf/index.js +1 -1
  77. package/dist/esm/biz-components/BuyOneGetOneShelf/index.js.map +1 -1
  78. package/dist/esm/biz-components/BuyOneGetOneShelf/types.d.ts +12 -0
  79. package/dist/esm/biz-components/BuyOneGetOneShelf/types.js.map +1 -1
  80. package/dist/esm/biz-components/HeaderNavigation/index.js +1 -1
  81. package/dist/esm/biz-components/HeaderNavigation/index.js.map +2 -2
  82. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.d.ts +6 -0
  83. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js +4 -4
  84. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js.map +3 -3
  85. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CouponInit.d.ts +13 -0
  86. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CouponInit.js +2 -0
  87. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CouponInit.js.map +7 -0
  88. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CouponSuccess.d.ts +11 -0
  89. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CouponSuccess.js +2 -0
  90. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CouponSuccess.js.map +7 -0
  91. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CreditCouponListItem.d.ts +19 -0
  92. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CreditCouponListItem.js +2 -0
  93. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/CreditCouponListItem.js.map +7 -0
  94. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/RedeemCouponModal.d.ts +16 -0
  95. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/RedeemCouponModal.js +2 -0
  96. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/RedeemCouponModal.js.map +7 -0
  97. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/index.d.ts +7 -0
  98. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/index.js +2 -0
  99. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/index.js.map +7 -0
  100. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/tracking.d.ts +33 -0
  101. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/tracking.js +2 -0
  102. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/tracking.js.map +7 -0
  103. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/types.d.ts +70 -0
  104. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/types.js +1 -0
  105. package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/CreditCouponRedeem/types.js.map +7 -0
  106. package/dist/esm/biz-components/SecondaryBanner/index.d.ts +10 -0
  107. package/dist/esm/biz-components/SecondaryBanner/index.js +1 -1
  108. package/dist/esm/biz-components/SecondaryBanner/index.js.map +3 -3
  109. package/dist/esm/biz-components/ShelfDisplay/index.js +1 -1
  110. package/dist/esm/biz-components/ShelfDisplay/index.js.map +3 -3
  111. package/dist/esm/biz-components/ShelfDisplay/shelfDisplay.d.ts +25 -0
  112. package/dist/esm/biz-components/ShelfDisplay/shelfDisplay.js +1 -1
  113. package/dist/esm/biz-components/ShelfDisplay/shelfDisplay.js.map +1 -1
  114. package/dist/esm/biz-components/ShelfDisplay/shelfDisplayItem.js +1 -1
  115. package/dist/esm/biz-components/ShelfDisplay/shelfDisplayItem.js.map +3 -3
  116. package/dist/esm/biz-components/ShelfDisplayHorizontal/index.d.ts +7 -0
  117. package/dist/esm/biz-components/ShelfDisplayHorizontal/index.js +2 -0
  118. package/dist/esm/biz-components/ShelfDisplayHorizontal/index.js.map +7 -0
  119. package/dist/esm/biz-components/ShelfDisplayHorizontal/shelfDisplayHorizontalItem.d.ts +8 -0
  120. package/dist/esm/biz-components/ShelfDisplayHorizontal/shelfDisplayHorizontalItem.js +2 -0
  121. package/dist/esm/biz-components/ShelfDisplayHorizontal/shelfDisplayHorizontalItem.js.map +7 -0
  122. package/dist/esm/biz-components/Specs/dropdown.d.ts +2 -1
  123. package/dist/esm/biz-components/Specs/dropdown.js +2 -2
  124. package/dist/esm/biz-components/Specs/dropdown.js.map +3 -3
  125. package/dist/esm/biz-components/Specs/index.js +1 -1
  126. package/dist/esm/biz-components/Specs/index.js.map +3 -3
  127. package/dist/esm/biz-components/SwiperBox/index.js +1 -1
  128. package/dist/esm/biz-components/SwiperBox/index.js.map +3 -3
  129. package/dist/esm/biz-components/SwiperBox/types.d.ts +6 -0
  130. package/dist/esm/biz-components/SwiperBox/types.js.map +1 -1
  131. package/dist/esm/biz-components/index.d.ts +6 -0
  132. package/dist/esm/biz-components/index.js +1 -1
  133. package/dist/esm/biz-components/index.js.map +2 -2
  134. package/dist/esm/hooks/useDraggableScroll.js +1 -1
  135. package/dist/esm/hooks/useDraggableScroll.js.map +2 -2
  136. package/dist/esm/hooks/useExposure.d.ts +1 -1
  137. package/dist/esm/hooks/useExposure.js +1 -1
  138. package/dist/esm/hooks/useExposure.js.map +2 -2
  139. package/dist/esm/hooks/useViewItemList.d.ts +1 -1
  140. package/dist/esm/hooks/useViewItemList.js.map +2 -2
  141. package/dist/tokens/anker.css +2 -1
  142. package/dist/tokens/base.css +2 -1
  143. package/dist/tokens/eufy.css +2 -1
  144. package/dist/tokens/eufyMake.css +2 -1
  145. package/dist/tokens/oneAnker.css +4 -2
  146. package/dist/tokens/solix.css +2 -1
  147. package/dist/tokens/soundcore.css +4 -2
  148. package/package.json +1 -1
  149. package/style.css +169 -9
@@ -25,6 +25,8 @@ export interface ProductCardProps extends React.HTMLAttributes<HTMLDivElement> {
25
25
  onLearnMore?: (product: ProductCardData, selectedGifts: FreeGift[]) => void;
26
26
  /** Shop Now 点击回调 */
27
27
  onShopNow?: (product: ProductCardData, selectedGifts: FreeGift[]) => void;
28
+ /** 加入购物车回调 */
29
+ onAddToCart?: (product: ProductCardData, selectedGifts: FreeGift[]) => void;
28
30
  /** 赠品点击回调 */
29
31
  onGiftClick?: (gift: FreeGift, selectedGifts: FreeGift[]) => void;
30
32
  /** 赠品选择变化回调 */
@@ -1,2 +1,2 @@
1
- "use strict";"use client";var Y=Object.create;var h=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var re=(e,t)=>{for(var o in t)h(e,o,{get:t[o],enumerable:!0})},F=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of D(t))!te.call(e,a)&&a!==o&&h(e,a,{get:()=>t[a],enumerable:!(s=Z(t,a))||s.enumerable});return e};var c=(e,t,o)=>(o=e!=null?Y(ee(e)):{},F(t||!e||!e.__esModule?h(o,"default",{value:e,enumerable:!0}):o,e)),oe=e=>F(h({},"__esModule",{value:!0}),e);var ie={};re(ie,{default:()=>ne});module.exports=oe(ie);var i=require("react/jsx-runtime"),l=c(require("react")),P=require("../../helpers/index.js"),M=c(require("./ProductImage.js")),O=c(require("./ProductInfo.js")),I=c(require("./GiftSelection.js")),T=c(require("./PriceAndActions.js")),H=require("./context.js");const N=l.forwardRef(({productData:e,gifts:t=[],giftType:o=1,selectedGiftSku:s,sceneImages:a,tags:B,layout:R,className:j,onProductClick:x,onProductImageClick:b,onLearnMore:z,onShopNow:A,onGiftClick:C,onGiftSelectionChange:E,classNames:k,soldOutText:W,...V},_)=>{const{layout:$,theme:q}=l.useContext(H.BuyOneGetOneShelfContext),G=R??$,[J,y]=l.useState(!1),[K,w]=l.useState(!1),[v,f]=l.useState(()=>!t||t.length===0?[]:o===2?t.map(r=>r.id):[t[0].id]),u=l.useMemo(()=>t?t.map(r=>({...r,selected:v.includes(r.id)})):[],[t,v]);l.useEffect(()=>{if(!t||t.length===0){f([]);return}f(o===2?t.map(r=>r.id):r=>{const n=r[0];return n&&t.some(S=>S.id===n)?[n]:[t[0].id]})},[t,o]);const m=l.useMemo(()=>({...e,gifts:t,gift_type:o}),[e,t,o]),Q=r=>{if(o===2){const n=u.filter(d=>d.selected);C?.(r,n);return}f(()=>{const n=[r.id],d=t?.filter(S=>n.includes(S.id))||[];return C?.(r,d),E?.(d,m),n})},p=!!(b??x),L=`/products/${e.handle}`,g=()=>{(b??x)?.(m)},U=async()=>{const r=u.filter(n=>n.selected);y(!0);try{await z?.(m,r)}finally{y(!1)}},X=async()=>{const r=u.filter(n=>n.selected);w(!0);try{await A?.(m,r)}finally{w(!1)}};return(0,i.jsxs)("div",{ref:_,className:(0,P.cn)("bg-container-primary rounded-box flex items-stretch overflow-hidden",G==="horizontal"?["laptop:flex-row lg-desktop:min-h-[560px] desktop:min-h-[448px] tablet:min-h-[526px] min-h-[610px] flex-col","laptop:col-span-2"]:["flex-col justify-between"],j),...V,children:[(0,i.jsx)(M.default,{images:a,name:e.name,layout:G,tags:e.tags||B,onClick:p?g:void 0,href:p?void 0:L}),(0,i.jsx)("div",{className:(0,P.cn)("bg-container-primary desktop:p-6 flex flex-col justify-between p-4",G==="horizontal"?["rounded-r-box laptop:rounded-r-box tablet:rounded-b-box tablet:rounded-l-none","laptop:basis-[39.1%]","desktop:basis-[42.1%]","lg-desktop:basis-[42.1%]","shrink-0"]:["rounded-b-box","w-full","grow"]),children:(0,i.jsxs)("div",{className:"flex flex-1 flex-col justify-between gap-6",children:[(0,i.jsx)(O.default,{name:e.name,onClick:p?g:void 0,href:p?void 0:L,description:e.description,classNames:k}),(0,i.jsx)(I.default,{freeGiftLabel:e.freeGiftLabel,freeGifts:u,onGiftClick:Q,giftType:o,selectedGiftSku:s,theme:q}),(0,i.jsx)(T.default,{currentPrice:e.currentPrice??"",originalPrice:e.originalPrice,priceLabel:e.priceLabel,learnMoreText:e.learnMoreText,shopNowText:e.shopNowText,soldOutText:W,onLearnMore:U,onShopNow:X,availableForSale:e.availableForSale,learnMoreLoading:J,shopNowLoading:K,trackingTitle:e.name,trackingDescription:e.description,trackingSku:e.sku,classNames:k})]})})]})});N.displayName="BuyOneGetOneShelf.ProductCard";var ne=N;
1
+ "use strict";"use client";var ee=Object.create;var h=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var ie=(e,t)=>{for(var r in t)h(e,r,{get:t[r],enumerable:!0})},N=(e,t,r,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of re(t))!ne.call(e,d)&&d!==r&&h(e,d,{get:()=>t[d],enumerable:!(f=te(t,d))||f.enumerable});return e};var u=(e,t,r)=>(r=e!=null?ee(oe(e)):{},N(t||!e||!e.__esModule?h(r,"default",{value:e,enumerable:!0}):r,e)),ae=e=>N(h({},"__esModule",{value:!0}),e);var de={};ie(de,{default:()=>le});module.exports=ae(de);var a=require("react/jsx-runtime"),l=u(require("react")),P=require("../../helpers/index.js"),L=u(require("./ProductImage.js")),M=u(require("./ProductInfo.js")),T=u(require("./GiftSelection.js")),O=u(require("./PriceAndActions.js")),I=require("./context.js");const g=l.forwardRef(({productData:e,gifts:t=[],giftType:r=1,selectedGiftSku:f,sceneImages:d,tags:B,layout:H,className:A,onProductClick:S,onProductImageClick:x,onLearnMore:R,onShopNow:j,onAddToCart:z,onGiftClick:C,onGiftSelectionChange:E,classNames:y,soldOutText:W,...V},_)=>{const{layout:$,theme:q}=l.useContext(I.BuyOneGetOneShelfContext),G=H??$,[J,K]=l.useState(!1),[Q,U]=l.useState(!1),[k,m]=l.useState(()=>!t||t.length===0?[]:r===2?t.map(o=>o.id):[t[0].id]),b=l.useMemo(()=>t?t.map(o=>({...o,selected:k.includes(o.id)})):[],[t,k]);l.useEffect(()=>{if(!t||t.length===0){m([]);return}m(r===2?t.map(o=>o.id):o=>{const n=o[0];return n&&t.some(s=>s.id===n)?[n]:[t[0].id]})},[t,r]);const c=l.useMemo(()=>({...e,gifts:t,gift_type:r}),[e,t,r]),X=o=>{if(r===2){const n=b.filter(i=>i.selected);C?.(o,n);return}m(()=>{const n=[o.id],i=t?.filter(s=>n.includes(s.id))||[];return C?.(o,i),E?.(i,c),n})},p=!!(x??S),w=`/products/${e.handle}`,F=()=>{(x??S)?.(c)},v=async(o,n)=>{const i=b.filter(D=>D.selected),s=n==="primary"?U:K;s(!0);try{switch(o){case"buyNow":await j?.(c,i);break;case"addCart":await z?.(c,i);break;case"learnMore":await R?.(c,i);break}}finally{s(!1)}},Y=e.learnMoreFun??"learnMore",Z=e.shopNowFun??"buyNow";return(0,a.jsxs)("div",{ref:_,className:(0,P.cn)("bg-container-primary rounded-box flex items-stretch overflow-hidden",G==="horizontal"?["laptop:flex-row lg-desktop:min-h-[560px] desktop:min-h-[448px] tablet:min-h-[526px] min-h-[610px] flex-col","laptop:col-span-2"]:["flex-col justify-between"],A),...V,children:[(0,a.jsx)(L.default,{images:d,name:e.name,layout:G,tags:e.tags||B,onClick:p?F:void 0,href:p?void 0:w}),(0,a.jsx)("div",{className:(0,P.cn)("bg-container-primary desktop:p-6 flex flex-col justify-between p-4",G==="horizontal"?["rounded-r-box laptop:rounded-r-box tablet:rounded-b-box tablet:rounded-l-none","laptop:basis-[39.1%]","desktop:basis-[42.1%]","lg-desktop:basis-[42.1%]","shrink-0"]:["rounded-b-box","w-full","grow"]),children:(0,a.jsxs)("div",{className:"flex flex-1 flex-col justify-between gap-6",children:[(0,a.jsx)(M.default,{name:e.name,onClick:p?F:void 0,href:p?void 0:w,description:e.description,classNames:y}),(0,a.jsx)(T.default,{freeGiftLabel:e.freeGiftLabel,freeGifts:b,onGiftClick:X,giftType:r,selectedGiftSku:f,theme:q}),(0,a.jsx)(O.default,{currentPrice:e.currentPrice??"",originalPrice:e.originalPrice,priceLabel:e.priceLabel,learnMoreText:e.learnMoreText,shopNowText:e.shopNowText,soldOutText:W,onLearnMore:()=>v(Y,"secondary"),onShopNow:()=>v(Z,"primary"),availableForSale:e.availableForSale,learnMoreLoading:J,shopNowLoading:Q,trackingTitle:e.name,trackingDescription:e.description,trackingSku:e.sku,classNames:y})]})})]})});g.displayName="BuyOneGetOneShelf.ProductCard";var le=g;
2
2
  //# sourceMappingURL=ProductCard.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/biz-components/BuyOneGetOneShelf/ProductCard.tsx"],
4
- "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../../helpers/index.js'\nimport ProductImage from './ProductImage.js'\nimport ProductInfo from './ProductInfo.js'\nimport GiftSelection from './GiftSelection.js'\nimport PriceAndActions from './PriceAndActions.js'\nimport { BuyOneGetOneShelfContext } from './context.js'\nimport type {\n FreeGift,\n FreeGiftWithSelection,\n ProductCardData,\n PureProductData,\n ProductTag,\n BuyOneGetOneShelfProductCardSemanticName,\n} from './types.js'\n\nexport interface ProductCardProps extends React.HTMLAttributes<HTMLDivElement> {\n /** \u4EA7\u54C1\u6570\u636E\uFF08\u4E0D\u5305\u542B\u8D60\u54C1\u4FE1\u606F\uFF09 */\n productData: PureProductData\n /** \u8D60\u54C1\u5217\u8868 */\n gifts?: FreeGift[]\n /** \u8D60\u54C1\u7C7B\u578B 1-> \u8D60\u9001\u5176\u4E2D\u4E00\u4E2A\u8D60\u54C1\uFF0C 2 -> \u8D60\u9001\u6240\u6709\u8D60\u54C1 */\n giftType?: 1 | 2\n /** \u573A\u666F\u56FE\u7247 */\n sceneImages: any\n /** \u4EA7\u54C1\u6807\u7B7E */\n tags?: ProductTag[]\n /** \u5F53\u524D\u9009\u4E2D\u7684\u8D60\u54C1SKU\uFF08\u53D7\u63A7\u7EC4\u4EF6\uFF09 */\n selectedGiftSku?: string\n /** @deprecated Layout is now automatically inferred by Root based on children count. */\n layout?: 'horizontal' | 'vertical'\n classNames?: Partial<Record<BuyOneGetOneShelfProductCardSemanticName, string>>\n soldOutText?: string\n /** @deprecated Use `onProductImageClick` instead. */\n onProductClick?: (product: ProductCardData) => void\n /** \u4EA7\u54C1\u56FE\u7247\u70B9\u51FB\u56DE\u8C03 */\n onProductImageClick?: (product: ProductCardData) => void\n /** Learn More \u70B9\u51FB\u56DE\u8C03 */\n onLearnMore?: (product: ProductCardData, selectedGifts: FreeGift[]) => void\n /** Shop Now \u70B9\u51FB\u56DE\u8C03 */\n onShopNow?: (product: ProductCardData, selectedGifts: FreeGift[]) => void\n /** \u8D60\u54C1\u70B9\u51FB\u56DE\u8C03 */\n onGiftClick?: (gift: FreeGift, selectedGifts: FreeGift[]) => void\n /** \u8D60\u54C1\u9009\u62E9\u53D8\u5316\u56DE\u8C03 */\n onGiftSelectionChange?: (selectedGifts: FreeGift[], product: ProductCardData) => void\n /** \u9009\u4E2D\u8D60\u54C1SKU\u53D8\u5316\u56DE\u8C03\uFF08\u53D7\u63A7\u7EC4\u4EF6\uFF09 */\n onSelectedGiftSkuChange?: (selectedSku: string | null) => void\n}\n\n/**\n * ProductCard - \u4E70\u8D60\u8D27\u67B6\u4EA7\u54C1\u5361\u7247\n *\n * @description \u7528\u4E8E\u4E70\u4E00\u8D60\u4E00\u6D3B\u52A8\u7684\u4EA7\u54C1\u5C55\u793A\u5361\u7247\uFF0C\u5DE6\u4FA7\u5C55\u793A\u4EA7\u54C1\u56FE\u7247\u548C\u6807\u7B7E\uFF0C\u53F3\u4FA7\u5C55\u793A\u4EA7\u54C1\u4FE1\u606F\u3001\u8D60\u54C1\u548C\u8D2D\u4E70\u6309\u94AE\n */\nconst ProductCard = React.forwardRef<HTMLDivElement, ProductCardProps>(\n (\n {\n productData,\n gifts = [],\n giftType = 1,\n selectedGiftSku,\n sceneImages,\n tags,\n layout: layoutProp,\n className,\n onProductClick,\n onProductImageClick,\n onLearnMore,\n onShopNow,\n onGiftClick,\n onGiftSelectionChange,\n classNames,\n soldOutText,\n ...props\n },\n ref\n ) => {\n const { layout: contextLayout, theme } = React.useContext(BuyOneGetOneShelfContext)\n const layout = layoutProp ?? contextLayout\n\n const [learnMoreLoading, setLearnMoreLoading] = React.useState(false)\n const [shopNowLoading, setShopNowLoading] = React.useState(false)\n\n // \u5185\u90E8\u72B6\u6001\u7BA1\u7406\u8D60\u54C1\u7684\u9009\u62E9\u72B6\u6001 - \u4F7F\u7528\u9009\u4E2D\u7684ID\u6570\u7EC4\u800C\u4E0D\u662F\u4FEE\u6539gift\u5BF9\u8C61\n const [selectedGiftIds, setSelectedGiftIds] = React.useState<string[]>(() => {\n if (!gifts || gifts.length === 0) return []\n\n if (giftType === 2) {\n // gift_type 2 (\u5168\u9009\u6A21\u5F0F) - \u9009\u4E2D\u6240\u6709\u8D60\u54C1\n return gifts.map((gift: FreeGift) => gift.id)\n } else {\n // gift_type 1 (\u5355\u9009\u6A21\u5F0F) - \u9ED8\u8BA4\u9009\u4E2D\u7B2C\u4E00\u4E2A\u8D60\u54C1\n return [gifts[0].id]\n }\n })\n\n // \u751F\u6210\u5E26\u6709\u9009\u62E9\u72B6\u6001\u7684\u8D60\u54C1\u5217\u8868\u7528\u4E8E\u6E32\u67D3\n const giftsWithSelection = React.useMemo(() => {\n if (!gifts) return []\n\n return gifts.map((gift: FreeGift) => ({\n ...gift,\n selected: selectedGiftIds.includes(gift.id),\n }))\n }, [gifts, selectedGiftIds])\n\n // \u5F53 gifts \u6216 giftType \u66F4\u65B0\u65F6\uFF0C\u540C\u6B65\u66F4\u65B0\u5185\u90E8\u72B6\u6001\n React.useEffect(() => {\n if (!gifts || gifts.length === 0) {\n setSelectedGiftIds([])\n return\n }\n\n if (giftType === 2) {\n // gift_type 2 (\u5168\u9009\u6A21\u5F0F) - \u9009\u4E2D\u6240\u6709\u8D60\u54C1\n setSelectedGiftIds(gifts.map((gift: FreeGift) => gift.id))\n } else {\n // gift_type 1 (\u5355\u9009\u6A21\u5F0F) - \u667A\u80FD\u72B6\u6001\u7BA1\u7406\n setSelectedGiftIds(prevSelectedIds => {\n // \u68C0\u67E5\u5F53\u524D\u9009\u4E2D\u7684\u793C\u54C1\u662F\u5426\u4ECD\u7136\u5B58\u5728\u4E8E\u65B0\u7684 gifts \u5217\u8868\u4E2D\n const currentSelectedId = prevSelectedIds[0]\n const isCurrentSelectionValid =\n currentSelectedId && gifts.some((gift: FreeGift) => gift.id === currentSelectedId)\n\n // \u5982\u679C\u5F53\u524D\u9009\u4E2D\u72B6\u6001\u4ECD\u7136\u6709\u6548\uFF0C\u4FDD\u6301\u4E0D\u53D8\uFF1B\u5426\u5219\u9ED8\u8BA4\u9009\u4E2D\u7B2C\u4E00\u4E2A\n return isCurrentSelectionValid ? [currentSelectedId] : [gifts[0].id]\n })\n }\n }, [gifts, giftType])\n\n // \u6784\u9020\u5B8C\u6574\u7684\u4EA7\u54C1\u6570\u636E\u7528\u4E8E\u56DE\u8C03\n const fullProductData: ProductCardData = React.useMemo(\n () => ({\n ...productData,\n gifts,\n gift_type: giftType,\n }),\n [productData, gifts, giftType]\n )\n\n const handleGiftClick = (gift: FreeGift) => {\n // gift_type 2 (\u5168\u9009\u6A21\u5F0F) - \u4E0D\u5141\u8BB8\u53D6\u6D88\u9009\u62E9\uFF0C\u76F4\u63A5\u8FD4\u56DE\n if (giftType === 2) {\n // \u83B7\u53D6\u5F53\u524D\u6240\u6709\u9009\u4E2D\u7684gifts\u4F5C\u4E3A\u7B2C\u4E8C\u4E2A\u53C2\u6570\n const currentSelectedGifts = giftsWithSelection.filter((g: FreeGiftWithSelection) => g.selected)\n onGiftClick?.(gift, currentSelectedGifts)\n return\n }\n\n // gift_type 1 (\u5355\u9009\u6A21\u5F0F)\n setSelectedGiftIds(() => {\n const newSelectedIds = [gift.id] // \u5355\u9009\uFF1A\u59CB\u7EC8\u9009\u4E2D\u5F53\u524D\u9879\uFF0C\u70B9\u51FB\u5DF2\u9009\u4E2D\u9879\u4FDD\u6301\u72B6\u6001\uFF0C\u70B9\u51FB\u672A\u9009\u4E2D\u9879\u5207\u6362\u5230\u8BE5\u9879\n\n // \u8BA1\u7B97\u65B0\u7684\u9009\u4E2Dgifts\u4F5C\u4E3A\u7B2C\u4E8C\u4E2A\u53C2\u6570\u4F20\u9012\u7ED9\u56DE\u8C03\n const newSelectedGifts = gifts?.filter((g: FreeGift) => newSelectedIds.includes(g.id)) || []\n\n // \u8C03\u7528\u56DE\u8C03\u51FD\u6570\uFF0C\u7B2C\u4E8C\u4E2A\u53C2\u6570\u662F\u5F53\u524D\u9009\u4E2D\u7684gifts\n onGiftClick?.(gift, newSelectedGifts)\n onGiftSelectionChange?.(newSelectedGifts, fullProductData)\n\n return newSelectedIds\n })\n }\n\n const hasClickHandler = !!(onProductImageClick ?? onProductClick)\n const productHref = `/products/${productData.handle}`\n\n const handleProductImageClick = () => {\n const callback = onProductImageClick ?? onProductClick\n callback?.(fullProductData)\n }\n\n const handleLearnMoreClick = async () => {\n const selectedGifts = giftsWithSelection.filter(gift => gift.selected)\n setLearnMoreLoading(true)\n try {\n await onLearnMore?.(fullProductData, selectedGifts)\n } finally {\n setLearnMoreLoading(false)\n }\n }\n\n const handleShopNowClick = async () => {\n const selectedGifts = giftsWithSelection.filter(gift => gift.selected)\n setShopNowLoading(true)\n try {\n await onShopNow?.(fullProductData, selectedGifts)\n } finally {\n setShopNowLoading(false)\n }\n }\n\n return (\n <div\n ref={ref}\n className={cn(\n 'bg-container-primary rounded-box flex items-stretch overflow-hidden',\n // \u6839\u636E\u5E03\u5C40\u6A21\u5F0F\u8C03\u6574\u5BB9\u5668\n layout === 'horizontal'\n ? [\n 'laptop:flex-row lg-desktop:min-h-[560px] desktop:min-h-[448px] tablet:min-h-[526px] min-h-[610px] flex-col',\n 'laptop:col-span-2',\n ]\n : ['flex-col justify-between'],\n className\n )}\n {...props}\n >\n {/* \u4EA7\u54C1\u56FE\u7247\u533A\u57DF */}\n <ProductImage\n images={sceneImages}\n name={productData.name}\n layout={layout}\n tags={productData.tags || tags}\n onClick={hasClickHandler ? handleProductImageClick : undefined}\n href={hasClickHandler ? undefined : productHref}\n />\n\n {/* \u4EA7\u54C1\u4FE1\u606F\u533A\u57DF */}\n <div\n className={cn(\n 'bg-container-primary desktop:p-6 flex flex-col justify-between p-4',\n // \u6839\u636E\u5E03\u5C40\u6A21\u5F0F\u8C03\u6574\u5706\u89D2\u548C\u5C3A\u5BF8\n layout === 'horizontal'\n ? [\n 'rounded-r-box laptop:rounded-r-box tablet:rounded-b-box tablet:rounded-l-none',\n // \u4F7F\u7528 flex-basis \u8BBE\u7F6E\u5BBD\u5EA6\u6BD4\u4F8B\n 'laptop:basis-[39.1%]', // 360px / 921px \u2248 39.1%\n 'desktop:basis-[42.1%]', // 552px / 1312px \u2248 42.1%\n 'lg-desktop:basis-[42.1%]', // 700px / 1664px \u2248 42.1%\n 'shrink-0',\n ]\n : ['rounded-b-box', 'w-full', 'grow']\n )}\n >\n <div className=\"flex flex-1 flex-col justify-between gap-6\">\n {/* \u4EA7\u54C1\u6807\u9898\u548C\u63CF\u8FF0 */}\n <ProductInfo\n name={productData.name}\n onClick={hasClickHandler ? handleProductImageClick : undefined}\n href={hasClickHandler ? undefined : productHref}\n description={productData.description}\n classNames={classNames}\n />\n\n {/* \u514D\u8D39\u8D60\u54C1\u533A\u57DF */}\n <GiftSelection\n freeGiftLabel={productData.freeGiftLabel}\n freeGifts={giftsWithSelection}\n onGiftClick={handleGiftClick}\n giftType={giftType}\n selectedGiftSku={selectedGiftSku}\n theme={theme}\n />\n <PriceAndActions\n currentPrice={productData.currentPrice ?? ''}\n originalPrice={productData.originalPrice}\n priceLabel={productData.priceLabel}\n learnMoreText={productData.learnMoreText}\n shopNowText={productData.shopNowText}\n soldOutText={soldOutText}\n onLearnMore={handleLearnMoreClick}\n onShopNow={handleShopNowClick}\n availableForSale={productData.availableForSale}\n learnMoreLoading={learnMoreLoading}\n shopNowLoading={shopNowLoading}\n trackingTitle={productData.name}\n trackingDescription={productData.description}\n trackingSku={productData.sku}\n classNames={classNames}\n />\n </div>\n </div>\n </div>\n )\n }\n)\n\nProductCard.displayName = 'BuyOneGetOneShelf.ProductCard'\n\nexport default ProductCard\n"],
5
- "mappings": "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",
6
- "names": ["ProductCard_exports", "__export", "ProductCard_default", "__toCommonJS", "import_jsx_runtime", "React", "import_helpers", "import_ProductImage", "import_ProductInfo", "import_GiftSelection", "import_PriceAndActions", "import_context", "ProductCard", "productData", "gifts", "giftType", "selectedGiftSku", "sceneImages", "tags", "layoutProp", "className", "onProductClick", "onProductImageClick", "onLearnMore", "onShopNow", "onGiftClick", "onGiftSelectionChange", "classNames", "soldOutText", "props", "ref", "contextLayout", "theme", "layout", "learnMoreLoading", "setLearnMoreLoading", "shopNowLoading", "setShopNowLoading", "selectedGiftIds", "setSelectedGiftIds", "gift", "giftsWithSelection", "prevSelectedIds", "currentSelectedId", "fullProductData", "handleGiftClick", "currentSelectedGifts", "g", "newSelectedIds", "newSelectedGifts", "hasClickHandler", "productHref", "handleProductImageClick", "handleLearnMoreClick", "selectedGifts", "handleShopNowClick", "ProductImage", "ProductInfo", "GiftSelection", "PriceAndActions"]
4
+ "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../../helpers/index.js'\nimport ProductImage from './ProductImage.js'\nimport ProductInfo from './ProductInfo.js'\nimport GiftSelection from './GiftSelection.js'\nimport PriceAndActions from './PriceAndActions.js'\nimport { BuyOneGetOneShelfContext } from './context.js'\nimport type {\n FreeGift,\n FreeGiftWithSelection,\n ProductCardData,\n PureProductData,\n ProductTag,\n ButtonFunctionType,\n BuyOneGetOneShelfProductCardSemanticName,\n} from './types.js'\n\nexport interface ProductCardProps extends React.HTMLAttributes<HTMLDivElement> {\n /** \u4EA7\u54C1\u6570\u636E\uFF08\u4E0D\u5305\u542B\u8D60\u54C1\u4FE1\u606F\uFF09 */\n productData: PureProductData\n /** \u8D60\u54C1\u5217\u8868 */\n gifts?: FreeGift[]\n /** \u8D60\u54C1\u7C7B\u578B 1-> \u8D60\u9001\u5176\u4E2D\u4E00\u4E2A\u8D60\u54C1\uFF0C 2 -> \u8D60\u9001\u6240\u6709\u8D60\u54C1 */\n giftType?: 1 | 2\n /** \u573A\u666F\u56FE\u7247 */\n sceneImages: any\n /** \u4EA7\u54C1\u6807\u7B7E */\n tags?: ProductTag[]\n /** \u5F53\u524D\u9009\u4E2D\u7684\u8D60\u54C1SKU\uFF08\u53D7\u63A7\u7EC4\u4EF6\uFF09 */\n selectedGiftSku?: string\n /** @deprecated Layout is now automatically inferred by Root based on children count. */\n layout?: 'horizontal' | 'vertical'\n classNames?: Partial<Record<BuyOneGetOneShelfProductCardSemanticName, string>>\n soldOutText?: string\n /** @deprecated Use `onProductImageClick` instead. */\n onProductClick?: (product: ProductCardData) => void\n /** \u4EA7\u54C1\u56FE\u7247\u70B9\u51FB\u56DE\u8C03 */\n onProductImageClick?: (product: ProductCardData) => void\n /** Learn More \u70B9\u51FB\u56DE\u8C03 */\n onLearnMore?: (product: ProductCardData, selectedGifts: FreeGift[]) => void\n /** Shop Now \u70B9\u51FB\u56DE\u8C03 */\n onShopNow?: (product: ProductCardData, selectedGifts: FreeGift[]) => void\n /** \u52A0\u5165\u8D2D\u7269\u8F66\u56DE\u8C03 */\n onAddToCart?: (product: ProductCardData, selectedGifts: FreeGift[]) => void\n /** \u8D60\u54C1\u70B9\u51FB\u56DE\u8C03 */\n onGiftClick?: (gift: FreeGift, selectedGifts: FreeGift[]) => void\n /** \u8D60\u54C1\u9009\u62E9\u53D8\u5316\u56DE\u8C03 */\n onGiftSelectionChange?: (selectedGifts: FreeGift[], product: ProductCardData) => void\n /** \u9009\u4E2D\u8D60\u54C1SKU\u53D8\u5316\u56DE\u8C03\uFF08\u53D7\u63A7\u7EC4\u4EF6\uFF09 */\n onSelectedGiftSkuChange?: (selectedSku: string | null) => void\n}\n\n/**\n * ProductCard - \u4E70\u8D60\u8D27\u67B6\u4EA7\u54C1\u5361\u7247\n *\n * @description \u7528\u4E8E\u4E70\u4E00\u8D60\u4E00\u6D3B\u52A8\u7684\u4EA7\u54C1\u5C55\u793A\u5361\u7247\uFF0C\u5DE6\u4FA7\u5C55\u793A\u4EA7\u54C1\u56FE\u7247\u548C\u6807\u7B7E\uFF0C\u53F3\u4FA7\u5C55\u793A\u4EA7\u54C1\u4FE1\u606F\u3001\u8D60\u54C1\u548C\u8D2D\u4E70\u6309\u94AE\n */\nconst ProductCard = React.forwardRef<HTMLDivElement, ProductCardProps>(\n (\n {\n productData,\n gifts = [],\n giftType = 1,\n selectedGiftSku,\n sceneImages,\n tags,\n layout: layoutProp,\n className,\n onProductClick,\n onProductImageClick,\n onLearnMore,\n onShopNow,\n onAddToCart,\n onGiftClick,\n onGiftSelectionChange,\n classNames,\n soldOutText,\n ...props\n },\n ref\n ) => {\n const { layout: contextLayout, theme } = React.useContext(BuyOneGetOneShelfContext)\n const layout = layoutProp ?? contextLayout\n\n const [learnMoreLoading, setLearnMoreLoading] = React.useState(false)\n const [shopNowLoading, setShopNowLoading] = React.useState(false)\n\n // \u5185\u90E8\u72B6\u6001\u7BA1\u7406\u8D60\u54C1\u7684\u9009\u62E9\u72B6\u6001 - \u4F7F\u7528\u9009\u4E2D\u7684ID\u6570\u7EC4\u800C\u4E0D\u662F\u4FEE\u6539gift\u5BF9\u8C61\n const [selectedGiftIds, setSelectedGiftIds] = React.useState<string[]>(() => {\n if (!gifts || gifts.length === 0) return []\n\n if (giftType === 2) {\n // gift_type 2 (\u5168\u9009\u6A21\u5F0F) - \u9009\u4E2D\u6240\u6709\u8D60\u54C1\n return gifts.map((gift: FreeGift) => gift.id)\n } else {\n // gift_type 1 (\u5355\u9009\u6A21\u5F0F) - \u9ED8\u8BA4\u9009\u4E2D\u7B2C\u4E00\u4E2A\u8D60\u54C1\n return [gifts[0].id]\n }\n })\n\n // \u751F\u6210\u5E26\u6709\u9009\u62E9\u72B6\u6001\u7684\u8D60\u54C1\u5217\u8868\u7528\u4E8E\u6E32\u67D3\n const giftsWithSelection = React.useMemo(() => {\n if (!gifts) return []\n\n return gifts.map((gift: FreeGift) => ({\n ...gift,\n selected: selectedGiftIds.includes(gift.id),\n }))\n }, [gifts, selectedGiftIds])\n\n // \u5F53 gifts \u6216 giftType \u66F4\u65B0\u65F6\uFF0C\u540C\u6B65\u66F4\u65B0\u5185\u90E8\u72B6\u6001\n React.useEffect(() => {\n if (!gifts || gifts.length === 0) {\n setSelectedGiftIds([])\n return\n }\n\n if (giftType === 2) {\n // gift_type 2 (\u5168\u9009\u6A21\u5F0F) - \u9009\u4E2D\u6240\u6709\u8D60\u54C1\n setSelectedGiftIds(gifts.map((gift: FreeGift) => gift.id))\n } else {\n // gift_type 1 (\u5355\u9009\u6A21\u5F0F) - \u667A\u80FD\u72B6\u6001\u7BA1\u7406\n setSelectedGiftIds(prevSelectedIds => {\n // \u68C0\u67E5\u5F53\u524D\u9009\u4E2D\u7684\u793C\u54C1\u662F\u5426\u4ECD\u7136\u5B58\u5728\u4E8E\u65B0\u7684 gifts \u5217\u8868\u4E2D\n const currentSelectedId = prevSelectedIds[0]\n const isCurrentSelectionValid =\n currentSelectedId && gifts.some((gift: FreeGift) => gift.id === currentSelectedId)\n\n // \u5982\u679C\u5F53\u524D\u9009\u4E2D\u72B6\u6001\u4ECD\u7136\u6709\u6548\uFF0C\u4FDD\u6301\u4E0D\u53D8\uFF1B\u5426\u5219\u9ED8\u8BA4\u9009\u4E2D\u7B2C\u4E00\u4E2A\n return isCurrentSelectionValid ? [currentSelectedId] : [gifts[0].id]\n })\n }\n }, [gifts, giftType])\n\n // \u6784\u9020\u5B8C\u6574\u7684\u4EA7\u54C1\u6570\u636E\u7528\u4E8E\u56DE\u8C03\n const fullProductData: ProductCardData = React.useMemo(\n () => ({\n ...productData,\n gifts,\n gift_type: giftType,\n }),\n [productData, gifts, giftType]\n )\n\n const handleGiftClick = (gift: FreeGift) => {\n // gift_type 2 (\u5168\u9009\u6A21\u5F0F) - \u4E0D\u5141\u8BB8\u53D6\u6D88\u9009\u62E9\uFF0C\u76F4\u63A5\u8FD4\u56DE\n if (giftType === 2) {\n // \u83B7\u53D6\u5F53\u524D\u6240\u6709\u9009\u4E2D\u7684gifts\u4F5C\u4E3A\u7B2C\u4E8C\u4E2A\u53C2\u6570\n const currentSelectedGifts = giftsWithSelection.filter((g: FreeGiftWithSelection) => g.selected)\n onGiftClick?.(gift, currentSelectedGifts)\n return\n }\n\n // gift_type 1 (\u5355\u9009\u6A21\u5F0F)\n setSelectedGiftIds(() => {\n const newSelectedIds = [gift.id] // \u5355\u9009\uFF1A\u59CB\u7EC8\u9009\u4E2D\u5F53\u524D\u9879\uFF0C\u70B9\u51FB\u5DF2\u9009\u4E2D\u9879\u4FDD\u6301\u72B6\u6001\uFF0C\u70B9\u51FB\u672A\u9009\u4E2D\u9879\u5207\u6362\u5230\u8BE5\u9879\n\n // \u8BA1\u7B97\u65B0\u7684\u9009\u4E2Dgifts\u4F5C\u4E3A\u7B2C\u4E8C\u4E2A\u53C2\u6570\u4F20\u9012\u7ED9\u56DE\u8C03\n const newSelectedGifts = gifts?.filter((g: FreeGift) => newSelectedIds.includes(g.id)) || []\n\n // \u8C03\u7528\u56DE\u8C03\u51FD\u6570\uFF0C\u7B2C\u4E8C\u4E2A\u53C2\u6570\u662F\u5F53\u524D\u9009\u4E2D\u7684gifts\n onGiftClick?.(gift, newSelectedGifts)\n onGiftSelectionChange?.(newSelectedGifts, fullProductData)\n\n return newSelectedIds\n })\n }\n\n const hasClickHandler = !!(onProductImageClick ?? onProductClick)\n const productHref = `/products/${productData.handle}`\n\n const handleProductImageClick = () => {\n const callback = onProductImageClick ?? onProductClick\n callback?.(fullProductData)\n }\n\n const handleButtonClick = async (buttonFun: ButtonFunctionType, buttonType: 'primary' | 'secondary') => {\n const selectedGifts = giftsWithSelection.filter(gift => gift.selected)\n const setLoading = buttonType === 'primary' ? setShopNowLoading : setLearnMoreLoading\n setLoading(true)\n try {\n switch (buttonFun) {\n case 'buyNow':\n await onShopNow?.(fullProductData, selectedGifts)\n break\n case 'addCart':\n await onAddToCart?.(fullProductData, selectedGifts)\n break\n case 'learnMore':\n await onLearnMore?.(fullProductData, selectedGifts)\n break\n }\n } finally {\n setLoading(false)\n }\n }\n\n const learnMoreFun = productData.learnMoreFun ?? 'learnMore'\n const shopNowFun = productData.shopNowFun ?? 'buyNow'\n\n return (\n <div\n ref={ref}\n className={cn(\n 'bg-container-primary rounded-box flex items-stretch overflow-hidden',\n // \u6839\u636E\u5E03\u5C40\u6A21\u5F0F\u8C03\u6574\u5BB9\u5668\n layout === 'horizontal'\n ? [\n 'laptop:flex-row lg-desktop:min-h-[560px] desktop:min-h-[448px] tablet:min-h-[526px] min-h-[610px] flex-col',\n 'laptop:col-span-2',\n ]\n : ['flex-col justify-between'],\n className\n )}\n {...props}\n >\n {/* \u4EA7\u54C1\u56FE\u7247\u533A\u57DF */}\n <ProductImage\n images={sceneImages}\n name={productData.name}\n layout={layout}\n tags={productData.tags || tags}\n onClick={hasClickHandler ? handleProductImageClick : undefined}\n href={hasClickHandler ? undefined : productHref}\n />\n\n {/* \u4EA7\u54C1\u4FE1\u606F\u533A\u57DF */}\n <div\n className={cn(\n 'bg-container-primary desktop:p-6 flex flex-col justify-between p-4',\n // \u6839\u636E\u5E03\u5C40\u6A21\u5F0F\u8C03\u6574\u5706\u89D2\u548C\u5C3A\u5BF8\n layout === 'horizontal'\n ? [\n 'rounded-r-box laptop:rounded-r-box tablet:rounded-b-box tablet:rounded-l-none',\n // \u4F7F\u7528 flex-basis \u8BBE\u7F6E\u5BBD\u5EA6\u6BD4\u4F8B\n 'laptop:basis-[39.1%]', // 360px / 921px \u2248 39.1%\n 'desktop:basis-[42.1%]', // 552px / 1312px \u2248 42.1%\n 'lg-desktop:basis-[42.1%]', // 700px / 1664px \u2248 42.1%\n 'shrink-0',\n ]\n : ['rounded-b-box', 'w-full', 'grow']\n )}\n >\n <div className=\"flex flex-1 flex-col justify-between gap-6\">\n {/* \u4EA7\u54C1\u6807\u9898\u548C\u63CF\u8FF0 */}\n <ProductInfo\n name={productData.name}\n onClick={hasClickHandler ? handleProductImageClick : undefined}\n href={hasClickHandler ? undefined : productHref}\n description={productData.description}\n classNames={classNames}\n />\n\n {/* \u514D\u8D39\u8D60\u54C1\u533A\u57DF */}\n <GiftSelection\n freeGiftLabel={productData.freeGiftLabel}\n freeGifts={giftsWithSelection}\n onGiftClick={handleGiftClick}\n giftType={giftType}\n selectedGiftSku={selectedGiftSku}\n theme={theme}\n />\n <PriceAndActions\n currentPrice={productData.currentPrice ?? ''}\n originalPrice={productData.originalPrice}\n priceLabel={productData.priceLabel}\n learnMoreText={productData.learnMoreText}\n shopNowText={productData.shopNowText}\n soldOutText={soldOutText}\n onLearnMore={() => handleButtonClick(learnMoreFun, 'secondary')}\n onShopNow={() => handleButtonClick(shopNowFun, 'primary')}\n availableForSale={productData.availableForSale}\n learnMoreLoading={learnMoreLoading}\n shopNowLoading={shopNowLoading}\n trackingTitle={productData.name}\n trackingDescription={productData.description}\n trackingSku={productData.sku}\n classNames={classNames}\n />\n </div>\n </div>\n </div>\n )\n }\n)\n\nProductCard.displayName = 'BuyOneGetOneShelf.ProductCard'\n\nexport default ProductCard\n"],
5
+ "mappings": "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",
6
+ "names": ["ProductCard_exports", "__export", "ProductCard_default", "__toCommonJS", "import_jsx_runtime", "React", "import_helpers", "import_ProductImage", "import_ProductInfo", "import_GiftSelection", "import_PriceAndActions", "import_context", "ProductCard", "productData", "gifts", "giftType", "selectedGiftSku", "sceneImages", "tags", "layoutProp", "className", "onProductClick", "onProductImageClick", "onLearnMore", "onShopNow", "onAddToCart", "onGiftClick", "onGiftSelectionChange", "classNames", "soldOutText", "props", "ref", "contextLayout", "theme", "layout", "learnMoreLoading", "setLearnMoreLoading", "shopNowLoading", "setShopNowLoading", "selectedGiftIds", "setSelectedGiftIds", "gift", "giftsWithSelection", "prevSelectedIds", "currentSelectedId", "fullProductData", "handleGiftClick", "currentSelectedGifts", "g", "newSelectedIds", "newSelectedGifts", "hasClickHandler", "productHref", "handleProductImageClick", "handleButtonClick", "buttonFun", "buttonType", "selectedGifts", "setLoading", "learnMoreFun", "shopNowFun", "ProductImage", "ProductInfo", "GiftSelection", "PriceAndActions"]
7
7
  }
@@ -5,4 +5,4 @@ declare const BuyOneGetOneShelf: {
5
5
  ProductCard: React.ForwardRefExoticComponent<import("./ProductCard.js").ProductCardProps & React.RefAttributes<HTMLDivElement>>;
6
6
  };
7
7
  export default BuyOneGetOneShelf;
8
- export type { FreeGift, FreeGiftWithSelection, ProductTag, BuyOneGetOneShelfSemanticName, BuyOneGetOneShelfRootSemanticName, BuyOneGetOneShelfProductCardSemanticName, ResponsiveImage, ResponsiveImages, BaseProductData, PureProductData, WithGiftData, ProductData, ProductCardData, CopyConfig, BogoItem, BuyOneGetOneShelfData, BuyOneGetOneShelfProps, BuyOneGetOneShelfCardProps, } from './types.js';
8
+ export type { FreeGift, FreeGiftWithSelection, ProductTag, ButtonFunctionType, BuyOneGetOneShelfSemanticName, BuyOneGetOneShelfRootSemanticName, BuyOneGetOneShelfProductCardSemanticName, ResponsiveImage, ResponsiveImages, BaseProductData, PureProductData, WithGiftData, ProductData, ProductCardData, CopyConfig, BogoItem, BuyOneGetOneShelfData, BuyOneGetOneShelfProps, BuyOneGetOneShelfCardProps, } from './types.js';
@@ -1,2 +1,2 @@
1
- "use strict";"use client";var k=Object.create;var d=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var T=(e,t)=>{for(var o in t)d(e,o,{get:t[o],enumerable:!0})},O=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of w(t))!L.call(e,n)&&n!==o&&d(e,n,{get:()=>t[n],enumerable:!(i=z(t,n))||i.enumerable});return e};var R=(e,t,o)=>(o=e!=null?k(I(e)):{},O(t||!e||!e.__esModule?d(o,"default",{value:e,enumerable:!0}):o,e)),M=e=>O(d({},"__esModule",{value:!0}),e);var A={};T(A,{default:()=>W});module.exports=M(A);var r=require("react/jsx-runtime"),a=R(require("react")),s=require("../../helpers/index.js"),C=R(require("./ProductCard.js")),u=require("../../components/index.js"),N=require("./context.js"),S=require("../../hooks/useExposure.js");const H="shelf",V="buy_one_get_one_shelf";function x(e){return a.Children.toArray(e).flatMap(t=>a.isValidElement(t)&&t.type===a.Fragment?x(t.props.children):[t])}function _(e){return a.isValidElement(e)?e.props.layout??"horizontal":"horizontal"}function j(e,t){let o=0,i=0;for(let n=0;n<t;n++){const p=_(e[n])==="horizontal"?2:1;p===2&&o>0&&(o=0),o+=p,o===2&&(i=n+1,o=0)}return e.slice(0,i)}const v=a.forwardRef(({className:e,classNames:t={},theme:o,title:i,subtitle:n,children:p,viewMoreThreshold:y=4,viewMoreText:B="View More",viewLessText:G="View Less",...P},b)=>{const f=a.useRef(null),[c,E]=a.useState(!1);(0,S.useExposure)(f,{componentType:H,componentName:V,componentTitle:i,componentDescription:n}),a.useImperativeHandle(b,()=>f.current);const m=x(p),h=m.length>y,D=(h&&!c?j(m,y):m).map(l=>{if(!a.isValidElement(l))return l;const g=l.props;return g.layout==="horizontal"?a.cloneElement(l,{className:(0,s.cn)(g.className,"laptop:col-span-2")}):l});return(0,r.jsx)(N.BuyOneGetOneShelfContext.Provider,{value:{layout:"horizontal",theme:o},children:(0,r.jsxs)("div",{ref:f,className:(0,s.cn)("bogo-shelf-root w-full py-0",{"aiui-dark":o==="dark"},e,t?.root),...P,children:[i&&(0,r.jsx)(u.Heading,{as:"h2",size:3,html:i,className:(0,s.cn)("bogo-shelf-title text-info-primary mb-4",t?.title)}),n&&(0,r.jsx)(u.Text,{size:3,as:"p",html:n,className:(0,s.cn)("bogo-shelf-description text-info-primary mb-6",t?.description)}),(0,r.jsx)("div",{className:(0,s.cn)("grid grid-cols-1 gap-6","laptop:grid-cols-2"),children:D}),h&&(0,r.jsx)("div",{className:"mt-6 flex justify-center",children:(0,r.jsxs)("button",{type:"button",onClick:()=>E(l=>!l),"aria-expanded":c,className:(0,s.cn)("hover:text-brand-0 lg-desktop:text-[16px] text-info-primary flex cursor-pointer items-center gap-2 border-none bg-transparent text-[14px] font-bold outline-none transition-colors",t?.viewMoreBtn),children:[c?G:B,(0,r.jsx)("svg",{className:(0,s.cn)("size-4 transition-transform",c&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})})]})})});v.displayName="BuyOneGetOneShelf.Root";const F={Root:v,ProductCard:C.default};var W=F;
1
+ "use strict";"use client";var k=Object.create;var d=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var L=(e,t)=>{for(var o in t)d(e,o,{get:t[o],enumerable:!0})},O=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T(t))!I.call(e,n)&&n!==o&&d(e,n,{get:()=>t[n],enumerable:!(i=z(t,n))||i.enumerable});return e};var R=(e,t,o)=>(o=e!=null?k(w(e)):{},O(t||!e||!e.__esModule?d(o,"default",{value:e,enumerable:!0}):o,e)),M=e=>O(d({},"__esModule",{value:!0}),e);var A={};L(A,{default:()=>W});module.exports=M(A);var r=require("react/jsx-runtime"),a=R(require("react")),s=require("../../helpers/index.js"),C=R(require("./ProductCard.js")),u=require("../../components/index.js"),N=require("./context.js"),B=require("../../hooks/useExposure.js");const H="shelf",V="buy_one_get_one_shelf";function x(e){return a.Children.toArray(e).flatMap(t=>a.isValidElement(t)&&t.type===a.Fragment?x(t.props.children):[t])}function F(e){return a.isValidElement(e)?e.props.layout??"horizontal":"horizontal"}function _(e,t){let o=0,i=0;for(let n=0;n<t;n++){const p=F(e[n])==="horizontal"?2:1;p===2&&o>0&&(o=0),o+=p,o===2&&(i=n+1,o=0)}return e.slice(0,i)}const v=a.forwardRef(({className:e,classNames:t={},theme:o,title:i,subtitle:n,children:p,viewMoreThreshold:y=4,viewMoreText:S="View More",viewLessText:G="View Less",...P},b)=>{const f=a.useRef(null),[c,E]=a.useState(!1);(0,B.useExposure)(f,{componentType:H,componentName:V,componentTitle:i,componentDescription:n}),a.useImperativeHandle(b,()=>f.current);const m=x(p),h=m.length>y,D=(h&&!c?_(m,y):m).map(l=>{if(!a.isValidElement(l))return l;const g=l.props;return g.layout==="horizontal"?a.cloneElement(l,{className:(0,s.cn)(g.className,"laptop:col-span-2")}):l});return(0,r.jsx)(N.BuyOneGetOneShelfContext.Provider,{value:{layout:"horizontal",theme:o},children:(0,r.jsxs)("div",{ref:f,className:(0,s.cn)("bogo-shelf-root w-full py-0",{"aiui-dark":o==="dark"},e,t?.root),...P,children:[i&&(0,r.jsx)(u.Heading,{as:"h2",size:3,html:i,className:(0,s.cn)("bogo-shelf-title text-info-primary mb-4",t?.title)}),n&&(0,r.jsx)(u.Text,{size:3,as:"p",html:n,className:(0,s.cn)("bogo-shelf-description text-info-primary mb-6",t?.description)}),(0,r.jsx)("div",{className:(0,s.cn)("grid grid-cols-1 gap-6","laptop:grid-cols-2"),children:D}),h&&(0,r.jsx)("div",{className:"mt-6 flex justify-center",children:(0,r.jsxs)("button",{type:"button",onClick:()=>E(l=>!l),"aria-expanded":c,className:(0,s.cn)("hover:text-brand-0 lg-desktop:text-[16px] text-info-primary flex cursor-pointer items-center gap-2 border-none bg-transparent text-[14px] font-bold outline-none transition-colors",t?.viewMoreBtn),children:[c?G:S,(0,r.jsx)("svg",{className:(0,s.cn)("size-4 transition-transform",c&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})})]})})});v.displayName="BuyOneGetOneShelf.Root";const j={Root:v,ProductCard:C.default};var W=j;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/biz-components/BuyOneGetOneShelf/index.tsx"],
4
- "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../../helpers/index.js'\nimport ProductCard from './ProductCard.js'\nimport { Heading, Text } from '../../components/index.js'\nimport { BuyOneGetOneShelfContext } from './context.js'\nimport type { BuyOneGetOneShelfProps } from './types.js'\nimport { useExposure } from '../../hooks/useExposure.js'\n\nconst componentType = 'shelf'\nconst componentName = 'buy_one_get_one_shelf'\n\nfunction flattenChildren(children: React.ReactNode): React.ReactNode[] {\n return React.Children.toArray(children).flatMap(child => {\n if (React.isValidElement(child) && child.type === React.Fragment) {\n return flattenChildren((child.props as { children?: React.ReactNode }).children)\n }\n return [child]\n })\n}\n\nfunction getLayout(node: React.ReactNode): string {\n if (React.isValidElement(node)) {\n return (node.props as { layout?: string }).layout ?? 'horizontal'\n }\n return 'horizontal'\n}\n\nfunction sliceToCompleteRow(all: React.ReactNode[], threshold: number): React.ReactNode[] {\n let filledInRow = 0\n let lastCompleteIndex = 0\n for (let i = 0; i < threshold; i++) {\n const span = getLayout(all[i]) === 'horizontal' ? 2 : 1\n if (span === 2 && filledInRow > 0) filledInRow = 0\n filledInRow += span\n if (filledInRow === 2) {\n lastCompleteIndex = i + 1\n filledInRow = 0\n }\n }\n return all.slice(0, lastCompleteIndex)\n}\n\nconst BuyOneGetOneShelfRoot = React.forwardRef<HTMLDivElement, BuyOneGetOneShelfProps>(\n (\n {\n className,\n classNames = {},\n theme,\n title,\n subtitle,\n children,\n viewMoreThreshold = 4,\n viewMoreText = 'View More',\n viewLessText = 'View Less',\n ...props\n },\n ref\n ) => {\n const boxRef = React.useRef<HTMLDivElement>(null)\n const [isExpanded, setIsExpanded] = React.useState(false)\n\n useExposure(boxRef, {\n componentType,\n componentName,\n componentTitle: title,\n componentDescription: subtitle,\n })\n\n React.useImperativeHandle(ref, () => boxRef.current as HTMLDivElement)\n\n const childrenArray = flattenChildren(children)\n const needCollapse = childrenArray.length > viewMoreThreshold\n const displayedChildren =\n needCollapse && !isExpanded ? sliceToCompleteRow(childrenArray, viewMoreThreshold) : childrenArray\n\n const renderedChildren = displayedChildren.map(child => {\n if (!React.isValidElement(child)) return child\n const childProps = child.props as { layout?: string; className?: string }\n if (childProps.layout === 'horizontal') {\n return React.cloneElement(child as React.ReactElement<{ className?: string }>, {\n className: cn(childProps.className, 'laptop:col-span-2'),\n })\n }\n return child\n })\n\n return (\n <BuyOneGetOneShelfContext.Provider value={{ layout: 'horizontal', theme }}>\n <div\n ref={boxRef}\n className={cn(\n 'bogo-shelf-root w-full py-0',\n {\n 'aiui-dark': theme === 'dark',\n },\n className,\n classNames?.root\n )}\n {...props}\n >\n {title && (\n <Heading\n as=\"h2\"\n size={3}\n html={title}\n className={cn('bogo-shelf-title text-info-primary mb-4', classNames?.title)}\n />\n )}\n {subtitle && (\n <Text\n size={3}\n as=\"p\"\n html={subtitle}\n className={cn('bogo-shelf-description text-info-primary mb-6', classNames?.description)}\n />\n )}\n <div className={cn('grid grid-cols-1 gap-6', 'laptop:grid-cols-2')}>{renderedChildren}</div>\n {needCollapse && (\n <div className=\"mt-6 flex justify-center\">\n <button\n type=\"button\"\n onClick={() => setIsExpanded(prev => !prev)}\n aria-expanded={isExpanded}\n className={cn(\n 'hover:text-brand-0 lg-desktop:text-[16px] text-info-primary flex cursor-pointer items-center gap-2 border-none bg-transparent text-[14px] font-bold outline-none transition-colors',\n classNames?.viewMoreBtn\n )}\n >\n {isExpanded ? viewLessText : viewMoreText}\n <svg\n className={cn('size-4 transition-transform', isExpanded && 'rotate-180')}\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M19 9l-7 7-7-7\" />\n </svg>\n </button>\n </div>\n )}\n </div>\n </BuyOneGetOneShelfContext.Provider>\n )\n }\n)\n\nBuyOneGetOneShelfRoot.displayName = 'BuyOneGetOneShelf.Root'\n\n// \u521B\u5EFA\u547D\u540D\u7A7A\u95F4\u5BF9\u8C61\uFF0C\u5305\u542B Root \u548C ProductCard \u7EC4\u4EF6\nconst BuyOneGetOneShelf = {\n Root: BuyOneGetOneShelfRoot,\n ProductCard: ProductCard,\n}\n\nexport default BuyOneGetOneShelf\n\n// Re-export types for external use\nexport type {\n FreeGift,\n FreeGiftWithSelection,\n ProductTag,\n BuyOneGetOneShelfSemanticName,\n BuyOneGetOneShelfRootSemanticName,\n BuyOneGetOneShelfProductCardSemanticName,\n ResponsiveImage,\n ResponsiveImages,\n BaseProductData,\n PureProductData,\n WithGiftData,\n ProductData,\n ProductCardData,\n CopyConfig,\n BogoItem,\n BuyOneGetOneShelfData,\n BuyOneGetOneShelfProps,\n BuyOneGetOneShelfCardProps,\n} from './types.js'\n"],
4
+ "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../../helpers/index.js'\nimport ProductCard from './ProductCard.js'\nimport { Heading, Text } from '../../components/index.js'\nimport { BuyOneGetOneShelfContext } from './context.js'\nimport type { BuyOneGetOneShelfProps } from './types.js'\nimport { useExposure } from '../../hooks/useExposure.js'\n\nconst componentType = 'shelf'\nconst componentName = 'buy_one_get_one_shelf'\n\nfunction flattenChildren(children: React.ReactNode): React.ReactNode[] {\n return React.Children.toArray(children).flatMap(child => {\n if (React.isValidElement(child) && child.type === React.Fragment) {\n return flattenChildren((child.props as { children?: React.ReactNode }).children)\n }\n return [child]\n })\n}\n\nfunction getLayout(node: React.ReactNode): string {\n if (React.isValidElement(node)) {\n return (node.props as { layout?: string }).layout ?? 'horizontal'\n }\n return 'horizontal'\n}\n\nfunction sliceToCompleteRow(all: React.ReactNode[], threshold: number): React.ReactNode[] {\n let filledInRow = 0\n let lastCompleteIndex = 0\n for (let i = 0; i < threshold; i++) {\n const span = getLayout(all[i]) === 'horizontal' ? 2 : 1\n if (span === 2 && filledInRow > 0) filledInRow = 0\n filledInRow += span\n if (filledInRow === 2) {\n lastCompleteIndex = i + 1\n filledInRow = 0\n }\n }\n return all.slice(0, lastCompleteIndex)\n}\n\nconst BuyOneGetOneShelfRoot = React.forwardRef<HTMLDivElement, BuyOneGetOneShelfProps>(\n (\n {\n className,\n classNames = {},\n theme,\n title,\n subtitle,\n children,\n viewMoreThreshold = 4,\n viewMoreText = 'View More',\n viewLessText = 'View Less',\n ...props\n },\n ref\n ) => {\n const boxRef = React.useRef<HTMLDivElement>(null)\n const [isExpanded, setIsExpanded] = React.useState(false)\n\n useExposure(boxRef, {\n componentType,\n componentName,\n componentTitle: title,\n componentDescription: subtitle,\n })\n\n React.useImperativeHandle(ref, () => boxRef.current as HTMLDivElement)\n\n const childrenArray = flattenChildren(children)\n const needCollapse = childrenArray.length > viewMoreThreshold\n const displayedChildren =\n needCollapse && !isExpanded ? sliceToCompleteRow(childrenArray, viewMoreThreshold) : childrenArray\n\n const renderedChildren = displayedChildren.map(child => {\n if (!React.isValidElement(child)) return child\n const childProps = child.props as { layout?: string; className?: string }\n if (childProps.layout === 'horizontal') {\n return React.cloneElement(child as React.ReactElement<{ className?: string }>, {\n className: cn(childProps.className, 'laptop:col-span-2'),\n })\n }\n return child\n })\n\n return (\n <BuyOneGetOneShelfContext.Provider value={{ layout: 'horizontal', theme }}>\n <div\n ref={boxRef}\n className={cn(\n 'bogo-shelf-root w-full py-0',\n {\n 'aiui-dark': theme === 'dark',\n },\n className,\n classNames?.root\n )}\n {...props}\n >\n {title && (\n <Heading\n as=\"h2\"\n size={3}\n html={title}\n className={cn('bogo-shelf-title text-info-primary mb-4', classNames?.title)}\n />\n )}\n {subtitle && (\n <Text\n size={3}\n as=\"p\"\n html={subtitle}\n className={cn('bogo-shelf-description text-info-primary mb-6', classNames?.description)}\n />\n )}\n <div className={cn('grid grid-cols-1 gap-6', 'laptop:grid-cols-2')}>{renderedChildren}</div>\n {needCollapse && (\n <div className=\"mt-6 flex justify-center\">\n <button\n type=\"button\"\n onClick={() => setIsExpanded(prev => !prev)}\n aria-expanded={isExpanded}\n className={cn(\n 'hover:text-brand-0 lg-desktop:text-[16px] text-info-primary flex cursor-pointer items-center gap-2 border-none bg-transparent text-[14px] font-bold outline-none transition-colors',\n classNames?.viewMoreBtn\n )}\n >\n {isExpanded ? viewLessText : viewMoreText}\n <svg\n className={cn('size-4 transition-transform', isExpanded && 'rotate-180')}\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M19 9l-7 7-7-7\" />\n </svg>\n </button>\n </div>\n )}\n </div>\n </BuyOneGetOneShelfContext.Provider>\n )\n }\n)\n\nBuyOneGetOneShelfRoot.displayName = 'BuyOneGetOneShelf.Root'\n\n// \u521B\u5EFA\u547D\u540D\u7A7A\u95F4\u5BF9\u8C61\uFF0C\u5305\u542B Root \u548C ProductCard \u7EC4\u4EF6\nconst BuyOneGetOneShelf = {\n Root: BuyOneGetOneShelfRoot,\n ProductCard: ProductCard,\n}\n\nexport default BuyOneGetOneShelf\n\n// Re-export types for external use\nexport type {\n FreeGift,\n FreeGiftWithSelection,\n ProductTag,\n ButtonFunctionType,\n BuyOneGetOneShelfSemanticName,\n BuyOneGetOneShelfRootSemanticName,\n BuyOneGetOneShelfProductCardSemanticName,\n ResponsiveImage,\n ResponsiveImages,\n BaseProductData,\n PureProductData,\n WithGiftData,\n ProductData,\n ProductCardData,\n CopyConfig,\n BogoItem,\n BuyOneGetOneShelfData,\n BuyOneGetOneShelfProps,\n BuyOneGetOneShelfCardProps,\n} from './types.js'\n"],
5
5
  "mappings": "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",
6
6
  "names": ["BuyOneGetOneShelf_exports", "__export", "BuyOneGetOneShelf_default", "__toCommonJS", "import_jsx_runtime", "React", "import_helpers", "import_ProductCard", "import_components", "import_context", "import_useExposure", "componentType", "componentName", "flattenChildren", "children", "child", "getLayout", "node", "sliceToCompleteRow", "all", "threshold", "filledInRow", "lastCompleteIndex", "i", "span", "BuyOneGetOneShelfRoot", "className", "classNames", "theme", "title", "subtitle", "viewMoreThreshold", "viewMoreText", "viewLessText", "props", "ref", "boxRef", "isExpanded", "setIsExpanded", "childrenArray", "needCollapse", "renderedChildren", "childProps", "prev", "BuyOneGetOneShelf", "ProductCard"]
7
7
  }
@@ -1,5 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import type { Theme } from '../../types/props';
3
+ /**
4
+ * 按钮功能类型
5
+ */
6
+ export type ButtonFunctionType = 'buyNow' | 'addCart' | 'learnMore';
3
7
  /**
4
8
  * 免费赠品接口
5
9
  */
@@ -112,6 +116,10 @@ export interface PureProductData extends BaseProductData {
112
116
  tags?: ProductTag[];
113
117
  /** 赠品选择模式 */
114
118
  giftSelectionMode?: 'single' | 'multiple';
119
+ /** Learn More 按钮功能(默认 'learnMore') */
120
+ learnMoreFun?: ButtonFunctionType;
121
+ /** Shop Now 按钮功能(默认 'buyNow') */
122
+ shopNowFun?: ButtonFunctionType;
115
123
  availableForSale: boolean;
116
124
  }
117
125
  export interface ProductData extends BaseProductData, WithGiftData {
@@ -195,6 +203,8 @@ export interface BuyOneGetOneShelfCardProps extends Omit<React.HTMLAttributes<HT
195
203
  learnMoreText?: string;
196
204
  shopNowText?: string;
197
205
  freeGiftLabel?: string;
206
+ learnMoreFun?: ButtonFunctionType;
207
+ shopNowFun?: ButtonFunctionType;
198
208
  };
199
209
  /** 赠品列表 */
200
210
  gifts?: FreeGift[];
@@ -215,6 +225,8 @@ export interface BuyOneGetOneShelfCardProps extends Omit<React.HTMLAttributes<HT
215
225
  onLearnMore?: (product: ProductCardData, selectedGifts: FreeGift[]) => void;
216
226
  /** Shop Now 点击回调 */
217
227
  onShopNow?: (product: ProductCardData, selectedGifts: FreeGift[]) => void;
228
+ /** 加入购物车回调 */
229
+ onAddToCart?: (product: ProductCardData, selectedGifts: FreeGift[]) => void;
218
230
  /** 赠品点击回调 */
219
231
  onGiftClick?: (gift: FreeGift, selectedGifts: FreeGift[]) => void;
220
232
  /** 赠品选择变化回调 */
@@ -1,2 +1,2 @@
1
- "use strict";var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var d=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of s(e))!c.call(t,r)&&r!==n&&o(t,r,{get:()=>e[r],enumerable:!(i=a(e,r))||i.enumerable});return t};var l=t=>d(o({},"__esModule",{value:!0}),t);var g={};module.exports=l(g);var p=require("react");
1
+ "use strict";var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var c=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of s(e))!d.call(t,r)&&r!==n&&o(t,r,{get:()=>e[r],enumerable:!(i=a(e,r))||i.enumerable});return t};var u=t=>c(o({},"__esModule",{value:!0}),t);var l={};module.exports=u(l);var p=require("react");
2
2
  //# sourceMappingURL=types.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/biz-components/BuyOneGetOneShelf/types.ts"],
4
- "sourcesContent": ["import * as React from 'react'\nimport type { Theme } from '../../types/props'\n\n/**\n * \u514D\u8D39\u8D60\u54C1\u63A5\u53E3\n */\nexport interface FreeGift {\n /** \u8D60\u54C1ID */\n id: string\n /** \u8D60\u54C1\u56FE\u7247URL */\n image: string\n /** \u8D60\u54C1\u540D\u79F0 */\n name: string\n /** \u539F\u4EF7 */\n originalPrice: string\n /** \u73B0\u4EF7\uFF08\u901A\u5E38\u4E3AFree\uFF09 */\n currentPrice: string\n /** \u6570\u91CF */\n quantity: number\n /** \u53D8\u4F53ID */\n variantId: string\n /** SKU */\n sku: string\n /** \u53E5\u67C4 */\n handle: string\n /** \u8D60\u54C1tag */\n tag?: string\n}\n\n/**\n * \u5E26\u9009\u62E9\u72B6\u6001\u7684\u514D\u8D39\u8D60\u54C1\u63A5\u53E3\n */\nexport interface FreeGiftWithSelection extends FreeGift {\n /** \u662F\u5426\u5DF2\u9009\u4E2D */\n selected?: boolean\n}\n\n/**\n * \u4EA7\u54C1\u6807\u7B7E\u63A5\u53E3\n */\nexport interface ProductTag {\n /** \u6807\u7B7E\u6587\u672C */\n label: string\n /** \u6807\u7B7E\u6837\u5F0F\u53D8\u4F53 */\n variant: 'outline' | 'fill' | 'promotional'\n /** \u4FC3\u9500\u7C7B\u578B\uFF08\u4EC5\u5F53 variant \u4E3A 'promotional' \u65F6\u6709\u6548\uFF09 */\n promotionalType?: 'plus-member' | 'regular-member' | 'regular-discount' | 'time-limited-discount'\n}\n\n// Root \u7EC4\u4EF6\u76F8\u5173\u7684\u8BED\u4E49\u7C7B\u540D\nexport type BuyOneGetOneShelfRootSemanticName = 'root' | 'title' | 'description' | 'content' | 'viewMoreBtn'\n\n// ProductCard \u7EC4\u4EF6\u76F8\u5173\u7684\u8BED\u4E49\u7C7B\u540D\nexport type BuyOneGetOneShelfProductCardSemanticName =\n | 'productCard'\n | 'productCardImage'\n | 'productCardTitle'\n | 'productCardDescription'\n | 'productCardPriceLabel'\n | 'productCardPrice'\n | 'productCardOriginalPrice'\n | 'productCardGiftsContainer'\n | 'productCardBtnGroup'\n\n// \u5B8C\u6574\u7684\u8BED\u4E49\u7C7B\u540D\uFF08\u5411\u540E\u517C\u5BB9\uFF09\nexport type BuyOneGetOneShelfSemanticName = BuyOneGetOneShelfRootSemanticName | BuyOneGetOneShelfProductCardSemanticName\n\n/**\n * \u54CD\u5E94\u5F0F\u56FE\u7247\u63A5\u53E3\n */\nexport interface ResponsiveImage {\n id: number\n baseUrl?: string\n url: string\n thumbnailURL?: string\n filename?: string\n mimeType?: string\n width?: number\n height?: number\n}\n\n/**\n * \u54CD\u5E94\u5F0F\u56FE\u7247\u96C6\u5408\u63A5\u53E3\n */\nexport interface ResponsiveImages {\n laptop?: ResponsiveImage\n mobile?: ResponsiveImage\n tablet?: ResponsiveImage\n desktop?: ResponsiveImage\n lgDesktop?: ResponsiveImage\n}\n\n/**\n * \u4EA7\u54C1\u57FA\u7840\u6570\u636E\u63A5\u53E3\n */\nexport interface BaseProductData {\n sku: string\n name: string\n image: string\n value: string\n handle: string\n shopify_id: string\n}\n\nexport interface WithGiftData {\n /**\n * \u8D60\u54C1\n */\n gifts: FreeGift[]\n /**\n * \u8D60\u54C1\u7C7B\u578B 1-> \u8D60\u9001\u5176\u4E2D\u4E00\u4E2A\u8D60\u54C1\uFF0C 2 -> \u8D60\u9001\u6240\u6709\u8D60\u54C1\n */\n gift_type: 1 | 2\n}\n\n/**\n * \u7EAF\u4EA7\u54C1\u6570\u636E\u63A5\u53E3\uFF08\u4E0D\u5305\u542B\u8D60\u54C1\u4FE1\u606F\uFF09\n */\nexport interface PureProductData extends BaseProductData {\n /** \u4EA7\u54C1\u63CF\u8FF0 */\n description?: string\n /** \u5F53\u524D\u4EF7\u683C */\n currentPrice?: string\n /** \u539F\u4EF7 */\n originalPrice?: string\n /** \u4EF7\u683C\u6807\u7B7E\u6587\u672C\uFF08\u5982 \"Plus Member Price\"\uFF09 */\n priceLabel?: string\n /** \u4E86\u89E3\u66F4\u591A\u6309\u94AE\u6587\u672C */\n learnMoreText?: string\n /** \u7ACB\u5373\u8D2D\u4E70\u6309\u94AE\u6587\u672C */\n shopNowText?: string\n /** \u8D60\u54C1\u6807\u7B7E\u6587\u672C */\n freeGiftLabel?: string\n /** \u4EA7\u54C1\u6807\u7B7E */\n tags?: ProductTag[]\n /** \u8D60\u54C1\u9009\u62E9\u6A21\u5F0F */\n giftSelectionMode?: 'single' | 'multiple'\n availableForSale: boolean\n}\n\nexport interface ProductData extends BaseProductData, WithGiftData {\n /** \u4EA7\u54C1\u63CF\u8FF0 */\n description?: string\n /** \u5F53\u524D\u4EF7\u683C */\n currentPrice?: string\n /** \u539F\u4EF7 */\n originalPrice?: string\n /** \u4E86\u89E3\u66F4\u591A\u6309\u94AE\u6587\u672C */\n learnMoreText?: string\n /** \u7ACB\u5373\u8D2D\u4E70\u6309\u94AE\u6587\u672C */\n shopNowText?: string\n /** \u8D60\u54C1\u6807\u7B7E\u6587\u672C */\n freeGiftLabel?: string\n /** \u8D60\u54C1\u9009\u62E9\u6A21\u5F0F */\n giftSelectionMode?: 'single' | 'multiple'\n}\n\n// Alias for consistency with other components\nexport type ProductCardData = ProductData\n\n/**\n * \u6587\u6848\u914D\u7F6E\u63A5\u53E3\n */\nexport interface CopyConfig {\n shopNowText: string\n freeGiftLabel: string\n learnMoreText: string\n freeGiftHeading: string\n soldOutText?: string\n}\n\n/**\n * \u4E70\u8D60\u9879\u76EE\u63A5\u53E3\n */\nexport interface BogoItem {\n id: string\n data: ProductData[]\n images: ResponsiveImages\n shopNowFun: string\n shopNowText: string\n learnMoreText: string\n layout?: 'horizontal' | 'vertical'\n}\n\n/**\n * BuyOneGetOneShelf \u4E1A\u52A1\u7EC4\u4EF6\u6570\u636E\u63A5\u53E3 - \u65B0\u683C\u5F0F\n */\nexport interface BuyOneGetOneShelfData {\n copy: CopyConfig\n theme: string\n title: string\n subtitle: string\n bogoItems: BogoItem[]\n /** \u8D85\u8FC7\u6B64\u6570\u91CF\u7684\u5546\u54C1\u65F6\u663E\u793A\"View More/View Less\"\u6309\u94AE\uFF0C\u9ED8\u8BA4 4 */\n viewMoreThreshold?: number\n /** View More \u6309\u94AE\u6587\u6848\uFF0C\u9ED8\u8BA4 'View More' */\n viewMoreText?: string\n /** View Less \u6309\u94AE\u6587\u6848\uFF0C\u9ED8\u8BA4 'View Less' */\n viewLessText?: string\n}\n\n// Root \u7EC4\u4EF6 Props\uFF08\u65B0\u7684\u7EC4\u5408\u5F0F\u8BBE\u8BA1\uFF09\nexport interface BuyOneGetOneShelfProps extends React.HTMLAttributes<HTMLDivElement> {\n /** \u6807\u9898 */\n title?: string\n /** \u526F\u6807\u9898 */\n subtitle?: string\n theme?: Theme\n /** \u5B50\u7EC4\u4EF6 */\n children: React.ReactNode\n /** Root \u7EC4\u4EF6\u7684\u81EA\u5B9A\u4E49\u7C7B\u540D */\n classNames?: Partial<Record<BuyOneGetOneShelfRootSemanticName, string>>\n /** \u8D85\u8FC7\u6B64\u6570\u91CF\u7684\u5546\u54C1\u65F6\u663E\u793A\"View More/View Less\"\u6309\u94AE\uFF0C\u9ED8\u8BA4 4 */\n viewMoreThreshold?: number\n /** View More \u6309\u94AE\u6587\u6848\uFF0C\u9ED8\u8BA4 'View More' */\n viewMoreText?: string\n /** View Less \u6309\u94AE\u6587\u6848\uFF0C\u9ED8\u8BA4 'View Less' */\n viewLessText?: string\n}\n\n// \u5361\u7247\u7EC4\u4EF6Props - \u57FA\u4E8EProductCardProps\u4F46\u7B80\u5316\nexport interface BuyOneGetOneShelfCardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick'> {\n /** \u4EA7\u54C1\u6570\u636E */\n productData: BaseProductData & {\n description?: string\n currentPrice?: string\n originalPrice?: string\n learnMoreText?: string\n shopNowText?: string\n freeGiftLabel?: string\n }\n /** \u8D60\u54C1\u5217\u8868 */\n gifts?: FreeGift[]\n /** \u8D60\u54C1\u7C7B\u578B 1-> \u8D60\u9001\u5176\u4E2D\u4E00\u4E2A\u8D60\u54C1\uFF0C 2 -> \u8D60\u9001\u6240\u6709\u8D60\u54C1 */\n giftType?: 1 | 2\n soldOutText?: string\n /** \u573A\u666F\u56FE\u7247 */\n sceneImages?: ResponsiveImages\n /** @deprecated Layout is now automatically inferred by Root based on children count. */\n layout?: 'horizontal' | 'vertical'\n /** ProductCard \u7EC4\u4EF6\u7684\u81EA\u5B9A\u4E49\u7C7B\u540D */\n classNames?: Partial<Record<BuyOneGetOneShelfProductCardSemanticName, string>>\n /** @deprecated Use `onProductImageClick` instead. */\n onProductClick?: (product: ProductCardData) => void\n /** \u4EA7\u54C1\u56FE\u7247\u70B9\u51FB\u56DE\u8C03 */\n onProductImageClick?: (product: ProductCardData) => void\n /** Learn More \u70B9\u51FB\u56DE\u8C03 */\n onLearnMore?: (product: ProductCardData, selectedGifts: FreeGift[]) => void\n /** Shop Now \u70B9\u51FB\u56DE\u8C03 */\n onShopNow?: (product: ProductCardData, selectedGifts: FreeGift[]) => void\n /** \u8D60\u54C1\u70B9\u51FB\u56DE\u8C03 */\n onGiftClick?: (gift: FreeGift, selectedGifts: FreeGift[]) => void\n /** \u8D60\u54C1\u9009\u62E9\u53D8\u5316\u56DE\u8C03 */\n onGiftSelectionChange?: (selectedGifts: FreeGift[], product: ProductCardData) => void\n /** \u9009\u4E2D\u8D60\u54C1SKU\u53D8\u5316\u56DE\u8C03\uFF08\u53D7\u63A7\u7EC4\u4EF6\uFF09 */\n onSelectedGiftSkuChange?: (selectedSku: string | null) => void\n}\n\n// \u4FDD\u6301\u5411\u540E\u517C\u5BB9\u7684\u4F20\u7EDFProps\nexport interface BuyOneGetOneShelfLegacyProps extends React.HTMLAttributes<HTMLDivElement> {\n /** \u4E1A\u52A1\u6570\u636E */\n data: BuyOneGetOneShelfData\n /** @deprecated Use `onProductImageClick` instead. */\n onProductClick?: (product: ProductCardData) => void\n /** \u4EA7\u54C1\u56FE\u7247\u70B9\u51FB\u56DE\u8C03 */\n onProductImageClick?: (product: ProductCardData) => void\n /** Learn More\u6309\u94AE\u70B9\u51FB\u4E8B\u4EF6 */\n onLearnMore?: (product: ProductCardData, selectedGifts: FreeGift[]) => void\n /** Shop Now\u6309\u94AE\u70B9\u51FB\u4E8B\u4EF6 */\n onShopNow?: (product: ProductCardData, selectedGifts: FreeGift[]) => void\n onAddToCart?: (product: ProductCardData) => void\n /** \u8D60\u54C1\u70B9\u51FB\u4E8B\u4EF6 */\n onGiftClick?: (gift: FreeGift, selectedGifts: FreeGift[]) => void\n /** \u8D60\u54C1\u9009\u62E9\u53D8\u5316\u4E8B\u4EF6 */\n onGiftSelectionChange?: (selectedGifts: FreeGift[], product: ProductCardData) => void\n classNames?: Partial<Record<BuyOneGetOneShelfSemanticName, string>>\n}\n"],
4
+ "sourcesContent": ["import * as React from 'react'\nimport type { Theme } from '../../types/props'\n\n/**\n * \u6309\u94AE\u529F\u80FD\u7C7B\u578B\n */\nexport type ButtonFunctionType = 'buyNow' | 'addCart' | 'learnMore'\n\n/**\n * \u514D\u8D39\u8D60\u54C1\u63A5\u53E3\n */\nexport interface FreeGift {\n /** \u8D60\u54C1ID */\n id: string\n /** \u8D60\u54C1\u56FE\u7247URL */\n image: string\n /** \u8D60\u54C1\u540D\u79F0 */\n name: string\n /** \u539F\u4EF7 */\n originalPrice: string\n /** \u73B0\u4EF7\uFF08\u901A\u5E38\u4E3AFree\uFF09 */\n currentPrice: string\n /** \u6570\u91CF */\n quantity: number\n /** \u53D8\u4F53ID */\n variantId: string\n /** SKU */\n sku: string\n /** \u53E5\u67C4 */\n handle: string\n /** \u8D60\u54C1tag */\n tag?: string\n}\n\n/**\n * \u5E26\u9009\u62E9\u72B6\u6001\u7684\u514D\u8D39\u8D60\u54C1\u63A5\u53E3\n */\nexport interface FreeGiftWithSelection extends FreeGift {\n /** \u662F\u5426\u5DF2\u9009\u4E2D */\n selected?: boolean\n}\n\n/**\n * \u4EA7\u54C1\u6807\u7B7E\u63A5\u53E3\n */\nexport interface ProductTag {\n /** \u6807\u7B7E\u6587\u672C */\n label: string\n /** \u6807\u7B7E\u6837\u5F0F\u53D8\u4F53 */\n variant: 'outline' | 'fill' | 'promotional'\n /** \u4FC3\u9500\u7C7B\u578B\uFF08\u4EC5\u5F53 variant \u4E3A 'promotional' \u65F6\u6709\u6548\uFF09 */\n promotionalType?: 'plus-member' | 'regular-member' | 'regular-discount' | 'time-limited-discount'\n}\n\n// Root \u7EC4\u4EF6\u76F8\u5173\u7684\u8BED\u4E49\u7C7B\u540D\nexport type BuyOneGetOneShelfRootSemanticName = 'root' | 'title' | 'description' | 'content' | 'viewMoreBtn'\n\n// ProductCard \u7EC4\u4EF6\u76F8\u5173\u7684\u8BED\u4E49\u7C7B\u540D\nexport type BuyOneGetOneShelfProductCardSemanticName =\n | 'productCard'\n | 'productCardImage'\n | 'productCardTitle'\n | 'productCardDescription'\n | 'productCardPriceLabel'\n | 'productCardPrice'\n | 'productCardOriginalPrice'\n | 'productCardGiftsContainer'\n | 'productCardBtnGroup'\n\n// \u5B8C\u6574\u7684\u8BED\u4E49\u7C7B\u540D\uFF08\u5411\u540E\u517C\u5BB9\uFF09\nexport type BuyOneGetOneShelfSemanticName = BuyOneGetOneShelfRootSemanticName | BuyOneGetOneShelfProductCardSemanticName\n\n/**\n * \u54CD\u5E94\u5F0F\u56FE\u7247\u63A5\u53E3\n */\nexport interface ResponsiveImage {\n id: number\n baseUrl?: string\n url: string\n thumbnailURL?: string\n filename?: string\n mimeType?: string\n width?: number\n height?: number\n}\n\n/**\n * \u54CD\u5E94\u5F0F\u56FE\u7247\u96C6\u5408\u63A5\u53E3\n */\nexport interface ResponsiveImages {\n laptop?: ResponsiveImage\n mobile?: ResponsiveImage\n tablet?: ResponsiveImage\n desktop?: ResponsiveImage\n lgDesktop?: ResponsiveImage\n}\n\n/**\n * \u4EA7\u54C1\u57FA\u7840\u6570\u636E\u63A5\u53E3\n */\nexport interface BaseProductData {\n sku: string\n name: string\n image: string\n value: string\n handle: string\n shopify_id: string\n}\n\nexport interface WithGiftData {\n /**\n * \u8D60\u54C1\n */\n gifts: FreeGift[]\n /**\n * \u8D60\u54C1\u7C7B\u578B 1-> \u8D60\u9001\u5176\u4E2D\u4E00\u4E2A\u8D60\u54C1\uFF0C 2 -> \u8D60\u9001\u6240\u6709\u8D60\u54C1\n */\n gift_type: 1 | 2\n}\n\n/**\n * \u7EAF\u4EA7\u54C1\u6570\u636E\u63A5\u53E3\uFF08\u4E0D\u5305\u542B\u8D60\u54C1\u4FE1\u606F\uFF09\n */\nexport interface PureProductData extends BaseProductData {\n /** \u4EA7\u54C1\u63CF\u8FF0 */\n description?: string\n /** \u5F53\u524D\u4EF7\u683C */\n currentPrice?: string\n /** \u539F\u4EF7 */\n originalPrice?: string\n /** \u4EF7\u683C\u6807\u7B7E\u6587\u672C\uFF08\u5982 \"Plus Member Price\"\uFF09 */\n priceLabel?: string\n /** \u4E86\u89E3\u66F4\u591A\u6309\u94AE\u6587\u672C */\n learnMoreText?: string\n /** \u7ACB\u5373\u8D2D\u4E70\u6309\u94AE\u6587\u672C */\n shopNowText?: string\n /** \u8D60\u54C1\u6807\u7B7E\u6587\u672C */\n freeGiftLabel?: string\n /** \u4EA7\u54C1\u6807\u7B7E */\n tags?: ProductTag[]\n /** \u8D60\u54C1\u9009\u62E9\u6A21\u5F0F */\n giftSelectionMode?: 'single' | 'multiple'\n /** Learn More \u6309\u94AE\u529F\u80FD\uFF08\u9ED8\u8BA4 'learnMore'\uFF09 */\n learnMoreFun?: ButtonFunctionType\n /** Shop Now \u6309\u94AE\u529F\u80FD\uFF08\u9ED8\u8BA4 'buyNow'\uFF09 */\n shopNowFun?: ButtonFunctionType\n availableForSale: boolean\n}\n\nexport interface ProductData extends BaseProductData, WithGiftData {\n /** \u4EA7\u54C1\u63CF\u8FF0 */\n description?: string\n /** \u5F53\u524D\u4EF7\u683C */\n currentPrice?: string\n /** \u539F\u4EF7 */\n originalPrice?: string\n /** \u4E86\u89E3\u66F4\u591A\u6309\u94AE\u6587\u672C */\n learnMoreText?: string\n /** \u7ACB\u5373\u8D2D\u4E70\u6309\u94AE\u6587\u672C */\n shopNowText?: string\n /** \u8D60\u54C1\u6807\u7B7E\u6587\u672C */\n freeGiftLabel?: string\n /** \u8D60\u54C1\u9009\u62E9\u6A21\u5F0F */\n giftSelectionMode?: 'single' | 'multiple'\n}\n\n// Alias for consistency with other components\nexport type ProductCardData = ProductData\n\n/**\n * \u6587\u6848\u914D\u7F6E\u63A5\u53E3\n */\nexport interface CopyConfig {\n shopNowText: string\n freeGiftLabel: string\n learnMoreText: string\n freeGiftHeading: string\n soldOutText?: string\n}\n\n/**\n * \u4E70\u8D60\u9879\u76EE\u63A5\u53E3\n */\nexport interface BogoItem {\n id: string\n data: ProductData[]\n images: ResponsiveImages\n shopNowFun: string\n shopNowText: string\n learnMoreText: string\n layout?: 'horizontal' | 'vertical'\n}\n\n/**\n * BuyOneGetOneShelf \u4E1A\u52A1\u7EC4\u4EF6\u6570\u636E\u63A5\u53E3 - \u65B0\u683C\u5F0F\n */\nexport interface BuyOneGetOneShelfData {\n copy: CopyConfig\n theme: string\n title: string\n subtitle: string\n bogoItems: BogoItem[]\n /** \u8D85\u8FC7\u6B64\u6570\u91CF\u7684\u5546\u54C1\u65F6\u663E\u793A\"View More/View Less\"\u6309\u94AE\uFF0C\u9ED8\u8BA4 4 */\n viewMoreThreshold?: number\n /** View More \u6309\u94AE\u6587\u6848\uFF0C\u9ED8\u8BA4 'View More' */\n viewMoreText?: string\n /** View Less \u6309\u94AE\u6587\u6848\uFF0C\u9ED8\u8BA4 'View Less' */\n viewLessText?: string\n}\n\n// Root \u7EC4\u4EF6 Props\uFF08\u65B0\u7684\u7EC4\u5408\u5F0F\u8BBE\u8BA1\uFF09\nexport interface BuyOneGetOneShelfProps extends React.HTMLAttributes<HTMLDivElement> {\n /** \u6807\u9898 */\n title?: string\n /** \u526F\u6807\u9898 */\n subtitle?: string\n theme?: Theme\n /** \u5B50\u7EC4\u4EF6 */\n children: React.ReactNode\n /** Root \u7EC4\u4EF6\u7684\u81EA\u5B9A\u4E49\u7C7B\u540D */\n classNames?: Partial<Record<BuyOneGetOneShelfRootSemanticName, string>>\n /** \u8D85\u8FC7\u6B64\u6570\u91CF\u7684\u5546\u54C1\u65F6\u663E\u793A\"View More/View Less\"\u6309\u94AE\uFF0C\u9ED8\u8BA4 4 */\n viewMoreThreshold?: number\n /** View More \u6309\u94AE\u6587\u6848\uFF0C\u9ED8\u8BA4 'View More' */\n viewMoreText?: string\n /** View Less \u6309\u94AE\u6587\u6848\uFF0C\u9ED8\u8BA4 'View Less' */\n viewLessText?: string\n}\n\n// \u5361\u7247\u7EC4\u4EF6Props - \u57FA\u4E8EProductCardProps\u4F46\u7B80\u5316\nexport interface BuyOneGetOneShelfCardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick'> {\n /** \u4EA7\u54C1\u6570\u636E */\n productData: BaseProductData & {\n description?: string\n currentPrice?: string\n originalPrice?: string\n learnMoreText?: string\n shopNowText?: string\n freeGiftLabel?: string\n learnMoreFun?: ButtonFunctionType\n shopNowFun?: ButtonFunctionType\n }\n /** \u8D60\u54C1\u5217\u8868 */\n gifts?: FreeGift[]\n /** \u8D60\u54C1\u7C7B\u578B 1-> \u8D60\u9001\u5176\u4E2D\u4E00\u4E2A\u8D60\u54C1\uFF0C 2 -> \u8D60\u9001\u6240\u6709\u8D60\u54C1 */\n giftType?: 1 | 2\n soldOutText?: string\n /** \u573A\u666F\u56FE\u7247 */\n sceneImages?: ResponsiveImages\n /** @deprecated Layout is now automatically inferred by Root based on children count. */\n layout?: 'horizontal' | 'vertical'\n /** ProductCard \u7EC4\u4EF6\u7684\u81EA\u5B9A\u4E49\u7C7B\u540D */\n classNames?: Partial<Record<BuyOneGetOneShelfProductCardSemanticName, string>>\n /** @deprecated Use `onProductImageClick` instead. */\n onProductClick?: (product: ProductCardData) => void\n /** \u4EA7\u54C1\u56FE\u7247\u70B9\u51FB\u56DE\u8C03 */\n onProductImageClick?: (product: ProductCardData) => void\n /** Learn More \u70B9\u51FB\u56DE\u8C03 */\n onLearnMore?: (product: ProductCardData, selectedGifts: FreeGift[]) => void\n /** Shop Now \u70B9\u51FB\u56DE\u8C03 */\n onShopNow?: (product: ProductCardData, selectedGifts: FreeGift[]) => void\n /** \u52A0\u5165\u8D2D\u7269\u8F66\u56DE\u8C03 */\n onAddToCart?: (product: ProductCardData, selectedGifts: FreeGift[]) => void\n /** \u8D60\u54C1\u70B9\u51FB\u56DE\u8C03 */\n onGiftClick?: (gift: FreeGift, selectedGifts: FreeGift[]) => void\n /** \u8D60\u54C1\u9009\u62E9\u53D8\u5316\u56DE\u8C03 */\n onGiftSelectionChange?: (selectedGifts: FreeGift[], product: ProductCardData) => void\n /** \u9009\u4E2D\u8D60\u54C1SKU\u53D8\u5316\u56DE\u8C03\uFF08\u53D7\u63A7\u7EC4\u4EF6\uFF09 */\n onSelectedGiftSkuChange?: (selectedSku: string | null) => void\n}\n\n// \u4FDD\u6301\u5411\u540E\u517C\u5BB9\u7684\u4F20\u7EDFProps\nexport interface BuyOneGetOneShelfLegacyProps extends React.HTMLAttributes<HTMLDivElement> {\n /** \u4E1A\u52A1\u6570\u636E */\n data: BuyOneGetOneShelfData\n /** @deprecated Use `onProductImageClick` instead. */\n onProductClick?: (product: ProductCardData) => void\n /** \u4EA7\u54C1\u56FE\u7247\u70B9\u51FB\u56DE\u8C03 */\n onProductImageClick?: (product: ProductCardData) => void\n /** Learn More\u6309\u94AE\u70B9\u51FB\u4E8B\u4EF6 */\n onLearnMore?: (product: ProductCardData, selectedGifts: FreeGift[]) => void\n /** Shop Now\u6309\u94AE\u70B9\u51FB\u4E8B\u4EF6 */\n onShopNow?: (product: ProductCardData, selectedGifts: FreeGift[]) => void\n onAddToCart?: (product: ProductCardData) => void\n /** \u8D60\u54C1\u70B9\u51FB\u4E8B\u4EF6 */\n onGiftClick?: (gift: FreeGift, selectedGifts: FreeGift[]) => void\n /** \u8D60\u54C1\u9009\u62E9\u53D8\u5316\u4E8B\u4EF6 */\n onGiftSelectionChange?: (selectedGifts: FreeGift[], product: ProductCardData) => void\n classNames?: Partial<Record<BuyOneGetOneShelfSemanticName, string>>\n}\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAA,IAAAE,EAAuB",
6
6
  "names": ["types_exports", "__toCommonJS", "React"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";"use client";var Me=Object.create;var Z=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var De=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var Te=(n,r)=>{for(var i in r)Z(n,i,{get:r[i],enumerable:!0})},le=(n,r,i,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let u of Pe(r))!Ee.call(n,u)&&u!==i&&Z(n,u,{get:()=>r[u],enumerable:!(c=Se(r,u))||c.enumerable});return n};var ee=(n,r,i)=>(i=n!=null?Me(De(n)):{},le(r||!n||!n.__esModule?Z(i,"default",{value:n,enumerable:!0}):i,n)),He=n=>le(Z({},"__esModule",{value:!0}),n);var Ie={};Te(Ie,{default:()=>Be});module.exports=He(Ie);var e=require("react/jsx-runtime"),t=require("react"),l=require("../../components/index.js"),pe=require("../../shared/Styles.js"),k=require("../../helpers/utils.js"),F=ee(require("./NavProvider.js")),o=require("./types.js"),fe=ee(require("jump.js")),te=require("@gsap/react"),X=require("gsap"),C=require("./withCategory.js"),S=require("./icons/index.js"),be=ee(require("../NavigationSearch/index.js")),ve=require("./ResourceSidebarDropdown.js"),ge=require("./MobileResourceSidebarMenu.js"),he=require("./SidebarDropdown.js"),ae=require("./useScrollLock.js"),ye=require("./MulticolDropdown.js"),Ne=require("./SupportsDropdown.js"),ke=require("./MobileSidebarMenu.js"),we=require("./MobileSupportMenu.js"),xe=require("./MobileMulticolMenu.js"),ne=require("./MobileMenuComponents.js"),oe=require("../AiuiProvider/index.js"),ie=ee(require("../../shared/throttle.js"));const se=(0,t.forwardRef)((n,r)=>{const{data:{header:i}={},buildProps:c,event:u,profile:P,theme:s="light",isTop:m=!1,searchResult:x,onSearch:b,isSearching:p,keywords:_,onPrimaryNavClick:w,onSeriesProductClick:h,onSidebarNavClick:D,onMobileMenuToggle:U,headerId:E,cartCount:L,menuData:z,render:R,componentOverrides:G,...J}=n,[B,f]=(0,t.useState)(!1),[W,I]=(0,t.useState)(!1),[A,H]=(0,t.useState)(!1),[Y,g]=(0,t.useState)(!1),O=(0,t.useRef)(null),M=(0,t.useRef)(null),q=()=>{const y=document?.querySelector("body")?.offsetWidth||0;g(y<=1440)};(0,t.useEffect)(()=>(q(),window.addEventListener("resize",q),()=>{window.removeEventListener("resize",q)}),[]),(0,t.useImperativeHandle)(r,()=>M.current),(0,t.useEffect)(()=>{M.current&&m&&(0,fe.default)(M.current,{duration:0,offset:M.current?.getBoundingClientRect()?.bottom||0})},[m]),(0,t.useEffect)(()=>{if(m){I(!1),H(!1);return}let y=0,a=0,d=0;const v=()=>document?.documentElement?.scrollTop||document?.body?.scrollTop||0,N=v();y=N,I(N>300),H(N>30);const $=(0,ie.default)(()=>{const T=v(),K=T-y;H(T>30),K>0?(a=0,d+=K,d>=300&&T>300&&I(!0)):K<0&&(d=0,a+=Math.abs(K),a>=300&&(I(!1),a=0)),y=T},100);return window.addEventListener("scroll",$,{passive:!0}),()=>window.removeEventListener("scroll",$)},[m]),(0,t.useEffect)(()=>{u&&(u.search=()=>f(!0))},[u]),(0,te.useGSAP)(()=>{O?.current&&B&&X.gsap.fromTo(O.current,{height:0},{height:"auto",duration:.3})},[B]),(0,ae.useScrollLock)(B);const Q=(0,t.useMemo)(()=>i?.bar?.actions?.find(y=>y?.blockType===o.HeaderNavigationActionBlockType.Search)?.searchBar?.[0]||{},[i]),j=R?.mobileHeaderNavigation;return(0,e.jsx)(F.default,{buildProps:c,profile:P,isMobile:Y,event:u,payloadData:i,onSidebarNavClick:D,onSeriesProductClick:h,cartCount:L,componentOverrides:G,children:(0,e.jsx)("header",{...J,id:E||"header","data-ui-component-id":"HeaderNavigation",className:m?"relative z-[100] bg-white":(0,k.cn)("sticky top-0 z-[100] transition-transform duration-500 ease-in-out",{"translate-y-[-100%]":W}),ref:M,children:(0,e.jsxs)("div",{className:(0,k.cn)("hover:bg-white hover:text-black",s==="light"?"text-black":"text-white",{"!bg-white transition-all duration-500 ease-in-out":!m&&A},{"hover:!text-black":s==="dark","!text-black":!m&&A}),onClick:()=>!m&&H(!0),children:[(0,e.jsx)(ce,{data:i,className:"desktop:block hidden !bg-white",theme:s,onNavItemClick:()=>!m&&H(!0),onPrimaryNavClick:w}),j?(0,e.jsx)(j,{className:"desktop:hidden block !bg-white",menuData:z,data:i,onPrimaryNavClick:w}):(0,e.jsx)(ue,{menuData:z,data:i,className:"desktop:hidden block !bg-white",onPrimaryNavClick:w,onMobileMenuToggle:U}),B&&(0,e.jsxs)("div",{className:"absolute left-0 top-0 z-[60] flex w-full flex-col bg-black/70",style:{height:`calc(100dvh - ${M?.current?.getBoundingClientRect()?.top}px)`},role:"dialog","aria-modal":"true","aria-label":"Search",children:[(0,e.jsx)("div",{ref:O,className:(0,k.cn)("overflow-y-auto",{}),children:(0,e.jsx)(be.default,{data:Q,keywords:_,isSearching:p,searchResult:x,onSearch:y=>{b?.(y)},onClose:()=>{b?.(),f(!1)}})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>f(!1),role:"button",tabIndex:0,"aria-label":"Close search",onKeyDown:y=>{(y.key==="Enter"||y.key===" "||y.key==="Escape")&&(y.preventDefault(),f(!1))}})]})]})})})}),ce=(0,t.forwardRef)((n,r)=>{const{data:i,onNavItemClick:c,className:u,theme:P,onPrimaryNavClick:s}=n,{event:m,profile:x}=(0,F.useNavContext)(),[b,p]=(0,t.useState)(!1),{locale:_="us"}=(0,oe.useAiuiContext)(),w=(0,t.useMemo)(()=>(0,C.WithGroupCategory)(i?.categories?.filter(a=>a?.pcShow)),[i]),[h,D]=(0,t.useState)(null),[U,E]=(0,t.useState)([]),L=(0,t.useRef)(null),[z,R]=(0,t.useState)(!1),G=(0,t.useRef)(null),J=(0,t.useRef)(null),B=(0,t.useRef)(w.map(a=>Array(a?.length||0).fill(null)));(0,t.useEffect)(()=>{w?.length&&E(w?.map((a,d)=>a?.map((v,N)=>({groupIndex:d,index:N,open:!1}))))},[w]);const f=(0,t.useMemo)(()=>{let a=null;for(const d of U){for(const v of d)if(v.open){a=v;break}if(a)break}return a},[U]);(0,ae.useScrollLock)(!!f?.open||z);const W=(a,d,v)=>{R(!1);const N=w[d][v];if(N?.components?.[0]?.blockType===o.HeaderNavigationBlockType.Links)N?.components?.[0]?.url&&window.open(N?.components?.[0]?.url,N?.components?.[0]?.target??"_blank");else{const $=w?.flat()||[],T=$?.findIndex(K=>K?.id===w[d][v]?.id);a.stopPropagation(),c?.(),s?.($[T],T),D(N),E(K=>K.map(Ce=>Ce.map(V=>V.groupIndex===d&&V.index===v?{...V,open:!V.open}:{...V,open:!1})))}},I=(a,d,v)=>{a.key==="Enter"||a.key===" "?(a.preventDefault(),W(a,d,v)):a.key==="Escape"&&f?.groupIndex===d&&f?.index===v&&(a.preventDefault(),A())},A=()=>{E(a=>a.map(d=>d.map(v=>({...v,open:!1}))))},H=(0,t.useMemo)(()=>{if(h)return h?.components?.[0]?.blockType},[h]),Y=(0,C.WithSidebar)(he.SidebarDropdown,h),g=(0,C.WithResource)(ve.ResourceSidebarDropdown,h),O=(0,C.WithMulticol)(ye.MulticolDropdown,h),M=(0,C.WithSupports)(Ne.SupportsDropdown,{categoriesItem:h,currentNavItemRef:B.current?.[f?.groupIndex||0]?.[f?.index||0]}),q=(0,t.useMemo)(()=>{switch(H){case o.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(Y,{});case o.HeaderNavigationBlockType.Resource:return(0,e.jsx)(g,{});case o.HeaderNavigationBlockType.Supports:return(0,e.jsx)(M,{});case o.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(O,{});default:return null}},[H,h]),Q=(0,t.useMemo)(()=>i?.bar?.actions?.filter(a=>a?.pcShow),[i]),j=(0,t.useMemo)(()=>Q?.find(a=>a?.blockType===o.HeaderNavigationActionBlockType.Profile),[Q]),y=(0,t.useCallback)(()=>{R(a=>!a)},[]);return(0,t.useEffect)(()=>{if(L?.current){const a=L.current;return a.addEventListener("click",y),()=>{a.removeEventListener("click",y)}}},[y]),(0,te.useGSAP)(()=>{f?.open&&X.gsap.fromTo(J?.current,{height:0},{height:"auto"})},[f?.open]),(0,e.jsxs)(l.Container,{className:(0,k.cn)("relative h-[96px]",u),children:[(0,e.jsxs)("div",{ref:G,onClick:A,className:"flex h-full flex-col justify-end gap-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(de,{}),(0,e.jsx)(re,{ref:L,actions:Q,activeStatus:z})]}),(0,e.jsx)("nav",{className:"flex justify-between",role:"navigation","aria-label":"Primary navigation",children:w?.map((a,d)=>(0,e.jsx)("div",{className:"flex gap-3",children:a?.map((v,N)=>{const $=f?.groupIndex===d&&f?.index===N;return(0,e.jsx)("div",{ref:T=>{B.current[d][N]=T},className:"group",children:(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsxs)("button",{className:"flex cursor-pointer items-center gap-1 border-0 bg-transparent pb-4",onClick:T=>W(T,d,N),onKeyDown:T=>I(T,d,N),"aria-expanded":$,"aria-haspopup":"true","aria-label":v.text,children:[(0,e.jsx)(l.Text,{html:v.text,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)(S.DownArrow,{className:(0,k.cn)("size-4 opacity-0 transition-opacity duration-500 group-hover:opacity-100",{"rotate-180":f?.groupIndex===d&&f?.index===N,"opacity-100":b&&f?.groupIndex===d&&f?.index===N,invisible:!v?.components?.length||v?.components?.[0]?.blockType===o.HeaderNavigationBlockType.Links})})]}),(0,e.jsx)("div",{className:(0,k.cn)("absolute bottom-0 left-0 h-[2px] w-0 transition-all duration-500",{"w-[calc(100%-20px)]":$},P==="dark"?"bg-white":"bg-[#080A0F]"),"aria-hidden":"true"})]})},v.id)})},`groupCategory-${d}`))})]}),(0,e.jsxs)("div",{role:"menu","aria-hidden":!(f?.open&&h),className:(0,k.cn)("absolute left-0 top-full z-[999] flex w-full flex-col overflow-hidden border-t border-b-[#E4E5E6] bg-black/70 text-black",{hidden:!(f?.open&&h)}),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{height:`calc(100dvh - ${G?.current?.getBoundingClientRect()?.bottom}px)`},children:[(0,e.jsx)("div",{ref:J,className:(0,k.cn)("relative z-50",{"overflow-hidden":H!==o.HeaderNavigationBlockType.Supports}),children:q}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:A,role:"button",tabIndex:0,"aria-label":"Close menu",onKeyDown:a=>{(a.key==="Enter"||a.key===" "||a.key==="Escape")&&(a.preventDefault(),A())}})]}),z&&(0,e.jsxs)("div",{className:"absolute left-0 top-full z-[999] flex h-dvh w-full bg-black/70",role:"dialog","aria-modal":"true","aria-label":"User profile menu",children:[(0,e.jsx)("div",{className:"rounded-box absolute w-[272px] overflow-hidden bg-white p-4",style:{right:`calc(100% - ${L?.current?.getBoundingClientRect()?.right}px)`,top:"-36px"},children:x?.email?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l.Text,{html:x?.nick_name||j?.welcome,className:"text-sm font-bold"}),(0,e.jsx)("div",{className:"mt-2 h-px bg-[#D9D9D9]","aria-hidden":"true"}),(0,e.jsx)("nav",{className:"mt-2",role:"navigation","aria-label":"Profile navigation",children:j?.profiles?.map(a=>(0,e.jsx)(ne.MenuItem,{className:"py-2",label:a?.title,href:(0,k.getLocalizedPath)(a?.url,_)},a.id))})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(S.Polygon,{className:"absolute -top-2 right-[46px] z-30 text-white","aria-hidden":"true"}),(0,e.jsx)(l.Text,{html:j?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:j?.benefits?.map(a=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(l.Picture,{source:a.benefitIcon?.url,className:"size-4 shrink-0",alt:a.benefit,width:16,height:16}),(0,e.jsx)(l.Text,{html:a.benefit,className:"text-sm font-bold leading-[1.4]"})]},a.id))}),(0,e.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[(0,e.jsx)(l.Button,{className:"grow",variant:"secondary",size:"lg",onClick:()=>m?.join?.(),children:(0,e.jsx)(l.Text,{html:j?.primaryButton||"Join Now",className:"font-bold"})}),(0,e.jsx)(l.Button,{className:"grow",variant:"primary",size:"lg",onClick:()=>m?.login?.(),children:(0,e.jsx)(l.Text,{html:j?.secondaryButton||"Log In",className:"font-bold"})})]})]})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>R(!1),role:"button",tabIndex:0,"aria-label":"Close profile menu",onKeyDown:a=>{(a.key==="Enter"||a.key===" "||a.key==="Escape")&&(a.preventDefault(),R(!1))}})]})]})}),ue=(0,t.forwardRef)(({data:n,menuData:r,className:i,onPrimaryNavClick:c,onMobileMenuToggle:u},P)=>{const s=(0,t.useMemo)(()=>(0,C.WithGroupCategory)(n?.categories?.filter(g=>g?.mobileShow)),[n]),{currentMenu:m,setCurrentMenu:x,subSubCategory:b}=(0,F.useNavContext)(),[p,_]=(0,t.useState)(!1),[w,h]=(0,t.useState)(0),[D,U]=(0,t.useState)(null),E=(0,t.useRef)(null),L=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(E?.current&&p){const g=E?.current?.getBoundingClientRect();h(window?.innerHeight-(g?.top||0))}u?.({open:p})},[p,u]),(0,t.useEffect)(()=>{if(!p)return;const g=(0,ie.default)(()=>{if(E?.current){const O=E.current.getBoundingClientRect();L.current=!0,h(window?.innerHeight-(O?.top||0))}},100);return window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[p]),(0,te.useGSAP)(()=>{if(L.current){X.gsap.set(E.current,{height:w}),L.current=!1;return}X.gsap.fromTo(E.current,{height:0},{height:w,duration:.3})},[w]),(0,ae.useScrollLock)(p);const z=(0,t.useMemo)(()=>D?.components?.[0]?.blockType,[D]),R=(0,C.WithSupports)(we.MobileSupportMenu,{categoriesItem:D}),G=(0,C.WithSidebar)(ke.MobileSidebarMenu,D),J=(0,C.WithResource)(ge.MobileResourceSidebarMenu,D),B=(0,C.WithMulticol)(xe.MobileMulticolMenu,D),f=(0,t.useMemo)(()=>{switch(z){case o.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(G,{});case o.HeaderNavigationBlockType.Resource:return(0,e.jsx)(J,{});case o.HeaderNavigationBlockType.Supports:return(0,e.jsx)(R,{});case o.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(B,{});default:return null}},[z,D,R]),W=(0,t.useCallback)(()=>{_(!1),h(0),x&&x(o.HeaderNavigationMenu.Primary)},[_,h,x]),I=(0,t.useMemo)(()=>n?.bar?.actions?.filter(g=>g?.mobileShow&&g?.blockType!==o.HeaderNavigationActionBlockType.Profile),[n]),A=(0,t.useMemo)(()=>n?.bar?.actions?.find(g=>g?.mobileShow&&g?.blockType===o.HeaderNavigationActionBlockType.Profile)||{},[n]),H=(0,t.useMemo)(()=>{switch(m){case o.HeaderNavigationMenu.Primary:return(0,e.jsx)(Re,{actions:I,menuOpen:p,onMenuOpenClose:()=>{_(!1),h(0)},onMenuOpenClick:()=>_(!0)});case o.HeaderNavigationMenu.Secondary:return(0,e.jsx)(me,{title:D?.text,onMenuOpenClose:W,onMenuBackClick:()=>x?.(o.HeaderNavigationMenu.Primary)});case o.HeaderNavigationMenu.Third:return(0,e.jsx)(me,{title:b?.label,onMenuOpenClose:W,onMenuBackClick:()=>x?.(o.HeaderNavigationMenu.Secondary)});default:return null}},[p,m,x,D,I,b,W]),Y=(0,t.useCallback)((g,O)=>{const M=Array.isArray(s)?Array.isArray(s[g])?s[g][O]:{}:{};U(M),M?.components?.[0]?.blockType===o.HeaderNavigationBlockType.Links?M?.components?.[0]?.url&&window.open(M?.components?.[0]?.url,M?.components?.[0]?.target??"_blank"):x?.(o.HeaderNavigationMenu.Secondary)},[s,x]);return(0,e.jsxs)(l.Container,{className:(0,k.cn)("relative h-[52px]",i),children:[H,p&&(0,e.jsxs)("nav",{ref:E,className:"absolute left-0 top-full z-[999] w-full overflow-y-auto border-t border-[#E4E5E6] bg-white text-black",style:{height:w},role:"navigation","aria-label":"Mobile navigation menu",children:[m===o.HeaderNavigationMenu.Primary&&r?(0,e.jsx)("div",{className:"pt-4",children:(0,e.jsx)(l.BrandStrip,{data:r})}):null,m===o.HeaderNavigationMenu.Primary?(0,e.jsx)(Le,{categories:s,onPrimaryMenuClick:Y,onPrimaryNavClick:c,profileAction:A}):f]})]})}),Le=({categories:n,onPrimaryMenuClick:r,profileAction:i,onPrimaryNavClick:c})=>(0,e.jsxs)("div",{className:"flex h-full flex-col justify-between",children:[(0,e.jsx)("div",{className:"tablet:px-8 laptop:px-16 p-4",children:n?.map((u,P)=>(0,e.jsxs)("div",{className:"",children:[(0,e.jsx)("div",{className:(0,k.cn)("my-2 h-px w-full bg-[#E5E5E7]")}),u?.map((s,m)=>(0,e.jsx)(ne.MenuItem,{label:s.text,onClick:()=>{const b=(n?.flat()||[])?.findIndex(p=>p?.id===n[P][m]?.id);r(P,m),c?.(s,b)},icon:s.components?.[0]?.icon},s.id))]},`groupCategory-${P}`))}),(0,e.jsx)(ze,{profileAction:i})]}),ze=({profileAction:n})=>{const[r,i]=(0,t.useState)(!1),{profile:c,event:u}=(0,F.useNavContext)(),{locale:P="us"}=(0,oe.useAiuiContext)();return(0,e.jsxs)("div",{className:(0,k.cn)("tablet:px-8 laptop:px-16 bg-[#F5F5F7] px-4 py-6",{"p-4":r}),children:[(0,e.jsxs)("button",{className:"flex w-full cursor-pointer items-center justify-between border-0 bg-transparent",onClick:()=>i(!r),"aria-expanded":r,"aria-label":c?.nick_name||n?.welcome,children:[(0,e.jsxs)("div",{className:"flex items-center gap-[14px]",children:[(0,e.jsx)("div",{className:"flex size-[40px] shrink-0 items-center justify-center rounded-full bg-white",children:(0,e.jsx)(S.User,{"aria-hidden":"true"})}),(0,e.jsx)(l.Text,{html:c?.nick_name||n?.welcome,className:"text-base font-bold leading-[1.4]"})]}),!c?.email&&(0,e.jsx)(S.DownArrow,{"aria-hidden":"true",className:(0,k.cn)("laptop:size-4 size-5",{"rotate-180":r})})]}),c?.email&&(0,e.jsx)("nav",{className:"mt-4",role:"navigation","aria-label":"Profile menu",children:n?.profiles?.map(s=>(0,e.jsx)(ne.MenuItem,{label:s?.title,href:(0,k.getLocalizedPath)(s?.url,P)},s.id))}),r&&!c?.email&&(0,e.jsxs)("div",{className:"mt-4",children:[(0,e.jsx)(l.Text,{html:n?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:n?.benefits?.map(s=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(l.Picture,{source:s.benefitIcon?.url,className:"size-4",alt:s.benefit,width:16,height:16}),(0,e.jsx)(l.Text,{html:s.benefit,className:"text-sm font-bold leading-[1.4]"})]},s.id))})]}),!c?.email&&(0,e.jsxs)("div",{className:"mt-4 flex items-center gap-3",children:[(0,e.jsx)(l.Button,{className:"tablet:flex-none flex-1",variant:"secondary",size:"base",onClick:()=>u?.join?.(),children:(0,e.jsx)(l.Text,{html:n?.primaryButton||"Join Now",className:"text-sm font-bold leading-[1.4]"})}),(0,e.jsx)(l.Button,{className:"tablet:flex-none flex-1",variant:"primary",size:"base",onClick:()=>u?.login?.(),children:(0,e.jsx)(l.Text,{html:n?.secondaryButton||"Log In",className:"text-sm font-bold leading-[1.4]"})})]})]})},Re=({menuOpen:n,onMenuOpenClose:r,onMenuOpenClick:i,actions:c})=>(0,e.jsxs)("div",{className:"flex h-full items-center justify-between gap-4",children:[(0,e.jsx)(de,{}),(0,e.jsxs)("div",{className:"desktop:gap-6 flex items-center gap-4",children:[(0,e.jsx)(re,{actions:c}),n?(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>r(),"aria-label":"Close menu","aria-expanded":"true",children:(0,e.jsx)(S.Close,{className:"size-5","aria-hidden":"true"})}):(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Open menu","aria-expanded":"false","aria-haspopup":"true",children:(0,e.jsx)(S.Menu,{className:"size-5","aria-hidden":"true"})})]})]}),de=()=>{const{payloadData:n,isMobile:r}=(0,F.useNavContext)(),{locale:i="us"}=(0,oe.useAiuiContext)();return(0,e.jsx)("a",{href:(0,k.getLocalizedPath)("/",i),className:"hover:text-brand-0 [&>svg]:w-full","aria-label":"Home",dangerouslySetInnerHTML:{__html:r?n?.bar?.mobileLogo:n?.bar?.desktopLogo}})},re=(0,t.forwardRef)(({actions:n,activeStatus:r=!1},i)=>{const{event:c,cartCount:u}=(0,F.useNavContext)(),[P,s]=(0,t.useState)(null),m=b=>{switch(b){case o.HeaderNavigationActionBlockType.Search:return"Search";case o.HeaderNavigationActionBlockType.Cart:return`Shopping cart${u>0?` (${u} items)`:""}`;case o.HeaderNavigationActionBlockType.Profile:return"User profile";case o.HeaderNavigationActionBlockType.Livestream:return"Livestream";default:return"Action"}},x=(0,t.useCallback)((b,p)=>{switch(s(p),b?.blockType){case o.HeaderNavigationActionBlockType.Search:c?.search?.();break;case o.HeaderNavigationActionBlockType.Cart:c?.cart?.();break;case o.HeaderNavigationActionBlockType.Profile:c?.profile?.();break;case o.HeaderNavigationActionBlockType.Livestream:c?.livestream?.();break;default:return()=>{}}},[c]);return(0,e.jsx)("div",{className:"desktop:gap-6 flex items-center gap-4",children:Array.isArray(n)&&n?.map((b,p)=>(0,e.jsxs)("button",{className:"relative cursor-pointer border-0 bg-transparent p-0","data-tag":b?.tag||"",ref:b.blockType===o.HeaderNavigationActionBlockType.Profile?i:null,onClick:()=>x(b,p),"aria-label":m(b.blockType),"aria-pressed":r&&P===p,children:[(0,e.jsx)(l.Text,{html:b.icon,className:(0,k.cn)("size-5",{"text-brand-0":r&&P===p}),"aria-hidden":"true"}),b.blockType===o.HeaderNavigationActionBlockType.Cart&&u>0&&(0,e.jsx)("div",{className:"bg-brand-0 absolute right-[-12px] top-[calc(100%-16px)] z-[1] flex min-h-5 min-w-5 items-center justify-center rounded-full px-[2px]","aria-hidden":"true",children:(0,e.jsx)(l.Text,{html:u?.toString(),className:"text-sm font-bold leading-[1.2] text-white"})})]},b.id))})}),me=({title:n,onMenuOpenClose:r,onMenuBackClick:i})=>(0,e.jsxs)("div",{className:"flex h-full items-center gap-3",children:[(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Back to previous menu",children:(0,e.jsx)(S.LeftArrow,{className:"size-5","aria-hidden":"true"})}),(0,e.jsx)(l.Text,{html:n,className:"flex-1 text-center text-base font-bold leading-[1.4]"}),(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>r(),"aria-label":"Close menu",children:(0,e.jsx)(S.Close,{className:"size-5","aria-hidden":"true"})})]});ue.displayName="MobileNavigation",re.displayName="Actions",se.displayName="HeaderNavigation",ce.displayName="DesktopNavigation";var Be=(0,pe.withLayout)(se);
1
+ "use strict";"use client";var Me=Object.create;var Z=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var De=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var Te=(n,o)=>{for(var i in o)Z(n,i,{get:o[i],enumerable:!0})},le=(n,o,i,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let u of Pe(o))!Ee.call(n,u)&&u!==i&&Z(n,u,{get:()=>o[u],enumerable:!(c=Se(o,u))||c.enumerable});return n};var ee=(n,o,i)=>(i=n!=null?Me(De(n)):{},le(o||!n||!n.__esModule?Z(i,"default",{value:n,enumerable:!0}):i,n)),He=n=>le(Z({},"__esModule",{value:!0}),n);var Ie={};Te(Ie,{default:()=>Be});module.exports=He(Ie);var e=require("react/jsx-runtime"),t=require("react"),l=require("../../components/index.js"),pe=require("../../shared/Styles.js"),g=require("../../helpers/utils.js"),U=ee(require("./NavProvider.js")),r=require("./types.js"),fe=ee(require("jump.js")),te=require("@gsap/react"),X=require("gsap"),C=require("./withCategory.js"),S=require("./icons/index.js"),be=ee(require("../NavigationSearch/index.js")),ve=require("./ResourceSidebarDropdown.js"),ge=require("./MobileResourceSidebarMenu.js"),he=require("./SidebarDropdown.js"),ae=require("./useScrollLock.js"),ye=require("./MulticolDropdown.js"),Ne=require("./SupportsDropdown.js"),ke=require("./MobileSidebarMenu.js"),we=require("./MobileSupportMenu.js"),xe=require("./MobileMulticolMenu.js"),ne=require("./MobileMenuComponents.js"),re=require("../AiuiProvider/index.js"),ie=ee(require("../../shared/throttle.js"));const se=(0,t.forwardRef)((n,o)=>{const{data:{header:i}={},buildProps:c,event:u,profile:P,theme:s="light",isTop:m=!1,searchResult:x,onSearch:b,isSearching:p,keywords:_,onPrimaryNavClick:w,onSeriesProductClick:y,onSidebarNavClick:D,onMobileMenuToggle:G,headerId:E,cartCount:L,menuData:z,render:R,componentOverrides:J,...Y}=n,[B,f]=(0,t.useState)(!1),[W,I]=(0,t.useState)(!1),[A,H]=(0,t.useState)(!1),[$,h]=(0,t.useState)(!1),O=(0,t.useRef)(null),M=(0,t.useRef)(null),q=()=>{const N=window.innerWidth||0;h(N<1440)};(0,t.useEffect)(()=>(q(),window.addEventListener("resize",q),()=>{window.removeEventListener("resize",q)}),[]),(0,t.useImperativeHandle)(o,()=>M.current),(0,t.useEffect)(()=>{M.current&&m&&(0,fe.default)(M.current,{duration:0,offset:M.current?.getBoundingClientRect()?.bottom||0})},[m]),(0,t.useEffect)(()=>{if(m){I(!1),H(!1);return}let N=0,a=0,d=0;const v=()=>document?.documentElement?.scrollTop||document?.body?.scrollTop||0,k=v();N=k,I(k>300),H(k>30);const K=(0,ie.default)(()=>{const T=v(),F=T-N;H(T>30),F>0?(a=0,d+=F,d>=300&&T>300&&I(!0)):F<0&&(d=0,a+=Math.abs(F),a>=300&&(I(!1),a=0)),N=T},100);return window.addEventListener("scroll",K,{passive:!0}),()=>window.removeEventListener("scroll",K)},[m]),(0,t.useEffect)(()=>{u&&(u.search=()=>f(!0))},[u]),(0,te.useGSAP)(()=>{O?.current&&B&&X.gsap.fromTo(O.current,{height:0},{height:"auto",duration:.3})},[B]),(0,ae.useScrollLock)(B);const Q=(0,t.useMemo)(()=>i?.bar?.actions?.find(N=>N?.blockType===r.HeaderNavigationActionBlockType.Search)?.searchBar?.[0]||{},[i]),j=R?.mobileHeaderNavigation;return(0,e.jsx)(U.default,{buildProps:c,profile:P,isMobile:$,event:u,payloadData:i,onSidebarNavClick:D,onSeriesProductClick:y,cartCount:L,componentOverrides:J,children:(0,e.jsx)("header",{...Y,id:E||"header","data-ui-component-id":"HeaderNavigation",className:m?"relative z-[100] bg-white":(0,g.cn)("sticky top-0 z-[100] transition-transform duration-500 ease-in-out",{"translate-y-[-100%]":W}),ref:M,children:(0,e.jsxs)("div",{className:(0,g.cn)("hover:bg-white hover:text-black",s==="light"?"text-black":"text-white",{"!bg-white transition-all duration-500 ease-in-out":!m&&A},{"hover:!text-black":s==="dark","!text-black":!m&&A}),onClick:()=>!m&&H(!0),children:[(0,e.jsx)(ce,{data:i,className:(0,g.cn)("hidden !bg-white",!$&&"block"),theme:s,onNavItemClick:()=>!m&&H(!0),onPrimaryNavClick:w}),j?(0,e.jsx)(j,{className:(0,g.cn)("block !bg-white",!$&&"hidden"),menuData:z,data:i,onPrimaryNavClick:w}):(0,e.jsx)(ue,{menuData:z,data:i,className:(0,g.cn)("block !bg-white",!$&&"hidden"),onPrimaryNavClick:w,onMobileMenuToggle:G}),B&&(0,e.jsxs)("div",{className:"absolute left-0 top-0 z-[60] flex w-full flex-col bg-black/70",style:{height:`calc(100dvh - ${M?.current?.getBoundingClientRect()?.top}px)`},role:"dialog","aria-modal":"true","aria-label":"Search",children:[(0,e.jsx)("div",{ref:O,className:(0,g.cn)("overflow-y-auto",{}),children:(0,e.jsx)(be.default,{data:Q,keywords:_,isSearching:p,searchResult:x,onSearch:N=>{b?.(N)},onClose:()=>{b?.(),f(!1)}})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>f(!1),role:"button",tabIndex:0,"aria-label":"Close search",onKeyDown:N=>{(N.key==="Enter"||N.key===" "||N.key==="Escape")&&(N.preventDefault(),f(!1))}})]})]})})})}),ce=(0,t.forwardRef)((n,o)=>{const{data:i,onNavItemClick:c,className:u,theme:P,onPrimaryNavClick:s}=n,{event:m,profile:x}=(0,U.useNavContext)(),[b,p]=(0,t.useState)(!1),{locale:_="us"}=(0,re.useAiuiContext)(),w=(0,t.useMemo)(()=>(0,C.WithGroupCategory)(i?.categories?.filter(a=>a?.pcShow)),[i]),[y,D]=(0,t.useState)(null),[G,E]=(0,t.useState)([]),L=(0,t.useRef)(null),[z,R]=(0,t.useState)(!1),J=(0,t.useRef)(null),Y=(0,t.useRef)(null),B=(0,t.useRef)(w.map(a=>Array(a?.length||0).fill(null)));(0,t.useEffect)(()=>{w?.length&&E(w?.map((a,d)=>a?.map((v,k)=>({groupIndex:d,index:k,open:!1}))))},[w]);const f=(0,t.useMemo)(()=>{let a=null;for(const d of G){for(const v of d)if(v.open){a=v;break}if(a)break}return a},[G]);(0,ae.useScrollLock)(!!f?.open||z);const W=(a,d,v)=>{R(!1);const k=w[d][v];if(k?.components?.[0]?.blockType===r.HeaderNavigationBlockType.Links)k?.components?.[0]?.url&&window.open(k?.components?.[0]?.url,k?.components?.[0]?.target??"_blank");else{const K=w?.flat()||[],T=K?.findIndex(F=>F?.id===w[d][v]?.id);a.stopPropagation(),c?.(),s?.(K[T],T),D(k),E(F=>F.map(Ce=>Ce.map(V=>V.groupIndex===d&&V.index===v?{...V,open:!V.open}:{...V,open:!1})))}},I=(a,d,v)=>{a.key==="Enter"||a.key===" "?(a.preventDefault(),W(a,d,v)):a.key==="Escape"&&f?.groupIndex===d&&f?.index===v&&(a.preventDefault(),A())},A=()=>{E(a=>a.map(d=>d.map(v=>({...v,open:!1}))))},H=(0,t.useMemo)(()=>{if(y)return y?.components?.[0]?.blockType},[y]),$=(0,C.WithSidebar)(he.SidebarDropdown,y),h=(0,C.WithResource)(ve.ResourceSidebarDropdown,y),O=(0,C.WithMulticol)(ye.MulticolDropdown,y),M=(0,C.WithSupports)(Ne.SupportsDropdown,{categoriesItem:y,currentNavItemRef:B.current?.[f?.groupIndex||0]?.[f?.index||0]}),q=(0,t.useMemo)(()=>{switch(H){case r.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)($,{});case r.HeaderNavigationBlockType.Resource:return(0,e.jsx)(h,{});case r.HeaderNavigationBlockType.Supports:return(0,e.jsx)(M,{});case r.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(O,{});default:return null}},[H,y]),Q=(0,t.useMemo)(()=>i?.bar?.actions?.filter(a=>a?.pcShow),[i]),j=(0,t.useMemo)(()=>Q?.find(a=>a?.blockType===r.HeaderNavigationActionBlockType.Profile),[Q]),N=(0,t.useCallback)(()=>{R(a=>!a)},[]);return(0,t.useEffect)(()=>{if(L?.current){const a=L.current;return a.addEventListener("click",N),()=>{a.removeEventListener("click",N)}}},[N]),(0,te.useGSAP)(()=>{f?.open&&X.gsap.fromTo(Y?.current,{height:0},{height:"auto"})},[f?.open]),(0,e.jsxs)(l.Container,{className:(0,g.cn)("relative h-[96px]",u),children:[(0,e.jsxs)("div",{ref:J,onClick:A,className:"flex h-full flex-col justify-end gap-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(de,{}),(0,e.jsx)(oe,{ref:L,actions:Q,activeStatus:z})]}),(0,e.jsx)("nav",{className:"flex justify-between",role:"navigation","aria-label":"Primary navigation",children:w?.map((a,d)=>(0,e.jsx)("div",{className:"flex gap-3",children:a?.map((v,k)=>{const K=f?.groupIndex===d&&f?.index===k;return(0,e.jsx)("div",{ref:T=>{B.current[d][k]=T},className:"group",children:(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsxs)("button",{className:"flex cursor-pointer items-center gap-1 border-0 bg-transparent pb-4",onClick:T=>W(T,d,k),onKeyDown:T=>I(T,d,k),"aria-expanded":K,"aria-haspopup":"true","aria-label":v.text,children:[(0,e.jsx)(l.Text,{html:v.text,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)(S.DownArrow,{className:(0,g.cn)("size-4 opacity-0 transition-opacity duration-500 group-hover:opacity-100",{"rotate-180":f?.groupIndex===d&&f?.index===k,"opacity-100":b&&f?.groupIndex===d&&f?.index===k,invisible:!v?.components?.length||v?.components?.[0]?.blockType===r.HeaderNavigationBlockType.Links})})]}),(0,e.jsx)("div",{className:(0,g.cn)("absolute bottom-0 left-0 h-[2px] w-0 transition-all duration-500",{"w-[calc(100%-20px)]":K},P==="dark"?"bg-white":"bg-[#080A0F]"),"aria-hidden":"true"})]})},v.id)})},`groupCategory-${d}`))})]}),(0,e.jsxs)("div",{role:"menu","aria-hidden":!(f?.open&&y),className:(0,g.cn)("absolute left-0 top-full z-[999] flex w-full flex-col overflow-hidden border-t border-b-[#E4E5E6] bg-black/70 text-black",{hidden:!(f?.open&&y)}),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{height:`calc(100dvh - ${J?.current?.getBoundingClientRect()?.bottom}px)`},children:[(0,e.jsx)("div",{ref:Y,className:(0,g.cn)("relative z-50",{"overflow-hidden":H!==r.HeaderNavigationBlockType.Supports}),children:q}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:A,role:"button",tabIndex:0,"aria-label":"Close menu",onKeyDown:a=>{(a.key==="Enter"||a.key===" "||a.key==="Escape")&&(a.preventDefault(),A())}})]}),z&&(0,e.jsxs)("div",{className:"absolute left-0 top-full z-[999] flex h-dvh w-full bg-black/70",role:"dialog","aria-modal":"true","aria-label":"User profile menu",children:[(0,e.jsx)("div",{className:"rounded-box absolute w-[272px] overflow-hidden bg-white p-4",style:{right:`calc(100% - ${L?.current?.getBoundingClientRect()?.right}px)`,top:"-36px"},children:x?.email?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l.Text,{html:x?.nick_name||j?.welcome,className:"text-sm font-bold"}),(0,e.jsx)("div",{className:"mt-2 h-px bg-[#D9D9D9]","aria-hidden":"true"}),(0,e.jsx)("nav",{className:"mt-2",role:"navigation","aria-label":"Profile navigation",children:j?.profiles?.map(a=>(0,e.jsx)(ne.MenuItem,{className:"py-2",label:a?.title,href:(0,g.getLocalizedPath)(a?.url,_)},a.id))})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(S.Polygon,{className:"absolute -top-2 right-[46px] z-30 text-white","aria-hidden":"true"}),(0,e.jsx)(l.Text,{html:j?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:j?.benefits?.map(a=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(l.Picture,{source:a.benefitIcon?.url,className:"size-4 shrink-0",alt:a.benefit,width:16,height:16}),(0,e.jsx)(l.Text,{html:a.benefit,className:"text-sm font-bold leading-[1.4]"})]},a.id))}),(0,e.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[(0,e.jsx)(l.Button,{className:"grow",variant:"secondary",size:"lg",onClick:()=>m?.join?.(),children:(0,e.jsx)(l.Text,{html:j?.primaryButton||"Join Now",className:"font-bold"})}),(0,e.jsx)(l.Button,{className:"grow",variant:"primary",size:"lg",onClick:()=>m?.login?.(),children:(0,e.jsx)(l.Text,{html:j?.secondaryButton||"Log In",className:"font-bold"})})]})]})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>R(!1),role:"button",tabIndex:0,"aria-label":"Close profile menu",onKeyDown:a=>{(a.key==="Enter"||a.key===" "||a.key==="Escape")&&(a.preventDefault(),R(!1))}})]})]})}),ue=(0,t.forwardRef)(({data:n,menuData:o,className:i,onPrimaryNavClick:c,onMobileMenuToggle:u},P)=>{const s=(0,t.useMemo)(()=>(0,C.WithGroupCategory)(n?.categories?.filter(h=>h?.mobileShow)),[n]),{currentMenu:m,setCurrentMenu:x,subSubCategory:b}=(0,U.useNavContext)(),[p,_]=(0,t.useState)(!1),[w,y]=(0,t.useState)(0),[D,G]=(0,t.useState)(null),E=(0,t.useRef)(null),L=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(E?.current&&p){const h=E?.current?.getBoundingClientRect();y(window?.innerHeight-(h?.top||0))}u?.({open:p})},[p,u]),(0,t.useEffect)(()=>{if(!p)return;const h=(0,ie.default)(()=>{if(E?.current){const O=E.current.getBoundingClientRect();L.current=!0,y(window?.innerHeight-(O?.top||0))}},100);return window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[p]),(0,te.useGSAP)(()=>{if(L.current){X.gsap.set(E.current,{height:w}),L.current=!1;return}X.gsap.fromTo(E.current,{height:0},{height:w,duration:.3})},[w]),(0,ae.useScrollLock)(p);const z=(0,t.useMemo)(()=>D?.components?.[0]?.blockType,[D]),R=(0,C.WithSupports)(we.MobileSupportMenu,{categoriesItem:D}),J=(0,C.WithSidebar)(ke.MobileSidebarMenu,D),Y=(0,C.WithResource)(ge.MobileResourceSidebarMenu,D),B=(0,C.WithMulticol)(xe.MobileMulticolMenu,D),f=(0,t.useMemo)(()=>{switch(z){case r.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(J,{});case r.HeaderNavigationBlockType.Resource:return(0,e.jsx)(Y,{});case r.HeaderNavigationBlockType.Supports:return(0,e.jsx)(R,{});case r.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(B,{});default:return null}},[z,D,R]),W=(0,t.useCallback)(()=>{_(!1),y(0),x&&x(r.HeaderNavigationMenu.Primary)},[_,y,x]),I=(0,t.useMemo)(()=>n?.bar?.actions?.filter(h=>h?.mobileShow&&h?.blockType!==r.HeaderNavigationActionBlockType.Profile),[n]),A=(0,t.useMemo)(()=>n?.bar?.actions?.find(h=>h?.mobileShow&&h?.blockType===r.HeaderNavigationActionBlockType.Profile)||{},[n]),H=(0,t.useMemo)(()=>{switch(m){case r.HeaderNavigationMenu.Primary:return(0,e.jsx)(Re,{actions:I,menuOpen:p,onMenuOpenClose:()=>{_(!1),y(0)},onMenuOpenClick:()=>_(!0)});case r.HeaderNavigationMenu.Secondary:return(0,e.jsx)(me,{title:D?.text,onMenuOpenClose:W,onMenuBackClick:()=>x?.(r.HeaderNavigationMenu.Primary)});case r.HeaderNavigationMenu.Third:return(0,e.jsx)(me,{title:b?.label,onMenuOpenClose:W,onMenuBackClick:()=>x?.(r.HeaderNavigationMenu.Secondary)});default:return null}},[p,m,x,D,I,b,W]),$=(0,t.useCallback)((h,O)=>{const M=Array.isArray(s)?Array.isArray(s[h])?s[h][O]:{}:{};G(M),M?.components?.[0]?.blockType===r.HeaderNavigationBlockType.Links?M?.components?.[0]?.url&&window.open(M?.components?.[0]?.url,M?.components?.[0]?.target??"_blank"):x?.(r.HeaderNavigationMenu.Secondary)},[s,x]);return(0,e.jsxs)(l.Container,{className:(0,g.cn)("relative h-[52px]",i),children:[H,p&&(0,e.jsxs)("nav",{ref:E,className:"absolute left-0 top-full z-[999] w-full overflow-y-auto border-t border-[#E4E5E6] bg-white text-black",style:{height:w},role:"navigation","aria-label":"Mobile navigation menu",children:[m===r.HeaderNavigationMenu.Primary&&o?(0,e.jsx)("div",{className:"pt-4",children:(0,e.jsx)(l.BrandStrip,{data:o})}):null,m===r.HeaderNavigationMenu.Primary?(0,e.jsx)(Le,{categories:s,onPrimaryMenuClick:$,onPrimaryNavClick:c,profileAction:A}):f]})]})}),Le=({categories:n,onPrimaryMenuClick:o,profileAction:i,onPrimaryNavClick:c})=>(0,e.jsxs)("div",{className:"flex h-full flex-col justify-between",children:[(0,e.jsx)("div",{className:"tablet:px-8 laptop:px-16 p-4",children:n?.map((u,P)=>(0,e.jsxs)("div",{className:"",children:[(0,e.jsx)("div",{className:(0,g.cn)("my-2 h-px w-full bg-[#E5E5E7]")}),u?.map((s,m)=>(0,e.jsx)(ne.MenuItem,{label:s.text,onClick:()=>{const b=(n?.flat()||[])?.findIndex(p=>p?.id===n[P][m]?.id);o(P,m),c?.(s,b)},icon:s.components?.[0]?.icon},s.id))]},`groupCategory-${P}`))}),(0,e.jsx)(ze,{profileAction:i})]}),ze=({profileAction:n})=>{const[o,i]=(0,t.useState)(!1),{profile:c,event:u}=(0,U.useNavContext)(),{locale:P="us"}=(0,re.useAiuiContext)();return(0,e.jsxs)("div",{className:(0,g.cn)("tablet:px-8 laptop:px-16 bg-[#F5F5F7] px-4 py-6",{"p-4":o}),children:[(0,e.jsxs)("button",{className:"flex w-full cursor-pointer items-center justify-between border-0 bg-transparent",onClick:()=>i(!o),"aria-expanded":o,"aria-label":c?.nick_name||n?.welcome,children:[(0,e.jsxs)("div",{className:"flex items-center gap-[14px]",children:[(0,e.jsx)("div",{className:"flex size-[40px] shrink-0 items-center justify-center rounded-full bg-white",children:(0,e.jsx)(S.User,{"aria-hidden":"true"})}),(0,e.jsx)(l.Text,{html:c?.nick_name||n?.welcome,className:"text-base font-bold leading-[1.4]"})]}),!c?.email&&(0,e.jsx)(S.DownArrow,{"aria-hidden":"true",className:(0,g.cn)("laptop:size-4 size-5",{"rotate-180":o})})]}),c?.email&&(0,e.jsx)("nav",{className:"mt-4",role:"navigation","aria-label":"Profile menu",children:n?.profiles?.map(s=>(0,e.jsx)(ne.MenuItem,{label:s?.title,href:(0,g.getLocalizedPath)(s?.url,P)},s.id))}),o&&!c?.email&&(0,e.jsxs)("div",{className:"mt-4",children:[(0,e.jsx)(l.Text,{html:n?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:n?.benefits?.map(s=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(l.Picture,{source:s.benefitIcon?.url,className:"size-4",alt:s.benefit,width:16,height:16}),(0,e.jsx)(l.Text,{html:s.benefit,className:"text-sm font-bold leading-[1.4]"})]},s.id))})]}),!c?.email&&(0,e.jsxs)("div",{className:"mt-4 flex items-center gap-3",children:[(0,e.jsx)(l.Button,{className:"tablet:flex-none flex-1",variant:"secondary",size:"base",onClick:()=>u?.join?.(),children:(0,e.jsx)(l.Text,{html:n?.primaryButton||"Join Now",className:"text-sm font-bold leading-[1.4]"})}),(0,e.jsx)(l.Button,{className:"tablet:flex-none flex-1",variant:"primary",size:"base",onClick:()=>u?.login?.(),children:(0,e.jsx)(l.Text,{html:n?.secondaryButton||"Log In",className:"text-sm font-bold leading-[1.4]"})})]})]})},Re=({menuOpen:n,onMenuOpenClose:o,onMenuOpenClick:i,actions:c})=>(0,e.jsxs)("div",{className:"flex h-full items-center justify-between gap-4",children:[(0,e.jsx)(de,{}),(0,e.jsxs)("div",{className:"desktop:gap-6 flex items-center gap-4",children:[(0,e.jsx)(oe,{actions:c}),n?(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>o(),"aria-label":"Close menu","aria-expanded":"true",children:(0,e.jsx)(S.Close,{className:"size-5","aria-hidden":"true"})}):(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Open menu","aria-expanded":"false","aria-haspopup":"true",children:(0,e.jsx)(S.Menu,{className:"size-5","aria-hidden":"true"})})]})]}),de=()=>{const{payloadData:n,isMobile:o}=(0,U.useNavContext)(),{locale:i="us"}=(0,re.useAiuiContext)();return(0,e.jsx)("a",{href:(0,g.getLocalizedPath)("/",i),className:"hover:text-brand-0 [&>svg]:w-full","aria-label":"Home",dangerouslySetInnerHTML:{__html:o?n?.bar?.mobileLogo:n?.bar?.desktopLogo}})},oe=(0,t.forwardRef)(({actions:n,activeStatus:o=!1},i)=>{const{event:c,cartCount:u}=(0,U.useNavContext)(),[P,s]=(0,t.useState)(null),m=b=>{switch(b){case r.HeaderNavigationActionBlockType.Search:return"Search";case r.HeaderNavigationActionBlockType.Cart:return`Shopping cart${u>0?` (${u} items)`:""}`;case r.HeaderNavigationActionBlockType.Profile:return"User profile";case r.HeaderNavigationActionBlockType.Livestream:return"Livestream";default:return"Action"}},x=(0,t.useCallback)((b,p)=>{switch(s(p),b?.blockType){case r.HeaderNavigationActionBlockType.Search:c?.search?.();break;case r.HeaderNavigationActionBlockType.Cart:c?.cart?.();break;case r.HeaderNavigationActionBlockType.Profile:c?.profile?.();break;case r.HeaderNavigationActionBlockType.Livestream:c?.livestream?.();break;default:return()=>{}}},[c]);return(0,e.jsx)("div",{className:"desktop:gap-6 flex items-center gap-4",children:Array.isArray(n)&&n?.map((b,p)=>(0,e.jsxs)("button",{className:"relative cursor-pointer border-0 bg-transparent p-0","data-tag":b?.tag||"",ref:b.blockType===r.HeaderNavigationActionBlockType.Profile?i:null,onClick:()=>x(b,p),"aria-label":m(b.blockType),"aria-pressed":o&&P===p,children:[(0,e.jsx)(l.Text,{html:b.icon,className:(0,g.cn)("size-5",{"text-brand-0":o&&P===p}),"aria-hidden":"true"}),b.blockType===r.HeaderNavigationActionBlockType.Cart&&u>0&&(0,e.jsx)("div",{className:"bg-brand-0 absolute right-[-12px] top-[calc(100%-16px)] z-[1] flex min-h-5 min-w-5 items-center justify-center rounded-full px-[2px]","aria-hidden":"true",children:(0,e.jsx)(l.Text,{html:u?.toString(),className:"text-sm font-bold leading-[1.2] text-white"})})]},b.id))})}),me=({title:n,onMenuOpenClose:o,onMenuBackClick:i})=>(0,e.jsxs)("div",{className:"flex h-full items-center gap-3",children:[(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Back to previous menu",children:(0,e.jsx)(S.LeftArrow,{className:"size-5","aria-hidden":"true"})}),(0,e.jsx)(l.Text,{html:n,className:"flex-1 text-center text-base font-bold leading-[1.4]"}),(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>o(),"aria-label":"Close menu",children:(0,e.jsx)(S.Close,{className:"size-5","aria-hidden":"true"})})]});ue.displayName="MobileNavigation",oe.displayName="Actions",se.displayName="HeaderNavigation",ce.displayName="DesktopNavigation";var Be=(0,pe.withLayout)(se);
2
2
  //# sourceMappingURL=index.js.map