{"version":3,"file":"OfferSignupForm.DLay2RYC.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/iSWEvXlDFuqgBdzWTxVh/JjsA1pUxqGaHTp5IdyYT/OfferSignupForm.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import Checkbox from\"https://framer.com/m/Checkbox-6HGi.js@ZCBZmszzxeXzmj9ehrzn\";import CodablePrimaryButton from\"https://framer.com/m/CodablePrimaryButton-hjJA.js@nUxTef7NT42msFVh6UpB\";import PhoneInput from\"https://framer.com/m/PhoneInput-SnSe.js@Ryluk3eKNy5rQbe6I7D0\";import{spacing}from\"https://framer.com/m/Constants-e8LZ.js@WWFLc94a635DVsxeJKyF\";import{useState,useEffect}from\"react\";import{isValidPhoneNumber}from\"libphonenumber-js\";export default function OfferSignupForm(props){const[isSelected,setIsSelected]=useState(false);const[phoneNumber,setPhoneNumber]=useState(\"\");const[phoneError,setPhoneError]=useState(undefined);const[countryCode,setCountryCode]=useState(1);const[fetchedUrlParameters,setFetchedUrlParameters]=useState(false);useEffect(()=>{if(fetchedUrlParameters){return;}const phoneNumberUrlParameter=getPhoneNumberFromUrl();if(phoneNumberUrlParameter?.length>10){if(phoneNumberUrlParameter.startsWith(\"1\")){setCountryCode(1);}else if(phoneNumberUrlParameter.startsWith(\"44\")){setCountryCode(44);}setPhoneNumber(phoneNumberUrlParameter.slice(-10));}},[setFetchedUrlParameters,fetchedUrlParameters,setPhoneNumber]);const handleCheckboxChange=()=>{setIsSelected(!isSelected);};const handlePhoneNumberChange=number=>{setPhoneNumber(number);setPhoneError(undefined);};const handleCountryCodeChange=code=>{setCountryCode(code);};const onSubmit=()=>{const formattedPhoneNumber=\"+\"+countryCode+phoneNumber.replaceAll(\"-\",\"\");if(formattedPhoneNumber.length<12||!isValidPhoneNumber(formattedPhoneNumber)){setPhoneError(\"Please enter a valid phone number\");return;}// GTM tracking here\n// Start with the originating parameters\nconst parameters=new URLSearchParams(window.location.search);for(let key of parameters.keys()){// These keys must be removed from the originating parameters\n// The Framer set values take precedence\nif([\"phoneNumber\",\"smsMarketingOptInStatus\",\"redirectDestination\"].includes(key)){parameters.delete(key);}}const framerParameters=new URLSearchParams({phoneNumber:formattedPhoneNumber,partnerName:props.partnerName,promoName:props.promoName,smsMarketingOptInStatus:isSelected?\"true\":\"false\",redirectDestination:props.redirectDestination,membershipType:props.membershipType,userAudience:props.userAudience,utm_content:props.utmContent,utm_medium:props.utmMedium,utm_source:props.utmSource,utm_campaign:props.utmCampaign,utm_term:props.utmTerm,registration_referrer:window.document.referrer,registration_source:props.partnerName,eligibility:props.eligibility,eligibleMessageTemplate:props.messageTemplateEligible,ineligibleMessageTemplate:props.messageTemplateIneligible});for(let[key,val]of framerParameters.entries()){if(val){parameters.append(key,val);}}dataLayer.push({event:\"FramerPhoneNumberEntered\",data:{utmAudience:props.userAudience}});window.open(\"http://gopuff.com/partner-onboarding-magic-link-confirmation?\"+parameters,\"_self\");};return /*#__PURE__*/_jsxs(\"div\",{style:styles.container,children:[/*#__PURE__*/_jsx(PhoneInput,{onChange:handlePhoneNumberChange,error:phoneError,value:phoneNumber,onCountryCodeChange:handleCountryCodeChange,countryCode:countryCode}),/*#__PURE__*/_jsx(CodablePrimaryButton,{onClick:onSubmit,text:props.buttonText,theme:props.buttonTheme}),props.checkboxText.length>0&&/*#__PURE__*/_jsx(Checkbox,{selected:isSelected,onChange:handleCheckboxChange,text:props.checkboxText})]});}const styles={container:{display:\"flex\",flexDirection:\"column\",gap:spacing.s16,overflow:\"visible\"}};// Props\nOfferSignupForm.defaultProps={checkboxText:\"Send me order updates & deals via SMS\",buttonText:\"Get your special offer\",buttonTheme:\"Black\",partnerName:undefined,promoName:undefined,membershipType:undefined,userAudience:undefined};addPropertyControls(OfferSignupForm,{buttonText:{title:\"Button Text\",type:ControlType.String},buttonTheme:{title:\"Button Theme\",type:ControlType.Enum,options:[\"Black\",\"Blue\"]},checkboxText:{title:\"Checkbox Text\",type:ControlType.String},partnerName:{title:\"Partner Name\",type:ControlType.Enum,options:[\"Gopuff\",\"Apple\",\"ApplePay\",\"Cash App\",\"Bilt\",\"JetBlue\",\"Goodtime Hotel\",\"NIFT\",\"NYC Apartments\",\"Warehouse Wine and Spirits\",\"BevMo\"]},promoName:{title:\"Promo Name\",type:ControlType.String},membershipType:{title:\"Membership Type\",type:ControlType.Enum,defaultValue:\"none\",options:[\"None\",\"FAM\",\"Student FAM\"]},userAudience:{title:\"User Audience\",type:ControlType.String},redirectDestination:{title:\"Redirect Destination\",type:ControlType.Enum,defaultValue:\"app\",options:[\"app\",\"web\"]},utmContent:{title:\"utm_content\",type:ControlType.String},utmMedium:{title:\"utm_medium\",type:ControlType.String},utmSource:{title:\"utm_source\",type:ControlType.String},utmCampaign:{title:\"utm_campaign\",type:ControlType.String},utmTerm:{title:\"utm_term\",type:ControlType.String},eligibility:{title:\"Eligibility\",type:ControlType.Enum,defaultValue:\"NO_ACCOUNT\",options:[\"NO_ACCOUNT\",\"NEWBIE\",\"ANYONE\"]},messageTemplateEligible:{title:\"Eligibile Message Template\",type:ControlType.String},messageTemplateIneligible:{title:\"Ineligible Message Template\",type:ControlType.String}});function getPhoneNumberFromUrl(){return new URLSearchParams(window.location.search).get(\"phoneNumber\");}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"OfferSignupForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./OfferSignupForm.map"],"mappings":"oXAAqiB,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAM,CAAC,EAAY,GAAgBA,EAAS,GAAG,CAAM,CAAC,EAAW,GAAeA,EAAS,IAAA,GAAU,CAAM,CAAC,EAAY,GAAgBA,EAAS,EAAE,CAAM,CAAC,EAAqB,GAAyBA,EAAS,GAAM,CAIyL,O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