{"version":3,"file":"InitializePhoneInput.C1PdeSVp.mjs","names":[],"sources":["https:/framerusercontent.com/modules/2PXAP9mknCJz7SQHcGUE/l2J4EfxWHaT5zbFNUkKQ/InitializePhoneInput.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";const intlTelInputCss=\"https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/css/intlTelInput.css\";const intlTelInputJs=\"https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/intlTelInput.min.js\";const utilsScript=\"https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js\";const countryData=[{name:\"Afghanistan\",code:\"af\",dial_code:\"+93\"}];export function InitializePhoneInput({enableGeolocation,defaultCountry}){useEffect(()=>{console.log(\"Initializing Phone Input\");// Load the intl-tel-input CSS\nconst link=document.createElement(\"link\");link.rel=\"stylesheet\";link.href=intlTelInputCss;document.head.appendChild(link);// Load the intl-tel-input JS\nconst script=document.createElement(\"script\");script.src=intlTelInputJs;document.body.appendChild(script);script.onload=()=>{const inputs=document.querySelectorAll(\"input[type='tel']\");inputs.forEach(input=>{let userSelectedCountry=false// Track if user manually selects a country\n;const iti=window.intlTelInput(input,{initialCountry:enableGeolocation?\"auto\":defaultCountry||\"us\",geoIpLookup:enableGeolocation?callback=>{fetch(\"https://ipinfo.io/json\").then(res=>res.json()).then(data=>callback(data.country||\"us\"))// Fallback if no country data\n.catch(()=>callback(\"us\"));}:undefined,utilsScript:utilsScript,separateDialCode:true,autoHideDialCode:false,dropdownContainer:document.body,customPlaceholder:placeholder=>`e.g. ${placeholder}`});iti.promise.then(()=>{const setDialCodeWithSpace=()=>{const dialCode=iti.getSelectedCountryData().dialCode;const dialCodeWithPlusAndSpace=`+${dialCode} `// Add a space after the dial code\n;input.value=dialCodeWithPlusAndSpace;};setDialCodeWithSpace();// Handle manual country selection to lock it\ninput.addEventListener(\"countrychange\",()=>{userSelectedCountry=true// User manually selected a country\n;});// Move cursor to the end of the dial code and space on focus\ninput.addEventListener(\"focus\",()=>{setTimeout(()=>{const dialCodeLength=iti.getSelectedCountryData().dialCode.length+2// +2 for '+' and the space\n;input.setSelectionRange(dialCodeLength,dialCodeLength);},0);});// Prevent cursor moving before the space after the dial code\ninput.addEventListener(\"click\",()=>{const dialCodeLength=iti.getSelectedCountryData().dialCode.length+2// +2 for '+' and the space\n;if(input.selectionStart<dialCodeLength){input.setSelectionRange(dialCodeLength,dialCodeLength);}});// Prevent removing the space after the dial code\ninput.addEventListener(\"keydown\",e=>{const dialCodeLength=iti.getSelectedCountryData().dialCode.length+2// +2 for '+' and the space\n;// Prevent Backspace or Delete from removing the space after the dial code\nif(e.key===\"Backspace\"&&input.selectionStart<=dialCodeLength||e.key===\"Delete\"&&input.selectionStart<dialCodeLength){e.preventDefault();}// Handle Cmd+Backspace or Ctrl+Backspace\nif(e.key===\"Backspace\"&&(e.metaKey||e.ctrlKey)){e.preventDefault();input.value=input.value.slice(0,dialCodeLength)// Keep only the dial code and space\n;setTimeout(()=>{input.setSelectionRange(dialCodeLength,dialCodeLength);},0);}});// Ensure the space is maintained on input\ninput.addEventListener(\"input\",()=>{const dialCodeWithPlusAndSpace=`+${iti.getSelectedCountryData().dialCode} `;if(!input.value.startsWith(dialCodeWithPlusAndSpace)){input.value=dialCodeWithPlusAndSpace+input.value.slice(dialCodeWithPlusAndSpace.length).trimStart();input.setSelectionRange(dialCodeWithPlusAndSpace.length,dialCodeWithPlusAndSpace.length);}});// Prevent reverting to geolocation after manual selection\nif(enableGeolocation){input.addEventListener(\"blur\",()=>{if(userSelectedCountry){const selectedCountry=iti.getSelectedCountryData().iso2;iti.setCountry(selectedCountry)// Lock to manually selected country\n;}});}// Append full number on form submission\nconst form=input.closest(\"form\");if(form){form.addEventListener(\"submit\",()=>{const fullNumber=iti.getNumber();input.value=fullNumber;});}});});};script.onerror=()=>console.error(\"Failed to load intl-tel-input JS\");return()=>{document.head.removeChild(link);document.body.removeChild(script);};},[enableGeolocation,defaultCountry]);const isFramerEditor=typeof window!==\"undefined\"&&window.location.href.includes(\"framer.com\");const hiddenStyle=isFramerEditor?{}:{display:\"none\",padding:0};return /*#__PURE__*/_jsxs(\"div\",{style:hiddenStyle,children:[/*#__PURE__*/_jsx(\"p\",{children:\"Phone\"}),/*#__PURE__*/_jsx(\"style\",{children:`\n                .phone-mask-form {\n                    overflow: visible !important;\n                }\n                .phone-mask-form .framer-form-input-wrapper {\n                    overflow: visible !important;\n                }\n                .intl-tel-input {\n                    width: 100%;\n                    position: relative;\n                }\n                .intl-tel-input .selected-flag {\n                    border-radius: 5px;\n                    display: flex;\n                    align-items: center;\n                    justify-content: center;\n                }\n                .intl-tel-input .selected-dial-code {\n                    display: none !important; /* Completely hides the country code */\n                }\n                .intl-tel-input input[type=\"tel\"] {\n                    border: none;\n                    background: none;\n                    position: absolute;\n                    left: 0;\n                    top: 0;\n                    width: 100%;\n                    height: 100%;\n                    opacity: 0; /* Hides the input completely but keeps it interactive */\n                    pointer-events: none; /* Prevents any interaction on the actual input field */\n                }\n                .iti__selected-dial-code {\n                    display:none;\n                }\n                /* Customizing the dropdown */\n                .iti__dropdown {\n                    background-color: #f9f9f9; /* Light background for the dropdown */\n                    border: 1px solid #ddd; /* Border around the dropdown */\n                    border-radius: 5px; /* Rounded corners */\n                    font-family: 'Arial', sans-serif; /* Custom font */\n                }\n\n                /* Customizing each list item */\n                .iti__country {\n                    padding: 10px; /* More padding for each item */\n                    color: #333; /* Custom text color */\n                }\n\n                .iti__country:hover {\n                    background-color: #EDEAFD; /* Highlight on hover */\n                    color: #0056b3; /* Change text color on hover */\n                }\n                \n                .iti__flag {\n                    border-radius: 2px; /* Rounded flags */\n                }\n                .iti__country-list {\n                    border-radius: 8px;\n                    border: 1px solid #888888;\n                }\n                .iti__country-name {\n                    font-family: 'Inter';\n                    font-size: 14px;\n                    font-weight: 500;\n                    letter-spacing: -.5px;\n                }\n                .iti__dial-code {\n                    font-size: 14px;\n                }\n            `})]});}addPropertyControls(InitializePhoneInput,{enableGeolocation:{type:ControlType.Boolean,title:\"IP Detect\",defaultValue:true},defaultCountry:{type:ControlType.Enum,title:\"Default Country\",options:countryData.map(country=>country.code),optionTitles:countryData.map(country=>country.name),hidden:props=>props.enableGeolocation}});InitializePhoneInput.displayName=\"Phone Mask Configuration\";\nexport const __FramerMetadata__ = {\"exports\":{\"InitializePhoneInput\":{\"type\":\"reactComponent\",\"name\":\"InitializePhoneInput\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./InitializePhoneInput.map"],"mappings":"gMAA+f,SAAgB,EAAqB,CAAC,oBAAkB,kBAAgB,CAoB9F,OApB+F,MAAc,CAAC,QAAQ,IAAI,0BAA0B,EAC7nB,IAAM,EAAK,SAAS,cAAc,MAAM,EAAE,EAAK,IAAI,aAAa,EAAK,KAAK,EAAgB,SAAS,KAAK,YAAY,CAAI,EACxH,IAAM,EAAO,SAAS,cAAc,QAAQ,EAkB2K,MAlBzK,GAAO,IAAI,EAAe,SAAS,KAAK,YAAY,CAAM,EAAE,EAAO,WAAW,CAA6D,SAAtC,iBAAiB,mBAA0B,CAAC,CAAC,QAAQ,GAAO,CAAC,IAAI,EAAoB,GACjO,EAAI,EAAO,aAAa,EAAM,CAAC,eAAe,EAAkB,OAAO,GAAgB,KAAK,YAAY,EAAkB,GAAU,CAAC,MAAM,wBAAwB,CAAC,CAAC,KAAK,GAAK,EAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAM,EAAS,EAAK,SAAS,IAAI,CAAC,CAAC,CACzO,UAAU,EAAS,IAAI,CAAC,CAAE,EAAE,IAAA,GAAsB,cAAY,iBAAiB,GAAK,iBAAiB,GAAM,kBAAkB,SAAS,KAAK,kBAAkB,GAAa,QAAQ,GAAa,CAAC,EAAE,EAAI,QAAQ,SAAS,CACvN,EAAM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