var carousel=document.querySelector('.carousel');var cells=carousel.querySelectorAll('.carousel__cell');var cellCount=cells.length;var selectedIndex=0;var cellWidth=230;var cellHeight=carousel.offsetHeight;var isHorizontal=true;var rotateFn=isHorizontal?'rotateY':'rotateX';var radius,theta;var rearHeightAdjust=120;var heightIncrement=rearHeightAdjust/(cellCount/2);function rotateCarousel(){var angle=theta*selectedIndex* -1;carousel.style.transform='translateZ('+ -radius+'px) '+rotateFn+'('+angle+'deg)';for(var i=0;i<cells.length;i++){var cell=cells[i];cell.querySelector(".item-text").style.opacity="0";}
for(var i=0;i<cells.length/2;i++){var index=getArrayBoundIndex(selectedIndex+i);var height=heightIncrement*i;var wrapper=cells[index].querySelector(".wrapper");wrapper.style.transform='translateY(-'+height+'px)';if(i>0){index=getArrayBoundIndex(selectedIndex-i);wrapper=cells[index].querySelector(".wrapper");wrapper.style.transform='translateY(-'+height+'px)';}else{index=getArrayBoundIndex(selectedIndex-cells.length/2);wrapper=cells[index].querySelector(".wrapper");wrapper.style.transform='translateY(-'+rearHeightAdjust+'px) rotateY(180deg)';}}
var frontCell=cells[getArrayBoundIndex(selectedIndex)];if(frontCell){var frontCellText=frontCell.querySelector(".item-text");frontCellText.style.opacity="1";}};function getArrayBoundIndex(selectedInt){var index=selectedInt%cellCount;if(selectedInt<0){posSelectedIndex=selectedInt* -1;index=(index+cellCount*posSelectedIndex)%cellCount;}
return index;}
function changeCarousel(){theta=360/cellCount;var cellSize=isHorizontal?cellWidth:cellHeight;radius=Math.round(cellSize/2/Math.tan(Math.PI/cellCount));for(var i=0;i<cells.length;i++){var cell=cells[i];if(i<cellCount){cell.style.opacity=1;var cellAngle=theta*i;cell.style.transform=rotateFn+'('+cellAngle+'deg) translateZ('+radius+'px)';}else{cell.style.opacity=0;cell.style.transform='none';}}
rotateCarousel();}
document.addEventListener("DOMContentLoaded",function(event){var prevButton=document.querySelector('.previous-button');prevButton.addEventListener('click',function(){selectedIndex--;rotateCarousel();});var nextButton=document.querySelector('.next-button');nextButton.addEventListener('click',function(){selectedIndex++;rotateCarousel();});changeCarousel();});;;
var _window$Zeit;function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread();}
function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}
function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}
function _iterableToArray(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter);}
function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr);}
function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}
window.Zeit=(_window$Zeit=window.Zeit)!==null&&_window$Zeit!==void 0?_window$Zeit:{};Zeit.offer=function(){var tokenConfig={countryGroups:[]};var tokenRegEx=/%%(.*?)%%/g;var tokenContentElements=[];var tokenPriceElements=[];function getSelectedOffer(){var offer=null;var selector=document.querySelector('#offer-selector');if(selector){var _selector$querySelect,_selector$querySelect2;var selectedOfferInputId=(_selector$querySelect=(_selector$querySelect2=selector.querySelector('input[name="offer"]:checked'))===null||_selector$querySelect2===void 0?void 0:_selector$querySelect2.value)!==null&&_selector$querySelect!==void 0?_selector$querySelect:"";if(selectedOfferInputId){var offerSection=document.querySelector("#offer-section-"+selectedOfferInputId);var offerData=offerSection.dataset;offer=JSON.parse(offerData.offer);if(offerData.successUrl!==""){offer.successUrl=offerData.successUrl;}
if(offerData.existingCustomerSuccessUrl!==""){offer.existingCustomerSuccessUrl=offerData.existingCustomerSuccessUrl;}
var isStudent=isStudentChecked();var coupleOffer=JSON.parse(offerData.coupleOffer);if(isStudent&&coupleOffer){offer=coupleOffer;}}}
return offer;}
function isStudentChecked(){var form=document.querySelector('#order_form');var studentInput=form["IsStudent"];var isStudent=false;if(studentInput){isStudent=studentInput.checked;}
return isStudent;}
function getSelectedGiftId(){var selector=document.querySelector('#gift-selector');var value=null;if(selector){var _selector$querySelect3,_selector$querySelect4;value=(_selector$querySelect3=(_selector$querySelect4=selector.querySelector('input[name="gift"]:checked:not(:disabled)'))===null||_selector$querySelect4===void 0?void 0:_selector$querySelect4.value)!==null&&_selector$querySelect3!==void 0?_selector$querySelect3:"";}
return value;}
function getSelectedGift(){var id=Zeit.offer.getSelectedGiftId();var gift=null;if(id){var giftSection=document.querySelector("#gift-section-"+id);gift=giftSection.dataset;}
return gift;}
function initialiseTokenisedContent(){var tokenContentAttributeElements=document.querySelectorAll('[tokenise-content-id]');tokenContentAttributeElements.forEach(function(element){tokenContentElements.push({id:element.getAttribute('tokenise-content-id'),originalContent:element.innerHTML});});var tokenPriceAttributeElements=document.querySelectorAll('[tokenise-price-id]');tokenPriceAttributeElements.forEach(function(element){tokenPriceElements.push({id:element.getAttribute('tokenise-price-id'),originalContent:element.innerHTML});});}
function refreshTokenContent(){tokenContentElements.forEach(function(tokenElement){var htmlElement=document.querySelector("[tokenise-content-id="+tokenElement.id+"]");var tokenisedContent=tokeniseHtml(htmlElement,tokenElement.originalContent);htmlElement.innerHTML=tokenisedContent;htmlElement.style.visibility='visible';});tokenPriceElements.forEach(function(tokenElement){var htmlElement=document.querySelector("[tokenise-price-id="+tokenElement.id+"]");var tokenisedPrice=tokeniseHtml(htmlElement,tokenElement.originalContent);var priceHtml="";if(tokenisedPrice){var priceRegex=/(\d+)\D(\d+)\s+(\S+)/i;var matches=tokenisedPrice.match(priceRegex);var part="";switch(matches[1].length){case 1:part="single-digit";break;case 2:part="double-digit";break;default:part="triple-digit";break;}
var bubblePriceContainer=htmlElement.closest('.price-bubble');bubblePriceContainer.className="price-bubble ".concat(part);var majorCurrencyClass=matches[1].length>1?"two-digit":"";var minorCurrency=matches[2]==="00"?"":matches[2];var currencyClass=matches[3].length>2?"triple-char":"";priceHtml="<span class=\"major-currency ".concat(majorCurrencyClass,"\">").concat(matches[1],"</span>\n                            <span class=\"minor-currency\">").concat(minorCurrency,"</span>\n                            <span class=\"currency-symbol ").concat(currencyClass,"\">").concat(matches[3],"</span>");}
htmlElement.innerHTML=priceHtml;htmlElement.style.visibility='visible';});}
function tokeniseHtml(htmlElement,originalContent){var allCountryGroupId=tokenConfig.countryGroups.find(function(g){return g.groupName==="ALL";}).Id;function getReplacementMatch(tokenVariations,selectedCountryCode){var tokenReplacement=tokenVariations.find(function(p){var countryGroup=tokenConfig.countryGroups.find(function(g){return g.id===p.CountryCode;});if(countryGroup){return countryGroup.groupCountryList.some(function(c){return c.startsWith(selectedCountryCode);});}
return false;});if(tokenReplacement===undefined){tokenReplacement=tokenVariations.find(function(p){return p.CountryCode===""||p.CountryCode===null||p.CountryCode===allCountryGroupId;});}
return tokenReplacement!==undefined?tokenReplacement.Value:"";}
function replaceTokenMatches(elementHtml,tokens,countryPrices,kioskPrices,isChild){var matches=_toConsumableArray(elementHtml.matchAll(tokenRegEx));var selectedCountryCode=getCurrentCountry();if(matches.length>0){matches.forEach(function(match){var tokenId=match[1];var replacementVariations=tokens[tokenId];var replacement="";if(replacementVariations!==undefined){replacement=getReplacementMatch(replacementVariations,selectedCountryCode);if(replacement==="PRICE_LOOKUP"){replacement=findOfferPrice(countryPrices,tokenId);}
if(replacement==="KIOSK_LOOKUP"){replacement=findKioskPrice(kioskPrices,tokenId);}
replacement=replaceTokenMatches(replacement,tokens,countryPrices,true);}
if(isChild&&replacement===""){elementHtml=replacement;}else{elementHtml=elementHtml.replace(match[0],replacement);}});}
return elementHtml;}
function findKioskPrice(kioskPrices,token){var _price$Value$toFixed;if(kioskPrices.length==0)return"";var price=kioskPrices[0];var priceValue="";if(!price||price.Value==0)return priceValue;priceValue=(_price$Value$toFixed=price.Value.toFixed(2))!==null&&_price$Value$toFixed!==void 0?_price$Value$toFixed:"";function formatPriceValue(token,_char){priceValue+=" ".concat(_char);}
switch(price.CountryCode){case"DE":priceValue=price.Value.toLocaleString('de-DE',{maximumFractionDigits:2,minimumFractionDigits:2});formatPriceValue(token,"€");break;case"AT":priceValue=price.Value.toLocaleString('de-AT',{maximumFractionDigits:2,minimumFractionDigits:2});formatPriceValue(token,"€");break;case"CH":priceValue=price.Value.toLocaleString('de-CH',{maximumFractionDigits:2,minimumFractionDigits:2});formatPriceValue(token,"CHF");break;}
return priceValue;}
function findOfferPrice(prices,token){var price=prices.find(function(p){return p.Name===token;});var priceValue="";if(!price||price.Value==0)return priceValue;var isPercentage=token.endsWith("Ersparnis proz. zum EV");if(isPercentage){var hasNoDecimals=Number.isInteger(price.Value);var formatNumber=hasNoDecimals?price.Value:price.Value.toFixed(2);priceValue="".concat(formatNumber," %");}else{var _price$Value$toFixed2;var formatPriceValue=function formatPriceValue(token,_char2){priceValue+=" ".concat(_char2);};priceValue=(_price$Value$toFixed2=price.Value.toFixed(2))!==null&&_price$Value$toFixed2!==void 0?_price$Value$toFixed2:"";switch(price.CountryCode){case"DE":priceValue=price.Value.toLocaleString('de-DE',{maximumFractionDigits:2,minimumFractionDigits:2});formatPriceValue(token,"€");break;case"AT":priceValue=price.Value.toLocaleString('de-AT',{maximumFractionDigits:2,minimumFractionDigits:2});formatPriceValue(token,"€");break;case"CH":priceValue=price.Value.toLocaleString('de-CH',{maximumFractionDigits:2,minimumFractionDigits:2});formatPriceValue(token,"CHF");break;}}
return priceValue;}
function getCurrentCountry(){var selectedCountryCode="DE";if(!Zeit.orderForm){var countryInput=document.querySelector('#Addresses_0__country');if(typeof countryInput==='undefined'||countryInput===null)return"DE";selectedCountryCode=countryInput.value?countryInput.value:"DE";}else{selectedCountryCode=Zeit.orderForm.getSelectedCountry();}
return selectedCountryCode;}
function cleanHtml(html){var pTagPattern=/<p[^>]*>[\s|&nbsp;]*<\/p[^>]*>/img;var cleanHtml=html.replace(pTagPattern,"");return cleanHtml;}
var offer=Zeit.offer.getSelectedOffer();if(offer==null&&htmlElement.dataset.offer){offer=JSON.parse(htmlElement.dataset.offer);}
if(offer!=null){var selectedCountryCode=getCurrentCountry();var validCountries=["DE","AT","CH"];if(!validCountries.includes(selectedCountryCode))selectedCountryCode="DE";var tokens=offer.TokenValues;var prices=offer.Prices;var countryPrices=prices.filter(function(p){return p.CountryCode===selectedCountryCode;});var kioskPrices=offer.KioskPrices.filter(function(p){return p.CountryCode===selectedCountryCode;});originalContent=replaceTokenMatches(originalContent,tokens,countryPrices,kioskPrices,false);originalContent=cleanHtml(originalContent);}
return originalContent;}
return{initialiseTokens:initialiseTokenisedContent,constants:{types:{digital:"Digital",print:"Print"}},getSelectedOffer:getSelectedOffer,getSelectedGiftId:getSelectedGiftId,getSelectedGift:getSelectedGift,refreshTokenContent:refreshTokenContent,tokenConfig:tokenConfig};}();;;
