@anker-in/headless-ui 1.0.26-alpha.1762780691263 → 1.0.26-alpha.1762827586408

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 (31) hide show
  1. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductSummary/index.js +1 -1
  2. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductSummary/index.js.map +2 -2
  3. package/dist/cjs/biz-components/Listing/components/PurchaseBar/ProductActions/index.js +1 -1
  4. package/dist/cjs/biz-components/Listing/components/PurchaseBar/ProductActions/index.js.map +3 -3
  5. package/dist/cjs/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/index.js +1 -1
  6. package/dist/cjs/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/index.js.map +3 -3
  7. package/dist/cjs/biz-components/Listing/hooks/useBenefits.js +1 -1
  8. package/dist/cjs/biz-components/Listing/hooks/useBenefits.js.map +3 -3
  9. package/dist/cjs/biz-components/Listing/hooks/useDiscountEnable.d.ts +5 -5
  10. package/dist/cjs/biz-components/Listing/hooks/useDiscountEnable.js +1 -1
  11. package/dist/cjs/biz-components/Listing/hooks/useDiscountEnable.js.map +3 -3
  12. package/dist/cjs/biz-components/Listing/types.d.ts +1 -0
  13. package/dist/cjs/biz-components/Listing/types.js +1 -1
  14. package/dist/cjs/biz-components/Listing/types.js.map +1 -1
  15. package/dist/cjs/biz-components/Title/index.js +1 -1
  16. package/dist/cjs/biz-components/Title/index.js.map +2 -2
  17. package/dist/esm/biz-components/Listing/components/ProductCard/ProductSummary/index.js +1 -1
  18. package/dist/esm/biz-components/Listing/components/ProductCard/ProductSummary/index.js.map +2 -2
  19. package/dist/esm/biz-components/Listing/components/PurchaseBar/ProductActions/index.js +1 -1
  20. package/dist/esm/biz-components/Listing/components/PurchaseBar/ProductActions/index.js.map +3 -3
  21. package/dist/esm/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/index.js +1 -1
  22. package/dist/esm/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/index.js.map +3 -3
  23. package/dist/esm/biz-components/Listing/hooks/useBenefits.js +1 -1
  24. package/dist/esm/biz-components/Listing/hooks/useBenefits.js.map +3 -3
  25. package/dist/esm/biz-components/Listing/hooks/useDiscountEnable.d.ts +5 -5
  26. package/dist/esm/biz-components/Listing/hooks/useDiscountEnable.js +1 -1
  27. package/dist/esm/biz-components/Listing/hooks/useDiscountEnable.js.map +3 -3
  28. package/dist/esm/biz-components/Listing/types.d.ts +1 -0
  29. package/dist/esm/biz-components/Title/index.js +1 -1
  30. package/dist/esm/biz-components/Title/index.js.map +2 -2
  31. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/biz-components/Title/index.tsx"],
4
- "sourcesContent": ["'use client'\nimport React, { useEffect, useRef, useImperativeHandle } from 'react'\nimport { gsap } from 'gsap'\nimport { SplitText } from 'gsap/dist/SplitText'\nimport { ScrollTrigger } from 'gsap/dist/ScrollTrigger'\nimport { cn } from '../../helpers/utils.js'\nimport { Heading } from '../../components/index.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport type { TitleProps } from './types.js'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { trackUrlRef } from '../../shared/trackUrlRef.js'\nimport { useInView } from 'react-intersection-observer'\n\nconst componentType = 'link'\nconst componentName = 'title'\n\nconst Title = React.forwardRef<HTMLDivElement, TitleProps>(({ data, className, as = 'h2' }, ref) => {\n const { title, caption, theme, extensions, align = 'left' } = data\n const innerRef = useRef<HTMLDivElement>(null)\n const titleRef = useRef<HTMLHeadingElement>(null)\n const splitTextInstance = useRef<SplitText | null>(null)\n const scrollTriggerRef = useRef<ScrollTrigger | null>(null)\n\n const { ref: inViewRef, inView } = useInView()\n\n useImperativeHandle(ref, () => innerRef.current as HTMLDivElement)\n\n useEffect(() => {\n gsap.registerPlugin(SplitText, ScrollTrigger)\n function gsapResize() {\n if (!titleRef.current) return\n const height = titleRef.current?.clientHeight || 80\n if (splitTextInstance.current) {\n splitTextInstance.current.revert()\n }\n if (scrollTriggerRef.current) {\n scrollTriggerRef.current.kill()\n }\n splitTextInstance.current = new SplitText(titleRef.current, {\n type: 'words',\n wordsClass: 'word',\n })\n const words = splitTextInstance.current.words\n gsap.set(words, { opacity: 0 })\n scrollTriggerRef.current = ScrollTrigger.create({\n trigger: titleRef.current,\n start: 'bottom bottom-=4%',\n end: `bottom+=${height * 1.5 + 60}px bottom-=4%`,\n scrub: true,\n invalidateOnRefresh: true,\n onUpdate: (self: any) => {\n const progress = self.progress\n const total = words.length || 1\n const overlap = 0.5\n const interval = 1 / total\n const step = interval * (1 - overlap)\n const lastEnd = (total - 1) * step + interval\n const normalizedProgress = Math.min(1, lastEnd > 0 ? progress / lastEnd : 0)\n words.forEach((word: any, i: number) => {\n const start = i * step\n const width = interval\n let opacity = (normalizedProgress - start) / width\n opacity = Math.max(0, Math.min(1, opacity))\n gsap.set(word, { opacity })\n })\n },\n })\n }\n\n if (inView) {\n gsapResize()\n }\n\n return () => {\n splitTextInstance.current && splitTextInstance.current.revert()\n // ScrollTrigger.getAll().forEach((t: { kill: () => any }) => t.kill())\n scrollTriggerRef.current && scrollTriggerRef.current.kill()\n }\n }, [inView])\n\n return (\n (title || caption) && (\n <div className=\"mb-6 flex items-end justify-between overflow-hidden title-box\" ref={innerRef}>\n <div\n ref={inViewRef}\n className={cn('space-y-4 flex-1', className, {\n 'aiui-dark': theme === 'dark',\n 'text-center': align === 'center',\n 'text-right': align === 'right',\n 'text-left': align === 'left',\n })}\n >\n <Heading ref={titleRef} as={as} size={4} html={caption || title} />\n </div>\n {extensions?.textLink && (\n <a\n className={cn(\n { 'aiui-dark': theme === 'dark' },\n 'flex items-center text-base font-[700] leading-[1.4] text-[#777] transition-all duration-[0.4s] hover:text-[#1D1D1F]'\n )}\n href={trackUrlRef(extensions?.link, `${componentType}_${componentName}`)}\n data-headless-type-name={`${componentType}#${componentName}`}\n data-headless-title-desc-button={`${title}#${caption}`}\n >\n {extensions?.textLink}\n <svg\n width=\"24\"\n height=\"24\"\n className=\"mb-[3px]\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n >\n <path\n className=\"transition-all duration-[0.4s]\"\n d=\"M10.5 8L14.5 12L10.5 16\"\n stroke=\"#777\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n ></path>\n </svg>\n </a>\n )}\n </div>\n )\n )\n})\n\nTitle.displayName = 'Title'\n\nexport default withLayout(Title)\n"],
5
- "mappings": "ukBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,EAAAH,IA4FU,IAAAI,EAAA,6BA3FVC,EAA8D,oBAC9DC,EAAqB,gBACrBC,EAA0B,+BAC1BC,EAA8B,mCAC9BC,EAAmB,kCACnBC,EAAwB,qCACxBC,EAA2B,kCAE3BC,GAA4B,sCAC5BC,EAA4B,uCAC5BC,EAA0B,uCAE1B,MAAMC,EAAgB,OAChBC,EAAgB,QAEhBC,EAAQ,EAAAC,QAAM,WAAuC,CAAC,CAAE,KAAAC,EAAM,UAAAC,EAAW,GAAAC,EAAK,IAAK,EAAGC,IAAQ,CAClG,KAAM,CAAE,MAAAC,EAAO,QAAAC,EAAS,MAAAC,EAAO,WAAAC,EAAY,MAAAC,EAAQ,MAAO,EAAIR,EACxDS,KAAW,UAAuB,IAAI,EACtCC,KAAW,UAA2B,IAAI,EAC1CC,KAAoB,UAAyB,IAAI,EACjDC,KAAmB,UAA6B,IAAI,EAEpD,CAAE,IAAKC,EAAW,OAAAC,CAAO,KAAI,aAAU,EAE7C,gCAAoBX,EAAK,IAAMM,EAAS,OAAyB,KAEjE,aAAU,IAAM,CACd,OAAK,eAAe,YAAW,eAAa,EAC5C,SAASM,GAAa,CACpB,GAAI,CAACL,EAAS,QAAS,OACvB,MAAMM,EAASN,EAAS,SAAS,cAAgB,GAC7CC,EAAkB,SACpBA,EAAkB,QAAQ,OA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,EAAU,GAAIR,EAAI,KAAM,EAAG,KAAMG,GAAWD,EAAO,EACnE,EACCG,GAAY,aACX,QAAC,KACC,aAAW,MACT,CAAE,YAAaD,IAAU,MAAO,EAChC,sHACF,EACA,QAAM,eAAYC,GAAY,KAAM,GAAGX,CAAa,IAAIC,CAAa,EAAE,EACvE,0BAAyB,GAAGD,CAAa,IAAIC,CAAa,GAC1D,kCAAiC,GAAGO,CAAK,IAAIC,CAAO,GAEnD,UAAAE,GAAY,YACb,OAAC,OACC,MAAM,KACN,OAAO,KACP,UAAU,WACV,MAAM,6BACN,QAAQ,YACR,KAAK,OAEL,mBAAC,QACC,UAAU,iCACV,EAAE,0BACF,OAAO,OACP,eAAa,MACb,iBAAe,QAChB,EACH,GACF,GAEJ,CAGN,CAAC,EAEDT,EAAM,YAAc,QAEpB,IAAOf,MAAQ,cAAWe,CAAK",
4
+ "sourcesContent": ["'use client'\nimport React, { useEffect, useRef, useImperativeHandle } from 'react'\nimport { gsap } from 'gsap'\nimport { SplitText } from 'gsap/dist/SplitText'\nimport { ScrollTrigger } from 'gsap/dist/ScrollTrigger'\nimport { cn } from '../../helpers/utils.js'\nimport { Heading } from '../../components/index.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport type { TitleProps } from './types.js'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { trackUrlRef } from '../../shared/trackUrlRef.js'\nimport { useInView } from 'react-intersection-observer'\n\nconst componentType = 'link'\nconst componentName = 'title'\n\nconst Title = React.forwardRef<HTMLDivElement, TitleProps>(({ data, className, as = 'h2' }, ref) => {\n const { title, caption, theme, extensions, align = 'left' } = data\n const innerRef = useRef<HTMLDivElement>(null)\n const titleRef = useRef<HTMLHeadingElement>(null)\n const splitTextInstance = useRef<SplitText | null>(null)\n const scrollTriggerRef = useRef<ScrollTrigger | null>(null)\n\n const { ref: inViewRef, inView } = useInView()\n\n useImperativeHandle(ref, () => innerRef.current as HTMLDivElement)\n\n useEffect(() => {\n gsap.registerPlugin(SplitText, ScrollTrigger)\n function gsapResize() {\n if (!titleRef.current) return\n const height = titleRef.current?.clientHeight || 80\n if (splitTextInstance.current) {\n splitTextInstance.current.revert()\n }\n if (scrollTriggerRef.current) {\n scrollTriggerRef.current.kill()\n }\n splitTextInstance.current = new SplitText(titleRef.current, {\n type: 'words',\n wordsClass: 'word',\n })\n const words = splitTextInstance.current.words\n gsap.set(words, { opacity: 0 })\n scrollTriggerRef.current = ScrollTrigger.create({\n trigger: titleRef.current,\n start: 'bottom bottom-=4%',\n end: `bottom+=${height * 1.5 + 60}px bottom-=4%`,\n scrub: true,\n invalidateOnRefresh: true,\n onUpdate: (self: any) => {\n const progress = self.progress\n const total = words.length || 1\n const overlap = 0.5\n const interval = 1 / total\n const step = interval * (1 - overlap)\n const lastEnd = (total - 1) * step + interval\n const normalizedProgress = Math.min(1, lastEnd > 0 ? progress / lastEnd : 0)\n words.forEach((word: any, i: number) => {\n const start = i * step\n const width = interval\n let opacity = (normalizedProgress - start) / width\n opacity = Math.max(0, Math.min(1, opacity))\n gsap.set(word, { opacity })\n })\n },\n })\n }\n\n if (inView) {\n gsapResize()\n }\n\n return () => {\n splitTextInstance.current && splitTextInstance.current.revert()\n // ScrollTrigger.getAll().forEach((t: { kill: () => any }) => t.kill())\n scrollTriggerRef.current && scrollTriggerRef.current.kill()\n }\n }, [inView])\n\n return (\n (title || caption) && (\n <div id={extensions?.id} className=\"mb-6 flex items-end justify-between overflow-hidden title-box\" ref={innerRef}>\n <div\n ref={inViewRef}\n className={cn('space-y-4 flex-1', className, {\n 'aiui-dark': theme === 'dark',\n 'text-center': align === 'center',\n 'text-right': align === 'right',\n 'text-left': align === 'left',\n })}\n >\n <Heading ref={titleRef} as={as} size={4} html={caption || title} />\n </div>\n {extensions?.textLink && (\n <a\n className={cn(\n { 'aiui-dark': theme === 'dark' },\n 'flex items-center text-base font-[700] leading-[1.4] text-[#777] transition-all duration-[0.4s] hover:text-[#1D1D1F]'\n )}\n href={trackUrlRef(extensions?.link, `${componentType}_${componentName}`)}\n data-headless-type-name={`${componentType}#${componentName}`}\n data-headless-title-desc-button={`${title}#${caption}`}\n >\n {extensions?.textLink}\n <svg\n width=\"24\"\n height=\"24\"\n className=\"mb-[3px]\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n >\n <path\n className=\"transition-all duration-[0.4s]\"\n d=\"M10.5 8L14.5 12L10.5 16\"\n stroke=\"#777\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n ></path>\n </svg>\n </a>\n )}\n </div>\n )\n )\n})\n\nTitle.displayName = 'Title'\n\nexport default withLayout(Title)\n"],
5
+ "mappings": "ukBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,EAAAH,IA4FU,IAAAI,EAAA,6BA3FVC,EAA8D,oBAC9DC,EAAqB,gBACrBC,EAA0B,+BAC1BC,EAA8B,mCAC9BC,EAAmB,kCACnBC,EAAwB,qCACxBC,EAA2B,kCAE3BC,GAA4B,sCAC5BC,EAA4B,uCAC5BC,EAA0B,uCAE1B,MAAMC,EAAgB,OAChBC,EAAgB,QAEhBC,EAAQ,EAAAC,QAAM,WAAuC,CAAC,CAAE,KAAAC,EAAM,UAAAC,EAAW,GAAAC,EAAK,IAAK,EAAGC,IAAQ,CAClG,KAAM,CAAE,MAAAC,EAAO,QAAAC,EAAS,MAAAC,EAAO,WAAAC,EAAY,MAAAC,EAAQ,MAAO,EAAIR,EACxDS,KAAW,UAAuB,IAAI,EACtCC,KAAW,UAA2B,IAAI,EAC1CC,KAAoB,UAAyB,IAAI,EACjDC,KAAmB,UAA6B,IAAI,EAEpD,CAAE,IAAKC,EAAW,OAAAC,CAAO,KAAI,aAAU,EAE7C,gCAAoBX,EAAK,IAAMM,EAAS,OAAyB,KAEjE,aAAU,IAAM,CACd,OAAK,eAAe,YAAW,eAAa,EAC5C,SAASM,GAAa,CACpB,GAAI,CAACL,EAAS,QAAS,OACvB,MAAMM,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E,IAAU,SACzB,aAAcA,IAAU,QACxB,YAAaA,IAAU,MACzB,CAAC,EAED,mBAAC,WAAQ,IAAKE,EAAU,GAAIR,EAAI,KAAM,EAAG,KAAMG,GAAWD,EAAO,EACnE,EACCG,GAAY,aACX,QAAC,KACC,aAAW,MACT,CAAE,YAAaD,IAAU,MAAO,EAChC,sHACF,EACA,QAAM,eAAYC,GAAY,KAAM,GAAGX,CAAa,IAAIC,CAAa,EAAE,EACvE,0BAAyB,GAAGD,CAAa,IAAIC,CAAa,GAC1D,kCAAiC,GAAGO,CAAK,IAAIC,CAAO,GAEnD,UAAAE,GAAY,YACb,OAAC,OACC,MAAM,KACN,OAAO,KACP,UAAU,WACV,MAAM,6BACN,QAAQ,YACR,KAAK,OAEL,mBAAC,QACC,UAAU,iCACV,EAAE,0BACF,OAAO,OACP,eAAa,MACb,iBAAe,QAChB,EACH,GACF,GAEJ,CAGN,CAAC,EAEDT,EAAM,YAAc,QAEpB,IAAOf,MAAQ,cAAWe,CAAK",
6
6
  "names": ["Title_exports", "__export", "Title_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_gsap", "import_SplitText", "import_ScrollTrigger", "import_utils", "import_components", "import_Styles", "import_useExposure", "import_trackUrlRef", "import_react_intersection_observer", "componentType", "componentName", "Title", "React", "data", "className", "as", "ref", "title", "caption", "theme", "extensions", "align", "innerRef", "titleRef", "splitTextInstance", "scrollTriggerRef", "inViewRef", "inView", "gsapResize", "height", "words", "self", "progress", "total", "overlap", "interval", "step", "lastEnd", "normalizedProgress", "word", "i", "start", "width", "opacity"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as a}from"react/jsx-runtime";import{Text as i,Button as C,Grid as K,GridItem as S,Picture as P,Heading as Q}from"../../../../../components";import{useBizProductContext as O}from"../../../BizProductProvider";import{useEffect as U,useMemo as X,useState as Y}from"react";import{formatPrice as f}from"../../../utils";import{useAiuiContext as B}from"../../../../AiuiProvider";import"../../../../../helpers";import V from"decimal.js";import{replaceTemplate as Z}from"../../../utils/textFormat";const _=()=>{const{locale:d="us",copyWriting:t}=B(),{product:s,variant:l,finalPrice:u,comparePrice:m,coupon:h,selectedOptions:p,selectedVariants:c,totalSavings:N,onAddToCart:D,onBuyNow:z,savingDetail:g,checkedBundle:E,joinedRecommendBuyProducts:n,setJoinedRecommendBuyProducts:v,setCheckedGift:w,setCheckedExchangePurchase:x,setCheckedBundle:k,setSavingDetail:$,addToCartLoading:J,buyNowLoading:H,profile:F}=O(),[y]=c,M=X(()=>{const r=E?.variants.find(q=>q.variant.sku===y?.sku),W=new V(y?.price?.amount||0).minus(r?.price||y?.price?.amount).toNumber();let A=new V(y?.price?.amount||0);return F?.email&&(A=A.minus(g?.member||0)),A.minus(g?.coupon).minus(W).toNumber()},[y,E,F,g?.member,g?.coupon]);if(!l.availableForSale)return null;const{bundleVariant:j,giftVariant:G,exchangeVariant:L}=ee()||{},[o,b]=Y();return U(()=>{b({bundle:n.bundle?.value?void 0:j,gift:n.gift?.value?void 0:G,exchange:n.exchange?.value?void 0:L})},[j,G,L,n]),e("div",{className:"ipc-product-summary laptop:px-16 desktop:px-0 mt-16 desktop:mt-[96px] lg-desktop:mt-[128px]",children:e("div",{className:"bg-[#F5F5F7] laptop:rounded-2xl",children:a(K,{className:"px-4 pt-6 tablet:p-8 tablet:!pb-0",children:[a(S,{className:"col-span-12 laptop:col-start-1 laptop:col-span-5 gap-4 flex flex-col justify-between",children:[e(Q,{className:"font-bold text-[24px] lg-desktop:text-[48px] laptop:text-[32px] desktop:text-[40px] leading-[1] mb-4 [&>span]:text-[#D1D1D1]",html:`${s.title} is ready <br/><span>Just the way you want it.</span>`}),e("div",{className:"",children:e(P,{source:l.image?.url||s?.images?.[0]?.url,className:"lg-desktop:aspect-[644/368] desktop:aspect-[503/272] laptop:aspect-[331/191] tablet:aspect-[704/380] aspect-[358/192]",imgClassName:"object-cover h-full"})})]}),a(S,{className:"col-span-12 mt-8 pb-6 tablet:pb-8 laptop:col-start-7 laptop:mt-0 laptop:col-span-6 flex flex-col gap-6 justify-between",children:[a("div",{children:[a("div",{className:"flex flex-col gap-4",children:[a("div",{className:"flex items-center justify-between",children:[a("div",{className:"shrink-0 flex items-center gap-4",children:[e(P,{source:l.image?.url||s?.images?.[0]?.url,className:"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg"}),a("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[e(i,{className:"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]",html:s.title}),e(i,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]",html:`x1 | ${p.color||p.colour||p.couleur}`})]})]}),a("div",{className:"flex items-center gap-1",children:[e(i,{className:"text-base desktop:text-2xl font-bold",html:f({amount:M,currencyCode:l.price.currencyCode,locale:d})}),N>0&&e(i,{className:"text-base desktop:text-2xl laptop:text-xl font-bold line-through text-[#6D6D6F]",html:f({amount:l?.price?.amount,currencyCode:l.price.currencyCode,locale:d})})]})]}),n?.gift?.value&&e(I,{giftOperation:r=>{w?.(void 0),v?.({...n,gift:{value:void 0,canOperate:!0}}),b?.({...o,gift:r})},status:!!n?.gift,gift:n?.gift?.value,canOperate:n?.gift?.canOperate}),n?.bundle?.value&&e(R,{bundleOperation:r=>{k?.(void 0),v?.({...n,bundle:{value:void 0,canOperate:!0}}),b?.({...o,bundle:r})},status:!!n?.bundle,bundleListItem:n?.bundle?.value,canOperate:n?.bundle?.canOperate}),n?.exchange?.value&&e(T,{exchangeOperation:r=>{x?.(void 0),v?.({...n,exchange:{value:void 0,canOperate:!0}}),b?.({...o,exchange:r})},status:!!n?.exchange,canOperate:n?.exchange?.canOperate,exchange:n?.exchange?.value})]}),(o?.bundle||o?.gift||o?.exchange)&&a("div",{className:"mt-6",children:[e(i,{className:"text-sm desktop:text-[18px] font-bold",html:"Recommend Buy"}),a("div",{className:"flex flex-col gap-6 mt-6",children:[o?.exchange&&e(T,{exchangeOperation:r=>{k?.(void 0),v?.({bundle:{value:void 0,canOperate:!0},gift:{value:n?.gift?.value,canOperate:!0},exchange:{value:r,canOperate:!0}}),b?.({...o,exchange:void 0})},canOperate:n?.exchange?.canOperate,status:!o?.exchange,exchange:o?.exchange}),o?.bundle&&e(R,{bundleOperation:r=>{w?.(void 0),x?.(void 0),$?.({...g,exchangePurchase:0}),v?.({gift:{value:void 0,canOperate:!0},exchange:{value:void 0,canOperate:!0},bundle:{value:r,canOperate:!0}}),b?.({...o,bundle:void 0})},canOperate:n?.bundle?.canOperate,status:!o?.bundle,bundleListItem:o?.bundle}),o?.gift&&e(I,{giftOperation:r=>{k?.(void 0),v?.({bundle:{value:void 0,canOperate:!0},exchange:{value:n?.exchange?.value,canOperate:!0},gift:{value:r,canOperate:!0}}),b?.({...o,gift:void 0})},canOperate:n?.gift?.canOperate,status:!o?.gift,gift:o?.gift})]})]})]}),a("div",{className:"text-right",children:[e(i,{className:"laptop:text-xl desktop:text-2xl font-bold text-right",html:`${Z(t?.totalPrice||"",{amount:f({amount:u,currencyCode:l.price.currencyCode,locale:d})})}`}),N>0&&e(i,{className:"text-base laptop:text-xl desktop:text-2xl ml-1 font-bold line-through text-[#6D6D6F]",html:f({amount:m,currencyCode:l.price.currencyCode,locale:d})}),a("div",{className:"flex gap-3 mt-2 justify-end",children:[e(C,{size:"lg",variant:"secondary",loading:J,className:"w-1/2 tablet:w-auto laptop:w-1/2 desktop:w-auto",onClick:()=>D?.(),children:t?.addToCart}),e(C,{size:"lg",loading:H,variant:"primary",className:"w-1/2 tablet:w-auto laptop:w-1/2 desktop:w-auto",onClick:()=>z?.(),children:t?.shopNow})]})]})]})]})})})},ee=()=>{const{bundle:d,variant:t,checkedBundle:s,freeGift:l,checkedGift:u,exchangePurchase:m,checkedExchangePurchase:h}=O();let p,c,N;const{bundleList:D}=d||{},{giftList:z=[]}=l||{},{giftList:g=[]}=m||{},E=D?.filter(x=>x.variants.slice(1,x.variants.length).every(k=>k.variant.availableForSale))||[],[n]=E;p=s||n;const[v]=z?.filter(x=>x.availableForSale);c=u||v;const[w]=g?.filter(x=>x.availableForSale);return N=h||w,{bundleVariant:p,giftVariant:c,exchangeVariant:N}},R=({bundleOperation:d,bundleListItem:t,canOperate:s,status:l})=>{const{locale:u="us"}=B(),{variant:m,setCheckedBundle:h}=O(),p=t?.variants.filter(c=>c.variant.sku!==m.sku);return e("div",{className:"",children:p?.map(c=>a("div",{className:"flex items-center gap-4 justify-between",children:[a("div",{className:"flex items-center gap-4",children:[e(P,{source:c?.variant?.image?.url,className:"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg"}),e("div",{className:"flex flex-col gap-[6px] line-clamp-2 max-w-[178px] tablet:max-w-none",children:e(i,{className:"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]",html:c.variant.product.title})})]}),a("div",{className:"flex flex-col items-end gap-1 justify-center",children:[!!t&&a("div",{className:"flex items-center gap-1",children:[e(i,{className:"text-base desktop:text-2xl font-bold",html:f({amount:c?.price||0,locale:u,currencyCode:c.variant?.price?.currencyCode||""})}),e(i,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:f({amount:c.variant.price.amount||0,locale:u,currencyCode:c.variant?.price?.currencyCode||""})})]}),s&&e(C,{size:"icon",variant:"link",onClick:()=>{h?.(l?void 0:t),d?.(t)},className:"shrink-0 size-auto underline",children:l?"Remove":"Add"})]})]},c.variant.id))})},I=({giftOperation:d,gift:t,status:s,canOperate:l})=>{const{locale:u="us"}=B(),{freeGift:m,setCheckedGift:h}=O(),{freeLabel:p,count:c}=m||{};return a("div",{className:"flex items-center justify-between",children:[a("div",{className:"flex items-center gap-4",children:[e(P,{source:t?.image?.url,className:"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg"}),a("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[e(i,{className:"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]",html:t?.product?.title}),e(i,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]",html:`x${c} | ${p}`})]})]}),a("div",{className:"flex flex-col items-end gap-2 justify-center",children:[!!t&&a("div",{className:"flex items-center gap-1",children:[e(i,{className:"text-base desktop:text-2xl font-bold",html:p}),e(i,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:f({amount:t.price.amount,locale:u,currencyCode:t.price.currencyCode})})]}),l&&e(C,{size:"icon",variant:"link",onClick:()=>{h?.(s?void 0:t),d(t)},className:"shrink-0 size-auto underline",children:s?"Remove":"Add"})]})]})},T=({exchangeOperation:d,exchange:t,canOperate:s,status:l})=>{const{locale:u="us"}=B(),{setCheckedExchangePurchase:m}=O();return a("div",{className:"flex items-center justify-between",children:[a("div",{className:"flex items-center gap-4",children:[e(P,{source:t?.image?.url,className:"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg"}),a("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[e(i,{className:"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]",html:t?.product?.title}),e(i,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]"})]})]}),a("div",{className:"flex flex-col items-end gap-2 justify-center",children:[!!t&&a("div",{className:"flex items-center gap-1",children:[e(i,{className:"text-base desktop:text-2xl font-bold",html:f({amount:t.finalPrice?.amount||0,locale:u,currencyCode:t.price.currencyCode})}),e(i,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:f({amount:t.price?.amount||0,locale:u,currencyCode:t.price.currencyCode})})]}),s&&e(C,{size:"icon",variant:"link",onClick:()=>{m?.(l?void 0:t),d(t)},className:"shrink-0 size-auto underline",children:l?"Remove":"Add"})]})]})};var pe=_;export{pe as default};
1
+ import{jsx as e,jsxs as a}from"react/jsx-runtime";import{Text as c,Button as C,Grid as K,GridItem as S,Picture as P,Heading as Q}from"../../../../../components";import{useBizProductContext as O}from"../../../BizProductProvider";import{useEffect as U,useMemo as X,useState as Y}from"react";import{formatPrice as f}from"../../../utils";import{useAiuiContext as B}from"../../../../AiuiProvider";import"../../../../../helpers";import R from"decimal.js";import{replaceTemplate as Z}from"../../../utils/textFormat";const _=()=>{const{locale:d="us",copyWriting:t}=B(),{product:s,variant:l,finalPrice:u,comparePrice:m,coupon:h,selectedOptions:p,selectedVariants:o,totalSavings:N,onAddToCart:D,onBuyNow:z,savingDetail:g,checkedBundle:E,joinedRecommendBuyProducts:n,setJoinedRecommendBuyProducts:v,setCheckedGift:w,setCheckedExchangePurchase:x,setCheckedBundle:k,setSavingDetail:$,addToCartLoading:J,buyNowLoading:H,profile:F}=O(),[y]=o,M=X(()=>{const r=E?.variants.find(q=>q.variant.sku===y?.sku),W=new R(y?.price?.amount||0).minus(r?.price||y?.price?.amount).toNumber();let A=new R(y?.price?.amount||0);return F?.email&&(A=A.minus(g?.member||0)),A.minus(g?.coupon).minus(W).toNumber()},[y,E,F,g?.member,g?.coupon]);if(!l.availableForSale)return null;const{bundleVariant:j,giftVariant:G,exchangeVariant:L}=ee()||{},[i,b]=Y();return U(()=>{b({bundle:n.bundle?.value?void 0:j,gift:n.gift?.value?void 0:G,exchange:n.exchange?.value?void 0:L})},[j,G,L,n]),e("div",{className:"ipc-product-summary laptop:px-16 desktop:px-0 mt-16 desktop:mt-[96px] lg-desktop:mt-[128px]",children:e("div",{className:"bg-[#F5F5F7] laptop:rounded-2xl",children:a(K,{className:"px-4 pt-6 tablet:p-8 tablet:!pb-0",children:[a(S,{className:"col-span-12 laptop:col-start-1 laptop:col-span-5 gap-4 flex flex-col justify-between",children:[e(Q,{className:"font-bold text-[24px] lg-desktop:text-[48px] laptop:text-[32px] desktop:text-[40px] leading-[1] mb-4 [&>span]:text-[#D1D1D1]",html:`${s.title} is ready <br/><span>Just the way you want it.</span>`}),e("div",{className:"",children:e(P,{source:l.image?.url||s?.images?.[0]?.url,className:"lg-desktop:aspect-[644/368] desktop:aspect-[503/272] laptop:aspect-[331/191] tablet:aspect-[704/380] aspect-[358/192]",imgClassName:"object-cover h-full"})})]}),a(S,{className:"col-span-12 mt-8 pb-6 tablet:pb-8 laptop:col-start-7 laptop:mt-0 laptop:col-span-6 flex flex-col gap-6 justify-between",children:[a("div",{children:[a("div",{className:"flex flex-col gap-4",children:[a("div",{className:"flex items-center justify-between",children:[a("div",{className:"shrink-0 flex items-center gap-4",children:[e(P,{source:l.image?.url||s?.images?.[0]?.url,className:"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg"}),a("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[e(c,{className:"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]",html:s.title}),e(c,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]",html:`x1 | ${p.color||p.colour||p.couleur}`})]})]}),a("div",{className:"flex items-center gap-1",children:[e(c,{className:"text-base desktop:text-2xl font-bold",html:f({amount:M,currencyCode:l.price.currencyCode,locale:d})}),N>0&&e(c,{className:"text-base desktop:text-2xl laptop:text-xl font-bold line-through text-[#6D6D6F]",html:f({amount:l?.price?.amount,currencyCode:l.price.currencyCode,locale:d})})]})]}),n?.gift?.value&&e(I,{giftOperation:r=>{w?.(void 0),v?.({...n,gift:{value:void 0,canOperate:!0}}),b?.({...i,gift:r})},status:!!n?.gift,gift:n?.gift?.value,canOperate:n?.gift?.canOperate}),n?.bundle?.value&&e(V,{bundleOperation:r=>{k?.(void 0),v?.({...n,bundle:{value:void 0,canOperate:!0}}),b?.({...i,bundle:r})},status:!!n?.bundle,bundleListItem:n?.bundle?.value,canOperate:n?.bundle?.canOperate}),n?.exchange?.value&&e(T,{exchangeOperation:r=>{x?.(void 0),v?.({...n,exchange:{value:void 0,canOperate:!0}}),b?.({...i,exchange:r})},status:!!n?.exchange,canOperate:n?.exchange?.canOperate,exchange:n?.exchange?.value})]}),(i?.bundle||i?.gift||i?.exchange)&&a("div",{className:"mt-6",children:[e(c,{className:"text-sm desktop:text-[18px] font-bold",html:"Recommend Buy"}),a("div",{className:"flex flex-col gap-6 mt-6",children:[i?.exchange&&e(T,{exchangeOperation:r=>{k?.(void 0),v?.({bundle:{value:void 0,canOperate:!0},gift:{value:n?.gift?.value,canOperate:!0},exchange:{value:r,canOperate:!0}}),b?.({...i,exchange:void 0})},canOperate:n?.exchange?.canOperate,status:!i?.exchange,exchange:i?.exchange}),i?.bundle&&e(V,{bundleOperation:r=>{w?.(void 0),x?.(void 0),$?.({...g,exchangePurchase:0}),v?.({gift:{value:void 0,canOperate:!0},exchange:{value:void 0,canOperate:!0},bundle:{value:r,canOperate:!0}}),b?.({...i,bundle:void 0})},canOperate:n?.bundle?.canOperate,status:!i?.bundle,bundleListItem:i?.bundle}),i?.gift&&e(I,{giftOperation:r=>{k?.(void 0),v?.({bundle:{value:void 0,canOperate:!0},exchange:{value:n?.exchange?.value,canOperate:!0},gift:{value:r,canOperate:!0}}),b?.({...i,gift:void 0})},canOperate:n?.gift?.canOperate,status:!i?.gift,gift:i?.gift})]})]})]}),a("div",{className:"text-right",children:[e(c,{className:"laptop:text-xl desktop:text-2xl font-bold text-right",html:`${Z(t?.totalPrice||"",{amount:f({amount:u,currencyCode:l.price.currencyCode,locale:d})})}`}),N>0&&e(c,{className:"text-base laptop:text-xl desktop:text-2xl ml-1 font-bold line-through text-[#6D6D6F]",html:f({amount:m,currencyCode:l.price.currencyCode,locale:d})}),a("div",{className:"flex gap-3 mt-2 justify-end",children:[e(C,{size:"lg",variant:"secondary",loading:J,className:"w-1/2 tablet:w-auto laptop:w-1/2 desktop:w-auto",onClick:()=>D?.(),children:t?.addToCart}),e(C,{size:"lg",loading:H,variant:"primary",className:"w-1/2 tablet:w-auto laptop:w-1/2 desktop:w-auto",onClick:()=>z?.(),children:t?.shopNow})]})]})]})]})})})},ee=()=>{const{bundle:d,variant:t,checkedBundle:s,freeGift:l,checkedGift:u,exchangePurchase:m,checkedExchangePurchase:h}=O();let p,o,N;const{bundleList:D}=d||{},{giftList:z=[]}=l||{},{giftList:g=[]}=m||{},E=D?.filter(x=>x.variants.slice(1,x.variants.length).every(k=>k.variant.availableForSale))||[],[n]=E;p=s||n;const[v]=z?.filter(x=>x.availableForSale);o=u||v;const[w]=g?.filter(x=>x.availableForSale);return N=h||w,{bundleVariant:p,giftVariant:o,exchangeVariant:N}},V=({bundleOperation:d,bundleListItem:t,canOperate:s,status:l})=>{const{locale:u="us"}=B(),{variant:m,setCheckedBundle:h}=O(),p=t?.variants.filter(o=>o.variant.sku!==m.sku);return e("div",{className:"",children:p?.map(o=>a("div",{className:"flex items-center gap-4 justify-between",children:[a("div",{className:"flex items-center gap-4",children:[e(P,{source:o?.variant?.image?.url,className:"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg"}),e("div",{className:"flex flex-col gap-[6px] line-clamp-2 max-w-[178px] tablet:max-w-none",children:e(c,{className:"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]",html:o.variant.product.title})})]}),a("div",{className:"flex flex-col items-end gap-1 justify-center",children:[!!t&&a("div",{className:"flex items-center gap-1",children:[e(c,{className:"text-base desktop:text-2xl font-bold",html:f({amount:o?.price||0,locale:u,currencyCode:o.variant?.price?.currencyCode||""})}),o.price<o.variant.price.amount&&e(c,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:f({amount:o.variant.price.amount||0,locale:u,currencyCode:o.variant?.price?.currencyCode||""})})]}),s&&e(C,{size:"icon",variant:"link",onClick:()=>{h?.(l?void 0:t),d?.(t)},className:"shrink-0 size-auto underline",children:l?"Remove":"Add"})]})]},o.variant.id))})},I=({giftOperation:d,gift:t,status:s,canOperate:l})=>{const{locale:u="us"}=B(),{freeGift:m,setCheckedGift:h}=O(),{freeLabel:p,count:o}=m||{};return a("div",{className:"flex items-center justify-between",children:[a("div",{className:"flex items-center gap-4",children:[e(P,{source:t?.image?.url,className:"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg"}),a("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[e(c,{className:"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]",html:t?.product?.title}),e(c,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]",html:`x${o} | ${p}`})]})]}),a("div",{className:"flex flex-col items-end gap-2 justify-center",children:[!!t&&a("div",{className:"flex items-center gap-1",children:[e(c,{className:"text-base desktop:text-2xl font-bold",html:p}),e(c,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:f({amount:t.price.amount,locale:u,currencyCode:t.price.currencyCode})})]}),l&&e(C,{size:"icon",variant:"link",onClick:()=>{h?.(s?void 0:t),d(t)},className:"shrink-0 size-auto underline",children:s?"Remove":"Add"})]})]})},T=({exchangeOperation:d,exchange:t,canOperate:s,status:l})=>{const{locale:u="us"}=B(),{setCheckedExchangePurchase:m}=O();return a("div",{className:"flex items-center justify-between",children:[a("div",{className:"flex items-center gap-4",children:[e(P,{source:t?.image?.url,className:"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg"}),a("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[e(c,{className:"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]",html:t?.product?.title}),e(c,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]"})]})]}),a("div",{className:"flex flex-col items-end gap-2 justify-center",children:[!!t&&a("div",{className:"flex items-center gap-1",children:[e(c,{className:"text-base desktop:text-2xl font-bold",html:f({amount:t.finalPrice?.amount||0,locale:u,currencyCode:t.price.currencyCode})}),e(c,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:f({amount:t.price?.amount||0,locale:u,currencyCode:t.price.currencyCode})})]}),s&&e(C,{size:"icon",variant:"link",onClick:()=>{m?.(l?void 0:t),d(t)},className:"shrink-0 size-auto underline",children:l?"Remove":"Add"})]})]})};var pe=_;export{pe as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/biz-components/Listing/components/ProductCard/ProductSummary/index.tsx"],
4
- "sourcesContent": ["import { Text, Button, Container, Grid, GridItem, Picture, Heading } from '../../../../../components'\nimport { useBizProductContext } from '../../../BizProductProvider'\nimport { useEffect, useMemo, useState } from 'react'\nimport { formatPrice } from '../../../utils'\nimport { useAiuiContext } from '../../../../AiuiProvider'\nimport type { BundleListItem, ProductVariant, ProductPrice } from '../../../types/product'\nimport { cn } from '../../../../../helpers'\nimport Decimal from 'decimal.js'\nimport { replaceTemplate } from '../../../utils/textFormat'\n\nconst ProductSummary = () => {\n const { locale = 'us', copyWriting } = useAiuiContext()\n const {\n product,\n variant,\n finalPrice,\n comparePrice,\n coupon,\n selectedOptions,\n selectedVariants,\n totalSavings,\n onAddToCart,\n onBuyNow,\n savingDetail,\n checkedBundle,\n joinedRecommendBuyProducts,\n setJoinedRecommendBuyProducts,\n setCheckedGift,\n setCheckedExchangePurchase,\n setCheckedBundle,\n setSavingDetail,\n addToCartLoading,\n buyNowLoading,\n profile,\n } = useBizProductContext()\n\n const [currentProductVariant] = selectedVariants\n\n const summaryFinalPrice = useMemo(() => {\n const currentBundleVariant = checkedBundle?.variants.find(v => v.variant.sku === currentProductVariant?.sku)\n const currentBundlePrice = new Decimal(currentProductVariant?.price?.amount || 0)\n .minus(currentBundleVariant?.price || currentProductVariant?.price?.amount)\n .toNumber()\n let currentProductPrice = new Decimal(currentProductVariant?.price?.amount || 0)\n if (!!profile?.email) {\n currentProductPrice = currentProductPrice.minus(savingDetail?.member || 0)\n }\n return currentProductPrice.minus(savingDetail?.coupon).minus(currentBundlePrice).toNumber()\n }, [currentProductVariant, checkedBundle, profile, savingDetail?.member, savingDetail?.coupon])\n\n const isAvailable = variant.availableForSale\n if (!isAvailable) return null\n\n const { bundleVariant, giftVariant, exchangeVariant } = useRecommendBuyProducts() || {}\n const [initialRecommendBuyProducts, setInitialRecommendBuyProducts] = useState<{\n bundle?: BundleListItem\n gift?: ProductVariant\n exchange?: ProductVariant\n }>()\n\n useEffect(() => {\n setInitialRecommendBuyProducts({\n bundle: joinedRecommendBuyProducts.bundle?.value ? undefined : bundleVariant,\n gift: joinedRecommendBuyProducts.gift?.value ? undefined : giftVariant,\n exchange: joinedRecommendBuyProducts.exchange?.value ? undefined : exchangeVariant,\n })\n }, [bundleVariant, giftVariant, exchangeVariant, joinedRecommendBuyProducts])\n\n return (\n <div className=\"ipc-product-summary laptop:px-16 desktop:px-0 mt-16 desktop:mt-[96px] lg-desktop:mt-[128px]\">\n <div className=\"bg-[#F5F5F7] laptop:rounded-2xl\">\n <Grid className=\"px-4 pt-6 tablet:p-8 tablet:!pb-0\">\n <GridItem className=\"col-span-12 laptop:col-start-1 laptop:col-span-5 gap-4 flex flex-col justify-between\">\n <Heading\n className=\"font-bold text-[24px] lg-desktop:text-[48px] laptop:text-[32px] desktop:text-[40px] leading-[1] mb-4 [&>span]:text-[#D1D1D1]\"\n html={`${product.title} is ready <br/><span>Just the way you want it.</span>`}\n />\n <div className=\"\">\n <Picture\n source={variant.image?.url || product?.images?.[0]?.url}\n className=\"lg-desktop:aspect-[644/368] desktop:aspect-[503/272] laptop:aspect-[331/191] tablet:aspect-[704/380] aspect-[358/192]\"\n imgClassName=\"object-cover h-full\"\n />\n </div>\n </GridItem>\n <GridItem className=\"col-span-12 mt-8 pb-6 tablet:pb-8 laptop:col-start-7 laptop:mt-0 laptop:col-span-6 flex flex-col gap-6 justify-between\">\n <div>\n <div className=\"flex flex-col gap-4\">\n <div className=\"flex items-center justify-between\">\n <div className=\"shrink-0 flex items-center gap-4\">\n <Picture\n source={variant.image?.url || product?.images?.[0]?.url}\n className=\"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg\"\n />\n <div className=\"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none\">\n <Text\n className=\"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]\"\n html={product.title}\n />\n <Text\n className=\"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]\"\n html={`x1 | ${selectedOptions.color || selectedOptions.colour || selectedOptions.couleur}`}\n />\n </div>\n </div>\n <div className=\"flex items-center gap-1\">\n <Text\n className=\"text-base desktop:text-2xl font-bold\"\n html={formatPrice({\n amount: summaryFinalPrice,\n currencyCode: variant.price.currencyCode,\n locale,\n })}\n />\n {totalSavings > 0 && (\n <Text\n className=\"text-base desktop:text-2xl laptop:text-xl font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: variant?.price?.amount,\n currencyCode: variant.price.currencyCode,\n locale,\n })}\n />\n )}\n </div>\n </div>\n {joinedRecommendBuyProducts?.gift?.value && (\n <ProductGiftSummary\n giftOperation={gift => {\n setCheckedGift?.(undefined)\n setJoinedRecommendBuyProducts?.({\n ...joinedRecommendBuyProducts,\n gift: {\n value: undefined,\n canOperate: true,\n },\n })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, gift })\n }}\n status={!!joinedRecommendBuyProducts?.gift}\n gift={joinedRecommendBuyProducts?.gift?.value}\n canOperate={joinedRecommendBuyProducts?.gift?.canOperate}\n />\n )}\n {joinedRecommendBuyProducts?.bundle?.value && (\n <ProductBundleSummary\n bundleOperation={bundle => {\n setCheckedBundle?.(undefined)\n setJoinedRecommendBuyProducts?.({\n ...joinedRecommendBuyProducts,\n bundle: {\n value: undefined,\n canOperate: true,\n },\n })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, bundle })\n }}\n status={!!joinedRecommendBuyProducts?.bundle}\n bundleListItem={joinedRecommendBuyProducts?.bundle?.value}\n canOperate={joinedRecommendBuyProducts?.bundle?.canOperate}\n />\n )}\n {joinedRecommendBuyProducts?.exchange?.value && (\n <ProductExchangeSummary\n exchangeOperation={exchange => {\n setCheckedExchangePurchase?.(undefined)\n setJoinedRecommendBuyProducts?.({\n ...joinedRecommendBuyProducts,\n exchange: {\n value: undefined,\n canOperate: true,\n },\n })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, exchange })\n }}\n status={!!joinedRecommendBuyProducts?.exchange}\n canOperate={joinedRecommendBuyProducts?.exchange?.canOperate}\n exchange={joinedRecommendBuyProducts?.exchange?.value}\n />\n )}\n </div>\n {(initialRecommendBuyProducts?.bundle ||\n initialRecommendBuyProducts?.gift ||\n initialRecommendBuyProducts?.exchange) && (\n <div className=\"mt-6\">\n <Text className=\"text-sm desktop:text-[18px] font-bold\" html={'Recommend Buy'} />\n <div className=\"flex flex-col gap-6 mt-6\">\n {initialRecommendBuyProducts?.exchange && (\n <ProductExchangeSummary\n exchangeOperation={exchange => {\n setCheckedBundle?.(undefined)\n setJoinedRecommendBuyProducts?.({\n bundle: {\n value: undefined,\n canOperate: true,\n },\n gift: {\n value: joinedRecommendBuyProducts?.gift?.value,\n canOperate: true,\n },\n exchange: {\n value: exchange,\n canOperate: true,\n },\n })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, exchange: undefined })\n }}\n canOperate={joinedRecommendBuyProducts?.exchange?.canOperate}\n status={!initialRecommendBuyProducts?.exchange}\n exchange={initialRecommendBuyProducts?.exchange}\n />\n )}\n {initialRecommendBuyProducts?.bundle && (\n <ProductBundleSummary\n bundleOperation={bundle => {\n setCheckedGift?.(undefined)\n setCheckedExchangePurchase?.(undefined)\n setSavingDetail?.({ ...savingDetail, exchangePurchase: 0 })\n setJoinedRecommendBuyProducts?.({\n gift: {\n value: undefined,\n canOperate: true,\n },\n exchange: {\n value: undefined,\n canOperate: true,\n },\n bundle: {\n value: bundle,\n canOperate: true,\n },\n })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, bundle: undefined })\n }}\n canOperate={joinedRecommendBuyProducts?.bundle?.canOperate}\n status={!initialRecommendBuyProducts?.bundle}\n bundleListItem={initialRecommendBuyProducts?.bundle}\n />\n )}\n {initialRecommendBuyProducts?.gift && (\n <ProductGiftSummary\n giftOperation={gift => {\n setCheckedBundle?.(undefined)\n setJoinedRecommendBuyProducts?.({\n bundle: {\n value: undefined,\n canOperate: true,\n },\n exchange: {\n value: joinedRecommendBuyProducts?.exchange?.value,\n canOperate: true,\n },\n gift: {\n value: gift,\n canOperate: true,\n },\n })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, gift: undefined })\n }}\n canOperate={joinedRecommendBuyProducts?.gift?.canOperate}\n status={!initialRecommendBuyProducts?.gift}\n gift={initialRecommendBuyProducts?.gift}\n />\n )}\n </div>\n </div>\n )}\n </div>\n <div className=\"text-right\">\n <Text\n className=\"laptop:text-xl desktop:text-2xl font-bold text-right\"\n html={`${replaceTemplate(copyWriting?.totalPrice || '', { amount: formatPrice({ amount: finalPrice, currencyCode: variant.price.currencyCode, locale }) })}`}\n />\n\n {totalSavings > 0 && (\n <Text\n className=\"text-base laptop:text-xl desktop:text-2xl ml-1 font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: comparePrice,\n currencyCode: variant.price.currencyCode,\n locale,\n })}\n />\n )}\n <div className=\"flex gap-3 mt-2 justify-end\">\n <Button\n size=\"lg\"\n variant=\"secondary\"\n loading={addToCartLoading}\n className=\"w-1/2 tablet:w-auto laptop:w-1/2 desktop:w-auto\"\n onClick={() => onAddToCart?.()}\n >\n {copyWriting?.addToCart}\n </Button>\n <Button\n size=\"lg\"\n loading={buyNowLoading}\n variant=\"primary\"\n className=\"w-1/2 tablet:w-auto laptop:w-1/2 desktop:w-auto\"\n onClick={() => onBuyNow?.()}\n >\n {copyWriting?.shopNow}\n </Button>\n </div>\n </div>\n </GridItem>\n </Grid>\n </div>\n </div>\n )\n}\n\nconst useRecommendBuyProducts = () => {\n const { bundle, variant, checkedBundle, freeGift, checkedGift, exchangePurchase, checkedExchangePurchase } =\n useBizProductContext()\n let bundleVariant = undefined\n let giftVariant = undefined\n let exchangeVariant = undefined\n const { bundleList } = bundle || {}\n\n const { giftList = [] } = freeGift || {}\n const { giftList: exchangeList = [] } = exchangePurchase || {}\n\n const availableBundleList =\n bundleList?.filter(bundle =>\n bundle.variants.slice(1, bundle.variants.length).every(v => v.variant.availableForSale)\n ) || []\n\n const [firstAvailableBundle] = availableBundleList\n bundleVariant = checkedBundle || firstAvailableBundle\n\n const [firstAvailableGift] = giftList?.filter(gift => gift.availableForSale)\n giftVariant = checkedGift || firstAvailableGift\n\n const [firstAvailableExchange] = exchangeList?.filter(exchange => exchange.availableForSale)\n exchangeVariant = checkedExchangePurchase || firstAvailableExchange\n\n return { bundleVariant, giftVariant, exchangeVariant }\n}\n\nconst ProductBundleSummary = ({\n bundleOperation,\n bundleListItem,\n canOperate,\n status,\n}: {\n bundleOperation: (bundle?: BundleListItem) => void\n bundleListItem?: BundleListItem\n canOperate?: boolean\n status?: boolean\n}) => {\n const { locale = 'us' } = useAiuiContext()\n const { variant, setCheckedBundle } = useBizProductContext()\n const bundleVariants = bundleListItem?.variants.filter(v => v.variant.sku !== variant.sku)\n\n return (\n <div className=\"\">\n {bundleVariants?.map(bundleVariant => {\n return (\n <div className=\"flex items-center gap-4 justify-between\" key={bundleVariant.variant.id}>\n <div className=\"flex items-center gap-4\">\n <Picture\n source={bundleVariant?.variant?.image?.url}\n className=\"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg\"\n />\n <div className=\"flex flex-col gap-[6px] line-clamp-2 max-w-[178px] tablet:max-w-none\">\n <Text\n className=\"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]\"\n html={bundleVariant.variant.product.title}\n />\n </div>\n </div>\n <div className=\"flex flex-col items-end gap-1 justify-center\">\n {!!bundleListItem && (\n <div className=\"flex items-center gap-1\">\n <Text\n className=\"text-base desktop:text-2xl font-bold\"\n html={formatPrice({\n amount: bundleVariant?.price || 0,\n locale,\n currencyCode: bundleVariant.variant?.price?.currencyCode || '',\n })}\n />\n <Text\n className=\"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: bundleVariant.variant.price.amount || 0,\n locale,\n currencyCode: bundleVariant.variant?.price?.currencyCode || '',\n })}\n />\n </div>\n )}\n {canOperate && (\n <Button\n size=\"icon\"\n variant=\"link\"\n onClick={() => {\n setCheckedBundle?.(status ? undefined : bundleListItem)\n bundleOperation?.(bundleListItem)\n }}\n className=\"shrink-0 size-auto underline\"\n >\n {!!status ? 'Remove' : 'Add'}\n </Button>\n )}\n </div>\n </div>\n )\n })}\n </div>\n )\n}\n\nconst ProductGiftSummary = ({\n giftOperation,\n gift,\n status,\n canOperate,\n}: {\n giftOperation: (gift?: ProductVariant) => void\n gift?: ProductVariant\n status?: boolean\n canOperate?: boolean\n}) => {\n const { locale = 'us' } = useAiuiContext()\n const { freeGift, setCheckedGift } = useBizProductContext()\n const { freeLabel, count } = freeGift || {}\n\n return (\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center gap-4\">\n <Picture\n source={gift?.image?.url}\n className=\"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg\"\n />\n <div className=\"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none\">\n <Text\n className=\"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]\"\n html={gift?.product?.title}\n />\n <Text\n className=\"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]\"\n html={`x${count} | ${freeLabel}`}\n />\n </div>\n </div>\n <div className=\"flex flex-col items-end gap-2 justify-center\">\n {!!gift && (\n <div className=\"flex items-center gap-1\">\n <Text className=\"text-base desktop:text-2xl font-bold\" html={freeLabel} />\n <Text\n className=\"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: gift.price.amount,\n locale,\n currencyCode: gift.price.currencyCode,\n })}\n />\n </div>\n )}\n {canOperate && (\n <Button\n size=\"icon\"\n variant=\"link\"\n onClick={() => {\n setCheckedGift?.(status ? undefined : gift)\n giftOperation(gift)\n }}\n className=\"shrink-0 size-auto underline\"\n >\n {status ? 'Remove' : 'Add'}\n </Button>\n )}\n </div>\n </div>\n )\n}\n\nconst ProductExchangeSummary = ({\n exchangeOperation,\n exchange,\n canOperate,\n status,\n}: {\n exchangeOperation: (exchange?: ProductVariant) => void\n exchange?: ProductVariant & { finalPrice?: ProductPrice }\n canOperate?: boolean\n status?: boolean\n}) => {\n const { locale = 'us' } = useAiuiContext()\n const { setCheckedExchangePurchase } = useBizProductContext()\n\n return (\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center gap-4\">\n <Picture\n source={exchange?.image?.url}\n className=\"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg\"\n />\n <div className=\"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none\">\n <Text\n className=\"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]\"\n html={exchange?.product?.title}\n />\n <Text className=\"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]\" />\n </div>\n </div>\n <div className=\"flex flex-col items-end gap-2 justify-center\">\n {!!exchange && (\n <div className=\"flex items-center gap-1\">\n <Text\n className=\"text-base desktop:text-2xl font-bold\"\n html={formatPrice({\n amount: exchange.finalPrice?.amount || 0,\n locale,\n currencyCode: exchange.price.currencyCode,\n })}\n />\n <Text\n className=\"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: exchange.price?.amount || 0,\n locale,\n currencyCode: exchange.price.currencyCode,\n })}\n />\n </div>\n )}\n {canOperate && (\n <Button\n size=\"icon\"\n variant=\"link\"\n onClick={() => {\n setCheckedExchangePurchase?.(status ? undefined : exchange)\n exchangeOperation(exchange)\n }}\n className=\"shrink-0 size-auto underline\"\n >\n {status ? 'Remove' : 'Add'}\n </Button>\n )}\n </div>\n </div>\n )\n}\n\nexport default ProductSummary\n"],
5
- "mappings": "AAwEU,OACE,OAAAA,EADF,QAAAC,MAAA,oBAxEV,OAAS,QAAAC,EAAM,UAAAC,EAAmB,QAAAC,EAAM,YAAAC,EAAU,WAAAC,EAAS,WAAAC,MAAe,4BAC1E,OAAS,wBAAAC,MAA4B,8BACrC,OAAS,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAC7C,OAAS,eAAAC,MAAmB,iBAC5B,OAAS,kBAAAC,MAAsB,2BAE/B,MAAmB,yBACnB,OAAOC,MAAa,aACpB,OAAS,mBAAAC,MAAuB,4BAEhC,MAAMC,EAAiB,IAAM,CAC3B,KAAM,CAAE,OAAAC,EAAS,KAAM,YAAAC,CAAY,EAAIL,EAAe,EAChD,CACJ,QAAAM,EACA,QAAAC,EACA,WAAAC,EACA,aAAAC,EACA,OAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,aAAAC,EACA,YAAAC,EACA,SAAAC,EACA,aAAAC,EACA,cAAAC,EACA,2BAAAC,EACA,8BAAAC,EACA,eAAAC,EACA,2BAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,cAAAC,EACA,QAAAC,CACF,EAAI/B,EAAqB,EAEnB,CAACgC,CAA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,EAAA,CACC,UAAU,uCACV,KAAMU,EAAY,CAChB,OAAQ6C,EAAS,YAAY,QAAU,EACvC,OAAAxC,EACA,aAAcwC,EAAS,MAAM,YAC/B,CAAC,EACH,EACAzD,EAACE,EAAA,CACC,UAAU,mEACV,KAAMU,EAAY,CAChB,OAAQ6C,EAAS,OAAO,QAAU,EAClC,OAAAxC,EACA,aAAcwC,EAAS,MAAM,YAC/B,CAAC,EACH,GACF,EAEDc,GACCvE,EAACG,EAAA,CACC,KAAK,OACL,QAAQ,OACR,QAAS,IAAM,CACb+B,IAA6BsC,EAAS,OAAYf,CAAQ,EAC1DoB,EAAkBpB,CAAQ,CAC5B,EACA,UAAU,+BAET,SAAAe,EAAS,SAAW,MACvB,GAEJ,GACF,CAEJ,EAEA,IAAOM,GAAQ9D",
4
+ "sourcesContent": ["import { Text, Button, Container, Grid, GridItem, Picture, Heading } from '../../../../../components'\nimport { useBizProductContext } from '../../../BizProductProvider'\nimport { useEffect, useMemo, useState } from 'react'\nimport { formatPrice } from '../../../utils'\nimport { useAiuiContext } from '../../../../AiuiProvider'\nimport type { BundleListItem, ProductVariant, ProductPrice } from '../../../types/product'\nimport { cn } from '../../../../../helpers'\nimport Decimal from 'decimal.js'\nimport { replaceTemplate } from '../../../utils/textFormat'\n\nconst ProductSummary = () => {\n const { locale = 'us', copyWriting } = useAiuiContext()\n const {\n product,\n variant,\n finalPrice,\n comparePrice,\n coupon,\n selectedOptions,\n selectedVariants,\n totalSavings,\n onAddToCart,\n onBuyNow,\n savingDetail,\n checkedBundle,\n joinedRecommendBuyProducts,\n setJoinedRecommendBuyProducts,\n setCheckedGift,\n setCheckedExchangePurchase,\n setCheckedBundle,\n setSavingDetail,\n addToCartLoading,\n buyNowLoading,\n profile,\n } = useBizProductContext()\n\n const [currentProductVariant] = selectedVariants\n\n const summaryFinalPrice = useMemo(() => {\n const currentBundleVariant = checkedBundle?.variants.find(v => v.variant.sku === currentProductVariant?.sku)\n const currentBundlePrice = new Decimal(currentProductVariant?.price?.amount || 0)\n .minus(currentBundleVariant?.price || currentProductVariant?.price?.amount)\n .toNumber()\n let currentProductPrice = new Decimal(currentProductVariant?.price?.amount || 0)\n if (!!profile?.email) {\n currentProductPrice = currentProductPrice.minus(savingDetail?.member || 0)\n }\n return currentProductPrice.minus(savingDetail?.coupon).minus(currentBundlePrice).toNumber()\n }, [currentProductVariant, checkedBundle, profile, savingDetail?.member, savingDetail?.coupon])\n\n const isAvailable = variant.availableForSale\n if (!isAvailable) return null\n\n const { bundleVariant, giftVariant, exchangeVariant } = useRecommendBuyProducts() || {}\n const [initialRecommendBuyProducts, setInitialRecommendBuyProducts] = useState<{\n bundle?: BundleListItem\n gift?: ProductVariant\n exchange?: ProductVariant\n }>()\n\n useEffect(() => {\n setInitialRecommendBuyProducts({\n bundle: joinedRecommendBuyProducts.bundle?.value ? undefined : bundleVariant,\n gift: joinedRecommendBuyProducts.gift?.value ? undefined : giftVariant,\n exchange: joinedRecommendBuyProducts.exchange?.value ? undefined : exchangeVariant,\n })\n }, [bundleVariant, giftVariant, exchangeVariant, joinedRecommendBuyProducts])\n\n return (\n <div className=\"ipc-product-summary laptop:px-16 desktop:px-0 mt-16 desktop:mt-[96px] lg-desktop:mt-[128px]\">\n <div className=\"bg-[#F5F5F7] laptop:rounded-2xl\">\n <Grid className=\"px-4 pt-6 tablet:p-8 tablet:!pb-0\">\n <GridItem className=\"col-span-12 laptop:col-start-1 laptop:col-span-5 gap-4 flex flex-col justify-between\">\n <Heading\n className=\"font-bold text-[24px] lg-desktop:text-[48px] laptop:text-[32px] desktop:text-[40px] leading-[1] mb-4 [&>span]:text-[#D1D1D1]\"\n html={`${product.title} is ready <br/><span>Just the way you want it.</span>`}\n />\n <div className=\"\">\n <Picture\n source={variant.image?.url || product?.images?.[0]?.url}\n className=\"lg-desktop:aspect-[644/368] desktop:aspect-[503/272] laptop:aspect-[331/191] tablet:aspect-[704/380] aspect-[358/192]\"\n imgClassName=\"object-cover h-full\"\n />\n </div>\n </GridItem>\n <GridItem className=\"col-span-12 mt-8 pb-6 tablet:pb-8 laptop:col-start-7 laptop:mt-0 laptop:col-span-6 flex flex-col gap-6 justify-between\">\n <div>\n <div className=\"flex flex-col gap-4\">\n <div className=\"flex items-center justify-between\">\n <div className=\"shrink-0 flex items-center gap-4\">\n <Picture\n source={variant.image?.url || product?.images?.[0]?.url}\n className=\"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg\"\n />\n <div className=\"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none\">\n <Text\n className=\"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]\"\n html={product.title}\n />\n <Text\n className=\"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]\"\n html={`x1 | ${selectedOptions.color || selectedOptions.colour || selectedOptions.couleur}`}\n />\n </div>\n </div>\n <div className=\"flex items-center gap-1\">\n <Text\n className=\"text-base desktop:text-2xl font-bold\"\n html={formatPrice({\n amount: summaryFinalPrice,\n currencyCode: variant.price.currencyCode,\n locale,\n })}\n />\n {totalSavings > 0 && (\n <Text\n className=\"text-base desktop:text-2xl laptop:text-xl font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: variant?.price?.amount,\n currencyCode: variant.price.currencyCode,\n locale,\n })}\n />\n )}\n </div>\n </div>\n {joinedRecommendBuyProducts?.gift?.value && (\n <ProductGiftSummary\n giftOperation={gift => {\n setCheckedGift?.(undefined)\n setJoinedRecommendBuyProducts?.({\n ...joinedRecommendBuyProducts,\n gift: {\n value: undefined,\n canOperate: true,\n },\n })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, gift })\n }}\n status={!!joinedRecommendBuyProducts?.gift}\n gift={joinedRecommendBuyProducts?.gift?.value}\n canOperate={joinedRecommendBuyProducts?.gift?.canOperate}\n />\n )}\n {joinedRecommendBuyProducts?.bundle?.value && (\n <ProductBundleSummary\n bundleOperation={bundle => {\n setCheckedBundle?.(undefined)\n setJoinedRecommendBuyProducts?.({\n ...joinedRecommendBuyProducts,\n bundle: {\n value: undefined,\n canOperate: true,\n },\n })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, bundle })\n }}\n status={!!joinedRecommendBuyProducts?.bundle}\n bundleListItem={joinedRecommendBuyProducts?.bundle?.value}\n canOperate={joinedRecommendBuyProducts?.bundle?.canOperate}\n />\n )}\n {joinedRecommendBuyProducts?.exchange?.value && (\n <ProductExchangeSummary\n exchangeOperation={exchange => {\n setCheckedExchangePurchase?.(undefined)\n setJoinedRecommendBuyProducts?.({\n ...joinedRecommendBuyProducts,\n exchange: {\n value: undefined,\n canOperate: true,\n },\n })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, exchange })\n }}\n status={!!joinedRecommendBuyProducts?.exchange}\n canOperate={joinedRecommendBuyProducts?.exchange?.canOperate}\n exchange={joinedRecommendBuyProducts?.exchange?.value}\n />\n )}\n </div>\n {(initialRecommendBuyProducts?.bundle ||\n initialRecommendBuyProducts?.gift ||\n initialRecommendBuyProducts?.exchange) && (\n <div className=\"mt-6\">\n <Text className=\"text-sm desktop:text-[18px] font-bold\" html={'Recommend Buy'} />\n <div className=\"flex flex-col gap-6 mt-6\">\n {initialRecommendBuyProducts?.exchange && (\n <ProductExchangeSummary\n exchangeOperation={exchange => {\n setCheckedBundle?.(undefined)\n setJoinedRecommendBuyProducts?.({\n bundle: {\n value: undefined,\n canOperate: true,\n },\n gift: {\n value: joinedRecommendBuyProducts?.gift?.value,\n canOperate: true,\n },\n exchange: {\n value: exchange,\n canOperate: true,\n },\n })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, exchange: undefined })\n }}\n canOperate={joinedRecommendBuyProducts?.exchange?.canOperate}\n status={!initialRecommendBuyProducts?.exchange}\n exchange={initialRecommendBuyProducts?.exchange}\n />\n )}\n {initialRecommendBuyProducts?.bundle && (\n <ProductBundleSummary\n bundleOperation={bundle => {\n setCheckedGift?.(undefined)\n setCheckedExchangePurchase?.(undefined)\n setSavingDetail?.({ ...savingDetail, exchangePurchase: 0 })\n setJoinedRecommendBuyProducts?.({\n gift: {\n value: undefined,\n canOperate: true,\n },\n exchange: {\n value: undefined,\n canOperate: true,\n },\n bundle: {\n value: bundle,\n canOperate: true,\n },\n })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, bundle: undefined })\n }}\n canOperate={joinedRecommendBuyProducts?.bundle?.canOperate}\n status={!initialRecommendBuyProducts?.bundle}\n bundleListItem={initialRecommendBuyProducts?.bundle}\n />\n )}\n {initialRecommendBuyProducts?.gift && (\n <ProductGiftSummary\n giftOperation={gift => {\n setCheckedBundle?.(undefined)\n setJoinedRecommendBuyProducts?.({\n bundle: {\n value: undefined,\n canOperate: true,\n },\n exchange: {\n value: joinedRecommendBuyProducts?.exchange?.value,\n canOperate: true,\n },\n gift: {\n value: gift,\n canOperate: true,\n },\n })\n setInitialRecommendBuyProducts?.({ ...initialRecommendBuyProducts, gift: undefined })\n }}\n canOperate={joinedRecommendBuyProducts?.gift?.canOperate}\n status={!initialRecommendBuyProducts?.gift}\n gift={initialRecommendBuyProducts?.gift}\n />\n )}\n </div>\n </div>\n )}\n </div>\n <div className=\"text-right\">\n <Text\n className=\"laptop:text-xl desktop:text-2xl font-bold text-right\"\n html={`${replaceTemplate(copyWriting?.totalPrice || '', { amount: formatPrice({ amount: finalPrice, currencyCode: variant.price.currencyCode, locale }) })}`}\n />\n\n {totalSavings > 0 && (\n <Text\n className=\"text-base laptop:text-xl desktop:text-2xl ml-1 font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: comparePrice,\n currencyCode: variant.price.currencyCode,\n locale,\n })}\n />\n )}\n <div className=\"flex gap-3 mt-2 justify-end\">\n <Button\n size=\"lg\"\n variant=\"secondary\"\n loading={addToCartLoading}\n className=\"w-1/2 tablet:w-auto laptop:w-1/2 desktop:w-auto\"\n onClick={() => onAddToCart?.()}\n >\n {copyWriting?.addToCart}\n </Button>\n <Button\n size=\"lg\"\n loading={buyNowLoading}\n variant=\"primary\"\n className=\"w-1/2 tablet:w-auto laptop:w-1/2 desktop:w-auto\"\n onClick={() => onBuyNow?.()}\n >\n {copyWriting?.shopNow}\n </Button>\n </div>\n </div>\n </GridItem>\n </Grid>\n </div>\n </div>\n )\n}\n\nconst useRecommendBuyProducts = () => {\n const { bundle, variant, checkedBundle, freeGift, checkedGift, exchangePurchase, checkedExchangePurchase } =\n useBizProductContext()\n let bundleVariant = undefined\n let giftVariant = undefined\n let exchangeVariant = undefined\n const { bundleList } = bundle || {}\n\n const { giftList = [] } = freeGift || {}\n const { giftList: exchangeList = [] } = exchangePurchase || {}\n\n const availableBundleList =\n bundleList?.filter(bundle =>\n bundle.variants.slice(1, bundle.variants.length).every(v => v.variant.availableForSale)\n ) || []\n\n const [firstAvailableBundle] = availableBundleList\n bundleVariant = checkedBundle || firstAvailableBundle\n\n const [firstAvailableGift] = giftList?.filter(gift => gift.availableForSale)\n giftVariant = checkedGift || firstAvailableGift\n\n const [firstAvailableExchange] = exchangeList?.filter(exchange => exchange.availableForSale)\n exchangeVariant = checkedExchangePurchase || firstAvailableExchange\n\n return { bundleVariant, giftVariant, exchangeVariant }\n}\n\nconst ProductBundleSummary = ({\n bundleOperation,\n bundleListItem,\n canOperate,\n status,\n}: {\n bundleOperation: (bundle?: BundleListItem) => void\n bundleListItem?: BundleListItem\n canOperate?: boolean\n status?: boolean\n}) => {\n const { locale = 'us' } = useAiuiContext()\n const { variant, setCheckedBundle } = useBizProductContext()\n const bundleVariants = bundleListItem?.variants.filter(v => v.variant.sku !== variant.sku)\n\n return (\n <div className=\"\">\n {bundleVariants?.map(bundleVariant => {\n return (\n <div className=\"flex items-center gap-4 justify-between\" key={bundleVariant.variant.id}>\n <div className=\"flex items-center gap-4\">\n <Picture\n source={bundleVariant?.variant?.image?.url}\n className=\"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg\"\n />\n <div className=\"flex flex-col gap-[6px] line-clamp-2 max-w-[178px] tablet:max-w-none\">\n <Text\n className=\"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]\"\n html={bundleVariant.variant.product.title}\n />\n </div>\n </div>\n <div className=\"flex flex-col items-end gap-1 justify-center\">\n {!!bundleListItem && (\n <div className=\"flex items-center gap-1\">\n <Text\n className=\"text-base desktop:text-2xl font-bold\"\n html={formatPrice({\n amount: bundleVariant?.price || 0,\n locale,\n currencyCode: bundleVariant.variant?.price?.currencyCode || '',\n })}\n />\n {bundleVariant.price < bundleVariant.variant.price.amount && (\n <Text\n className=\"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: bundleVariant.variant.price.amount || 0,\n locale,\n currencyCode: bundleVariant.variant?.price?.currencyCode || '',\n })}\n />\n )}\n </div>\n )}\n {canOperate && (\n <Button\n size=\"icon\"\n variant=\"link\"\n onClick={() => {\n setCheckedBundle?.(status ? undefined : bundleListItem)\n bundleOperation?.(bundleListItem)\n }}\n className=\"shrink-0 size-auto underline\"\n >\n {!!status ? 'Remove' : 'Add'}\n </Button>\n )}\n </div>\n </div>\n )\n })}\n </div>\n )\n}\n\nconst ProductGiftSummary = ({\n giftOperation,\n gift,\n status,\n canOperate,\n}: {\n giftOperation: (gift?: ProductVariant) => void\n gift?: ProductVariant\n status?: boolean\n canOperate?: boolean\n}) => {\n const { locale = 'us' } = useAiuiContext()\n const { freeGift, setCheckedGift } = useBizProductContext()\n const { freeLabel, count } = freeGift || {}\n\n return (\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center gap-4\">\n <Picture\n source={gift?.image?.url}\n className=\"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg\"\n />\n <div className=\"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none\">\n <Text\n className=\"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]\"\n html={gift?.product?.title}\n />\n <Text\n className=\"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]\"\n html={`x${count} | ${freeLabel}`}\n />\n </div>\n </div>\n <div className=\"flex flex-col items-end gap-2 justify-center\">\n {!!gift && (\n <div className=\"flex items-center gap-1\">\n <Text className=\"text-base desktop:text-2xl font-bold\" html={freeLabel} />\n <Text\n className=\"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: gift.price.amount,\n locale,\n currencyCode: gift.price.currencyCode,\n })}\n />\n </div>\n )}\n {canOperate && (\n <Button\n size=\"icon\"\n variant=\"link\"\n onClick={() => {\n setCheckedGift?.(status ? undefined : gift)\n giftOperation(gift)\n }}\n className=\"shrink-0 size-auto underline\"\n >\n {status ? 'Remove' : 'Add'}\n </Button>\n )}\n </div>\n </div>\n )\n}\n\nconst ProductExchangeSummary = ({\n exchangeOperation,\n exchange,\n canOperate,\n status,\n}: {\n exchangeOperation: (exchange?: ProductVariant) => void\n exchange?: ProductVariant & { finalPrice?: ProductPrice }\n canOperate?: boolean\n status?: boolean\n}) => {\n const { locale = 'us' } = useAiuiContext()\n const { setCheckedExchangePurchase } = useBizProductContext()\n\n return (\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center gap-4\">\n <Picture\n source={exchange?.image?.url}\n className=\"size-10 laptop:size-12 p-2 lg-desktop:size-16 object-cover border-1 border-[#E4E5E6] bg-[#EAEAEC] rounded-[5px] rounded-lg\"\n />\n <div className=\"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none\">\n <Text\n className=\"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]\"\n html={exchange?.product?.title}\n />\n <Text className=\"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]\" />\n </div>\n </div>\n <div className=\"flex flex-col items-end gap-2 justify-center\">\n {!!exchange && (\n <div className=\"flex items-center gap-1\">\n <Text\n className=\"text-base desktop:text-2xl font-bold\"\n html={formatPrice({\n amount: exchange.finalPrice?.amount || 0,\n locale,\n currencyCode: exchange.price.currencyCode,\n })}\n />\n <Text\n className=\"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]\"\n html={formatPrice({\n amount: exchange.price?.amount || 0,\n locale,\n currencyCode: exchange.price.currencyCode,\n })}\n />\n </div>\n )}\n {canOperate && (\n <Button\n size=\"icon\"\n variant=\"link\"\n onClick={() => {\n setCheckedExchangePurchase?.(status ? undefined : exchange)\n exchangeOperation(exchange)\n }}\n className=\"shrink-0 size-auto underline\"\n >\n {status ? 'Remove' : 'Add'}\n </Button>\n )}\n </div>\n </div>\n )\n}\n\nexport default ProductSummary\n"],
5
+ "mappings": "AAwEU,OACE,OAAAA,EADF,QAAAC,MAAA,oBAxEV,OAAS,QAAAC,EAAM,UAAAC,EAAmB,QAAAC,EAAM,YAAAC,EAAU,WAAAC,EAAS,WAAAC,MAAe,4BAC1E,OAAS,wBAAAC,MAA4B,8BACrC,OAAS,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAC7C,OAAS,eAAAC,MAAmB,iBAC5B,OAAS,kBAAAC,MAAsB,2BAE/B,MAAmB,yBACnB,OAAOC,MAAa,aACpB,OAAS,mBAAAC,MAAuB,4BAEhC,MAAMC,EAAiB,IAAM,CAC3B,KAAM,CAAE,OAAAC,EAAS,KAAM,YAAAC,CAAY,EAAIL,EAAe,EAChD,CACJ,QAAAM,EACA,QAAAC,EACA,WAAAC,EACA,aAAAC,EACA,OAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,aAAAC,EACA,YAAAC,EACA,SAAAC,EACA,aAAAC,EACA,cAAAC,EACA,2BAAAC,EACA,8BAAAC,EACA,eAAAC,EACA,2BAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,cAAAC,EACA,QAAAC,CACF,EAAI/B,EAAqB,EAEnB,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C,CAACwD,GACDxD,EAAC,OAAI,UAAU,0BACb,UAAAD,EAACE,EAAA,CACC,UAAU,uCACV,KAAMU,EAAY,CAChB,OAAQ6C,EAAS,YAAY,QAAU,EACvC,OAAAxC,EACA,aAAcwC,EAAS,MAAM,YAC/B,CAAC,EACH,EACAzD,EAACE,EAAA,CACC,UAAU,mEACV,KAAMU,EAAY,CAChB,OAAQ6C,EAAS,OAAO,QAAU,EAClC,OAAAxC,EACA,aAAcwC,EAAS,MAAM,YAC/B,CAAC,EACH,GACF,EAEDc,GACCvE,EAACG,EAAA,CACC,KAAK,OACL,QAAQ,OACR,QAAS,IAAM,CACb+B,IAA6BsC,EAAS,OAAYf,CAAQ,EAC1DoB,EAAkBpB,CAAQ,CAC5B,EACA,UAAU,+BAET,SAAAe,EAAS,SAAW,MACvB,GAEJ,GACF,CAEJ,EAEA,IAAOM,GAAQ9D",
6
6
  "names": ["jsx", "jsxs", "Text", "Button", "Grid", "GridItem", "Picture", "Heading", "useBizProductContext", "useEffect", "useMemo", "useState", "formatPrice", "useAiuiContext", "Decimal", "replaceTemplate", "ProductSummary", "locale", "copyWriting", "product", "variant", "finalPrice", "comparePrice", "coupon", "selectedOptions", "selectedVariants", "totalSavings", "onAddToCart", "onBuyNow", "savingDetail", "checkedBundle", "joinedRecommendBuyProducts", "setJoinedRecommendBuyProducts", "setCheckedGift", "setCheckedExchangePurchase", "setCheckedBundle", "setSavingDetail", "addToCartLoading", "buyNowLoading", "profile", "currentProductVariant", "summaryFinalPrice", "currentBundleVariant", "v", "currentBundlePrice", "currentProductPrice", "bundleVariant", "giftVariant", "exchangeVariant", "useRecommendBuyProducts", "initialRecommendBuyProducts", "setInitialRecommendBuyProducts", "ProductGiftSummary", "gift", "ProductBundleSummary", "bundle", "ProductExchangeSummary", "exchange", "freeGift", "checkedGift", "exchangePurchase", "checkedExchangePurchase", "bundleList", "giftList", "exchangeList", "availableBundleList", "firstAvailableBundle", "firstAvailableGift", "firstAvailableExchange", "bundleOperation", "bundleListItem", "canOperate", "status", "bundleVariants", "giftOperation", "freeLabel", "count", "exchangeOperation", "ProductSummary_default"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{jsx as a,jsxs as n}from"react/jsx-runtime";import{Text as l,Button as u}from"../../../../../components";import{useAiuiContext as w}from"../../../../AiuiProvider/index.js";import{useBizProductContext as h}from"../../../BizProductProvider.js";import{useMemo as p}from"react";import{formatPrice as i}from"../../../utils";import{replaceTemplate as x}from"../../../utils/textFormat";const k=()=>{const{copyWriting:t,locale:o="us"}=w(),{variant:e,finalPrice:b,totalSavings:r,memberFunctionResult:s,isLogin:c,comparePrice:g,onAddToCart:v,onBuyNow:f,savingDetail:d,coupon:T,addToCartLoading:C,buyNowLoading:y,profile:P}=h(),m=Math.max(s?.withCouponMemberTotalSave??0,s?.withoutCouponMaxMemberTotalSave??0),N=p(()=>x(t?.totalSavings||"",{amount:i({amount:r,currencyCode:e.price.currencyCode,locale:o})}),[t?.totalSavings,r,e.price.currencyCode,o]),S=p(()=>x(t?.memberSaving||"",{amount:i({amount:m,currencyCode:e.price.currencyCode,locale:o})}),[t?.memberSaving,m,e.price.currencyCode,o]);return n("div",{className:"bg-white py-3 px-4 tablet:p-0 tablet:flex tablet:items-center tablet:gap-4",children:[e.availableForSale?n("div",{className:"flex items-center justify-between tablet:flex-col desktop:items-end",children:[n("div",{className:"flex items-center gap-1",children:[a(l,{className:"text-xl font-bold !leading-[1.2] desktop:text-xl lg-desktop:text-2xl",html:i({amount:b,currencyCode:e.price.currencyCode,locale:o})}),(r>0||d?.member>0&&c)&&a(l,{className:"text-xl font-bold line-through text-[#999] !leading-[1.2] desktop:text-xl lg-desktop:text-2xl",html:i({amount:g,currencyCode:e.price.currencyCode,locale:o})})]}),(r>0||d?.member>0&&c)&&a(l,{className:"text-brand-0 text-base !leading-[1.2] font-bold desktop:text-xl lg-desktop:text-2xl",html:`${m>0&&c?S:N}`})]}):a(l,{className:"text-[20px] font-bold text-[#999999]",html:t?.soldOut??"Sold Out"}),n("div",{className:"flex items-center gap-2 mt-2 tablet:mt-0",children:[a(u,{variant:"secondary",disabled:!e.availableForSale,size:"lg",className:"w-1/2 tablet:w-auto",onClick:()=>v?.(),loading:C,children:t?.addToCart??"Add to Cart"}),a(u,{variant:"primary",disabled:!e.availableForSale,size:"lg",loading:y,className:"w-1/2 tablet:w-auto",onClick:()=>f?.(),children:t?.buyNow??"Buy Now"})]})]})};var O=k;export{O as default};
1
+ import{jsx as a,jsxs as i}from"react/jsx-runtime";import{Text as l,Button as u}from"../../../../../components";import{useAiuiContext as k}from"../../../../AiuiProvider/index.js";import{useBizProductContext as T}from"../../../BizProductProvider.js";import{useMemo as p}from"react";import{formatPrice as n}from"../../../utils";import{replaceTemplate as b}from"../../../utils/textFormat";import{useDiscountEnable as B}from"../../../hooks/useDiscountEnable";const P=()=>{const{copyWriting:t,locale:o="us"}=k(),{variant:e,finalPrice:x,totalSavings:r,memberFunctionResult:c,isLogin:s,comparePrice:g,onAddToCart:v,onBuyNow:f,savingDetail:m,coupon:C,addToCartLoading:y,buyNowLoading:N,profile:S}=T(),d=Math.max(c?.withCouponMemberTotalSave??0,c?.withoutCouponMaxMemberTotalSave??0),w=p(()=>b(t?.totalSavings||"",{amount:n({amount:r,currencyCode:e.price.currencyCode,locale:o})}),[t?.totalSavings,r,e.price.currencyCode,o]),h=p(()=>b(t?.memberSaving||"",{amount:n({amount:d,currencyCode:e.price.currencyCode,locale:o})}),[t?.memberSaving,d,e.price.currencyCode,o]),M=B({profile:S,variant:e,memberFunctionResult:c,coupon:C});return i("div",{className:"bg-white py-3 px-4 tablet:p-0 tablet:flex tablet:items-center tablet:gap-4",children:[e.availableForSale?i("div",{className:"flex items-center justify-between tablet:flex-col desktop:items-end",children:[i("div",{className:"flex items-center gap-1",children:[a(l,{className:"text-xl font-bold !leading-[1.2] desktop:text-xl lg-desktop:text-2xl",html:n({amount:x,currencyCode:e.price.currencyCode,locale:o})}),(r>0||m?.member>0&&s)&&a(l,{className:"text-xl font-bold line-through text-[#999] !leading-[1.2] desktop:text-xl lg-desktop:text-2xl",html:n({amount:g,currencyCode:e.price.currencyCode,locale:o})})]}),(r>0||m?.member>0&&s)&&a(l,{className:"text-brand-0 text-base !leading-[1.2] font-bold desktop:text-xl lg-desktop:text-2xl",html:`${m?.member?h:w}`})]}):a(l,{className:"text-[20px] font-bold text-[#999999]",html:t?.soldOut??"Sold Out"}),i("div",{className:"flex items-center gap-2 mt-2 tablet:mt-0",children:[a(u,{variant:"secondary",disabled:!e.availableForSale,size:"lg",className:"w-1/2 tablet:w-auto",onClick:()=>v?.(),loading:y,children:t?.addToCart??"Add to Cart"}),a(u,{variant:"primary",disabled:!e.availableForSale,size:"lg",loading:N,className:"w-1/2 tablet:w-auto",onClick:()=>f?.(),children:t?.buyNow??"Buy Now"})]})]})};var R=P;export{R as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/biz-components/Listing/components/PurchaseBar/ProductActions/index.tsx"],
4
- "sourcesContent": ["import { Text, Button } from '../../../../../components'\nimport { useAiuiContext } from '../../../../AiuiProvider/index.js'\nimport { useBizProductContext } from '../../../BizProductProvider.js'\nimport { useMemo } from 'react'\nimport { formatPrice } from '../../../utils'\nimport { replaceTemplate } from '../../../utils/textFormat'\n\nconst ProductActions = () => {\n const { copyWriting, locale = 'us' } = useAiuiContext()\n const {\n variant,\n finalPrice,\n totalSavings,\n memberFunctionResult,\n isLogin,\n comparePrice,\n onAddToCart,\n onBuyNow,\n savingDetail,\n coupon,\n addToCartLoading,\n buyNowLoading,\n profile,\n } = useBizProductContext()\n\n const memberPriceSave = Math.max(\n memberFunctionResult?.withCouponMemberTotalSave ?? 0,\n memberFunctionResult?.withoutCouponMaxMemberTotalSave ?? 0\n )\n\n const totalSavingsText = useMemo(() => {\n return replaceTemplate(copyWriting?.totalSavings || '', {\n amount: formatPrice({ amount: totalSavings, currencyCode: variant.price.currencyCode, locale }),\n })\n }, [copyWriting?.totalSavings, totalSavings, variant.price.currencyCode, locale])\n\n const memberPriceSaveText = useMemo(() => {\n return replaceTemplate(copyWriting?.memberSaving || '', {\n amount: formatPrice({ amount: memberPriceSave, currencyCode: variant.price.currencyCode, locale }),\n })\n }, [copyWriting?.memberSaving, memberPriceSave, variant.price.currencyCode, locale])\n\n return (\n <div className=\"bg-white py-3 px-4 tablet:p-0 tablet:flex tablet:items-center tablet:gap-4\">\n {variant.availableForSale ? (\n <div className=\"flex items-center justify-between tablet:flex-col desktop:items-end\">\n <div className=\"flex items-center gap-1\">\n <Text\n className=\"text-xl font-bold !leading-[1.2] desktop:text-xl lg-desktop:text-2xl\"\n html={formatPrice({ amount: finalPrice, currencyCode: variant.price.currencyCode, locale })}\n />\n {(totalSavings > 0 || savingDetail?.member > 0 && isLogin ) && (\n <Text\n className=\"text-xl font-bold line-through text-[#999] !leading-[1.2] desktop:text-xl lg-desktop:text-2xl\"\n html={formatPrice({\n amount: comparePrice,\n currencyCode: variant.price.currencyCode,\n locale,\n })}\n />\n )}\n </div>\n {(totalSavings > 0 || (savingDetail?.member > 0 && isLogin)) && (\n <Text\n className=\"text-brand-0 text-base !leading-[1.2] font-bold desktop:text-xl lg-desktop:text-2xl\"\n html={`${memberPriceSave > 0 && isLogin ? memberPriceSaveText : totalSavingsText}`}\n />\n )}\n </div>\n ) : (\n <Text className=\"text-[20px] font-bold text-[#999999]\" html={copyWriting?.soldOut ?? 'Sold Out'} />\n )}\n <div className=\"flex items-center gap-2 mt-2 tablet:mt-0\">\n <Button\n variant=\"secondary\"\n disabled={!variant.availableForSale}\n size=\"lg\"\n className=\"w-1/2 tablet:w-auto\"\n onClick={() => onAddToCart?.()}\n loading={addToCartLoading}\n >\n {copyWriting?.addToCart ?? 'Add to Cart'}\n </Button>\n <Button\n variant=\"primary\"\n disabled={!variant.availableForSale}\n size=\"lg\"\n loading={buyNowLoading}\n className=\"w-1/2 tablet:w-auto\"\n onClick={() => onBuy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0BACb,UAAAD,EAACE,EAAA,CACC,UAAU,uEACV,KAAMK,EAAY,CAAE,OAAQM,EAAY,aAAcD,EAAQ,MAAM,aAAc,OAAAD,CAAO,CAAC,EAC5F,GACEG,EAAe,GAAKM,GAAc,OAAS,GAAKJ,IAChDhB,EAACE,EAAA,CACC,UAAU,gGACV,KAAMK,EAAY,CAChB,OAAQU,EACR,aAAcL,EAAQ,MAAM,aAC5B,OAAAD,CACF,CAAC,EACH,GAEJ,GACEG,EAAe,GAAMM,GAAc,OAAS,GAAKJ,IACjDhB,EAACE,EAAA,CACC,UAAU,sFACV,KAAM,GAAGuB,EAAkB,GAAKT,EAAUW,EAAsBD,CAAgB,GAClF,GAEJ,EAEA1B,EAACE,EAAA,CAAK,UAAU,uCAAuC,KAAMQ,GAAa,SAAW,WAAY,EAEnGT,EAAC,OAAI,UAAU,2CACb,UAAAD,EAACG,EAAA,CACC,QAAQ,YACR,SAAU,CAACS,EAAQ,iBACnB,KAAK,KACL,UAAU,sBACV,QAAS,IAAMM,IAAc,EAC7B,QAASI,EAER,SAAAZ,GAAa,WAAa,cAC7B,EACAV,EAACG,EAAA,CACC,QAAQ,UACR,SAAU,CAACS,EAAQ,iBACnB,KAAK,KACL,QAASW,EACT,UAAU,sBACV,QAAS,IAAMJ,IAAW,EAEzB,SAAAT,GAAa,QAAU,UAC1B,GACF,GACF,CAEJ,EAEA,IAAOkB,EAAQnB",
6
- "names": ["jsx", "jsxs", "Text", "Button", "useAiuiContext", "useBizProductContext", "useMemo", "formatPrice", "replaceTemplate", "ProductActions", "copyWriting", "locale", "variant", "finalPrice", "totalSavings", "memberFunctionResult", "isLogin", "comparePrice", "onAddToCart", "onBuyNow", "savingDetail", "coupon", "addToCartLoading", "buyNowLoading", "profile", "memberPriceSave", "totalSavingsText", "memberPriceSaveText", "ProductActions_default"]
4
+ "sourcesContent": ["import { Text, Button } from '../../../../../components'\nimport { useAiuiContext } from '../../../../AiuiProvider/index.js'\nimport { useBizProductContext } from '../../../BizProductProvider.js'\nimport { useMemo } from 'react'\nimport { formatPrice } from '../../../utils'\nimport { replaceTemplate } from '../../../utils/textFormat'\nimport { useDiscountEnable } from '../../../hooks/useDiscountEnable'\n\nconst ProductActions = () => {\n const { copyWriting, locale = 'us' } = useAiuiContext()\n const {\n variant,\n finalPrice,\n totalSavings,\n memberFunctionResult,\n isLogin,\n comparePrice,\n onAddToCart,\n onBuyNow,\n savingDetail,\n coupon,\n addToCartLoading,\n buyNowLoading,\n profile,\n } = useBizProductContext()\n\n const memberPriceSave = Math.max(\n memberFunctionResult?.withCouponMemberTotalSave ?? 0,\n memberFunctionResult?.withoutCouponMaxMemberTotalSave ?? 0\n )\n\n const totalSavingsText = useMemo(() => {\n return replaceTemplate(copyWriting?.totalSavings || '', {\n amount: formatPrice({ amount: totalSavings, currencyCode: variant.price.currencyCode, locale }),\n })\n }, [copyWriting?.totalSavings, totalSavings, variant.price.currencyCode, locale])\n\n const memberPriceSaveText = useMemo(() => {\n return replaceTemplate(copyWriting?.memberSaving || '', {\n amount: formatPrice({ amount: memberPriceSave, currencyCode: variant.price.currencyCode, locale }),\n })\n }, [copyWriting?.memberSaving, memberPriceSave, variant.price.currencyCode, locale])\n\n const discountEnable = useDiscountEnable({ profile, variant, memberFunctionResult, coupon })\n\n return (\n <div className=\"bg-white py-3 px-4 tablet:p-0 tablet:flex tablet:items-center tablet:gap-4\">\n {variant.availableForSale ? (\n <div className=\"flex items-center justify-between tablet:flex-col desktop:items-end\">\n <div className=\"flex items-center gap-1\">\n <Text\n className=\"text-xl font-bold !leading-[1.2] desktop:text-xl lg-desktop:text-2xl\"\n html={formatPrice({ amount: finalPrice, currencyCode: variant.price.currencyCode, locale })}\n />\n {(totalSavings > 0 || (savingDetail?.member > 0 && isLogin)) && (\n <Text\n className=\"text-xl font-bold line-through text-[#999] !leading-[1.2] desktop:text-xl lg-desktop:text-2xl\"\n html={formatPrice({\n amount: comparePrice,\n currencyCode: variant.price.currencyCode,\n locale,\n })}\n />\n )}\n </div>\n {(totalSavings > 0 || (savingDetail?.member > 0 && isLogin)) && (\n <Text\n className=\"text-brand-0 text-base !leading-[1.2] font-bold desktop:text-xl lg-desktop:text-2xl\"\n html={`${Boolean(savingDetail?.member) ? memberPriceSaveText : totalSavingsText}`}\n />\n )}\n </div>\n ) : (\n <Text className=\"text-[20px] font-bold text-[#999999]\" html={copyWriting?.soldOut ?? 'Sold Out'} />\n )}\n <div className=\"flex items-center gap-2 mt-2 tablet:mt-0\">\n <Button\n variant=\"secondary\"\n disabled={!variant.availableForSale}\n size=\"lg\"\n className=\"w-1/2 tablet:w-auto\"\n onClick={() => onAddToCart?.()}\n loading={addToCartLoading}\n >\n {copyWriting?.addToCart ?? 'Add to Cart'}\n </Button>\n <Button\n variant=\"primary\"\n disabled={!variant.availableForSale}\n size=\"lg\"\n loading={buyNowLoading}\n className=\"w-1/2 tablet:w-auto\"\n onClick={() => onBuyNow?.()}\n >\n {copyWriting?.buyNow ?? 'Buy Now'}\n </Button>\n </div>\n </div>\n )\n}\n\nexport default ProductActions\n"],
5
+ "mappings": "AAiDU,OACE,OAAAA,EADF,QAAAC,MAAA,oBAjDV,OAAS,QAAAC,EAAM,UAAAC,MAAc,4BAC7B,OAAS,kBAAAC,MAAsB,oCAC/B,OAAS,wBAAAC,MAA4B,iCACrC,OAAS,WAAAC,MAAe,QACxB,OAAS,eAAAC,MAAmB,iBAC5B,OAAS,mBAAAC,MAAuB,4BAChC,OAAS,qBAAAC,MAAyB,mCAElC,MAAMC,EAAiB,IAAM,CAC3B,KAAM,CAAE,YAAAC,EAAa,OAAAC,EAAS,IAAK,EAAIR,EAAe,EAChD,CACJ,QAAAS,EACA,WAAAC,EACA,aAAAC,EACA,qBAAAC,EACA,QAAAC,EACA,aAAAC,EACA,YAAAC,EACA,SAAAC,EACA,aAAAC,EACA,OAAAC,EACA,iBAAAC,EACA,cAAAC,EACA,QAAAC,CACF,EAAIpB,EAAqB,EAEnBqB,EAAkB,KAAK,IAC3BV,GAAs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G,EAAA,CACC,QAAQ,YACR,SAAU,CAACU,EAAQ,iBACnB,KAAK,KACL,UAAU,sBACV,QAAS,IAAMM,IAAc,EAC7B,QAASI,EAER,SAAAZ,GAAa,WAAa,cAC7B,EACAX,EAACG,EAAA,CACC,QAAQ,UACR,SAAU,CAACU,EAAQ,iBACnB,KAAK,KACL,QAASW,EACT,UAAU,sBACV,QAAS,IAAMJ,IAAW,EAEzB,SAAAT,GAAa,QAAU,UAC1B,GACF,GACF,CAEJ,EAEA,IAAOmB,EAAQpB",
6
+ "names": ["jsx", "jsxs", "Text", "Button", "useAiuiContext", "useBizProductContext", "useMemo", "formatPrice", "replaceTemplate", "useDiscountEnable", "ProductActions", "copyWriting", "locale", "variant", "finalPrice", "totalSavings", "memberFunctionResult", "isLogin", "comparePrice", "onAddToCart", "onBuyNow", "savingDetail", "coupon", "addToCartLoading", "buyNowLoading", "profile", "memberPriceSave", "totalSavingsText", "memberPriceSaveText", "discountEnable", "ProductActions_default"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{jsx as o,jsxs as s}from"react/jsx-runtime";import"../../../../AiuiProvider/index.js";import{cn as m}from"../../../../../helpers/index.js";import{useState as c,useCallback as p,useRef as x}from"react";import{gsap as S}from"gsap";import{useBizProductContext as h}from"../../../BizProductProvider.js";const g=t=>o("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:o("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"#1D1D1F",strokeLinecap:"round",strokeLinejoin:"round"})}),w=({tabs:t,purchaseBarHeight:a,onSpyNavItemClick:i})=>{const[n,r]=c(!1),[e,f]=c(t?.[0]),d=x(null),{renderRating:u}=h(),v=p(l=>{f(l),i?.(l),r(!1)},[]),b=p(()=>{r(!n),S.fromTo(d?.current,{height:0},{height:"auto",duration:.5,ease:"power2.inOut"})},[n]);return s("div",{children:[s("button",{className:"text-sm h-[28px] font-bold flex gap-1 items-center leading-[28px] px-[10px] border rounded-full border-black",onClick:b,children:[e?.label,o(g,{className:"size-3"})]}),s("div",{className:m("absolute top-full w-full flex flex-col z-[60] bg-black/60 left-0",{hidden:!n}),style:{height:`calc(100dvh - ${a}px)`},children:[s("div",{ref:d,className:"border-t overflow-hidden border-[#E4E5E6] flex flex-col bg-white",children:[t?.map(l=>o("button",{className:"text-sm hover:bg-[#EAEAEC] p-4 text-left font-bold",onClick:()=>v(l),children:l.label},l.id)),o("button",{className:"text-sm hover:bg-[#EAEAEC] p-4 text-left font-bold",children:u})]}),o("div",{className:"flex-1",onClick:()=>r(!1)})]})]})},N=({tabs:t,onSpyNavItemClick:a})=>{const[i,n]=c(t?.[0]),r=p(e=>{n(e),a?.(e)},[]);return o("div",{className:"flex gap-8",children:t?.map(e=>s("button",{className:"text-sm relative py-[10px] font-bold",onClick:()=>r(e),children:[e.label,o("div",{className:m("absolute bottom-0 left-0 w-0 transition-all duration-300 ease-in-out h-[2px] bg-brand-0",{"w-full":i?.id===e.id})})]},e.id))})};export{N as DesktopScrollSpyNav,w as MobileScrollSpyNav};
1
+ import{jsx as s,jsxs as d}from"react/jsx-runtime";import"../../../../AiuiProvider/index.js";import{cn as v}from"../../../../../helpers/index.js";import{useState as b,useCallback as u,useRef as w,useEffect as x}from"react";import{gsap as h}from"gsap";import{useBizProductContext as g}from"../../../BizProductProvider.js";const N=o=>s("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o,children:s("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"#1D1D1F",strokeLinecap:"round",strokeLinejoin:"round"})}),S=(o,i)=>{const[r,l]=b(o?.[0]);return x(()=>{if(!o||o.length===0)return;const n=()=>{const e=o.map(t=>{const p=t.id||t.href?.replace("#","");return{tab:t,element:document.getElementById(p)}}).filter(t=>t.element!==null);if(e.length===0)return;const f=window.scrollY+150;let c=e[0];for(const t of e){const m=t.element.offsetTop;if(f>=m)c=t;else break}c&&c.tab.id!==r?.id&&(l(c.tab),i?.(c.tab))};return n(),window.addEventListener("scroll",n,{passive:!0}),()=>{window.removeEventListener("scroll",n)}},[o,r?.id,i]),{activeTab:r,setActiveTab:l}},y=({tabs:o,purchaseBarHeight:i,onSpyNavItemClick:r})=>{const[l,n]=b(!1),e=w(null),{renderRating:f}=g(),{activeTab:c,setActiveTab:t}=S(o),p=u(a=>{t(a),r?.(a),n(!1)},[r,t]),m=u(()=>{n(!l),h.fromTo(e?.current,{height:0},{height:"auto",duration:.5,ease:"power2.inOut"})},[l]);return d("div",{children:[d("button",{className:"text-sm h-[28px] font-bold flex gap-1 items-center leading-[28px] px-[10px] border rounded-full border-black",onClick:m,children:[c?.label,s(N,{className:"size-3"})]}),d("div",{className:v("absolute top-full w-full flex flex-col z-[60] bg-black/60 left-0",{hidden:!l}),style:{height:`calc(100dvh - ${i}px)`},children:[d("div",{ref:e,className:"border-t overflow-hidden border-[#E4E5E6] flex flex-col bg-white",children:[o?.map(a=>s("button",{className:"text-sm hover:bg-[#EAEAEC] p-4 text-left font-bold",onClick:()=>p(a),children:a.label},a.id)),s("button",{className:"text-sm hover:bg-[#EAEAEC] p-4 text-left font-bold",children:f})]}),s("div",{className:"flex-1",onClick:()=>n(!1)})]})]})},E=({tabs:o,onSpyNavItemClick:i})=>{const{activeTab:r,setActiveTab:l}=S(o),n=u(e=>{l(e),i?.(e)},[i,l]);return s("div",{className:"flex gap-8",children:o?.map(e=>d("button",{className:"text-sm relative py-[10px] font-bold",onClick:()=>n(e),children:[e.label,s("div",{className:v("absolute bottom-0 left-0 w-0 transition-all duration-300 ease-in-out h-[2px] bg-brand-0",{"w-full":r?.id===e.id})})]},e.id))})};export{E as DesktopScrollSpyNav,y as MobileScrollSpyNav};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/index.tsx"],
4
- "sourcesContent": ["import { useAiuiContext } from '../../../../AiuiProvider/index.js'\nimport { cn } from '../../../../../helpers/index.js'\nimport { useState, useCallback, useRef } from 'react'\nimport { gsap } from 'gsap'\nimport type { ScrollSpyNavItem, ScrollSpyNavProps } from './types.js'\nimport { useBizProductContext } from '../../../BizProductProvider.js'\n\nconst ArrowDownIcon = (props: React.SVGProps<SVGSVGElement>) => {\n return (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <path d=\"M3 4.5L6 7.5L9 4.5\" stroke=\"#1D1D1F\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )\n}\n\nconst MobileScrollSpyNav = ({ tabs, purchaseBarHeight, onSpyNavItemClick }: ScrollSpyNavProps) => {\n const [dropdownOpen, setDropdownOpen] = useState(false)\n const [activeTab, setActiveTab] = useState(tabs?.[0])\n const dropdownRef = useRef<HTMLDivElement>(null)\n const { renderRating } = useBizProductContext()\n \n const onTabClick = useCallback((tab: ScrollSpyNavItem) => {\n setActiveTab(tab)\n onSpyNavItemClick?.(tab)\n setDropdownOpen(false)\n }, [])\n\n const onDropdownOpen = useCallback(() => {\n setDropdownOpen(!dropdownOpen)\n gsap.fromTo(dropdownRef?.current, { height: 0 }, { height: 'auto', duration: 0.5, ease: 'power2.inOut' })\n }, [dropdownOpen])\n\n return (\n <div>\n <button\n className=\"text-sm h-[28px] font-bold flex gap-1 items-center leading-[28px] px-[10px] border rounded-full border-black\"\n onClick={onDropdownOpen}\n >\n {activeTab?.label}<ArrowDownIcon className='size-3'/>\n </button>\n <div\n className={cn('absolute top-full w-full flex flex-col z-[60] bg-black/60 left-0', {\n ['hidden']: !dropdownOpen,\n })}\n style={{\n height: `calc(100dvh - ${purchaseBarHeight}px)`,\n }}\n >\n <div ref={dropdownRef} className=\"border-t overflow-hidden border-[#E4E5E6] flex flex-col bg-white\">\n {tabs?.map(tab => (\n <button\n className=\"text-sm hover:bg-[#EAEAEC] p-4 text-left font-bold\"\n key={tab.id}\n onClick={() => onTabClick(tab)}\n >\n {tab.label}\n </button>\n ))}\n <button className=\"text-sm hover:bg-[#EAEAEC] p-4 text-left font-bold\">{renderRating}</button>\n </div>\n <div className=\"flex-1\" onClick={() => setDropdownOpen(false)} />\n </div>\n </div>\n )\n}\n\nconst DesktopScrollSpyNav = ({ tabs, onSpyNavItemClick }: ScrollSpyNavProps) => {\n const [activeTab, setActiveTab] = useState(tabs?.[0])\n\n const onTabClick = useCallback((tab: ScrollSpyNavItem) => {\n setActiveTab(tab)\n onSpyNavItemClick?.(tab)\n }, [])\n\n return (\n <div className=\"flex gap-8\">\n {tabs?.map(tab => (\n <button className=\"text-sm relative py-[10px] font-bold\" key={tab.id} onClick={() => onTabClick(tab)}>\n {tab.label}\n <div\n className={cn('absolute bottom-0 left-0 w-0 transition-all duration-300 ease-in-out h-[2px] bg-brand-0', {\n 'w-full': activeTab?.id === tab.id,\n })}\n />\n </button>\n ))}\n </div>\n )\n}\n\nexport { MobileScrollSpyNav, DesktopScrollSpyNav }\n"],
5
- "mappings": "AAUM,cAAAA,EAwBA,QAAAC,MAxBA,oBAVN,MAA+B,oCAC/B,OAAS,MAAAC,MAAU,kCACnB,OAAS,YAAAC,EAAU,eAAAC,EAAa,UAAAC,MAAc,QAC9C,OAAS,QAAAC,MAAY,OAErB,OAAS,wBAAAC,MAA4B,iCAErC,MAAMC,EAAiBC,GAEnBT,EAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,6BAA8B,GAAGS,EACjG,SAAAT,EAAC,QAAK,EAAE,qBAAqB,OAAO,UAAU,cAAc,QAAQ,eAAe,QAAQ,EAC7F,EAIEU,EAAqB,CAAC,CAAE,KAAAC,EAAM,kBAAAC,EAAmB,kBAAAC,CAAkB,IAAyB,CAChG,KAAM,CAACC,EAAcC,CAAe,EAAIZ,EAAS,EAAK,EAChD,CAACa,EAAWC,CAAY,EAAId,EAASQ,IAAO,CAAC,CAAC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B,EAAC,UAAO,UAAU,uCAAoD,QAAS,IAAMmB,EAAWC,CAAG,EAChG,UAAAA,EAAI,MACLrB,EAAC,OACC,UAAWE,EAAG,0FAA2F,CACvG,SAAUc,GAAW,KAAOK,EAAI,EAClC,CAAC,EACH,IAN4DA,EAAI,EAOlE,CACD,EACH,CAEJ",
6
- "names": ["jsx", "jsxs", "cn", "useState", "useCallback", "useRef", "gsap", "useBizProductContext", "ArrowDownIcon", "props", "MobileScrollSpyNav", "tabs", "purchaseBarHeight", "onSpyNavItemClick", "dropdownOpen", "setDropdownOpen", "activeTab", "setActiveTab", "dropdownRef", "renderRating", "onTabClick", "tab", "onDropdownOpen", "DesktopScrollSpyNav"]
4
+ "sourcesContent": ["import { useAiuiContext } from '../../../../AiuiProvider/index.js'\nimport { cn } from '../../../../../helpers/index.js'\nimport { useState, useCallback, useRef, useEffect } from 'react'\nimport { gsap } from 'gsap'\nimport type { ScrollSpyNavItem, ScrollSpyNavProps } from './types.js'\nimport { useBizProductContext } from '../../../BizProductProvider.js'\n\nconst ArrowDownIcon = (props: React.SVGProps<SVGSVGElement>) => {\n return (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <path d=\"M3 4.5L6 7.5L9 4.5\" stroke=\"#1D1D1F\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n )\n}\n\n// \u81EA\u5B9A\u4E49 hook\uFF1A\u76D1\u542C\u9875\u9762\u6EDA\u52A8\uFF0C\u81EA\u52A8\u66F4\u65B0\u5F53\u524D\u6FC0\u6D3B\u7684 tab\nconst useScrollSpy = (tabs: ScrollSpyNavItem[], onActiveChange?: (tab: ScrollSpyNavItem) => void) => {\n const [activeTab, setActiveTab] = useState(tabs?.[0])\n\n useEffect(() => {\n if (!tabs || tabs.length === 0) return\n\n const handleScroll = () => {\n // \u83B7\u53D6\u6240\u6709\u951A\u70B9\u5143\u7D20\n const sections = tabs\n .map(tab => {\n // \u652F\u6301 #id \u6216\u76F4\u63A5 id \u683C\u5F0F\n const id = tab.id || tab.href?.replace('#', '')\n return {\n tab,\n element: document.getElementById(id),\n }\n })\n .filter(item => item.element !== null)\n\n if (sections.length === 0) return\n\n // \u83B7\u53D6\u5F53\u524D\u6EDA\u52A8\u4F4D\u7F6E\uFF08\u52A0\u4E0A\u4E00\u4E2A\u504F\u79FB\u91CF\uFF0C\u901A\u5E38\u662F\u5BFC\u822A\u680F\u9AD8\u5EA6\uFF09\n const scrollPosition = window.scrollY + 150 // 150px \u504F\u79FB\u91CF\n\n // \u627E\u5230\u5F53\u524D\u89C6\u53E3\u4E2D\u6700\u9760\u8FD1\u9876\u90E8\u7684 section\n let currentSection = sections[0]\n\n for (const section of sections) {\n const element = section.element!\n const offsetTop = element.offsetTop\n\n if (scrollPosition >= offsetTop) {\n currentSection = section\n } else {\n break\n }\n }\n\n // \u66F4\u65B0\u6FC0\u6D3B\u72B6\u6001\n if (currentSection && currentSection.tab.id !== activeTab?.id) {\n setActiveTab(currentSection.tab)\n onActiveChange?.(currentSection.tab)\n }\n }\n\n // \u521D\u59CB\u5316\u65F6\u6267\u884C\u4E00\u6B21\n handleScroll()\n\n // \u6DFB\u52A0\u6EDA\u52A8\u76D1\u542C\n window.addEventListener('scroll', handleScroll, { passive: true })\n\n return () => {\n window.removeEventListener('scroll', handleScroll)\n }\n }, [tabs, activeTab?.id, onActiveChange])\n\n return { activeTab, setActiveTab }\n}\n\nconst MobileScrollSpyNav = ({ tabs, purchaseBarHeight, onSpyNavItemClick }: ScrollSpyNavProps) => {\n const [dropdownOpen, setDropdownOpen] = useState(false)\n const dropdownRef = useRef<HTMLDivElement>(null)\n const { renderRating } = useBizProductContext()\n\n // \u4F7F\u7528 useScrollSpy hook \u81EA\u52A8\u76D1\u542C\u6EDA\u52A8\n const { activeTab, setActiveTab } = useScrollSpy(tabs)\n\n const onTabClick = useCallback(\n (tab: ScrollSpyNavItem) => {\n setActiveTab(tab)\n onSpyNavItemClick?.(tab)\n setDropdownOpen(false)\n },\n [onSpyNavItemClick, setActiveTab]\n )\n\n const onDropdownOpen = useCallback(() => {\n setDropdownOpen(!dropdownOpen)\n gsap.fromTo(dropdownRef?.current, { height: 0 }, { height: 'auto', duration: 0.5, ease: 'power2.inOut' })\n }, [dropdownOpen])\n\n return (\n <div>\n <button\n className=\"text-sm h-[28px] font-bold flex gap-1 items-center leading-[28px] px-[10px] border rounded-full border-black\"\n onClick={onDropdownOpen}\n >\n {activeTab?.label}\n <ArrowDownIcon className=\"size-3\" />\n </button>\n <div\n className={cn('absolute top-full w-full flex flex-col z-[60] bg-black/60 left-0', {\n ['hidden']: !dropdownOpen,\n })}\n style={{\n height: `calc(100dvh - ${purchaseBarHeight}px)`,\n }}\n >\n <div ref={dropdownRef} className=\"border-t overflow-hidden border-[#E4E5E6] flex flex-col bg-white\">\n {tabs?.map(tab => (\n <button\n className=\"text-sm hover:bg-[#EAEAEC] p-4 text-left font-bold\"\n key={tab.id}\n onClick={() => onTabClick(tab)}\n >\n {tab.label}\n </button>\n ))}\n <button className=\"text-sm hover:bg-[#EAEAEC] p-4 text-left font-bold\">{renderRating}</button>\n </div>\n <div className=\"flex-1\" onClick={() => setDropdownOpen(false)} />\n </div>\n </div>\n )\n}\n\nconst DesktopScrollSpyNav = ({ tabs, onSpyNavItemClick }: ScrollSpyNavProps) => {\n // \u4F7F\u7528 useScrollSpy hook \u81EA\u52A8\u76D1\u542C\u6EDA\u52A8\n const { activeTab, setActiveTab } = useScrollSpy(tabs)\n\n const onTabClick = useCallback(\n (tab: ScrollSpyNavItem) => {\n setActiveTab(tab)\n onSpyNavItemClick?.(tab)\n },\n [onSpyNavItemClick, setActiveTab]\n )\n\n return (\n <div className=\"flex gap-8\">\n {tabs?.map(tab => (\n <button className=\"text-sm relative py-[10px] font-bold\" key={tab.id} onClick={() => onTabClick(tab)}>\n {tab.label}\n <div\n className={cn('absolute bottom-0 left-0 w-0 transition-all duration-300 ease-in-out h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A,EAAI,OAHAA,EAAI,EAIX,CACD,EACDlB,EAAC,UAAO,UAAU,qDAAsD,SAAA+B,EAAa,GACvF,EACA/B,EAAC,OAAI,UAAU,SAAS,QAAS,IAAM6B,EAAgB,EAAK,EAAG,GACjE,GACF,CAEJ,EAEMK,EAAsB,CAAC,CAAE,KAAAtB,EAAM,kBAAAe,CAAkB,IAAyB,CAE9E,KAAM,CAAE,UAAAb,EAAW,aAAAC,CAAa,EAAIJ,EAAaC,CAAI,EAE/CoB,EAAa5B,EAChBc,GAA0B,CACzBH,EAAaG,CAAG,EAChBS,IAAoBT,CAAG,CACzB,EACA,CAACS,EAAmBZ,CAAY,CAClC,EAEA,OACEf,EAAC,OAAI,UAAU,aACZ,SAAAY,GAAM,IAAIM,GACTjB,EAAC,UAAO,UAAU,uCAAoD,QAAS,IAAM+B,EAAWd,CAAG,EAChG,UAAAA,EAAI,MACLlB,EAAC,OACC,UAAWE,EAAG,0FAA2F,CACvG,SAAUY,GAAW,KAAOI,EAAI,EAClC,CAAC,EACH,IAN4DA,EAAI,EAOlE,CACD,EACH,CAEJ",
6
+ "names": ["jsx", "jsxs", "cn", "useState", "useCallback", "useRef", "useEffect", "gsap", "useBizProductContext", "ArrowDownIcon", "props", "useScrollSpy", "tabs", "onActiveChange", "activeTab", "setActiveTab", "handleScroll", "sections", "tab", "id", "item", "scrollPosition", "currentSection", "section", "offsetTop", "MobileScrollSpyNav", "purchaseBarHeight", "onSpyNavItemClick", "dropdownOpen", "setDropdownOpen", "dropdownRef", "renderRating", "onTabClick", "onDropdownOpen", "DesktopScrollSpyNav"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{useBizProductContext as h}from"../BizProductProvider";import{checkItemAvailableForProduct as C}from"../utils/helper";import{useDiscountEnable as D}from"./useDiscountEnable";import{useAiuiContext as v}from"../../AiuiProvider/index.js";import"react";const M=({variant:o})=>{const{coupon:u,product:r,bundle:t,freeGift:l,memberFunctionResult:i,creditsRedemptionAmount:s,discount:a,profile:m,savingDetail:p}=h(),{codeSavings:I}=a||{},{trackingData:n}=v(),d=Math.max(i?.withCouponMemberTotalSave??0,i?.withoutCouponMaxMemberTotalSave??0),c=D({profile:m,savingDetail:p,memberFunctionResult:i,discount:a}),g=!!(n?.paidShipping&&o.requiresShipping&&!o?.metafields?.global?.presell&&!o?.metafields?.global?.HideShipping),f=n?.freeGift,b=f?.excludeProducts?.map(e=>typeof e=="object"&&"sku"in e?e.sku:e)??[],B=n?.levelDiscount&&C({product:r,variant:o,item:n?.levelDiscount});return{commonCoupon:{enable:c.showCommonCoupon,config:u??{}},freeGift:{enable:!!l&&!!l?.giftList?.length,config:l},bundle:{enable:!!t&&!!t?.bundleList?.length&&Math.max(...t?.bundleList?.map(e=>e.savings??0))>0,config:t},memberDiscount:{enable:c.showMemberDiscount,config:{amount:d,description:i?.labels?.find(e=>e.key==="benefit_tab_string")?.value}},creditsRedemption:{enable:!!s&&s>0,config:{amount:s,label:n?.creditsRedemptionLabel}},paidShipping:{enable:g,config:{}},fullGift:{enable:!!(f&&!b.includes(o.sku)),config:f??{}},levelDiscount:{enable:!!B,config:n?.levelDiscount??{}}}};export{M as useBenefits};
1
+ import{useBizProductContext as b}from"../BizProductProvider";import{checkItemAvailableForProduct as B}from"../utils/helper";import{useDiscountEnable as h}from"./useDiscountEnable";import{useAiuiContext as C}from"../../AiuiProvider/index.js";import"react";const S=({variant:n})=>{const{coupon:a,product:u,bundle:t,freeGift:l,memberFunctionResult:i,creditsRedemptionAmount:s,discount:D,profile:r,savingDetail:I}=b(),{trackingData:o}=C(),m=Math.max(i?.withCouponMemberTotalSave??0,i?.withoutCouponMaxMemberTotalSave??0),c=h({profile:r,variant:n,memberFunctionResult:i,coupon:a}),p=!!(o?.paidShipping&&n.requiresShipping&&!n?.metafields?.global?.presell&&!n?.metafields?.global?.HideShipping),f=o?.freeGift,d=f?.excludeProducts?.map(e=>typeof e=="object"&&"sku"in e?e.sku:e)??[],g=o?.levelDiscount&&B({product:u,variant:n,item:o?.levelDiscount});return{commonCoupon:{enable:c.showCommonCoupon,config:a??{}},freeGift:{enable:!!l&&!!l?.giftList?.length,config:l},bundle:{enable:!!t&&!!t?.bundleList?.length&&Math.max(...t?.bundleList?.map(e=>e.savings??0))>0,config:t},memberDiscount:{enable:c.showMemberDiscount,config:{amount:m,description:i?.labels?.find(e=>e.key==="benefit_tab_string")?.value}},creditsRedemption:{enable:!!s&&s>0,config:{amount:s,label:o?.creditsRedemptionLabel}},paidShipping:{enable:p,config:{}},fullGift:{enable:!!(f&&!d.includes(n.sku)),config:f??{}},levelDiscount:{enable:!!g,config:o?.levelDiscount??{}}}};export{S as useBenefits};
2
2
  //# sourceMappingURL=useBenefits.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/biz-components/Listing/hooks/useBenefits.ts"],
4
- "sourcesContent": ["import { useBizProductContext } from '../BizProductProvider'\nimport type { ProductVariant, FreeGift, Bundle } from '../types/product'\nimport { checkItemAvailableForProduct } from '../utils/helper'\nimport { useDiscountEnable } from './useDiscountEnable'\n\nimport { useAiuiContext } from '../../AiuiProvider/index.js'\nimport { useMemo } from 'react'\n\ninterface BenefitsParams {\n variant: ProductVariant\n}\n\ninterface BenefitItemConfig<T extends Record<string, any> = Record<string, any>> {\n enable: boolean\n config?: T // \u539F\u59CB\u914D\u7F6E\n}\n\ninterface BenefitsResult {\n /**\n * \u901A\u7528\u4F18\u60E0\u5238\n */\n commonCoupon?: BenefitItemConfig\n /**\n * \u4E70\u8D60\n */\n freeGift: BenefitItemConfig<FreeGift>\n /**\n * \u6346\u7ED1\u6298\u6263\n */\n bundle: BenefitItemConfig<Bundle>\n /**\n * \u4F1A\u5458\u4EF7\n */\n memberDiscount: BenefitItemConfig\n /**\n * \u79EF\u5206\u62B5\u73B0\n */\n creditsRedemption: BenefitItemConfig\n /**\n * \u9AD8\u6807\u7269\u6D41\n */\n paidShipping: BenefitItemConfig\n\n /**\n * \u6EE1\u8D60\n */\n fullGift: BenefitItemConfig\n\n /**\n * \u6EE1\u51CF\u6298\u6263\n */\n levelDiscount: BenefitItemConfig\n}\n\n/**\n * \u5546\u54C1\u6743\u76CA\n * \u83B7\u53D6\u5F53\u524Dsku \u6240\u6709\u7684\u6743\u76CA\n * \u5305\u62EC \u901A\u7528\u4F18\u60E0\u5238\uFF0C\u4F1A\u5458\u4EF7\uFF0C\u6EE1\u51CF\uFF0C\u6346\u7ED1\u6298\u6263\uFF0C\u4E70\u8D60 \uFF0C\u6EE1\u8D60 \uFF0C\u79EF\u5206\u62B5\u73B0\n * @returns\n */\nexport const useBenefits = ({ variant }: BenefitsParams): BenefitsResult => {\n const {\n coupon,\n product,\n bundle,\n freeGift,\n memberFunctionResult,\n creditsRedemptionAmount,\n discount,\n profile,\n savingDetail,\n } = useBizProductContext()\n const { codeSavings } = discount || {}\n\n const { trackingData } = useAiuiContext()\n\n const total = Math.max(\n memberFunctionResult?.withCouponMemberTotalSave ?? 0,\n memberFunctionResult?.withoutCouponMaxMemberTotalSave ?? 0\n )\n\n const discountEnable = useDiscountEnable({ profile, savingDetail, memberFunctionResult, discount })\n\n // \u9AD8\u6807\u7269\u6D41\n const showPaidShipping = Boolean(\n trackingData?.paidShipping &&\n variant.requiresShipping &&\n !variant?.metafields?.global?.presell &&\n !variant?.metafields?.global?.HideShipping\n )\n\n // \u811A\u672C\u6EE1\u8D60\n const fullGift = trackingData?.freeGift\n const excludeProducts =\n fullGift?.excludeProducts?.map((item: any) => (typeof item === 'object' && 'sku' in item ? item.sku : item)) ?? []\n\n const showLevelDiscount =\n trackingData?.levelDiscount && checkItemAvailableForProduct({ product, variant, item: trackingData?.levelDiscount })\n\n\n return {\n commonCoupon: {\n enable: discountEnable.showCommonCoupon,\n config: coupon ?? {},\n },\n freeGift: {\n enable: Boolean(freeGift) && !!freeGift?.giftList?.length,\n config: freeGift,\n },\n bundle: {\n enable:\n Boolean(bundle) &&\n !!bundle?.bundleList?.length &&\n Math.max(...bundle?.bundleList?.map(item => item.savings ?? 0)) > 0, // \u6709\u4F18\u60E0\u624D\u5C55\u793A\n config: bundle,\n },\n memberDiscount: {\n enable: discountEnable.showMemberDiscount,\n // enable: total > 0,\n config: {\n amount: total,\n description: memberFunctionResult?.labels?.find((item: any) => item.key === 'benefit_tab_string')?.value,\n },\n },\n creditsRedemption: {\n enable: Boolean(creditsRedemptionAmount) && creditsRedemptionAmount! > 0,\n config: { amount: creditsRedemptionAmount, label: trackingData?.creditsRedemptionLabel },\n },\n paidShipping: {\n enable: showPaidShipping,\n config: {},\n },\n fullGift: {\n enable: Boolean(fullGift && !excludeProducts.includes(variant.sku)),\n config: fullGift ?? {},\n },\n levelDiscount: {\n enable: Boolean(showLevelDiscount),\n config: trackingData?.levelDiscount ?? {},\n },\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,wBAAAA,MAA4B,wBAErC,OAAS,gCAAAC,MAAoC,kBAC7C,OAAS,qBAAAC,MAAyB,sBAElC,OAAS,kBAAAC,MAAsB,8BAC/B,MAAwB,QAsDjB,MAAMC,EAAc,CAAC,CAAE,QAAAC,CAAQ,IAAsC,CAC1E,KAAM,CACJ,OAAAC,EACA,QAAAC,EACA,OAAAC,EACA,SAAAC,EACA,qBAAAC,EACA,wBAAAC,EACA,SAAAC,EACA,QAAAC,EACA,aAAAC,CACF,EAAId,EAAqB,EACnB,CAAE,YAAAe,CAAY,EAAIH,GAAY,CAAC,EAE/B,CAAE,aAAAI,CAAa,EAAIb,EAAe,EAElCc,EAAQ,KAAK,IACjBP,GAAsB,2BAA6B,EACnDA,GAAsB,iCAAmC,CAC3D,EAEMQ,EAAiBhB,EAAkB,CAAE,QAAAW,EAAS,aAAAC,EAAc,qBAAAJ,EAAsB,SAAAE,CAAS,CAAC,EAG5FO,EAAmB,GACvBH,GAAc,cACZX,EAAQ,kBACR,CAACA,GAAS,YAAY,QAAQ,SAC9B,CAACA,GAAS,YAAY,QAAQ,cAI5Be,EAAWJ,GAAc,SACzBK,EACJD,GAAU,iBAAiB,IAAKE,GAAe,OAAOA,GAAS,UAAY,QAASA,EAAOA,EAAK,IAAMA,CAAK,GAAK,CAAC,EAE7GC,EACJP,GAAc,eAAiBf,EAA6B,CAAE,QAAAM,EAAS,QAAAF,EAAS,KAAMW,GAAc,aAAc,CAAC,EAGrH,MAAO,CACL,aAAc,CACZ,OAAQE,EAAe,iBACvB,OAAQZ,GAAU,CAAC,CACrB,EACA,SAAU,CACR,OAAQ,EAAQG,GAAa,CAAC,CAACA,GAAU,UAAU,OACnD,OAAQA,CACV,EACA,OAAQ,CACN,OACE,EAAQD,GACR,CAAC,CAACA,GAAQ,YAAY,QACtB,KAAK,IAAI,GAAGA,GAAQ,YAAY,IAAIc,GAAQA,EAAK,SAAW,CAAC,CAAC,EAAI,EACpE,OAAQd,CACV,EACA,eAAgB,CACd,OAAQU,EAAe,mBAEvB,OAAQ,CACN,OAAQD,EACR,YAAaP,GAAsB,QAAQ,KAAMY,GAAcA,EAAK,MAAQ,oBAAoB,GAAG,KACrG,CACF,EACA,kBAAmB,CACjB,OAAQ,EAAQX,GAA4BA,EAA2B,EACvE,OAAQ,CAAE,OAAQA,EAAyB,MAAOK,GAAc,sBAAuB,CACzF,EACA,aAAc,CACZ,OAAQG,EACR,OAAQ,CAAC,CACX,EACA,SAAU,CACR,OAAQ,GAAQC,GAAY,CAACC,EAAgB,SAAShB,EAAQ,GAAG,GACjE,OAAQe,GAAY,CAAC,CACvB,EACA,cAAe,CACb,OAAQ,EAAQG,EAChB,OAAQP,GAAc,eAAiB,CAAC,CAC1C,CACF,CACF",
6
- "names": ["useBizProductContext", "checkItemAvailableForProduct", "useDiscountEnable", "useAiuiContext", "useBenefits", "variant", "coupon", "product", "bundle", "freeGift", "memberFunctionResult", "creditsRedemptionAmount", "discount", "profile", "savingDetail", "codeSavings", "trackingData", "total", "discountEnable", "showPaidShipping", "fullGift", "excludeProducts", "item", "showLevelDiscount"]
4
+ "sourcesContent": ["import { useBizProductContext } from '../BizProductProvider'\nimport type { ProductVariant, FreeGift, Bundle } from '../types/product'\nimport { checkItemAvailableForProduct } from '../utils/helper'\nimport { useDiscountEnable } from './useDiscountEnable'\n\nimport { useAiuiContext } from '../../AiuiProvider/index.js'\nimport { useMemo } from 'react'\n\ninterface BenefitsParams {\n variant: ProductVariant\n}\n\ninterface BenefitItemConfig<T extends Record<string, any> = Record<string, any>> {\n enable: boolean\n config?: T // \u539F\u59CB\u914D\u7F6E\n}\n\ninterface BenefitsResult {\n /**\n * \u901A\u7528\u4F18\u60E0\u5238\n */\n commonCoupon?: BenefitItemConfig\n /**\n * \u4E70\u8D60\n */\n freeGift: BenefitItemConfig<FreeGift>\n /**\n * \u6346\u7ED1\u6298\u6263\n */\n bundle: BenefitItemConfig<Bundle>\n /**\n * \u4F1A\u5458\u4EF7\n */\n memberDiscount: BenefitItemConfig\n /**\n * \u79EF\u5206\u62B5\u73B0\n */\n creditsRedemption: BenefitItemConfig\n /**\n * \u9AD8\u6807\u7269\u6D41\n */\n paidShipping: BenefitItemConfig\n\n /**\n * \u6EE1\u8D60\n */\n fullGift: BenefitItemConfig\n\n /**\n * \u6EE1\u51CF\u6298\u6263\n */\n levelDiscount: BenefitItemConfig\n}\n\n/**\n * \u5546\u54C1\u6743\u76CA\n * \u83B7\u53D6\u5F53\u524Dsku \u6240\u6709\u7684\u6743\u76CA\n * \u5305\u62EC \u901A\u7528\u4F18\u60E0\u5238\uFF0C\u4F1A\u5458\u4EF7\uFF0C\u6EE1\u51CF\uFF0C\u6346\u7ED1\u6298\u6263\uFF0C\u4E70\u8D60 \uFF0C\u6EE1\u8D60 \uFF0C\u79EF\u5206\u62B5\u73B0\n * @returns\n */\nexport const useBenefits = ({ variant }: BenefitsParams): BenefitsResult => {\n const {\n coupon,\n product,\n bundle,\n freeGift,\n memberFunctionResult,\n creditsRedemptionAmount,\n discount,\n profile,\n savingDetail,\n } = useBizProductContext()\n\n const { trackingData } = useAiuiContext()\n\n const total = Math.max(\n memberFunctionResult?.withCouponMemberTotalSave ?? 0,\n memberFunctionResult?.withoutCouponMaxMemberTotalSave ?? 0\n )\n\n const discountEnable = useDiscountEnable({ profile, variant, memberFunctionResult, coupon })\n\n // \u9AD8\u6807\u7269\u6D41\n const showPaidShipping = Boolean(\n trackingData?.paidShipping &&\n variant.requiresShipping &&\n !variant?.metafields?.global?.presell &&\n !variant?.metafields?.global?.HideShipping\n )\n\n // \u811A\u672C\u6EE1\u8D60\n const fullGift = trackingData?.freeGift\n const excludeProducts =\n fullGift?.excludeProducts?.map((item: any) => (typeof item === 'object' && 'sku' in item ? item.sku : item)) ?? []\n\n const showLevelDiscount =\n trackingData?.levelDiscount && checkItemAvailableForProduct({ product, variant, item: trackingData?.levelDiscount })\n\n\n return {\n commonCoupon: {\n enable: discountEnable.showCommonCoupon,\n config: coupon ?? {},\n },\n freeGift: {\n enable: Boolean(freeGift) && !!freeGift?.giftList?.length,\n config: freeGift,\n },\n bundle: {\n enable:\n Boolean(bundle) &&\n !!bundle?.bundleList?.length &&\n Math.max(...bundle?.bundleList?.map(item => item.savings ?? 0)) > 0, // \u6709\u4F18\u60E0\u624D\u5C55\u793A\n config: bundle,\n },\n memberDiscount: {\n enable: discountEnable.showMemberDiscount,\n // enable: total > 0,\n config: {\n amount: total,\n description: memberFunctionResult?.labels?.find((item: any) => item.key === 'benefit_tab_string')?.value,\n },\n },\n creditsRedemption: {\n enable: Boolean(creditsRedemptionAmount) && creditsRedemptionAmount! > 0,\n config: { amount: creditsRedemptionAmount, label: trackingData?.creditsRedemptionLabel },\n },\n paidShipping: {\n enable: showPaidShipping,\n config: {},\n },\n fullGift: {\n enable: Boolean(fullGift && !excludeProducts.includes(variant.sku)),\n config: fullGift ?? {},\n },\n levelDiscount: {\n enable: Boolean(showLevelDiscount),\n config: trackingData?.levelDiscount ?? {},\n },\n }\n}\n"],
5
+ "mappings": "AAAA,OAAS,wBAAAA,MAA4B,wBAErC,OAAS,gCAAAC,MAAoC,kBAC7C,OAAS,qBAAAC,MAAyB,sBAElC,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B,CACjB,OAAQ,EAAQV,GAA4BA,EAA2B,EACvE,OAAQ,CAAE,OAAQA,EAAyB,MAAOI,GAAc,sBAAuB,CACzF,EACA,aAAc,CACZ,OAAQG,EACR,OAAQ,CAAC,CACX,EACA,SAAU,CACR,OAAQ,GAAQC,GAAY,CAACC,EAAgB,SAASf,EAAQ,GAAG,GACjE,OAAQc,GAAY,CAAC,CACvB,EACA,cAAe,CACb,OAAQ,EAAQG,EAChB,OAAQP,GAAc,eAAiB,CAAC,CAC1C,CACF,CACF",
6
+ "names": ["useBizProductContext", "checkItemAvailableForProduct", "useDiscountEnable", "useAiuiContext", "useBenefits", "variant", "coupon", "product", "bundle", "freeGift", "memberFunctionResult", "creditsRedemptionAmount", "discount", "profile", "savingDetail", "trackingData", "total", "discountEnable", "showPaidShipping", "fullGift", "excludeProducts", "item", "showLevelDiscount"]
7
7
  }
@@ -1,14 +1,14 @@
1
- import type { SavingDetail, FunctionMemberPriceResult, UserProfile } from '../BizProductProvider';
2
- import type { DiscountData } from '../types';
1
+ import type { FunctionMemberPriceResult, UserProfile } from '../BizProductProvider';
2
+ import type { VariantCoupon, ProductVariant } from '../types/product';
3
3
  interface DiscountEnableResult {
4
4
  showMemberDiscount: boolean;
5
5
  showCommonCoupon: boolean;
6
6
  }
7
7
  interface DiscountEnableParams {
8
8
  profile?: UserProfile;
9
- savingDetail: SavingDetail;
9
+ variant: ProductVariant;
10
10
  memberFunctionResult?: FunctionMemberPriceResult;
11
- discount?: DiscountData;
11
+ coupon?: VariantCoupon;
12
12
  }
13
- export declare const useDiscountEnable: ({ profile, savingDetail, memberFunctionResult, discount, }: DiscountEnableParams) => DiscountEnableResult;
13
+ export declare const useDiscountEnable: ({ profile, variant, memberFunctionResult, coupon, }: DiscountEnableParams) => DiscountEnableResult;
14
14
  export {};
@@ -1,2 +1,2 @@
1
- const l=({profile:a,savingDetail:n,memberFunctionResult:t,discount:s})=>{let e=!1,o=!1;const i=!!a?.email,r=n?.member??0,u=n?.coupon??0;return t?.withoutCouponMaxMemberTotalSave?i?r>u?(e=!0,o=!1):(e=!1,o=!0):t?.withoutCouponMaxMemberTotalSave>(s?.codeSavings||0)?(e=!0,o=!0):(e=!1,o=!0):t?.withCouponMemberTotalSave&&(e=!0,o=!0),{showMemberDiscount:e,showCommonCoupon:o}};export{l as useDiscountEnable};
1
+ import l from"decimal.js";const m=({profile:i,variant:u,memberFunctionResult:t,coupon:s})=>{let e=!1,o=!1;const r=!!i?.email,n=new l(u?.price?.amount).minus(s?.variant_price4wscode||0).toNumber();if(t?.withoutCouponMaxMemberTotalSave){const a=t?.withoutCouponMaxMemberTotalSave||0;r?a>n?(e=!0,o=!1):(e=!1,o=!0):a>n?(e=!0,o=!0):(e=!1,o=!0)}else t?.withCouponMemberTotalSave&&(e=!0,o=!0);return{showMemberDiscount:e,showCommonCoupon:o}};export{m as useDiscountEnable};
2
2
  //# sourceMappingURL=useDiscountEnable.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/biz-components/Listing/hooks/useDiscountEnable.ts"],
4
- "sourcesContent": ["import type { SavingDetail, FunctionMemberPriceResult, UserProfile } from '../BizProductProvider'\nimport type { DiscountData } from '../types'\ninterface DiscountEnableResult {\n showMemberDiscount: boolean\n showCommonCoupon: boolean\n}\n\ninterface DiscountEnableParams {\n profile?: UserProfile\n savingDetail: SavingDetail\n memberFunctionResult?: FunctionMemberPriceResult\n discount?: DiscountData\n}\n\n// withCouponMemberTotalSave \u4E0D\u4E3A0\u65F6\uFF0C\u4F1A\u5458\u4EF7\u53EF\u53E0\u52A0\n// withoutCouponMaxMemberTotalSave \u4E0D\u4E3A0\u65F6\uFF0C\u4F1A\u5458\u4EF7\u4E0D\u53EF\u53E0\u52A0\nexport const useDiscountEnable = ({\n profile,\n savingDetail,\n memberFunctionResult,\n discount,\n}: DiscountEnableParams): DiscountEnableResult => {\n let showMemberDiscount = false // \u662F\u5426\u5C55\u793A\u4F1A\u5458\u4EF7\u6298\u6263\n let showCommonCoupon = false // \u662F\u5426\u5C55\u793Acode\u6298\u6263\n const isLoggedIn = Boolean(profile?.email) // \u662F\u5426\u767B\u5F55\n const memberSaving = savingDetail?.member ?? 0 // \u4F1A\u5458\u4EF7\u6298\u6263\n const couponSaving = savingDetail?.coupon ?? 0 // code\u6298\u6263\n\n // \u5F53\u4F1A\u5458\u4EF7\u914D\u7F6E\u4E86\u4E0D\u53EF\u53E0\u52A0\u4EA7\u54C1\u6298\u6263\n // \u7528\u6237\u5DF2\u767B\u5F55\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D>\u300Ccode\u300D\n // \u5C55\u793A\u4F1A\u5458\u4EF7\u6298\u6263\n // \u4F1A\u5458\u4EF7\u6298\u6263\u9ED8\u8BA4\u52FE\u9009\n // code\u6298\u6263\u9690\u85CF\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D<=\u300Ccode\u300D\n // \u5C55\u793Acode\u6298\u6263\uFF0C\u6839\u636E\u6298\u6263\u524D\u7F00\u5224\u5B9A\u662F\u5426\u9ED8\u8BA4\u52FE\u9009\n // \u4F1A\u5458\u4EF7\u6298\u6263\u9690\u85CF\n // \u7528\u6237\u672A\u767B\u5F55\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D>\u300Ccode\u300D\n // \u5C55\u793A\u4F1A\u5458\u4EF7\u6298\u6263\u548Ccode\u6298\u6263\n // code\u6298\u6263\u6839\u636E\u6298\u6263\u524D\u7F00\u5224\u65AD\u662F\u5426\u9ED8\u8BA4\u52FE\u9009\n // \u4F1A\u5458\u4EF7\u6298\u6263\u4E0D\u9ED8\u8BA4\u52FE\u9009\uFF0C\u70B9\u51FB\u52FE\u9009\u8DF3\u51FA\u8BA2\u6CE8\u4E00\u4F53\u5F39\u7A97\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D<=\u300Ccode\u300D\n // \u5C55\u793Acode\u6298\u6263\uFF0C\u4F1A\u5458\u4EF7\u6298\u6263\u9690\u85CF\n\n // \u5F53\u4F1A\u5458\u4EF7\u914D\u7F6E\u4E86\u53EF\u53E0\u52A0\u4EA7\u54C1\u6298\u6263\n // \u7528\u6237\u5DF2\u767B\u5F55\n // \u5C55\u793A\u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D\u548C\u300Ccode\u300D\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D\u9ED8\u8BA4\u52FE\u9009\n // \u300Ccode\u300D\u6298\u6263\u6839\u636E\u524D\u7F00\u5224\u65AD\u662F\u5426\u52FE\u9009\n // \u7528\u6237\u672A\u767B\u5F55\n // \u5C55\u793A\u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D\u548C\u300Ccode\u300D\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D\u4E0D\u9ED8\u8BA4\u52FE\u9009\uFF0C\u70B9\u51FB\u52FE\u9009\u8DF3\u51FA\u8BA2\u6CE8\u4E00\u4F53\u5F39\u7A97\n // \u300Ccode\u300D\u6298\u6263\u6839\u636E\u524D\u7F00\u5224\u65AD\u662F\u5426\u52FE\u9009\n\n // \u4F1A\u5458\u4EF7\u4E0D\u53EF\u53E0\u52A0\u4EA7\u54C1\u6298\u6263\n if (memberFunctionResult?.withoutCouponMaxMemberTotalSave) {\n if (isLoggedIn) {\n // \u7528\u6237\u5DF2\u767B\u5F55\n if (memberSaving > couponSaving) {\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D>\u300Ccode\u300D\uFF1A\u5C55\u793A\u4F1A\u5458\u4EF7\u6298\u6263\uFF0Ccode\u6298\u6263\u9690\u85CF\n showMemberDiscount = true\n showCommonCoupon = false\n } else {\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D<=\u300Ccode\u300D\uFF1A\u5C55\u793Acode\u6298\u6263\uFF0C\u4F1A\u5458\u4EF7\u6298\u6263\u9690\u85CF\n showMemberDiscount = false\n showCommonCoupon = true\n }\n } else {\n // \u7528\u6237\u672A\u767B\u5F55\n if (memberFunctionResult?.withoutCouponMaxMemberTotalSave > (discount?.codeSavings || 0)) {\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D>\u300Ccode\u300D\uFF1A\u5C55\u793A\u4F1A\u5458\u4EF7\u6298\u6263\uFF0C\u5C55\u793Acode\u6298\u6263\n showMemberDiscount = true\n showCommonCoupon = true\n } else {\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D<=\u300Ccode\u300D\uFF1A\u5C55\u793Acode\u6298\u6263\uFF0C\u4F1A\u5458\u4EF7\u6298\u6263\u9690\u85CF\n showMemberDiscount = false\n showCommonCoupon = true\n }\n }\n }\n // \u4F1A\u5458\u4EF7\u53EF\u53E0\u52A0\u4EA7\u54C1\u6298\u6263\n else if (memberFunctionResult?.withCouponMemberTotalSave) {\n if (isLoggedIn) {\n // \u7528\u6237\u5DF2\u767B\u5F55\uFF1A\u5C55\u793A\u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D\u548C\u300Ccode\u300D\uFF0C\u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D\u9ED8\u8BA4\u52FE\u9009\uFF0C\u5C55\u793Acode\u6298\u6263\n showMemberDiscount = true\n showCommonCoupon = true\n } else {\n // \u7528\u6237\u672A\u767B\u5F55\uFF1A\u5C55\u793A\u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D\u548C\u300Ccode\u300D\n showMemberDiscount = true\n showCommonCoupon = true\n }\n }\n\n return { showMemberDiscount, showCommonCoupon }\n}\n"],
5
- "mappings": "AAgBO,MAAMA,EAAoB,CAAC,CAChC,QAAAC,EACA,aAAAC,EACA,qBAAAC,EACA,SAAAC,CACF,IAAkD,CAChD,IAAIC,EAAqB,GACrBC,EAAmB,GACvB,MAAMC,EAAa,EAAQN,GAAS,MAC9BO,EAAeN,GAAc,QAAU,EACvCO,EAAeP,GAAc,QAAU,EA8B7C,OAAIC,GAAsB,gCACpBI,EAEEC,EAAeC,GAEjBJ,EAAqB,GACrBC,EAAmB,KAGnBD,EAAqB,GACrBC,EAAmB,IAIjBH,GAAsB,iCAAmCC,GAAU,aAAe,IAEpFC,EAAqB,GACrBC,EAAmB,KAGnBD,EAAqB,GACrBC,EAAmB,IAKhBH,GAAsB,4BAG3BE,EAAqB,GACrBC,EAAmB,IAQhB,CAAE,mBAAAD,EAAoB,iBAAAC,CAAiB,CAChD",
6
- "names": ["useDiscountEnable", "profile", "savingDetail", "memberFunctionResult", "discount", "showMemberDiscount", "showCommonCoupon", "isLoggedIn", "memberSaving", "couponSaving"]
4
+ "sourcesContent": ["import type { SavingDetail, FunctionMemberPriceResult, UserProfile } from '../BizProductProvider'\nimport type { DiscountData } from '../types'\nimport type { VariantCoupon, ProductVariant } from '../types/product'\nimport Decimal from 'decimal.js'\ninterface DiscountEnableResult {\n showMemberDiscount: boolean\n showCommonCoupon: boolean\n}\n\ninterface DiscountEnableParams {\n profile?: UserProfile\n variant: ProductVariant\n memberFunctionResult?: FunctionMemberPriceResult\n coupon?: VariantCoupon\n}\n\n// withCouponMemberTotalSave \u4E0D\u4E3A0\u65F6\uFF0C\u4F1A\u5458\u4EF7\u53EF\u53E0\u52A0\n// withoutCouponMaxMemberTotalSave \u4E0D\u4E3A0\u65F6\uFF0C\u4F1A\u5458\u4EF7\u4E0D\u53EF\u53E0\u52A0\nexport const useDiscountEnable = ({\n profile,\n variant,\n memberFunctionResult,\n coupon,\n}: DiscountEnableParams): DiscountEnableResult => {\n let showMemberDiscount = false // \u662F\u5426\u5C55\u793A\u4F1A\u5458\u4EF7\u6298\u6263\n let showCommonCoupon = false // \u662F\u5426\u5C55\u793Acode\u6298\u6263\n const isLoggedIn = Boolean(profile?.email) // \u662F\u5426\u767B\u5F55\n const couponSaving = new Decimal(variant?.price?.amount).minus(coupon?.variant_price4wscode || 0).toNumber() // code\u6298\u6263\n\n // \u5F53\u4F1A\u5458\u4EF7\u914D\u7F6E\u4E86\u4E0D\u53EF\u53E0\u52A0\u4EA7\u54C1\u6298\u6263\n // \u7528\u6237\u5DF2\u767B\u5F55\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D>\u300Ccode\u300D\n // \u5C55\u793A\u4F1A\u5458\u4EF7\u6298\u6263\n // \u4F1A\u5458\u4EF7\u6298\u6263\u9ED8\u8BA4\u52FE\u9009\n // code\u6298\u6263\u9690\u85CF\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D<=\u300Ccode\u300D\n // \u5C55\u793Acode\u6298\u6263\uFF0C\u6839\u636E\u6298\u6263\u524D\u7F00\u5224\u5B9A\u662F\u5426\u9ED8\u8BA4\u52FE\u9009\n // \u4F1A\u5458\u4EF7\u6298\u6263\u9690\u85CF\n // \u7528\u6237\u672A\u767B\u5F55\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D>\u300Ccode\u300D\n // \u5C55\u793A\u4F1A\u5458\u4EF7\u6298\u6263\u548Ccode\u6298\u6263\n // code\u6298\u6263\u6839\u636E\u6298\u6263\u524D\u7F00\u5224\u65AD\u662F\u5426\u9ED8\u8BA4\u52FE\u9009\n // \u4F1A\u5458\u4EF7\u6298\u6263\u4E0D\u9ED8\u8BA4\u52FE\u9009\uFF0C\u70B9\u51FB\u52FE\u9009\u8DF3\u51FA\u8BA2\u6CE8\u4E00\u4F53\u5F39\u7A97\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D<=\u300Ccode\u300D\n // \u5C55\u793Acode\u6298\u6263\uFF0C\u4F1A\u5458\u4EF7\u6298\u6263\u9690\u85CF\n\n // \u5F53\u4F1A\u5458\u4EF7\u914D\u7F6E\u4E86\u53EF\u53E0\u52A0\u4EA7\u54C1\u6298\u6263\n // \u7528\u6237\u5DF2\u767B\u5F55\n // \u5C55\u793A\u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D\u548C\u300Ccode\u300D\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D\u9ED8\u8BA4\u52FE\u9009\n // \u300Ccode\u300D\u6298\u6263\u6839\u636E\u524D\u7F00\u5224\u65AD\u662F\u5426\u52FE\u9009\n // \u7528\u6237\u672A\u767B\u5F55\n // \u5C55\u793A\u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D\u548C\u300Ccode\u300D\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D\u4E0D\u9ED8\u8BA4\u52FE\u9009\uFF0C\u70B9\u51FB\u52FE\u9009\u8DF3\u51FA\u8BA2\u6CE8\u4E00\u4F53\u5F39\u7A97\n // \u300Ccode\u300D\u6298\u6263\u6839\u636E\u524D\u7F00\u5224\u65AD\u662F\u5426\u52FE\u9009\n\n // \u4F1A\u5458\u4EF7\u4E0D\u53EF\u53E0\u52A0\u4EA7\u54C1\u6298\u6263\n if (memberFunctionResult?.withoutCouponMaxMemberTotalSave) {\n const memberSaving = memberFunctionResult?.withoutCouponMaxMemberTotalSave || 0\n if (isLoggedIn) {\n // \u7528\u6237\u5DF2\u767B\u5F55\n if (memberSaving > couponSaving) {\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D>\u300Ccode\u300D\uFF1A\u5C55\u793A\u4F1A\u5458\u4EF7\u6298\u6263\uFF0Ccode\u6298\u6263\u9690\u85CF\n showMemberDiscount = true\n showCommonCoupon = false\n } else {\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D<=\u300Ccode\u300D\uFF1A\u5C55\u793Acode\u6298\u6263\uFF0C\u4F1A\u5458\u4EF7\u6298\u6263\u9690\u85CF\n showMemberDiscount = false\n showCommonCoupon = true\n }\n } else {\n // \u7528\u6237\u672A\u767B\u5F55\n if (memberSaving > couponSaving) {\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D>\u300Ccode\u300D\uFF1A\u5C55\u793A\u4F1A\u5458\u4EF7\u6298\u6263\uFF0C\u5C55\u793Acode\u6298\u6263\n showMemberDiscount = true\n showCommonCoupon = true\n } else {\n // \u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D<=\u300Ccode\u300D\uFF1A\u5C55\u793Acode\u6298\u6263\uFF0C\u4F1A\u5458\u4EF7\u6298\u6263\u9690\u85CF\n showMemberDiscount = false\n showCommonCoupon = true\n }\n }\n }\n // \u4F1A\u5458\u4EF7\u53EF\u53E0\u52A0\u4EA7\u54C1\u6298\u6263\n else if (memberFunctionResult?.withCouponMemberTotalSave) {\n if (isLoggedIn) {\n // \u7528\u6237\u5DF2\u767B\u5F55\uFF1A\u5C55\u793A\u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D\u548C\u300Ccode\u300D\uFF0C\u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D\u9ED8\u8BA4\u52FE\u9009\uFF0C\u5C55\u793Acode\u6298\u6263\n showMemberDiscount = true\n showCommonCoupon = true\n } else {\n // \u7528\u6237\u672A\u767B\u5F55\uFF1A\u5C55\u793A\u300C\u4F1A\u5458\u4EF7\u6298\u6263\u300D\u548C\u300Ccode\u300D\n showMemberDiscount = true\n showCommonCoupon = true\n }\n }\n\n return { showMemberDiscount, showCommonCoupon }\n}\n"],
5
+ "mappings": "AAGA,OAAOA,MAAa,aAeb,MAAMC,EAAoB,CAAC,CAChC,QAAAC,EACA,QAAAC,EACA,qBAAAC,EACA,OAAAC,CACF,IAAkD,CAChD,IAAIC,EAAqB,GACrBC,EAAmB,GACvB,MAAMC,EAAa,EAAQN,GAAS,MAC9BO,EAAe,IAAIT,EAAQG,GAAS,OAAO,MAAM,EAAE,MAAME,GAAQ,sBAAwB,CAAC,EAAE,SAAS,EA8B3G,GAAID,GAAsB,gCAAiC,CACzD,MAAMM,EAAeN,GAAsB,iCAAmC,EAC1EI,EAEEE,EAAeD,GAEjBH,EAAqB,GACrBC,EAAmB,KAGnBD,EAAqB,GACrBC,EAAmB,IAIjBG,EAAeD,GAEjBH,EAAqB,GACrBC,EAAmB,KAGnBD,EAAqB,GACrBC,EAAmB,GAGzB,MAESH,GAAsB,4BAG3BE,EAAqB,GACrBC,EAAmB,IAQvB,MAAO,CAAE,mBAAAD,EAAoB,iBAAAC,CAAiB,CAChD",
6
+ "names": ["Decimal", "useDiscountEnable", "profile", "variant", "memberFunctionResult", "coupon", "showMemberDiscount", "showCommonCoupon", "isLoggedIn", "couponSaving", "memberSaving"]
7
7
  }
@@ -20,6 +20,7 @@ export type CompareData = {
20
20
  show: boolean;
21
21
  };
22
22
  export type DiscountData = {
23
+ memberFunctionSaving: number;
23
24
  codeSavings: number;
24
25
  scriptSavings: number;
25
26
  totalSavings: number;
@@ -1,2 +1,2 @@
1
- "use client";import{jsx as i,jsxs as L}from"react/jsx-runtime";import F,{useEffect as O,useRef as n,useImperativeHandle as _}from"react";import{gsap as f}from"gsap";import{SplitText as v}from"gsap/dist/SplitText";import{ScrollTrigger as T}from"gsap/dist/ScrollTrigger";import{cn as k}from"../../helpers/utils.js";import{Heading as q}from"../../components/index.js";import{withLayout as A}from"../../shared/Styles.js";import"../../hooks/useExposure.js";import{trackUrlRef as G}from"../../shared/trackUrlRef.js";import{useInView as J}from"react-intersection-observer";const y="link",b="title",R=F.forwardRef(({data:E,className:H,as:M="h2"},N)=>{const{title:o,caption:s,theme:p,extensions:l,align:a="left"}=E,d=n(null),e=n(null),t=n(null),r=n(null),{ref:$,inView:g}=J();return _(N,()=>d.current),O(()=>{f.registerPlugin(v,T);function D(){if(!e.current)return;const P=e.current?.clientHeight||80;t.current&&t.current.revert(),r.current&&r.current.kill(),t.current=new v(e.current,{type:"words",wordsClass:"word"});const c=t.current.words;f.set(c,{opacity:0}),r.current=T.create({trigger:e.current,start:"bottom bottom-=4%",end:`bottom+=${P*1.5+60}px bottom-=4%`,scrub:!0,invalidateOnRefresh:!0,onUpdate:S=>{const z=S.progress,h=c.length||1,I=.5,m=1/h,x=m*(1-I),w=(h-1)*x+m,V=Math.min(1,w>0?z/w:0);c.forEach((U,j)=>{const B=j*x,C=m;let u=(V-B)/C;u=Math.max(0,Math.min(1,u)),f.set(U,{opacity:u})})}})}return g&&D(),()=>{t.current&&t.current.revert(),r.current&&r.current.kill()}},[g]),(o||s)&&L("div",{className:"mb-6 flex items-end justify-between overflow-hidden title-box",ref:d,children:[i("div",{ref:$,className:k("space-y-4 flex-1",H,{"aiui-dark":p==="dark","text-center":a==="center","text-right":a==="right","text-left":a==="left"}),children:i(q,{ref:e,as:M,size:4,html:s||o})}),l?.textLink&&L("a",{className:k({"aiui-dark":p==="dark"},"flex items-center text-base font-[700] leading-[1.4] text-[#777] transition-all duration-[0.4s] hover:text-[#1D1D1F]"),href:G(l?.link,`${y}_${b}`),"data-headless-type-name":`${y}#${b}`,"data-headless-title-desc-button":`${o}#${s}`,children:[l?.textLink,i("svg",{width:"24",height:"24",className:"mb-[3px]",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",children:i("path",{className:"transition-all duration-[0.4s]",d:"M10.5 8L14.5 12L10.5 16",stroke:"#777","stroke-width":"1.5","stroke-linecap":"round"})})]})]})});R.displayName="Title";var ot=A(R);export{ot as default};
1
+ "use client";import{jsx as o,jsxs as L}from"react/jsx-runtime";import F,{useEffect as O,useRef as i,useImperativeHandle as _}from"react";import{gsap as f}from"gsap";import{SplitText as v}from"gsap/dist/SplitText";import{ScrollTrigger as T}from"gsap/dist/ScrollTrigger";import{cn as k}from"../../helpers/utils.js";import{Heading as q}from"../../components/index.js";import{withLayout as A}from"../../shared/Styles.js";import"../../hooks/useExposure.js";import{trackUrlRef as G}from"../../shared/trackUrlRef.js";import{useInView as J}from"react-intersection-observer";const y="link",b="title",R=F.forwardRef(({data:E,className:H,as:M="h2"},N)=>{const{title:s,caption:l,theme:p,extensions:n,align:a="left"}=E,d=i(null),e=i(null),t=i(null),r=i(null),{ref:$,inView:g}=J();return _(N,()=>d.current),O(()=>{f.registerPlugin(v,T);function D(){if(!e.current)return;const P=e.current?.clientHeight||80;t.current&&t.current.revert(),r.current&&r.current.kill(),t.current=new v(e.current,{type:"words",wordsClass:"word"});const c=t.current.words;f.set(c,{opacity:0}),r.current=T.create({trigger:e.current,start:"bottom bottom-=4%",end:`bottom+=${P*1.5+60}px bottom-=4%`,scrub:!0,invalidateOnRefresh:!0,onUpdate:S=>{const z=S.progress,h=c.length||1,I=.5,m=1/h,x=m*(1-I),w=(h-1)*x+m,V=Math.min(1,w>0?z/w:0);c.forEach((U,j)=>{const B=j*x,C=m;let u=(V-B)/C;u=Math.max(0,Math.min(1,u)),f.set(U,{opacity:u})})}})}return g&&D(),()=>{t.current&&t.current.revert(),r.current&&r.current.kill()}},[g]),(s||l)&&L("div",{id:n?.id,className:"mb-6 flex items-end justify-between overflow-hidden title-box",ref:d,children:[o("div",{ref:$,className:k("space-y-4 flex-1",H,{"aiui-dark":p==="dark","text-center":a==="center","text-right":a==="right","text-left":a==="left"}),children:o(q,{ref:e,as:M,size:4,html:l||s})}),n?.textLink&&L("a",{className:k({"aiui-dark":p==="dark"},"flex items-center text-base font-[700] leading-[1.4] text-[#777] transition-all duration-[0.4s] hover:text-[#1D1D1F]"),href:G(n?.link,`${y}_${b}`),"data-headless-type-name":`${y}#${b}`,"data-headless-title-desc-button":`${s}#${l}`,children:[n?.textLink,o("svg",{width:"24",height:"24",className:"mb-[3px]",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",children:o("path",{className:"transition-all duration-[0.4s]",d:"M10.5 8L14.5 12L10.5 16",stroke:"#777","stroke-width":"1.5","stroke-linecap":"round"})})]})]})});R.displayName="Title";var ot=A(R);export{ot as default};
2
2
  //# sourceMappingURL=index.js.map