{"version":3,"file":"AutoFetchCountry_2.CTXsleTZ.mjs","names":["__legacyOverrideHOC_DataObserverContext","_jsx"],"sources":["https:/framerusercontent.com/modules/IOhZHSbvXZj2pdQCLWVb/8YJ6qYEtRoiCgPbanG0H/AutoFetchCountry_2.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";// Original version\nexport function autofillCountry(){useEffect(()=>{// Fetch the visitor's country using the provided API\nfetch(\"https://api.fetch.tools/location\").then(response=>response.json()).then(data=>{const country=data.country// For example, \"PK\"\n;// Now, get the country calling code using a service\nfetch(`https://restcountries.com/v3.1/alpha/${country}`).then(res=>res.json()).then(countryData=>{const countryCode=countryData[0].idd.root// For example, \"+\" for PK\n;const callingCode=countryData[0].idd.suffixes[0]// This will be the code, like 92\n;// Combine to form the full country calling code\nconst fullCountryCode=`${countryCode}${callingCode}`;// Select the input field by its name attribute\nconst inputField=document.querySelector('input[name=\"Phone\"]');// If the input field exists, set its value to the detected country code\nif(inputField){inputField.value=fullCountryCode;}}).catch(error=>{console.error(\"Error fetching country code:\",error);});}).catch(error=>{console.error(\"Error fetching country:\",error);});},[]);// Return an empty object as no additional props are being overridden\nreturn{};}// Enhanced version with improvements\nexport function autofillCountryEnhanced(){useEffect(()=>{let isMounted=true;const autofillPhoneCode=async()=>{try{// Fetch the visitor's country\nconst locationResponse=await fetch(\"https://api.fetch.tools/location\");if(!locationResponse.ok)throw new Error(\"Failed to fetch location\");const locationData=await locationResponse.json();const country=locationData.country;if(!country||!isMounted)return;// Get the country calling code\nconst countryResponse=await fetch(`https://restcountries.com/v3.1/alpha/${country}`);if(!countryResponse.ok)throw new Error(\"Failed to fetch country data\");const countryData=await countryResponse.json();// Validate the response structure\nif(!countryData[0]?.idd?.root||!countryData[0]?.idd?.suffixes?.[0]){console.warn(\"Invalid country data structure\");return;}const{root,suffixes}=countryData[0].idd;const fullCountryCode=`${root}${suffixes[0]}`;if(!isMounted)return;// Find the input field\nconst inputField=document.querySelector('input[name=\"Phone\"]');if(inputField){// Set the value\ninputField.value=fullCountryCode;// Trigger React events properly\nconst nativeInputValueSetter=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,\"value\")?.set;if(nativeInputValueSetter){nativeInputValueSetter.call(inputField,fullCountryCode);}// Dispatch input and change events\ninputField.dispatchEvent(new Event(\"input\",{bubbles:true}));inputField.dispatchEvent(new Event(\"change\",{bubbles:true}));}}catch(error){console.error(\"Error autofilling country code:\",error);}};autofillPhoneCode();// Cleanup function\nreturn()=>{isMounted=false;};},[])// Empty dependency array - runs once on mount\n;return{};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withautofillCountry(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...autofillCountry(props)});};}withautofillCountry.displayName=\"autofillCountry\";export function withautofillCountryEnhanced(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...autofillCountryEnhanced(props)});};}withautofillCountryEnhanced.displayName=\"autofillCountryEnhanced\";\nexport const __FramerMetadata__ = {\"exports\":{\"withautofillCountryEnhanced\":{\"type\":\"reactHoc\",\"name\":\"withautofillCountryEnhanced\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"autofillCountryEnhanced\":{\"type\":\"override\",\"name\":\"autofillCountryEnhanced\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"autofillCountry\":{\"type\":\"override\",\"name\":\"autofillCountry\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withautofillCountry\":{\"type\":\"reactHoc\",\"name\":\"withautofillCountry\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AutoFetchCountry_2.map"],"mappings":"oLACA,SAAgB,GAAiB,CASjC,OATkC,MAAc,CAChD,MAAM,kCAAkC,CAAC,CAAC,KAAK,GAAU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