{"version":3,"file":"AutoPromoCode.CUoMi3qv.mjs","names":[],"sources":["https:/framerusercontent.com/modules/GJwcovSHPtfLKg4a3htY/9sY4QGgB63ZT1Qnbzd7t/AutoPromoCode.js"],"sourcesContent":["// Automatically applies a promo code without user interaction or consent\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Auto Promo Code Applier\n *\n * Automatically applies a promo code by storing it in a cookie when the component mounts.\n * Hidden component that runs in the background.\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function AutoPromoCode(props){const{promoCode,cookieName,expiryDays}=props;useEffect(()=>{if(typeof window===\"undefined\")return;const setCookie=(name,value,days)=>{const date=new Date;date.setTime(date.getTime()+days*24*60*60*1e3);const expires=`expires=${date.toUTCString()}`;document.cookie=`${name}=${encodeURIComponent(value)};${expires};path=/;domain=.stairtop.com;secure;samesite=lax`;};const getCookie=name=>{const nameEQ=`${name}=`;const ca=document.cookie.split(\";\");for(let i=0;i<ca.length;i++){let c=ca[i];while(c.charAt(0)===\" \")c=c.substring(1,c.length);if(c.indexOf(nameEQ)===0)return c.substring(nameEQ.length,c.length);}return null;};const existingPromo=getCookie(cookieName);if(!existingPromo&&promoCode){startTransition(()=>{setCookie(cookieName,promoCode,expiryDays);const event=new CustomEvent(\"promoCodeApplied\",{detail:{code:promoCode}});window.dispatchEvent(event);});}},[promoCode,cookieName,expiryDays]);return /*#__PURE__*/_jsx(\"div\",{});}addPropertyControls(AutoPromoCode,{promoCode:{type:ControlType.String,title:\"Promo Code\",defaultValue:\"FREESHIP\",placeholder:\"Enter promo code\"},cookieName:{type:ControlType.String,title:\"Cookie Name\",defaultValue:\"applied_promo_code\",placeholder:\"Cookie identifier\"},expiryDays:{type:ControlType.Number,title:\"Expiry Days\",defaultValue:30,min:1,max:365,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AutoPromoCode\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AutoPromoCode.map"],"mappings":"+LASG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,YAAU,aAAW,cAAY,EAA41B,OAAt1B,MAAc,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,GAAW,EAAK,EAAM,IAAO,CAAC,IAAM,EAAK,IAAI,KAAK,EAAK,QAAQ,EAAK,QAAQ,EAAE,EAAK,GAAG,GAAG,GAAG,GAAG,EAAE,IAAM,EAAQ,WAAW,EAAK,YAAY,IAAI,SAAS,OAAO,GAAG,EAAK,GAAG,mBAAmB,CAAK,EAAE,GAAG,EAAQ,iDAAkD,EAAgT,EAA9R,GAAM,CAAC,IAAM,EAAO,GAAG,EAAK,GAAS,EAAG,SAAS,OAAO,MAAM,GAAG,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,EAAG,OAAO,IAAI,CAAC,IAAI,EAAE,EAAG,GAAG,KAAM,EAAE,OAAO,CAAC,IAAI,KAAI,EAAE,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAM,IAAI,EAAE,OAAO,EAAE,UAAU,EAAO,OAAO,EAAE,MAAM,CAAE,CAAC,OAAO,IAAK,EAAsB,CAAU,CAA4B,GAAG,GAAW,MAAoB,CAAC,EAAU,EAAW,EAAU,CAAU,EAAE,IAAM,EAAM,IAAI,YAAY,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAS,CAAC,CAAC,EAAE,EAAO,cAAc,CAAK,CAAE,CAAC,CAAG,EAAE,CAAC,EAAU,EAAW,CAAU,CAAC,EAAsB,EAAK,MAAM,CAAC,CAAC,CAAE,qBAR56B,IAA6C,IAAoD,EAQ40B,EAAoB,EAAc,CAAC,UAAU,CAAC,KAAK,EAAY,OAAO,MAAM,aAAa,aAAa,WAAW,YAAY,kBAAkB,EAAE,WAAW,CAAC,KAAK,EAAY,OAAO,MAAM,cAAc,aAAa,qBAAqB,YAAY,mBAAmB,EAAE,WAAW,CAAC,KAAK,EAAY,OAAO,MAAM,cAAc,aAAa,GAAG,IAAI,EAAE,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC"}