enqueueScripts([function(){ (window.webpackJsonpvtex_shelf_1_49_0=window.webpackJsonpvtex_shelf_1_49_0||[]).push([["Shelf"],[function(t,e){t.exports=PropTypes},function(t,e){t.exports=React},,function(t,e){t.exports=__RENDER_8_RUNTIME__},function(t,e){t.exports=R},,,,function(t,e){t.exports=__RENDER_8_COMPONENTS__["vtex.css-handles@0.x/useCssHandles"]},function(t,e){t.exports=__RENDER_8_COMPONENTS__["vtex.css-handles@0.x/withCssHandles"]},function(t,e){t.exports=Classnames},,function(t,e){t.exports=ReactApollo},function(t,e){t.exports=__RENDER_8_COMPONENTS__["vtex.device-detector@0.x/useDevice"]},function(t,e){t.exports=__RENDER_8_COMPONENTS__["vtex.product-list-context@0.x/ProductListContext"]},,,,,,function(t,e){t.exports=__RENDER_8_COMPONENTS__["vtex.native-types@0.x/IOMessage"]},function(t,e){t.exports=__RENDER_8_COMPONENTS__["vtex.native-types@0.x/formatIOMessage"]},function(t,e){t.exports=__RENDER_8_COMPONENTS__["vtex.store-icons@0.x/IconCaret"]},function(t,e){t.exports=__RENDER_8_COMPONENTS__["vtex.slider@0.x/Slider"]},function(t,e){t.exports=__RENDER_8_COMPONENTS__["vtex.slider@0.x/Slide"]},function(t,e){t.exports=__RENDER_8_COMPONENTS__["vtex.slider@0.x/Dots"]},function(t,e){t.exports=__RENDER_8_COMPONENTS__["vtex.slider@0.x/SliderContainer"]},function(t,e){t.exports=__RENDER_8_COMPONENTS__["vtex.product-summary@2.x/ProductSummaryCustom"]},function(t,e){t.exports=__RENDER_8_COMPONENTS__["vtex.pixel-manager@1.x/PixelContext"]},function(t,e){t.exports=__RENDER_8_COMPONENTS__["vtex.product-list-context@0.x/useProductImpression"]},,,,,,,,,,,,,,,,,,function(t,e,_){"use strict";_.r(e),function(t){var e=_(5);_.p=Object(e.getPublicPath)("vtex.shelf@1.49.0");var o=Object(e.register)((function(){return _(36)}),t,"vtex.shelf@1.49.0","vtex.shelf@1.x","Shelf");o.renderHotReload,o.setupHMR}.call(this,_(31)(t))}],[[47,"common",1,0,2]]]); },function(){ !function(t){function e(e){for(var r,u,c=e[0],a=e[1],f=e[2],s=0,p=[];st.length)&&(e=t.length);for(var n=0,r=new Array(e);n3&&void 0!==arguments[3]?arguments[3]:"/",n="";if(r&&r>0){var a=new Date;a.setTime((new Date).getTime()+r),n="expires=".concat(a.toUTCString(),";")}document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";").concat(n,"path=").concat(o)}var f=function(){function e(t){Object(c.a)(this,e),this.client=t,this.historyKey="biggy-search-history"}var t,r,o;return Object(s.a)(e,[{key:"topSearches",value:(o=Object(a.a)(n.a.mark((function e(){return n.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.client.query({query:h.a}));case 1:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"suggestionSearches",value:(r=Object(a.a)(n.a.mark((function e(t){return n.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.client.query({query:m.a,variables:{fullText:t}}));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"suggestionProducts",value:(t=Object(a.a)(n.a.mark((function e(t,r,o){var a,c,s,i,u,m,p=arguments;return n.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=p.length>3&&void 0!==p[3]&&p[3],c=p.length>4&&void 0!==p[4]?p[4]:"default",s=p.length>5&&void 0!==p[5]&&p[5],i=p.length>6?p[6]:void 0,u=p.length>7?p[7]:void 0,m=p.length>8?p[8]:void 0,e.abrupt("return",this.client.query({query:l.a,variables:{simulationBehavior:c,hideUnavailableItems:s,orderBy:i,fullText:t,facetKey:r,facetValue:o,productOriginVtex:a,count:u,shippingOptions:m,variant:d("sp-variant")},fetchPolicy:"network-only"}));case 7:case"end":return e.stop()}}),e,this)}))),function(e,r,o){return t.apply(this,arguments)})},{key:"searchHistory",value:function(){return(d(this.historyKey)||"").split(",").filter((function(e){return!!e}))}},{key:"prependSearchHistory",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;if(null!=e&&""!==e.trim()){var r=this.searchHistory();r.indexOf(e)<0&&(r.unshift(e),r=r.slice(0,t)),x(this.historyKey,r.join(","))}}}]),e}()},function(e,t,r){e.exports={textoProdrecomendados:"cloemx-search-2-x-textoProdrecomendados",sugerenciasdecompra:"cloemx-search-2-x-sugerenciasdecompra",wrapper:"cloemx-search-2-x-wrapper",suggestions:"cloemx-search-2-x-suggestions",upsellshelf:"cloemx-search-2-x-upsellshelf",producttop:"cloemx-search-2-x-producttop",productimagecontainer:"cloemx-search-2-x-productimagecontainer",productimage:"cloemx-search-2-x-productimage",productname:"cloemx-search-2-x-productname",productbrand:"cloemx-search-2-x-productbrand",productpricecontainer:"cloemx-search-2-x-productpricecontainer",productlistprice:"cloemx-search-2-x-productlistprice",productsellingprice:"cloemx-search-2-x-productsellingprice",".discounted":"cloemx-search-2-x-.discounted",addtocartbuttoncontainer:"cloemx-search-2-x-addtocartbuttoncontainer",savingspct:"cloemx-search-2-x-savingspct","discountLabel--0":"cloemx-search-2-x-discountLabel--0","discountLabel--1":"cloemx-search-2-x-discountLabel--1",discountLabel:"cloemx-search-2-x-discountLabel",weightedbuttoncontainer:"cloemx-search-2-x-weightedbuttoncontainer",vtexnumericstepperselector:"cloemx-search-2-x-vtexnumericstepperselector",vtexnumericstepper__input:"cloemx-search-2-x-vtexnumericstepper__input",selector:"cloemx-search-2-x-selector","vtex-button":"cloemx-search-2-x-vtex-button","vtex-button__label":"cloemx-search-2-x-vtex-button__label",disabled:"cloemx-search-2-x-disabled",slickprev:"cloemx-search-2-x-slickprev",slicknext:"cloemx-search-2-x-slicknext",sliderBuscador:"cloemx-search-2-x-sliderBuscador","slick-prev":"cloemx-search-2-x-slick-prev","slick-next":"cloemx-search-2-x-slick-next",productVariantLinkContainer:"cloemx-search-2-x-productVariantLinkContainer",circleSkeleton:"cloemx-search-2-x-circleSkeleton","skeleton-loading":"cloemx-search-2-x-skeleton-loading","caretIcon--searcher":"cloemx-search-2-x-caretIcon--searcher",bullets:"cloemx-search-2-x-bullets",skeletonBullets:"cloemx-search-2-x-skeletonBullets",productVariantMoreParagraph:"cloemx-search-2-x-productVariantMoreParagraph",MoreColors_title:"cloemx-search-2-x-MoreColors_title",colorBullet:"cloemx-search-2-x-colorBullet",Multicolor:"cloemx-search-2-x-Multicolor","Électrico":"cloemx-search-2-x-Électrico",Marino:"cloemx-search-2-x-Marino",Electrico:"cloemx-search-2-x-Electrico",Azul:"cloemx-search-2-x-Azul",Celeste:"cloemx-search-2-x-Celeste",Amarillo:"cloemx-search-2-x-Amarillo","Limón":"cloemx-search-2-x-Limón",Ocre:"cloemx-search-2-x-Ocre",Limon:"cloemx-search-2-x-Limon",Oro:"cloemx-search-2-x-Oro",Verde:"cloemx-search-2-x-Verde",Olivo:"cloemx-search-2-x-Olivo","Petróleo":"cloemx-search-2-x-Petróleo",Petroleo:"cloemx-search-2-x-Petroleo",Turquesa:"cloemx-search-2-x-Turquesa",Menta:"cloemx-search-2-x-Menta",morado:"cloemx-search-2-x-morado",lila:"cloemx-search-2-x-lila",Lila:"cloemx-search-2-x-Lila",Morado:"cloemx-search-2-x-Morado",Blaco:"cloemx-search-2-x-Blaco",Negro:"cloemx-search-2-x-Negro",Gris:"cloemx-search-2-x-Gris",Fango:"cloemx-search-2-x-Fango",Plata:"cloemx-search-2-x-Plata",Inox:"cloemx-search-2-x-Inox",Rosa:"cloemx-search-2-x-Rosa",Magenta:"cloemx-search-2-x-Magenta",Coral:"cloemx-search-2-x-Coral",Pathe:"cloemx-search-2-x-Pathe",Rojo:"cloemx-search-2-x-Rojo",Tinto:"cloemx-search-2-x-Tinto",Naranja:"cloemx-search-2-x-Naranja",Tan:"cloemx-search-2-x-Tan",Camel:"cloemx-search-2-x-Camel","Café":"cloemx-search-2-x-Café",Chocolate:"cloemx-search-2-x-Chocolate",Cafe:"cloemx-search-2-x-Cafe",Beige:"cloemx-search-2-x-Beige",Nude:"cloemx-search-2-x-Nude",Bronce:"cloemx-search-2-x-Bronce",Copper:"cloemx-search-2-x-Copper","wishlistIconContainer--pdp-wishlist":"cloemx-search-2-x-wishlistIconContainer--pdp-wishlist"}},,,,function(e,t){e.exports=regeneratorRuntime},function(e,t){e.exports=__RENDER_8_COMPONENTS__["vtex.styleguide@9.x/IconClose"]},function(e,t){e.exports=__RENDER_8_COMPONENTS__["vtex.styleguide@9.x/IconClock"]},function(e,t){e.exports=__RENDER_8_COMPONENTS__["vtex.product-list-context@0.x/ProductListContext"]},function(e,t){e.exports=__RENDER_8_COMPONENTS__["vtex.device-detector@0.x/withDevice"]},function(e,t){function r(e,t,r){var o,n,a,c,s;function i(){var l=Date.now()-c;l=0?o=setTimeout(i,t-l):(o=null,r||(s=e.apply(a,n),a=n=null))}null==t&&(t=100);var l=function(){a=this,n=arguments,c=Date.now();var l=r&&!o;return o||(o=setTimeout(i,t)),l&&(s=e.apply(a,n),a=n=null),s};return l.clear=function(){o&&(clearTimeout(o),o=null)},l.flush=function(){o&&(s=e.apply(a,n),a=n=null,clearTimeout(o),o=null)},l}r.debounce=r,e.exports=r},function(e,t){e.exports=__RENDER_8_COMPONENTS__["vtex.pixel-manager@1.x/PixelContext"]},function(e,t){e.exports=__RENDER_8_COMPONENTS__["vtex.styleguide@9.x/Spinner"]},function(e,t){e.exports=__RENDER_8_COMPONENTS__["vtex.product-summary@2.x/ProductSummaryCustom"]},,,,,function(e,t,r){"use strict";r.r(t),function(e){var t=r(3);r.p=Object(t.getPublicPath)("cloemx.search@2.16.41");var o=Object(t.register)((function(){return r(44)}),e,"cloemx.search@2.16.41","cloemx.search@2.x","Autocomplete");o.renderHotReload,o.setupHMR}.call(this,r(15)(e))},,,,,,function(e,t,r){"use strict";r.r(t);var o=r(1),n=r.n(o),a=r(5),c=r(10),s=r(11),i=r(23),l=r(22),u=r(12),m=r(0),p=r.n(m),h=r(8),d=r(4),x=r(26),f=r.n(x),v=r(27),g=r.n(v),y=r(28),b=r.n(y),k=r(29),E=r.n(k),w=r(30),S=r.n(w),L=r(31),_=r(21),O=r.n(_),P=r(2),C=function(){return p.a.createElement("div",{className:"".concat(O.a.sugerenciasdecompra)},p.a.createElement("h1",{className:"".concat(O.a.textoProdrecomendados)},"Productos recomendados"),p.a.createElement("div",{className:"".concat(O.a.wrapper)},p.a.createElement("div",{className:"".concat(O.a.suggestions)},p.a.createElement(P.ExtensionPoint,{id:"list-context.product-list#search-recommended"}))))},T=r(20),M=r(13),I=r.n(M),N=r(24),R=r(32),j=r.n(R),H=r(33),B=r.n(H),F=r(7),V=r.n(F),A={desktop:6,tablet:2,phone:1},D=!0,q={timeout:5e3,stopOnHover:!0},W=function(e){var t=e.term,r=e.title,o=e.products,n=e.showTitle,a=e.totalProducts,c=e.layout,s=e.isLoading,i=e.onProductClick,l=e.onSeeAllClick,u=e.HorizontalProductSummary,h=e.customPage,x=Object(m.useState)(0),f=Object(N.a)(x,2),v=f[0],g=f[1],y=Object(m.useState)(A.desktop),b=Object(N.a)(y,2),k=b[0],E=b[1];Object(m.useEffect)((function(){var e=function(){var e=/iPad|Macintosh/.test(navigator.userAgent)&&"ontouchend"in document;window.innerWidth<=768?E(A.phone):e?E(5):window.innerWidth<=1024?E(A.tablet):E(A.desktop)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]);var w=function(){g((function(e){return e+k>=o.length?0:e+k}))};return Object(m.useEffect)((function(){var e=setInterval((function(){w()}),q.timeout);return function(){return clearInterval(e)}}),[o,k]),0!==o.length||s?p.a.createElement("section",{className:V.a.tileList},n&&p.a.createElement("p",{className:"".concat(V.a.tileListTitle," c-on-base")},r),s?p.a.createElement("div",{className:V.a.tileListSpinner},p.a.createElement(j.a,null)):p.a.createElement(p.a.Fragment,null,p.a.createElement("div",{className:V.a.sliderWrapper},D?p.a.createElement("button",{className:V.a.prevButton,onClick:function(){g((function(e){return e-k<0?o.length-k:e-k}))}},p.a.createElement("svg",{fill:"none",width:"25",height:"25",viewBox:"0 0 16 16",className:" cloemx-search-2-x-caretIcon cloemx-search-2-x-caretIcon--searcher",xmlns:"http://www.w3.org/2000/svg"},p.a.createElement("use",{href:"#nav-thin-caret--left"}))):p.a.createElement(p.a.Fragment,null),p.a.createElement("div",{className:V.a.sliderContainer,style:{transform:"translateX(-".concat(v*(100/k),"%)")}},o.map((function(e,r){var o=B.a.mapCatalogProductToProductSummary(e),n=r>=v&&r0&&p.a.createElement(P.Link,{query:"map=ft&_q=".concat(t),params:{term:t},page:h||"store.search",className:V.a.tileListSeeMore,onClick:function(){return l(t)}},p.a.createElement(d.FormattedMessage,{id:"store/seeMore",values:{count:a}}))))):null};var z=r(6),U=r.n(z),Q=function(e){var t;return(null===(t=e.item)||void 0===t?void 0:t.attributes)?p.a.createElement("ul",{className:U.a.itemListSubList},e.item.attributes.map((function(t,r){return p.a.createElement("li",{key:r,className:"".concat(U.a.itemListSubItem," c-on-base pointer"),onMouseOver:function(r){return e.onMouseOver(r,t)},onFocus:function(r){return e.onMouseOver(r,t)},onMouseOut:function(){return e.onMouseOut()},onBlur:function(){return e.onMouseOut()}},p.a.createElement(P.Link,{className:"".concat(U.a.itemListSubItemLink," c-on-base"),to:"/".concat(e.item.value,"/").concat(t.value),query:"map=ft,".concat(t.key),onClick:function(){e.closeModal(),e.onItemClick(t.label,r)}},t.label))}))):null};function G(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,o=Object(u.a)(e);if(t){var n=Object(u.a)(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return Object(l.a)(this,r)}}var K=function(e){Object(i.a)(r,e);var t=G(r);function r(){var e;return Object(c.a)(this,r),(e=t.apply(this,arguments)).state={currentTimeoutId:null},e.handleMouseOver=function(t,r){if(t.stopPropagation(),!e.state.currentTimeoutId){var o=setTimeout((function(){e.props.onItemHover&&e.props.onItemHover(r),e.setState({currentTimeoutId:null})}),100);e.setState({currentTimeoutId:o})}},e.handleMouseOut=function(){var t=e.state.currentTimeoutId;t&&(clearTimeout(t),e.setState({currentTimeoutId:null}))},e}return Object(s.a)(r,[{key:"render",value:function(){var e=this;if(0===this.props.items.length&&!this.props.showTitleOnEmpty)return null;var t=this.props.modifier?U.a["itemList--".concat(this.props.modifier)]:"";return m.createElement("article",{className:"".concat(U.a.itemList," ").concat(t)},this.props.showTitle?m.createElement("p",{className:"".concat(U.a.itemListTitle," c-on-base")},this.props.title):null,m.createElement("ol",{className:U.a.itemListList},this.props.items.map((function(t,r){var o;return m.createElement("li",{key:t.value,className:"".concat(U.a.itemListItem),onMouseOver:function(r){return e.handleMouseOver(r,t)},onFocus:function(r){return e.handleMouseOver(r,t)},onMouseOut:function(){return e.handleMouseOut()},onBlur:function(){return e.handleMouseOut()}},m.createElement(P.Link,{page:null!==(o=e.props.customPage)&&void 0!==o?o:"store.search",params:{term:t.value},query:"map=ft&_q=".concat(t.value),onClick:function(){return e.props.onItemClick(t.value,r)},className:U.a.itemListLink},t.icon?m.createElement("span",{className:U.a.itemListIcon},t.icon):null,t.prefix?m.createElement("span",{className:U.a.itemListPrefix},t.prefix):null,m.createElement("span",{className:"".concat(U.a.itemListLinkTitle," c-on-base")},t.label)),m.createElement(Q,{item:t,onMouseOver:e.handleMouseOver,onMouseOut:e.handleMouseOut,closeModal:e.props.closeModal,onItemClick:e.props.onItemClick}))}))))}}]),r}(m.Component),J=r(34);var X;function $(e,t,r){return function(o,n){e({page:t,event:"autocomplete",eventType:r,search:{term:o,position:n}})}}function Y(e,t,r,o,n){try{e({event:"autocomplete",eventType:X.Search,search:{operator:t,misspelled:r,text:decodeURI(n),match:o}})}catch(a){e({event:"autocomplete",eventType:X.Search,search:{operator:t,misspelled:r,text:n,match:o}})}}!function(e){e.ProductClick="product_click",e.SearchSuggestionClick="search_suggestion_click",e.TopSearchClick="top_search_click",e.HistoryClick="history_click",e.Search="search",e.SeeAllClick="see_all_click"}(X||(X={}));var Z=function(){var e=Object(a.a)(n.a.mark((function e(t){var r,o,a,c,s,i,l;return n.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(c=new Headers).append("Content-Type","application/json"),s={method:"GET",headers:c,redirect:"follow"},e.next=5,fetch("".concat(t||"","/api/sessions?items=public.shippingOption"),s);case 5:return i=e.sent,e.next=8,i.json();case 8:if(l=e.sent,null===(a=null===(o=null===(r=null==l?void 0:l.namespaces)||void 0===r?void 0:r.public)||void 0===o?void 0:o.shippingOption)||void 0===a?void 0:a.value){e.next=11;break}return e.abrupt("return",null);case 11:return e.abrupt("return",JSON.parse(l.namespaces.public.shippingOption.value));case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function ee(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,o=Object(u.a)(e);if(t){var n=Object(u.a)(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return Object(l.a)(this,r)}}var te;!function(e){e.Horizontal="HORIZONTAL",e.Vertical="VERTICAL"}(te||(te={}));var re,oe=b.a.ProductListProvider,ne=function(e){Object(i.a)(u,e);var t,r,o,l=ee(u);function u(e){var t;return Object(c.a)(this,u),(t=l.call(this,e)).state={topSearchedItems:[],history:[],products:[],suggestionItems:[],totalProducts:0,queryFromHover:{},dynamicTerm:"",isProductsLoading:!1,currentHeightWhenOpen:0,isCloseModal:!1},t.handleItemHover=function(e){"groupValue"in e?(t.setState({dynamicTerm:e.groupValue,queryFromHover:{key:e.key,value:e.value}}),t.updateProducts(e.groupValue)):(t.setState({dynamicTerm:e.value,queryFromHover:{key:void 0,value:void 0}}),t.updateProducts(e.value))},t.getProductLayout=function(){var e=t.props,r=e.productLayout,o=e.isMobile;return void 0!==r?r:o?te.Horizontal:te.Vertical},t.client=new T.a(t.props.client),t.autocompleteRef=p.a.createRef(),t.isIOS=navigator&&!!navigator.userAgent.match(/(iPod|iPhone|iPad)/),t}return Object(s.a)(u,[{key:"fitAutocompleteInWindow",value:function(){if(window&&this.autocompleteRef.current&&this.props.isMobile&&!this.isIOS){var e=window.innerHeight,t=this.autocompleteRef.current.getBoundingClientRect().y,r=this.autocompleteRef.current.offsetHeight,o=r-(t+r-e);this.autocompleteRef.current.style.maxHeight="".concat(o,"px")}}},{key:"addEvents",value:function(){window.addEventListener("resize",S()(this.fitAutocompleteInWindow.bind(this),100))}},{key:"componentDidMount",value:function(){this.updateTopSearches(),this.updateHistory(),this.addEvents()}},{key:"shouldUpdate",value:function(e){return e.inputValue!==this.props.inputValue||!e.isOpen&&this.props.isOpen}},{key:"addTermToHistory",value:function(){var e=window.location.href.split("_q=");if(e[1]){var t=e[1].split("&")[0];try{return this.client.prependSearchHistory(decodeURI(t))}catch(e){return this.client.prependSearchHistory(t)}}}},{key:"closeModal",value:function(){var e=this;this.props.closeMenu&&(this.props.closeMenu(),setTimeout((function(){e.handleAutomaticClick()}),100),setTimeout((function(){e.handleAutomaticClick()}),200))}},{key:"handleAutomaticClick",value:function(){for(var e=0;e<10;){var t=Math.random()*window.innerWidth,r=Math.random()*window.innerHeight,o=document.elementFromPoint(t,r);if(o&&"A"!==o.tagName&&"IMG"!==o.tagName){var n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0,clientX:t,clientY:r});return void o.dispatchEvent(n)}e++}}},{key:"componentDidUpdate",value:function(e){var t=this;if(this.shouldUpdate(e)){this.addTermToHistory(),this.fitAutocompleteInWindow();var r=this.props.inputValue;this.setState({dynamicTerm:r,queryFromHover:void 0}),null===r||""===r?(this.updateTopSearches(),this.updateHistory(),this.setState({suggestionItems:[],products:[]})):this.updateSuggestions().then((function(){return t.fitAutocompleteInWindow(),t.updateProducts(r)})).then((function(){return t.fitAutocompleteInWindow()}))}}},{key:"highlightTerm",value:function(e,t){var r=e.split(t);return p.a.createElement(p.a.Fragment,null,r.map((function(e,o){return p.a.createElement(p.a.Fragment,null,e,o!==r.length-1?p.a.createElement("span",{className:"b"},t):null)})))}},{key:"updateSuggestions",value:(o=Object(a.a)(n.a.mark((function e(){var t,r,o,a,c,s,i=this;return n.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.client.suggestionSearches(this.props.inputValue);case 2:t=e.sent,r=t.data.autocompleteSearchSuggestions.searches,o=this.props.maxSuggestedTerms,a=void 0===o?5:o,c=r.slice(0,a).map((function(e){var t=e.attributes||[];return{term:e.term,attributes:t.map((function(t){return{label:t.labelValue,value:t.value,link:"/".concat(e.term,"/").concat(t.value,"/?map=ft,").concat(t.key),groupValue:e.term,key:t.key}}))}})),s=c.map((function(e){return{label:i.highlightTerm(e.term.toLowerCase(),i.props.inputValue.toLocaleLowerCase()),value:e.term,groupValue:e.term,link:"/".concat(e.term,"?map=ft"),attributes:e.attributes}})),this.setState({suggestionItems:s});case 8:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"updateProducts",value:(r=Object(a.a)(n.a.mark((function e(t){var r,o,a,c,s,i,l,u,m,p,h,d,x,f,v,g,y,b,k,E,w;return n.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=t,a=this.props,c=a.__unstableProductOrigin,s=a.__unstableProductOriginVtex,i=void 0!==s&&s,l=a.simulationBehavior,u=void 0===l?"default":l,m=a.hideUnavailableItems,p=void 0!==m&&m,h=a.orderBy,d=this.state.queryFromHover,o){e.next=6;break}return this.setState({products:[],totalProducts:0}),e.abrupt("return");case 6:return c&&console.warn("The prop `__unstableProductOrigin` has been deprecated. Use the boolean prop `__unstableProductOriginVtex` instead."),this.setState({isProductsLoading:!0}),e.next=10,Z(this.props.runtime.rootPath);case 10:return x=e.sent,f=null!==(r=null==x?void 0:x.map((function(e){return e.value})))&&void 0!==r?r:[],e.next=14,this.client.suggestionProducts(o,d?d.key:void 0,d?d.value:void 0,"VTEX"===c||i,u,p,h,this.props.maxSuggestedProducts||3,f);case 14:v=e.sent,d||(g=v.data.productSuggestions,y=g.count,b=g.operator,k=g.misspelled,Y(this.props.push,b,k,y,o)),this.setState({isProductsLoading:!1}),E=v.data.productSuggestions,w=E.products.slice(0,this.getProductCount()),this.setState({products:w,totalProducts:E.count});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"updateTopSearches",value:(t=Object(a.a)(n.a.mark((function e(){var t,r,o,a,c;return n.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.client.topSearches();case 2:t=e.sent,r=t.data.topSearches.searches,o=this.props.maxTopSearches,a=void 0===o?10:o,c=r.slice(0,a).map((function(e,t){return{prefix:p.a.createElement(p.a.Fragment,null,"".concat(t+1),p.a.createElement(d.FormattedMessage,{id:"store/ordinalNumber"})),value:e.term,label:e.term,link:"/".concat(e.term,"?map=ft")}})),this.setState({topSearchedItems:c});case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"updateHistory",value:function(){var e=this.client.searchHistory().slice(0,this.props.maxHistory||5).map((function(e){return{label:(t=e,t.replace(/\$2F/gi,"/")),value:e,link:"/".concat(e,"?map=ft"),icon:p.a.createElement(g.a,null)};var t}));this.setState({history:e})}},{key:"renderSuggestions",value:function(){var e=this,t=!!this.state.suggestionItems&&this.state.suggestionItems.length>0,r=t?p.a.createElement(d.FormattedMessage,{id:"store/suggestions"}):p.a.createElement(d.FormattedMessage,{id:"store/emptySuggestion"});return p.a.createElement(K,{title:r,items:this.state.suggestionItems||[],modifier:"suggestion",showTitle:!t||!this.props.hideTitles,onItemHover:this.handleItemHover,showTitleOnEmpty:0!==this.props.maxSuggestedTerms,onItemClick:function(t,r){$(e.props.push,e.props.runtime.page,X.SearchSuggestionClick)(t,r)},customPage:this.props.customPage,closeModal:function(){return e.closeModal()}})}},{key:"contentWhenQueryIsEmpty",value:function(){var e=this;return p.a.createElement("div",{className:I.a["history-and-top-wrapper"],style:{flexDirection:this.props.historyFirst?"row-reverse":"row"}},!this.props.isMobile||this.props.isMobile&&!this.props.historyFirst||0===this.state.history.length?p.a.createElement(K,{modifier:"top-search",title:p.a.createElement(d.FormattedMessage,{id:"store/topSearches"}),items:this.state.topSearchedItems||[],showTitle:!this.props.hideTitles,onItemClick:function(t,r){$(e.props.push,e.props.runtime.page,X.TopSearchClick)(t,r)},customPage:this.props.customPage,closeModal:function(){return e.closeModal()}}):null)}},{key:"contentWhenQueryIsNotEmpty",value:function(){var e=this.state,t=e.products,r=e.totalProducts,o=e.isProductsLoading,n=this.props,a=n.hideTitles,c=n.push,s=n.runtime,i=n.inputValue,l=i.replace(/\//gi,"$2F");return p.a.createElement(p.a.Fragment,null,this.renderSuggestions(),p.a.createElement(W,{term:l||"",customPage:this.props.customPage,shelfProductCount:this.getProductCount(),title:p.a.createElement(d.FormattedMessage,{id:"store/suggestedProducts",values:{term:i}}),products:t||[],showTitle:!a,totalProducts:r||0,layout:this.getProductLayout(),isLoading:o,onProductClick:function(e,t,r){!function(e,t){return function(r,o,n){return e({page:t,event:"autocomplete",eventType:X.ProductClick,product:{productId:r,position:o},term:n})}}(c,s.page)(e,t,r)},onSeeAllClick:function(e){!function(e,t){return function(r){return e({page:t,event:"autocomplete",eventType:X.SeeAllClick,search:{term:r}})}}(c,s.page)(e)},HorizontalProductSummary:this.props.HorizontalProductSummary}))}},{key:"renderContent",value:function(){var e=this.props.inputValue.trim();return e&&""!==e?this.contentWhenQueryIsNotEmpty():this.contentWhenQueryIsEmpty()}},{key:"hasContent",value:function(){var e=this.state,t=e.topSearchedItems,r=e.suggestionItems,o=e.history,n=e.products;return t.length>0||r.length>0||o.length>0||n.length>0}},{key:"getProductCount",value:function(){var e=this.props,t=e.customBreakpoints,r=e.isMobile,o=e.maxSuggestedProducts,n=void 0===o?3:o;if(!window||r||!t)return n;var a=window.innerWidth;return t.md&&t.lg&&t.xlg?a>=t.xlg.width?t.xlg.maxSuggestedProducts:a>=t.lg.width?t.lg.maxSuggestedProducts:a>=t.md.width?t.md.maxSuggestedProducts:n:n}},{key:"render",value:function(){var e=this,t=this.props.isOpen&&this.hasContent()?"":I.a["biggy-js-container--hidden"],r=!this.props.inputValue.trim();return p.a.createElement("div",{className:I.a["biggy-autocomplete-wrapper"],style:{width:this.props.autocompleteWidth?"".concat(this.props.autocompleteWidth,"vw"):void 0}},p.a.createElement("section",{ref:this.autocompleteRef,className:"".concat(I.a["biggy-autocomplete"]," ").concat(this.props.isMobile?this.props.isMobile&&this.state.isCloseModal?t:"":t," w-100"),style:{flexDirection:this.getProductLayout()===te.Horizontal?"column":"row"}},p.a.createElement(oe,{listName:"autocomplete-result-list"},this.renderContent(),this.props.isMobile?p.a.createElement("button",{onClick:function(){e.closeModal(),e.setState({isCloseModal:!0})},className:I.a["close-btn"]},p.a.createElement(f.a,null)):null),r?p.a.createElement(C,null):p.a.createElement(p.a.Fragment,null)))}}]),u}(p.a.Component),ae=Object(L.withPixel)(E()(Object(h.withApollo)((re=ne,function(e){return p.a.createElement(re,Object(J.a)({},e,{runtime:Object(P.useRuntime)()}))}))));t.default=ae}],[[38,"common"]]]); }], document.currentScript.dataset.index)