var j=Object.defineProperty;var J=(f,g,w)=>g in f?j(f,g,{enumerable:!0,configurable:!0,writable:!0,value:w}):f[g]=w;var o=(f,g,w)=>(J(f,typeof g!="symbol"?g+"":g,w),w);(function(){"use strict";const f="";function g(t,n){typeof t=="string"&&(t=t.replace(".",""));let e="";const a=/\{\{\s*(\w+)\s*\}\}/,s=n||this.money_format;function l(r,d){return typeof r>"u"?d:r}function i(r,d,u=".",p=","){if(d=l(d,2),u=l(u,","),p=l(p,"."),isNaN(r)||r==null)return 0;r=(r/100).toFixed(d);const h=r.split("."),T=h[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+u),S=h[1]?p+h[1]:"";return T+S}switch(s.match(a)[1]){case"amount":e=i(t,2);break;case"amount_no_decimals":e=i(t,0);break;case"amount_with_comma_separator":e=i(t,2,".",",");break;case"amount_no_decimals_with_comma_separator":e=i(t,0,".",",");break}return s.replace(a,e)}var w=(t=>(t.ADDED_WITH_UPSELLEANDOLA="_AddedWithUpselleandola",t.UPSELLEANDOLA_WIDGET_SETTINGS_ID="_UpselleandolaWidgetSettingsID",t.UPSELLEANDOLA_WIDGET_SETTINGS_NAME="_UpselleandolaWidgetSettingsName",t.CART_CROSS_SELL_TRACKING="_UpselleandolaCrossSellTracking",t.CART_CROSS_SELL_IDS="_UpselleandolaCrossSellIds",t))(w||{}),E=(t=>(t.TARGET_FIRST_CHILD="TARGET_FIRST_CHILD",t.TARGET_LAST_CHILD="TARGET_LAST_CHILD",t.TARGET_BEFORE="TARGET_BEFORE",t.TARGET_AFTER="TARGET_AFTER",t))(E||{}),A=(t=>(t.BELOW_GALLERY="BELOW_GALLERY",t.BELOW_ADD_TO_CART="BELOW_ADD_TO_CART",t.ABOVE_ADD_TO_CART="ABOVE_ADD_TO_CART",t))(A||{}),C=(t=>(t.STORAGE_KEY="HACIENDOLA_UPSELLEANDOLA_ANALYTICS",t.CART_TOKEN_HISTORY_KEY="CART_TOKEN_HISTORY",t.CART_CURRENT_TOKEN_KEY="CART",t.UPSELLEANDOLA_CROSS_SELLING="UPSELLEANDOLA_CROSS_SELLING",t))(C||{});const k=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,x=/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i,P=/android|ipad|playbook|silk/i;function R(){const t=navigator.userAgent||navigator.vendor||window.opera;return k.test(t)||x.test(t.substr(0,4))}function L(){return I()||N()}function D(){return R()||L()}function I(){const t=navigator.userAgent||navigator.vendor||window.opera;return P.test(t)}function N(){return navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)}function y(){return!D()}class $ extends HTMLElement{constructor(){super();o(this,"product");o(this,"recommendations");o(this,"settings");o(this,"button");o(this,"buttonText");o(this,"productsWrapper");o(this,"loadingOverlay");o(this,"errorsWrapper");o(this,"totalsPrice");o(this,"totalsCompareAtPrice");o(this,"deviceType");o(this,"createViewedObserver",()=>{let e=null;new IntersectionObserver((a,s)=>{a[0].isIntersecting?e=setTimeout(()=>{this.registerAnalytic("VIEWED"),s.unobserve(this)},2e3):e&&clearTimeout(e)},{rootMargin:"0px 0px -200px 0px"}).observe(this)});o(this,"registerAnalytic",e=>{const a={action:"registerAnalytic",productId:window.HACIENDOLA.UPSELLEANDOLA.productId,widgetSettingsId:this.settings.widgetSettingsId,deviceType:this.deviceType,eventType:e,themeId:Shopify.theme.theme_store_id};window.HACIENDOLA.UPSELLEANDOLA.analytics.registerAnalytic(a)});o(this,"generateStyles",()=>{const e=this.settings.widgetSettingsJson,a=document.createElement("style");a.type="text/css",a.innerHTML=`
.haciendola-upselleandola__wrapper {
background: ${e.widgetBackgroundColor};
border-color: ${e.widgetBorderColor};
border-radius: ${e.widgetBorderRadius}px;
border-width: ${e.widgetBorderWidth}px;
border-style: ${e.widgetBorderStyle};
}
.haciendola-upselleandola__title {
color: ${e.titleColor};
font-size: ${e.titleFontSizeDesktop}px;
}
.haciendola-upselleandola__product-card {
background: ${e.cardBackgroundColor};
border-color: ${e.cardBorderColor};
border-radius: ${e.cardBorderRadius}px;
border-style: ${e.cardBorderStyle};
border-width: ${e.cardBorderWidth}px;
--haciendola-upselleandola-checkbox-color: ${e.productCheckboxColor||"#09f"};
}
.haciendola-upselleandola__button {
background: ${e.buttonBackgroundColor};
border-color: ${e.buttonBorderColor};
border-radius: ${e.buttonBorderRadius}px;
border-style: ${e.buttonBorderStyle};
border-width: ${e.buttonBorderWidth}px;
}
.haciendola-upselleandola__button__text {
font-weight: ${e.buttonFontWeight};
color: ${e.buttonTextColor};
}
.haciendola-upselleandola__button:hover {
background: ${e.buttonBackgroundColorHover};
border-color: ${e.buttonBorderColorHover};
}
.haciendola-upselleandola__button:hover .haciendola-upselleandola__button__text {
color: ${e.buttonTextColorHover};
}
.haciendola-upselleandola__product-card__title {
color: ${e.productNameColor};
font-weight: ${e.productNameFontWeight};
}
.haciendola-upselleandola__product-card__price {
color: ${e.productPriceColor};
font-weight: ${e.productPriceFontWeight};
}
.haciendola-upselleandola__product-card__compare-price, .haciendola-upselleandola__totals__compare-price {
color: ${e.productComparePriceColor};
font-weight: ${e.productComparePriceFontWeight};
}
.haciendola-upselleandola__loading-overlay {
background: ${e.loadingOverlayColor};
}
.haciendola-upselleandola__loading-overlay.loading-finish .haciendola-upselleandola__loading-overlay__checkmark path {
fill: ${e.loadingCheckmarkColor};
}
.haciendola-upselleandola__loading-overlay__loading:after {
border: 6px solid ${e.loadingSpinnerColor};
border-color: ${e.loadingSpinnerColor} transparent ${e.loadingSpinnerColor} transparent;
}
.haciendola-upselleandola__product-card img {
${e.widgetImageSettings==="DEFAULT"?"width: auto;":""}
}
${e.extraCss}
`,this.parentNode.insertBefore(a,this.nextSibling)});o(this,"renderInitialState",()=>{this.innerHTML=`
${this.settings.widgetSettingsJson.title}
`,this.productsWrapper=this.querySelector(".haciendola-upselleandola__products-wrapper"),this.errorsWrapper=this.querySelector(".haciendola-upselleandola__errors-wrapper")});o(this,"updateTotals",()=>{let e=0,a=0,s=0;[...this.productsWrapper.children].forEach(i=>{i.productChecked&&(s++,e+=+i.selectedVariant.price,a+=i.selectedVariant.compareAtPrice!==null?+i.selectedVariant.compareAtPrice:+i.selectedVariant.price)}),this.totalsCompareAtPrice.innerText="",this.totalsPrice.innerText="",a>e&&(this.totalsCompareAtPrice.innerText=g(a*100,window.HACIENDOLA.SHOP_MONEY_FORMAT)),this.totalsPrice.innerText=g(e*100,window.HACIENDOLA.SHOP_MONEY_FORMAT);let l=this.settings.widgetSettingsJson.buttonText;this.buttonText.innerText=l.replace("(P)",String(s)),s===0?this.button.disabled=!0:this.button.disabled=!1});o(this,"renderComponent",()=>{this.renderInitialState();const e=document.createElement("upselleandola-widget-product-card");e.productJson=this.product,e.linkToProduct=!1,this.productsWrapper.appendChild(e);let a=0;for(const l of this.recommendations)if(a
${this.settings.widgetSettingsJson.totalsText}
`,this.productsWrapper.appendChild(s),this.button=this.querySelector(".haciendola-upselleandola__button"),this.buttonText=this.querySelector(".haciendola-upselleandola__button__text"),this.loadingOverlay=this.querySelector(".haciendola-upselleandola__loading-overlay"),!!this.settings.widgetSettingsJson.buttonExtraClasses&&this.settings.widgetSettingsJson.buttonExtraClasses!==""&&this.button.classList.add(...this.settings.widgetSettingsJson.buttonExtraClasses.split(" ")),this.totalsCompareAtPrice=this.querySelector(".haciendola-upselleandola__totals__compare-price"),this.totalsPrice=this.querySelector(".haciendola-upselleandola__totals__price"),this.updateTotals(),this.button.addEventListener("click",this.handleAddToCartButtonClicked),this.registerAnalytic("RENDERED"),this.createViewedObserver()});o(this,"setComponentHandlers",()=>{this.querySelectorAll("select,input[type='checkbox']").forEach(a=>a.addEventListener("change",this.updateViewOnChange)),this.querySelectorAll("upselleandola-widget-product-card").forEach(a=>{a.linkToProduct})});o(this,"updateViewOnChange",()=>{this.updateTotals()});o(this,"handleAddToCartButtonClicked",async e=>{if(this.loadingOverlay.classList.contains("haciendola-upselleandola__loading-overlay--loading"))return;e.preventDefault(),e.stopPropagation();const a=this.productsWrapper.querySelectorAll("input[type='checkbox']:checked");this.loadingOverlay.classList.add("haciendola-upselleandola__loading-overlay--loading");const s="/cart/add.js",l=await fetch(s).then(d=>d.json());let i=[];const r={items:[...a].map(d=>{const u=d.closest("upselleandola-widget-product-card"),p={};return i=[...i,u.selectedVariant.id],{id:u.selectedVariant.id,quantity:1,properties:p}}),attributes:{...l.attributes,[w.ADDED_WITH_UPSELLEANDOLA]:i.join(",")}};try{const d=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});d.ok?(window.HACIENDOLA.UPSELLEANDOLA.analytics.addUpsellTrack(r.items.map(u=>u.id)),this.registerAnalytic("CLICKED"),this.handleAfterAddToCartSuccess()):await this.handleAfterAddToCartErrors(d)}catch(d){console.log(d)}});o(this,"handleAfterAddToCartErrors",async e=>{const a=await e.json(),s=await fetch("/cart.js").then(d=>d.json()),l=s.attributes._AddedWithUpselleandola.split(","),i=s.items;let r=0;for(let d=0;dh.json())).items[r];if(l.includes(p.id.toString())){const h=l.indexOf(p.id.toString());l.splice(h,1);const T=p.quantity-1,S={id:p.key,quantity:T};let c=!1;for(;!c;)try{await fetch("/cart/change.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)}),c=!0}catch(m){console.log(m)}T!==0&&r++}else r++}if(l.length!==0)if((await fetch("/cart.js").then(u=>u.json())).items.length===0){const u={attributes:{_AddedWithUpselleandola:""}};await fetch("/cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)})}else{const p={attributes:{_AddedWithUpselleandola:l.join(",")}};await fetch("/cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)})}else{const d={attributes:{_AddedWithUpselleandola:""}};await fetch("/cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)})}this.loadingOverlay.classList.remove("haciendola-upselleandola__loading-overlay--loading"),this.errorsWrapper.classList.add("show-error"),this.errorsWrapper.innerHTML=`${a.description}`});o(this,"handleAfterAddToCartSuccess",()=>{switch(this.loadingOverlay.classList.add("loading-finish"),this.settings.widgetSettingsJson.afterAddToCartAction){case"REDIRECT_TO_CART":window.location.href="/cart";break;case"REDIRECT_TO_CHECKOUT":window.location.href="/checkout";break;case"STAY_IN_PRODUCT_PAGE":break;case"REFRESH":window.location.reload();break}})}async connectedCallback(){this.product.availableForSale&&(this.deviceType=y()?"DESKTOP":L()?"TABLET":"MOBILE",this.generateStyles(),this.renderComponent(),this.setComponentHandlers())}}customElements.get("upselleandola-widget")===void 0&&customElements.define("upselleandola-widget",$);class H extends HTMLElement{constructor(){super();o(this,"productJson");o(this,"selectedVariant");o(this,"variantOptions");o(this,"productTitle");o(this,"productImage");o(this,"productPrice");o(this,"productComparePrice");o(this,"productVariantSelect");o(this,"productChecked",!0);o(this,"linkToProduct",!0);o(this,"initializeState",()=>{var e,a;if(this.selectedVariant=this.productJson.variants.find(s=>s.availableForSale),this.selectedVariant||(this.selectedVariant=this.productJson.variants[0]),this.productJson.variants.length>1){this.variantOptions=[];for(const s of this.productJson.variants){let l=s.option1;s.option2!==null&&(l+=" - "+s.option2),s.option3!==null&&(l+=" - "+s.option3);const i=(e=this.productJson.images.find(r=>r.id===s.image_id))==null?void 0:e.src;this.variantOptions.push({value:s.id,label:l,imgSrc:i||((a=this.productJson.images[0])==null?void 0:a.src)})}}});o(this,"updateTitle",()=>{this.productTitle.innerText=this.productJson.title});o(this,"updateImage",()=>{if(this.productJson.variants.length>1){const e=this.variantOptions.find(a=>a.value===this.selectedVariant.id);e.imgSrc&&(this.productImage.src=e.imgSrc)}else this.productImage.src=this.productJson.images.length>0?this.productJson.images[0].src:""});o(this,"updatePrice",()=>{+this.selectedVariant.compare_at_price>+this.selectedVariant.price?this.productComparePrice.innerText=g(+this.selectedVariant.compare_at_price*100,window.HACIENDOLA.SHOP_MONEY_FORMAT):this.productComparePrice.innerText="",this.productPrice.innerText=g(+this.selectedVariant.price*100,window.HACIENDOLA.SHOP_MONEY_FORMAT)});o(this,"renderComponent",()=>{var a;this.classList.add("haciendola-upselleandola__product-card");let e=`
`;this.productJson.variants.length>1&&(e+='
"),e+=`
`,this.innerHTML=e,this.productTitle=this.querySelector(".haciendola-upselleandola__product-card__title"),this.productComparePrice=this.querySelector(".haciendola-upselleandola__product-card__compare-price"),this.productPrice=this.querySelector(".haciendola-upselleandola__product-card__price"),this.productImage=this.querySelector(".haciendola-upselleandola__product-card__image"),this.productJson.variants.length>1&&(this.productVariantSelect=this.querySelector(".haciendola-upselleandola__product-card__select"),this.productVariantSelect.addEventListener("change",this.handleProductVariantSelectChange)),this.linkToProduct&&(this.productImage.addEventListener("click",this.handleCrossNavigation),this.productTitle.addEventListener("click",this.handleCrossNavigation)),(a=this.querySelector('input[type="checkbox"]'))==null||a.addEventListener("change",this.handleProductCheckboxChange),this.updateTitle(),this.updateImage(),this.updatePrice(),this.handleUrlVariantChange()});o(this,"handleCrossNavigation",()=>{fetch("/cart.js").then(e=>e.json()).then(e=>{console.log("cargamos el carrito",e);const a=e.attributes,s=String(a[w.CART_CROSS_SELL_TRACKING]||"");console.log(s),a[w.CART_CROSS_SELL_TRACKING]=s.includes(this.productJson.id)?s:`${s}, ${this.productJson.id}`,fetch("/cart/update.js",{method:"POST",headers:{"Content-Type":"application/json;"},body:JSON.stringify({attributes:a})}).then(()=>{window.location.href="/products/"+this.productJson.handle})})});o(this,"handleProductCheckboxChange",e=>{this.productChecked=e.target.checked,e.target.checked?this.productImage.classList.remove("grayscale"):this.productImage.classList.add("grayscale")});o(this,"handleProductVariantSelectChange",e=>{this.updateProductVariant(e.target.value)});o(this,"updateProductVariant",e=>{const a=this.productJson.variants.find(s=>s.id==e);a&&(this.selectedVariant=a,this.updateTitle(),this.updateImage(),this.updatePrice())});o(this,"handleUrlVariantChange",()=>{const e=document.querySelector(".haciendola-upselleandola__product-card"),a=e==null?void 0:e.querySelector(".haciendola-upselleandola__product-card__select"),s=()=>{let r=new URLSearchParams(window.location.search).get("variant");r&&(a.value=r,this.updateProductVariant(r))},l={apply:function(i,r,d){i.apply(r,d),setTimeout(s,0)}};window.history.pushState=new Proxy(window.history.pushState,l),window.history.replaceState=new Proxy(window.history.replaceState,l),s()})}connectedCallback(){this.initializeState(),this.renderComponent()}}customElements.get("upselleandola-widget-product-card")===void 0&&customElements.define("upselleandola-widget-product-card",H);const O=(t,n,e)=>{switch(e){case E.TARGET_FIRST_CHILD:t.prepend(n);break;case E.TARGET_LAST_CHILD:t.appendChild(n);break;case E.TARGET_BEFORE:t.parentNode.insertBefore(n,t);break;case E.TARGET_AFTER:t.parentNode.insertBefore(n,t.nextSibling);break}},B=(t,n)=>{const e=Object.keys(n).map(a=>`${a}=${n[a]}`).join("&");return`${t}?${e}`};class V{constructor(){o(this,"state");o(this,"init",async()=>{const n=sessionStorage.getItem(C.STORAGE_KEY);this.state=n==null?{crossTrack:[],upsellTrack:[]}:JSON.parse(n),this.persistState(),await this.registerAnalytic({eventType:"CROSS",action:"registerAnalytic"})});o(this,"persistState",()=>{sessionStorage.setItem(C.STORAGE_KEY,JSON.stringify(this.state)),console.log(this.state.cartToken)});o(this,"addCrossTrack",n=>{this.state.crossTrack.findIndex(e=>e===n)===-1&&this.state.crossTrack.push(n),this.persistState()});o(this,"addUpsellTrack",n=>{n.forEach(e=>{this.state.upsellTrack.findIndex(a=>a===e)===-1&&this.state.upsellTrack.push(e)}),this.persistState()});o(this,"registerAnalytic",async n=>{const a=await(await fetch("/cart.json")).json();n.cartToken=a.token,n.crossTrack=this.state.crossTrack.join(","),n.upsellTrack=this.state.upsellTrack.join(",");const s=Object.keys(n).map(i=>`${i}=${n[i]}`),l=`${window.HACIENDOLA.UPSELLEANDOLA.baseUrl}?${s.join("&")}`;await fetch(l).then()});this.init()}}(async function(){var t;window.HACIENDOLA=window.HACIENDOLA||{},window.HACIENDOLA.UPSELLEANDOLA=window.HACIENDOLA.UPSELLEANDOLA||{productId:0,baseUrl:""},window.HACIENDOLA.UPSELLEANDOLA.baseUrl="/apps/upselleandola/",window.HACIENDOLA.UPSELLEANDOLA.analytics=new V;try{if(!window.location.pathname.includes("/products/"))return;const e=await(await fetch(B(window.HACIENDOLA.UPSELLEANDOLA.baseUrl,{action:"getProductRecommendations",productId:window.HACIENDOLA.UPSELLEANDOLA.productId,themeId:Shopify.theme.theme_store_id,themeName:window.BOOMR.themeName,themeVersion:window.BOOMR.themeVersion}))).json();if(((t=e.recommendations)==null?void 0:t.length)===0){console.log("Este producto no tiene recomendaciones a\xFAn");return}const{widgetTargetPlacement:a,widgetTargetSelector:s,moneyFormat:l,widgetTargetPlacementMobile:i,widgetTargetSelectorMobile:r,defaultPlacementDesktop:d,defaultPlacementMobile:u}=e.settings.widgetSettingsJson,p=y();window.HACIENDOLA.SHOP_MONEY_FORMAT=l.replace(/<\/?[^>]+(>|$)/g,"");const h=document.createElement("upselleandola-widget");h.product=e.product,h.recommendations=e.recommendations.sort((c,m)=>c.countm.count?-1:0),h.settings=e.settings,p||h.classList.add("haciendola-upselleandola__mobile-view");const T=[...document.querySelectorAll("[data-upselleandola]")];if(T.length>0){let c=T[0];if(p){const m=T.find(_=>_.getAttribute("data-upselleandola")==="DESKTOP");c=m||c}else{const m=T.find(_=>_.getAttribute("data-upselleandola")==="MOBILE");c=m||c}c.parentNode.replaceChild(h,c)}else{const c=p?s:r,m=p?a:i;if(c===""){let _="",b="";if(p)switch(d){case A.BELOW_GALLERY:_=e.defaults.belowGallerySelector,b=e.defaults.belowGalleryTargetPlacement;break;case A.BELOW_ADD_TO_CART:_=e.defaults.belowAddToCartSelector,b=e.defaults.belowAddToCartTargetPlacement;break;case A.ABOVE_ADD_TO_CART:_=e.defaults.aboveAddToCartSelector,b=e.defaults.aboveAddToCartTargetPlacement;break}else switch(u){case A.BELOW_GALLERY:_=e.defaults.belowGallerySelector,b=e.defaults.belowGalleryTargetPlacement;break;case A.BELOW_ADD_TO_CART:_=e.defaults.belowAddToCartSelector,b=e.defaults.belowAddToCartTargetPlacement;break;case A.ABOVE_ADD_TO_CART:_=e.defaults.aboveAddToCartSelector,b=e.defaults.aboveAddToCartTargetPlacement;break}const v=document.querySelectorAll(_);if(v.length===0)console.log("No se encontr\xF3 el target de inserci\xF3n",c);else if(v.length>1)console.log("El selector devolvi\xF3 m\xFAltiples objetivos",c);else{const U=v[0];O(U,h,b)}}else{const _=document.querySelectorAll(c);if(_.length===0)console.log("No se encontr\xF3 el target de inserci\xF3n",c);else if(_.length>1)console.log("El selector devolvi\xF3 m\xFAltiples objetivos",c);else{const b=_[0];O(b,h,m)}}}const S=h.querySelector(".haciendola-upselleandola__button");S&&e.defaults.buttonClasses&&S.classList.add(...e.defaults.buttonClasses.split(" "))}catch(n){console.log(n)}})()})();