1"use strict";(globalThis.webpackChunkaem_maven_archetype||=[]).push([[116],{116(o,e,t){t.r(e),t.d(e,["default",0,{props:{cssSelector:"c-fastbooking__submenu-discount",classNameDiscount:"enable",promocodeSelector:"promocode-JS",deletePromocodeJS:".delete-promocode-JS",formPromoCodeJS:".form-promocode-JS",tabSelector:"discount-JS",checkboxSelector:"discounts-checkbox-JS",attrPromocode:"promocode",attrCampaignPromo:"promo",cookieName:"barcelo_FB_discount",noActiveSelector:"promocode-noactive-JS",activeSelector:"promocode-active-JS",isDiscountInput:!1},init:function(){if(bcl.c.fastbooking.disabled)return void delete bcl.c.fastbooking.discount;let o=bcl.c.fastbooking.commonProps.fastbooking.$container.getElementsByClassName(this.props.cssSelector);o?.[0]&&(this.props.$container=o[0],this.initNodes(),this.initPromocode(),this.initCheckbox(),this.getInitCookies(),this.parseQueryParams())},initNodes:function(){let o=bcl.c.fastbooking.commonProps.fastbooking.$container.getElementsByClassName(this.props.tabSelector);o?.[0]&&(this.props.$tab=o[0])},initPromocode:function(){let o=this.props.$container.getElementsByClassName(this.props.promocodeSelector);if(!o?.[0])return;let e=o[0].children[0];this.props.$inputPromocode=e,e.addEventListener("keypress",function(o){13==o.keyCode&&(o.preventDefault(),o.stopPropagation())}),o[0].children[2]?o[0].children[2].addEventListener("click",()=>{this.addOrRemovePromocode(e.value),bcl.s.tabs.closeActive()}):(e.setAttribute("value",""),e.value="",this.addOrRemovePromocode(""))},hiddeShowActiveElements:function(o){bcl.u[o](bcl.c.fastbooking.commonProps.fastbooking.$container.getElementsByClassName(this.props.activeSelector)),bcl.u[o](bcl.c.fastbooking.commonProps.fastbooking.$container.querySelectorAll(this.props.formPromoCodeJS)),bcl.u["showElements"===o?"hiddeElements":"showElements"](bcl.c.fastbooking.commonProps.fastbooking.$container.getElementsByClassName(this.props.noActiveSelector))},addOrRemovePromocode:function(o){let e=this.props.attrPromocode;o?(bcl.u.hiddeElements(bcl.c.fastbooking.commonProps.fastbooking.$container.getElementsByClassName(this.props.noActiveSelector)),bcl.u.showElements(bcl.c.fastbooking.commonProps.fastbooking.$container.getElementsByClassName(this.props.activeSelector)),bcl.u.hiddeElements(bcl.c.fastbooking.commonProps.fastbooking.$container.querySelectorAll(this.props.formPromoCodeJS)),this.add(o,e,o)):(bcl.u.showElements(bcl.c.fastbooking.commonProps.fastbooking.$container.getElementsByClassName(this.props.noActiveSelector)),bcl.u.hiddeElements(bcl.c.fastbooking.commonProps.fastbooking.$container.getElementsByClassName(this.props.activeSelector)),bcl.u.hiddeElements(bcl.c.fastbooking.commonProps.fastbooking.$container.querySelectorAll(this.props.formPromoCodeJS)),this.remove(e))},initCheckbox:function(){let o=bcl.c.fastbooking.commonProps.fastbooking.$container.getElementsByClassName(this.props.checkboxSelector);if(!o?.[0])return;this.props.$containerCheckbox=o[0];let e=this.props.$containerCheckbox.querySelectorAll("input");bcl.u.forEach(e,(o,e)=>{o.addEventListener("keydown",function(o){"Enter"===o.key&&(o.preventDefault(),this.click())}),o.addEventListener("change",()=>{this.props.isDiscountInput=!0,this.addOrRemoveCheckbox(o,e)})})},cleanCheckbox:function(){let o=this.props.$containerCheckbox.querySelectorAll("input");bcl.u.forEach(o,(o,e)=>{o.checked=!1,this.props.isDiscountInput=!0,this.addOrRemoveCheckbox(o,e)})},addOrRemoveCheckbox:function(o,e){let t=o.checked,s=o.dataset.value,n=o.parentNode.children[1];if(this.props.$containerCheckbox){let o=this.props.$containerCheckbox.querySelectorAll("input");t&&this.selectOnlyOneOption(s,o)}t?(this.add(s,e,n.innerText),this.addCookies()):this.remove(e)},selectOnlyOneOption:function(o,e){for(let t=0;t<e.length;t++)e[t].dataset.value!==o&&(e[t].checked=!1,delete bcl.c.fastbooking.commonProps.discount.data[t])},add:function(o,e,t,s){bcl.c.fastbooking.commonProps.discount.data[e]={value:o,label:t,selector:s},this.update()},remove:function(o){delete bcl.c.fastbooking.commonProps.discount.data[o],this.update()},update:function(){if(!this.props.$tab)return;let o=Object.keys(bcl.c.fastbooking.commonProps.discount.data);bcl.u.containsClass(document.body,"homepage")&&!this.props.isDiscountInput&&(o=bcl.c.fastbooking.deleteAllOtherValueInArray(o,"promocode")),this.props.isDiscountInput=!1;let e=o.length,t=this.props.$tab.children[1];if(this.hiddeShowActiveElements("hiddeElements"),e>0){bcl.u.addClass(this.props.$tab,this.props.classNameDiscount),bcl.u.removeClass(t,bcl.c.fastbooking.commonProps.fastbooking.hiddenClass),this.hiddeShowActiveElements("showElements"),1==e?t.innerText=bcl.c.fastbooking.commonProps.fastbooking.$container.dataset.i18nOnediscount:2==e?t.innerText=bcl.c.fastbooking.commonProps.fastbooking.$container.dataset.i18nTwodiscount:3==e?t.innerText=bcl.c.fastbooking.commonProps.fastbooking.$container.dataset.i18nThreediscount:t.innerText=bcl.c.fastbooking.commonProps.fastbooking.$container.dataset.i18nMorediscount;return}bcl.u.removeClass(this.props.$tab,this.props.classNameDiscount),bcl.u.addClass(t,bcl.c.fastbooking.commonProps.fastbooking.hiddenClass)},addPromocode:function(o,e){this.props.$inputPromocode.value=o,this.addOrRemovePromocode(o),this.addCookiesOnlyPromocode(),e&&bcl.c.fastbooking.afterSetData()}
1,getMappedCoupon:function(o){if(!o)return null;let e=Object.freeze({RESIDENT:"CRESIDENT",SENIOR:"SENIORB",MILLENNIAL:"AMILLENNIAL",ARMY:"ARMYB",FAMILY:"FAMILYB"});if(Array.isArray(o))return o.map(o=>this.getMappedCoupon(o));let t=o.toUpperCase(),s=Object.keys(e).find(o=>t.startsWith(o));return s?e[s]+o.substring(s.length):o},generateData:function(o){if(bcl.c.fastbooking.commonProps.discount.data)for(let e in bcl.c.fastbooking.commonProps.discount.data.promocode&&bcl.c.fastbooking.addCoupon(o.coupon,bcl.c.fastbooking.commonProps.discount.data.promocode.value),bcl.c.fastbooking.commonProps.discount.data.promo&&bcl.c.fastbooking.addCoupon(o.promo,bcl.c.fastbooking.commonProps.discount.data.promo.value),bcl.c.fastbooking.commonProps.discount.data)e!==this.props.attrPromocode&&e!==this.props.attrCampaignPromo&&bcl.c.fastbooking.addCoupon(o.coupon,bcl.c.fastbooking.commonProps.discount.data[e].value)},updateData:function(o){this.props.$inputPromocode&&(this.props.$inputPromocode.value=o.promocode?.value||"",this.addOrRemovePromocode(this.props.$inputPromocode.value));let e=this.props.$container.querySelectorAll('[type="checkbox"]');bcl.u.forEach(e,(e,t)=>{let s=o[t]?.value;e.checked=this.foundDiscountsInHotel(s,e),this.addOrRemoveCheckbox(e,t)})},foundDiscountsInHotel:function(o,e){let t=document.querySelector(".hotel-button-JS"),s=!1;return(t?.dataset.specialdiscount?.includes(o)||!t&&o===e.dataset.value)&&(s=!0),s},getInitCookies:function(){let o=bcl.cookie.get(this.props.cookieName);!o||(o=JSON.parse(o))&&this.updateData(o)},addCookies:function(){let o=bcl.c.fastbooking.commonProps.discount.data;bcl.c.fastbooking.calendar.removeCookie(this.props.cookieName),0!=Object.keys(o).length&&bcl.c.fastbooking.setCookies(this.props.cookieName,JSON.stringify(o))},addCookiesOnlyPromocode:function(){let o=bcl.cookie.get(this.props.cookieName);(o=o?JSON.parse(o):{}).promocode=bcl.c.fastbooking.commonProps.discount.data.promocode,bcl.c.fastbooking.setCookies(this.props.cookieName,JSON.stringify(o))},parseQueryParams:function(){let o=window.location.search;if(o)for(let e of o=(o=decodeURIComponent(o)).substring(1,o.length).split("&")){let o=e.split("="),t=o[0],s=o[1];if(("coupon"==t||"codes"==t)&&s){this.addPromocode(s);break}}},updateDataDest:function(o){let e=null;if(o&&"group"!=o.type&&o.data){if(e={},!o.data.specialDiscounts)return void bcl.u.addClass(this.props.$containerCheckbox,"hidden");for(let t in o.data.specialDiscounts)Object.prototype.hasOwnProperty.call(o.data.specialDiscounts,t)&&(e[t]=!0)}else if("false"===this.props.$containerCheckbox.dataset.activechecks)return void bcl.u.addClass(this.props.$containerCheckbox,"hidden");let t=this.props.$containerCheckbox.querySelectorAll("input");bcl.u.forEach(t,o=>{this.updateCheckboxDiscount(o,e)}),bcl.u.removeClass(this.props.$containerCheckbox,"hidden")},updateCheckboxDiscount:function(o,e){let t="addClass";(e?.[o.dataset.value]||!e&&"true"===o.dataset.default)&&(t="removeClass"),bcl.u[t](o.parentNode,"hidden")},openTab:function(o){let e=o||this.props.$container;e&&(this.initDiscountFocusTrap(e),setTimeout(()=>{let o=e.querySelector(".close-JS:not([aria-hidden='true'])")||e.querySelector("input:not([type='hidden']):not([disabled]), button, [role='button'], [tabindex]:not([tabindex='-1'])");o&&"function"==typeof o.focus&&(o.classList&&(o.classList.add("js-kbd-focus"),o.addEventListener("blur",()=>o.classList.remove("js-kbd-focus"),{once:!0})),o.focus())},50))},closeTab:function(o){let e=o||this.props.$container;this.removeDiscountFocusTrap(e);let t=this.props.$tab;t&&t.classList&&(t.classList.add("js-kbd-focus"),t.addEventListener("blur",()=>t.classList.remove("js-kbd-focus"),{once:!0}))},initDiscountFocusTrap:function(o){if(!o||this.props.discountFocusTrapHandler)return;let e=e=>{let t;if("Tab"!==e.key)return;let s=bcl.ariaUtils?.getFocusableElements?.(o)||[];if(0===s.length)return;e.preventDefault();let n=s.indexOf(document.activeElement);t=e.shiftKey?n<=0?s.length-1:n-1:-1===n||n===s.length-1?0:n+1;let c=s[t];c&&"function"==typeof c.focus&&(c.classList&&(c.classList.add("js-kbd-focus"),c.addEventListener("blur",()=>c.classList.remove("js-kbd-focus"),{once:!0})),c.focus())};this.props.discountFocusTrapHandler=e,o.addEventListener("keydown",e)},removeDiscountFocusTrap:function(o){this.props.discountFocusTrapHandler&&o&&(o.removeEventListener("keydown",this.props.discountFocusTrapHandler),this.props.discountFocusTrapHandler=null)}}])}}]); 2//# sourceMappingURL=/etc.clientlibs/barcelo/clientlibs/clientlib-components/resources/116.8f32b7bc.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.