{"version":3,"sources":["webpack:///./assets/javascripts/modules/utils/BrowserHistoryUtils.js","webpack:///./assets/javascripts/modules/utils/SearchUrlUtil.js","webpack:///./assets/javascripts/modules/components/HistoryManagerComponent.js"],"names":["__webpack_require__","d","__webpack_exports__","BrowserHistoryUtils_replacePageInHistory","hasFocusElement","getFocusElement","hasHideNotification","hasShowNotification","replacePageInHistory","url","additionalStateData","title","needPreload","history","window","replaceState","trim","length","query","preloadAttribute","includes","addPreloadParam","document","focusElement","scrollRestoration","state","getHideNotification","notificationOff","getShowNotification","promocodeMessage","HistoryManagerComponent","_classCallCheck","this","_possibleConstructorReturn","__proto__","Object","getPrototypeOf","call","Component","pagersContainer","SELECTORS","$","on","e","currentProduct","productId","data","productPage","href","find","attr","location","origin","pathname","params","search","pageSupportsPagination","paramPage","match","paramPageVal","OldParam","toString","newParam","replace","bindEvents","console","info"],"mappings":"2FAAAA,EAAAC,EAAAC,EAAA,sBAAAC,IAAAH,EAAAC,EAAAC,EAAA,sBAAAE,IAAAJ,EAAAC,EAAAC,EAAA,sBAAAG,IAAAL,EAAAC,EAAAC,EAAA,sBAAAI,IAAAN,EAAAC,EAAAC,EAAA,sBAAAK,IAaO,IAOMC,EAAuB,SAACC,EAAKC,EAAqBC,EAAOC,GACpE,IAAMC,EAAUC,OAAOD,QACnBA,GAAWA,EAAQE,cAAgBN,GAAOA,EAAIO,OAAOC,OAAS,IAC5DL,IACFH,ECPuB,SAACS,GAC5B,IACIC,GAAoBD,EAAME,SAAS,KAAO,IAAM,KADtC,eAEd,OAAOF,EAAME,SAFC,WAEmBF,EAAQA,EAAQC,EDIvCE,CAAgBZ,IAExBI,EAAQE,aAAaL,EAAqBC,GAASG,OAAOQ,SAASX,MAAOF,GACtEC,GAAuBA,EAAoBa,eAC7CV,EAAQW,kBAAoB,YAKrBpB,EAAkB,WAC7B,QAASC,KAGEA,EAAkB,WAC7B,IAAMQ,EAAUC,OAAOD,QACvB,OAAOA,GAAWA,EAAQY,OAASZ,EAAQ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ks.js","sourcesContent":["import {addPreloadParam} from \"../utils/SearchUrlUtil\";\n\n/**\n * window.history.pushState is a native API which adds on browser history a new entry which allows to manually override/enrich the navigation history.\n * This technique is used in SPA to mimic page transition and specify how browser should behave on back/forward operations.\n *\n * After every pushState/replaceState the page url/title will be updated accordingly without reloading the page.\n *\n * @param url which will be used on back/forward/go operation\n * @param title of the page\n * @param additionalStateData additional data that will be applied on history entry\n */\n\nexport const addNewPageInHistory = (url, additionalStateData, title) => {\n const history = window.history;\n if (history && history.pushState && url && url.trim().length > 0) {\n history.pushState(additionalStateData, title || window.document.title, url);\n }\n}\n\nexport const replacePageInHistory = (url, additionalStateData, title, needPreload) => {\n const history = window.history;\n if (history && history.replaceState && url && url.trim().length > 0) {\n if (needPreload) {\n url = addPreloadParam(url);\n }\n history.replaceState(additionalStateData, title || window.document.title, url);\n if (additionalStateData && additionalStateData.focusElement) {\n history.scrollRestoration = 'manual';\n }\n }\n}\n\nexport const hasFocusElement = ()=> {\n return !!getFocusElement();\n}\n\nexport const getFocusElement = ()=> {\n const history = window.history;\n return history && history.state && history.state.focusElement;\n}\n\nexport const hasHideNotification = ()=> {\n return !!getHideNotification();\n}\n\nexport const getHideNotification = ()=> {\n const history = window.history;\n return history && history.state && history.state.notificationOff;\n}\n\nexport const hasShowNotification = ()=> {\n return !!getShowNotification();\n}\n\nexport const getShowNotification = ()=> {\n const history = window.history;\n return history && history.state && history.state.promocodeMessage;\n}\n\n","\nexport const addOrUpdateUrlParam = (name, value) => {\n let href = window.location.href;\n let regex = new RegExp('[&\\\\?]' + name + '=');\n if (regex.test(href)) {\n regex = new RegExp(name + '=' + '(tru|fals)e');\n return href.replace(regex, name + '=' + value);\n } else {\n if (href.indexOf('?') > -1) {\n return href + '&' + name + '=' + value;\n }\n else {\n return href + '?' + name + '=' + value;\n }\n }\n}\n\nexport const addPreloadParam=(query) => {\n let preload = 'preload';\n let preloadAttribute = (query.includes('?') ? '&' : '?') + preload + '=true';\n return query.includes(preload) ? query : query + preloadAttribute;\n}","import Component from '../abstracts/Component';\nimport {replacePageInHistory} from '../utils/BrowserHistoryUtils';\n\nexport default class HistoryManagerComponent extends Component {\n get SELECTORS() {\n return {\n pagersContainer: '.js-item-pagination'\n }\n }\n constructor() {\n super();\n }\n bindEvents() {\n const {pagersContainer} = this.SELECTORS;\n $(document).on('click', '.w-card-product[data-product-id]', function (e) {\n const currentProduct = $(this);\n const productId = currentProduct.data('product-id');\n const productPage = currentProduct.data('product-page');\n const href = $(currentProduct).find('.js-product-card').attr('href');\n if(productId && href) {\n let query = location.origin + location.pathname;\n let params = location.search;\n let pageSupportsPagination = $(pagersContainer).length > 0;\n if(params.length != 0) {\n let paramPage = params.match(/page?=/);\n let paramPageVal = params.match(/page?=\\d+/);\n if(paramPage != null && paramPageVal != null) {\n let OldParam = paramPageVal.toString();\n let newParam = paramPage.toString() + productPage;\n query+= params.replace(OldParam, newParam);\n } else {\n query+= params;\n }\n }\n if(!pageSupportsPagination && !query.match(/[\\?&]preload=/) && query.match(/[\\?&]page=\\d+/)) {\n query+='&preload=true';\n }\n replacePageInHistory(\n query,\n {\n focusElement: '.w-card-product[data-product-id=' + productId + ']'\n },\n '',\n !pageSupportsPagination && query.includes('page=')\n );\n }\n });\n }\n render() {\n this.bindEvents();\n console.info('[HistoryManager] init');\n }\n}\n"],"sourceRoot":""}