@anker-in/campaign-ui 0.5.0-beta.4 → 0.5.0-beta.6

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 (60) hide show
  1. package/dist/cjs/components/credits/context/hooks/useCountries.js +1 -1
  2. package/dist/cjs/components/credits/context/hooks/useCountries.js.map +3 -3
  3. package/dist/cjs/components/memberPopup/MemberPopup.js +1 -1
  4. package/dist/cjs/components/memberPopup/MemberPopup.js.map +3 -3
  5. package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.d.ts +10 -0
  6. package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js +2 -0
  7. package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +7 -0
  8. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.d.ts +2 -1
  9. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js +1 -1
  10. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js.map +3 -3
  11. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
  12. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js.map +3 -3
  13. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.d.ts +11 -0
  14. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js +2 -0
  15. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js.map +7 -0
  16. package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeModal.js +1 -1
  17. package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeModal.js.map +2 -2
  18. package/dist/cjs/components/memberPopup/panels/EarnCredits/index.js +1 -1
  19. package/dist/cjs/components/memberPopup/panels/EarnCredits/index.js.map +2 -2
  20. package/dist/cjs/components/memberPopup/panels/Referral/index.js +1 -1
  21. package/dist/cjs/components/memberPopup/panels/Referral/index.js.map +2 -2
  22. package/dist/cjs/components/memberPopup/type.d.ts +14 -2
  23. package/dist/cjs/components/memberPopup/type.js +1 -1
  24. package/dist/cjs/components/memberPopup/type.js.map +2 -2
  25. package/dist/esm/components/credits/context/hooks/useCountries.js +1 -1
  26. package/dist/esm/components/credits/context/hooks/useCountries.js.map +3 -3
  27. package/dist/esm/components/memberPopup/MemberPopup.js +1 -1
  28. package/dist/esm/components/memberPopup/MemberPopup.js.map +3 -3
  29. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.d.ts +10 -0
  30. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js +2 -0
  31. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +7 -0
  32. package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.d.ts +2 -1
  33. package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js +1 -1
  34. package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js.map +3 -3
  35. package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
  36. package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js.map +3 -3
  37. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.d.ts +11 -0
  38. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js +2 -0
  39. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js.map +7 -0
  40. package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeModal.js +1 -1
  41. package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeModal.js.map +2 -2
  42. package/dist/esm/components/memberPopup/panels/EarnCredits/index.js +1 -1
  43. package/dist/esm/components/memberPopup/panels/EarnCredits/index.js.map +2 -2
  44. package/dist/esm/components/memberPopup/panels/Referral/index.js +1 -1
  45. package/dist/esm/components/memberPopup/panels/Referral/index.js.map +2 -2
  46. package/dist/esm/components/memberPopup/type.d.ts +14 -2
  47. package/dist/esm/components/memberPopup/type.js +1 -1
  48. package/dist/esm/components/memberPopup/type.js.map +2 -2
  49. package/package.json +1 -1
  50. package/src/components/credits/context/hooks/useCountries.ts +1 -2
  51. package/src/components/memberPopup/MemberPopup.tsx +18 -13
  52. package/src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx +194 -0
  53. package/src/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.tsx +61 -28
  54. package/src/components/memberPopup/panels/ConsumeCredits/index.tsx +40 -14
  55. package/src/components/memberPopup/panels/EarnCredits/index.tsx +94 -64
  56. package/src/components/memberPopup/panels/Referral/index.tsx +1 -1
  57. package/src/components/memberPopup/type.ts +10 -1
  58. package/src/components/memberPopup/panels/ConsumeCredits/RedeemCouponModal.tsx +0 -150
  59. package/src/components/memberPopup/panels/EarnCredits/SubscribeModal.tsx +0 -144
  60. package/src/components/memberPopup/panels/EarnCredits/SubscribePanel.tsx +0 -147
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var g=(t,e)=>{for(var s in e)a(t,s,{get:e[s],enumerable:!0})},d=(t,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of C(e))!y.call(t,o)&&o!==s&&a(t,o,{get:()=>e[o],enumerable:!(n=m(e,o))||n.enumerable});return t};var S=t=>d(a({},"__esModule",{value:!0}),t);var D={};g(D,{default:()=>x});module.exports=S(D);var r=require("react"),f=require("@anker-in/lib");function w({shopifyStoreDomain:t}){const{locale:e=""}=(0,f.useHeadlessContext)(),[s,n]=(0,r.useState)(!1),[o,c]=(0,r.useState)([]);return(0,r.useEffect)(()=>{(async()=>{n(!0);try{const p=await(await fetch("/api/multipass/account/countries",{headers:{"current-language":e}})).json();let i=p?.data||p||[];i=i.sort((l,h)=>l.name.localeCompare(h.name)),console.log("fetch shipsToCountries",i),c(i)}catch(u){c([]),console.error(u)}finally{n(!1)}})()},[e]),{isLoading:s,countries:o}}var x=w;
1
+ "use strict";var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var s in e)a(t,s,{get:e[s],enumerable:!0})},g=(t,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of m(e))!C.call(t,o)&&o!==s&&a(t,o,{get:()=>e[o],enumerable:!(n=h(e,o))||n.enumerable});return t};var d=t=>g(a({},"__esModule",{value:!0}),t);var x={};y(x,{default:()=>w});module.exports=d(x);var r=require("react"),p=require("@anker-in/lib");function S({shopifyStoreDomain:t}){const{locale:e=""}=(0,p.useHeadlessContext)(),[s,n]=(0,r.useState)(!1),[o,c]=(0,r.useState)([]);return(0,r.useEffect)(()=>{(async()=>{n(!0);try{let i=(await(await fetch("/api/multipass/account/countries",{headers:{"current-language":e}})).json())?.data?.data||[];i=i.sort((f,l)=>f.name.localeCompare(l.name)),console.log("fetch shipsToCountries",i),c(i)}catch(u){c([]),console.error(u)}finally{n(!1)}})()},[e]),{isLoading:s,countries:o}}var w=S;
2
2
  //# sourceMappingURL=useCountries.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/credits/context/hooks/useCountries.ts"],
4
- "sourcesContent": ["import { useEffect, useState } from 'react'\n\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { type ShippingCountry } from '../../type'\n\nfunction useCountries({ shopifyStoreDomain }: { shopifyStoreDomain: string }) {\n const { locale = '' } = useHeadlessContext()\n\n const [isLoading, setLoading] = useState(false)\n const [countries, setCountries] = useState<ShippingCountry[]>([])\n\n useEffect(() => {\n const fetchCountries = async () => {\n setLoading(true)\n try {\n const response = await fetch('/api/multipass/account/countries', {\n headers: {\n 'current-language': locale,\n },\n })\n const res: any = await response.json()\n\n // \u65B0\u63A5\u53E3\u76F4\u63A5\u8FD4\u56DE\u56FD\u5BB6\u6570\u7EC4 [{ id, name, code }]\n let shipsToCountries: ShippingCountry[] = res?.data || res || []\n\n // \u5B57\u6BCD\u987A\u5E8F\u6392\u5E8F\n shipsToCountries = shipsToCountries.sort((a, b) => {\n return a.name.localeCompare(b.name)\n })\n\n console.log('fetch shipsToCountries', shipsToCountries)\n setCountries(shipsToCountries)\n } catch (e) {\n setCountries([])\n console.error(e)\n } finally {\n setLoading(false)\n }\n }\n\n fetchCountries()\n }, [locale])\n\n return {\n isLoading,\n countries,\n }\n}\n\nexport default useCountries\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,iBAEpCC,EAAmC,yBAGnC,SAASC,EAAa,CAAE,mBAAAC,CAAmB,EAAmC,CAC5E,KAAM,CAAE,OAAAC,EAAS,EAAG,KAAI,sBAAmB,EAErC,CAACC,EAAWC,CAAU,KAAI,YAAS,EAAK,EACxC,CAACC,EAAWC,CAAY,KAAI,YAA4B,CAAC,CAAC,EAEhE,sBAAU,IAAM,EACS,SAAY,CACjCF,EAAW,EAAI,EACf,GAAI,CAMF,MAAMG,EAAW,MALA,MAAM,MAAM,mCAAoC,CAC/D,QAAS,CACP,mBAAoBL,CACtB,CACF,CAAC,GAC+B,KAAK,EAGrC,IAAIM,EAAsCD,GAAK,MAAQA,GAAO,CAAC,EAG/DC,EAAmBA,EAAiB,KAAK,CAACC,EAAGC,IACpCD,EAAE,KAAK,cAAcC,EAAE,IAAI,CACnC,EAED,QAAQ,IAAI,yBAA0BF,CAAgB,EACtDF,EAAaE,CAAgB,CAC/B,OAASG,EAAG,CACVL,EAAa,CAAC,CAAC,EACf,QAAQ,MAAMK,CAAC,CACjB,QAAE,CACAP,EAAW,EAAK,CAClB,CACF,GAEe,CACjB,EAAG,CAACF,CAAM,CAAC,EAEJ,CACL,UAAAC,EACA,UAAAE,CACF,CACF,CAEA,IAAOT,EAAQI",
6
- "names": ["useCountries_exports", "__export", "useCountries_default", "__toCommonJS", "import_react", "import_lib", "useCountries", "shopifyStoreDomain", "locale", "isLoading", "setLoading", "countries", "setCountries", "res", "shipsToCountries", "a", "b", "e"]
4
+ "sourcesContent": ["import { useEffect, useState } from 'react'\n\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { type ShippingCountry } from '../../type'\n\nfunction useCountries({ shopifyStoreDomain }: { shopifyStoreDomain: string }) {\n const { locale = '' } = useHeadlessContext()\n\n const [isLoading, setLoading] = useState(false)\n const [countries, setCountries] = useState<ShippingCountry[]>([])\n\n useEffect(() => {\n const fetchCountries = async () => {\n setLoading(true)\n try {\n const response = await fetch('/api/multipass/account/countries', {\n headers: {\n 'current-language': locale,\n },\n })\n const res: any = await response.json()\n\n let shipsToCountries: ShippingCountry[] = res?.data?.data || []\n\n // \u5B57\u6BCD\u987A\u5E8F\u6392\u5E8F\n shipsToCountries = shipsToCountries.sort((a, b) => {\n return a.name.localeCompare(b.name)\n })\n\n console.log('fetch shipsToCountries', shipsToCountries)\n setCountries(shipsToCountries)\n } catch (e) {\n setCountries([])\n console.error(e)\n } finally {\n setLoading(false)\n }\n }\n\n fetchCountries()\n }, [locale])\n\n return {\n isLoading,\n countries,\n }\n}\n\nexport default useCountries\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,iBAEpCC,EAAmC,yBAGnC,SAASC,EAAa,CAAE,mBAAAC,CAAmB,EAAmC,CAC5E,KAAM,CAAE,OAAAC,EAAS,EAAG,KAAI,sBAAmB,EAErC,CAACC,EAAWC,CAAU,KAAI,YAAS,EAAK,EACxC,CAACC,EAAWC,CAAY,KAAI,YAA4B,CAAC,CAAC,EAEhE,sBAAU,IAAM,EACS,SAAY,CACjCF,EAAW,EAAI,EACf,GAAI,CAQF,IAAIG,GAFa,MALA,MAAM,MAAM,mCAAoC,CAC/D,QAAS,CACP,mBAAoBL,CACtB,CACF,CAAC,GAC+B,KAAK,IAEU,MAAM,MAAQ,CAAC,EAG9DK,EAAmBA,EAAiB,KAAK,CAACC,EAAGC,IACpCD,EAAE,KAAK,cAAcC,EAAE,IAAI,CACnC,EAED,QAAQ,IAAI,yBAA0BF,CAAgB,EACtDD,EAAaC,CAAgB,CAC/B,OAASG,EAAG,CACVJ,EAAa,CAAC,CAAC,EACf,QAAQ,MAAMI,CAAC,CACjB,QAAE,CACAN,EAAW,EAAK,CAClB,CACF,GAEe,CACjB,EAAG,CAACF,CAAM,CAAC,EAEJ,CACL,UAAAC,EACA,UAAAE,CACF,CACF,CAEA,IAAOT,EAAQI",
6
+ "names": ["useCountries_exports", "__export", "useCountries_default", "__toCommonJS", "import_react", "import_lib", "useCountries", "shopifyStoreDomain", "locale", "isLoading", "setLoading", "countries", "setCountries", "shipsToCountries", "a", "b", "e"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";"use client";var U=Object.create;var g=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var G=(e,n)=>{for(var i in n)g(e,i,{get:n[i],enumerable:!0})},k=(e,n,i,d)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of W(n))!F.call(e,l)&&l!==i&&g(e,l,{get:()=>n[l],enumerable:!(d=B(n,l))||d.enumerable});return e};var m=(e,n,i)=>(i=e!=null?U(q(e)):{},k(n||!e||!e.__esModule?g(i,"default",{value:e,enumerable:!0}):i,e)),J=e=>k(g({},"__esModule",{value:!0}),e);var ne={};G(ne,{MemberPopup:()=>se});module.exports=J(ne);var t=require("react/jsx-runtime"),r=require("react"),M=require("@anker-in/headless-ui"),f=require("@anker-in/lib"),s=require("./type"),O=require("./context/provider"),A=require("./context/provider"),V=require("./context/viewStack"),a=require("./icons"),R=require("../../constants");const K=(0,r.lazy)(()=>import("./panels/EarnCredits")),Q=(0,r.lazy)(()=>import("./panels/ConsumeCredits")),X=(0,r.lazy)(()=>import("./panels/Referral")),Y=(0,r.lazy)(()=>import("./panels/EarnCredits/CompleteProfilePanel")),Z=(0,r.lazy)(()=>import("./panels/EarnCredits/SubscribePanel")),$=(0,r.lazy)(()=>import("./panels/EarnCredits/SubscribeEmailPanel")),ee=(0,r.lazy)(()=>import("./panels/EarnCredits/ActivatePanel")),te=(0,r.lazy)(()=>import("./panels/ConsumeCredits/RedeemCouponPanel"));function se({copy:e,bottomOffset:n="24px",...i}){return(0,t.jsx)(O.MemberPopupProvider,{...i,earnCreditsCopy:e.earnCredits,children:(0,t.jsx)(oe,{copy:e,bottomOffset:n})})}function oe({copy:e,bottomOffset:n}){const{profile:i,openSignInPopup:d,openSignUpPopup:l}=(0,A.useMemberPopupContext)(),{brand:x,storeDomain:C}=(0,f.useHeadlessContext)(),v=R.ROUNDED_BRANDS.includes(x),z=!!i,[S,N]=(0,r.useState)(!1),[w,P]=(0,r.useState)([]),[E,H]=(0,r.useState)(!1),[T,j]=(0,r.useState)(!1),[_,D]=(0,r.useState)(!1),o=w[w.length-1]??null;if(!(0,r.useMemo)(()=>{const p=e.pageConfig;if(!p)return!0;const u=typeof window<"u"?window.location.pathname:"",y=p.pages.some(I=>u===I||u.startsWith(I+"/"));switch(p.scope){case s.MemberPopupPageScope.Include:return y;case s.MemberPopupPageScope.Exclude:return!y;default:return!0}},[e.pageConfig]))return null;const b=(0,r.useCallback)(p=>{P(u=>[...u,p])},[]),c=(0,r.useCallback)(()=>{P(p=>p.slice(0,-1))},[]);function L(p,u){switch(p){case s.MemberPopupActionType.ExternalLink:u&&window.open(u,"_blank","noopener,noreferrer");break;case s.MemberPopupActionType.OpenEarnCredits:b({type:s.MemberPopupPanelType.EarnCredits});break;case s.MemberPopupActionType.OpenConsumeCredits:b({type:s.MemberPopupPanelType.ConsumeCredits});break;case s.MemberPopupActionType.OpenReferral:b({type:s.MemberPopupPanelType.Referral});break;case s.MemberPopupActionType.OpenSubscribe:b({type:s.MemberPopupPanelType.Subscribe});break}}function h(){N(!1),P([])}return(0,t.jsxs)(V.ViewStackContext.Provider,{value:{pushView:b,popView:c},children:[S&&(0,t.jsx)("div",{className:"fixed inset-0 z-[998]",onClick:h}),(0,t.jsxs)("div",{className:"fixed right-0 z-[999] flex flex-col items-end pr-[16px]",style:{bottom:n},children:[S&&(0,t.jsxs)("div",{className:(0,f.classNames)("relative mb-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[600px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] cmp-md:w-[358px] cmp-sm:w-[258px]",v?"rounded-[12px]":"rounded-none"),onClick:p=>p.stopPropagation(),children:[(0,t.jsx)("div",{className:"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white"}),(0,t.jsxs)("div",{className:"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]",children:[o!==null&&(0,t.jsx)("button",{className:"mr-auto flex size-[24px] cursor-pointer items-center justify-center",onClick:c,"aria-label":"Back",children:(0,t.jsx)(a.IconSwitch,{})}),(0,t.jsx)("button",{className:"flex size-[24px] cursor-pointer items-center justify-center",onClick:h,"aria-label":"Close",children:(0,t.jsx)(a.IconClose,{})})]}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]",style:{maxHeight:"min(calc(80vh - 118px), 606px)"},children:[o===null&&(0,t.jsxs)(t.Fragment,{children:[(e.title||e.subtitle)&&(0,t.jsxs)("div",{className:"flex flex-col gap-[4px]",children:[e.title&&(0,t.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),e.subtitle&&(0,t.jsx)("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:e.subtitle})]}),e.list.map((p,u)=>(0,t.jsx)(re,{item:p,onAction:L,rounded:v},u))]}),o!==null&&(0,t.jsxs)(r.Suspense,{fallback:(0,t.jsx)("div",{className:"flex items-center justify-center py-[32px]",children:(0,t.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}),children:[o.type===s.MemberPopupPanelType.EarnCredits&&e.earnCredits&&(0,t.jsx)(K,{copy:e.earnCredits,onClose:c,isSubscribeSuccess:E,isActivateSuccess:T,isProfileCompleteSuccess:_,onSubscribeSuccess:()=>H(!0),onActivateSuccess:()=>j(!0),onProfileCompleteSuccess:()=>D(!0)}),o.type===s.MemberPopupPanelType.ConsumeCredits&&e.consumeCredits&&(0,t.jsx)(Q,{copy:e.consumeCredits,onClose:c}),o.type===s.MemberPopupPanelType.Referral&&e.referral&&(0,t.jsx)(X,{copy:e.referral,onClose:c}),o.type===s.MemberPopupPanelType.CompleteProfile&&e.earnCredits&&(0,t.jsx)(Y,{copy:e.earnCredits.completeProfile,shopifyStoreDomain:C,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.Subscribe&&e.subscribe&&(0,t.jsx)(Z,{copy:e.subscribe,email:i?.email,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.SubscribeEmail&&e.earnCredits&&(0,t.jsx)($,{copy:e.earnCredits.subscribe,email:i?.email,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.Activate&&e.earnCredits&&(0,t.jsx)(ee,{copy:e.earnCredits.authCodeActivate,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.RedeemCoupon&&o.props&&e.consumeCredits&&(0,t.jsx)(te,{itemTitle:o.props.itemTitle,itemCredits:o.props.itemCredits,itemImage:o.props.itemImage,itemValue:o.props.itemValue,itemOff:o.props.itemOff,redeemId:o.props.redeemId,userId:o.props.userId,alpcConfig:o.props.alpcConfig,copy:e.consumeCredits.redeemModal,pointUnit:e.consumeCredits.pointUnit,onClose:c})]})]}),e.footer&&!z&&(0,t.jsx)("div",{className:"border-t border-[#dadce0] p-[16px]",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-[16px]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[14px] font-[700] text-[#080a0f]",children:e.footer.loginHint}),(0,t.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline",onClick:d,children:e.footer.loginLabel})]}),(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-[8px]",children:(0,t.jsx)("button",{className:(0,f.classNames)("cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]",v?"rounded-[4px]":"rounded-none"),onClick:l,children:e.footer.joinLabel})})]})})]}),(0,t.jsx)("button",{className:"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg",onClick:()=>N(p=>!p),"aria-label":e.triggerImg.alt??"Open member popup",children:(0,t.jsx)(M.Picture,{source:e.triggerImg.url,alt:e.triggerImg.alt??"",className:"size-[58px]"})})]})]})}function re({item:e,onAction:n,rounded:i}){const d={[s.MemberPopupActionType.OpenEarnCredits]:a.IconCredit,[s.MemberPopupActionType.OpenConsumeCredits]:a.IconBag,[s.MemberPopupActionType.OpenReferral]:a.IconReferral,[s.MemberPopupActionType.OpenSubscribe]:a.IconSubscription};return(0,t.jsxs)("div",{className:(0,f.classNames)("flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]",i?"rounded-[8px]":"rounded-none"),children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[4px]",children:[(0,t.jsx)("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#1e2024]",children:e.title}),e.description&&(0,t.jsx)("p",{className:"text-[14px] font-[700] leading-[1.43] text-[#1e2024]",children:e.description})]}),(0,t.jsx)("div",{className:"flex flex-col gap-[16px]",children:e.links.map((l,x)=>{const C=d[l.type];return(0,t.jsxs)("div",{children:[x>0&&(0,t.jsx)("div",{className:"mb-[16px] h-px bg-[#dadce0]"}),(0,t.jsxs)("button",{className:"flex w-full cursor-pointer items-center gap-[12px]",onClick:()=>n(l.type,l.url),children:[C&&(0,t.jsx)(C,{className:"size-[24px] shrink-0"}),(0,t.jsx)("span",{className:"flex-1 text-left text-[14px] font-[700] text-[#1e2024]",children:l.label}),(0,t.jsx)(a.IconArrow,{className:"size-[16px] shrink-0"})]})]},x)})})]})}
1
+ "use strict";"use client";var B=Object.create;var g=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var K=(e,i)=>{for(var n in i)g(e,n,{get:i[n],enumerable:!0})},M=(e,i,n,u)=>{if(i&&typeof i=="object"||typeof i=="function")for(let l of q(i))!J.call(e,l)&&l!==n&&g(e,l,{get:()=>i[l],enumerable:!(u=W(i,l))||u.enumerable});return e};var d=(e,i,n)=>(n=e!=null?B(G(e)):{},M(i||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),Q=e=>M(g({},"__esModule",{value:!0}),e);var pe={};K(pe,{MemberPopup:()=>re});module.exports=Q(pe);var t=require("react/jsx-runtime"),r=require("react"),O=require("@anker-in/headless-ui"),f=require("@anker-in/lib"),s=require("./type"),A=require("./context/provider"),V=require("./context/provider"),R=require("./context/viewStack"),a=require("./icons"),H=require("../../constants");const X=(0,r.lazy)(()=>import("./panels/EarnCredits")),Y=(0,r.lazy)(()=>import("./panels/ConsumeCredits")),Z=(0,r.lazy)(()=>import("./panels/Referral")),$=(0,r.lazy)(()=>import("./panels/EarnCredits/CompleteProfilePanel")),ee=(0,r.lazy)(()=>import("./panels/ActivitiesSubscribePanel")),te=(0,r.lazy)(()=>import("./panels/EarnCredits/SubscribeEmailPanel")),se=(0,r.lazy)(()=>import("./panels/EarnCredits/ActivatePanel")),oe=(0,r.lazy)(()=>import("./panels/ConsumeCredits/RedeemCouponPanel"));function re({copy:e,bottomOffset:i="24px",...n}){return(0,t.jsx)(A.MemberPopupProvider,{...n,earnCreditsCopy:e.earnCredits,children:(0,t.jsx)(ie,{copy:e,bottomOffset:i})})}function ie({copy:e,bottomOffset:i}){const{profile:n,openSignInPopup:u,openSignUpPopup:l}=(0,V.useMemberPopupContext)(),{brand:x,storeDomain:C}=(0,f.useHeadlessContext)(),v=H.ROUNDED_BRANDS.includes(x),z=!!n,[S,w]=(0,r.useState)(!1),[h,P]=(0,r.useState)([]),[E,T]=(0,r.useState)(!1),[j,_]=(0,r.useState)(!1),[D,F]=(0,r.useState)(!1),[L,N]=(0,r.useState)(!1),o=h[h.length-1]??null;if(!(0,r.useMemo)(()=>{const p=e.pageConfig;if(!p)return!0;const m=typeof window<"u"?window.location.pathname:"",I=p.pages.some(k=>m===k||m.startsWith(k+"/"));switch(p.scope){case s.MemberPopupPageScope.Include:return I;case s.MemberPopupPageScope.Exclude:return!I;default:return!0}},[e.pageConfig]))return null;const b=(0,r.useCallback)(p=>{P(m=>[...m,p])},[]),c=(0,r.useCallback)(()=>{P(p=>p.slice(0,-1))},[]);function U(p,m){switch(p){case s.MemberPopupActionType.ExternalLink:m&&window.open(m,"_blank","noopener,noreferrer");break;case s.MemberPopupActionType.OpenEarnCredits:b({type:s.MemberPopupPanelType.EarnCredits});break;case s.MemberPopupActionType.OpenConsumeCredits:b({type:s.MemberPopupPanelType.ConsumeCredits});break;case s.MemberPopupActionType.OpenReferral:b({type:s.MemberPopupPanelType.Referral});break;case s.MemberPopupActionType.OpenSubscribe:b({type:s.MemberPopupPanelType.Subscribe});break}}function y(){w(!1),P([]),N(!1)}return(0,t.jsxs)(R.ViewStackContext.Provider,{value:{pushView:b,popView:c},children:[S&&(0,t.jsx)("div",{className:"fixed inset-0 z-[998]",onClick:y}),(0,t.jsxs)("div",{className:"fixed right-0 z-[999] flex flex-row items-end pr-[16px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0",style:{bottom:i},children:[S&&(0,t.jsxs)("div",{className:(0,f.classNames)("relative mr-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[500px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] md:mr-0 md:mb-[8px] md:mx-[16px] md:w-[calc(100vw-32px)] md:max-w-[400px]",v?"rounded-[12px]":"rounded-none"),style:{maxHeight:"min(80vh, 606px)"},onClick:p=>p.stopPropagation(),children:[(0,t.jsx)("div",{className:"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white md:bottom-[-8px] md:left-auto md:right-[29px] md:top-auto md:border-x-8 md:border-b-transparent md:border-t-white"}),(0,t.jsxs)("div",{className:"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]",children:[o!==null&&(0,t.jsx)("button",{className:"mr-auto flex size-[24px] cursor-pointer items-center justify-center",onClick:c,"aria-label":"Back",children:(0,t.jsx)(a.IconSwitch,{})}),(0,t.jsx)("button",{className:"flex size-[24px] cursor-pointer items-center justify-center",onClick:y,"aria-label":"Close",children:(0,t.jsx)(a.IconClose,{})})]}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]",children:[o===null&&(0,t.jsxs)(t.Fragment,{children:[(e.title||e.subtitle)&&(0,t.jsxs)("div",{className:"flex flex-col gap-[4px]",children:[e.title&&(0,t.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),e.subtitle&&(0,t.jsx)("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:e.subtitle})]}),e.list.map((p,m)=>(0,t.jsx)(ne,{item:p,onAction:U,rounded:v},m))]}),o!==null&&(0,t.jsxs)(r.Suspense,{fallback:(0,t.jsx)("div",{className:"flex items-center justify-center py-[32px]",children:(0,t.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}),children:[o.type===s.MemberPopupPanelType.EarnCredits&&e.earnCredits&&(0,t.jsx)(X,{copy:e.earnCredits,onClose:c,isSubscribeSuccess:E,isActivateSuccess:j,isProfileCompleteSuccess:D,onSubscribeSuccess:()=>T(!0),onActivateSuccess:()=>_(!0),onProfileCompleteSuccess:()=>F(!0)}),o.type===s.MemberPopupPanelType.ConsumeCredits&&e.consumeCredits&&(0,t.jsx)(Y,{copy:e.consumeCredits,onClose:c}),o.type===s.MemberPopupPanelType.Referral&&e.referral&&(0,t.jsx)(Z,{copy:e.referral,onClose:c}),o.type===s.MemberPopupPanelType.CompleteProfile&&e.earnCredits&&(0,t.jsx)($,{copy:e.earnCredits.completeProfile,shopifyStoreDomain:C,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.Subscribe&&e.activitiesSubscribe&&(0,t.jsx)(ee,{copy:e.activitiesSubscribe,email:n?.email,onSuccess:o.props?.onSuccess,hideForm:L,onHideForm:()=>N(!0)}),o.type===s.MemberPopupPanelType.SubscribeEmail&&e.earnCredits&&(0,t.jsx)(te,{copy:e.earnCredits.subscribe,email:n?.email,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.Activate&&e.earnCredits&&(0,t.jsx)(se,{copy:e.earnCredits.authCodeActivate,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.RedeemCoupon&&o.props&&e.consumeCredits&&(0,t.jsx)(oe,{itemTitle:o.props.itemTitle,itemCredits:o.props.itemCredits,itemImage:o.props.itemImage,itemValue:o.props.itemValue,itemOff:o.props.itemOff,itemRules:o.props.itemRules,redeemId:o.props.redeemId,userId:o.props.userId,alpcConfig:o.props.alpcConfig,copy:e.consumeCredits.redeemModal,pointUnit:e.consumeCredits.pointUnit,onClose:c})]})]}),e.footer&&!z&&(0,t.jsx)("div",{className:"border-t border-[#dadce0] p-[16px]",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-[16px]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[14px] font-[700] text-[#080a0f]",children:e.footer.loginHint}),(0,t.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline",onClick:u,children:e.footer.loginLabel})]}),(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-[8px]",children:(0,t.jsx)("button",{className:(0,f.classNames)("cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]",v?"rounded-[4px]":"rounded-none"),onClick:l,children:e.footer.joinLabel})})]})})]}),(0,t.jsx)("button",{className:"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg md:ml-auto md:mr-[16px]",onClick:()=>w(p=>!p),"aria-label":e.triggerImg.alt??"Open member popup",children:(0,t.jsx)(O.Picture,{source:e.triggerImg.url,alt:e.triggerImg.alt??"",className:"size-[58px]"})})]})]})}function ne({item:e,onAction:i,rounded:n}){const u={[s.MemberPopupActionType.OpenEarnCredits]:a.IconCredit,[s.MemberPopupActionType.OpenConsumeCredits]:a.IconBag,[s.MemberPopupActionType.OpenReferral]:a.IconReferral,[s.MemberPopupActionType.OpenSubscribe]:a.IconSubscription};return(0,t.jsxs)("div",{className:(0,f.classNames)("flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]",n?"rounded-[8px]":"rounded-none"),children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[4px]",children:[(0,t.jsx)("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#1e2024]",children:e.title}),e.description&&(0,t.jsx)("p",{className:"text-[14px] font-[700] leading-[1.43] text-[#1e2024]",children:e.description})]}),(0,t.jsx)("div",{className:"flex flex-col gap-[16px]",children:e.links.map((l,x)=>{const C=u[l.type];return(0,t.jsxs)("div",{children:[x>0&&(0,t.jsx)("div",{className:"mb-[16px] h-px bg-[#dadce0]"}),(0,t.jsxs)("button",{className:"flex w-full cursor-pointer items-center gap-[12px]",onClick:()=>i(l.type,l.url),children:[C&&(0,t.jsx)(C,{className:"size-[24px] shrink-0"}),(0,t.jsx)("span",{className:"flex-1 text-left text-[14px] font-[700] text-[#1e2024]",children:l.label}),(0,t.jsx)(a.IconArrow,{className:"size-[16px] shrink-0"})]})]},x)})})]})}
2
2
  //# sourceMappingURL=MemberPopup.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/memberPopup/MemberPopup.tsx"],
4
- "sourcesContent": ["'use client'\n\nimport { lazy, Suspense, useState, useCallback, useMemo } from 'react'\nimport { Picture } from '@anker-in/headless-ui'\nimport { type HeadlessConfig, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport {\n MemberPopupActionType,\n MemberPopupPageScope,\n MemberPopupPanelType,\n type MemberPopupCopy,\n type MemberPopupContextValue,\n type MemberPopupItem,\n} from './type'\nimport { MemberPopupProvider } from './context/provider'\nimport { useMemberPopupContext } from './context/provider'\nimport { ViewStackContext, type ViewPayload } from './context/viewStack'\nimport { IconClose, IconArrow, IconCredit, IconBag, IconReferral, IconSwitch, IconSubscription } from './icons'\nimport { ROUNDED_BRANDS } from '../../constants'\n\nconst EarnCredits = lazy(() => import('./panels/EarnCredits'))\nconst ConsumeCredits = lazy(() => import('./panels/ConsumeCredits'))\nconst Referral = lazy(() => import('./panels/Referral'))\nconst CompleteProfile = lazy(() => import('./panels/EarnCredits/CompleteProfilePanel'))\nconst Subscribe = lazy(() => import('./panels/EarnCredits/SubscribePanel'))\nconst SubscribeEmail = lazy(() => import('./panels/EarnCredits/SubscribeEmailPanel'))\nconst Activate = lazy(() => import('./panels/EarnCredits/ActivatePanel'))\nconst RedeemCoupon = lazy(() => import('./panels/ConsumeCredits/RedeemCouponPanel'))\n\ntype MemberPopupProps = MemberPopupContextValue & {\n headlessConfig: HeadlessConfig\n copy: MemberPopupCopy\n bottomOffset?: string\n}\n\nexport function MemberPopup({ copy, bottomOffset = '24px', ...providerProps }: MemberPopupProps) {\n return (\n <MemberPopupProvider {...providerProps} earnCreditsCopy={copy.earnCredits}>\n <MemberPopupContent copy={copy} bottomOffset={bottomOffset} />\n </MemberPopupProvider>\n )\n}\n\ntype MemberPopupContentProps = {\n copy: MemberPopupCopy\n bottomOffset: string\n}\n\nfunction MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {\n const { profile, openSignInPopup, openSignUpPopup } = useMemberPopupContext()\n const { brand, storeDomain } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const isLogin = !!profile\n const [isOpen, setIsOpen] = useState(false)\n const [viewStack, setViewStack] = useState<ViewPayload[]>([])\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isActivateSuccess, setIsActivateSuccess] = useState(false)\n const [isProfileCompleteSuccess, setIsProfileCompleteSuccess] = useState(false)\n\n const currentView = viewStack[viewStack.length - 1] ?? null\n\n const isVisible = useMemo(() => {\n const config = copy.pageConfig\n if (!config) return true\n const pathname = typeof window !== 'undefined' ? window.location.pathname : ''\n const matches = config.pages.some(page => pathname === page || pathname.startsWith(page + '/'))\n switch (config.scope) {\n case MemberPopupPageScope.Include:\n return matches\n case MemberPopupPageScope.Exclude:\n return !matches\n default:\n return true\n }\n }, [copy.pageConfig])\n\n if (!isVisible) return null\n\n const pushView = useCallback((view: ViewPayload) => {\n setViewStack(prev => [...prev, view])\n }, [])\n\n const popView = useCallback(() => {\n setViewStack(prev => prev.slice(0, -1))\n }, [])\n\n function handleAction(type: MemberPopupActionType, url?: string) {\n switch (type) {\n case MemberPopupActionType.ExternalLink:\n if (url) window.open(url, '_blank', 'noopener,noreferrer')\n break\n case MemberPopupActionType.OpenEarnCredits:\n pushView({ type: MemberPopupPanelType.EarnCredits })\n break\n case MemberPopupActionType.OpenConsumeCredits:\n pushView({ type: MemberPopupPanelType.ConsumeCredits })\n break\n case MemberPopupActionType.OpenReferral:\n pushView({ type: MemberPopupPanelType.Referral })\n break\n case MemberPopupActionType.OpenSubscribe:\n pushView({ type: MemberPopupPanelType.Subscribe })\n break\n }\n }\n\n function handleClose() {\n setIsOpen(false)\n setViewStack([])\n }\n\n return (\n <ViewStackContext.Provider value={{ pushView, popView }}>\n {isOpen && <div className=\"fixed inset-0 z-[998]\" onClick={handleClose} />}\n <div className=\"fixed right-0 z-[999] flex flex-col items-end pr-[16px]\" style={{ bottom: bottomOffset }}>\n {isOpen && (\n <div\n className={cn(\n 'relative mb-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[600px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] cmp-md:w-[358px] cmp-sm:w-[258px]',\n rounded ? 'rounded-[12px]' : 'rounded-none'\n )}\n onClick={e => e.stopPropagation()}\n >\n <div className=\"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white\" />\n <div className=\"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]\">\n {currentView !== null && (\n <button\n className=\"mr-auto flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={popView}\n aria-label=\"Back\"\n >\n <IconSwitch />\n </button>\n )}\n <button\n className=\"flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={handleClose}\n aria-label=\"Close\"\n >\n <IconClose />\n </button>\n </div>\n\n <div\n className=\"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]\"\n style={{ maxHeight: 'min(calc(80vh - 118px), 606px)' }}\n >\n {currentView === null && (\n <>\n {(copy.title || copy.subtitle) && (\n <div className=\"flex flex-col gap-[4px]\">\n {copy.title && (\n <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>\n )}\n {copy.subtitle && (\n <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>\n )}\n </div>\n )}\n {copy.list.map((item, i) => (\n <HomeCard key={i} item={item} onAction={handleAction} rounded={rounded} />\n ))}\n </>\n )}\n\n {currentView !== null && (\n <Suspense\n fallback={\n <div className=\"flex items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n }\n >\n {currentView.type === MemberPopupPanelType.EarnCredits && copy.earnCredits && (\n <EarnCredits\n copy={copy.earnCredits}\n onClose={popView}\n isSubscribeSuccess={isSubscribeSuccess}\n isActivateSuccess={isActivateSuccess}\n isProfileCompleteSuccess={isProfileCompleteSuccess}\n onSubscribeSuccess={() => setIsSubscribeSuccess(true)}\n onActivateSuccess={() => setIsActivateSuccess(true)}\n onProfileCompleteSuccess={() => setIsProfileCompleteSuccess(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.ConsumeCredits && copy.consumeCredits && (\n <ConsumeCredits copy={copy.consumeCredits} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.Referral && copy.referral && (\n <Referral copy={copy.referral} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.CompleteProfile && copy.earnCredits && (\n <CompleteProfile\n copy={copy.earnCredits.completeProfile}\n shopifyStoreDomain={storeDomain}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Subscribe && copy.subscribe && (\n <Subscribe\n copy={copy.subscribe}\n email={profile?.email}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.SubscribeEmail && copy.earnCredits && (\n <SubscribeEmail\n copy={copy.earnCredits.subscribe}\n email={profile?.email}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Activate && copy.earnCredits && (\n <Activate\n copy={copy.earnCredits.authCodeActivate}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.RedeemCoupon &&\n currentView.props &&\n copy.consumeCredits && (\n <RedeemCoupon\n itemTitle={currentView.props.itemTitle}\n itemCredits={currentView.props.itemCredits}\n itemImage={currentView.props.itemImage}\n itemValue={currentView.props.itemValue}\n itemOff={currentView.props.itemOff}\n redeemId={currentView.props.redeemId}\n userId={currentView.props.userId}\n alpcConfig={currentView.props.alpcConfig}\n copy={copy.consumeCredits.redeemModal}\n pointUnit={copy.consumeCredits.pointUnit}\n onClose={popView}\n />\n )}\n </Suspense>\n )}\n </div>\n\n {copy.footer && !isLogin && (\n <div className=\"border-t border-[#dadce0] p-[16px]\">\n <div className=\"flex items-center justify-between gap-[16px]\">\n <div className=\"flex items-center gap-[4px]\">\n <span className=\"text-[14px] font-[700] text-[#080a0f]\">{copy.footer.loginHint}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={openSignInPopup}\n >\n {copy.footer.loginLabel}\n </button>\n </div>\n <div className=\"flex shrink-0 items-center gap-[8px]\">\n <button\n className={cn(\n 'cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={openSignUpPopup}\n >\n {copy.footer.joinLabel}\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n )}\n\n <button\n className=\"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg\"\n onClick={() => setIsOpen(prev => !prev)}\n aria-label={copy.triggerImg.alt ?? 'Open member popup'}\n >\n <Picture source={copy.triggerImg.url} alt={copy.triggerImg.alt ?? ''} className=\"size-[58px]\" />\n </button>\n </div>\n </ViewStackContext.Provider>\n )\n}\n\ntype HomeCardProps = {\n item: MemberPopupItem\n onAction: (type: MemberPopupActionType, url?: string) => void\n rounded: boolean\n}\n\nfunction HomeCard({ item, onAction, rounded }: HomeCardProps) {\n const ACTION_ICON: Partial<Record<MemberPopupActionType, typeof IconCredit>> = {\n [MemberPopupActionType.OpenEarnCredits]: IconCredit,\n [MemberPopupActionType.OpenConsumeCredits]: IconBag,\n [MemberPopupActionType.OpenReferral]: IconReferral,\n [MemberPopupActionType.OpenSubscribe]: IconSubscription,\n }\n\n return (\n <div className={cn('flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <div className=\"flex flex-col gap-[4px]\">\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#1e2024]\">{item.title}</h3>\n {item.description && <p className=\"text-[14px] font-[700] leading-[1.43] text-[#1e2024]\">{item.description}</p>}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {item.links.map((link, i) => {\n const IconComponent = ACTION_ICON[link.type]\n return (\n <div key={i}>\n {i > 0 && <div className=\"mb-[16px] h-px bg-[#dadce0]\" />}\n <button\n className=\"flex w-full cursor-pointer items-center gap-[12px]\"\n onClick={() => onAction(link.type, link.url)}\n >\n {IconComponent && <IconComponent className=\"size-[24px] shrink-0\" />}\n <span className=\"flex-1 text-left text-[14px] font-[700] text-[#1e2024]\">{link.label}</span>\n <IconArrow className=\"size-[16px] shrink-0\" />\n </button>\n </div>\n )\n })}\n </div>\n </div>\n )\n}\n"],
5
- "mappings": "ukBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,iBAAAE,KAAA,eAAAC,EAAAH,IAqCM,IAAAI,EAAA,6BAnCNC,EAA+D,iBAC/DC,EAAwB,iCACxBC,EAA0E,yBAC1EC,EAOO,kBACPC,EAAoC,8BACpCA,EAAsC,8BACtCC,EAAmD,+BACnDC,EAAsG,mBACtGC,EAA+B,2BAE/B,MAAMC,KAAc,QAAK,IAAM,OAAO,sBAAsB,CAAC,EACvDC,KAAiB,QAAK,IAAM,OAAO,yBAAyB,CAAC,EAC7DC,KAAW,QAAK,IAAM,OAAO,mBAAmB,CAAC,EACjDC,KAAkB,QAAK,IAAM,OAAO,2CAA2C,CAAC,EAChFC,KAAY,QAAK,IAAM,OAAO,qCAAqC,CAAC,EACpEC,KAAiB,QAAK,IAAM,OAAO,0CAA0C,CAAC,EAC9EC,MAAW,QAAK,IAAM,OAAO,oCAAoC,CAAC,EAClEC,MAAe,QAAK,IAAM,OAAO,2CAA2C,CAAC,EAQ5E,SAASlB,GAAY,CAAE,KAAAmB,EAAM,aAAAC,EAAe,OAAQ,GAAGC,CAAc,EAAqB,CAC/F,SACE,OAAC,uBAAqB,GAAGA,EAAe,gBAAiBF,E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,wBAAsB,YAAY,EAAG,eACtC,CAAC,wBAAsB,aAAa,EAAG,kBACzC,EAEA,SACE,QAAC,OAAI,aAAW,EAAAN,YAAG,iDAAkDzB,EAAU,gBAAkB,cAAc,EAC7G,qBAAC,OAAI,UAAU,0BACb,oBAAC,MAAG,UAAU,sDAAuD,SAAA2B,EAAK,MAAM,EAC/EA,EAAK,gBAAe,OAAC,KAAE,UAAU,uDAAwD,SAAAA,EAAK,YAAY,GAC7G,KAEA,OAAC,OAAI,UAAU,2BACZ,SAAAA,EAAK,MAAM,IAAI,CAACK,EAAMJ,IAAM,CAC3B,MAAMK,EAAgBF,EAAYC,EAAK,IAAI,EAC3C,SACE,QAAC,OACE,UAAAJ,EAAI,MAAK,OAAC,OAAI,UAAU,8BAA8B,KACvD,QAAC,UACC,UAAU,qDACV,QAAS,IAAME,EAASE,EAAK,KAAMA,EAAK,GAAG,EAE1C,UAAAC,MAAiB,OAACA,EAAA,CAAc,UAAU,uBAAuB,KAClE,OAAC,QAAK,UAAU,yDAA0D,SAAAD,EAAK,MAAM,KACrF,OAAC,aAAU,UAAU,uBAAuB,GAC9C,IATQJ,CAUV,CAEJ,CAAC,EACH,GACF,CAEJ",
6
- "names": ["MemberPopup_exports", "__export", "MemberPopup", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_type", "import_provider", "import_viewStack", "import_icons", "import_constants", "EarnCredits", "ConsumeCredits", "Referral", "CompleteProfile", "Subscribe", "SubscribeEmail", "Activate", "RedeemCoupon", "copy", "bottomOffset", "providerProps", "MemberPopupContent", "profile", "openSignInPopup", "openSignUpPopup", "brand", "storeDomain", "rounded", "isLogin", "isOpen", "setIsOpen", "viewStack", "setViewStack", "isSubscribeSuccess", "setIsSubscribeSuccess", "isActivateSuccess", "setIsActivateSuccess", "isProfileCompleteSuccess", "setIsProfileCompleteSuccess", "currentView", "config", "pathname", "matches", "page", "pushView", "view", "prev", "popView", "handleAction", "type", "url", "handleClose", "cn", "e", "item", "i", "HomeCard", "onAction", "ACTION_ICON", "link", "IconComponent"]
4
+ "sourcesContent": ["'use client'\n\nimport { lazy, Suspense, useState, useCallback, useMemo } from 'react'\nimport { Picture } from '@anker-in/headless-ui'\nimport { type HeadlessConfig, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport {\n MemberPopupActionType,\n MemberPopupPageScope,\n MemberPopupPanelType,\n type MemberPopupCopy,\n type MemberPopupContextValue,\n type MemberPopupItem,\n} from './type'\nimport { MemberPopupProvider } from './context/provider'\nimport { useMemberPopupContext } from './context/provider'\nimport { ViewStackContext, type ViewPayload } from './context/viewStack'\nimport { IconClose, IconArrow, IconCredit, IconBag, IconReferral, IconSwitch, IconSubscription } from './icons'\nimport { ROUNDED_BRANDS } from '../../constants'\n\nconst EarnCredits = lazy(() => import('./panels/EarnCredits'))\nconst ConsumeCredits = lazy(() => import('./panels/ConsumeCredits'))\nconst Referral = lazy(() => import('./panels/Referral'))\nconst CompleteProfile = lazy(() => import('./panels/EarnCredits/CompleteProfilePanel'))\nconst ActivitiesSubscribe = lazy(() => import('./panels/ActivitiesSubscribePanel'))\nconst SubscribeEmail = lazy(() => import('./panels/EarnCredits/SubscribeEmailPanel'))\nconst Activate = lazy(() => import('./panels/EarnCredits/ActivatePanel'))\nconst RedeemCoupon = lazy(() => import('./panels/ConsumeCredits/RedeemCouponPanel'))\n\ntype MemberPopupProps = MemberPopupContextValue & {\n headlessConfig: HeadlessConfig\n copy: MemberPopupCopy\n bottomOffset?: string\n}\n\nexport function MemberPopup({ copy, bottomOffset = '24px', ...providerProps }: MemberPopupProps) {\n return (\n <MemberPopupProvider {...providerProps} earnCreditsCopy={copy.earnCredits}>\n <MemberPopupContent copy={copy} bottomOffset={bottomOffset} />\n </MemberPopupProvider>\n )\n}\n\ntype MemberPopupContentProps = {\n copy: MemberPopupCopy\n bottomOffset: string\n}\n\nfunction MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {\n const { profile, openSignInPopup, openSignUpPopup } = useMemberPopupContext()\n const { brand, storeDomain } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const isLogin = !!profile\n const [isOpen, setIsOpen] = useState(false)\n const [viewStack, setViewStack] = useState<ViewPayload[]>([])\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isActivateSuccess, setIsActivateSuccess] = useState(false)\n const [isProfileCompleteSuccess, setIsProfileCompleteSuccess] = useState(false)\n const [isSubscribeFormHidden, setIsSubscribeFormHidden] = useState(false)\n\n const currentView = viewStack[viewStack.length - 1] ?? null\n\n const isVisible = useMemo(() => {\n const config = copy.pageConfig\n if (!config) return true\n const pathname = typeof window !== 'undefined' ? window.location.pathname : ''\n const matches = config.pages.some(page => pathname === page || pathname.startsWith(page + '/'))\n switch (config.scope) {\n case MemberPopupPageScope.Include:\n return matches\n case MemberPopupPageScope.Exclude:\n return !matches\n default:\n return true\n }\n }, [copy.pageConfig])\n\n if (!isVisible) return null\n\n const pushView = useCallback((view: ViewPayload) => {\n setViewStack(prev => [...prev, view])\n }, [])\n\n const popView = useCallback(() => {\n setViewStack(prev => prev.slice(0, -1))\n }, [])\n\n function handleAction(type: MemberPopupActionType, url?: string) {\n switch (type) {\n case MemberPopupActionType.ExternalLink:\n if (url) window.open(url, '_blank', 'noopener,noreferrer')\n break\n case MemberPopupActionType.OpenEarnCredits:\n pushView({ type: MemberPopupPanelType.EarnCredits })\n break\n case MemberPopupActionType.OpenConsumeCredits:\n pushView({ type: MemberPopupPanelType.ConsumeCredits })\n break\n case MemberPopupActionType.OpenReferral:\n pushView({ type: MemberPopupPanelType.Referral })\n break\n case MemberPopupActionType.OpenSubscribe:\n pushView({ type: MemberPopupPanelType.Subscribe })\n break\n }\n }\n\n function handleClose() {\n setIsOpen(false)\n setViewStack([])\n setIsSubscribeFormHidden(false)\n }\n\n return (\n <ViewStackContext.Provider value={{ pushView, popView }}>\n {isOpen && <div className=\"fixed inset-0 z-[998]\" onClick={handleClose} />}\n <div\n className=\"fixed right-0 z-[999] flex flex-row items-end pr-[16px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0\"\n style={{ bottom: bottomOffset }}\n >\n {isOpen && (\n <div\n className={cn(\n 'relative mr-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[500px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] md:mr-0 md:mb-[8px] md:mx-[16px] md:w-[calc(100vw-32px)] md:max-w-[400px]',\n rounded ? 'rounded-[12px]' : 'rounded-none'\n )}\n style={{ maxHeight: 'min(80vh, 606px)' }}\n onClick={e => e.stopPropagation()}\n >\n <div className=\"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white md:bottom-[-8px] md:left-auto md:right-[29px] md:top-auto md:border-x-8 md:border-b-transparent md:border-t-white\" />\n <div className=\"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]\">\n {currentView !== null && (\n <button\n className=\"mr-auto flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={popView}\n aria-label=\"Back\"\n >\n <IconSwitch />\n </button>\n )}\n <button\n className=\"flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={handleClose}\n aria-label=\"Close\"\n >\n <IconClose />\n </button>\n </div>\n\n <div className=\"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]\">\n {currentView === null && (\n <>\n {(copy.title || copy.subtitle) && (\n <div className=\"flex flex-col gap-[4px]\">\n {copy.title && (\n <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>\n )}\n {copy.subtitle && (\n <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>\n )}\n </div>\n )}\n {copy.list.map((item, i) => (\n <HomeCard key={i} item={item} onAction={handleAction} rounded={rounded} />\n ))}\n </>\n )}\n\n {currentView !== null && (\n <Suspense\n fallback={\n <div className=\"flex items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n }\n >\n {currentView.type === MemberPopupPanelType.EarnCredits && copy.earnCredits && (\n <EarnCredits\n copy={copy.earnCredits}\n onClose={popView}\n isSubscribeSuccess={isSubscribeSuccess}\n isActivateSuccess={isActivateSuccess}\n isProfileCompleteSuccess={isProfileCompleteSuccess}\n onSubscribeSuccess={() => setIsSubscribeSuccess(true)}\n onActivateSuccess={() => setIsActivateSuccess(true)}\n onProfileCompleteSuccess={() => setIsProfileCompleteSuccess(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.ConsumeCredits && copy.consumeCredits && (\n <ConsumeCredits copy={copy.consumeCredits} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.Referral && copy.referral && (\n <Referral copy={copy.referral} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.CompleteProfile && copy.earnCredits && (\n <CompleteProfile\n copy={copy.earnCredits.completeProfile}\n shopifyStoreDomain={storeDomain}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Subscribe && copy.activitiesSubscribe && (\n <ActivitiesSubscribe\n copy={copy.activitiesSubscribe}\n email={profile?.email}\n onSuccess={currentView.props?.onSuccess}\n hideForm={isSubscribeFormHidden}\n onHideForm={() => setIsSubscribeFormHidden(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.SubscribeEmail && copy.earnCredits && (\n <SubscribeEmail\n copy={copy.earnCredits.subscribe}\n email={profile?.email}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Activate && copy.earnCredits && (\n <Activate\n copy={copy.earnCredits.authCodeActivate}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.RedeemCoupon &&\n currentView.props &&\n copy.consumeCredits && (\n <RedeemCoupon\n itemTitle={currentView.props.itemTitle}\n itemCredits={currentView.props.itemCredits}\n itemImage={currentView.props.itemImage}\n itemValue={currentView.props.itemValue}\n itemOff={currentView.props.itemOff}\n itemRules={currentView.props.itemRules}\n redeemId={currentView.props.redeemId}\n userId={currentView.props.userId}\n alpcConfig={currentView.props.alpcConfig}\n copy={copy.consumeCredits.redeemModal}\n pointUnit={copy.consumeCredits.pointUnit}\n onClose={popView}\n />\n )}\n </Suspense>\n )}\n </div>\n\n {copy.footer && !isLogin && (\n <div className=\"border-t border-[#dadce0] p-[16px]\">\n <div className=\"flex items-center justify-between gap-[16px]\">\n <div className=\"flex items-center gap-[4px]\">\n <span className=\"text-[14px] font-[700] text-[#080a0f]\">{copy.footer.loginHint}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={openSignInPopup}\n >\n {copy.footer.loginLabel}\n </button>\n </div>\n <div className=\"flex shrink-0 items-center gap-[8px]\">\n <button\n className={cn(\n 'cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={openSignUpPopup}\n >\n {copy.footer.joinLabel}\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n )}\n\n <button\n className=\"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg md:ml-auto md:mr-[16px]\"\n onClick={() => setIsOpen(prev => !prev)}\n aria-label={copy.triggerImg.alt ?? 'Open member popup'}\n >\n <Picture source={copy.triggerImg.url} alt={copy.triggerImg.alt ?? ''} className=\"size-[58px]\" />\n </button>\n </div>\n </ViewStackContext.Provider>\n )\n}\n\ntype HomeCardProps = {\n item: MemberPopupItem\n onAction: (type: MemberPopupActionType, url?: string) => void\n rounded: boolean\n}\n\nfunction HomeCard({ item, onAction, rounded }: HomeCardProps) {\n const ACTION_ICON: Partial<Record<MemberPopupActionType, typeof IconCredit>> = {\n [MemberPopupActionType.OpenEarnCredits]: IconCredit,\n [MemberPopupActionType.OpenConsumeCredits]: IconBag,\n [MemberPopupActionType.OpenReferral]: IconReferral,\n [MemberPopupActionType.OpenSubscribe]: IconSubscription,\n }\n\n return (\n <div className={cn('flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <div className=\"flex flex-col gap-[4px]\">\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#1e2024]\">{item.title}</h3>\n {item.description && <p className=\"text-[14px] font-[700] leading-[1.43] text-[#1e2024]\">{item.description}</p>}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {item.links.map((link, i) => {\n const IconComponent = ACTION_ICON[link.type]\n return (\n <div key={i}>\n {i > 0 && <div className=\"mb-[16px] h-px bg-[#dadce0]\" />}\n <button\n className=\"flex w-full cursor-pointer items-center gap-[12px]\"\n onClick={() => onAction(link.type, link.url)}\n >\n {IconComponent && <IconComponent className=\"size-[24px] shrink-0\" />}\n <span className=\"flex-1 text-left text-[14px] font-[700] text-[#1e2024]\">{link.label}</span>\n <IconArrow className=\"size-[16px] shrink-0\" />\n </button>\n </div>\n )\n })}\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": "ukBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,iBAAAE,KAAA,eAAAC,EAAAH,IAqCM,IAAAI,EAAA,6BAnCNC,EAA+D,iBAC/DC,EAAwB,iCACxBC,EAA0E,yBAC1EC,EAOO,kBACPC,EAAoC,8BACpCA,EAAsC,8BACtCC,EAAmD,+BACnDC,EAAsG,mBACtGC,EAA+B,2BAE/B,MAAMC,KAAc,QAAK,IAAM,OAAO,sBAAsB,CAAC,EACvDC,KAAiB,QAAK,IAAM,OAAO,yBAAyB,CAAC,EAC7DC,KAAW,QAAK,IAAM,OAAO,mBAAmB,CAAC,EACjDC,KAAkB,QAAK,IAAM,OAAO,2CAA2C,CAAC,EAChFC,MAAsB,QAAK,IAAM,OAAO,mCAAmC,CAAC,EAC5EC,MAAiB,QAAK,IAAM,OAAO,0CAA0C,CAA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AAS,IAAMY,EAAUkB,GAAQ,CAACA,CAAI,EACtC,aAAY9B,EAAK,WAAW,KAAO,oBAEnC,mBAAC,WAAQ,OAAQA,EAAK,WAAW,IAAK,IAAKA,EAAK,WAAW,KAAO,GAAI,UAAU,cAAc,EAChG,GACF,GACF,CAEJ,CAQA,SAASwC,GAAS,CAAE,KAAAF,EAAM,SAAAG,EAAU,QAAAhC,CAAQ,EAAkB,CAC5D,MAAMiC,EAAyE,CAC7E,CAAC,wBAAsB,eAAe,EAAG,aACzC,CAAC,wBAAsB,kBAAkB,EAAG,UAC5C,CAAC,wBAAsB,YAAY,EAAG,eACtC,CAAC,wBAAsB,aAAa,EAAG,kBACzC,EAEA,SACE,QAAC,OAAI,aAAW,EAAAN,YAAG,iDAAkD3B,EAAU,gBAAkB,cAAc,EAC7G,qBAAC,OAAI,UAAU,0BACb,oBAAC,MAAG,UAAU,sDAAuD,SAAA6B,EAAK,MAAM,EAC/EA,EAAK,gBAAe,OAAC,KAAE,UAAU,uDAAwD,SAAAA,EAAK,YAAY,GAC7G,KAEA,OAAC,OAAI,UAAU,2BACZ,SAAAA,EAAK,MAAM,IAAI,CAACK,EAAMJ,IAAM,CAC3B,MAAMK,EAAgBF,EAAYC,EAAK,IAAI,EAC3C,SACE,QAAC,OACE,UAAAJ,EAAI,MAAK,OAAC,OAAI,UAAU,8BAA8B,KACvD,QAAC,UACC,UAAU,qDACV,QAAS,IAAME,EAASE,EAAK,KAAMA,EAAK,GAAG,EAE1C,UAAAC,MAAiB,OAACA,EAAA,CAAc,UAAU,uBAAuB,KAClE,OAAC,QAAK,UAAU,yDAA0D,SAAAD,EAAK,MAAM,KACrF,OAAC,aAAU,UAAU,uBAAuB,GAC9C,IATQJ,CAUV,CAEJ,CAAC,EACH,GACF,CAEJ",
6
+ "names": ["MemberPopup_exports", "__export", "MemberPopup", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_type", "import_provider", "import_viewStack", "import_icons", "import_constants", "EarnCredits", "ConsumeCredits", "Referral", "CompleteProfile", "ActivitiesSubscribe", "SubscribeEmail", "Activate", "RedeemCoupon", "copy", "bottomOffset", "providerProps", "MemberPopupContent", "profile", "openSignInPopup", "openSignUpPopup", "brand", "storeDomain", "rounded", "isLogin", "isOpen", "setIsOpen", "viewStack", "setViewStack", "isSubscribeSuccess", "setIsSubscribeSuccess", "isActivateSuccess", "setIsActivateSuccess", "isProfileCompleteSuccess", "setIsProfileCompleteSuccess", "isSubscribeFormHidden", "setIsSubscribeFormHidden", "currentView", "config", "pathname", "matches", "page", "pushView", "view", "prev", "popView", "handleAction", "type", "url", "handleClose", "cn", "e", "item", "i", "HomeCard", "onAction", "ACTION_ICON", "link", "IconComponent"]
7
7
  }
@@ -0,0 +1,10 @@
1
+ import type { SubscribeModalCopy } from '../type';
2
+ type Props = {
3
+ onSuccess?: () => void;
4
+ copy: SubscribeModalCopy;
5
+ email?: string;
6
+ hideForm: boolean;
7
+ onHideForm: () => void;
8
+ };
9
+ export default function ActivitiesSubscribeModal({ onSuccess, copy, email: initialEmail, hideForm, onHideForm, }: Props): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";var j=Object.create;var m=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var q=(r,e)=>{for(var o in e)m(r,o,{get:e[o],enumerable:!0})},C=(r,e,o,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of F(e))!I.call(r,n)&&n!==o&&m(r,n,{get:()=>e[n],enumerable:!(u=E(e,n))||u.enumerable});return r};var J=(r,e,o)=>(o=r!=null?j(H(r)):{},C(e||!r||!r.__esModule?m(o,"default",{value:r,enumerable:!0}):o,r)),V=r=>C(m({},"__esModule",{value:!0}),r);var z={};q(z,{default:()=>T});module.exports=V(z);var t=require("react/jsx-runtime"),s=require("react"),a=require("@anker-in/headless-ui"),l=require("@anker-in/lib"),f=J(require("js-cookie")),M=require("query-string"),S=require("../../credits/context/utils"),k=require("../context/provider"),y=require("../../../constants");function X(){if(typeof window>"u")return{register_source:""};const{search:r,href:e}=window.location,o=(0,M.parse)(r);return{fbuy_ref_code:f.default.get("fbuy_ref_code"),ref:f.default.get("ref_ads"),inviter_code:o.ic??o.inviter_code??f.default.get("inviter_code"),register_source:o.redirect??f.default.get("reg_source")??e}}async function Z(r){if(typeof window>"u"||!window?.grecaptcha?.execute||!r)return"";try{return await window.grecaptcha.execute(r,{action:"activity"})}catch{return""}}function T({onSuccess:r,copy:e,email:o,hideForm:u,onHideForm:n}){const{alpcConfig:L}=(0,k.useMemberPopupContext)(),{locale:g}=L,{brand:P,storeDomain:h,recaptchaSitekey:A}=(0,l.useHeadlessContext)(),p=y.ROUNDED_BRANDS.includes(P),[x,B]=(0,s.useState)(!1),[d,v]=(0,s.useState)(o??""),[b,i]=(0,s.useState)(""),[D,_]=(0,s.useState)(""),[R,w]=(0,s.useState)(!1);(0,s.useEffect)(()=>{o&&v(o)},[o]);const O=(0,s.useCallback)(async()=>{if(i(""),!d)return i("Please fill in your email");if(!(0,S.emailValidate)(d))return i("Invalid email address");if(!x)return i("Please agree to the policy");w(!0);const{register_source:c}=X(),U=await Z(A||"");try{const N=await(await fetch("/api/multipass/rainbowbridge/activities",{method:"POST",headers:{"Content-Type":"application/json","current-language":g,"X-Recaptcha-Token":U},body:JSON.stringify({email:d,register_source:c,shopify_domain:h,single_brand_subscribe:e.single_brand_subscribe??!0,genre:e.genre??e.dealsType??"",sub_brand_type:e.sub_brand_type??""})})).json();N.errors?i(N.errors??"Error occurred"):(_(e.successTips??"Subscribed successfully!"),r?.(),setTimeout(()=>{n(),_("")},3e3))}catch{i("Network error")}finally{w(!1)}},[d,x,g,h,e,r,n]);return(0,t.jsxs)("div",{className:"flex flex-col gap-[16px] text-center",children:[!u&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(a.Text,{className:"text-[22px] font-bold",html:e.title}),e.desc&&(0,t.jsx)(a.Text,{className:"text-left text-[16px] font-semibold text-[#1f2021]",html:e.desc}),(0,t.jsx)("input",{className:(0,l.classNames)("h-[46px] w-full border px-[14px] text-[16px] outline-none placeholder:text-[#999]",b?"border-[#f84d4f]":"border-[#d8d8d8]",p?"rounded-[4px]":"rounded-none"),placeholder:e.placeholder,value:d,onChange:c=>{i(""),v(c.target.value.trim())}}),(0,t.jsxs)("div",{className:"flex w-full items-start gap-[8px]",children:[(0,t.jsx)(a.Checkbox,{checked:x,onCheckedChange:()=>B(c=>!c),className:"border-[#1d1d1f]"}),(0,t.jsx)("label",{className:"text-left text-[14px] font-semibold text-[#777] [&_a]:underline",dangerouslySetInnerHTML:{__html:e.policy??""}})]}),(0,t.jsx)("button",{className:(0,l.classNames)("w-full cursor-pointer bg-[#080a0f] py-[14px] text-[14px] font-[700] text-white disabled:opacity-60",p?"rounded-[4px]":"rounded-none"),disabled:R,onClick:O,children:e.buttonLabel??"Subscribe"}),b&&(0,t.jsx)("div",{className:"text-left text-[16px] font-semibold text-[#f84d4f]",children:(0,t.jsx)(a.Text,{html:b})}),(0,t.jsx)("div",{className:"text-left text-[16px] font-semibold text-[#52c41a]",children:(0,t.jsx)(a.Text,{html:D})})]}),e.promo&&(0,t.jsxs)("div",{className:"flex flex-col text-left",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[e.promo?.title&&(0,t.jsx)("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#080a0f]",children:e.promo?.title}),e.promo.description&&(0,t.jsx)("p",{className:"text-[14px] leading-[1.5] text-[#1e2024]",children:e.promo.description}),e.promo.learnMoreLabel&&e.promo.learnMoreUrl&&(0,t.jsxs)("a",{href:e.promo.learnMoreUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-[4px] text-[14px] font-[700] text-[#080a0f] underline",children:[e.promo.learnMoreLabel,(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:(0,t.jsx)("path",{d:"M5.52827 3.52876C5.78862 3.26841 6.21063 3.26841 6.47098 3.52876L10.471 7.52876C10.7313 7.78911 10.7313 8.21112 10.471 8.47147L6.47098 12.4715C6.21063 12.7318 5.78862 12.7318 5.52827 12.4715C5.26792 12.2111 5.26792 11.7891 5.52827 11.5288L9.05692 8.00011L5.52827 4.47147C5.26792 4.21112 5.26792 3.78911 5.52827 3.52876Z",fill:"#080A0F"})})]})]}),e.promo.image?.url&&(0,t.jsx)(a.Picture,{source:e.promo.image.url,alt:e.promo.image.alt??"",className:(0,l.classNames)("h-[100px] mt-[8px] w-full object-cover",p?"rounded-[8px]":"rounded-none")})]})]})}
2
+ //# sourceMappingURL=ActivitiesSubscribePanel.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx"],
4
+ "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Button, Checkbox, Picture, Text } from '@anker-in/headless-ui'\nimport { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport Cookies from 'js-cookie'\nimport { parse } from 'query-string'\nimport { emailValidate } from '../../credits/context/utils'\nimport { useMemberPopupContext } from '../context/provider'\nimport type { SubscribeModalCopy } from '../type'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\ntype Props = {\n onSuccess?: () => void\n copy: SubscribeModalCopy\n email?: string\n hideForm: boolean\n onHideForm: () => void\n}\n\nfunction getAdCookie() {\n if (typeof window === 'undefined') return { register_source: '' }\n const { search, href } = window.location\n const query = parse(search)\n return {\n fbuy_ref_code: Cookies.get('fbuy_ref_code'),\n ref: Cookies.get('ref_ads'),\n inviter_code: query.ic ?? query.inviter_code ?? Cookies.get('inviter_code'),\n register_source: query.redirect ?? Cookies.get('reg_source') ?? href,\n }\n}\n\nasync function getRecaptchaToken(sitekey: string): Promise<string> {\n if (typeof window === 'undefined' || !window?.grecaptcha?.execute) return ''\n if (!sitekey) return ''\n try {\n return await window.grecaptcha.execute(sitekey, { action: 'activity' })\n } catch {\n return ''\n }\n}\n\nexport default function ActivitiesSubscribeModal({\n onSuccess,\n copy,\n email: initialEmail,\n hideForm,\n onHideForm,\n}: Props) {\n const { alpcConfig } = useMemberPopupContext()\n const { locale } = alpcConfig\n const { brand: headlessBrand, storeDomain, recaptchaSitekey } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(headlessBrand)\n const [policy, setPolicy] = useState(false)\n const [email, setEmail] = useState(initialEmail ?? '')\n const [errorMessage, setErrorMessage] = useState('')\n const [successMessage, setSuccessMessage] = useState('')\n const [loading, setLoading] = useState(false)\n\n useEffect(() => {\n if (initialEmail) setEmail(initialEmail)\n }, [initialEmail])\n\n const handleSubmit = useCallback(async () => {\n setErrorMessage('')\n if (!email) return setErrorMessage('Please fill in your email')\n if (!emailValidate(email)) return setErrorMessage('Invalid email address')\n if (!policy) return setErrorMessage('Please agree to the policy')\n\n setLoading(true)\n const { register_source } = getAdCookie()\n const recaptchaToken = await getRecaptchaToken(recaptchaSitekey || '')\n try {\n const response = await fetch('/api/multipass/rainbowbridge/activities', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'current-language': locale,\n 'X-Recaptcha-Token': recaptchaToken,\n },\n body: JSON.stringify({\n email,\n register_source,\n shopify_domain: storeDomain,\n single_brand_subscribe: copy.single_brand_subscribe ?? true,\n genre: copy.genre ?? copy.dealsType ?? '',\n sub_brand_type: copy.sub_brand_type ?? '',\n }),\n })\n const result = await response.json()\n if (!result.errors) {\n setSuccessMessage(copy.successTips ?? 'Subscribed successfully!')\n onSuccess?.()\n setTimeout(() => {\n onHideForm()\n setSuccessMessage('')\n }, 3000)\n } else {\n setErrorMessage(result.errors ?? 'Error occurred')\n }\n } catch {\n setErrorMessage('Network error')\n } finally {\n setLoading(false)\n }\n }, [email, policy, locale, storeDomain, copy, onSuccess, onHideForm])\n\n return (\n <div className=\"flex flex-col gap-[16px] text-center\">\n {!hideForm && (\n <>\n <Text className=\"text-[22px] font-bold\" html={copy.title} />\n {copy.desc && <Text className=\"text-left text-[16px] font-semibold text-[#1f2021]\" html={copy.desc} />}\n\n <input\n className={cn(\n 'h-[46px] w-full border px-[14px] text-[16px] outline-none placeholder:text-[#999]',\n errorMessage ? 'border-[#f84d4f]' : 'border-[#d8d8d8]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n placeholder={copy.placeholder}\n value={email}\n onChange={e => {\n setErrorMessage('')\n setEmail(e.target.value.trim())\n }}\n />\n\n <div className=\"flex w-full items-start gap-[8px]\">\n <Checkbox checked={policy} onCheckedChange={() => setPolicy(v => !v)} className=\"border-[#1d1d1f]\" />\n <label\n className=\"text-left text-[14px] font-semibold text-[#777] [&_a]:underline\"\n dangerouslySetInnerHTML={{ __html: copy.policy ?? '' }}\n />\n </div>\n\n <button\n className={cn(\n 'w-full cursor-pointer bg-[#080a0f] py-[14px] text-[14px] font-[700] text-white disabled:opacity-60',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={loading}\n onClick={handleSubmit}\n >\n {copy.buttonLabel ?? 'Subscribe'}\n </button>\n\n {errorMessage && (\n <div className=\"text-left text-[16px] font-semibold text-[#f84d4f]\">\n <Text html={errorMessage} />\n </div>\n )}\n <div className=\"text-left text-[16px] font-semibold text-[#52c41a]\">\n <Text html={successMessage} />\n </div>\n </>\n )}\n\n {copy.promo && (\n <div className=\"flex flex-col text-left\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.promo?.title && (\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.promo?.title}</h3>\n )}\n {copy.promo.description && (\n <p className=\"text-[14px] leading-[1.5] text-[#1e2024]\">{copy.promo.description}</p>\n )}\n {copy.promo.learnMoreLabel && copy.promo.learnMoreUrl && (\n <a\n href={copy.promo.learnMoreUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"flex items-center gap-[4px] text-[14px] font-[700] text-[#080a0f] underline\"\n >\n {copy.promo.learnMoreLabel}\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n <path\n d=\"M5.52827 3.52876C5.78862 3.26841 6.21063 3.26841 6.47098 3.52876L10.471 7.52876C10.7313 7.78911 10.7313 8.21112 10.471 8.47147L6.47098 12.4715C6.21063 12.7318 5.78862 12.7318 5.52827 12.4715C5.26792 12.2111 5.26792 11.7891 5.52827 11.5288L9.05692 8.00011L5.52827 4.47147C5.26792 4.21112 5.26792 3.78911 5.52827 3.52876Z\"\n fill=\"#080A0F\"\n />\n </svg>\n </a>\n )}\n </div>\n {copy.promo.image?.url && (\n <Picture\n source={copy.promo.image.url}\n alt={copy.promo.image.alt ?? ''}\n className={cn('h-[100px] mt-[8px] w-full object-cover', rounded ? 'rounded-[8px]' : 'rounded-none')}\n />\n )}\n </div>\n )}\n </div>\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA4GQ,IAAAI,EAAA,6BA5GRC,EAAiD,iBACjDC,EAAgD,iCAChDC,EAAqD,yBACrDC,EAAoB,wBACpBC,EAAsB,wBACtBC,EAA8B,uCAC9BC,EAAsC,+BAEtCC,EAA+B,8BAU/B,SAASC,GAAc,CACrB,GAAI,OAAO,OAAW,IAAa,MAAO,CAAE,gBAAiB,EAAG,EAChE,KAAM,CAAE,OAAAC,EAAQ,KAAAC,CAAK,EAAI,OAAO,SAC1BC,KAAQ,SAAMF,CAAM,EAC1B,MAAO,CACL,cAAe,EAAAG,QAAQ,IAAI,eAAe,EAC1C,IAAK,EAAAA,QAAQ,IAAI,SAAS,EAC1B,aAAcD,EAAM,IAAMA,EAAM,cAAgB,EAAAC,QAAQ,IAAI,cAAc,EAC1E,gBAAiBD,EAAM,UAAY,EAAAC,QAAQ,IAAI,YAAY,GAAKF,CAClE,CACF,CAEA,eAAeG,EAAkBC,EAAkC,CAEjE,GADI,OAAO,OAAW,KAAe,CAAC,Q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EF,OAAC,OAAI,UAAU,qDACb,mBAAC,QAAK,KAAME,EAAgB,EAC9B,GACF,EAGDhB,EAAK,UACJ,QAAC,OAAI,UAAU,0BACb,qBAAC,OAAI,UAAU,0BACZ,UAAAA,EAAK,OAAO,UACX,OAAC,MAAG,UAAU,sDAAuD,SAAAA,EAAK,OAAO,MAAM,EAExFA,EAAK,MAAM,gBACV,OAAC,KAAE,UAAU,2CAA4C,SAAAA,EAAK,MAAM,YAAY,EAEjFA,EAAK,MAAM,gBAAkBA,EAAK,MAAM,iBACvC,QAAC,KACC,KAAMA,EAAK,MAAM,aACjB,OAAO,SACP,IAAI,sBACJ,UAAU,8EAET,UAAAA,EAAK,MAAM,kBACZ,OAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACnD,mBAAC,QACC,EAAE,kUACF,KAAK,UACP,EACF,GACF,GAEJ,EACCA,EAAK,MAAM,OAAO,QACjB,OAAC,WACC,OAAQA,EAAK,MAAM,MAAM,IACzB,IAAKA,EAAK,MAAM,MAAM,KAAO,GAC7B,aAAW,EAAAwB,YAAG,yCAA0Cf,EAAU,gBAAkB,cAAc,EACpG,GAEJ,GAEJ,CAEJ",
6
+ "names": ["ActivitiesSubscribePanel_exports", "__export", "ActivitiesSubscribeModal", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_js_cookie", "import_query_string", "import_utils", "import_provider", "import_constants", "getAdCookie", "search", "href", "query", "Cookies", "getRecaptchaToken", "sitekey", "onSuccess", "copy", "initialEmail", "hideForm", "onHideForm", "alpcConfig", "locale", "headlessBrand", "storeDomain", "recaptchaSitekey", "rounded", "policy", "setPolicy", "email", "setEmail", "errorMessage", "setErrorMessage", "successMessage", "setSuccessMessage", "loading", "setLoading", "handleSubmit", "register_source", "recaptchaToken", "result", "cn", "e", "v"]
7
+ }
@@ -9,6 +9,7 @@ type Props = {
9
9
  };
10
10
  itemValue?: string;
11
11
  itemOff?: string;
12
+ itemRules?: string[];
12
13
  redeemId: number;
13
14
  userId?: string;
14
15
  copy: RedeemCouponModalCopy;
@@ -16,5 +17,5 @@ type Props = {
16
17
  alpcConfig: AlpcConfig;
17
18
  onError?: (code: number) => void;
18
19
  };
19
- export default function RedeemCouponPanel({ onClose, itemTitle, itemCredits, itemImage, itemValue, itemOff, redeemId, userId, copy, pointUnit, alpcConfig, onError, }: Props): import("react/jsx-runtime").JSX.Element;
20
+ export default function RedeemCouponPanel({ onClose, itemTitle, itemCredits, itemImage, itemValue, itemOff, itemRules, redeemId, userId, copy, pointUnit, alpcConfig, onError, }: Props): import("react/jsx-runtime").JSX.Element;
20
21
  export {};
@@ -1,2 +1,2 @@
1
- "use strict";var H=Object.create;var x=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var z=(t,n)=>{for(var s in n)x(t,s,{get:n[s],enumerable:!0})},T=(t,n,s,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of O(n))!q.call(t,r)&&r!==s&&x(t,r,{get:()=>n[r],enumerable:!(a=I(n,r))||a.enumerable});return t};var F=(t,n,s)=>(s=t!=null?H($(t)):{},T(n||!t||!t.__esModule?x(s,"default",{value:t,enumerable:!0}):s,t)),G=t=>T(x({},"__esModule",{value:!0}),t);var J={};z(J,{default:()=>L});module.exports=G(J);var e=require("react/jsx-runtime"),d=require("react"),l=require("@anker-in/headless-ui"),c=require("@anker-in/lib"),f=require("../../../credits/context/const"),k=require("./hooks/useRedeemCoupon"),y=F(require("../../../credits/context/hooks/useCopy")),D=require("../../../../constants");function L({onClose:t,itemTitle:n,itemCredits:s,itemImage:a,itemValue:r,itemOff:b,redeemId:C,userId:v,copy:o,pointUnit:S="pts",alpcConfig:A,onError:h}){const[g,E]=(0,d.useState)(),[w,m]=(0,d.useState)(""),[U,u]=(0,d.useState)(!1),{copy:_,copied:R}=(0,y.default)(),{brand:M}=(0,c.useHeadlessContext)(),N=D.ROUNDED_BRANDS.includes(M),{isMutating:P,trigger:B}=(0,k.useRedeemCoupon)(A),j=(0,d.useCallback)(async()=>{m("");const{data:i}=await B({user_id:v,rule_id:C});if(!i){m(o.commonError);return}if(i.data?.success)E(i.data.coupon_code);else{let p=o.commonError;i.code===f.AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit?(p=o.redeemLimitError,u(!0)):i.code===f.AlpcErrorCode.CodeLpcRuleInventoryNotEnough?(p=o.inventoryNotEnough,u(!0)):i.code===f.AlpcErrorCode.CodeLpcNotEnoughCredits?(p=o.creditsNotEnough,u(!0)):i.code===f.AlpcErrorCode.CodeCrossSiteError&&(p=o.crossSiteError,u(!0)),m(p),h?.(i.code)}},[B,v,C,o,h]);return(0,d.useEffect)(()=>{E(void 0),m(""),u(!1)},[C]),(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[a?.url&&(0,e.jsxs)("div",{className:(0,c.classNames)("relative overflow-hidden w-fit mx-auto",N?"rounded-[8px]":"rounded-none"),children:[(0,e.jsx)("img",{src:a.url,alt:a.alt??"",className:"mx-auto h-[140px] object-contain"}),r&&(0,e.jsxs)("div",{className:"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white",children:[r,b?` ${b}`:""]})]}),(0,e.jsxs)("p",{className:"text-center text-[24px] font-[700] text-[#1d1d1f]",children:[s," ",S]}),g?(0,e.jsxs)("div",{className:"flex flex-col gap-[12px] text-center",children:[(0,e.jsxs)("div",{className:"flex items-center justify-center gap-[10px]",children:[(0,e.jsx)("span",{className:"text-[24px] font-[700]",children:g}),(0,e.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none",disabled:R,onClick:()=>_(g),children:R?"Copied":"Copy"})]}),(0,e.jsx)(l.Text,{className:"text-[20px] font-[700]",html:o.successTitle}),(0,e.jsx)(l.Text,{className:"text-[14px] font-[700] text-[#6d6d6f]",html:o.successDesc}),(0,e.jsx)(l.Button,{className:(0,c.classNames)("w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]",N?"rounded-[4px]":"rounded-none"),onClick:()=>{o.successButtonUrl&&(window.location.href=o.successButtonUrl),t()},children:o.successButton})]}):(0,e.jsxs)("div",{className:"flex flex-col gap-[12px] text-center",children:[(0,e.jsx)(l.Text,{className:"block text-[20px] font-[700]",html:o.confirmTitle}),(0,e.jsx)(l.Button,{className:(0,c.classNames)("w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]",N?"rounded-[4px]":"rounded-none"),disabled:U,loading:P,onClick:j,children:o.confirmButton})]}),w&&(0,e.jsx)(l.Text,{className:"text-center text-[14px] font-[700] text-[#ff0000]",html:w})]})}
1
+ "use strict";var I=Object.create;var g=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var G=(t,s)=>{for(var n in s)g(t,n,{get:s[n],enumerable:!0})},k=(t,s,n,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of $(s))!z.call(t,r)&&r!==n&&g(t,r,{get:()=>s[r],enumerable:!(c=O(s,r))||c.enumerable});return t};var J=(t,s,n)=>(n=t!=null?I(q(t)):{},k(s||!t||!t.__esModule?g(n,"default",{value:t,enumerable:!0}):n,t)),K=t=>k(g({},"__esModule",{value:!0}),t);var Q={};G(Q,{default:()=>L});module.exports=K(Q);var e=require("react/jsx-runtime"),d=require("react"),i=require("@anker-in/headless-ui"),p=require("@anker-in/lib"),x=require("../../../credits/context/const"),D=require("./hooks/useRedeemCoupon"),S=J(require("../../../credits/context/hooks/useCopy")),T=require("../../../../constants");function L({onClose:t,itemTitle:s,itemCredits:n,itemImage:c,itemValue:r,itemOff:b,itemRules:C,redeemId:N,userId:h,copy:o,pointUnit:A="pts",alpcConfig:U,onError:w}){const[m,E]=(0,d.useState)(),[y,f]=(0,d.useState)(""),[_,u]=(0,d.useState)(!1),{copy:M,copied:B}=(0,S.default)(),{brand:P}=(0,p.useHeadlessContext)(),v=T.ROUNDED_BRANDS.includes(P),{isMutating:j,trigger:R}=(0,D.useRedeemCoupon)(U),F=(0,d.useCallback)(async()=>{f("");const{data:l}=await R({user_id:h,rule_id:N});if(!l){f(o.commonError);return}if(l.data?.success)E(l.data.coupon_code);else{let a=o.commonError;l.code===x.AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit?(a=o.redeemLimitError,u(!0)):l.code===x.AlpcErrorCode.CodeLpcRuleInventoryNotEnough?(a=o.inventoryNotEnough,u(!0)):l.code===x.AlpcErrorCode.CodeLpcNotEnoughCredits?(a=o.creditsNotEnough,u(!0)):l.code===x.AlpcErrorCode.CodeCrossSiteError&&(a=o.crossSiteError,u(!0)),f(a),w?.(l.code)}},[R,h,N,o,w]);(0,d.useEffect)(()=>{E(void 0),f(""),u(!1)},[N]);const H=C&&C.length>0&&(0,e.jsx)("div",{className:"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]",children:(0,e.jsx)("ul",{className:"ml-4 grid grid-flow-row gap-[4px]",children:C?.map((l,a)=>(0,e.jsx)("li",{className:"list-disc",children:(0,e.jsx)(i.Text,{html:l,className:"font-bold"})},a))})});return(0,e.jsxs)("div",{className:"flex flex-col",children:[c?.url&&(0,e.jsx)("div",{className:"relative w-full px-[24px]",children:(0,e.jsxs)("div",{className:(0,p.classNames)("relative mx-auto overflow-hidden",v?"rounded-[8px]":"rounded-none"),children:[(0,e.jsx)("img",{src:c.url,alt:c.alt??"",className:"mx-auto h-[140px] w-full object-cover"}),r&&(0,e.jsxs)("div",{className:"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white",children:[r,b?` ${b}`:""]})]})}),!m&&(0,e.jsxs)("div",{className:"flex flex-col gap-[16px] px-[24px] py-[20px]",children:[(0,e.jsxs)("p",{className:"text-center text-[24px] font-[700] text-[#1d1d1f]",children:[n," ",A]}),H]}),m&&(0,e.jsxs)("div",{className:"flex flex-col gap-[8px] text-center",children:[(0,e.jsxs)("div",{className:"flex items-center justify-center gap-[10px]",children:[(0,e.jsx)("span",{className:"text-[24px] font-[700]",children:m}),(0,e.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none",disabled:B,onClick:()=>M(m),children:B?"Copied":"Copy"})]}),(0,e.jsx)(i.Text,{className:"text-[20px] font-[700]",html:o.successTitle}),(0,e.jsx)(i.Text,{className:"text-[14px] font-[700] text-[#6d6d6f]",html:o.successDesc}),(0,e.jsx)(i.Button,{className:(0,p.classNames)("w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]",v?"rounded-[4px]":"rounded-none"),onClick:()=>{o.successButtonUrl&&(window.location.href=o.successButtonUrl),t()},children:o.successButton})]}),!m&&(0,e.jsxs)("div",{className:"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-[8px] text-center",children:[(0,e.jsx)(i.Text,{className:"block text-[16px] font-[700] leading-[1.3]",html:o.confirmTitle}),(0,e.jsx)(i.Button,{className:(0,p.classNames)("w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]",v?"rounded-[4px]":"rounded-none"),disabled:_,loading:j,onClick:F,children:o.confirmButton})]}),y&&(0,e.jsx)(i.Text,{className:"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]",html:y})]})]})}
2
2
  //# sourceMappingURL=RedeemCouponPanel.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.tsx"],
4
- "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Text, Button } from '@anker-in/headless-ui'\nimport { useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport { AlpcErrorCode } from '../../../credits/context/const'\nimport { useRedeemCoupon } from './hooks/useRedeemCoupon'\nimport useCopy from '../../../credits/context/hooks/useCopy'\nimport type { RedeemCouponModalCopy, AlpcConfig } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n onClose: () => void\n itemTitle: string\n itemCredits: number\n itemImage?: { url: string; alt?: string }\n itemValue?: string\n itemOff?: string\n redeemId: number\n userId?: string\n copy: RedeemCouponModalCopy\n pointUnit?: string\n alpcConfig: AlpcConfig\n onError?: (code: number) => void\n}\n\nexport default function RedeemCouponPanel({\n onClose,\n itemTitle,\n itemCredits,\n itemImage,\n itemValue,\n itemOff,\n redeemId,\n userId,\n copy,\n pointUnit = 'pts',\n alpcConfig,\n onError,\n}: Props) {\n const [couponCode, setCouponCode] = useState<string>()\n const [errorInfo, setErrorInfo] = useState('')\n const [disabled, setDisabled] = useState(false)\n const { copy: copyText, copied } = useCopy()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const { isMutating: loading, trigger } = useRedeemCoupon(alpcConfig)\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n const { data } = await trigger({ user_id: userId, rule_id: redeemId })\n if (!data) {\n setErrorInfo(copy.commonError)\n return\n }\n if (data.data?.success) {\n setCouponCode(data.data.coupon_code)\n } else {\n let msg = copy.commonError\n if (data.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n msg = copy.redeemLimitError\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n msg = copy.inventoryNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n msg = copy.creditsNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeCrossSiteError) {\n msg = copy.crossSiteError\n setDisabled(true)\n }\n setErrorInfo(msg)\n onError?.(data.code)\n }\n }, [trigger, userId, redeemId, copy, onError])\n\n useEffect(() => {\n setCouponCode(undefined)\n setErrorInfo('')\n setDisabled(false)\n }, [redeemId])\n\n return (\n <div className=\"flex flex-col gap-[16px]\">\n {itemImage?.url && (\n <div className={cn('relative overflow-hidden w-fit mx-auto', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <img src={itemImage.url} alt={itemImage.alt ?? ''} className=\"mx-auto h-[140px] object-contain\" />\n {itemValue && (\n <div className=\"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white\">\n {itemValue}\n {itemOff ? ` ${itemOff}` : ''}\n </div>\n )}\n </div>\n )}\n\n <p className=\"text-center text-[24px] font-[700] text-[#1d1d1f]\">\n {itemCredits} {pointUnit}\n </p>\n\n {!couponCode ? (\n <div className=\"flex flex-col gap-[12px] text-center\">\n <Text className=\"block text-[20px] font-[700]\" html={copy.confirmTitle} />\n <Button\n className={cn('w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]', rounded ? 'rounded-[4px]' : 'rounded-none')}\n disabled={disabled}\n loading={loading}\n onClick={handleConfirm}\n >\n {copy.confirmButton}\n </Button>\n </div>\n ) : (\n <div className=\"flex flex-col gap-[12px] text-center\">\n <div className=\"flex items-center justify-center gap-[10px]\">\n <span className=\"text-[24px] font-[700]\">{couponCode}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none\"\n disabled={copied}\n onClick={() => copyText(couponCode)}\n >\n {copied ? 'Copied' : 'Copy'}\n </button>\n </div>\n <Text className=\"text-[20px] font-[700]\" html={copy.successTitle} />\n <Text className=\"text-[14px] font-[700] text-[#6d6d6f]\" html={copy.successDesc} />\n <Button\n className={cn('w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]', rounded ? 'rounded-[4px]' : 'rounded-none')}\n onClick={() => {\n if (copy.successButtonUrl) window.location.href = copy.successButtonUrl\n onClose()\n }}\n >\n {copy.successButton}\n </Button>\n </div>\n )}\n\n {errorInfo && <Text className=\"text-center text-[14px] font-[700] text-[#ff0000]\" html={errorInfo} />}\n </div>\n )\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAA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K,cACR,GACF,EA2BDM,MAAa,OAAC,QAAK,UAAU,oDAAoD,KAAMA,EAAW,GACrG,CAEJ",
6
- "names": ["RedeemCouponPanel_exports", "__export", "RedeemCouponPanel", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_const", "import_useRedeemCoupon", "import_useCopy", "import_constants", "onClose", "itemTitle", "itemCredits", "itemImage", "itemValue", "itemOff", "redeemId", "userId", "copy", "pointUnit", "alpcConfig", "onError", "couponCode", "setCouponCode", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "copyText", "copied", "useCopy", "brand", "rounded", "loading", "trigger", "handleConfirm", "data", "msg", "cn"]
4
+ "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Text, Button } from '@anker-in/headless-ui'\nimport { useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport { AlpcErrorCode } from '../../../credits/context/const'\nimport { useRedeemCoupon } from './hooks/useRedeemCoupon'\nimport useCopy from '../../../credits/context/hooks/useCopy'\nimport type { RedeemCouponModalCopy, AlpcConfig } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n onClose: () => void\n itemTitle: string\n itemCredits: number\n itemImage?: { url: string; alt?: string }\n itemValue?: string\n itemOff?: string\n itemRules?: string[]\n redeemId: number\n userId?: string\n copy: RedeemCouponModalCopy\n pointUnit?: string\n alpcConfig: AlpcConfig\n onError?: (code: number) => void\n}\n\nexport default function RedeemCouponPanel({\n onClose,\n itemTitle,\n itemCredits,\n itemImage,\n itemValue,\n itemOff,\n itemRules,\n redeemId,\n userId,\n copy,\n pointUnit = 'pts',\n alpcConfig,\n onError,\n}: Props) {\n const [couponCode, setCouponCode] = useState<string>()\n const [errorInfo, setErrorInfo] = useState('')\n const [disabled, setDisabled] = useState(false)\n const { copy: copyText, copied } = useCopy()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const { isMutating: loading, trigger } = useRedeemCoupon(alpcConfig)\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n const { data } = await trigger({ user_id: userId, rule_id: redeemId })\n if (!data) {\n setErrorInfo(copy.commonError)\n return\n }\n if (data.data?.success) {\n setCouponCode(data.data.coupon_code)\n } else {\n let msg = copy.commonError\n if (data.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n msg = copy.redeemLimitError\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n msg = copy.inventoryNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n msg = copy.creditsNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeCrossSiteError) {\n msg = copy.crossSiteError\n setDisabled(true)\n }\n setErrorInfo(msg)\n onError?.(data.code)\n }\n }, [trigger, userId, redeemId, copy, onError])\n\n useEffect(() => {\n setCouponCode(undefined)\n setErrorInfo('')\n setDisabled(false)\n }, [redeemId])\n\n const rulesSection = itemRules && itemRules.length > 0 && (\n <div className=\"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]\">\n <ul className=\"ml-4 grid grid-flow-row gap-[4px]\">\n {itemRules?.map((text, index) => (\n <li className=\"list-disc\" key={index}>\n <Text html={text} className=\"font-bold\" />\n </li>\n ))}\n </ul>\n </div>\n )\n\n return (\n <div className=\"flex flex-col\">\n {itemImage?.url && (\n <div className=\"relative w-full px-[24px]\">\n <div className={cn('relative mx-auto overflow-hidden', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <img src={itemImage.url} alt={itemImage.alt ?? ''} className=\"mx-auto h-[140px] w-full object-cover\" />\n {itemValue && (\n <div className=\"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white\">\n {itemValue}\n {itemOff ? ` ${itemOff}` : ''}\n </div>\n )}\n </div>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"flex flex-col gap-[16px] px-[24px] py-[20px]\">\n <p className=\"text-center text-[24px] font-[700] text-[#1d1d1f]\">\n {itemCredits} {pointUnit}\n </p>\n {rulesSection}\n </div>\n )}\n\n {couponCode && (\n <div className=\"flex flex-col gap-[8px] text-center\">\n <div className=\"flex items-center justify-center gap-[10px]\">\n <span className=\"text-[24px] font-[700]\">{couponCode}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none\"\n disabled={copied}\n onClick={() => copyText(couponCode)}\n >\n {copied ? 'Copied' : 'Copy'}\n </button>\n </div>\n <Text className=\"text-[20px] font-[700]\" html={copy.successTitle} />\n <Text className=\"text-[14px] font-[700] text-[#6d6d6f]\" html={copy.successDesc} />\n <Button\n className={cn(\n 'w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={() => {\n if (copy.successButtonUrl) window.location.href = copy.successButtonUrl\n onClose()\n }}\n >\n {copy.successButton}\n </Button>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]\">\n <div className=\"flex flex-col gap-[8px] text-center\">\n <Text className=\"block text-[16px] font-[700] leading-[1.3]\" html={copy.confirmTitle} />\n <Button\n className={cn(\n 'w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={disabled}\n loading={loading}\n onClick={handleConfirm}\n >\n {copy.confirmButton}\n </Button>\n </div>\n\n {errorInfo && (\n <Text className=\"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]\" html={errorInfo} />\n )}\n </div>\n )}\n </div>\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAyFY,IAAAI,EAAA,6BAzFZC,EAAiD,iBACjDC,EAA6B,iCAC7BC,EAAqD,yBACrDC,EAA8B,0CAC9BC,EAAgC,mCAChC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EAGD,CAACI,MACA,QAAC,OAAI,UAAU,+DACb,qBAAC,OAAI,UAAU,sCACb,oBAAC,QAAK,UAAU,6CAA6C,KAAMJ,EAAK,aAAc,KACtF,OAAC,UACC,aAAW,EAAAuB,YACT,sFACAT,EAAU,gBAAkB,cAC9B,EACA,SAAUN,EACV,QAASO,EACT,QAASE,EAER,SAAAjB,EAAK,cACR,GACF,EAECM,MACC,OAAC,QAAK,UAAU,6DAA6D,KAAMA,EAAW,GAElG,GAEJ,CAEJ",
6
+ "names": ["RedeemCouponPanel_exports", "__export", "RedeemCouponPanel", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_const", "import_useRedeemCoupon", "import_useCopy", "import_constants", "onClose", "itemTitle", "itemCredits", "itemImage", "itemValue", "itemOff", "itemRules", "redeemId", "userId", "copy", "pointUnit", "alpcConfig", "onError", "couponCode", "setCouponCode", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "copyText", "copied", "useCopy", "brand", "rounded", "loading", "trigger", "handleConfirm", "data", "msg", "rulesSection", "text", "index", "cn"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var y=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var q=(t,r)=>{for(var s in r)y(t,s,{get:r[s],enumerable:!0})},J=(t,r,s,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of H(r))!G.call(t,l)&&l!==s&&y(t,l,{get:()=>r[l],enumerable:!(d=j(r,l))||d.enumerable});return t};var K=t=>J(y({},"__esModule",{value:!0}),t);var X={};q(X,{default:()=>W});module.exports=K(X);var n=require("react/jsx-runtime"),c=require("react"),g=require("@anker-in/headless-ui"),u=require("@anker-in/lib"),P=require("../../context/provider"),w=require("../../context/viewStack"),A=require("./hooks/useRedeemableList"),k=require("./hooks/useRedeemAndBuy"),i=require("../../type"),v=require("../../../credits/context/utils"),M=require("../../../../constants");function Q({copy:t,onClose:r}){const{profile:s,creditInfo:d,openSignUpPopup:l,alpcConfig:b}=(0,P.useMemberPopupContext)(),{pushView:O}=(0,w.useViewStack)(),{brand:U}=(0,u.useHeadlessContext)(),h=M.ROUNDED_BRANDS.includes(U),[I,R]=(0,c.useState)(""),[E,B]=(0,c.useState)(null),f=!!s,{redeemableList:D,listLoading:L}=(0,A.useRedeemableList)(b),{trigger:S}=(0,k.useRedeemAndBuy)(b),$=t.list.map(e=>e.product?.handle).filter(Boolean),{data:_}=(0,u.useProductsByHandles)({handles:$}),z=(0,c.useMemo)(()=>t.list.map(e=>{const a=D.find(m=>String(m.id)===String(e.redeemId));if(!a)return null;const p=Number(d?.available_credit??0),N=f&&!!s?.activated&&a.consume_credits>p,x=a.is_limited&&(!a.remaining_inventory||a.remaining_inventory<=0);let o,C;return e.type===i.ConsumeCreditsItemType.RedeemAndBuy&&e.product&&(o=_?.find(m=>m.handle===e.product.handle),C=o?.variants?.find(m=>m.sku===e.product.sku)??o?.variants?.[0],!o||!C)?null:{...e,alpcData:a,insufficient:N,soldOut:x,product:o,variant:C}}).filter(Boolean),[t.list,D,d,s,f,_]);function F(e){return f?e.soldOut?t.soldOut:t.btnRedeem:t.unlockRewards}function T(e){return e.soldOut||e.insufficient}async function V(e){if(!f){l();return}if(e.type===i.ConsumeCreditsItemType.Coupon)O({type:i.MemberPopupPanelType.RedeemCoupon,props:{itemTitle:e.title,itemCredits:e.alpcData.consume_credits,itemImage:t.imageMapping?.[e.type]?{url:t.imageMapping[e.type].url,alt:e.image?.alt}:e.image,itemValue:e.value,itemOff:t.off,redeemId:Number(e.redeemId),userId:s?.user_id,alpcConfig:b}});else{R(""),B(e.redeemId);try{await S({productVariant:e.variant,redeemId:Number(e.redeemId),userId:s?.user_id})}catch(a){R(a?.message??t.redeemModal.commonError)}finally{B(null)}}}return(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"flex flex-1 flex-col gap-[12px]",children:[(0,n.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[t.title&&(0,n.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title}),t.subtitle&&(0,n.jsx)("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:t.subtitle})]}),t.insufficientCredits&&d&&(0,n.jsxs)("div",{className:"text-[14px] font-[700] text-[#1d1d1f]",children:[t.insufficientCredits,": ",(0,v.numberFormat)(d.available_credit)," ",t.pointUnit]}),I&&(0,n.jsx)("div",{className:"text-[14px] font-[700] text-[#f84d4f]",children:I}),L?(0,n.jsx)("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:(0,n.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):(0,n.jsx)("div",{className:"flex flex-col",children:z.map((e,a)=>(0,n.jsxs)("div",{className:"relative py-[16px]",children:[a>0&&(0,n.jsx)("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),(0,n.jsxs)("div",{className:"flex items-center gap-[12px]",children:[(()=>{const p=e.type===i.ConsumeCreditsItemType.RedeemAndBuy,N=t.imageMapping?.[e.type]?.url,x=p?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:N??e.image?.url,o=p?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return x?(0,n.jsxs)("div",{className:(0,u.classNames)("relative size-[64px] shrink-0 overflow-hidden",h?"rounded-[4px]":"rounded-none"),children:[(0,n.jsx)(g.Picture,{source:x,alt:o,className:"flex size-full items-center justify-center",imgClassName:p?"object-cover":"h-full w-auto object-contain"}),!p&&e.value&&(0,n.jsxs)("div",{className:"absolute bottom-[20px] left-[4px] text-[14px] font-[800] leading-none text-white",children:[e.value," ",t.off]})]}):null})(),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"text-[16px] font-[700] text-[#1e2024] line-clamp-2",children:e.type===i.ConsumeCreditsItemType.RedeemAndBuy&&e.product?.title?e.product.title:e.title}),(0,n.jsx)("div",{className:"mt-[4px] text-[14px] text-[#666]",children:e.type===i.ConsumeCreditsItemType.RedeemAndBuy&&e.price!=null?`${(0,v.numberFormat)(e.alpcData.consume_credits)} ${t.pointUnit??""} + $${Number(e.price).toFixed(2)}`:`${(0,v.numberFormat)(e.alpcData.consume_credits)} ${t.pointUnit??""}`})]}),(0,n.jsxs)("div",{className:"relative group",children:[(0,n.jsx)(g.Button,{className:(0,u.classNames)("bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",h?"rounded-[4px]":"rounded-none"),disabled:T(e),loading:E===e.redeemId,onClick:()=>V(e),children:F(e)}),e.insufficient&&(0,n.jsx)("div",{className:"pointer-events-none absolute left-[48px] top-full mt-[10px] hidden -translate-x-1/2 group-hover:block",children:(0,n.jsxs)("div",{className:"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow md:px-[10px] md:py-[8px]",children:[(0,n.jsx)("p",{className:"text-pretty tracking-[-0.02em] text-[14px]",children:t.insufficientCredits}),(0,n.jsx)("div",{className:"absolute -top-[8px] left-[48px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]},a))}),t.creditsPage?.url&&(0,n.jsx)("a",{href:t.creditsPage.url,target:"_blank",rel:"noopener noreferrer",className:"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline",children:t.creditsPage.label??"Go to Credits Page"})]})})}var W=Q;
1
+ "use strict";var h=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var q=(t,s)=>{for(var a in s)h(t,a,{get:s[a],enumerable:!0})},J=(t,s,a,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of G(s))!H.call(t,o)&&o!==a&&h(t,o,{get:()=>s[o],enumerable:!(l=j(s,o))||l.enumerable});return t};var K=t=>J(h({},"__esModule",{value:!0}),t);var X={};q(X,{default:()=>W});module.exports=K(X);var r=require("react/jsx-runtime"),f=require("react"),v=require("@anker-in/headless-ui"),p=require("@anker-in/lib"),D=require("../../context/provider"),k=require("../../context/viewStack"),A=require("./hooks/useRedeemableList"),M=require("./hooks/useRedeemAndBuy"),n=require("../../type"),g=require("../../../credits/context/utils"),O=require("../../../../constants");function Q({copy:t,onClose:s}){const{profile:a,creditInfo:l,openSignUpPopup:o,alpcConfig:b}=(0,D.useMemberPopupContext)(),{pushView:y}=(0,k.useViewStack)(),{brand:U}=(0,p.useHeadlessContext)(),I=O.ROUNDED_BRANDS.includes(U),[P,R]=(0,f.useState)(""),[E,w]=(0,f.useState)(null),m=!!a,{redeemableList:_,listLoading:L}=(0,A.useRedeemableList)(b),{trigger:S}=(0,M.useRedeemAndBuy)(b),$=t.list.map(e=>e.product?.handle).filter(Boolean),{data:B}=(0,p.useProductsByHandles)({handles:$}),z=(0,f.useMemo)(()=>t.list.map(e=>{const i=_.find(c=>String(c.id)===String(e.redeemId));if(!i)return null;const d=Number(l?.available_credit??0),C=m&&!!a?.activated&&i.consume_credits>d,x=i.is_limited&&(!i.remaining_inventory||i.remaining_inventory<=0);let u,N;return(e.type===n.ConsumeCreditsItemType.RedeemAndBuy||e.type===n.ConsumeCreditsItemType.Product)&&e.product&&(u=B?.find(c=>c.handle===e.product.handle),N=u?.variants?.find(c=>c.sku===e.product.sku)??u?.variants?.[0],e.type===n.ConsumeCreditsItemType.RedeemAndBuy&&(!u||!N))?null:{...e,alpcData:i,insufficient:C,soldOut:x,product:u,variant:N}}).filter(Boolean),[t.list,_,l,a,m,B]);function F(e){return m?e.soldOut?t.soldOut:t.btnRedeem:t.unlockRewards}function T(e){return e.type===n.ConsumeCreditsItemType.GiftCard||e.type===n.ConsumeCreditsItemType.Product?e.insufficient:e.soldOut||e.insufficient}async function V(e){if(!m){o();return}if(!a?.activated){y({type:n.MemberPopupPanelType.Activate});return}if(e.type===n.ConsumeCreditsItemType.GiftCard||e.type===n.ConsumeCreditsItemType.Product){t.creditsPage?.url&&window.open(t.creditsPage.url,"_blank","noopener,noreferrer");return}if(e.type===n.ConsumeCreditsItemType.Coupon)y({type:n.MemberPopupPanelType.RedeemCoupon,props:{itemTitle:e.title,itemCredits:e.alpcData.consume_credits,itemImage:t.imageMapping?.[e.type]?{url:t.imageMapping[e.type].url,alt:e.image?.alt}:e.image,itemValue:e.value,itemOff:t.off,itemRules:e.rules,redeemId:Number(e.redeemId),userId:a?.user_id,alpcConfig:b}});else{R(""),w(e.redeemId);try{await S({productVariant:e.variant,redeemId:Number(e.redeemId),userId:a?.user_id})}catch(i){R(i?.message??t.redeemModal.commonError)}finally{w(null)}}}return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex flex-1 flex-col gap-[12px]",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[t.title&&(0,r.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title}),t.subtitle&&(0,r.jsx)("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:t.subtitle})]}),t.insufficientCredits&&l&&(0,r.jsxs)("div",{className:"text-[14px] font-[700] text-[#1d1d1f]",children:[t.insufficientCredits,": ",(0,g.numberFormat)(l.available_credit)," ",t.pointUnit]}),P&&(0,r.jsx)("div",{className:"text-[14px] font-[700] text-[#f84d4f]",children:P}),L?(0,r.jsx)("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:(0,r.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):(0,r.jsx)("div",{className:"flex flex-col",children:z.map((e,i)=>{const d=!!e.product;return(0,r.jsxs)("div",{className:"relative py-[16px]",children:[i>0&&(0,r.jsx)("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),(0,r.jsxs)("div",{className:"flex items-center gap-[12px]",children:[(()=>{const C=t.imageMapping?.[e.type]?.url,x=d?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:C??e.image?.url,u=d?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return x?(0,r.jsxs)("div",{className:(0,p.classNames)("relative size-[64px] shrink-0 overflow-hidden",I?"rounded-[4px]":"rounded-none"),children:[(0,r.jsx)(v.Picture,{source:x,alt:u,className:"flex size-full items-center justify-center",imgClassName:d?"object-cover":"h-full w-auto object-contain"}),!d&&e.value&&(0,r.jsxs)("div",{className:"absolute bottom-[20px] left-[4px] text-[14px] font-[800] leading-none text-white",children:[e.value," ",t.off]})]}):null})(),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"text-[16px] font-[700] text-[#1e2024] line-clamp-2",children:d&&e.product?.title?e.product.title:e.title}),(0,r.jsx)("div",{className:"mt-[4px] text-[14px] text-[#666]",children:d&&e.price!=null?`${(0,g.numberFormat)(e.alpcData.consume_credits)} ${t.pointUnit??""} + $${Number(e.price).toFixed(2)}`:`${(0,g.numberFormat)(e.alpcData.consume_credits)} ${t.pointUnit??""}`})]}),(0,r.jsxs)("div",{className:"relative group",children:[(0,r.jsx)(v.Button,{className:(0,p.classNames)("bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",I?"rounded-[4px]":"rounded-none"),disabled:T(e),loading:E===e.redeemId,onClick:()=>V(e),children:F(e)}),e.insufficient&&(0,r.jsx)("div",{className:"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block",children:(0,r.jsxs)("div",{className:"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow",children:[(0,r.jsx)("p",{className:"text-pretty tracking-[-0.02em] text-[14px]",children:t.insufficientCredits}),(0,r.jsx)("div",{className:"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]},i)})}),t.creditsPage?.url&&(0,r.jsx)("a",{href:t.creditsPage.url,target:"_blank",rel:"noopener noreferrer",className:"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline",children:t.creditsPage.label??"Go to Credits Page"})]})})}var W=Q;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/ConsumeCredits/index.tsx"],
4
- "sourcesContent": ["import { useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { classNames as cn, useProductsByHandles, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useRedeemableList } from './hooks/useRedeemableList'\nimport { useRedeemAndBuy } from './hooks/useRedeemAndBuy'\nimport {\n ConsumeCreditsItemType,\n MemberPopupPanelType,\n type ConsumeCreditsopy,\n type ConsumeCreditsItem,\n} from '../../type'\nimport { numberFormat } from '../../../credits/context/utils'\nimport type { ConsumeCreditRuleResponse } from '../../../credits/context/response'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype EnrichedItem = ConsumeCreditsItem & {\n alpcData: ConsumeCreditRuleResponse\n insufficient: boolean\n soldOut: boolean\n product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n onClose: () => void\n}\n\nfunction ConsumeCredits({ copy, onClose }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig } = useMemberPopupContext()\n const { pushView } = useViewStack()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [redeemAndBuyError, setRedeemAndBuyError] = useState('')\n const [loadingId, setLoadingId] = useState<string | number | null>(null)\n\n const isLogin = !!profile\n const { redeemableList, listLoading } = useRedeemableList(alpcConfig)\n const { trigger: redeemAndBuy } = useRedeemAndBuy(alpcConfig)\n\n const handles = copy.list.map(item => item.product?.handle).filter(Boolean) as string[]\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const alpcData = redeemableList.find(r => String(r.id) === String(item.redeemId))\n if (!alpcData) return null\n\n const availableCredit = Number(creditInfo?.available_credit ?? 0)\n const insufficient = isLogin && !!profile?.activated && alpcData.consume_credits > availableCredit\n const soldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n let product\n let variant\n if (item.type === ConsumeCreditsItemType.RedeemAndBuy && item.product) {\n product = products?.find((p: any) => p.handle === item.product!.handle)\n variant = product?.variants?.find((v: any) => v.sku === item.product!.sku) ?? product?.variants?.[0]\n if (!product || !variant) return null\n }\n\n return { ...item, alpcData, insufficient, soldOut, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin) return copy.unlockRewards\n if (item.soldOut) return copy.soldOut\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n return item.soldOut || item.insufficient\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\n pushView({\n type: MemberPopupPanelType.RedeemCoupon,\n props: {\n itemTitle: item.title,\n itemCredits: item.alpcData.consume_credits,\n itemImage: copy.imageMapping?.[item.type]\n ? { url: copy.imageMapping[item.type]!.url, alt: item.image?.alt }\n : item.image,\n itemValue: item.value,\n itemOff: copy.off,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n alpcConfig,\n },\n })\n } else {\n setRedeemAndBuyError('')\n setLoadingId(item.redeemId)\n try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n })\n } catch (e: any) {\n setRedeemAndBuyError(e?.message ?? copy.redeemModal.commonError)\n } finally {\n setLoadingId(null)\n }\n }\n }\n\n return (\n <>\n <div className=\"flex flex-1 flex-col gap-[12px]\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n {copy.subtitle && <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>}\n </div>\n\n {copy.insufficientCredits && creditInfo && (\n <div className=\"text-[14px] font-[700] text-[#1d1d1f]\">\n {copy.insufficientCredits}: {numberFormat(creditInfo.available_credit)} {copy.pointUnit}\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] font-[700] text-[#f84d4f]\">{redeemAndBuyError}</div>}\n\n {listLoading ? (\n <div className=\"flex flex-1 items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n ) : (\n <div className=\"flex flex-col\">\n {list.map((item, idx) => (\n <div key={idx} className=\"relative py-[16px]\">\n {idx > 0 && <div className=\"absolute inset-x-0 top-0 h-px bg-[#dadce0]\" />}\n <div className=\"flex items-center gap-[12px]\">\n {(() => {\n const isRedeemAndBuy = item.type === ConsumeCreditsItemType.RedeemAndBuy\n const mappedImgUrl = copy.imageMapping?.[item.type]?.url\n const imgUrl = isRedeemAndBuy\n ? (item.variant?.image?.url ?? item.product?.images?.[0]?.url ?? item.image?.url)\n : (mappedImgUrl ?? item.image?.url)\n const imgAlt = isRedeemAndBuy\n ? (item.variant?.image?.altText ?? item.product?.images?.[0]?.alt ?? item.image?.alt ?? '')\n : (item.image?.alt ?? '')\n if (!imgUrl) return null\n return (\n <div className={cn('relative size-[64px] shrink-0 overflow-hidden', rounded ? 'rounded-[4px]' : 'rounded-none')}>\n <Picture\n source={imgUrl}\n alt={imgAlt}\n className=\"flex size-full items-center justify-center\"\n imgClassName={isRedeemAndBuy ? 'object-cover' : 'h-full w-auto object-contain'}\n />\n {!isRedeemAndBuy && item.value && (\n <div className=\"absolute bottom-[20px] left-[4px] text-[14px] font-[800] leading-none text-white\">\n {item.value} {copy.off}\n </div>\n )}\n </div>\n )\n })()}\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024] line-clamp-2\">\n {item.type === ConsumeCreditsItemType.RedeemAndBuy && item.product?.title\n ? item.product.title\n : item.title}\n </div>\n <div className=\"mt-[4px] text-[14px] text-[#666]\">\n {item.type === ConsumeCreditsItemType.RedeemAndBuy && item.price != null\n ? `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''} + $${Number(item.price).toFixed(2)}`\n : `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''}`}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn('bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white', rounded ? 'rounded-[4px]' : 'rounded-none')}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && (\n <div className=\"pointer-events-none absolute left-[48px] top-full mt-[10px] hidden -translate-x-1/2 group-hover:block\">\n <div className=\"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow md:px-[10px] md:py-[8px]\">\n <p className=\"text-pretty tracking-[-0.02em] text-[14px]\">{copy.insufficientCredits}</p>\n <div className=\"absolute -top-[8px] left-[48px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n )}\n </div>\n </div>\n </div>\n ))}\n </div>\n )}\n\n {copy.creditsPage?.url && (\n <a\n href={copy.creditsPage.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default ConsumeCredits\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAsHI,IAAAI,EAAA,6BAtHJC,EAAkC,iBAClCC,EAAgC,iCAChCC,EAA2E,yB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K,MAAM,IAAElB,EAAK,KACrB,GAEJ,EAdkB,IAgBtB,GAAG,KACH,QAAC,OAAI,UAAU,iBACb,oBAAC,OAAI,UAAU,qDACZ,SAAAkB,EAAK,OAAS,yBAAuB,cAAgBA,EAAK,SAAS,MAChEA,EAAK,QAAQ,MACbA,EAAK,MACX,KACA,OAAC,OAAI,UAAU,mCACZ,SAAAA,EAAK,OAAS,yBAAuB,cAAgBA,EAAK,OAAS,KAChE,MAAG,gBAAaA,EAAK,SAAS,eAAe,CAAC,IAAIlB,EAAK,WAAa,EAAE,OAAO,OAAOkB,EAAK,KAAK,EAAE,QAAQ,CAAC,CAAC,GAC1G,MAAG,gBAAaA,EAAK,SAAS,eAAe,CAAC,IAAIlB,EAAK,WAAa,EAAE,GAC5E,GACF,KACA,QAAC,OAAI,UAAU,iBACb,oBAAC,UACC,aAAW,EAAAuC,YAAG,6FAA8F/B,EAAU,gBAAkB,cAAc,EACtJ,SAAUuB,EAAWb,CAAI,EACzB,QAASP,IAAcO,EAAK,SAC5B,QAAS,IAAMc,EAAad,CAAI,EAE/B,SAAAY,EAAeZ,CAAI,EACtB,EACCA,EAAK,iBACJ,OAAC,OAAI,UAAU,wGACb,oBAAC,OAAI,UAAU,mGACb,oBAAC,KAAE,UAAU,6CAA8C,SAAAlB,EAAK,oBAAoB,KACpF,OAAC,OAAI,UAAU,mGAAmG,GACpH,EACF,GAEJ,GACF,IA3DQkC,CA4DV,CACD,EACH,EAGClC,EAAK,aAAa,QACjB,OAAC,KACC,KAAMA,EAAK,YAAY,IACvB,OAAO,SACP,IAAI,sBACJ,UAAU,qEAET,SAAAA,EAAK,YAAY,OAAS,qBAC7B,GAEJ,EACF,CAEJ,CAEA,IAAOd,EAAQa",
6
- "names": ["ConsumeCredits_exports", "__export", "ConsumeCredits_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_provider", "import_viewStack", "import_useRedeemableList", "import_useRedeemAndBuy", "import_type", "import_utils", "import_constants", "ConsumeCredits", "copy", "onClose", "profile", "creditInfo", "openSignUpPopup", "alpcConfig", "pushView", "brand", "rounded", "redeemAndBuyError", "setRedeemAndBuyError", "loadingId", "setLoadingId", "isLogin", "redeemableList", "listLoading", "redeemAndBuy", "handles", "item", "products", "list", "alpcData", "r", "availableCredit", "insufficient", "soldOut", "product", "variant", "p", "v", "getButtonLabel", "isDisabled", "handleRedeem", "e", "idx", "isRedeemAndBuy", "mappedImgUrl", "imgUrl", "imgAlt", "cn"]
4
+ "sourcesContent": ["import { useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { classNames as cn, useProductsByHandles, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useRedeemableList } from './hooks/useRedeemableList'\nimport { useRedeemAndBuy } from './hooks/useRedeemAndBuy'\nimport {\n ConsumeCreditsItemType,\n MemberPopupPanelType,\n type ConsumeCreditsopy,\n type ConsumeCreditsItem,\n} from '../../type'\nimport { numberFormat } from '../../../credits/context/utils'\nimport type { ConsumeCreditRuleResponse } from '../../../credits/context/response'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype EnrichedItem = ConsumeCreditsItem & {\n alpcData: ConsumeCreditRuleResponse\n insufficient: boolean\n soldOut: boolean\n product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n onClose: () => void\n}\n\nfunction ConsumeCredits({ copy, onClose }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig } = useMemberPopupContext()\n const { pushView } = useViewStack()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [redeemAndBuyError, setRedeemAndBuyError] = useState('')\n const [loadingId, setLoadingId] = useState<string | number | null>(null)\n\n const isLogin = !!profile\n const { redeemableList, listLoading } = useRedeemableList(alpcConfig)\n const { trigger: redeemAndBuy } = useRedeemAndBuy(alpcConfig)\n\n const handles = copy.list.map(item => item.product?.handle).filter(Boolean) as string[]\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const alpcData = redeemableList.find(r => String(r.id) === String(item.redeemId))\n if (!alpcData) return null\n\n const availableCredit = Number(creditInfo?.available_credit ?? 0)\n const insufficient = isLogin && !!profile?.activated && alpcData.consume_credits > availableCredit\n const soldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n let product\n let variant\n if (\n (item.type === ConsumeCreditsItemType.RedeemAndBuy ||\n item.type === ConsumeCreditsItemType.Product) &&\n item.product\n ) {\n product = products?.find((p: any) => p.handle === item.product!.handle)\n variant = product?.variants?.find((v: any) => v.sku === item.product!.sku) ?? product?.variants?.[0]\n if (item.type === ConsumeCreditsItemType.RedeemAndBuy && (!product || !variant)) return null\n }\n\n return { ...item, alpcData, insufficient, soldOut, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin) return copy.unlockRewards\n if (item.soldOut) return copy.soldOut\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n if (\n item.type === ConsumeCreditsItemType.GiftCard ||\n item.type === ConsumeCreditsItemType.Product\n ) {\n return item.insufficient\n }\n return item.soldOut || item.insufficient\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (!profile?.activated) {\n pushView({ type: MemberPopupPanelType.Activate })\n return\n }\n if (\n item.type === ConsumeCreditsItemType.GiftCard ||\n item.type === ConsumeCreditsItemType.Product\n ) {\n if (copy.creditsPage?.url) {\n window.open(copy.creditsPage.url, '_blank', 'noopener,noreferrer')\n }\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\n pushView({\n type: MemberPopupPanelType.RedeemCoupon,\n props: {\n itemTitle: item.title,\n itemCredits: item.alpcData.consume_credits,\n itemImage: copy.imageMapping?.[item.type]\n ? { url: copy.imageMapping[item.type]!.url, alt: item.image?.alt }\n : item.image,\n itemValue: item.value,\n itemOff: copy.off,\n itemRules: item.rules,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n alpcConfig,\n },\n })\n } else {\n setRedeemAndBuyError('')\n setLoadingId(item.redeemId)\n try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n })\n } catch (e: any) {\n setRedeemAndBuyError(e?.message ?? copy.redeemModal.commonError)\n } finally {\n setLoadingId(null)\n }\n }\n }\n\n return (\n <>\n <div className=\"flex flex-1 flex-col gap-[12px]\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n {copy.subtitle && <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>}\n </div>\n\n {copy.insufficientCredits && creditInfo && (\n <div className=\"text-[14px] font-[700] text-[#1d1d1f]\">\n {copy.insufficientCredits}: {numberFormat(creditInfo.available_credit)} {copy.pointUnit}\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] font-[700] text-[#f84d4f]\">{redeemAndBuyError}</div>}\n\n {listLoading ? (\n <div className=\"flex flex-1 items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n ) : (\n <div className=\"flex flex-col\">\n {list.map((item, idx) => {\n const hasProduct = !!item.product\n return (\n <div key={idx} className=\"relative py-[16px]\">\n {idx > 0 && <div className=\"absolute inset-x-0 top-0 h-px bg-[#dadce0]\" />}\n <div className=\"flex items-center gap-[12px]\">\n {(() => {\n const mappedImgUrl = copy.imageMapping?.[item.type]?.url\n const imgUrl = hasProduct\n ? (item.variant?.image?.url ?? item.product?.images?.[0]?.url ?? item.image?.url)\n : (mappedImgUrl ?? item.image?.url)\n const imgAlt = hasProduct\n ? (item.variant?.image?.altText ?? item.product?.images?.[0]?.alt ?? item.image?.alt ?? '')\n : (item.image?.alt ?? '')\n if (!imgUrl) return null\n return (\n <div className={cn('relative size-[64px] shrink-0 overflow-hidden', rounded ? 'rounded-[4px]' : 'rounded-none')}>\n <Picture\n source={imgUrl}\n alt={imgAlt}\n className=\"flex size-full items-center justify-center\"\n imgClassName={hasProduct ? 'object-cover' : 'h-full w-auto object-contain'}\n />\n {!hasProduct && item.value && (\n <div className=\"absolute bottom-[20px] left-[4px] text-[14px] font-[800] leading-none text-white\">\n {item.value} {copy.off}\n </div>\n )}\n </div>\n )\n })()}\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024] line-clamp-2\">\n {hasProduct && item.product?.title\n ? item.product.title\n : item.title}\n </div>\n <div className=\"mt-[4px] text-[14px] text-[#666]\">\n {hasProduct && item.price != null\n ? `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''} + $${Number(item.price).toFixed(2)}`\n : `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''}`}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn('bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white', rounded ? 'rounded-[4px]' : 'rounded-none')}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && (\n <div className=\"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block\">\n <div className=\"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow\">\n <p className=\"text-pretty tracking-[-0.02em] text-[14px]\">{copy.insufficientCredits}</p>\n <div className=\"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n )}\n </div>\n </div>\n </div>\n )\n })}\n </div>\n )}\n\n {copy.creditsPage?.url && (\n <a\n href={copy.creditsPage.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default ConsumeCredits\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA8II,IAAAI,EAAA,6BA9IJC,EAAkC,iBAClCC,EAAgC,iCAChCC,EAA2E,yBAC3EC,EAAsC,kCACtCC,EAA6B,mCAC7BC,EAAkC,qCAClCC,EAAgC,mCAChCC,EAKO,sBACPC,EAA6B,0CAE7BC,EAA+B,iCAe/B,SAASC,EAAe,CAAE,KAAAC,EAAM,QAAAC,CAAQ,EAAU,CAChD,KAAM,CAAE,QAAAC,EAAS,WAAAC,EAAY,gBAAAC,EAAiB,WAAAC,CAAW,KAAI,yBAAsB,EAC7E,CAAE,SAAAC,CAAS,KAAI,gBAAa,EAC5B,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CAAK,EAEvC,CAACE,EAAmBC,CAAoB,KAAI,YAAS,EAAE,EACvD,CAACC,EAAWC,CAAY,KAAI,YAAiC,IAAI,EAEjEC,EAAU,CAAC,CAACX,EACZ,CAAE,eAAAY,EAAgB,YAAAC,CAAY,KAAI,qBAAkBV,CAAU,EAC9D,CAAE,QAASW,CAAa,KAAI,mBAAgBX,CAAU,EAEtDY,EAAUjB,EAAK,KAAK,IAAIkB,GAAQA,EAAK,SAAS,MAAM,EAAE,OAAO,OAAO,EACpE,CAAE,KAAMC,CAAS,KAAI,wBAAqB,CAAE,QAAAF,CAAQ,CAAC,EAErDG,KAAO,WAAQ,IACZpB,EAAK,KACT,IAAIkB,GAAQ,CACX,MAAMG,EAAWP,EAAe,KAAKQ,GAAK,OAAOA,EAAE,EAAE,IAAM,OAAOJ,EAAK,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W,EAAAuC,YAAG,6FAA8F/B,EAAU,gBAAkB,cAAc,EACtJ,SAAUuB,EAAWb,CAAI,EACzB,QAASP,IAAcO,EAAK,SAC5B,QAAS,IAAMc,EAAad,CAAI,EAE/B,SAAAY,EAAeZ,CAAI,EACtB,EACCA,EAAK,iBACJ,OAAC,OAAI,UAAU,qGACb,oBAAC,OAAI,UAAU,0EACb,oBAAC,KAAE,UAAU,6CAA8C,SAAAlB,EAAK,oBAAoB,KACpF,OAAC,OAAI,UAAU,oGAAoG,GACrH,EACF,GAEJ,GACF,IA1DQkC,CA2DV,CAEF,CAAC,EACH,EAGClC,EAAK,aAAa,QACjB,OAAC,KACC,KAAMA,EAAK,YAAY,IACvB,OAAO,SACP,IAAI,sBACJ,UAAU,qEAET,SAAAA,EAAK,YAAY,OAAS,qBAC7B,GAEJ,EACF,CAEJ,CAEA,IAAOd,EAAQa",
6
+ "names": ["ConsumeCredits_exports", "__export", "ConsumeCredits_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_provider", "import_viewStack", "import_useRedeemableList", "import_useRedeemAndBuy", "import_type", "import_utils", "import_constants", "ConsumeCredits", "copy", "onClose", "profile", "creditInfo", "openSignUpPopup", "alpcConfig", "pushView", "brand", "rounded", "redeemAndBuyError", "setRedeemAndBuyError", "loadingId", "setLoadingId", "isLogin", "redeemableList", "listLoading", "redeemAndBuy", "handles", "item", "products", "list", "alpcData", "r", "availableCredit", "insufficient", "soldOut", "product", "variant", "p", "v", "getButtonLabel", "isDisabled", "handleRedeem", "e", "idx", "hasProduct", "mappedImgUrl", "imgUrl", "imgAlt", "cn"]
7
7
  }
@@ -0,0 +1,11 @@
1
+ import type { SubscribeModalCopy } from '../../type';
2
+ type Props = {
3
+ onClose: () => void;
4
+ onSuccess?: () => void;
5
+ copy: SubscribeModalCopy;
6
+ email?: string;
7
+ hideForm: boolean;
8
+ onHideForm: () => void;
9
+ };
10
+ export default function ActivitiesSubscribeModal({ onClose, onSuccess, copy, email: initialEmail, hideForm, onHideForm }: Props): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";var E=Object.create;var p=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var J=(r,o)=>{for(var e in o)p(r,e,{get:o[e],enumerable:!0})},M=(r,o,e,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of H(o))!q.call(r,i)&&i!==e&&p(r,i,{get:()=>o[i],enumerable:!(n=F(o,i))||n.enumerable});return r};var V=(r,o,e)=>(e=r!=null?E(I(r)):{},M(o||!r||!r.__esModule?p(e,"default",{value:r,enumerable:!0}):e,r)),X=r=>M(p({},"__esModule",{value:!0}),r);var G={};J(G,{default:()=>L});module.exports=X(G);var t=require("react/jsx-runtime"),a=require("react"),s=require("@anker-in/headless-ui"),d=require("@anker-in/lib"),f=V(require("js-cookie")),S=require("query-string"),k=require("../../../credits/context/utils"),T=require("../../context/provider"),y=require("../../../../constants");function Z(){if(typeof window>"u")return{register_source:""};const{search:r,href:o}=window.location,e=(0,S.parse)(r);return{fbuy_ref_code:f.default.get("fbuy_ref_code"),ref:f.default.get("ref_ads"),inviter_code:e.ic??e.inviter_code??f.default.get("inviter_code"),register_source:e.redirect??f.default.get("reg_source")??o}}async function z(r){if(typeof window>"u"||!window?.grecaptcha?.execute||!r)return"";try{return await window.grecaptcha.execute(r,{action:"activity"})}catch{return""}}function L({onClose:r,onSuccess:o,copy:e,email:n,hideForm:i,onHideForm:b}){const{alpcConfig:P}=(0,T.useMemberPopupContext)(),{locale:h}=P,{brand:B,storeDomain:v,recaptchaSitekey:A}=(0,d.useHeadlessContext)(),m=y.ROUNDED_BRANDS.includes(B),[x,D]=(0,a.useState)(!1),[c,_]=(0,a.useState)(n??""),[g,l]=(0,a.useState)(""),[R,w]=(0,a.useState)(""),[O,C]=(0,a.useState)(!1);(0,a.useEffect)(()=>{n&&_(n)},[n]);const U=(0,a.useCallback)(async()=>{if(l(""),!c)return l("Please fill in your email");if(!(0,k.emailValidate)(c))return l("Invalid email address");if(!x)return l("Please agree to the policy");C(!0);const{register_source:u}=Z(),j=await z(A||"");try{const N=await(await fetch("/api/multipass/rainbowbridge/activities",{method:"POST",headers:{"Content-Type":"application/json","current-language":h,"X-Recaptcha-Token":j},body:JSON.stringify({email:c,register_source:u,shopify_domain:v,single_brand_subscribe:e.single_brand_subscribe??!0,genre:e.genre??e.dealsType??"",sub_brand_type:e.sub_brand_type??""})})).json();N.errors?l(N.errors??"Error occurred"):(w(e.successTips??"Subscribed successfully!"),o?.(),setTimeout(()=>{b(),w("")},3e3))}catch{l("Network error")}finally{C(!1)}},[c,x,h,v,e,o,b]);return(0,t.jsxs)("div",{className:"flex flex-col gap-[16px] text-center",children:[!i&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.Text,{className:"text-[22px] font-bold",html:e.title}),e.desc&&(0,t.jsx)(s.Text,{className:"text-left text-[16px] font-semibold text-[#1f2021]",html:e.desc}),(0,t.jsxs)("div",{className:(0,d.classNames)("flex h-[52px] w-full overflow-hidden md:flex-col md:h-auto md:gap-[16px]",m?"rounded-[2px]":"rounded-none"),children:[(0,t.jsx)("input",{className:(0,d.classNames)("h-[46px] w-full border px-[14px] text-[16px] outline-none placeholder:text-[#999]",g?"border-[#f84d4f]":"border-[#d8d8d8]",m?"rounded-[4px]":"rounded-none"),placeholder:e.placeholder,value:c,onChange:u=>{l(""),_(u.target.value.trim())}}),(0,t.jsx)(s.Button,{variant:"primary",loading:O,className:(0,d.classNames)("!h-full !min-w-0 !px-[24px] md:!h-[46px]",m?"!rounded-l-none !rounded-r-[2px] md:!rounded-[2px]":"!rounded-none"),onClick:U,children:e.buttonLabel??"Subscribe"})]}),(0,t.jsxs)("div",{className:"flex w-full items-start gap-[8px]",children:[(0,t.jsx)(s.Checkbox,{checked:x,onCheckedChange:()=>D(u=>!u),className:"border-[#1d1d1f]"}),(0,t.jsx)("label",{className:"text-left text-[14px] font-semibold text-[#777] [&_a]:underline",dangerouslySetInnerHTML:{__html:e.policy??""}})]}),g&&(0,t.jsx)("div",{className:"text-left text-[16px] font-semibold text-[#f84d4f]",children:(0,t.jsx)(s.Text,{html:g})}),(0,t.jsx)("div",{className:"text-left text-[16px] font-semibold text-[#52c41a]",children:(0,t.jsx)(s.Text,{html:R})})]}),e.promo&&(0,t.jsxs)("div",{className:"flex flex-col text-left",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[e.promo?.title&&(0,t.jsx)("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#080a0f]",children:e.promo?.title}),e.promo.description&&(0,t.jsx)("p",{className:"text-[14px] leading-[1.5] text-[#1e2024]",children:e.promo.description}),e.promo.learnMoreLabel&&e.promo.learnMoreUrl&&(0,t.jsxs)("a",{href:e.promo.learnMoreUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-[4px] text-[14px] font-[700] text-[#080a0f] underline",children:[e.promo.learnMoreLabel,(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:(0,t.jsx)("path",{d:"M5.52827 3.52876C5.78862 3.26841 6.21063 3.26841 6.47098 3.52876L10.471 7.52876C10.7313 7.78911 10.7313 8.21112 10.471 8.47147L6.47098 12.4715C6.21063 12.7318 5.78862 12.7318 5.52827 12.4715C5.26792 12.2111 5.26792 11.7891 5.52827 11.5288L9.05692 8.00011L5.52827 4.47147C5.26792 4.21112 5.26792 3.78911 5.52827 3.52876Z",fill:"#080A0F"})})]})]}),e.promo.image?.url&&(0,t.jsx)(s.Picture,{source:e.promo.image.url,alt:e.promo.image.alt??"",className:(0,d.classNames)("h-[100px] mt-[8px] w-full object-cover",m?"rounded-[8px]":"rounded-none")})]})]})}
2
+ //# sourceMappingURL=ActivitiesSubscribePanel.js.map