{"version":3,"file":"Validations.BA4Kcm8s.mjs","names":[],"sources":["https:/framerusercontent.com/modules/cBZmbfdiKgqs6VZIDqgh/wkscNVBVhya6w5CoDWL5/Validations.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";/**\n@framerDisableUnlink\n@framerIntrinsicWidth 100\n@framerIntrinsicHeight 100\n*/export function withPhoneMaskAndNameValidation(Component){return props=>{useEffect(()=>{const applyPhoneMask=event=>{const matrix=\"+38 (0__) ___-__-__\"// Adjust phone matrix as needed\n;let i=0;const def=matrix.replace(/\\D/g,\"\");let currentValue=event.target.value.replace(/\\D/g,\"\");if(def.length>=currentValue.length){currentValue=def;}const newValue=matrix.replace(/./g,a=>{return/[_\\d]/.test(a)&&i<currentValue.length?currentValue.charAt(i++):i>=currentValue.length?\"\":a;});event.target.value=newValue;};const handleBlur=event=>{const currentValue=event.target.value;// Adjust to 2 for country codes with two digits (e.g., +38)\nif(currentValue.length<=4){event.target.value=\"\";const customEvent=new Event(\"change\");event.target.dispatchEvent(customEvent);}};const restrictNameInput=event=>{const regex=/^[a-zA-Z\\u0400-\\u04FF\\s]*$/// Latin, Cyrillic, and spaces\n;if(!regex.test(event.target.value)){event.target.value=event.target.value.replace(/[^a-zA-Z\\u0400-\\u04FF\\s]/g,\"\");}};const phoneFields=document.querySelectorAll('input[type=\"tel\"]');const nameFields=document.querySelectorAll('input[name=\"name\"]');phoneFields.forEach(phoneField=>{phoneField.addEventListener(\"input\",applyPhoneMask);phoneField.addEventListener(\"blur\",handleBlur);});nameFields.forEach(nameField=>{nameField.addEventListener(\"input\",restrictNameInput);});// Cleanup on unmount\nreturn()=>{phoneFields.forEach(phoneField=>{phoneField.removeEventListener(\"input\",applyPhoneMask);phoneField.removeEventListener(\"blur\",handleBlur);});nameFields.forEach(nameField=>{nameField.removeEventListener(\"input\",restrictNameInput);});};},[]);return /*#__PURE__*/_jsx(Component,{...props});};}// Adjusted based on all three screenshots to ensure completeness and alignment with the expected structure.\n\nexport const __FramerMetadata__ = {\"exports\":{\"withPhoneMaskAndNameValidation\":{\"type\":\"reactHoc\",\"name\":\"withPhoneMaskAndNameValidation\",\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"@framerIntrinsicWidth 100\",\"framerIntrinsicHeight\":\"100\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Validations.map"],"mappings":"2JAIE,SAAgB,EAA+B,EAAU,CAAC,MAAO,KAAQ,MAAc,CAAC,IAAM,EAAe,GAAO,CAAC,IAAM,EAAO,sBAC/H,EAAE,EAAQ,EAAI,EAAO,QAAQ,MAAM,IAAQ,EAAa,EAAM,OAAO,MAAM,QAAQ,MAAM,IAAO,EAAI,QAAQ,EAAa,SAAQ,EAAa,GAAK,IAAM,EAAS,EAAO,QAAQ,KAAK,GAAU,QAAQ,KAAK,IAAI,EAAE,EAAa,OAAO,EAAa,OAAO,KAAK,GAAG,EAAa,OAAO,GAAG,GAAK,EAAM,OAAO,MAAM,CAAU,EAAO,EAAW,GAAO,CAAC,IAAM,EAAa,EAAM,OAAO,MAC3X,GAAG,EAAa,QAAQ,EAAE,CAAC,EAAM,OAAO,MAAM,GAAG,IAAM,EAAY,IAAI,MAAM,UAAU,EAAM,OAAO,cAAc,EAAc,CAAC,EAAO,EAAkB,GAAO,CAAC,IAAM,EAAM,6BACzK,EAAM,KAAK,EAAM,OAAO,SAAQ,EAAM,OAAO,MAAM,EAAM,OAAO,MAAM,QAAQ,4BAA4B,IAAM,EAAO,EAAY,SAAS,iBAAiB,qBAA2B,EAAW,SAAS,iBAAiB,sBAClO,OADwP,EAAY,QAAQ,GAAY,CAAC,EAAW,iBAAiB,QAAQ,GAAgB,EAAW,iBAAiB,OAAO,EAAa,GAAE,EAAW,QAAQ,GAAW,CAAC,EAAU,iBAAiB,QAAQ,EAAoB,OAC3c,CAAC,EAAY,QAAQ,GAAY,CAAC,EAAW,oBAAoB,QAAQ,GAAgB,EAAW,oBAAoB,OAAO,EAAa,GAAE,EAAW,QAAQ,GAAW,CAAC,EAAU,oBAAoB,QAAQ,EAAoB,EAAG,CAAE,EAAC,EAAE,EAAsB,EAAK,EAAU,CAAC,GAAG,EAAM,EAAK"}