{"version":3,"sources":["webpack:///./src/components/pmicom/widgets/ir-search/controller.js"],"names":["fillWithDomElements","twoCiphers","awaitNextFrame","trackGtm4","require","CLASS_ACTIVE","CLASS_SEARCH","CLASS_FROM","CLASS_CALENDAR_FROM","CLASS_TO","CLASS_CALENDAR_TO","CLASS_CLEAR_ALL","CLASS_SUBMIT","elementClasses","search","fromField","calendarFrom","toField","calendarTo","clearAll","submit","module","exports","init","template","root","dataset","initCalendars","initEvents","addEventListener","clearAllFields","bind","onUpdate","forEach","element","gtmTracking","event","search_term","value","length","search_location","search_filter","fromLabel","toLabel","widget_name","fields","isBlank","some","el","hasChanged","__initialValue","classList","toggle","default","Pikaday","fromPicker","getCalendarOptions","toPicker","retainParameters","field","container","months","weekdays","previousMonth","nextMonth","map","list","split","disableWeekends","minDate","Date","undefined","maxDate","toString","date","getMonth","getDate","getFullYear","number","join","i18n","weekdaysShort","onOpen","setTimeout","add","onSelect","defineFromAndToRules","onClose","remove","setMinDate","setMaxDate","setDate","queryString","decodeURIComponent","window","location","params","paramObj","param","key","val","assignParam","source","isField"],"mappings":";;;;;;;;;AAAA,MAAM;EACLA,mBADK;EAELC,UAFK;EAGLC,cAHK;EAILC;AAJK,IAKFC,mBAAO,CAAC,gDAAD,CALX;;AAOA,MAAMC,YAAY,GAAG,QAArB;AAEA,MAAMC,YAAY,GAAG,yBAArB;AACA,MAAMC,UAAU,GAAG,uBAAnB;AACA,MAAMC,mBAAmB,GAAG,0BAA5B;AACA,MAAMC,QAAQ,GAAG,qBAAjB;AACA,MAAMC,iBAAiB,GAAG,wBAA1B;AACA,MAAMC,eAAe,GAAG,sBAAxB;AACA,MAAMC,YAAY,GAAG,mBAArB;AAEA,MAAMC,cAAc,GAAG;EACtBC,MAAM,EAAER,YADc;EAEtBS,SAAS,EAAER,UAFW;EAGtBS,YAAY,EAAER,mBAHQ;EAItBS,OAAO,EAAER,QAJa;EAKtBS,UAAU,EAAER,iBALU;EAMtBS,QAAQ,EAAER,eANY;EAOtB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;MACA8C,WAAW,CAAC,KAAKpF,OAAN,EAAe,KAAKwC,QAApB,EAA8B,IAA9B,CAAX;IACA;;IACD,KAAKzB,QAAL;EACA;;AA9He,CAAjB,C","file":"components--ir-search299af21d05a0f2fe6759.js","sourcesContent":["const {\n\tfillWithDomElements,\n\ttwoCiphers,\n\tawaitNextFrame,\n\ttrackGtm4,\n} = require('util/functions.js');\n\nconst CLASS_ACTIVE = 'active';\n\nconst CLASS_SEARCH = 'ir-search--input-search';\nconst CLASS_FROM = 'ir-search--input-from';\nconst CLASS_CALENDAR_FROM = 'ir-search--calendar-from';\nconst CLASS_TO = 'ir-search--input-to';\nconst CLASS_CALENDAR_TO = 'ir-search--calendar-to';\nconst CLASS_CLEAR_ALL = 'ir-search--clear-all';\nconst CLASS_SUBMIT = 'ir-search--submit';\n\nconst elementClasses = {\n\tsearch: CLASS_SEARCH,\n\tfromField: CLASS_FROM,\n\tcalendarFrom: CLASS_CALENDAR_FROM,\n\ttoField: CLASS_TO,\n\tcalendarTo: CLASS_CALENDAR_TO,\n\tclearAll: CLASS_CLEAR_ALL,\n\tsubmit: CLASS_SUBMIT,\n};\n\nmodule.exports = {\n\tinit() {\n\t\tfillWithDomElements(this, elementClasses);\n\t\tthis.template = this.root.dataset.template;\n\t\tthis.initCalendars();\n\t\tthis.initEvents();\n\t},\n\tinitEvents() {\n\t\tthis.clearAll.addEventListener('click', this.clearAllFields.bind(this));\n\t\tconst onUpdate = this.onUpdate.bind(this);\n\t\t[this.search, this.fromField, this.toField].forEach(element => {\n\t\t\telement.addEventListener('keyup', onUpdate);\n\t\t});\n\t\tthis.submit.addEventListener('click', this.gtmTracking.bind(this));\n\t},\n\tgtmTracking() {\n\t\ttrackGtm4({\n\t\t\tevent: 'GA4_event_c_search',\n\t\t\tsearch_term: this.search.value.length > 0 ? this.search.value : 'none',\n\t\t\tsearch_location: 'page',\n\t\t\tsearch_filter: `${this.fromField.value || this.root.dataset.fromLabel}|${\n\t\t\t\tthis.toField.value || this.root.dataset.toLabel\n\t\t\t}`,\n\t\t\twidget_name: 'V3-IR-search',\n\t\t});\n\t},\n\tasync onUpdate() {\n\t\t// necessary or else the value of the elements won't be updated\n\t\t// and isBlank check wont be accurate\n\t\tawait awaitNextFrame();\n\n\t\tconst fields = [this.search, this.fromField, this.toField];\n\t\tconst isBlank = !fields.some(el => el.value);\n\t\tconst hasChanged = fields.some(\n\t\t\tel => el.value !== (el.__initialValue || ''),\n\t\t);\n\t\tthis.submit.classList.toggle(CLASS_ACTIVE, hasChanged && !isBlank);\n\t},\n\tasync initCalendars() {\n\t\tconst { default: Pikaday } = await import(\n\t\t\t/* webpackChunkName: \"pikaday\" */ 'pikaday'\n\t\t);\n\t\tthis.fromPicker = new Pikaday(\n\t\t\tthis.getCalendarOptions(this.fromField, this.calendarFrom),\n\t\t);\n\t\tthis.toPicker = new Pikaday(\n\t\t\tthis.getCalendarOptions(this.toField, this.calendarTo),\n\t\t);\n\t\tthis.retainParameters();\n\t},\n\tgetCalendarOptions(field, container) {\n\t\tlet { months, weekdays, previousMonth, nextMonth } = this.root.dataset;\n\t\t[months, weekdays] = [months, weekdays].map(list => list.split(','));\n\t\treturn {\n\t\t\tfield: field,\n\t\t\tcontainer: container,\n\t\t\tdisableWeekends: true,\n\t\t\tminDate: this.template === 'upcoming' ? new Date() : undefined,\n\t\t\tmaxDate: this.template === 'past' ? new Date() : undefined,\n\t\t\ttoString(date) {\n\t\t\t\treturn [date.getMonth() + 1, date.getDate(), date.getFullYear()]\n\t\t\t\t\t.map(number => twoCiphers(number))\n\t\t\t\t\t.join('/');\n\t\t\t},\n\t\t\ti18n: {\n\t\t\t\tpreviousMonth,\n\t\t\t\tnextMonth,\n\t\t\t\tmonths,\n\t\t\t\tweekdays,\n\t\t\t\tweekdaysShort: weekdays,\n\t\t\t},\n\t\t\tonOpen: () => {\n\t\t\t\t// Fixes Chrome issue\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tcontainer.classList.add(CLASS_ACTIVE);\n\t\t\t\t}, 100);\n\t\t\t},\n\t\t\tonSelect: () => {\n\t\t\t\tthis.defineFromAndToRules();\n\t\t\t\tthis.onUpdate();\n\t\t\t},\n\t\t\tonClose: () => {\n\t\t\t\t// Fixes Chrome issue\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tcontainer.classList.remove(CLASS_ACTIVE);\n\t\t\t\t}, 100);\n\t\t\t},\n\t\t};\n\t},\n\tdefineFromAndToRules() {\n\t\tthis.toPicker.setMinDate(this.fromPicker.getDate());\n\t\tthis.fromPicker.setMaxDate(this.toPicker.getDate());\n\t},\n\t// to clear/reset every data that pickers contain,\n\t// pikaday's clear() method couldn't be use in this case\n\tclearAllFields() {\n\t\tthis.submit.classList.toggle(CLASS_ACTIVE, true);\n\t\tthis.fromPicker.setDate(null);\n\t\tthis.toPicker.setDate(null);\n\t},\n\tretainParameters() {\n\t\tconst queryString = decodeURIComponent(window.location.search).split(\n\t\t\t'?',\n\t\t)[1];\n\n\t\tif (queryString) {\n\t\t\tconst params = queryString.split('&');\n\t\t\tlet paramObj = {};\n\t\t\tparams.forEach(param => {\n\t\t\t\tlet [key, val] = param.split('=');\n\t\t\t\t// for search's wrong retain\n\t\t\t\tval = val.split('+').join(' ');\n\t\t\t\tparamObj[key] = val;\n\t\t\t});\n\t\t\tconst assignParam = (el, source, key, isField) => {\n\t\t\t\tconst value = paramObj[key];\n\t\t\t\tif (typeof value !== 'undefined')\n\t\t\t\t\tisField ? (source.value = value) : source.setDate(value);\n\n\t\t\t\tel.__initialValue = value || '';\n\t\t\t};\n\t\t\tassignParam(this.search, this.search, 'q', true);\n\t\t\tassignParam(this.fromField, this.fromPicker, 'from');\n\t\t\tassignParam(this.toField, this.toPicker, 'to');\n\t\t}\n\t\tthis.onUpdate();\n\t},\n};\n"],"sourceRoot":""}