vendor: 9,061 bytes, lines 1-7
1/** 2 * moofinder-prestashop - Ultra fast search engine for prestashop 3 * @version v1.4.0 4 * @link https://gitlab.com/waizabu/moofinder#readme 5 * @license propietary All rights reserved 6 */ 7!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=7)}([function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}},function(e,t,r){e.exports=r(6)},function(e,t){function r(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=r=function(e){return typeof e}:e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(t)}e.exports=r},function(e,t){function r(e,t,r,n,i,o,u){try{var a=e[o](u),s=a.value}catch(e){return void r(e)}a.done?t(s):Promise.resolve(s).then(n,i)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var u=e.apply(t,n);function a(e){r(u,i,o,a,s,"next",e)}function s(e){r(u,i,o,a,s,"throw",e)}a(void 0)}))}}},function(e,t,r){var n=function(e){"use strict";var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",u=n.toStringTag||"@@toStringTag";function a(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(e){a=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var i=t&&t.prototype instanceof f?t:f,o=Object.create(i.prototype),u=new k(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return C()}for(r.method=i,r.arg=o;;){var u=r.delegate;if(u){var a=T(u,r);if(a){if(a===c)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=l(e,t,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===c)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(e,r,u),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var c={};function f(){}function h(){}function d(){}var m={};m[i]=function(){return this};var p=Object.getPrototypeOf,g=p&&p(p(x([])));g&&g!==t&&r.call(g,i)&&(m=g);var y=d.prototype=f.prototype=Object.create(m);function v(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(i,o){function u(){return new t((function(n,u){!function n(i,o,u,a){var s=l(e[i],e,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,u,a)}),(function(e){n("throw",e,u,a)})):t.resolve(f).then((function(e){c.value=e,u(c)}),(function(e){return n("throw",e,u,a)}))}a(s.arg)}(i,o,n,u)}))}return n=n?n.then(u,u):u()}}function T(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var n=l(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,c;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function x(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return h.prototype=y.constructor=d,d.constructor=h,h.displayName=a(d,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,a(e,u,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},v(b.prototype),b.prototype[o]=function(){return this},e.AsyncIterator=b,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var u=new b(s(t,r,n,i),o);return e.isGeneratorFunction(r)?u:u.next().then((function(e){return e.done?e.value:u.next()}))},v(y),a(y,u,"Generator"),y[i]=function(){return this},y.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=x,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return u.type="throw",u.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],u=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var a=r.call(o,"catchLoc"),s=r.call(o,"finallyLoc");if(a&&s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var u=o?o.completion:{};return u.type=e,u.arg=t,o?(this.method="next",this.next=o.finallyLoc,c):this.complete(u)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;P(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:x(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},e}(e.exports);try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}},function(e,t,r){"use strict";r.r(t);var n=r(3),i=r.n(n),o=r(5),u=r.n(o),a=r(1),s=r.n(a),l=r(2),c=r.n(l),f=r(0),h=r.n(f),d=r(4),m=r.n(d),p=function(){function e(){s()(this,e)}return c()(e,null,[{key:"log",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];
7(t=console).log.apply(t,[e.prefix].concat(n))}},{key:"warn",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).warn.apply(t,[e.prefix].concat(n))}},{key:"error",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).error.apply(t,[e.prefix].concat(n))}},{key:"info",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).info.apply(t,[e.prefix].concat(n))}}]),e}();h()(p,"prefix","[MooFinder] ");var g=function(){function e(){var t=this;s()(this,e),h()(this,"config",{container:"moo-finder",close:"moo-finder-close",footer:".moo-finder-footer",filtersContainerSelector:".moo-filters",resultsContainerSelector:".mfd-results",noResultTemplateSelector:"#mfd-no-result",resultTemplateSelector:"#mfd-product-result",productCardId:"mfd-product-",resultsBottomPadding:100}),h()(this,"runtime",{mainContainer:null,filterWrapper:null,resultsWrapper:null,footerWrapper:null,lastTargetInput:null}),this.runtime.mainContainer=document.getElementById(this.config.container),this.runtime.resultsWrapper=document.querySelector(this.config.resultsContainerSelector),this.runtime.filterWrapper=document.querySelector(this.config.filtersContainerSelector),this.runtime.footerWrapper=document.querySelector(this.config.footer),this.runtime.mainContainer||p.error("Unable to find main container"),window.addEventListener("resize",(function(){t.runtime.lastTargetInput&&t.move(t.runtime.lastTargetInput)}),!1),this.moveMoofinderToBody()}return c()(e,[{key:"moveMoofinderToBody",value:function(){document.getElementsByTagName("body")[0].appendChild(this.runtime.mainContainer)}},{key:"move",value:function(e){var t=this;this.runtime.lastTargetInput=e;var r={x:0,y:0},n=0;new Promise((function(i){r=t.offset(e),n=e.getBoundingClientRect().height,i()})).then((function(){t.scroll(r.x,r.y);var i=r.y+n;t.isFixed(t.runtime.lastTargetInput)?t.runtime.mainContainer.style.position="fixed":t.runtime.mainContainer.style.position="absolute",t.resize(e),t.runtime.mainContainer.style.top=i+"px",t.runtime.mainContainer.style.zIndex=t.findHighestZIndex(window)+1}))}},{key:"isFixed",value:function(e){var t;for("object"===m()(e)?t=e[0]||e:"string"==typeof e&&(t=document.querySelector(e));"object"===m()(t)&&"body"!==t.nodeName.toLowerCase();){if("fixed"===window.getComputedStyle(t).getPropertyValue("position").toLowerCase())return!0;t=t.parentElement}return!1}},{key:"getTop",value:function(e){var t=this.offset(e),r=e.getBoundingClientRect().height;return t.y+r}},{key:"resize",value:function(e){var t=this.getTop(e),r=this.runtime.footerWrapper.getBoundingClientRect().height,n=window.innerHeight-r-this.config.resultsBottomPadding;this.isFixed(this.runtime.lastTargetInput)&&(n-=t),this.runtime.resultsWrapper.style.maxHeight=n+"px",this.runtime.filterWrapper&&(this.runtime.filterWrapper.style.maxHeight=n+"px")}},{key:"scroll",value:function(e,t){t>.3*window.innerHeight&&window.scrollTo(0,t)}},{key:"showResults",value:function(){document.getElementsByTagName("body")[0].style.overflowY="hidden",document.getElementsByTagName("body")[0].style.height="100vh",this.runtime.mainContainer.style.display="block"}},{key:"hideResults",value:function(){document.getElementsByTagName("body")[0].style.overflowY="auto",document.getElementsByTagName("body")[0].style.height="",this.runtime.mainContainer.style.display="none"}},{key:"hideFilters",value:function(){this.runtime.filterWrapper&&this.runtime.filterWrapper.classList.add("empty")}},{key:"showFilters",value:function(){this.runtime.filterWrapper&&this.runtime.filterWrapper.classList.remove("empty")}},{key:"buildMainContainer",value:function(){}},{key:"findHighestZIndex",value:function(e){for(var t=document.getElementsByTagName(e),r=Number.MAX_SAFE_INTEGER,n=0;n<t.length;n++){var i=Number.parseInt(document.defaultView.getComputedStyle(t[n],null).getPropertyValue("z-index"),10);i>r&&(r=i)}return r}},{key:"offset",value:function(e){var t=0,r=0;if(e.offsetParent){do{t+=e.offsetLeft,r+=e.offsetTop}while(e=e.offsetParent);return{x:t,y:r}}}}]),e}(),y=function(){function e(t){var r=this;s()(this,e),h()(this,"config",{searchInputSelector:".search_query",query:"",queryWords:[],container:"moo-finder",close:"moo-finder-close",footer:"moo-finder-footer",filterTitleClass:"moo-title-filter",resultsContainerSelector:"mfd-results",filtersSelector:"moo-result-filters",noResultTemplateSelector:"#mfd-no-result",resultTemplateSelector:"#mfd-product-result",loadTemplateSelector:"#mfd-load",productCardId:"mfd-product-",filterId:"mfd-filter",moduleDir:null,wordsUrl:"words",productsUrl:"products",imageUrl:"img/p/",imageDefault:"default.jpg",imageSize:{},imageExtension:"jpg",_previousQuery:null,pageSize:12,depth:3,productUrl:null,moofinderTest:null,moofinderTestWord:null,moofinderUrl:"https://moofinder.com/",exactMatch:!1,enableCatFilters:!1,enableAttFilters:!1,fixedStyles:{position:"absolute",height
7Container:{padding:15,boxshadow:2},resultsContainer:{"border-top":1},footerStyle:{"max-height":20,padding:2,"border-top":1}},filterTypes:{CATEGORY:"C",ATTRIBUTE:"A",FEATURE:"F"},identifierSeparator:"~~"}),h()(this,"runtime",{requestCache:[],pricesCache:{},renderEngine:null,resultTemplate:null,noResultTemplate:null,containers:{parent:null,results:null,filters:null},dictionaries:{},results:{},filteredIds:[],resultSorted:[],htmlResults:[],matchedKeywords:[],dictionaryIndex:[],previousRequest:null,previousRequestName:null,productDictionaries:{},productMatchedIds:[],productDictionaryIndex:[],resultStyles:{},productsIds:[],currentPage:0,totalPages:1,currentTimeoutFilters:null,currentTimeoutPrice:null,currentTimeoutPagination:null,currentIntervalProducts:null,sortWeight:1,renderTriggered:0,html:null,el:null,dictionariesTriggered:!1,enableFilter:!1,filters:{currentCategory:null,currentAttributes:[]}});try{this.runtime.renderEngine=new g(this.config)}catch(e){return void p.error("An error ocurred instantiating rendering engine. Disabled instant search. Error was: ",e)}try{console.log("%c "+"â¼".repeat(60),"color: #f9ba00;"),console.log("%c Instant search powered by MooFinder","font: 200 30px/50px Arial, Helvetica, sans-serif; color: #f9ba00;"),console.log("%c See more in https://addons.prestashop.com/es/busquedas-filtros/48581-ultrarapido-buscador.html","font: 200 14px/14px Arial, Helvetica, sans-serif; color: #f9ba00; "),console.log("%c "+"â²".repeat(60),"color: #f9ba00;")}catch(e){}this.config.moduleDir=t.moduleDir,this.config.wordsUrl=t.moduleDir+t.dataDir+this.config.wordsUrl+t.shardsDir,this.config.productsUrl=t.moduleDir+t.dataDir+this.config.productsUrl+t.shardsDir,this.config.imageSize={name:t.imageSize,height:t.imageHeight,width:t.imageWidth},this.config.imageUrl=t.imageUrl,this.config.imageDefault=t.imageDefault,this.config.productUrl=t.productUrl.replace(/&/g,"&"),this.config.moofinderTest=t.moofinderTest,this.config.query=t.moofinderTestWord,this.config.depth=
7parseInt(t.depth),this.config.exactMatch=t.exactMatch,this.config.enableCatFilters=0!==parseInt(t.enableCatFilters),this.config.enableAttFilters=0!==parseInt(t.enableAttFilters);var n=parseInt(t.pageSize);this.config.pageSize=n<this.config.pageSize?this.config.pageSize:n,this.config.searchInputSelector=t.input,$(document).ready((function(){r.init()}))}var t;return c()(e,[{key:"init",value:function(){var e=this;this.initDomRefs().then((function(){e.attachEvents(),e.initTemplates(),e.config.moofinderTest&&(e.runtime.el.val(e.config.query),e.runtime.el.click())}))}},{key:"initDb",value:function(){var e=this;return new Promise((function(t,r){if(e.runtime.dictionariesTriggered)return t();e.runtime.dictionariesTriggered=!0,new Promise((function(t,r){var n=e.config.wordsUrl+"dicts.js?callback=?";e.initDictionaries(n,"dictionaryIndex",t,r)})).then((function(){e.initProductDb().then(t)})).catch((function(){return r()}))}))}},{key:"initProductDb",value:function(){var e=this;return new Promise((function(t,r){var n=e.config.productsUrl+"dicts.js?callback=?";e.initDictionaries(n,"productDictionaryIndex",t,r)}))}},{key:"initDictionaries",value:function(e,t,r,n){var i=this;$.ajax({url:e,dataType:"jsonp",jsonp:"callback",jsonpCallback:"callback",success:function(e){i.runtime[t]=e,r()},error:function(e,t,r){p.error("getJSON failed, status: "+t+", error: "+r),n()}})}},{key:"initTemplates",value:function(){this.runtime.resultTemplate=$(this.config.resultTemplateSelector).html(),this.runtime.noResultTemplate=$(this.config.noResultTemplateSelector).html(),this.runtime.loadTemplate=$(this.config.loadTemplateSelector).html()}},{key:"initDomRefs",value:function(){var e=this;return new Promise((function(t,r){var n=$(e.config.searchInputSelector);n.length<=0?(p.error("DOM Element not found. Value was:",n),r()):(e.runtime.el=n,t())}))}},{key:"attachEvents",value:function(){var e=this;$("."+this.config.close).on("click",(function(){e.runtime.el.val(""),e.cleanResults()})),this.runtime.el.each((function(t,r){var n=$(r);n.off(),n.on("click",(function(t){e.runtime.renderEngine.move(t.currentTarget),e.initDb().then((function(){e.config.query=t.target.value,e.search(),n.on("input",(function(t){e.config.query=t.target.value,e.search()}))}))}))})),this.runtime.containers={parent:$("#"+this.config.container)||null,results:$("."+this.config.resultsContainerSelector)||null},(this.config.enableAttFilters||this.config.enableCatFilters)&&(this.runtime.containers.filters=$("."+this.config.filtersSelector)||null),$.each(this.runtime.containers,(function(e,t){(!t||t.length<=0)&&p.error("Missing "+e+" container")}))}},{key:"getZIndex",value:function(){var e=0;return $.each($("*"),(function(t,r){var n=parseInt($(r).css("zIndex"),10);n>e&&(e=n)})),e}},{key:"render",value:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(0==this.runtime.renderTriggered){this.runtime.renderTriggered=1;var r=0,n=0;this.runtime.htmlResults=[],this.runtime.productsIds=[];var i=this.runtime.resultSorted.length;if(i>0){this.runtime.totalPages=Math.ceil(i/this.config.pageSize);var o=[];new Promise((function(u){var a=e.config.pageSize;if(e.runtime.currentPage>0){var s=e.runtime.currentPage*e.config.pageSize;r=s,a+=s}t&&e.runtime.containers.results.html("");for(var l=r;l<=a;l++){if(l===a||l===i||void 0===e.runtime.resultSorted[l])return void u();n++;var c=e.runtime.resultSorted[l][0],f=e.getDictionaryName(c);e.runtime.productMatchedIds.push(c),e.runtime.containers.results.append($("<li>",{id:e.config.productCardId+c,style:"width:"+e.config.imageSize.width+"px"})),o.push(e.loadProduct(f,c))}})).then((function(){(n>0||o.length>0)&&e.renderResults(t).then((function(){Promise.all(o).then((function(){e.getPrices()}))})),"number"==typeof e.runtime.currentTimeoutPagination&&(clearTimeout(e.runtime.currentTimeoutPagination),delete e.runtime.currentTimeoutPagination),e.runtime.renderTriggered=0}))}else t&&(this.runtime.renderEngine.showResults(),this.runtime.containers.results.html(this.runtime.noResultTemplate),this.runtime.enableFilter||!this.config.enableCatFilters&&!this.config.enableAttFilters||this.runtime.renderEngine.hideFilters(),"number"==typeof this.runtime.currentTimeoutPagination&&(clearTimeout(this.runtime.currentTimeoutPagination),delete this.runtime.currentTimeoutPagination)),this.runtime.renderTriggered=0}}},{key:"loadProduct",value:function(e,t){var r=this;return new Promise((function(n){r.addProduct(e,t,n)}))}},{key:"addProduct",value:(t=u()(i.a.mark((function e(t,r,n){var o,u=this;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getProductDictionary(t);case 2:e.sent&&void 0!==this.runtime.productDictionaries[t]&&(o=setInterval((function(){if(u.runtime.productDictionaries[t].hasOwnProperty(r)){clearInterval(o);var e=u.runtime.productDictionaries[t][r],i=e.id_image+"";e.link=u.config.imageUrl+("null"!==i?i.split("").join("/")+"/"+i+"-"+u.config.imageSize.name+"."+u.config.imageExtension:u.config.imageDefault),e.imageHeight=u.config.imageSize.height,e.imageWidth=u.config.imageSize.width,e.productUrl=u.config.productUrl,e.productUrl.indexOf("?")>-1?e.productUrl+="&id="+e.id_product:e.productUrl+="?id="+e.id_product,u.runtime.productsIds.push(e.id_product);var a=u.parseTemplate(u.runtime.resultTemplate,e);u.runtime.containers.results.find("#"+u.config.productCardId+r).html(a),u.runtime.containers.results.find("#"+u.config.productCardId+r+" .price").html(u.runtime.loadTemplate),n()}}),1));case 4:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"renderResults",value:function(e){var t=this;return new Promise((function(e){t.runtime.renderEngine.showResults(),t.runtime.containers.results.off(),t.runtime.containers.results.scroll((function(e){var r=e.target,n=$(r).find("li").last().height();r.offsetHeight+r.scrollTop+n>=r.scrollHeight&&t.runtime.currentPage<t.runtime.totalPages&&(null!==t.runtime.currentTimeoutPagination&&void 0!==t.runtime.currentTimeoutPagination||(t.runtime.currentTimeoutPagination=setTimeout((function(){t.runtime.currentPage++,t.render(!1)}),500)))})),e()}))}},{key:"nextPage",value:function(){var e=this;this.runtime.currentPage<=this.runtime.totalPages&&(null!==this.runtime.currentTimeoutPagination&&void 0!==this.runtime.currentTimeoutPagination||(this.runtime.currentTimeoutPagination=setTimeout((function(){e.runtime.currentPage++,e.render(!1)}),0)))}},{key:"hashCode",value:function(e){return e.split("").reduce((function(e,t){return(e<<5)-e+t.charCodeAt(0)|0}),0)}},{key:"renderFilter",value:function(e){var t=this;if(!this.runtime.enableFilter)if(null!==typeof this.runtime.containers.filters){var r=[];if(e){var n={};Object.keys(e).forEach((function(e){var r=e.split(t.config.identifierSeparator),i=t.config.filterId+t.config.identifierSeparator,o=null;5===r.length&&(i+=r[1]+t.config.identifierSeparator+r[2]+t.config.identifierSeparator+r[3],o=r[0]+r[1],n.hasOwnProperty(o)||(n[o]={name:r[2],values:[]}),n[o].values.push(t.getItemFilter(i,r[4],e,r[0])))})),Object.keys(n).length>
70&&Object.keys(n).forEach((function(e){r.push(t.getGroupFilter(n[e].name,n[e].values))})),this.runtime.containers.filters.html($("<ul>",{html:r}));var i=$("."+this.config.filterTitleClass);i.off(),i.on("click",(function(e){var t=$(e.currentTarget);t.hasClass("active")?t.removeClass("active"):t.addClass("active")})),this.runtime.containers.filters.find("."+this.config.filterId).off(),this.runtime.containers.filters.find("."+this.config.filterId).on("click",(function(e){var r=$(e.currentTarget),n=r.data("type");if(r.data("enable")&&!r.data("empty")){if(n===t.config.filterTypes.CATEGORY){var i=r.siblings("li");r.hasClass("active")?i.data("enable",!0).removeClass("disable"):(i.data("enable",!1).addClass("disable"),r.data("enable",!0).removeClass("disable"))}r.toggleClass("active"),t.searchByFilter(n,r.data("key"))}}))}else this.runtime.containers.filters.html($("<ul>",{html:this.runtime.noResultTemplate}))}else p.error("Unable to find filter container")}},{key:"getItemFilter",value:function(e,t,r,n){return $("<li>",{id:e,class:this.config.filterId+" "+this.config.filterId+this.config.identifierSeparator+n,html:t,"data-key":r,"data-type":n,"data-enable":!0,"data-empty":!1})}},{key:"getGroupFilter",value:function(e,t){return $("<li>",{html:[$("<p>",{class:this.config.filterTitleClass,html:e}),$("<ul>",{html:t})]})}},{key:"searchByFilter",value:function(e,t){var r=this;$("."+this.config.filterId).data("empty",!1).removeClass("empty"),new Promise((function(n){switch(e){case r.config.filterTypes.CATEGORY:t===r.runtime.filters.currentCategory?r.runtime.filters.currentCategory=null:r.runtime.filters.currentCategory=t;break;case r.config.filterTypes.ATTRIBUTE:case r.config.filterTypes.FEATURE:var i=r.runtime.filters.currentAttributes.indexOf(t);i>-1?r.runtime.filters.currentAttributes.splice(i,1):r.runtime.filters.currentAttributes.push(t)}r.runtime.filteredIds=[];var o=Object.keys(r.runtime.results);if(null===r.runtime.filters.currentCategory&&0===r.runtime.filters.currentAttributes.length)r.runtime.filteredIds=o;else if(r.config.enableCatFilters&&null!==r.runtime.filters.currentCategory&&(r.runtime.filteredIds=r.runtime.filteredIds.concat(r.getFilterResult(r.runtime.filters.currentCategory))),r.config.enableAttFilters&&r.runtime.filters.currentAttributes.length>0){var u=[];r.runtime.filters.currentAttributes.forEach((function(e){u=u.concat(r.getFilterResult(e))})),r.runtime.filteredIds.length>0?r.runtime.filteredIds=r.intersect(r.runtime.filteredIds,u):r.runtime.filteredIds=u}r.disableEmptyFilters(),n()})).then((function(){r.search(!0)}))}},{key:"disableEmptyFilters",value:function(){var e=this,t=this.hashCode(this.config.query);if(void 0!==this.runtime.requestCache[t]){var r=this.runtime.requestCache[t];Object.keys(r).forEach((function(t){0===e.intersect(e.runtime.filteredIds,r[t]).length&&$('[data-key="'+t+'"]').data("empty",!0).addClass("empty")}))}}},{key:"intersect",value:function(e,t){return e.filter((function(e){return-1!==t.indexOf(e)}))}},{key:"getFilterResult",value:function(e){var t=this.hashCode(this.config.query);if(void 0!==this.runtime.requestCache[t]){var r=this.runtime.requestCache[t];if(r.hasOwnProperty(e))return r[e]}return[]}},{key:"getFilters",value:function(){var e=this;if(this.config.query){var t=this.hashCode(this.config.query);if(void 0!==this.runtime.requestCache[t])return this.loadFilters(),this.renderFilter(this.runtime.requestCache[t]);var r={term:this.config.query,filters:!0};this.cleanTimeout("currentTimeoutFilters"),this.runtime.currentTimeoutFilters=setTimeout((function(){e.loadFilters(),$.ajax({dataType:"json",data:r,method:"POST",url:e.config.productUrl,success:function(r){e.runtime.requestCache[t]=r,e.renderFilter(r)},error:function(e,t,r){p.error("getFilters failed, status: "+t+", error: "+r)}})}),150)}}},{key:"loadFilters",value:function(){!this.runtime.enableFilter&&(this.config.enableCatFilters||this.config.enableAttFilters)&&Object.keys(this.runtime.results).length>0&&(this.runtime.renderEngine.showFilters(),this.runtime.containers.filters.html(this.runtime.loadTemplate))}},{key:"getPrices",value:function(){var e=this,t=[];this.runtime.productsIds.forEach((function(r){e.runtime.pricesCache.hasOwnProperty(r)||t.push(r)}));var r=this.hashCode(t.join(this.config.identifierSeparator));if(0===t.length&&this.runtime.productsIds.length>0||void 0!==this.runtime.requestCache[r])return this.parsePrices();this.cleanTimeoutPrice(),this.runtime.currentTimeoutPrice=setTimeout((function(){$.ajax({dataType:"json",data:{id:t,prices:!0},method:"POST",url:e.config.productUrl,success:function(t){e.runtime.requestCache[r]=t,Object.keys(t).forEach((function(r){e.runtime.pricesCache.hasOwnProperty(r)||(e.runtime.pricesCache[r]=t[r])})),e.parsePrices()},error:function(e,t,r){p.error("getPrices failed, status: "+t+", error: "+r)}})}),500)}},{key:"parsePrices",value:function(){var e=this;this.runtime.productsIds.length>0&&(this.runtime.currentIntervalProducts=[],this.runtime.productsIds.forEach((function(t){e.runtime.currentIntervalProducts[t]=setInterval((function(){var r=e.runtime.containers.results.find("#"+e.config.productCardId+t+" .price");r.length>0&&(clearInterval(e.runtime.currentIntervalProducts[t]),r.html(e.runtime.pricesCache[t]))}),1)})))}},{key:"parseTemplate",value:function(e,t){var r=e+"";return r=r.replace(/{{(\w+)}}/g,(function(e,r){return t[r]||""}))}},{key:"clean",value:function(){this.runtime.renderEngine.hideResults(),this.runtime.containers.results.html("")}},{key:"search",value:function(){var t=this,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.runtime.enableFilter=r;var n=e.slug(this.config.query);n.length>=this.config.depth&&(this.runtime.enableFilter||n!==this.config._previousQuery)?(this.splitWords(),this.cleanResults().then((function(){t.runtime.sortWeight=1,t.config.queryWords.forEach((function(e,r,n){t.runtime.sortWeight+="0"})),t.runtime.sortWeight=parseInt(t.runtime.sortWeight),t.config.queryWords.forEach((function(e,r,n){if(!(""===e.trim()||e.length<t.config.depth)){var i=t.getDictionaryName(e);t.getDictionary(i).then((function(){return t.filterDictionary(e.trim(),i)}))}}))}))):n.length<this.config.depth&&this.cleanResults(),this.config._previousQuery=e.slug(this.config.query)}},{key:"getDictionaryName",value:function(e){var t=(e+="").trim().split("");return(t=t.slice(0,this.config.depth)).join("")}},{key:"cleanResults",value:function(){var e=this;return new Promise((function(t){e.runtime.enableFilter||(e.runtime.filters.currentAttributes=[],e.runtime.filters.currentCategory=null),e.runtime.currentPage=0,e.cleanTimeoutPrice(),e.cleanTimeoutPagination(),e.runtime.results={},e.runtime.resultSorted=[],e.runtime.matchedKeywords=[],e.clean(),t()}))}},{key:"cleanTimeoutPagination",value:function(){null!==this.runtime.currentTimeoutPagination&&void 0!==this.runtime.currentTimeoutPagination&&clearTimeout(this.runtime.currentTimeoutPagination)}},{key:"cleanTimeout",value:function(e){null!==this.runtime[e]&&void 0!==this.runtime[e]&&clearTimeout(this.runtime[e])}},{key:"cleanTimeoutPrice",value:function(){var e=this;null!==this.runtime.currentTimeoutPrice&&void 0!==this.runtime.currentTimeoutPrice&&(clearTimeout(this.runtime.currentTimeoutPrice),null!==this.runtime.currentIntervalProducts&&(Object.keys(this.runtime.currentIntervalProducts).forEac
7h((function(t){clearInterval(e.runtime.currentIntervalProducts[t])})),this.runtime.currentIntervalProducts=null))}},{key:"splitWords",value:function(){this.config.queryWords=e.slug(this.config.query).split(" ")}},{key:"filterDictionary",value:function(e,t){var r=this;return new Promise((function(n){Object.keys(r.runtime.dictionaries[t]).filter((function(t){return t.indexOf(e)>=0})).forEach((function(e,n,i){r.runtime.matchedKeywords.push(e),r.decompress(r.runtime.dictionaries[t][e])})),r.runtime.sortWeight/=10,n()})).then((function(){(r.config.enableCatFilters||r.config.enableAttFilters)&&r.getFilters(),r.sortAndFilterResults().then((function(){r.render()}))}))}},{key:"decompress",value:function(e){var t=this;e.forEach((function(e,r,n){if("string"==typeof e){var i=e.split("+"),o=parseInt(i[0]);t.addResult(o);for(var u=1;u<=i[1];u++)t.addResult(o+u)}else t.addResult(e)}))}},{key:"sortAndFilterResults",value:function(){var e=this;return new Promise((function(t){for(var r in e.runtime.resultSorted=[],e.runtime.results)e.runtime.filteredIds&&e.runtime.enableFilter?e.runtime.filteredIds.indexOf(r)>-1&&e.runtime.resultSorted.push([r,e.runtime.results[r]]):e.runtime.resultSorted.push([r,e.runtime.results[r]]);e.runtime.resultSorted.sort((function(e,t){return e[1]-t[1]})).reverse(),t()}))}},{key:"addResult",value:function(e){if(e+="",this.runtime.results.hasOwnProperty(e)){var t=this.runtime.sortWeight+"",r=this.runtime.results[e]+"";"0"===r[r.length-(t.indexOf("1")+1)-(t.length-(t.indexOf("1")+1))]&&(this.runtime.results[e]+=this.runtime.sortWeight)}else this.runtime.results[e]=this.runtime.sortWeight}},{key:"getProductDictionary",value:function(e){var t=this;return new Promise((function(r,n){""===e.trim()||t.runtime.productDictionaryIndex.indexOf(e)<0?r(!1):void 0!==t.runtime.productDictionaries[e]?r(!0):(t.runtime.productDictionaries[e]=[],$.ajax({url:t.config.productsUrl+e.split("").join("/")+"/"+e+".js?callback=?",dataType:"jsonp",async:!0,jsonp:"callback",jsonpCallback:"callback_"+e,success:function(n){t.runtime.productDictionaries[e]=n,r(!0)},error:function(e,t,r){p.error("getProductDictionary failed, status: "+t+", error: "+r)}}))}))}},{key:"getDictionary",value:function(e){var t=this;return new Promise((function(r,n){if(t.runtime.dictionaryIndex.indexOf(e)<0)return t.runtime.dictionaries[e]=[],void r();void 0===t.runtime.dictionaries[e]?t.runtime.previousRequestName!==e&&(t.runtime.previousRequestName=e+"",t.runtime.dictionaries[e]=[],$.ajax({url:t.config.wordsUrl+e.split("").join("/")+"/"+e+".js?callback=?",dataType:"jsonp",jsonp:"callback",jsonpCallback:"callback_"+e,success:function(n){t.runtime.dictionaries[e]=n,r()},error:function(e,t,r){p.error("getDictionary failed, status: "+t+", error: "+r)}})):r()}))}}],[{key:"getDictionaryNames",value:function(e){e+="";for(var t=[],r=0;r<e.length-(this.config.depth-1);r++)t.push(e.slice(r,r+this.config.depth));return t}},{key:"slug",value:function(e){e=(e=e.trim()).toLowerCase();for(var t="à áäâèéëêìÃïîòóöôùúüûñç·/_,:;",r=0,n=t.length;r<n;r++)e=e.replace(new RegExp(t.charAt(r),"g"),"aaaaeeeeiiiioooouuuunc------".charAt(r));return e=e.replace(/[^a-z0-9 -]/g,"").replace(/\s+/g," ").replace(/-+/g," ")}}]),e}(); 8/** 9 * NOTICE OF LICENSE 10 * 11 * This software is protected under Spanish law. Any distribution of this software 12 * will be prosecuted. 13 * 14 * @license propietary © E. Alamo Medina (Spain) All Rights Reserved. 15 * For commercial usage contact [email protected] 16 * @author Waizabú <[email protected]> 17 * @copyright Copyright (c) 2020 All Rights Reserved 18 */$(document).ready((function(){new y(window.moofinder)}))}]);
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.