{"version":3,"file":"New_Simple_Add_To_Cart.CF_rnFGf.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/OWxnUtWpORNWQupzlcni/OEEP6gnbiOJPXvZ586n5/New_Simple_Add_To_Cart.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export function AddToCartButton(props){const[isHovered,setIsHovered]=useState(false);const text=props.text??\"CONTINUE\";const productId=props.productId??\"\";const secondProductId=props.secondProductId??\"\";const shopifyUrl=props.shopifyUrl??\"\";const productPageUrl=props.productPageUrl??\"\";const continueLink=props.continueLink??\"\";const eligibilityMode=props.eligibilityMode??\"standard\";const hasContinueLink=Boolean(continueLink);const isShopifyProduct=Boolean(shopifyUrl);const isEligibilityProduct=eligibilityMode!==\"standard\";const isViewProduct=hasContinueLink||isShopifyProduct||isEligibilityProduct;const viewProductUrl=hasContinueLink?continueLink:isShopifyProduct?shopifyUrl:productPageUrl;const viewProductText=hasContinueLink?\"CHECK ELIGIBILITY\":\"VIEW PRODUCT\";const hasMultiple=Boolean(productId&&secondProductId);const dataProducts=hasMultiple?JSON.stringify([{productId,quantity:1},{productId:secondProductId,quantity:1}]):undefined;const multiProps=hasMultiple?{\"data-products\":dataProducts}:{\"data-product_id\":productId};function getUtmPropsFromDataLayer(){const dl=window.dataLayer||[];const sourceEvent=[...dl].reverse().find(item=>item&&(item.utm_source||item.utm_medium||item.utm_campaign||item.utm_content||item.utm_term));return{utm_source:sourceEvent?.utm_source||\"\",utm_medium:sourceEvent?.utm_medium||\"\",utm_campaign:sourceEvent?.utm_campaign||\"\",utm_content:sourceEvent?.utm_content||\"\",utm_term:sourceEvent?.utm_term||\"\"};}function getUrlWithUtms(url){const utms=getUtmPropsFromDataLayer();const params=new URLSearchParams;Object.entries(utms).forEach(([key,value])=>{if(value)params.set(key,value);});const queryString=params.toString();if(!queryString)return url;return url.includes(\"?\")?`${url}&${queryString}`:`${url}?${queryString}`;}function pushAddToCartEvent(){const items=hasMultiple?[{item_id:productId,quantity:1},{item_id:secondProductId,quantity:1}]:[{item_id:productId,quantity:1}];window.dataLayer=window.dataLayer||[];window.dataLayer.push({ecommerce:null});window.dataLayer.push({event:\"add_to_cart\",...getUtmPropsFromDataLayer(),ecommerce:{items}});}function handleViewProductClick(){if(!viewProductUrl)return;window.location.href=getUrlWithUtms(viewProductUrl);}return /*#__PURE__*/_jsx(\"div\",{style:props.style,children:isViewProduct?/*#__PURE__*/_jsx(\"div\",{role:\"button\",tabIndex:0,onMouseEnter:()=>setIsHovered(true),onMouseLeave:()=>setIsHovered(false),onClick:handleViewProductClick,onKeyDown:e=>{if(e.key===\"Enter\"||e.key===\" \"){handleViewProductClick();}},style:{...styles.button,background:props.buttonColor??\"#1A04FF\",color:props.textColor??\"white\",border:`1px solid ${props.borderColor??\"transparent\"}`,cursor:viewProductUrl?\"pointer\":\"default\",opacity:isHovered?.7:1,transition:\"opacity 0.2s ease\"},children:viewProductText}):/*#__PURE__*/_jsx(\"button\",{type:\"button\",className:\"add-to-cart-btn product-item\",...multiProps,disabled:!productId,onMouseEnter:()=>setIsHovered(true),onMouseLeave:()=>setIsHovered(false),onClick:pushAddToCartEvent,style:{...styles.button,background:props.buttonColor??\"#1A04FF\",color:props.textColor??\"white\",border:`1px solid ${props.borderColor??\"transparent\"}`,cursor:productId?\"pointer\":\"not-allowed\",opacity:isHovered?.7:1,transition:\"opacity 0.2s ease\"},children:text})});}const styles={button:{width:\"100%\",display:\"flex\",height:\"40px\",alignItems:\"center\",justifyContent:\"center\",gap:10,outline:\"none\",borderRadius:6,fontSize:\"0.8rem\",fontWeight:600,fontFamily:\"GT America Regular\",padding:\"0 16px\",textDecoration:\"none\",userSelect:\"none\",textTransform:\"uppercase\"}};addPropertyControls(AddToCartButton,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"ADD TO CART\"},productId:{type:ControlType.String,title:\"Product ID\",defaultValue:\"\"},secondProductId:{type:ControlType.String,title:\"Second Product\",defaultValue:\"\"},shopifyUrl:{type:ControlType.String,title:\"Shopify URL\",defaultValue:\"\",description:\"If filled, VIEW PRODUCT goes to Shopify.\"},productPageUrl:{type:ControlType.Link,title:\"Product Page\",defaultValue:\"\",description:\"Used when eligibility is not standard.\"},continueLink:{type:ControlType.String,title:\"Continue Link\",defaultValue:\"\",placeholder:\"https://...\"},eligibilityMode:{type:ControlType.Enum,title:\"Eligibility\",options:[\"standard\",\"openloop\",\"beluga\"],optionTitles:[\"Standard\",\"OpenLoop\",\"Beluga\"],defaultValue:\"standard\"},buttonColor:{type:ControlType.Color,title:\"Button\",defaultValue:\"#1A04FF\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},borderColor:{type:ControlType.Color,title:\"Border\",defaultValue:\"transparent\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"AddToCartButton\":{\"type\":\"reactComponent\",\"name\":\"AddToCartButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./New_Simple_Add_To_Cart.map"],"mappings":"yLAA2H,SAAgB,EAAgB,EAAM,CAAC,GAAK,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAO,EAAK,EAAM,MAAM,WAAiB,EAAU,EAAM,WAAW,GAAS,EAAgB,EAAM,iBAAiB,GAAS,EAAW,EAAM,YAAY,GAAS,EAAe,EAAM,gBAAgB,GAAS,EAAa,EAAM,cAAc,GAAS,EAAgB,EAAM,iBAAiB,WAAiB,EAAgB,EAAQ,EAAoB,EAAiB,EAAQ,EAA0E,EAAc,GAAiB,GAAlE,IAAkB,WAA6F,EAAe,EAAgB,EAAa,EAAiB,EAAW,EAAqB,EAAgB,EAAgB,oBAAoB,eAAqB,EAAY,GAAQ,GAAW,GAAuB,EAAa,EAAY,KAAK,UAAU,CAAC,CAAC,YAAU,SAAS,EAAE,CAAC,CAAC,UAAU,EAAgB,SAAS,EAAE,CAAC,CAAC,CA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