{"version":3,"file":"PromoCheckoutLinks.DzIcdPiC.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/Iwl9Yv5sNQkRBXPm3740/sJ7zedZZaZxmlv0wubd8/PromoCheckoutLinks.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";/* Ambassador / event landing pages are copies of a regular landing page whose\n   offer is a Stripe promo code. Every button on such a page that leads to the\n   checkout has to arrive there with the code in the URL\n   (/payment?prefilled_promo_code=CODE); the checkout passes it on to Stripe.\n\n   Most of those buttons live inside the shared nav, CTA section and footer,\n   which cannot be given a per-page link, and Framer drops query strings from\n   internal links anyway. So instead of touching the links on the canvas, the\n   page adds the code to a checkout link at the moment it is used. One export\n   per code, applied to any one layer of the landing page (it only acts while\n   that page is mounted). */const CHECKOUT_PATH=\"/payment\";function checkoutUrlWithCode(anchor,code){let url;try{url=new URL(anchor.href,window.location.href);}catch{return null;}if(url.origin!==window.location.origin)return null;if(url.pathname.replace(/\\/+$/,\"\")!==CHECKOUT_PATH)return null;/* keep whatever the visitor arrived with (utm etc.), like the checkout does */new URLSearchParams(window.location.search).forEach((value,key)=>{if(!url.searchParams.has(key))url.searchParams.set(key,value);});url.searchParams.set(\"prefilled_promo_code\",code);return url.toString();}function promoCheckoutLinks(code){return Component=>{return props=>{useEffect(()=>{const rewrite=e=>{const anchor=e.target?.closest?.(\"a[href]\");if(!(anchor instanceof HTMLAnchorElement))return false;const target=checkoutUrlWithCode(anchor,code);if(!target)return false;if(anchor.href!==target)anchor.href=target;return true;};/* Framer's own click handler navigates to the page it was built\n                   with and ignores the href, which would lose the code. Stopping\n                   the event here leaves the click to the browser, which follows\n                   the rewritten href (same tab or new tab, as the link says). */const onClick=e=>{if(rewrite(e))e.stopPropagation();};/* middle click and \"open in new tab\" from the context menu */const onAux=e=>void rewrite(e);document.addEventListener(\"click\",onClick,true);document.addEventListener(\"auxclick\",onAux,true);document.addEventListener(\"contextmenu\",onAux,true);return()=>{document.removeEventListener(\"click\",onClick,true);document.removeEventListener(\"auxclick\",onAux,true);document.removeEventListener(\"contextmenu\",onAux,true);};},[]);return /*#__PURE__*/_jsx(Component,{...props});};};}export function withDiwaliCheckoutLinks(Component){return promoCheckoutLinks(\"DIWALI\")(Component);}/* The checkout confirms the offer with a banner in the plan step, shown only\n   when the URL carries exactly this code. Same behaviour as the campaign\n   banners in PromoBanner.tsx; it is repeated here because code files cannot\n   import from each other, and keeping a landing's link and banner exports in\n   one file means they ship and get removed together. */function hasPromoCode(expected){if(typeof window===\"undefined\")return false;const code=new URLSearchParams(window.location.search).get(\"prefilled_promo_code\");return(code??\"\").trim().toUpperCase()===expected;}function promoBanner(expected){return Component=>{return props=>{const[show,setShow]=useState(()=>hasPromoCode(expected));useEffect(()=>{setShow(hasPromoCode(expected));},[]);return show?/*#__PURE__*/_jsx(Component,{...props}):null;};};}export function withDiwaliPromoBanner(Component){return promoBanner(\"DIWALI\")(Component);}\nexport const __FramerMetadata__ = {\"exports\":{\"withDiwaliPromoBanner\":{\"type\":\"reactHoc\",\"name\":\"withDiwaliPromoBanner\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withDiwaliCheckoutLinks\":{\"type\":\"reactHoc\",\"name\":\"withDiwaliCheckoutLinks\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PromoCheckoutLinks.map"],"mappings":"uIAU2D,SAAS,EAAoB,EAAO,EAAK,CAAC,IAAI,EAAI,GAAG,CAAC,EAAI,IAAI,IAAI,EAAO,KAAK,EAAO,SAAS,IAAI,CAAE,MAAM,CAAC,OAAO,IAAK,CAAuX,OAAnX,EAAI,SAAS,EAAO,SAAS,QAAsB,EAAI,SAAS,QAAQ,OAAO,EAAE,IAAI,EAAqB,MAAoF,IAAI,gBAAgB,EAAO,SAAS,MAAM,CAAC,CAAC,SAAS,EAAM,IAAM,CAAK,EAAI,aAAa,IAAI,CAAG,GAAE,EAAI,aA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