{"version":3,"file":"search.70a88a5347de355a78e2.chunk.js","mappings":"iNAAA,MAAMA,SAAW,CACbC,MAAO,uBACPC,MAAO,8BACPC,OAAQ,gCAGZ,MAAMC,UACFC,YAAYC,SACRC,KAAKD,QAAUE,OAAOC,OAAO,CAAC,EAAGT,SAAUM,SAE3C,MAAML,MAAQS,SAASC,cAAcJ,KAAKD,QAAQL,OAC5CC,MAAQQ,SAASC,cAAcJ,KAAKD,QAAQJ,OAC5CC,OAASO,SAASC,cAAcJ,KAAKD,QAAQH,QAE/CF,OACAA,MAAMW,iBAAiB,WAAWC,QAC9BN,KAAKO,YAAYD,MAAM,IAI3BX,OACAA,MAAMU,iBAAiB,SAAS,KAC5BL,KAAKL,OAAO,IAIhBC,QACAA,OAAOS,iBAAiB,SAAS,KAC7BL,KAAKJ,QAAQ,GAGzB,CAEAW,YAAYD,OACc,KAAlBA,MAAME,SAIVR,KAAKJ,QACT,CAEAD,QACI,MAAMD,MAAQS,SAASC,cAAcJ,KAAKD,QAAQL,OAE7CA,QAKLA,MAAMe,MAAQ,GAClB,CAEAb,SACI,MAAMc,aAAeP,SAASC,cAAcJ,KAAKD,QAAQH,QAEzD,IAAKc,aAED,OAGJ,IAAIC,UAAY,UACZC,kBAAoB,GACxB,MAAM,kBAAmB,kBAAuBF,aAAaG,QAEzDC,oBACAH,UAAYG,mBAGhB,MAAMpB,MAAQS,SAASC,cAAcJ,KAAKD,QAAQL,OAE9CA,OAASA,MAAMe,QACfG,kBAAqB,UAASlB,MAAMe,SAGpCM,mBACAH,mBAAsB,GAAEA,kBAAoB,IAAM,YAAYG,oBAGlEC,OAAOC,SAASC,KAAOP,UAAYC,iBACvC,EAKF,aAEa,CAAEO,KAJHpB,UACV,IAAIF,UAAUE,QAAQ,GAGH,wB","sources":["webpack://seges/./Seges.Website/scripts/core/components/search/index.js"],"sourcesContent":["const defaults = {\r\n input: '.js-search-box-input',\r\n reset: '.js-search-box-reset-button',\r\n submit: '.js-search-box-submit-button'\r\n};\r\n\r\nclass SearchBox {\r\n constructor(options) {\r\n this.options = Object.assign({}, defaults, options);\r\n\r\n const input = document.querySelector(this.options.input);\r\n const reset = document.querySelector(this.options.reset);\r\n const submit = document.querySelector(this.options.submit);\r\n\r\n if (input) {\r\n input.addEventListener('keydown', event => {\r\n this.handleInput(event);\r\n });\r\n }\r\n\r\n if (reset) {\r\n reset.addEventListener('click', () => {\r\n this.reset();\r\n });\r\n }\r\n\r\n if (submit) {\r\n submit.addEventListener('click', () => {\r\n this.submit();\r\n });\r\n }\r\n }\r\n\r\n handleInput(event) {\r\n if (event.keyCode !== 13) {\r\n return;\r\n }\r\n\r\n this.submit();\r\n }\r\n\r\n reset() {\r\n const input = document.querySelector(this.options.input);\r\n\r\n if (!input) {\r\n console.error('Can\\'t find search-box input element.');\r\n return;\r\n }\r\n\r\n input.value = '';\r\n }\r\n\r\n submit() {\r\n const submitButton = document.querySelector(this.options.submit);\r\n\r\n if (!submitButton) {\r\n console.error('Can\\'t find search-box submit button element.');\r\n return;\r\n }\r\n\r\n let searchUrl = '/search';\r\n let queryParamsString = '';\r\n const { searchRedirectUrl, searchCategoryId } = submitButton.dataset;\r\n\r\n if (searchRedirectUrl) {\r\n searchUrl = searchRedirectUrl;\r\n }\r\n\r\n const input = document.querySelector(this.options.input);\r\n\r\n if (input && input.value) {\r\n queryParamsString = `?query=${input.value}`;\r\n }\r\n\r\n if (searchCategoryId) {\r\n queryParamsString += `${queryParamsString ? '&' : '?'}mains=${searchCategoryId}`;\r\n }\r\n\r\n window.location.href = searchUrl + queryParamsString;\r\n }\r\n}\r\n\r\nconst init = (options) => {\r\n new SearchBox(options);\r\n};\r\n\r\nexport default { init };\r\n"],"names":["defaults","input","reset","submit","SearchBox","constructor","options","this","Object","assign","document","querySelector","addEventListener","event","handleInput","keyCode","value","submitButton","searchUrl","queryParamsString","dataset","searchRedirectUrl","searchCategoryId","window","location","href","init"],"sourceRoot":""}