{"version":3,"file":"UserCountry.CfIPMDfp.mjs","names":["countryCode","regionCode","React"],"sources":["https:/framerusercontent.com/modules/RJVJY14VcgSEAfLSVFav/1CUkp3bLzcgGYlfFyv3t/UserCountry.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import React,{forwardRef}from\"react\";const BLOCKED_COUNTRIES=new Set([\"RO\",\"SE\",\"GR\",\"GB\",\"US\"]);const BLOCKED_REGIONS=new Set([\"ON\"]);let countryCode=\"\";let regionCode=\"\";const getDocumentClassStartsFrom=str=>Array.from(document.documentElement.classList||[]).find((className=\"\")=>className.startsWith(str));const removePrefix=(prefix,fromStr=\"\")=>{return(fromStr||\"\").replace(prefix,\"\");};// Логика определения страны\nasync function detectCountryIso2(){const endpoints=[// { url: \"https://ifconfig.co/json\", key: \"country\" },\n{url:\"https://ipwho.is/\",country:\"country_code\",region:\"region_code\"},{url:\"http://ip-api.com/json/\",country:\"countryCode\",region:\"region\"},{url:\"https://ipinfo.io/json\",country:\"country\",region:\"region\"}];for(const{url,country,region}of endpoints){try{const controller=new AbortController;const timeoutId=setTimeout(()=>controller.abort(),5e3);const res=await fetch(url,{headers:{Accept:\"application/json\"},signal:controller.signal});clearTimeout(timeoutId);if(!res.ok){console.warn(`Failed to fetch from ${url}: ${res.status} ${res.statusText}`);continue;}const data=await res.json();const countryCode=data[country];const regionCode=data[region];if(typeof countryCode===\"string\"&&countryCode.length===2){// console.log(\n//     `countryCode detected from ${url}: ${countryCode.toUpperCase()}, regionCode:${regionCode.toUpperCase()}`\n// )\nreturn{countryCode:countryCode.toUpperCase(),regionCode:regionCode.toUpperCase()};}}catch(error){console.warn(`Error fetching from ${url}:`,error);}}console.warn(\"All country detection services failed\");return{};}/**\n * Основной оверрайд для применения к корневому элементу сайта\n */export function withCountryRestriction(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const country=getDocumentClassStartsFrom(\"country-\");const[state,setState]=React.useState({isLoading:!country});React.useEffect(()=>{let isMounted=true;if(!!country){setState({isLoading:false});return;}async function initializeCountryDetection(){// console.log(\n//     \"withCountryRestriction initializeCountryDetection 1\"\n// )\ntry{const{countryCode:detectedCountry,regionCode:detectedRegion}=await detectCountryIso2()||{};countryCode=detectedCountry;regionCode=detectedRegion;if(!isMounted)return;if(detectedCountry){document.documentElement.classList.add(`country-${countryCode}`);}if(detectedRegion){document.documentElement.classList.add(`region-${regionCode}`);}// console.log(\n//     \"withCountryRestriction initializeCountryDetection 2\",\n//     { detectedCountry, detectedRegion }\n// )\nsetState({isLoading:false});}catch(error){console.warn(\"Country detection failed:\",error);if(!isMounted)return;setState({isLoading:false});}}initializeCountryDetection();return()=>{isMounted=false;};},[]);// Рендерим оригинальный компонент\nreturn /*#__PURE__*/_jsx(Component,{ref:ref,...props,isLoading:state.isLoading});});}export function useCountryRestriction(customRestrictedCountries){const[ready,setReady]=React.useState(false);const[restricted,setRestricted]=React.useState(false);React.useEffect(()=>{const checkRestriction=when=>{const countryClass=getDocumentClassStartsFrom(\"country-\")||\"\";const regionClass=getDocumentClassStartsFrom(\"region-\")||\"\";// console.log({ when, countryCode })\nif(countryCode){const countryCode=removePrefix(/^country-/,countryClass||\"\");const regionCode=removePrefix(/^region-/,regionClass||\"\");setRestricted(BLOCKED_COUNTRIES.has(countryCode)||BLOCKED_REGIONS.has(regionCode));setReady(true);// console.log(1, {\n//     restricted:\n//         BLOCKED_COUNTRIES.has(countryCode) ||\n//         BLOCKED_REGIONS.has(regionCode),\n//     ready: true,\n// })\n}else{setRestricted(true);setReady(true);// console.log(2, { restricted: true, ready: true })\n}};// Проверяем при первой загрузке\ncheckRestriction(1);// Создаем MutationObserver для отслеживания изменений классов в document\nconst observer=new MutationObserver(mutations=>{mutations.forEach(mutation=>{if(mutation.type===\"attributes\"&&mutation.attributeName===\"class\"){checkRestriction(2);}});});// Наблюдаем за изменениями атрибута class у document.documentElement и document.body\nif(document.documentElement){observer.observe(document.documentElement,{attributes:true,attributeFilter:[\"class\"]});}if(document.body){observer.observe(document.body,{attributes:true,attributeFilter:[\"class\"]});}// Очищаем observer при размонтировании компонента\nreturn()=>{observer.disconnect();};},[]);return{ready,restricted};}export function RestrictedBlock(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const{ready,restricted}=useCountryRestriction();// console.log(\"RestrictedBlock BONUSES\", { ready, restricted })\nif(!ready||restricted){return null;}return /*#__PURE__*/_jsx(Component,{...props,ref:ref});});}export function withPreloaderHidding(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const{ready}=useCountryRestriction();if(ready){return null;}// console.log(\"withPreloaderHidding\", { ready })\nreturn /*#__PURE__*/_jsx(Component,{...props,ref:ref});});}export function withEventsDisabledBlock(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const{ready,restricted}=useCountryRestriction();const shouldDisable=!ready||restricted;const stopEvent=e=>{if(shouldDisable){e.preventDefault();e.stopPropagation();e.stopImmediatePropagation();}};if(shouldDisable){return /*#__PURE__*/_jsx(\"div\",{style:{display:\"contents\",pointerEvents:\"none\"},onClick:stopEvent,onMouseDown:stopEvent,onMouseUp:stopEvent,onTouchStart:stopEvent,onTouchEnd:stopEvent,onPointerDown:stopEvent,onPointerUp:stopEvent,children:/*#__PURE__*/_jsx(Component,{...props,ref:ref})});}return /*#__PURE__*/_jsx(Component,{...props,ref:ref});});}export function RestrictedBonusBlock(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[isAllowed,setIsAllowed]=React.useState(true);React.useEffect(()=>{if(ref?.current instanceof HTMLElement){// Находим первый элемент с data-framer-name=\"Localization\"\nconst localizationElement=ref?.current.querySelector('[data-framer-name=\"Location\"]');if(localizationElement){// Получаем текст из дочернего элемента\nconst textContent=localizationElement.textContent||\"\";// Парсим строку как массив, разделяя через запятую\nconst parsedArray=textContent.split(\",\").map(item=>item.trim()).filter(item=>item.length>0);// console.log(\"RestrictedBonusBlock\", { parsedArray })\nif(parsedArray.length===0){// console.log(1)\nsetIsAllowed(true);}else{const countryClass=getDocumentClassStartsFrom(\"country-\")||\"\";const regionClass=getDocumentClassStartsFrom(\"region-\")||\"\";if(countryCode){const countryCode=removePrefix(/^country-/,countryClass||\"\");const regionCode=removePrefix(/^region-/,regionClass||\"\");}// console.log(2, {\n//     parsedArray,\n//     countryCode,\n//     countryClass,\n//     r:\n//         parsedArray.includes(countryCode) ||\n//         parsedArray.includes(regionCode),\n// })\nsetIsAllowed(parsedArray.includes(countryCode)||parsedArray.includes(regionCode));}}}},[ref]);// console.log({ isAllowed })\nif(!isAllowed){return null;}return /*#__PURE__*/_jsx(Component,{...props,ref:ref});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withCountryRestriction\":{\"type\":\"reactHoc\",\"name\":\"withCountryRestriction\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withEventsDisabledBlock\":{\"type\":\"reactHoc\",\"name\":\"withEventsDisabledBlock\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withPreloaderHidding\":{\"type\":\"reactHoc\",\"name\":\"withPreloaderHidding\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useCountryRestriction\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"RestrictedBonusBlock\":{\"type\":\"reactHoc\",\"name\":\"RestrictedBonusBlock\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"RestrictedBlock\":{\"type\":\"reactHoc\",\"name\":\"RestrictedBlock\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./UserCountry.map"],"mappings":"yHACA,eAAe,GAAmB,CAC4K,IAAI,GAAK,CAAC,MAAI,UAAQ,WADjL,CACnD,CAAC,IAAI,oBAAoB,QAAQ,eAAe,OAAO,cAAc,CAAC,CAAC,IAAI,0BAA0B,QAAQ,cAAc,OAAO,SAAS,CAAC,CAAC,IAAI,yBAAyB,QAAQ,UAAU,OAAO,SAAS,CAAC,CAA4C,GAAG,CAAC,IAAM,EAAW,IAAI,gBAAsB,EAAU,eAAe,EAAW,OAAO,CA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