// source --> https://bauerbv.de/wp-content/plugins/termageddon-usercentrics/public/js/termageddon-usercentrics-ajax.min.js?ver=1.10.0 
const tuCookieHideName="tu-geoip-hide",tuCookieLocationName="tu-geoip-location",tuDebug="true"===termageddon_usercentrics_obj.debug,tuPSLHide="true"===termageddon_usercentrics_obj.psl_hide,tuUseGeoApi="true"===termageddon_usercentrics_obj.use_geo_api,tuToggle="div#usercentrics-root,aside#usercentrics-cmp-ui";function shouldHideForGeo(e,o){const t={hide:!0,reason:"Invalid or missing geolocation data",matches:{}};if(!e||!e.country)return t;let n=null,r=null;for(const i of Object.keys(o)){const c=o[i];if(!c){t.matches[i]={located_in:!1,enabled:!1};continue}let s=!1;switch(c.type){case"country_in_list":s=Array.isArray(c.codes)&&-1!==c.codes.indexOf(e.country);break;case"country":s=c.code===e.country;break;case"us_state":s="US"===e.country&&!!e.region_code&&e.region_code===c.region_code;break;default:s=!1}t.matches[i]={located_in:s,enabled:!!c.enabled},s&&(c.enabled||n||(n=i),c.enabled&&!r&&(r=i))}return n?(t.hide=!0,t.reason='Located in "'+n+'" but this region is disabled in settings'):r?(t.hide=!1,t.reason='Located in "'+r+'" which is enabled'):(t.hide=!0,t.reason="Not located in any configured region"),t}tuDebug&&console.log("UC: AJAX script initialized"),window.addEventListener("UC_UI_INITIALIZED",function(){const getCookie=e=>{const o=`; ${document.cookie}`.split(`; ${e}=`);if(2===o.length)return o.pop().split(";").shift()},setCookie=(e,o,t)=>{var n="";if(t){var r=new Date;r.setTime(r.getTime()+24*t*60*60*1e3),n="; expires="+r.toUTCString()}document.cookie=e+"="+(o||"")+n+"; path=/"},showElements=e=>{document.querySelectorAll(e).forEach(e=>e.style.display="")},hideElements=e=>{document.querySelectorAll(e).forEach(e=>e.style.display="none")},updateCookieConsent=e=>{if(!e)return tuDebug&&console.log("UC: Showing consent widget"),tuPSLHide&&showElements("#usercentrics-psl, .usercentrics-psl"),showElements(tuToggle),UC_UI.isConsentRequired()?UC_UI.showFirstLayer():UC_UI.closeCMP();tuDebug&&console.log("UC: Hiding consent widget"),tuPSLHide&&hideElements("#usercentrics-psl, .usercentrics-psl"),hideElements(tuToggle),UC_UI.areAllConsentsAccepted()||UC_UI.acceptAllConsents().then(()=>{tuDebug&&console.log("UC: All consents have been accepted."),UC_UI.closeCMP().then(()=>{tuDebug&&console.log("UC: CMP Widget has been closed.")})})};if("undefined"==typeof UC_UI)return console.error("Usercentrics not loaded");const e=""===(o="enable-usercentrics",new Proxy(new URLSearchParams(window.location.search),{get:(e,o)=>e.get(o)})[o]);var o;const t=getCookie("tu-geoip-hide");if(null!=t&&!tuDebug)return tuDebug&&console.log("UC: Cookie found.",(t?"Showing":"Hiding")+" Usercentrics"),void updateCookieConsent("true"===t);if(tuUseGeoApi){const finishWithGeoData=(o,t)=>{if(t&&setCookie("tu-geoip-location",JSON.stringify(o),365),e)return tuDebug&&console.log("UC: Enabling due to query parameter override.","Showing Usercentrics"),updateCookieConsent(!1);const n=shouldHideForGeo(o,termageddon_usercentrics_obj.geo_locations||{});tuDebug&&console.log("UC: Decision computed",{hide:n.hide,reason:n.reason,geo:o,matches:n.matches}),setCookie("tu-geoip-hide",n.hide?"true":"false"),updateCookieConsent(n.hide)},o=termageddon_usercentrics_obj.geo_debug_override;if(o&&"object"==typeof o)return tuDebug&&console.log("UC: Using geo debug override",o),finishWithGeoData(o,!1);const t=getCookie("tu-geoip-location");if(t&&!tuDebug)try{const e=JSON.parse(decodeURIComponent(t));if(e&&"object"==typeof e&&e.country)return tuDebug&&console.log("UC: Using cached geo cookie",e),finishWithGeoData(e,!1)}catch(e){tuDebug&&console.log("UC: Failed to parse geo cookie, refetching",e)}return tuDebug&&console.log("UC: Fetching geolocation from hosted API"),void fetch(termageddon_usercentrics_obj.geo_api_url,{method:"GET",headers:{"X-Tm-Key":termageddon_usercentrics_obj.geo_api_key}}).then(e=>{if(!e.ok)throw new Error("HTTP "+e.status);return e.json()}).then(e=>{if(!e||"object"!=typeof e||!e.country)throw new Error("Invalid geo response");const o={country:e.country,region_code:e.region_code||null,city:e.city||null};finishWithGeoData(o,!0)}).catch(e=>{console.error("Usercentrics: Geolocation lookup failed. Showing widget as a default.",e),updateCookieConsent(!1)})}tuDebug&&console.log("UC: Making AJAX Call");var n=new FormData;n.append("action","uc_geolocation_lookup"),n.append("nonce",termageddon_usercentrics_obj.nonce),void 0!==termageddon_usercentrics_obj.location&&n.append("location",termageddon_usercentrics_obj.location),fetch(termageddon_usercentrics_obj.ajax_url,{method:"POST",credentials:"same-origin",body:n}).then(function(e){if(!e.ok)throw new Error("HTTP "+e.status);return e.json()}).then(function(o){if(!o.success)return console.error("Unable to lookup location.",o.message||"");if(!o.data)return console.error("Location data was not provided.",o.data);const t=o.data;if(tuDebug&&console.log("TERMAGEDDON USERCENTRICS (AJAX)\nIP Address: "+t.ipAddress+"\nCity: "+(t.city||"Unknown")+"\nState: "+(t.state||"Unknown")+"\nCountry: "+(t.country||"Unknown")+"\nLocations: ",t.locations),e)return tuDebug&&console.log("UC: Enabling due to query parameter override.","Showing Usercentrics"),updateCookieConsent(!1);setCookie("tu-geoip-hide",t.hide?"true":"false"),updateCookieConsent(t.hide)}).catch(function(e){console.error("Usercentrics: Invalid response returned. Showing widget as a default.",e),updateCookieConsent(!1)})});