{"version":3,"file":"SearchGrid.js","names":["SearchGrid","a","setters","Component","default","Event","deepMerge","mix","LoaderMixin","execute","with","constructor","element","options","arguments","length","templateName","dataModelId","initCache","observer","tileTimeout","loader","bindEvents","on","onSearchUpdate","onSearchUpdated","onSearchRemoveLoader","data","isInsertMode","addLoader","overlay","render","replaceChildren","isAppend","then","removeLoader","destroy","removeListener"],"sources":["components/search/SearchGrid.js"],"sourcesContent":["import Component from 'core/Component';\nimport { Event } from 'services/EventEmitter';\nimport { deepMerge } from 'toolbox/deepMerge';\nimport { mix } from 'core/mixwith';\nimport LoaderMixin from 'mixins/Loader';\n\n/**\n * This is a description of the SearchGrid constructor function.\n * @class\n * @classdesc This is a description of the SearchGrid class.\n * @extends Component\n */\nexport default class SearchGrid extends mix(Component).with(LoaderMixin) {\n    /**\n     * Constructor of the class that mainly merge the options of the components\n     *\n     * @param {HTMLElement} element HTMLElement of the component\n     * @param {Object} options That belongs to the component\n     */\n    constructor(element, options = {}) {\n        super(element, deepMerge({\n            templateName: 'search/searchgrid',\n            dataModelId: 'searchgrid',\n        }, options));\n    }\n\n    /**\n     * All selectors must be cached. Never cache elements that are out of the component scope\n     */\n    initCache() {\n        this.observer = null;\n        this.tileTimeout = null;\n        this.loader = null;\n    }\n\n    /**\n     * Should contain only event listeners and nothing else\n     * All the event handlers should be into a separated function. No usage of anonymous function\n     */\n    bindEvents() {\n        Event.on('search.update', this.onSearchUpdate, this);\n        Event.on('search.updated', this.onSearchUpdated, this);\n        Event.on('search.removeLoader', this.onSearchRemoveLoader, this);\n    }\n\n    /**\n     * Search Update event handler\n     *\n     * @param {Object} data  Data due to refinement to be changed\n     * @param {Boolean} isInsertMode Flag due to a insertion\n     */\n    onSearchUpdate(data, isInsertMode) {\n        if (!isInsertMode) {\n            this.addLoader(null, { overlay: true });\n        }\n    }\n\n    /**\n     * Search Updated event handler\n     *\n     * @param {Object} data Data due to refinement to be changed\n     * @param {Boolean} isInsertMode Flag due to a insertion\n     */\n    onSearchUpdated(data, isInsertMode) {\n        if (data[this.options.dataModelId]) {\n            this.render(data[this.options.dataModelId], {\n                replaceChildren: true,\n                isAppend: !!isInsertMode,\n            }).then(() => {\n                this.removeLoader();\n            });\n        } else {\n            this.removeLoader();\n        }\n    }\n\n    /**\n     * Remove Loader when search fails\n     */\n    onSearchRemoveLoader() {\n        this.removeLoader();\n    }\n\n    /**\n     * Destroy is called automatically after the component is being removed from the DOM\n     * You must always destroy the listeners attached to an element to avoid any memory leaks\n     */\n    destroy() {\n        Event.removeListener('search.update', this.onSearchUpdate, this);\n        Event.removeListener('search.updated', this.onSearchUpdated, this);\n        Event.removeListener('search.removeLoader', this.onSearchRemoveLoader, this);\n    }\n}\n"],"mappings":"kKAYqBA,CAAU,QAAAC,CAAA,oBAAAC,OAAA,WAAAD,CAAA,EAZxBE,CAAS,CAAAF,CAAA,CAAAG,OAAA,WAAAH,CAAA,EACPI,CAAK,CAAAJ,CAAA,CAALI,KAAK,WAAAJ,CAAA,EACLK,CAAS,CAAAL,CAAA,CAATK,SAAS,WAAAL,CAAA,EACTM,CAAG,CAAAN,CAAA,CAAHM,GAAG,WAAAN,CAAA,EACLO,CAAW,CAAAP,CAAA,CAAAG,OAAA,GAAAK,OAAA,SAAAA,CAAA,EAAAR,CAAA,WAQGD,CAAU,CAAhB,aAAyB,CAAAO,CAAG,CAACJ,CAAS,CAAC,CAACO,IAAI,CAACF,CAAW,CAAE,CAOrEG,WAAWA,CAACC,CAAO,CAAgB,IAAd,CAAAC,CAAO,GAAAC,SAAA,CAAAC,MAAA,WAAAD,SAAA,IAAAA,SAAA,IAAG,CAAC,CAAC,CAC7B,KAAK,CAACF,CAAO,CAAEN,CAAS,CAAC,CACrBU,YAAY,CAAE,mBAAmB,CACjCC,WAAW,CAAE,YACjB,CAAC,CAAEJ,CAAO,CAAC,CACf,CAKAK,SAASA,CAAA,CAAG,CACR,IAAI,CAACC,QAAQ,CAAG,IAAI,CACpB,IAAI,CAACC,WAAW,CAAG,IAAI,CACv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