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

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 (53) hide show
  1. package/dist/cjs/biz-components/FeatureCards/FeatureCards.js +1 -1
  2. package/dist/cjs/biz-components/FeatureCards/FeatureCards.js.map +3 -3
  3. package/dist/cjs/biz-components/FeatureCards/types.d.ts +2 -0
  4. package/dist/cjs/biz-components/FeatureCards/types.js +1 -1
  5. package/dist/cjs/biz-components/FeatureCards/types.js.map +1 -1
  6. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductSummary/index.js +1 -1
  7. package/dist/cjs/biz-components/Listing/components/ProductCard/ProductSummary/index.js.map +2 -2
  8. package/dist/cjs/biz-components/Listing/components/PurchaseBar/ProductActions/index.js +1 -1
  9. package/dist/cjs/biz-components/Listing/components/PurchaseBar/ProductActions/index.js.map +3 -3
  10. package/dist/cjs/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/index.js +1 -1
  11. package/dist/cjs/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/index.js.map +3 -3
  12. package/dist/cjs/biz-components/Listing/hooks/useBenefits.js +1 -1
  13. package/dist/cjs/biz-components/Listing/hooks/useBenefits.js.map +3 -3
  14. package/dist/cjs/biz-components/Listing/hooks/useDiscountEnable.d.ts +5 -5
  15. package/dist/cjs/biz-components/Listing/hooks/useDiscountEnable.js +1 -1
  16. package/dist/cjs/biz-components/Listing/hooks/useDiscountEnable.js.map +3 -3
  17. package/dist/cjs/biz-components/Listing/types.d.ts +1 -0
  18. package/dist/cjs/biz-components/Listing/types.js +1 -1
  19. package/dist/cjs/biz-components/Listing/types.js.map +1 -1
  20. package/dist/cjs/biz-components/Title/index.js +1 -1
  21. package/dist/cjs/biz-components/Title/index.js.map +2 -2
  22. package/dist/cjs/shared/ErrorBoundary.d.ts +18 -0
  23. package/dist/cjs/shared/ErrorBoundary.js +2 -0
  24. package/dist/cjs/shared/ErrorBoundary.js.map +7 -0
  25. package/dist/cjs/shared/Styles.js +1 -1
  26. package/dist/cjs/shared/Styles.js.map +3 -3
  27. package/dist/cjs/stories/featureCards.stories.js +21 -1
  28. package/dist/cjs/stories/featureCards.stories.js.map +3 -3
  29. package/dist/esm/biz-components/FeatureCards/FeatureCards.js +1 -1
  30. package/dist/esm/biz-components/FeatureCards/FeatureCards.js.map +3 -3
  31. package/dist/esm/biz-components/FeatureCards/types.d.ts +2 -0
  32. package/dist/esm/biz-components/Listing/components/ProductCard/ProductSummary/index.js +1 -1
  33. package/dist/esm/biz-components/Listing/components/ProductCard/ProductSummary/index.js.map +2 -2
  34. package/dist/esm/biz-components/Listing/components/PurchaseBar/ProductActions/index.js +1 -1
  35. package/dist/esm/biz-components/Listing/components/PurchaseBar/ProductActions/index.js.map +3 -3
  36. package/dist/esm/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/index.js +1 -1
  37. package/dist/esm/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/index.js.map +3 -3
  38. package/dist/esm/biz-components/Listing/hooks/useBenefits.js +1 -1
  39. package/dist/esm/biz-components/Listing/hooks/useBenefits.js.map +3 -3
  40. package/dist/esm/biz-components/Listing/hooks/useDiscountEnable.d.ts +5 -5
  41. package/dist/esm/biz-components/Listing/hooks/useDiscountEnable.js +1 -1
  42. package/dist/esm/biz-components/Listing/hooks/useDiscountEnable.js.map +3 -3
  43. package/dist/esm/biz-components/Listing/types.d.ts +1 -0
  44. package/dist/esm/biz-components/Title/index.js +1 -1
  45. package/dist/esm/biz-components/Title/index.js.map +2 -2
  46. package/dist/esm/shared/ErrorBoundary.d.ts +18 -0
  47. package/dist/esm/shared/ErrorBoundary.js +2 -0
  48. package/dist/esm/shared/ErrorBoundary.js.map +7 -0
  49. package/dist/esm/shared/Styles.js +1 -1
  50. package/dist/esm/shared/Styles.js.map +3 -3
  51. package/dist/esm/stories/featureCards.stories.js +22 -2
  52. package/dist/esm/stories/featureCards.stories.js.map +3 -3
  53. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";"use client";var b=Object.create;var o=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var H=(a,s)=>{for(var p in s)o(a,p,{get:s[p],enumerable:!0})},g=(a,s,p,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let l of F(s))!z.call(a,l)&&l!==p&&o(a,l,{get:()=>s[l],enumerable:!(i=C(s,l))||i.enumerable});return a};var $=(a,s,p)=>(p=a!=null?b(T(a)):{},g(s||!a||!a.__esModule?o(p,"default",{value:a,enumerable:!0}):p,a)),R=a=>g(o({},"__esModule",{value:!0}),a);var j={};H(j,{default:()=>S});module.exports=R(j);var e=require("react/jsx-runtime"),d=$(require("react")),r=require("../../components/index.js"),c=require("../../helpers/utils.js"),k=require("../../shared/Styles.js"),N=require("../../hooks/useExposure.js"),w=require("../../shared/trackUrlRef.js"),x=require("swiper/react");const n="image",f="feature_cards",v=d.default.forwardRef(({data:a,className:s},p)=>{const{title:i,subtitle:l,items:m=[]}=a,u=(0,d.useRef)(null);(0,N.useExposure)(u,{componentType:n,componentName:f,componentTitle:i,componentDescription:l}),(0,d.useImperativeHandle)(p,()=>u.current);const y=t=>{const _=(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(r.Picture,{source:t.image?.url,alt:t.image?.alt||t.title,className:"feature-cards__card-image absolute inset-0 !h-full",imgClassName:"!h-full object-cover"}),(0,e.jsxs)("div",{className:"feature-cards__card-content z-10",children:[(0,e.jsx)(r.Heading,{size:3,as:"h2",className:"feature-cards__card-title laptop:text-[20px] desktop:text-[32px] lg-desktop:text-[32px]",children:t.title}),(0,e.jsx)(r.Text,{size:4,as:"p",className:"feature-cards__card-subtitle mt-[4px] line-clamp-2 h-[40px] text-[14px] laptop:h-[44px] lg-desktop:text-[18px]",children:t.subtitle})]})]}),h=(0,c.cn)("feature-cards__card relative flex h-[360px] max-h-[560px] flex-1 flex-col justify-end gap-[16px] overflow-hidden rounded-[12px] px-[16px] py-[12px] text-info-primary tablet:h-[336px] laptop:h-[336px] laptop:px-[16px] laptop:py-[16px] desktop:h-[448px] desktop:rounded-[16px] desktop:px-[32px] desktop:py-[24px] lg-desktop:h-[560px]",{"aiui-dark":t.theme==="dark","aiui-light":t.theme==="light"});return t.link?(0,e.jsx)("a",{href:(0,w.trackUrlRef)(t.link,`${n}_${f}`),className:h,"data-headless-type-name":`${n}#${f}`,"data-headless-title-desc-button":`${i}#${t.title}#${t.subtitle}`,children:_}):(0,e.jsx)("div",{className:h,children:_})};return(0,e.jsxs)("section",{ref:u,"data-ui-component-id":"FeatureCards",className:(0,c.cn)("feature-cards flex w-full flex-col justify-center",s),children:[(0,e.jsxs)("div",{className:"feature-cards__header",children:[(0,e.jsx)(r.Heading,{size:4,as:"h1",className:"feature-cards__title text-left laptop:text-center",children:i}),l&&(0,e.jsx)(r.Text,{size:2,as:"p",className:"feature-cards__subtitle mt-[4px] text-left text-[14px] laptop:text-center desktop:text-[16px] lg-desktop:text-[18px]",children:l})]}),(0,e.jsx)("div",{className:"feature-cards__grid mt-[24px] hidden w-full gap-[16px] laptop:mt-[32px] laptop:flex desktop:mt-[40px] lg-desktop:mt-[24px]",children:m.map(t=>(0,e.jsx)(d.default.Fragment,{children:y(t)},t.title))}),(0,e.jsx)("div",{className:"feature-cards__swiper-container mt-[24px] w-full laptop:hidden",children:(0,e.jsx)(x.Swiper,{spaceBetween:12,slidesPerView:"auto",grabCursor:!0,className:"feature-cards__swiper relative w-full !overflow-visible",children:m.map(t=>(0,e.jsx)(x.SwiperSlide,{className:"feature-cards__swiper-slide relative !h-[360px] !w-[296px]",children:(0,e.jsxs)("div",{className:(0,c.cn)("feature-cards__card feature-cards__card--mobile absolute inset-0 flex flex-1 flex-col justify-end gap-[16px] overflow-hidden rounded-[12px] px-[16px] py-[12px] text-info-primary laptop:px-[16px] laptop:py-[16px] desktop:rounded-[16px] desktop:px-[32px] desktop:py-[24px]",{"aiui-dark":t.theme==="dark","aiui-light":t.theme==="light"}),children:[(0,e.jsx)(r.Picture,{source:t.image?.url,alt:t.image?.alt||t.title,className:"feature-cards__card-image absolute inset-0 !h-full",imgClassName:"!h-full object-cover"}),(0,e.jsxs)("div",{className:"feature-cards__card-content z-10",children:[(0,e.jsx)(r.Heading,{size:3,as:"h2",className:"feature-cards__card-title",children:t.title}),(0,e.jsx)(r.Text,{size:4,as:"p",className:"feature-cards__card-subtitle mt-[4px] line-clamp-2 h-[40px] overflow-visible text-[14px] laptop:h-[50px] lg-desktop:text-[18px]",children:t.subtitle})]})]},t.title)},t.title))})})]})});v.displayName="FeatureCards";var S=(0,k.withLayout)(v);
1
+ "use strict";"use client";var H=Object.create;var c=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var L=(e,r)=>{for(var s in r)c(e,s,{get:r[s],enumerable:!0})},b=(e,r,s,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let p of $(r))!j.call(e,p)&&p!==s&&c(e,p,{get:()=>r[p],enumerable:!(i=R(r,p))||i.enumerable});return e};var D=(e,r,s)=>(s=e!=null?H(S(e)):{},b(r||!e||!e.__esModule?c(s,"default",{value:e,enumerable:!0}):s,e)),E=e=>b(c({},"__esModule",{value:!0}),e);var B={};L(B,{default:()=>M});module.exports=E(B);var t=require("react/jsx-runtime"),o=D(require("react")),l=require("../../components/index.js"),n=require("../../helpers/utils.js"),k=require("../../shared/Styles.js"),w=require("../../hooks/useExposure.js"),y=require("../../shared/trackUrlRef.js"),f=require("swiper/react");const m="image",h="feature_cards",P=(e,r)=>r===2?e===0?"laptop:flex-[2]":"laptop:flex-[3]":r===3?"laptop:flex-[1]":r===4?e===0?"laptop:flex-[2]":e===1||e===2?"laptop:flex-[3]":"laptop:flex-[2]":r===5?e<3?"laptop:flex-[1]":e===3?"laptop:flex-[2]":"laptop:flex-[3]":"laptop:flex-[1]",I=(e,r)=>r===4&&e===1||r===5&&e===2,N=o.default.forwardRef(({data:e,className:r},s)=>{const{title:i,subtitle:p,items:u=[],rounded:C=!1}=e,x=(0,o.useRef)(null);(0,w.useExposure)(x,{componentType:m,componentName:h,componentTitle:i,componentDescription:p}),(0,o.useImperativeHandle)(s,()=>x.current);const _=C?"rounded-[12px] laptop:rounded-[16px]":"rounded-none",F=(a,d)=>{const g=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l.Picture,{source:a.image?.url,alt:a.image?.alt||a.title,className:"feature-cards__card-image absolute inset-0 !h-full",imgClassName:"!h-full object-cover"}),(0,t.jsxs)("div",{className:"feature-cards__card-content z-10",children:[(0,t.jsx)(l.Heading,{size:3,as:"h2",className:"feature-cards__card-title laptop:text-[20px] desktop:text-[32px] lg-desktop:text-[32px]",children:a.title}),(0,t.jsx)(l.Text,{size:4,as:"p",className:"feature-cards__card-subtitle mt-[4px] line-clamp-2 h-[40px] text-[14px] laptop:h-[44px] lg-desktop:text-[18px]",children:a.subtitle})]})]}),T="feature-cards__card relative flex h-[360px] max-h-[560px] flex-col justify-end gap-[16px] overflow-hidden px-[16px] py-[12px] text-info-primary tablet:h-[336px] laptop:h-[336px] laptop:px-[16px] laptop:py-[16px] desktop:h-[448px] desktop:px-[32px] desktop:py-[24px] lg-desktop:h-[560px]",z=d!==void 0?P(d,u.length):"flex-1",v=(0,n.cn)(T,_,z,{"aiui-dark":a.theme==="dark","aiui-light":a.theme==="light"});return a.link?(0,t.jsx)("a",{href:(0,y.trackUrlRef)(a.link,`${m}_${h}`),className:v,"data-headless-type-name":`${m}#${h}`,"data-headless-title-desc-button":`${i}#${a.title}#${a.subtitle}`,children:g}):(0,t.jsx)("div",{className:v,children:g})};return(0,t.jsxs)("section",{ref:x,"data-ui-component-id":"FeatureCards",className:(0,n.cn)("feature-cards flex w-full flex-col justify-center",r),children:[(0,t.jsxs)("div",{className:"feature-cards__header",children:[(0,t.jsx)(l.Heading,{size:4,as:"h1",className:"feature-cards__title text-left laptop:text-center",children:i}),p&&(0,t.jsx)(l.Text,{size:2,as:"p",className:"feature-cards__subtitle mt-[4px] text-left text-[14px] laptop:text-center desktop:text-[16px] lg-desktop:text-[18px]",children:p})]}),(0,t.jsx)("div",{className:"feature-cards__grid mt-[24px] hidden w-full flex-wrap gap-[16px] laptop:mt-[32px] laptop:flex desktop:mt-[40px] lg-desktop:mt-[24px]",children:u.map((a,d)=>(0,t.jsxs)(o.default.Fragment,{children:[F(a,d),I(d,u.length)&&(0,t.jsx)("div",{className:"laptop:basis-full laptop:h-0"})]},a.title))}),(0,t.jsx)("div",{className:"feature-cards__swiper-container mt-[24px] w-full laptop:hidden",children:(0,t.jsx)(f.Swiper,{spaceBetween:12,slidesPerView:"auto",grabCursor:!0,className:"feature-cards__swiper relative w-full !overflow-visible",children:u.map(a=>(0,t.jsx)(f.SwiperSlide,{className:"feature-cards__swiper-slide relative !h-[360px] !w-[296px]",children:(0,t.jsxs)("div",{className:(0,n.cn)("feature-cards__card feature-cards__card--mobile absolute inset-0 flex flex-1 flex-col justify-end gap-[16px] overflow-hidden px-[16px] py-[12px] text-info-primary",_,{"aiui-dark":a.theme==="dark","aiui-light":a.theme==="light"}),children:[(0,t.jsx)(l.Picture,{source:a.image?.url,alt:a.image?.alt||a.title,className:"feature-cards__card-image absolute inset-0 !h-full",imgClassName:"!h-full object-cover"}),(0,t.jsxs)("div",{className:"feature-cards__card-content z-10",children:[(0,t.jsx)(l.Heading,{size:3,as:"h2",className:"feature-cards__card-title",children:a.title}),(0,t.jsx)(l.Text,{size:4,as:"p",className:"feature-cards__card-subtitle mt-[4px] line-clamp-2 h-[40px] overflow-visible text-[14px] laptop:h-[50px] lg-desktop:text-[18px]",children:a.subtitle})]})]},a.title)},a.title))})})]})});N.displayName="FeatureCards";var M=(0,k.withLayout)(N);
2
2
  //# sourceMappingURL=FeatureCards.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/biz-components/FeatureCards/FeatureCards.tsx"],
4
- "sourcesContent": ["'use client'\nimport React, { useImperativeHandle, useRef } from 'react'\nimport { Heading, Picture, Text } from '../../components/index.js'\nimport { cn } from '../../helpers/utils.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { trackUrlRef } from '../../shared/trackUrlRef.js'\nimport type { FeatureCardsProps, FeatureCardItem } from './types.js'\nimport { Swiper, SwiperSlide } from 'swiper/react'\n\nconst componentType = 'image'\nconst componentName = 'feature_cards'\n\nconst FeatureCards = React.forwardRef<HTMLDivElement, FeatureCardsProps>(({ data, className }, ref) => {\n const { title, subtitle, items = [] } = data\n\n const boxRef = useRef<HTMLDivElement>(null)\n\n useExposure(boxRef, {\n componentType,\n componentName,\n componentTitle: title,\n componentDescription: subtitle,\n })\n\n useImperativeHandle(ref, () => boxRef.current as HTMLDivElement)\n\n const renderCard = (item: FeatureCardItem) => {\n const cardContent = (\n <>\n <Picture\n source={item.image?.url}\n alt={item.image?.alt || item.title}\n className=\"feature-cards__card-image absolute inset-0 !h-full\"\n imgClassName=\"!h-full object-cover\"\n />\n <div className=\"feature-cards__card-content z-10\">\n <Heading size={3} as=\"h2\" className=\"feature-cards__card-title laptop:text-[20px] desktop:text-[32px] lg-desktop:text-[32px]\">\n {item.title}\n </Heading>\n <Text\n size={4}\n as=\"p\"\n className=\"feature-cards__card-subtitle mt-[4px] line-clamp-2 h-[40px] text-[14px] laptop:h-[44px] lg-desktop:text-[18px]\"\n >\n {item.subtitle}\n </Text>\n </div>\n </>\n )\n\n const cardClasses = cn(\n 'feature-cards__card relative flex h-[360px] max-h-[560px] flex-1 flex-col justify-end gap-[16px] overflow-hidden rounded-[12px] px-[16px] py-[12px] text-info-primary tablet:h-[336px] laptop:h-[336px] laptop:px-[16px] laptop:py-[16px] desktop:h-[448px] desktop:rounded-[16px] desktop:px-[32px] desktop:py-[24px] lg-desktop:h-[560px]',\n {\n 'aiui-dark': item.theme === 'dark',\n 'aiui-light': item.theme === 'light',\n }\n )\n\n if (item.link) {\n return (\n <a\n href={trackUrlRef(item.link, `${componentType}_${componentName}`)}\n className={cardClasses}\n data-headless-type-name={`${componentType}#${componentName}`}\n data-headless-title-desc-button={`${title}#${item.title}#${item.subtitle}`}\n >\n {cardContent}\n </a>\n )\n }\n\n return <div className={cardClasses}>{cardContent}</div>\n }\n\n return (\n <section\n ref={boxRef}\n data-ui-component-id=\"FeatureCards\"\n className={cn('feature-cards flex w-full flex-col justify-center', className)}\n >\n {/* \u6807\u9898\u533A\u57DF */}\n <div className=\"feature-cards__header\">\n <Heading size={4} as=\"h1\" className=\"feature-cards__title text-left laptop:text-center\">\n {title}\n </Heading>\n {subtitle && (\n <Text\n size={2}\n as=\"p\"\n className=\"feature-cards__subtitle mt-[4px] text-left text-[14px] laptop:text-center desktop:text-[16px] lg-desktop:text-[18px]\"\n >\n {subtitle}\n </Text>\n )}\n </div>\n\n {/* \u684C\u9762\u7AEF\u7F51\u683C\u5E03\u5C40 */}\n <div className=\"feature-cards__grid mt-[24px] hidden w-full gap-[16px] laptop:mt-[32px] laptop:flex desktop:mt-[40px] lg-desktop:mt-[24px]\">\n {items.map(item => (\n <React.Fragment key={item.title}>{renderCard(item)}</React.Fragment>\n ))}\n </div>\n\n {/* \u79FB\u52A8\u7AEF Swiper \u5E03\u5C40 */}\n <div className=\"feature-cards__swiper-container mt-[24px] w-full laptop:hidden\">\n <Swiper spaceBetween={12} slidesPerView=\"auto\" grabCursor className=\"feature-cards__swiper relative w-full !overflow-visible\">\n {items.map(item => (\n <SwiperSlide key={item.title} className=\"feature-cards__swiper-slide relative !h-[360px] !w-[296px]\">\n <div\n key={item.title}\n className={cn(\n 'feature-cards__card feature-cards__card--mobile absolute inset-0 flex flex-1 flex-col justify-end gap-[16px] overflow-hidden rounded-[12px] px-[16px] py-[12px] text-info-primary laptop:px-[16px] laptop:py-[16px] desktop:rounded-[16px] desktop:px-[32px] desktop:py-[24px]',\n {\n 'aiui-dark': item.theme === 'dark',\n 'aiui-light': item.theme === 'light',\n }\n )}\n >\n <Picture\n source={item.image?.url}\n alt={item.image?.alt || item.title}\n className=\"feature-cards__card-image absolute inset-0 !h-full\"\n imgClassName=\"!h-full object-cover\"\n />\n <div className=\"feature-cards__card-content z-10\">\n <Heading size={3} as=\"h2\" className=\"feature-cards__card-title\">\n {item.title}\n </Heading>\n <Text\n size={4}\n as=\"p\"\n className=\"feature-cards__card-subtitle mt-[4px] line-clamp-2 h-[40px] overflow-visible text-[14px] laptop:h-[50px] lg-desktop:text-[18px]\"\n >\n {item.subtitle}\n </Text>\n </div>\n </div>\n </SwiperSlide>\n ))}\n </Swiper>\n </div>\n </section>\n )\n})\n\nFeatureCards.displayName = 'FeatureCards'\n\nexport default withLayout(FeatureCards)\n"],
5
- "mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA6BM,IAAAI,EAAA,6BA5BNC,EAAmD,oBACnDC,EAAuC,qCACvCC,EAAmB,kCACnBC,EAA2B,kCAC3BC,EAA4B,sCAC5BC,EAA4B,uCAE5BL,EAAoC,wBAEpC,MAAMM,EAAgB,QAChBC,EAAgB,gBAEhBC,EAAe,EAAAC,QAAM,WAA8C,CAAC,CAAE,KAAAC,EAAM,UAAAC,CAAU,EAAGC,IAAQ,CACrG,KAAM,CAAE,MAAAC,EAAO,SAAAC,EAAU,MAAAC,EAAQ,CAAC,CAAE,EAAIL,EAElCM,KAAS,UAAuB,IAAI,KAE1C,eAAYA,EAAQ,CAClB,cAAAV,EACA,cAAAC,EACA,eAAgBM,EAChB,qBAAsBC,CACxB,CAAC,KAED,uBAAoBF,EAAK,IAAMI,EAAO,OAAyB,EAE/D,MAAMC,EAAcC,GAA0B,CAC5C,MAAMC,KACJ,oBACE,oBAAC,WACC,OAAQD,EAAK,OAAO,IACpB,IAAKA,EAAK,OAAO,KAAOA,EAAK,MAC7B,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OAAO,IACpB,IAAKA,EAAK,OAAO,KAAOA,EAAK,MAC7B,UAAU,qDACV,aAAa,uBACf,KACA,QAAC,OAAI,UAAU,mCACb,oBAAC,WAAQ,KAAM,EAAG,GAAG,KAAK,UAAU,4BACjC,SAAAA,EAAK,MACR,KACA,OAAC,QACC,KAAM,EACN,GAAG,IACH,UAAU,kIAET,SAAAA,EAAK,SACR,GACF,IA1BKA,EAAK,KA2BZ,GA7BgBA,EAAK,KA8BvB,CACD,EACH,EACF,GACF,CAEJ,CAAC,EAEDV,EAAa,YAAc,eAE3B,IAAOX,KAAQ,cAAWW,CAAY",
6
- "names": ["FeatureCards_exports", "__export", "FeatureCards_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_components", "import_utils", "import_Styles", "import_useExposure", "import_trackUrlRef", "componentType", "componentName", "FeatureCards", "React", "data", "className", "ref", "title", "subtitle", "items", "boxRef", "renderCard", "item", "cardContent", "cardClasses"]
4
+ "sourcesContent": ["'use client'\nimport React, { useImperativeHandle, useRef } from 'react'\nimport { Heading, Picture, Text } from '../../components/index.js'\nimport { cn } from '../../helpers/utils.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { trackUrlRef } from '../../shared/trackUrlRef.js'\nimport type { FeatureCardsProps, FeatureCardItem } from './types.js'\nimport { Swiper, SwiperSlide } from 'swiper/react'\n\nconst componentType = 'image'\nconst componentName = 'feature_cards'\n\n/**\n * \u6839\u636E\u5361\u7247\u6570\u91CF\u83B7\u53D6\u684C\u9762\u7AEF\uFF08laptop+\uFF09\u7684\u7F51\u683C\u5E03\u5C40\u7C7B\u540D\n * - 2\u5F20\u5361\u7247: 2:3\n * - 3\u5F20\u5361\u7247: 1:1:1\n * - 4\u5F20\u5361\u7247: \u7B2C\u4E00\u884C 2:3\uFF0C\u7B2C\u4E8C\u884C 3:2\n * - 5\u5F20\u5361\u7247: \u7B2C\u4E00\u884C 1:1:1\uFF0C\u7B2C\u4E8C\u884C 2:3\n */\nconst getCardLayoutClasses = (index: number, totalCards: number): string => {\n if (totalCards === 2) {\n // 2:3 \u6BD4\u4F8B\n return index === 0 ? 'laptop:flex-[2]' : 'laptop:flex-[3]'\n }\n\n if (totalCards === 3) {\n // 1:1:1 \u6BD4\u4F8B\n return 'laptop:flex-[1]'\n }\n\n if (totalCards === 4) {\n // \u7B2C\u4E00\u884C 2:3\uFF0C\u7B2C\u4E8C\u884C 3:2\n if (index === 0) return 'laptop:flex-[2]'\n if (index === 1) return 'laptop:flex-[3]'\n if (index === 2) return 'laptop:flex-[3]'\n return 'laptop:flex-[2]'\n }\n\n if (totalCards === 5) {\n // \u7B2C\u4E00\u884C 1:1:1\uFF0C\u7B2C\u4E8C\u884C 2:3\n if (index < 3) return 'laptop:flex-[1]'\n if (index === 3) return 'laptop:flex-[2]'\n return 'laptop:flex-[3]'\n }\n\n // \u9ED8\u8BA4\u7B49\u5BBD\n return 'laptop:flex-[1]'\n}\n\n/**\n * \u6839\u636E\u5361\u7247\u6570\u91CF\u786E\u5B9A\u662F\u5426\u9700\u8981\u6362\u884C\n * - 4\u5F20\u5361\u7247: \u7B2C\u4E00\u884C2\u5F20\uFF0C\u7B2C\u4E8C\u884C2\u5F20\n * - 5\u5F20\u5361\u7247: \u7B2C\u4E00\u884C3\u5F20\uFF0C\u7B2C\u4E8C\u884C2\u5F20\n */\nconst shouldBreakRow = (index: number, totalCards: number): boolean => {\n if (totalCards === 4 && index === 1) return true\n if (totalCards === 5 && index === 2) return true\n return false\n}\n\nconst FeatureCards = React.forwardRef<HTMLDivElement, FeatureCardsProps>(({ data, className }, ref) => {\n const { title, subtitle, items = [], rounded = false } = data\n\n const boxRef = useRef<HTMLDivElement>(null)\n\n useExposure(boxRef, {\n componentType,\n componentName,\n componentTitle: title,\n componentDescription: subtitle,\n })\n\n useImperativeHandle(ref, () => boxRef.current as HTMLDivElement)\n\n // \u5706\u89D2\u7C7B\u540D\n const roundedClasses = rounded ? 'rounded-[12px] laptop:rounded-[16px]' : 'rounded-none'\n\n const renderCard = (item: FeatureCardItem, index?: number) => {\n const cardContent = (\n <>\n <Picture\n source={item.image?.url}\n alt={item.image?.alt || item.title}\n className=\"feature-cards__card-image absolute inset-0 !h-full\"\n imgClassName=\"!h-full object-cover\"\n />\n <div className=\"feature-cards__card-content z-10\">\n <Heading size={3} as=\"h2\" className=\"feature-cards__card-title laptop:text-[20px] desktop:text-[32px] lg-desktop:text-[32px]\">\n {item.title}\n </Heading>\n <Text\n size={4}\n as=\"p\"\n className=\"feature-cards__card-subtitle mt-[4px] line-clamp-2 h-[40px] text-[14px] laptop:h-[44px] lg-desktop:text-[18px]\"\n >\n {item.subtitle}\n </Text>\n </div>\n </>\n )\n\n // \u57FA\u7840\u6837\u5F0F\uFF08\u79FB\u9664\u539F\u6709\u7684 rounded \u7C7B\uFF09\n const baseClasses = 'feature-cards__card relative flex h-[360px] max-h-[560px] flex-col justify-end gap-[16px] overflow-hidden px-[16px] py-[12px] text-info-primary tablet:h-[336px] laptop:h-[336px] laptop:px-[16px] laptop:py-[16px] desktop:h-[448px] desktop:px-[32px] desktop:py-[24px] lg-desktop:h-[560px]'\n\n // \u83B7\u53D6\u54CD\u5E94\u5F0F\u5E03\u5C40\u7C7B\u540D\uFF08\u4EC5\u7528\u4E8E\u684C\u9762\u7AEF\uFF09\n const layoutClasses = index !== undefined ? getCardLayoutClasses(index, items.length) : 'flex-1'\n\n const cardClasses = cn(\n baseClasses,\n roundedClasses,\n layoutClasses,\n {\n 'aiui-dark': item.theme === 'dark',\n 'aiui-light': item.theme === 'light',\n }\n )\n\n if (item.link) {\n return (\n <a\n href={trackUrlRef(item.link, `${componentType}_${componentName}`)}\n className={cardClasses}\n data-headless-type-name={`${componentType}#${componentName}`}\n data-headless-title-desc-button={`${title}#${item.title}#${item.subtitle}`}\n >\n {cardContent}\n </a>\n )\n }\n\n return <div className={cardClasses}>{cardContent}</div>\n }\n\n return (\n <section\n ref={boxRef}\n data-ui-component-id=\"FeatureCards\"\n className={cn('feature-cards flex w-full flex-col justify-center', className)}\n >\n {/* \u6807\u9898\u533A\u57DF */}\n <div className=\"feature-cards__header\">\n <Heading size={4} as=\"h1\" className=\"feature-cards__title text-left laptop:text-center\">\n {title}\n </Heading>\n {subtitle && (\n <Text\n size={2}\n as=\"p\"\n className=\"feature-cards__subtitle mt-[4px] text-left text-[14px] laptop:text-center desktop:text-[16px] lg-desktop:text-[18px]\"\n >\n {subtitle}\n </Text>\n )}\n </div>\n\n {/* \u684C\u9762\u7AEF\u7F51\u683C\u5E03\u5C40 */}\n <div className=\"feature-cards__grid mt-[24px] hidden w-full flex-wrap gap-[16px] laptop:mt-[32px] laptop:flex desktop:mt-[40px] lg-desktop:mt-[24px]\">\n {items.map((item, index) => (\n <React.Fragment key={item.title}>\n {renderCard(item, index)}\n {/* \u5728\u7279\u5B9A\u4F4D\u7F6E\u63D2\u5165\u6362\u884C */}\n {shouldBreakRow(index, items.length) && <div className=\"laptop:basis-full laptop:h-0\" />}\n </React.Fragment>\n ))}\n </div>\n\n {/* \u79FB\u52A8\u7AEF Swiper \u5E03\u5C40 */}\n <div className=\"feature-cards__swiper-container mt-[24px] w-full laptop:hidden\">\n <Swiper spaceBetween={12} slidesPerView=\"auto\" grabCursor className=\"feature-cards__swiper relative w-full !overflow-visible\">\n {items.map(item => (\n <SwiperSlide key={item.title} className=\"feature-cards__swiper-slide relative !h-[360px] !w-[296px]\">\n <div\n key={item.title}\n className={cn(\n 'feature-cards__card feature-cards__card--mobile absolute inset-0 flex flex-1 flex-col justify-end gap-[16px] overflow-hidden px-[16px] py-[12px] text-info-primary',\n roundedClasses,\n {\n 'aiui-dark': item.theme === 'dark',\n 'aiui-light': item.theme === 'light',\n }\n )}\n >\n <Picture\n source={item.image?.url}\n alt={item.image?.alt || item.title}\n className=\"feature-cards__card-image absolute inset-0 !h-full\"\n imgClassName=\"!h-full object-cover\"\n />\n <div className=\"feature-cards__card-content z-10\">\n <Heading size={3} as=\"h2\" className=\"feature-cards__card-title\">\n {item.title}\n </Heading>\n <Text\n size={4}\n as=\"p\"\n className=\"feature-cards__card-subtitle mt-[4px] line-clamp-2 h-[40px] overflow-visible text-[14px] laptop:h-[50px] lg-desktop:text-[18px]\"\n >\n {item.subtitle}\n </Text>\n </div>\n </div>\n </SwiperSlide>\n ))}\n </Swiper>\n </div>\n </section>\n )\n})\n\nFeatureCards.displayName = 'FeatureCards'\n\nexport default withLayout(FeatureCards)\n"],
5
+ "mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAgFM,IAAAI,EAAA,6BA/ENC,EAAmD,oBACnDC,EAAuC,qCACvCC,EAAmB,kCACnBC,EAA2B,kCAC3BC,EAA4B,sCAC5BC,EAA4B,uCAE5BL,EAAoC,wBAEpC,MAAMM,EAAgB,QAChBC,EAAgB,gBAShBC,EAAuB,CAACC,EAAeC,IACvCA,IAAe,EAEVD,IAAU,EAAI,kBAAoB,kBAGvCC,IAAe,EAEV,kBAGLA,IAAe,EAEbD,IAAU,EAAU,kBACpBA,IAAU,GACVA,IAAU,EAAU,kBACjB,kBAGLC,IAAe,EAEbD,EAAQ,EAAU,kBAClBA,IAAU,EAAU,kBACjB,kBAIF,kBAQHE,EAAiB,CAACF,EAAeC,IACjCA,IAAe,GAAKD,IAAU,GAC9BC,IAAe,GAAKD,IAAU,EAI9BG,EAAe,EAAAC,QAAM,WAA8C,CAAC,CAAE,KAAAC,EAAM,UAAAC,CAAU,EAAGC,IAAQ,CACrG,KAAM,CAAE,MAAAC,EAAO,SAAAC,EAAU,MAAAC,EAAQ,CAAC,EAAG,QAAAC,EAAU,EAAM,EAAIN,EAEnDO,KAAS,UAAuB,IAAI,KAE1C,eAAYA,EAAQ,CAClB,cAAAf,EACA,cAAAC,EACA,eAAgBU,EAChB,qBAAsBC,CACxB,CAAC,KAED,uBAAoBF,EAAK,IAAMK,EAAO,OAAyB,EAG/D,MAAMC,EAAiBF,EAAU,uCAAyC,e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AI,UAAU,+BAA+B,IAHnEK,EAAK,KAI1B,CACD,EACH,KAGA,OAAC,OAAI,UAAU,iEACb,mBAAC,UAAO,aAAc,GAAI,cAAc,OAAO,WAAU,GAAC,UAAU,0DACjE,SAAAL,EAAM,IAAIK,MACT,OAAC,eAA6B,UAAU,6DACtC,oBAAC,OAEC,aAAW,MACT,qKACAF,EACA,CACE,YAAaE,EAAK,QAAU,OAC5B,aAAcA,EAAK,QAAU,OAC/B,CACF,EAEA,oBAAC,WACC,OAAQA,EAAK,OAAO,IACpB,IAAKA,EAAK,OAAO,KAAOA,EAAK,MAC7B,UAAU,qDACV,aAAa,uBACf,KACA,QAAC,OAAI,UAAU,mCACb,oBAAC,WAAQ,KAAM,EAAG,GAAG,KAAK,UAAU,4BACjC,SAAAA,EAAK,MACR,KACA,OAAC,QACC,KAAM,EACN,GAAG,IACH,UAAU,kIAET,SAAAA,EAAK,SACR,GACF,IA3BKA,EAAK,KA4BZ,GA9BgBA,EAAK,KA+BvB,CACD,EACH,EACF,GACF,CAEJ,CAAC,EAEDZ,EAAa,YAAc,eAE3B,IAAOf,KAAQ,cAAWe,CAAY",
6
+ "names": ["FeatureCards_exports", "__export", "FeatureCards_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_components", "import_utils", "import_Styles", "import_useExposure", "import_trackUrlRef", "componentType", "componentName", "getCardLayoutClasses", "index", "totalCards", "shouldBreakRow", "FeatureCards", "React", "data", "className", "ref", "title", "subtitle", "items", "rounded", "boxRef", "roundedClasses", "renderCard", "item", "cardContent", "baseClasses", "layoutClasses", "cardClasses"]
7
7
  }
@@ -19,6 +19,8 @@ export interface FeatureCardsProps {
19
19
  subtitle?: string;
20
20
  /** 卡片列表 */
21
21
  items: FeatureCardItem[];
22
+ /** 是否显示圆角,默认为 false(直角)。laptop 以下 12px,laptop 以上 16px */
23
+ rounded?: boolean;
22
24
  };
23
25
  /** 自定义类名 */
24
26
  className?: string;
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var g=(t,e,a,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of n(e))!p.call(t,r)&&r!==a&&s(t,r,{get:()=>e[r],enumerable:!(i=m(e,r))||i.enumerable});return t};var d=t=>g(s({},"__esModule",{value:!0}),t);var l={};module.exports=d(l);
1
+ "use strict";var a=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var d=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of m(e))!o.call(t,r)&&r!==s&&a(t,r,{get:()=>e[r],enumerable:!(i=n(e,r))||i.enumerable});return t};var p=t=>d(a({},"__esModule",{value:!0}),t);var g={};module.exports=p(g);
2
2
  //# sourceMappingURL=types.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/biz-components/FeatureCards/types.ts"],
4
- "sourcesContent": ["import type { Media, Theme } from '../../types/props.js'\n\nexport interface FeatureCardItem {\n /** \u5361\u7247\u6807\u9898 */\n title: string\n /** \u5361\u7247\u526F\u6807\u9898/\u63CF\u8FF0 */\n subtitle: string\n /** \u80CC\u666F\u56FE\u7247 URL */\n image: Media\n /** \u4E3B\u9898\uFF0C\u9ED8\u8BA4 light */\n theme?: Theme\n /** \u94FE\u63A5\u5730\u5740 */\n link?: string\n}\n\nexport interface FeatureCardsProps {\n data: {\n /** \u4E3B\u6807\u9898 */\n title: string\n /** \u526F\u6807\u9898/\u63CF\u8FF0 */\n subtitle?: string\n /** \u5361\u7247\u5217\u8868 */\n items: FeatureCardItem[]\n }\n /** \u81EA\u5B9A\u4E49\u7C7B\u540D */\n className?: string\n}\n"],
4
+ "sourcesContent": ["import type { Media, Theme } from '../../types/props.js'\n\nexport interface FeatureCardItem {\n /** \u5361\u7247\u6807\u9898 */\n title: string\n /** \u5361\u7247\u526F\u6807\u9898/\u63CF\u8FF0 */\n subtitle: string\n /** \u80CC\u666F\u56FE\u7247 URL */\n image: Media\n /** \u4E3B\u9898\uFF0C\u9ED8\u8BA4 light */\n theme?: Theme\n /** \u94FE\u63A5\u5730\u5740 */\n link?: string\n}\n\nexport interface FeatureCardsProps {\n data: {\n /** \u4E3B\u6807\u9898 */\n title: string\n /** \u526F\u6807\u9898/\u63CF\u8FF0 */\n subtitle?: string\n /** \u5361\u7247\u5217\u8868 */\n items: FeatureCardItem[]\n /** \u662F\u5426\u663E\u793A\u5706\u89D2\uFF0C\u9ED8\u8BA4\u4E3A false\uFF08\u76F4\u89D2\uFF09\u3002laptop \u4EE5\u4E0B 12px\uFF0Claptop \u4EE5\u4E0A 16px */\n rounded?: boolean\n }\n /** \u81EA\u5B9A\u4E49\u7C7B\u540D */\n className?: string\n}\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["types_exports", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var K=Object.create;var w=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var Z=(n,t)=>{for(var o in t)w(n,o,{get:t[o],enumerable:!0})},S=(n,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of U(t))!Y.call(n,s)&&s!==o&&w(n,s,{get:()=>t[s],enumerable:!(i=Q(t,s))||i.enumerable});return n};var _=(n,t,o)=>(o=n!=null?K(X(n)):{},S(t||!n||!n.__esModule?w(o,"default",{value:n,enumerable:!0}):o,n)),ee=n=>S(w({},"__esModule",{value:!0}),n);var le={};Z(le,{default:()=>ne});module.exports=ee(le);var e=require("react/jsx-runtime"),a=require("../../../../../components"),h=require("../../../BizProductProvider"),N=require("react"),p=require("../../../utils"),P=require("../../../../AiuiProvider"),se=require("../../../../../helpers"),A=_(require("decimal.js")),T=require("../../../utils/textFormat");const te=()=>{const{locale:n="us",copyWriting:t}=(0,P.useAiuiContext)(),{product:o,variant:i,finalPrice:s,comparePrice:m,coupon:b,selectedOptions:u,selectedVariants:r,totalSavings:k,onAddToCart:B,onBuyNow:D,savingDetail:v,checkedBundle:O,joinedRecommendBuyProducts:l,setJoinedRecommendBuyProducts:f,setCheckedGift:E,setCheckedExchangePurchase:x,setCheckedBundle:y,setSavingDetail:$,addToCartLoading:J,buyNowLoading:H,profile:F}=(0,h.useBizProductContext)(),[C]=r,M=(0,N.useMemo)(()=>{const d=O?.variants.find(q=>q.variant.sku===C?.sku),W=new A.default(C?.price?.amount||0).minus(d?.price||C?.price?.amount).toNumber();let z=new A.default(C?.price?.amount||0);return F?.email&&(z=z.minus(v?.member||0)),z.minus(v?.coupon).minus(W).toNumber()},[C,O,F,v?.member,v?.coupon]);if(!i.availableForSale)return null;const{bundleVariant:j,giftVariant:G,exchangeVariant:L}=ae()||{},[c,g]=(0,N.useState)();return(0,N.useEffect)(()=>{g({bundle:l.bundle?.value?void 0:j,gift:l.gift?.value?void 0:G,exchange:l.exchange?.value?void 0:L})},[j,G,L,l]),(0,e.jsx)("div",{className:"ipc-product-summary laptop:px-16 desktop:px-0 mt-16 desktop:mt-[96px] lg-desktop:mt-[128px]",children:(0,e.jsx)("div",{className:"bg-[#F5F5F7] laptop:rounded-2xl",children:(0,e.jsxs)(a.Grid,{className:"px-4 pt-6 tablet:p-8 tablet:!pb-0",children:[(0,e.jsxs)(a.GridItem,{className:"col-span-12 laptop:col-start-1 laptop:col-span-5 gap-4 flex flex-col justify-between",children:[(0,e.jsx)(a.Heading,{className:"font-bold text-[24px] lg-desktop:text-[48px] laptop:text-[32px] desktop:text-[40px] leading-[1] mb-4 [&>span]:text-[#D1D1D1]",html:`${o.title} is ready <br/><span>Just the way you want it.</span>`}),(0,e.jsx)("div",{className:"",children:(0,e.jsx)(a.Picture,{source:i.image?.url||o?.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"})})]}),(0,e.jsxs)(a.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",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"shrink-0 flex items-center gap-4",children:[(0,e.jsx)(a.Picture,{source:i.image?.url||o?.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"}),(0,e.jsxs)("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[(0,e.jsx)(a.Text,{className:"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]",html:o.title}),(0,e.jsx)(a.Text,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]",html:`x1 | ${u.color||u.colour||u.couleur}`})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl font-bold",html:(0,p.formatPrice)({amount:M,currencyCode:i.price.currencyCode,locale:n})}),k>0&&(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl laptop:text-xl font-bold line-through text-[#6D6D6F]",html:(0,p.formatPrice)({amount:i?.price?.amount,currencyCode:i.price.currencyCode,locale:n})})]})]}),l?.gift?.value&&(0,e.jsx)(R,{giftOperation:d=>{E?.(void 0),f?.({...l,gift:{value:void 0,canOperate:!0}}),g?.({...c,gift:d})},status:!!l?.gift,gift:l?.gift?.value,canOperate:l?.gift?.canOperate}),l?.bundle?.value&&(0,e.jsx)(V,{bundleOperation:d=>{y?.(void 0),f?.({...l,bundle:{value:void 0,canOperate:!0}}),g?.({...c,bundle:d})},status:!!l?.bundle,bundleListItem:l?.bundle?.value,canOperate:l?.bundle?.canOperate}),l?.exchange?.value&&(0,e.jsx)(I,{exchangeOperation:d=>{x?.(void 0),f?.({...l,exchange:{value:void 0,canOperate:!0}}),g?.({...c,exchange:d})},status:!!l?.exchange,canOperate:l?.exchange?.canOperate,exchange:l?.exchange?.value})]}),(c?.bundle||c?.gift||c?.exchange)&&(0,e.jsxs)("div",{className:"mt-6",children:[(0,e.jsx)(a.Text,{className:"text-sm desktop:text-[18px] font-bold",html:"Recommend Buy"}),(0,e.jsxs)("div",{className:"flex flex-col gap-6 mt-6",children:[c?.exchange&&(0,e.jsx)(I,{exchangeOperation:d=>{y?.(void 0),f?.({bundle:{value:void 0,canOperate:!0},gift:{value:l?.gift?.value,canOperate:!0},exchange:{value:d,canOperate:!0}}),g?.({...c,exchange:void 0})},canOperate:l?.exchange?.canOperate,status:!c?.exchange,exchange:c?.exchange}),c?.bundle&&(0,e.jsx)(V,{bundleOperation:d=>{E?.(void 0),x?.(void 0),$?.({...v,exchangePurchase:0}),f?.({gift:{value:void 0,canOperate:!0},exchange:{value:void 0,canOperate:!0},bundle:{value:d,canOperate:!0}}),g?.({...c,bundle:void 0})},canOperate:l?.bundle?.canOperate,status:!c?.bundle,bundleListItem:c?.bundle}),c?.gift&&(0,e.jsx)(R,{giftOperation:d=>{y?.(void 0),f?.({bundle:{value:void 0,canOperate:!0},exchange:{value:l?.exchange?.value,canOperate:!0},gift:{value:d,canOperate:!0}}),g?.({...c,gift:void 0})},canOperate:l?.gift?.canOperate,status:!c?.gift,gift:c?.gift})]})]})]}),(0,e.jsxs)("div",{className:"text-right",children:[(0,e.jsx)(a.Text,{className:"laptop:text-xl desktop:text-2xl font-bold text-right",html:`${(0,T.replaceTemplate)(t?.totalPrice||"",{amount:(0,p.formatPrice)({amount:s,currencyCode:i.price.currencyCode,locale:n})})}`}),k>0&&(0,e.jsx)(a.Text,{className:"text-base laptop:text-xl desktop:text-2xl ml-1 font-bold line-through text-[#6D6D6F]",html:(0,p.formatPrice)({amount:m,currencyCode:i.price.currencyCode,locale:n})}),(0,e.jsxs)("div",{className:"flex gap-3 mt-2 justify-end",children:[(0,e.jsx)(a.Button,{size:"lg",variant:"secondary",loading:J,className:"w-1/2 tablet:w-auto laptop:w-1/2 desktop:w-auto",onClick:()=>B?.(),children:t?.addToCart}),(0,e.jsx)(a.Button,{size:"lg",loading:H,variant:"primary",className:"w-1/2 tablet:w-auto laptop:w-1/2 desktop:w-auto",onClick:()=>D?.(),children:t?.shopNow})]})]})]})]})})})},ae=()=>{const{bundle:n,variant:t,checkedBundle:o,freeGift:i,checkedGift:s,exchangePurchase:m,checkedExchangePurchase:b}=(0,h.useBizProductContext)();let u,r,k;const{bundleList:B}=n||{},{giftList:D=[]}=i||{},{giftList:v=[]}=m||{},O=B?.filter(x=>x.variants.slice(1,x.variants.length).every(y=>y.variant.availableForSale))||[],[l]=O;u=o||l;const[f]=D?.filter(x=>x.availableForSale);r=s||f;const[E]=v?.filter(x=>x.availableForSale);return k=b||E,{bundleVariant:u,giftVariant:r,exchangeVariant:k}},V=({bundleOperation:n,bundleListItem:t,canOperate:o,status:i})=>{const{locale:s="us"}=(0,P.useAiuiContext)(),{variant:m,setCheckedBundle:b}=(0,h.useBizProductContext)(),u=t?.variants.filter(r=>r.variant.sku!==m.sku);return(0,e.jsx)("div",{className:"",children:u?.map(r=>(0,e.jsxs)("div",{className:"flex items-center gap-4 justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)(a.Picture,{source:r?.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"}),(0,e.jsx)("div",{className:"flex flex-col gap-[6px] line-clamp-2 max-w-[178px] tablet:max-w-none",children:(0,e.jsx)(a.Text,{className:"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]",html:r.variant.product.title})})]}),(0,e.jsxs)("div",{className:"flex flex-col items-end gap-1 justify-center",children:[!!t&&(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl font-bold",html:(0,p.formatPrice)({amount:r?.price||0,locale:s,currencyCode:r.variant?.price?.currencyCode||""})}),(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:(0,p.formatPrice)({amount:r.variant.price.amount||0,locale:s,currencyCode:r.variant?.price?.currencyCode||""})})]}),o&&(0,e.jsx)(a.Button,{size:"icon",variant:"link",onClick:()=>{b?.(i?void 0:t),n?.(t)},className:"shrink-0 size-auto underline",children:i?"Remove":"Add"})]})]},r.variant.id))})},R=({giftOperation:n,gift:t,status:o,canOperate:i})=>{const{locale:s="us"}=(0,P.useAiuiContext)(),{freeGift:m,setCheckedGift:b}=(0,h.useBizProductContext)(),{freeLabel:u,count:r}=m||{};return(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)(a.Picture,{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"}),(0,e.jsxs)("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[(0,e.jsx)(a.Text,{className:"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]",html:t?.product?.title}),(0,e.jsx)(a.Text,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]",html:`x${r} | ${u}`})]})]}),(0,e.jsxs)("div",{className:"flex flex-col items-end gap-2 justify-center",children:[!!t&&(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl font-bold",html:u}),(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:(0,p.formatPrice)({amount:t.price.amount,locale:s,currencyCode:t.price.currencyCode})})]}),i&&(0,e.jsx)(a.Button,{size:"icon",variant:"link",onClick:()=>{b?.(o?void 0:t),n(t)},className:"shrink-0 size-auto underline",children:o?"Remove":"Add"})]})]})},I=({exchangeOperation:n,exchange:t,canOperate:o,status:i})=>{const{locale:s="us"}=(0,P.useAiuiContext)(),{setCheckedExchangePurchase:m}=(0,h.useBizProductContext)();return(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)(a.Picture,{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"}),(0,e.jsxs)("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[(0,e.jsx)(a.Text,{className:"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]",html:t?.product?.title}),(0,e.jsx)(a.Text,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]"})]})]}),(0,e.jsxs)("div",{className:"flex flex-col items-end gap-2 justify-center",children:[!!t&&(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl font-bold",html:(0,p.formatPrice)({amount:t.finalPrice?.amount||0,locale:s,currencyCode:t.price.currencyCode})}),(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:(0,p.formatPrice)({amount:t.price?.amount||0,locale:s,currencyCode:t.price.currencyCode})})]}),o&&(0,e.jsx)(a.Button,{size:"icon",variant:"link",onClick:()=>{m?.(i?void 0:t),n(t)},className:"shrink-0 size-auto underline",children:i?"Remove":"Add"})]})]})};var ne=te;
1
+ "use strict";var K=Object.create;var w=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var Z=(n,t)=>{for(var o in t)w(n,o,{get:t[o],enumerable:!0})},S=(n,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of U(t))!Y.call(n,r)&&r!==o&&w(n,r,{get:()=>t[r],enumerable:!(i=Q(t,r))||i.enumerable});return n};var _=(n,t,o)=>(o=n!=null?K(X(n)):{},S(t||!n||!n.__esModule?w(o,"default",{value:n,enumerable:!0}):o,n)),ee=n=>S(w({},"__esModule",{value:!0}),n);var le={};Z(le,{default:()=>ne});module.exports=ee(le);var e=require("react/jsx-runtime"),a=require("../../../../../components"),h=require("../../../BizProductProvider"),N=require("react"),p=require("../../../utils"),P=require("../../../../AiuiProvider"),se=require("../../../../../helpers"),A=_(require("decimal.js")),T=require("../../../utils/textFormat");const te=()=>{const{locale:n="us",copyWriting:t}=(0,P.useAiuiContext)(),{product:o,variant:i,finalPrice:r,comparePrice:m,coupon:b,selectedOptions:u,selectedVariants:c,totalSavings:k,onAddToCart:B,onBuyNow:D,savingDetail:v,checkedBundle:O,joinedRecommendBuyProducts:l,setJoinedRecommendBuyProducts:f,setCheckedGift:E,setCheckedExchangePurchase:x,setCheckedBundle:y,setSavingDetail:$,addToCartLoading:J,buyNowLoading:H,profile:F}=(0,h.useBizProductContext)(),[C]=c,M=(0,N.useMemo)(()=>{const d=O?.variants.find(q=>q.variant.sku===C?.sku),W=new A.default(C?.price?.amount||0).minus(d?.price||C?.price?.amount).toNumber();let z=new A.default(C?.price?.amount||0);return F?.email&&(z=z.minus(v?.member||0)),z.minus(v?.coupon).minus(W).toNumber()},[C,O,F,v?.member,v?.coupon]);if(!i.availableForSale)return null;const{bundleVariant:j,giftVariant:G,exchangeVariant:L}=ae()||{},[s,g]=(0,N.useState)();return(0,N.useEffect)(()=>{g({bundle:l.bundle?.value?void 0:j,gift:l.gift?.value?void 0:G,exchange:l.exchange?.value?void 0:L})},[j,G,L,l]),(0,e.jsx)("div",{className:"ipc-product-summary laptop:px-16 desktop:px-0 mt-16 desktop:mt-[96px] lg-desktop:mt-[128px]",children:(0,e.jsx)("div",{className:"bg-[#F5F5F7] laptop:rounded-2xl",children:(0,e.jsxs)(a.Grid,{className:"px-4 pt-6 tablet:p-8 tablet:!pb-0",children:[(0,e.jsxs)(a.GridItem,{className:"col-span-12 laptop:col-start-1 laptop:col-span-5 gap-4 flex flex-col justify-between",children:[(0,e.jsx)(a.Heading,{className:"font-bold text-[24px] lg-desktop:text-[48px] laptop:text-[32px] desktop:text-[40px] leading-[1] mb-4 [&>span]:text-[#D1D1D1]",html:`${o.title} is ready <br/><span>Just the way you want it.</span>`}),(0,e.jsx)("div",{className:"",children:(0,e.jsx)(a.Picture,{source:i.image?.url||o?.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"})})]}),(0,e.jsxs)(a.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",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"shrink-0 flex items-center gap-4",children:[(0,e.jsx)(a.Picture,{source:i.image?.url||o?.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"}),(0,e.jsxs)("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[(0,e.jsx)(a.Text,{className:"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]",html:o.title}),(0,e.jsx)(a.Text,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]",html:`x1 | ${u.color||u.colour||u.couleur}`})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl font-bold",html:(0,p.formatPrice)({amount:M,currencyCode:i.price.currencyCode,locale:n})}),k>0&&(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl laptop:text-xl font-bold line-through text-[#6D6D6F]",html:(0,p.formatPrice)({amount:i?.price?.amount,currencyCode:i.price.currencyCode,locale:n})})]})]}),l?.gift?.value&&(0,e.jsx)(V,{giftOperation:d=>{E?.(void 0),f?.({...l,gift:{value:void 0,canOperate:!0}}),g?.({...s,gift:d})},status:!!l?.gift,gift:l?.gift?.value,canOperate:l?.gift?.canOperate}),l?.bundle?.value&&(0,e.jsx)(R,{bundleOperation:d=>{y?.(void 0),f?.({...l,bundle:{value:void 0,canOperate:!0}}),g?.({...s,bundle:d})},status:!!l?.bundle,bundleListItem:l?.bundle?.value,canOperate:l?.bundle?.canOperate}),l?.exchange?.value&&(0,e.jsx)(I,{exchangeOperation:d=>{x?.(void 0),f?.({...l,exchange:{value:void 0,canOperate:!0}}),g?.({...s,exchange:d})},status:!!l?.exchange,canOperate:l?.exchange?.canOperate,exchange:l?.exchange?.value})]}),(s?.bundle||s?.gift||s?.exchange)&&(0,e.jsxs)("div",{className:"mt-6",children:[(0,e.jsx)(a.Text,{className:"text-sm desktop:text-[18px] font-bold",html:"Recommend Buy"}),(0,e.jsxs)("div",{className:"flex flex-col gap-6 mt-6",children:[s?.exchange&&(0,e.jsx)(I,{exchangeOperation:d=>{y?.(void 0),f?.({bundle:{value:void 0,canOperate:!0},gift:{value:l?.gift?.value,canOperate:!0},exchange:{value:d,canOperate:!0}}),g?.({...s,exchange:void 0})},canOperate:l?.exchange?.canOperate,status:!s?.exchange,exchange:s?.exchange}),s?.bundle&&(0,e.jsx)(R,{bundleOperation:d=>{E?.(void 0),x?.(void 0),$?.({...v,exchangePurchase:0}),f?.({gift:{value:void 0,canOperate:!0},exchange:{value:void 0,canOperate:!0},bundle:{value:d,canOperate:!0}}),g?.({...s,bundle:void 0})},canOperate:l?.bundle?.canOperate,status:!s?.bundle,bundleListItem:s?.bundle}),s?.gift&&(0,e.jsx)(V,{giftOperation:d=>{y?.(void 0),f?.({bundle:{value:void 0,canOperate:!0},exchange:{value:l?.exchange?.value,canOperate:!0},gift:{value:d,canOperate:!0}}),g?.({...s,gift:void 0})},canOperate:l?.gift?.canOperate,status:!s?.gift,gift:s?.gift})]})]})]}),(0,e.jsxs)("div",{className:"text-right",children:[(0,e.jsx)(a.Text,{className:"laptop:text-xl desktop:text-2xl font-bold text-right",html:`${(0,T.replaceTemplate)(t?.totalPrice||"",{amount:(0,p.formatPrice)({amount:r,currencyCode:i.price.currencyCode,locale:n})})}`}),k>0&&(0,e.jsx)(a.Text,{className:"text-base laptop:text-xl desktop:text-2xl ml-1 font-bold line-through text-[#6D6D6F]",html:(0,p.formatPrice)({amount:m,currencyCode:i.price.currencyCode,locale:n})}),(0,e.jsxs)("div",{className:"flex gap-3 mt-2 justify-end",children:[(0,e.jsx)(a.Button,{size:"lg",variant:"secondary",loading:J,className:"w-1/2 tablet:w-auto laptop:w-1/2 desktop:w-auto",onClick:()=>B?.(),children:t?.addToCart}),(0,e.jsx)(a.Button,{size:"lg",loading:H,variant:"primary",className:"w-1/2 tablet:w-auto laptop:w-1/2 desktop:w-auto",onClick:()=>D?.(),children:t?.shopNow})]})]})]})]})})})},ae=()=>{const{bundle:n,variant:t,checkedBundle:o,freeGift:i,checkedGift:r,exchangePurchase:m,checkedExchangePurchase:b}=(0,h.useBizProductContext)();let u,c,k;const{bundleList:B}=n||{},{giftList:D=[]}=i||{},{giftList:v=[]}=m||{},O=B?.filter(x=>x.variants.slice(1,x.variants.length).every(y=>y.variant.availableForSale))||[],[l]=O;u=o||l;const[f]=D?.filter(x=>x.availableForSale);c=r||f;const[E]=v?.filter(x=>x.availableForSale);return k=b||E,{bundleVariant:u,giftVariant:c,exchangeVariant:k}},R=({bundleOperation:n,bundleListItem:t,canOperate:o,status:i})=>{const{locale:r="us"}=(0,P.useAiuiContext)(),{variant:m,setCheckedBundle:b}=(0,h.useBizProductContext)(),u=t?.variants.filter(c=>c.variant.sku!==m.sku);return(0,e.jsx)("div",{className:"",children:u?.map(c=>(0,e.jsxs)("div",{className:"flex items-center gap-4 justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)(a.Picture,{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"}),(0,e.jsx)("div",{className:"flex flex-col gap-[6px] line-clamp-2 max-w-[178px] tablet:max-w-none",children:(0,e.jsx)(a.Text,{className:"font-bold text-[14px] desktop:text-[16px] lg-desktop:text-[18px]",html:c.variant.product.title})})]}),(0,e.jsxs)("div",{className:"flex flex-col items-end gap-1 justify-center",children:[!!t&&(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl font-bold",html:(0,p.formatPrice)({amount:c?.price||0,locale:r,currencyCode:c.variant?.price?.currencyCode||""})}),c.price<c.variant.price.amount&&(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:(0,p.formatPrice)({amount:c.variant.price.amount||0,locale:r,currencyCode:c.variant?.price?.currencyCode||""})})]}),o&&(0,e.jsx)(a.Button,{size:"icon",variant:"link",onClick:()=>{b?.(i?void 0:t),n?.(t)},className:"shrink-0 size-auto underline",children:i?"Remove":"Add"})]})]},c.variant.id))})},V=({giftOperation:n,gift:t,status:o,canOperate:i})=>{const{locale:r="us"}=(0,P.useAiuiContext)(),{freeGift:m,setCheckedGift:b}=(0,h.useBizProductContext)(),{freeLabel:u,count:c}=m||{};return(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)(a.Picture,{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"}),(0,e.jsxs)("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[(0,e.jsx)(a.Text,{className:"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]",html:t?.product?.title}),(0,e.jsx)(a.Text,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]",html:`x${c} | ${u}`})]})]}),(0,e.jsxs)("div",{className:"flex flex-col items-end gap-2 justify-center",children:[!!t&&(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl font-bold",html:u}),(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:(0,p.formatPrice)({amount:t.price.amount,locale:r,currencyCode:t.price.currencyCode})})]}),i&&(0,e.jsx)(a.Button,{size:"icon",variant:"link",onClick:()=>{b?.(o?void 0:t),n(t)},className:"shrink-0 size-auto underline",children:o?"Remove":"Add"})]})]})},I=({exchangeOperation:n,exchange:t,canOperate:o,status:i})=>{const{locale:r="us"}=(0,P.useAiuiContext)(),{setCheckedExchangePurchase:m}=(0,h.useBizProductContext)();return(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)(a.Picture,{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"}),(0,e.jsxs)("div",{className:"flex flex-col gap-[6px] max-w-[178px] tablet:max-w-none",children:[(0,e.jsx)(a.Text,{className:"font-bold text-[14px] line-clamp-2 desktop:text-[16px] lg-desktop:text-[18px]",html:t?.product?.title}),(0,e.jsx)(a.Text,{className:"text-[12px] laptop:text-[14px] desktop:text-[18px] font-bold text-[#6D6D6F]"})]})]}),(0,e.jsxs)("div",{className:"flex flex-col items-end gap-2 justify-center",children:[!!t&&(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl font-bold",html:(0,p.formatPrice)({amount:t.finalPrice?.amount||0,locale:r,currencyCode:t.price.currencyCode})}),(0,e.jsx)(a.Text,{className:"text-base desktop:text-2xl font-bold line-through text-[#6D6D6F]",html:(0,p.formatPrice)({amount:t.price?.amount||0,locale:r,currencyCode:t.price.currencyCode})})]}),o&&(0,e.jsx)(a.Button,{size:"icon",variant:"link",onClick:()=>{m?.(i?void 0:t),n(t)},className:"shrink-0 size-auto underline",children:i?"Remove":"Add"})]})]})};var ne=te;
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": "2jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,GAAAH,IAwEU,IAAAI,EAAA,6BAxEVC,EAA0E,qCAC1EC,EAAqC,uCACrCC,EAA6C,iBAC7CC,EAA4B,0BAC5BC,EAA+B,oCAE/BC,GAAmB,kCACnBC,EAAoB,yBACpBC,EAAgC,qCAEhC,MAAMC,GAAiB,IAAM,CAC3B,KAAM,CAAE,OAAAC,EAAS,KAAM,YAAAC,CAAY,KAAI,kBAAe,EAChD,CACJ,QAAAC,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,KAAI,wBAAqB,EAEnB,CAACC,CAAqB,EAAIf,EAE1BgB,KAAoB,WAAQ,IAAM,CACtC,MAAMC,EAAuBZ,GAAe,SAAS,KAAKa,GAAKA,EAAE,QAAQ,MAAQH,GAAuB,GAAG,EACrGI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OACR,QAAS,IAAM,CACbvC,IAAiBwC,EAAS,OAAYnB,CAAI,EAC1CqB,EAAcrB,CAAI,CACpB,EACA,UAAU,+BAET,SAAAmB,EAAS,SAAW,MACvB,GAEJ,GACF,CAEJ,EAEMhB,EAAyB,CAAC,CAC9B,kBAAAqB,EACA,SAAApB,EACA,WAAAc,EACA,OAAAC,CACF,IAKM,CACJ,KAAM,CAAE,OAAAxD,EAAS,IAAK,KAAI,kBAAe,EACnC,CAAE,2BAAAiB,CAA2B,KAAI,wBAAqB,EAE5D,SACE,QAAC,OAAI,UAAU,oCACb,qBAAC,OAAI,UAAU,0BACb,oBAAC,WACC,OAAQwB,GAAU,OAAO,IACzB,UAAU,6HACZ,KACA,QAAC,OAAI,UAAU,0DACb,oBAAC,QACC,UAAU,gFACV,KAAMA,GAAU,SAAS,MAC3B,KACA,OAAC,QAAK,UAAU,8EAA8E,GAChG,GACF,KACA,QAAC,OAAI,UAAU,+CACZ,WAAC,CAACA,MACD,QAAC,OAAI,UAAU,0BACb,oBAAC,QACC,UAAU,uCACV,QAAM,eAAY,CAChB,OAAQA,EAAS,YAAY,QAAU,EACvC,OAAAzC,EACA,aAAcyC,EAAS,MAAM,YAC/B,CAAC,EACH,KACA,OAAC,QACC,UAAU,mEACV,QAAM,eAAY,CAChB,OAAQA,EAAS,OAAO,QAAU,EAClC,OAAAzC,EACA,aAAcyC,EAAS,MAAM,YAC/B,CAAC,EACH,GACF,EAEDc,MACC,OAAC,UACC,KAAK,OACL,QAAQ,OACR,QAAS,IAAM,CACbtC,IAA6BuC,EAAS,OAAYf,CAAQ,EAC1DoB,EAAkBpB,CAAQ,CAC5B,EACA,UAAU,+BAET,SAAAe,EAAS,SAAW,MACvB,GAEJ,GACF,CAEJ,EAEA,IAAOpE,GAAQW",
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": "2jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,GAAAH,IAwEU,IAAAI,EAAA,6BAxEVC,EAA0E,qCAC1EC,EAAq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,KACA,QAAC,OAAI,UAAU,+CACZ,WAAC,CAACA,MACD,QAAC,OAAI,UAAU,0BACb,oBAAC,QACC,UAAU,uCACV,QAAM,eAAY,CAChB,OAAQA,EAAS,YAAY,QAAU,EACvC,OAAAzC,EACA,aAAcyC,EAAS,MAAM,YAC/B,CAAC,EACH,KACA,OAAC,QACC,UAAU,mEACV,QAAM,eAAY,CAChB,OAAQA,EAAS,OAAO,QAAU,EAClC,OAAAzC,EACA,aAAcyC,EAAS,MAAM,YAC/B,CAAC,EACH,GACF,EAEDc,MACC,OAAC,UACC,KAAK,OACL,QAAQ,OACR,QAAS,IAAM,CACbtC,IAA6BuC,EAAS,OAAYf,CAAQ,EAC1DoB,EAAkBpB,CAAQ,CAC5B,EACA,UAAU,+BAET,SAAAe,EAAS,SAAW,MACvB,GAEJ,GACF,CAEJ,EAEA,IAAOpE,GAAQW",
6
6
  "names": ["ProductSummary_exports", "__export", "ProductSummary_default", "__toCommonJS", "import_jsx_runtime", "import_components", "import_BizProductProvider", "import_react", "import_utils", "import_AiuiProvider", "import_helpers", "import_decimal", "import_textFormat", "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", "Decimal", "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"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var P=(t,e)=>{for(var o in e)s(t,o,{get:e[o],enumerable:!0})},B=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of k(e))!T.call(t,r)&&r!==o&&s(t,r,{get:()=>e[r],enumerable:!(n=h(e,r))||n.enumerable});return t};var M=t=>B(s({},"__esModule",{value:!0}),t);var z={};P(z,{default:()=>F});module.exports=M(z);var a=require("react/jsx-runtime"),l=require("../../../../../components"),b=require("../../../../AiuiProvider/index.js"),g=require("../../../BizProductProvider.js"),d=require("react"),i=require("../../../utils"),u=require("../../../utils/textFormat");const A=()=>{const{copyWriting:t,locale:e="us"}=(0,b.useAiuiContext)(),{variant:o,finalPrice:n,totalSavings:r,memberFunctionResult:p,isLogin:c,comparePrice:v,onAddToCart:f,onBuyNow:C,savingDetail:x,coupon:L,addToCartLoading:y,buyNowLoading:N,profile:O}=(0,g.useBizProductContext)(),m=Math.max(p?.withCouponMemberTotalSave??0,p?.withoutCouponMaxMemberTotalSave??0),S=(0,d.useMemo)(()=>(0,u.replaceTemplate)(t?.totalSavings||"",{amount:(0,i.formatPrice)({amount:r,currencyCode:o.price.currencyCode,locale:e})}),[t?.totalSavings,r,o.price.currencyCode,e]),w=(0,d.useMemo)(()=>(0,u.replaceTemplate)(t?.memberSaving||"",{amount:(0,i.formatPrice)({amount:m,currencyCode:o.price.currencyCode,locale:e})}),[t?.memberSaving,m,o.price.currencyCode,e]);return(0,a.jsxs)("div",{className:"bg-white py-3 px-4 tablet:p-0 tablet:flex tablet:items-center tablet:gap-4",children:[o.availableForSale?(0,a.jsxs)("div",{className:"flex items-center justify-between tablet:flex-col desktop:items-end",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(l.Text,{className:"text-xl font-bold !leading-[1.2] desktop:text-xl lg-desktop:text-2xl",html:(0,i.formatPrice)({amount:n,currencyCode:o.price.currencyCode,locale:e})}),(r>0||x?.member>0&&c)&&(0,a.jsx)(l.Text,{className:"text-xl font-bold line-through text-[#999] !leading-[1.2] desktop:text-xl lg-desktop:text-2xl",html:(0,i.formatPrice)({amount:v,currencyCode:o.price.currencyCode,locale:e})})]}),(r>0||x?.member>0&&c)&&(0,a.jsx)(l.Text,{className:"text-brand-0 text-base !leading-[1.2] font-bold desktop:text-xl lg-desktop:text-2xl",html:`${m>0&&c?w:S}`})]}):(0,a.jsx)(l.Text,{className:"text-[20px] font-bold text-[#999999]",html:t?.soldOut??"Sold Out"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-2 tablet:mt-0",children:[(0,a.jsx)(l.Button,{variant:"secondary",disabled:!o.availableForSale,size:"lg",className:"w-1/2 tablet:w-auto",onClick:()=>f?.(),loading:y,children:t?.addToCart??"Add to Cart"}),(0,a.jsx)(l.Button,{variant:"primary",disabled:!o.availableForSale,size:"lg",loading:N,className:"w-1/2 tablet:w-auto",onClick:()=>C?.(),children:t?.buyNow??"Buy Now"})]})]})};var F=A;
1
+ "use strict";var s=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var A=(t,e)=>{for(var o in e)s(t,o,{get:e[o],enumerable:!0})},F=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of P(e))!M.call(t,r)&&r!==o&&s(t,r,{get:()=>e[r],enumerable:!(i=B(e,r))||i.enumerable});return t};var z=t=>F(s({},"__esModule",{value:!0}),t);var E={};A(E,{default:()=>D});module.exports=z(E);var a=require("react/jsx-runtime"),l=require("../../../../../components"),x=require("../../../../AiuiProvider/index.js"),g=require("../../../BizProductProvider.js"),d=require("react"),n=require("../../../utils"),u=require("../../../utils/textFormat"),v=require("../../../hooks/useDiscountEnable");const L=()=>{const{copyWriting:t,locale:e="us"}=(0,x.useAiuiContext)(),{variant:o,finalPrice:i,totalSavings:r,memberFunctionResult:c,isLogin:p,comparePrice:f,onAddToCart:C,onBuyNow:y,savingDetail:m,coupon:N,addToCartLoading:S,buyNowLoading:w,profile:h}=(0,g.useBizProductContext)(),b=Math.max(c?.withCouponMemberTotalSave??0,c?.withoutCouponMaxMemberTotalSave??0),k=(0,d.useMemo)(()=>(0,u.replaceTemplate)(t?.totalSavings||"",{amount:(0,n.formatPrice)({amount:r,currencyCode:o.price.currencyCode,locale:e})}),[t?.totalSavings,r,o.price.currencyCode,e]),T=(0,d.useMemo)(()=>(0,u.replaceTemplate)(t?.memberSaving||"",{amount:(0,n.formatPrice)({amount:b,currencyCode:o.price.currencyCode,locale:e})}),[t?.memberSaving,b,o.price.currencyCode,e]),O=(0,v.useDiscountEnable)({profile:h,variant:o,memberFunctionResult:c,coupon:N});return(0,a.jsxs)("div",{className:"bg-white py-3 px-4 tablet:p-0 tablet:flex tablet:items-center tablet:gap-4",children:[o.availableForSale?(0,a.jsxs)("div",{className:"flex items-center justify-between tablet:flex-col desktop:items-end",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(l.Text,{className:"text-xl font-bold !leading-[1.2] desktop:text-xl lg-desktop:text-2xl",html:(0,n.formatPrice)({amount:i,currencyCode:o.price.currencyCode,locale:e})}),(r>0||m?.member>0&&p)&&(0,a.jsx)(l.Text,{className:"text-xl font-bold line-through text-[#999] !leading-[1.2] desktop:text-xl lg-desktop:text-2xl",html:(0,n.formatPrice)({amount:f,currencyCode:o.price.currencyCode,locale:e})})]}),(r>0||m?.member>0&&p)&&(0,a.jsx)(l.Text,{className:"text-brand-0 text-base !leading-[1.2] font-bold desktop:text-xl lg-desktop:text-2xl",html:`${m?.member?T:k}`})]}):(0,a.jsx)(l.Text,{className:"text-[20px] font-bold text-[#999999]",html:t?.soldOut??"Sold Out"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-2 tablet:mt-0",children:[(0,a.jsx)(l.Button,{variant:"secondary",disabled:!o.availableForSale,size:"lg",className:"w-1/2 tablet:w-auto",onClick:()=>C?.(),loading:S,children:t?.addToCart??"Add to Cart"}),(0,a.jsx)(l.Button,{variant:"primary",disabled:!o.availableForSale,size:"lg",loading:w,className:"w-1/2 tablet:w-auto",onClick:()=>y?.(),children:t?.buyNow??"Buy Now"})]})]})};var D=L;
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={() => onBuyNow?.()}\n >\n {copyWriting?.buyNow ?? 'Buy Now'}\n </Button>\n </div>\n </div>\n )\n}\n\nexport default ProductActions\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA8CU,IAAAI,EAAA,6BA9CVC,EAA6B,qCAC7BC,EAA+B,6CAC/BC,EAAqC,0CACr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Ac,OAAS,GAAKJ,OACjD,OAAC,QACC,UAAU,sFACV,KAAM,GAAGS,EAAkB,GAAKT,EAAUW,EAAsBD,CAAgB,GAClF,GAEJ,KAEA,OAAC,QAAK,UAAU,uCAAuC,KAAMhB,GAAa,SAAW,WAAY,KAEnG,QAAC,OAAI,UAAU,2CACb,oBAAC,UACC,QAAQ,YACR,SAAU,CAACE,EAAQ,iBACnB,KAAK,KACL,UAAU,sBACV,QAAS,IAAMM,IAAc,EAC7B,QAASI,EAER,SAAAZ,GAAa,WAAa,cAC7B,KACA,OAAC,UACC,QAAQ,UACR,SAAU,CAACE,EAAQ,iBACnB,KAAK,KACL,QAASW,EACT,UAAU,sBACV,QAAS,IAAMJ,IAAW,EAEzB,SAAAT,GAAa,QAAU,UAC1B,GACF,GACF,CAEJ,EAEA,IAAOV,EAAQS",
6
- "names": ["ProductActions_exports", "__export", "ProductActions_default", "__toCommonJS", "import_jsx_runtime", "import_components", "import_AiuiProvider", "import_BizProductProvider", "import_react", "import_utils", "import_textFormat", "ProductActions", "copyWriting", "locale", "variant", "finalPrice", "totalSavings", "memberFunctionResult", "isLogin", "comparePrice", "onAddToCart", "onBuyNow", "savingDetail", "coupon", "addToCartLoading", "buyNowLoading", "profile", "memberPriceSave", "totalSavingsText", "memberPriceSaveText"]
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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAiDU,IAAAI,EAAA,6BAjDVC,EAA6B,qCAC7BC,EAA+B,6CAC/BC,EAAqC,0CACrCC,EAAwB,iBACxBC,EAA4B,0BAC5BC,EAAgC,qCAChCC,EAAkC,4CAElC,MAAMC,EAAiB,IAAM,CAC3B,KAAM,CAAE,YAAAC,EAAa,OAAAC,EAAS,IAAK,KAAI,kBAAe,EAChD,CACJ,QAAAC,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,KAAI,wBAAqB,EAEnBC,EAAkB,KAAK,IAC3BV,GAAsB,2BAA6B,EACnDA,GAAsB,iCAAmC,CAC3D,EAEMW,KAAmB,WAAQ,OACxB,mBAAgBhB,GAAa,cAAgB,GAAI,CACtD,UAAQ,eAAY,CAAE,OAAQI,EAAc,aAAcF,EAAQ,MAAM,aAAc,OAAAD,CAAO,CAAC,CAChG,CAAC,EACA,CAACD,GAAa,aAAcI,EAAcF,EAAQ,MAAM,aAAcD,CAAM,CAAC,EAE1EgB,KAAsB,WAAQ,OAC3B,mBAAgBjB,GAAa,cAAgB,GAAI,CACtD,UAAQ,eAAY,CAAE,OAAQe,EAAiB,aAAcb,EAAQ,MAAM,aAAc,OAAAD,CAAO,CAAC,CACnG,CAAC,EACA,CAACD,GAAa,aAAce,EAAiBb,EAAQ,MAAM,aAAcD,CAAM,CAAC,EAE7EiB,KAAiB,qBAAkB,CAAE,QAAAJ,EAAS,QAAAZ,EAAS,qBAAAG,EAAsB,OAAAM,CAAO,CAAC,EAE3F,SACE,QAAC,OAAI,UAAU,6EACZ,UAAAT,EAAQ,oBACP,QAAC,OAAI,UAAU,sEACb,qBAAC,OAAI,UAAU,0BACb,oBAAC,QACC,UAAU,uEACV,QAAM,eAAY,CAAE,OAAQC,EAAY,aAAcD,EAAQ,MAAM,aAAc,OAAAD,CAAO,CAAC,EAC5F,GACEG,EAAe,GAAMM,GAAc,OAAS,GAAKJ,OACjD,OAAC,QACC,UAAU,gGACV,QAAM,eAAY,CAChB,OAAQC,EACR,aAAcL,EAAQ,MAAM,aAC5B,OAAAD,CACF,CAAC,EACH,GAEJ,GACEG,EAAe,GAAMM,GAAc,OAAS,GAAKJ,OACjD,OAAC,QACC,UAAU,sFACV,KAAM,GAAWI,GAAc,OAAUO,EAAsBD,CAAgB,GACjF,GAEJ,KAEA,OAAC,QAAK,UAAU,uCAAuC,KAAMhB,GAAa,SAAW,WAAY,KAEnG,QAAC,OAAI,UAAU,2CACb,oBAAC,UACC,QAAQ,YACR,SAAU,CAACE,EAAQ,iBACnB,KAAK,KACL,UAAU,sBACV,QAAS,IAAMM,IAAc,EAC7B,QAASI,EAER,SAAAZ,GAAa,WAAa,cAC7B,KACA,OAAC,UACC,QAAQ,UACR,SAAU,CAACE,EAAQ,iBACnB,KAAK,KACL,QAASW,EACT,UAAU,sBACV,QAAS,IAAMJ,IAAW,EAEzB,SAAAT,GAAa,QAAU,UAC1B,GACF,GACF,CAEJ,EAEA,IAAOX,EAAQU",
6
+ "names": ["ProductActions_exports", "__export", "ProductActions_default", "__toCommonJS", "import_jsx_runtime", "import_components", "import_AiuiProvider", "import_BizProductProvider", "import_react", "import_utils", "import_textFormat", "import_useDiscountEnable", "ProductActions", "copyWriting", "locale", "variant", "finalPrice", "totalSavings", "memberFunctionResult", "isLogin", "comparePrice", "onAddToCart", "onBuyNow", "savingDetail", "coupon", "addToCartLoading", "buyNowLoading", "profile", "memberPriceSave", "totalSavingsText", "memberPriceSaveText", "discountEnable"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var s in t)c(e,s,{get:t[s],enumerable:!0})},y=(e,t,s,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of w(t))!N.call(e,l)&&l!==s&&c(e,l,{get:()=>t[l],enumerable:!(a=g(t,l))||a.enumerable});return e};var C=e=>y(c({},"__esModule",{value:!0}),e);var A={};k(A,{DesktopScrollSpyNav:()=>v,MobileScrollSpyNav:()=>u});module.exports=C(A);var o=require("react/jsx-runtime"),D=require("../../../../AiuiProvider/index.js"),p=require("../../../../../helpers/index.js"),n=require("react"),m=require("gsap"),f=require("../../../BizProductProvider.js");const E=e=>(0,o.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,o.jsx)("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"#1D1D1F",strokeLinecap:"round",strokeLinejoin:"round"})}),u=({tabs:e,purchaseBarHeight:t,onSpyNavItemClick:s})=>{const[a,l]=(0,n.useState)(!1),[r,b]=(0,n.useState)(e?.[0]),d=(0,n.useRef)(null),{renderRating:x}=(0,f.useBizProductContext)(),S=(0,n.useCallback)(i=>{b(i),s?.(i),l(!1)},[]),h=(0,n.useCallback)(()=>{l(!a),m.gsap.fromTo(d?.current,{height:0},{height:"auto",duration:.5,ease:"power2.inOut"})},[a]);return(0,o.jsxs)("div",{children:[(0,o.jsxs)("button",{className:"text-sm h-[28px] font-bold flex gap-1 items-center leading-[28px] px-[10px] border rounded-full border-black",onClick:h,children:[r?.label,(0,o.jsx)(E,{className:"size-3"})]}),(0,o.jsxs)("div",{className:(0,p.cn)("absolute top-full w-full flex flex-col z-[60] bg-black/60 left-0",{hidden:!a}),style:{height:`calc(100dvh - ${t}px)`},children:[(0,o.jsxs)("div",{ref:d,className:"border-t overflow-hidden border-[#E4E5E6] flex flex-col bg-white",children:[e?.map(i=>(0,o.jsx)("button",{className:"text-sm hover:bg-[#EAEAEC] p-4 text-left font-bold",onClick:()=>S(i),children:i.label},i.id)),(0,o.jsx)("button",{className:"text-sm hover:bg-[#EAEAEC] p-4 text-left font-bold",children:x})]}),(0,o.jsx)("div",{className:"flex-1",onClick:()=>l(!1)})]})]})},v=({tabs:e,onSpyNavItemClick:t})=>{const[s,a]=(0,n.useState)(e?.[0]),l=(0,n.useCallback)(r=>{a(r),t?.(r)},[]);return(0,o.jsx)("div",{className:"flex gap-8",children:e?.map(r=>(0,o.jsxs)("button",{className:"text-sm relative py-[10px] font-bold",onClick:()=>l(r),children:[r.label,(0,o.jsx)("div",{className:(0,p.cn)("absolute bottom-0 left-0 w-0 transition-all duration-300 ease-in-out h-[2px] bg-brand-0",{"w-full":s?.id===r.id})})]},r.id))})};
1
+ "use strict";var u=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var E=(e,o)=>{for(var r in o)u(e,r,{get:o[r],enumerable:!0})},k=(e,o,r,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of N(o))!y.call(e,t)&&t!==r&&u(e,t,{get:()=>o[t],enumerable:!(s=g(o,t))||s.enumerable});return e};var T=e=>k(u({},"__esModule",{value:!0}),e);var C={};E(C,{DesktopScrollSpyNav:()=>h,MobileScrollSpyNav:()=>x});module.exports=T(C);var l=require("react/jsx-runtime"),L=require("../../../../AiuiProvider/index.js"),v=require("../../../../../helpers/index.js"),c=require("react"),S=require("gsap"),w=require("../../../BizProductProvider.js");const A=e=>(0,l.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,l.jsx)("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"#1D1D1F",strokeLinecap:"round",strokeLinejoin:"round"})}),b=(e,o)=>{const[r,s]=(0,c.useState)(e?.[0]);return(0,c.useEffect)(()=>{if(!e||e.length===0)return;const t=()=>{const n=e.map(i=>{const p=i.id||i.href?.replace("#","");return{tab:i,element:document.getElementById(p)}}).filter(i=>i.element!==null);if(n.length===0)return;const f=window.scrollY+150;let a=n[0];for(const i of n){const m=i.element.offsetTop;if(f>=m)a=i;else break}a&&a.tab.id!==r?.id&&(s(a.tab),o?.(a.tab))};return t(),window.addEventListener("scroll",t,{passive:!0}),()=>{window.removeEventListener("scroll",t)}},[e,r?.id,o]),{activeTab:r,setActiveTab:s}},x=({tabs:e,purchaseBarHeight:o,onSpyNavItemClick:r})=>{const[s,t]=(0,c.useState)(!1),n=(0,c.useRef)(null),{renderRating:f}=(0,w.useBizProductContext)(),{activeTab:a,setActiveTab:i}=b(e),p=(0,c.useCallback)(d=>{i(d),r?.(d),t(!1)},[r,i]),m=(0,c.useCallback)(()=>{t(!s),S.gsap.fromTo(n?.current,{height:0},{height:"auto",duration:.5,ease:"power2.inOut"})},[s]);return(0,l.jsxs)("div",{children:[(0,l.jsxs)("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:[a?.label,(0,l.jsx)(A,{className:"size-3"})]}),(0,l.jsxs)("div",{className:(0,v.cn)("absolute top-full w-full flex flex-col z-[60] bg-black/60 left-0",{hidden:!s}),style:{height:`calc(100dvh - ${o}px)`},children:[(0,l.jsxs)("div",{ref:n,className:"border-t overflow-hidden border-[#E4E5E6] flex flex-col bg-white",children:[e?.map(d=>(0,l.jsx)("button",{className:"text-sm hover:bg-[#EAEAEC] p-4 text-left font-bold",onClick:()=>p(d),children:d.label},d.id)),(0,l.jsx)("button",{className:"text-sm hover:bg-[#EAEAEC] p-4 text-left font-bold",children:f})]}),(0,l.jsx)("div",{className:"flex-1",onClick:()=>t(!1)})]})]})},h=({tabs:e,onSpyNavItemClick:o})=>{const{activeTab:r,setActiveTab:s}=b(e),t=(0,c.useCallback)(n=>{s(n),o?.(n)},[o,s]);return(0,l.jsx)("div",{className:"flex gap-8",children:e?.map(n=>(0,l.jsxs)("button",{className:"text-sm relative py-[10px] font-bold",onClick:()=>t(n),children:[n.label,(0,l.jsx)("div",{className:(0,v.cn)("absolute bottom-0 left-0 w-0 transition-all duration-300 ease-in-out h-[2px] bg-brand-0",{"w-full":r?.id===n.id})})]},n.id))})};
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": "yaAAA,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AC,UACC,UAAU,qDAEV,QAAS,IAAMD,EAAWC,CAAG,EAE5B,SAAAA,EAAI,OAHAA,EAAI,EAIX,CACD,KACD,OAAC,UAAO,UAAU,qDAAsD,SAAAF,EAAa,GACvF,KACA,OAAC,OAAI,UAAU,SAAS,QAAS,IAAMJ,EAAgB,EAAK,EAAG,GACjE,GACF,CAEJ,EAEMf,EAAsB,CAAC,CAAE,KAAAW,EAAM,kBAAAE,CAAkB,IAAyB,CAC9E,KAAM,CAACG,EAAWC,CAAY,KAAI,YAASN,IAAO,CAAC,CAAC,EAE9CS,KAAa,eAAaC,GAA0B,CACxDJ,EAAaI,CAAG,EAChBR,IAAoBQ,CAAG,CACzB,EAAG,CAAC,CAAC,EAEL,SACE,OAAC,OAAI,UAAU,aACZ,SAAAV,GAAM,IAAIU,MACT,QAAC,UAAO,UAAU,uCAAoD,QAAS,IAAMD,EAAWC,CAAG,EAChG,UAAAA,EAAI,SACL,OAAC,OACC,aAAW,MAAG,0FAA2F,CACvG,SAAUL,GAAW,KAAOK,EAAI,EAClC,CAAC,EACH,IAN4DA,EAAI,EAOlE,CACD,EACH,CAEJ",
6
- "names": ["ScrollSpyNav_exports", "__export", "DesktopScrollSpyNav", "MobileScrollSpyNav", "__toCommonJS", "import_jsx_runtime", "import_AiuiProvider", "import_helpers", "import_react", "import_gsap", "import_BizProductProvider", "ArrowDownIcon", "props", "tabs", "purchaseBarHeight", "onSpyNavItemClick", "dropdownOpen", "setDropdownOpen", "activeTab", "setActiveTab", "dropdownRef", "renderRating", "onTabClick", "tab", "onDropdownOpen"]
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-[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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,uBAAAC,IAAA,eAAAC,EAAAJ,GAUM,IAAAK,EAAA,6BAVNC,EAA+B,6CAC/BC,EAAmB,2CACnBC,EAAyD,iBACzDC,EAAqB,gBAErBC,EAAqC,0CAErC,MAAMC,EAAiBC,MAEnB,OAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,6BAA8B,GAAGA,EACjG,mBAAC,QAAK,EAAE,qBAAqB,OAAO,UAAU,cAAc,QAAQ,eAAe,QAAQ,EAC7F,EAKEC,EAAe,CAACC,EAA0BC,IAAqD,CACnG,KAAM,CAACC,EAAWC,CAAY,KAAI,YAASH,IAAO,CAAC,CAAC,EAEpD,sBAAU,IAAM,CACd,GAAI,CAACA,GAAQA,EAAK,SAAW,EAAG,OAEhC,MAAMI,EAAe,IA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iProvider", "import_helpers", "import_react", "import_gsap", "import_BizProductProvider", "ArrowDownIcon", "props", "useScrollSpy", "tabs", "onActiveChange", "activeTab", "setActiveTab", "handleScroll", "sections", "tab", "id", "item", "scrollPosition", "currentSection", "section", "offsetTop", "purchaseBarHeight", "onSpyNavItemClick", "dropdownOpen", "setDropdownOpen", "dropdownRef", "renderRating", "onTabClick", "onDropdownOpen"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var u=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var R=(e,n)=>{for(var l in n)u(e,l,{get:n[l],enumerable:!0})},S=(e,n,l,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of G(n))!P.call(e,o)&&o!==l&&u(e,o,{get:()=>n[o],enumerable:!(i=x(n,o))||i.enumerable});return e};var y=e=>S(u({},"__esModule",{value:!0}),e);var k={};R(k,{useBenefits:()=>M});module.exports=y(k);var p=require("../BizProductProvider"),d=require("../utils/helper"),g=require("./useDiscountEnable"),b=require("../../AiuiProvider/index.js"),F=require("react");const M=({variant:e})=>{const{coupon:n,product:l,bundle:i,freeGift:o,memberFunctionResult:f,creditsRedemptionAmount:a,discount:r,profile:B,savingDetail:h}=(0,p.useBizProductContext)(),{codeSavings:w}=r||{},{trackingData:s}=(0,b.useAiuiContext)(),C=Math.max(f?.withCouponMemberTotalSave??0,f?.withoutCouponMaxMemberTotalSave??0),m=(0,g.useDiscountEnable)({profile:B,savingDetail:h,memberFunctionResult:f,discount:r}),D=!!(s?.paidShipping&&e.requiresShipping&&!e?.metafields?.global?.presell&&!e?.metafields?.global?.HideShipping),c=s?.freeGift,v=c?.excludeProducts?.map(t=>typeof t=="object"&&"sku"in t?t.sku:t)??[],I=s?.levelDiscount&&(0,d.checkItemAvailableForProduct)({product:l,variant:e,item:s?.levelDiscount});return{commonCoupon:{enable:m.showCommonCoupon,config:n??{}},freeGift:{enable:!!o&&!!o?.giftList?.length,config:o},bundle:{enable:!!i&&!!i?.bundleList?.length&&Math.max(...i?.bundleList?.map(t=>t.savings??0))>0,config:i},memberDiscount:{enable:m.showMemberDiscount,config:{amount:C,description:f?.labels?.find(t=>t.key==="benefit_tab_string")?.value}},creditsRedemption:{enable:!!a&&a>0,config:{amount:a,label:s?.creditsRedemptionLabel}},paidShipping:{enable:D,config:{}},fullGift:{enable:!!(c&&!v.includes(e.sku)),config:c??{}},levelDiscount:{enable:!!I,config:s?.levelDiscount??{}}}};
1
+ "use strict";var u=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var P=(e,n)=>{for(var l in n)u(e,l,{get:n[l],enumerable:!0})},R=(e,n,l,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of x(n))!G.call(e,o)&&o!==l&&u(e,o,{get:()=>n[o],enumerable:!(i=I(n,o))||i.enumerable});return e};var v=e=>R(u({},"__esModule",{value:!0}),e);var S={};P(S,{useBenefits:()=>y});module.exports=v(S);var m=require("../BizProductProvider"),p=require("../utils/helper"),d=require("./useDiscountEnable"),g=require("../../AiuiProvider/index.js"),L=require("react");const y=({variant:e})=>{const{coupon:n,product:l,bundle:i,freeGift:o,memberFunctionResult:f,creditsRedemptionAmount:a,discount:M,profile:b,savingDetail:k}=(0,m.useBizProductContext)(),{trackingData:s}=(0,g.useAiuiContext)(),B=Math.max(f?.withCouponMemberTotalSave??0,f?.withoutCouponMaxMemberTotalSave??0),r=(0,d.useDiscountEnable)({profile:b,variant:e,memberFunctionResult:f,coupon:n}),h=!!(s?.paidShipping&&e.requiresShipping&&!e?.metafields?.global?.presell&&!e?.metafields?.global?.HideShipping),c=s?.freeGift,C=c?.excludeProducts?.map(t=>typeof t=="object"&&"sku"in t?t.sku:t)??[],D=s?.levelDiscount&&(0,p.checkItemAvailableForProduct)({product:l,variant:e,item:s?.levelDiscount});return{commonCoupon:{enable:r.showCommonCoupon,config:n??{}},freeGift:{enable:!!o&&!!o?.giftList?.length,config:o},bundle:{enable:!!i&&!!i?.bundleList?.length&&Math.max(...i?.bundleList?.map(t=>t.savings??0))>0,config:i},memberDiscount:{enable:r.showMemberDiscount,config:{amount:B,description:f?.labels?.find(t=>t.key==="benefit_tab_string")?.value}},creditsRedemption:{enable:!!a&&a>0,config:{amount:a,label:s?.creditsRedemptionLabel}},paidShipping:{enable:h,config:{}},fullGift:{enable:!!(c&&!C.includes(e.sku)),config:c??{}},levelDiscount:{enable:!!D,config:s?.levelDiscount??{}}}};
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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAqC,iCAErCC,EAA6C,2BAC7CC,EAAkC,+BAElCC,EAA+B,uCAC/BC,EAAwB,iBAsDjB,MAAMN,EAAc,CAAC,CAAE,QAAAO,CAAQ,IAAsC,CAC1E,KAAM,CACJ,OAAAC,EACA,QAAAC,EACA,OAAAC,EACA,SAAAC,EACA,qBAAAC,EACA,wBAAAC,EACA,SAAAC,EACA,QAAAC,EACA,aAAAC,CACF,KAAI,wBAAqB,EACnB,CAAE,YAAAC,CAAY,EAAIH,GAAY,CAAC,EAE/B,CAAE,aAAAI,CAAa,KAAI,kBAAe,EAElCC,EAAQ,KAAK,IACjBP,GAAsB,2BAA6B,EACnDA,GAAsB,iCAAmC,CAC3D,EAEMQ,KAAiB,qBAAkB,CAAE,QAAAL,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,kBAAiB,gCAA6B,CAAE,QAAAT,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": ["useBenefits_exports", "__export", "useBenefits", "__toCommonJS", "import_BizProductProvider", "import_helper", "import_useDiscountEnable", "import_AiuiProvider", "import_react", "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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAqC,iCAErCC,EAA6C,2BA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,EACA,kBAAmB,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": ["useBenefits_exports", "__export", "useBenefits", "__toCommonJS", "import_BizProductProvider", "import_helper", "import_useDiscountEnable", "import_AiuiProvider", "import_react", "variant", "coupon", "product", "bundle", "freeGift", "memberFunctionResult", "creditsRedemptionAmount", "discount", "profile", "savingDetail", "trackingData", "total", "discountEnable", "showPaidShipping", "fullGift", "excludeProducts", "item", "showLevelDiscount"]
7
7
  }