1 |
- define(["jquery","knockout","pubsub","ccConstants","koValidate","notifier","CCi18n","storeKoExtensions","swmRestClient","spinner","pageLayout/product","ccRestClient","ccResourceLoader!global/OCS_BFService","navigation","ccLogger"],function(e,t,n,r,i,s,o,u,a,f,l,c,h,p,d){"use strict";var v,m="LOADED",g="LOADING",y={parent:"#cc-product-spinner",selector:"#cc-product-spinner-area"},b=!1,w=0,E=5,S="OCS_ADD_ITEM_SUCCESS",x=function(e){var t=e.indexOf("@");return t!=-1?!0:!1},T={validaRut:function(e){var t=e.replace(/\./g,""),n=t.split("-"),r=n[1],i=n[0];return r=="K"&&r.toLowerCase(),T.dv(i)==r?!0:!1},dv:function(e){var t=0,n=1;for(;e;e=Math.floor(e/10))n=(n+e%10*(9-t++%6))%11;return n?n-1:"k"}},N=function(e,t){return e.spaceNameFull()>t.spaceNameFull()?1:e.spaceNameFull()<t.spaceNameFull()?-1:0},C=function(e,t){return e.spaceNameFull()>t.spaceNameFull()?1:e.spaceNameFull()<t.spaceNameFull()?-1:0};return{autoenpagovis:t.observable(!1),stockStatus:t.observable(!1),stockState:t.observable(),showStockStatus:t.observable(!1),variantOptionsArray:t.observableArray([]),itemQuantity:t.observable(1),stockAvailable:t.observable(),availabilityDate:t.observable(),selectedSku:t.observable(),disableOptions:t.observable(!1),priceRange:t.observable(!1),filtered:t.observable(!1),WIDGET_ID:"productDetails",isAddToCartClicked:t.observable(!1),containerImage:t.observable(),imgGroups:t.observableArray(),mainImgUrl:t.observable(),activeImgIndex:t.observable(0),activeImgIndexModal:t.observable(1),viewportWidth:t.observable(),skipTheContent:t.observable(!1),listPrice:t.observable(),salePrice:t.observable(),backLinkActive:t.observable(!0),variantName:t.observable(),variantValue:t.observable(),listingVariant:t.observable(),shippingSurcharge:t.observable(),secondaryCurrencyShippingSurcharge:t.observable(),imgMetadata:[],isMobile:t.observable(!1),quickViewFromPurchaseList:t.observable(!1),selectCarVersion:t.observable(),ocs_button_reserva:t.observable(!1),ocs_button_vendido:t.observable(!1),showSWM:t.observable(!0),isAddToSpaceClicked:t.observable(!1),disableAddToSpace:t.observable(!1),spaceOptionsArray:t.observableArray([]),spaceOptionsGrpMySpacesArr:t.observableArray([]),spaceOptionsGrpJoinedSpacesArr:t.observableArray([]),mySpaces:t.observableArray([]),siteFbAppId:t.observable(""),reserva_button:t.observable(!1),product_reserva:t.observableArray([]),cl_id:t.observable(""),user_email:t.observable(""),confirmation_user_email:t.observable(""),reservarButton:t.observable(!1),showFinancing:t.observable(!1),isVisibleReservarButton:t.observable(!0),isVisibleVenderButton:t.observable(!1),isVisibleCotizar:t.observable(!0),showPrices:t.observable(!0),showProductImage:t.observable(!1),showProductSpincar:t.observable(!1),loadNoImage:t.observable(!1),swiperPDPControl:null,swiperModalControl:null,swiperThumbails:null,sucursal:t.observable(),renderSwiperThumbails:function(){var e,t=setTimeout(function(){e=new Swiper(".swiper-product-pdp-thumbails",{spaceBetween:10,slidesPerView:"auto",roundLengths:!0,watchSlidesProgress:!0,centerInsufficientSlides:!0,keyboard:{enabled:!0,onlyInViewport:!1},navigation:{nextEl:".swiper-button-next-pdp",prevEl:".swiper-button-prev-pdp"},breakpoints:{320:{spaceBetween:15},768:{spaceBetween:10}},on:{click:function(e,t){v.activeImgIndex(e.activeIndex),v.activeImgIndexModal(1)}}}),v.swiperPDPControl=e,new Swiper(".swiper-product-pdp",{loop:!0,keyboard:{enabled:!0},navigation:{nextEl:".swiper-button-next-pdp-ppal",prevEl:".swiper-button-prev-pdp-ppal"},pagination:{el:".swiper-pagination-pdp",dynamicBullets:!0},thumbs:{swiper:v.swiperPDPControl}})},300)},renderSwiperThumbailsModal:function(){var e=new Swiper(".swiper-thumbails-modal",{direction:"vertical",slidesPerView:"auto",freeMode:!0,scrollbar:{el:".swiper-scrollbar-modal"},mousewheel:!0,on:{click:function(e,t){v.activeImgIndexModal(e.activeIndex),v.activeImgIndex(1)}}});e.slideNext();var t=setTimeout(function(){v.swiperModalControl=new Swiper(".swiper-product-modal",{loop:!0,keyboard:{enabled:!0,onlyInViewport:!1},on:{slideChange:function(e,t){v.activeImgIndexModal(e.activeIndex),v.activeImgIndex(1)}},navigation:{nextEl:".swiper-button-next-pdp-ppal",prevEl:".swiper-button-prev-pdp-ppal"},pagination:{el:".swiper-pagination-pdp",dynamicBullets:!0},thumbs:{swiper:v.swiperModalControl}})},300)},goToSwiperIndex:function(t,n){v.swiperModalControl&&(v.swiperModalControl.slideTo(t+1,200),e(".thumbail-modal-pdp").removeClass("active"),e(n).addClass("active"))},resourcesLoaded:function(e){b=!0},goToTop:function(){document.body.scrollTop=0,document.documentElement.scrollTop=0},initTooltip:function(){e('[data-toggle="tooltip"]').tooltip()},cotizarClickLink:function(n){e.Topic("ga_add_to_cart.memory").publish(v.product().product),localStorage.clear();var n=n;localStorage.setItem("flow_id",Date.now()),localStorage.setItem("ocs_product_id",n.product().id()),localStorage.setItem("ocw_product_x_patente",n.product().id()),localStorage.setItem("ocw_product_x_Ubicacion_Fisica",n.product().product.x_Ubicacion_Fisica),localStorage.setItem("ocw_product_x_modelo",n.product().product.x_modelo),localStorage.setItem("ocw_product_x_cilindrada",n.product().product.x_cilindrada),localStorage.setItem("ocw_product_x_kilometraje",n.product().product.x_kilometraje),localStorage.setItem("ocw_product_x_transmision",n.product().product.x_transmision),localStorage.setItem("ocw_product_x_marca",n.product().product.x_marca),localStorage.setItem("ocw_product_x_combustible",n.product().product.x_combustible),localStorage.setItem("ocw_product_x_color",n.product().product.x_color),localStorage.setItem("ocw_product_x_tipo",n.product().product.x_tipo),localStorage.setItem("ocw_product_x_agno",n.product().product.x_agno),localStorage.setItem("ocw_product_brand",n.product().product.x_marca),localStorage.setItem("cotiPrimaryLargeImageURL",n.product().product.primaryLargeImageURL),localStorage.setItem("cotiPrimarySmallImageURL",n.product().product.primarySmallImageURL),localStorage.setItem("marca_modelo_auto",n.product().displayName()),localStorage.setItem("brand",n.product().brand());var r=n.product().displayName(),i=r.split(" "),s=i[0],o=r.replace(s,"");localStorage.setItem("modelo",n.product().x_modelo()),localStorage.setItem("version",n.product().x_version()),localStorage.setItem("patente",n.product().id()),localStorage.setItem("imagen",n.product().fullImageURLs()[0]),localStorage.setItem("agno",n.product().x_agno()),localStorage.setItem("kilometraje",n.product().x_kilometraje()),localStorage.setItem("combustible",n.product().x_combustible()),localStorage.setItem("transmision",n.product().x_transmision()),localStorage.setItem("pg_financiadoConvencional",n.product().allPrices().pg_financiadoConvencional),localStorage.setItem("montoDescuento",n.product().allPrices().montoDescuento),localStorage.setItem("pg_bonoDeMarca",n.product().allPrices().pg_bonoDeMarca),localStorage.setItem("pg_financiadoInteligenteBF",n.product().allPrices().pg_financiadoInteligenteBF),localStorage.setItem("pg_precioLista",n.product().allPrices().pg_precioLista);var u=Object.assign({},t.toJS(n.product()));u.variantOptionsArray&&u.variantOptionsArray.forEach(function(e){delete e.parent}),localStorage.setItem("x_product",JSON.stringify(u)),h.utils.cache("actionType","quote"),p.goTo("/cotizacion-autos?option=quoting")},financiarClickLink:function(n){e.Topic("ga_add_to_cart.memory").publish(v.product().product),localStorage.clear();var n=n;localStorage.setItem("flow_id",Date.now()),localStorage.setItem("ocs_product_id",n.product().id()),localStorage.setItem("ocw_product_x_patente",n.product().id()),localStorage.setItem("ocw_product_x_Ubicacion_Fisica",n.product().product.x_Ubicacion_Fisica),localStorage.setItem("ocw_product_x_modelo",n.product().product.x_modelo),localStorage.setItem("ocw_product_x_cilindrada",n.product().product.x_cilindrada),localStorage.setItem("ocw_product_x_kilometraje",n.product().product.x_kilometraje),localStorage.setItem("ocw_product_x_transmision",n.product().product.x_transmision),localStorage.setItem("ocw_product_x_marca",n.product().product.x_marca),localStorage.setItem("ocw_product_x_combustible",n.product().product.x_combustible),localStorage.setItem("ocw_product_x_color",n.product().product.x_color),localStorage.setItem("ocw_product_x_tipo",n.product().product.x_tipo),localStorage.setItem("ocw_product_x_agno",n.product().product.x_agno),localStorage.setItem("ocw_product_brand",n.product().product.x_marca),localStorage.setItem("cotiPrimaryLargeImageURL",n.product().product.primaryLargeImageURL),localStorage.setItem("cotiPrimarySmallImageURL",n.product().product.primarySmallImageURL),localStorage.setItem("marca_modelo_auto",n.product().displayName()),localStorage.setItem("brand",n.product().brand());var r=n.product().displayName(),i=r.split(" "),s=i[0],o=r.replace(s,"");localStorage.setItem("modelo",n.product().x_modelo()),localStorage.setItem("version",n.product().x_version()),localStorage.setItem("patente",n.product().id()),localStorage.setItem("imagen",n.product().fullImageURLs()[0]),localStorage.setItem("agno",n.product().x_agno()),localStorage.setItem("kilometraje",n.product().x_kilometraje()),localStorage.setItem("combustible",n.product().x_combustible()),localStorage.setItem("transmision",n.product().x_transmision()),localStorage.setItem("pg_financiadoConvencional",n.product().allPrices().pg_financiadoConvencional),localStorage.setItem("montoDescuento",n.product().allPrices().montoDescuento),localStorage.setItem("pg_bonoDeMarca",n.product().allPrices().pg_bonoDeMarca),localStorage.setItem("pg_financiadoInteligenteBF",n.product().allPrices().pg_financiadoInteligenteBF),localStorage.setItem("pg_precioLista",n.product().allPrices().pg_precioLista);var u=Object.assign({},t.toJS(n.product()));u.variantOptionsArray&&u.variantOptionsArray.forEach(function(e){delete e.parent}),localStorage.setItem("x_product",JSON.stringify(u)),h.utils.cache("actionType","financing"),window.location.href="/cotizacion-autos?option=financing"},checkAction:function(){var e=this,t=(new URLSearchParams(location.search)).get("action");t&&(t=t.toUpperCase(),t=="C"?e.cotizarClickLink(e):t=="F"?e.financiarClickLink(e):t=="R"&&e.reservarButton()&&e.clickReservarButton(e))},onLoad:function(i){v=i,setTimeout(function(){e(document).ready(function(){e("#formatkmauto").each(function(t,n){e(this).text(e(this).text().toString().replace(/\B(?=(\d{3})+(?!\d))/g,"."))})})},1e3),e(window).on("shown.bs.modal",function(t){e("body, html").css("overflow","hidden")}),e(window).on("hidden.bs.modal",function(t){e("body, html").css("overflow","initial")}),e(window).width()<768&&e(window).scroll(function(t){var n=e("#ff-container-buttons-mobile"),r=n.css("position")=="fixed";e(this).scrollTop()>800&&!r&&n.css({position:"fixed",display:"flex"}),e(this).scrollTop()<800&&r&&n.css({position:"static",display:"none"})}),e(window).on("show.bs.modal",function(t){e("#product-spincar .sts-spin #spincar360iframe").clone().appendTo("#product-spincar-modal .sts-spin")}),e.Topic(n.topicNames.UPDATE_LISTING_FOCUS).subscribe(function(e){i.skipTheContent(!0)}),i.showSecondaryShippingData=t.pureComputed(function(){return i.site().payShippingInSecondaryCurrency&&null!=i.site().exchangeRate()&&null!=i.site().siteSecondaryCurrency()}),e.Topic(n.topicNames.PAGE_READY).subscribe(function(e){var t={};if(e.parameters){var n=e.parameters.split("&");for(var r=0;r<n.length;r++){var s=n[r].split("=");t[s[0]]=s[1]}}t.variantName&&t.variantValue?(i.variantName(decodeURI(t.variantName)),i.variantValue(decodeURI(t.variantValue))):(i.variantName(""),i.variantValue(""))}),e.Topic(n.topicNames.SOCIAL_SPACE_ADD_SUCCESS).subscribe(function(e){e.productUpdated?(i.disableAddToSpace(!0),setTimeout(function(){i.disableAddToSpace(!1)},3e3)):(i.isAddToSpaceClicked(!0),i.disableAddToSpace(!0),setTimeout(function(){i.isAddToSpaceClicked(!1)},3e3),setTimeout(function(){i.disableAddToSpace(!1)},3e3))}),i.itemQuantity.extend({required:{params:!0,message:o.t("ns.common:resources.quantityRequireMsg")},digit:{params:!0,message:o.t("ns.common:resources.quantityNumericMsg")},min:{params:1,message:o.t("ns.OCS_productDetailsUsedCar:resources.quantityGreaterThanMsg",{quantity:0})}}),i.stockAvailable.subscribe(function(e){var t=parseInt(e,10);i.itemQuantity.rules.remove(function(e){return e.rule=="max"}),t>0&&i.itemQuantity.extend({max:{params:t,message:o.t("ns.OCS_productDetailsUsedCar:resources.quantityLessThanMsg",{quantity:t})}})}),i.itemQuantityInCart=function(e){var t=e.orderLimit?!1:!0;return i.cart().getItemQuantityInCart(i.cart().items(),e.id,e.childSKUs[0].repositoryId,t)},a.init(i.site().tenantId,i.isPreview(),i.locale()),i.fetchFacebookAppId(),i.shippingSurchargeMouseOver=function(t,n){e(".shippingSurchargePopover").off("click"),e(".shippingSurchargePopover").off("keydown");var r=new Object;r.trigger="manual",r.html=!0,r.title=t.translate("shippingSurchargePopupTitle")+"<button id='shippingSurchargePopupCloseBtn' class='close btn pull-right'>"+t.translate("escapeKeyText")+" ×</button>",r.content=t.translate("shippingSurchargePopupText"),e(".shippingSurchargePopover").popover(r),e(".shippingSurchargePopover").on("click",t.shippingSurchargeShowPopover),e(".shippingSurchargePopover").on("keydown",t.shippingSurchargeShowPopover)},i.shippingSurchargeShowPopover=function(t){if(t.type==="keydown"&&t.which!==r.KEY_CODE_ENTER)return;t.stopPropagation(),e(this).popover("show"),e("html").on("click",i.shippingSurchargeHidePopover),e("html").on("keydown",i.shippingSurchargeHidePopover),e(".shippingSurchargePopover").off("click"),e(".shippingSurchargePopover").off("keydown")},i.shippingSurchargeHidePopover=function(t){if(t.type==="keydown"&&t.which!==r.KEY_CODE_ESCAPE)return;e(".shippingSurchargePopover").popover("hide"),e(".shippingSurchargePopover").on("click",i.shippingSurchargeShowPopover),e(".shippingSurchargePopover").on("keydown",i.shippingSurchargeShowPopover),e("html").off("click"),e("html").off("keydown"),e(".shippingSurchargePopover").focus()},i.isAddToPurchaseListDisabled=t.computed(function(){return!i.validateAddToSpace()||i.disableAddToSpace()},i),i.viewportWidth(e(window).width()),i.product()&&(i.imgGroups(i.groupImages(i.product().thumbImageURLs())),i.mainImgUrl(i.product().primaryFullImageURL()));var s=function(){e("#cc-product-details :focusable").first().focus(),i.skipTheContent(!1)};s(),setTimeout(s,1),e(document).on("keyup","#widget_iduser",function(){var t=e("#widget_iduser");t=t.val().replace(/[.-]/g,"").replace(/^(\d{1,2})(\d{3})(\d{3})(\w{1})$/,"$1.$2.$3-$4"),e("#widget_iduser").val(t)}),i.tooltipCuota=t.computed(function(){var e=(new Date).getFullYear()-i.product().x_agno();if(e<=6)return e<=4?"Cuota calculada con Crédito Inteligente, Pie del 40%, 36 Cuotas + Cuota 37.":"Cuota calculada con Crédito Convencional, Pie del 50%, 48 Cuotas."},i),setTimeout(function(){i.checkAction()},1500),i.reservarButton.subscribe(function(e){h.utils.cache("RESERVA_ENABLED",e.toString())})},spinnerSpinCar:function(){f.create({parent:"#loadingSpinCar"})},lowerActivepgFinanciadoConvencional:t.observable(!1),lowerActivepgPrecioLista:t.observable(!1),lowerActivepgReservaWeb:t.observable(!1),lowerActivepgBonoMarca:t.observable(!1),populateHighlightProperties:function(){v.product().highlightProperties=t.observableArray(),v.product().highlightProperties(h.populateHighlightProperties(v.product(),"pdp"))},showHighlyViewed:function(e){return h.showHighlyViewed(e.creationDate(),e.x_views())},beforeAppear:function(i){var o=this;o.showProductSpincar(!1),o.showProductImage(!1);var u=(new Date).getFullYear()-o.product().x_agno();u<=6?(o.showFinancing(!0),e.Topic("OCC_SHOW_FINANCING").publish(!0)):(o.showFinancing(!1),e.Topic("OCC_SHOW_FINANCING").publish(!1)),o.sucursal(null),o.product().x_Ubicacion_Fisica()!="Pronto Disponible"&&h.ajax({url:h.utils.siteSetting("BF_middleware","urlMiddleware")+"/sucursales/findSucursal/byAddress",type:"GET",data:{direccion:o.product().x_Ubicacion_Fisica()},success:function(e){e.success==1?(console.log(e.data),o.sucursal(e.data)):console.error("No se encontró la data de sucursal",e)},fail:function(e){console.error("Erros buscando la sucursal",e)}}),setTimeout(function(){e(document).ready(function(){e("#formatkmauto").each(function(t,n){e(this).text(e(this).text().toString().replace(/\B(?=(\d{3})+(?!\d))/g,"."))})})},1e3),o.lowerActivepgFinanciadoConvencional(!1),o.lowerActivepgPrecioLista(!1),o.lowerActivepgBonoMarca(!1),o.reservarButton(!1),o.product().allPrices=t.observable();if(o.product&&o.product()){o.checkResponsiveFeatures(e(window).width()),this.backLinkActive(!0),!o.isPreview()&&!o.historyStack.length&&this.backLinkActive(!1),o.shippingSurcharge(null),o.secondaryCurrencyShippingSurcharge(null),o.activeImgIndex(0),o.firstTimeRender=!0,this.populateVariantOptions(o),o.product()&&o.imgGroups(o.groupImages(o.product().thumbImageURLs())),o.loaded(!0),this.itemQuantity(1),o.product()&&o.product().childSKUs().length==1&&(this.filtered(!1),this.filterOptionValues(null)),s.clearSuccess(this.WIDGET_ID),s.clearError(this.WIDGET_ID);var a=null;o.user().catalog&&(a=o.user().catalog.repositoryId),o.listPrice(o.product().listPrice()),o.salePrice(o.product().salePrice());if(o.product()){o.product().stockStatus.subscribe(function(t){o.product().stockStatus().stockStatus!==r.IN_STOCK&&o.product().stockStatus().stockStatus!==r.PREORDERABLE&&o.product().stockStatus().stockStatus!==r.BACKORDERABLE||o.product().stockStatus().orderableQuantity==undefined&&o.product().stockStatus().productSkuInventoryStatus==undefined?(o.ocs_button_reserva(!1),o.ocs_button_vendido(!0),o.stockAvailable(0),o.stockState(r.OUT_OF_STOCK),o.disableOptions(!0),o.stockStatus(!1)):(o.product().stockStatus().orderableQuantity?o.stockAvailable(o.product().stockStatus().orderableQuantity):o.stockAvailable(1),o.disableOptions(!1),o.stockStatus(!0),o.stockState(o.product().stockStatus().stockStatus),o.availabilityDate(o.product().stockStatus().availabilityDate),o.ocs_button_reserva(!0),o.ocs_button_vendido(!1)),o.showStockStatus(!0),o.reservarButton(!0),o.isVisibleReservarButton(!0),o.isVisibleVenderButton(!1),o.isVisibleCotizar(!0),o.showPrices(!0),o.stockAvailable()===0?o.reservarButton(!1):o.stockAvailable()===888?(o.reservarButton(!0),o.isVisibleReservarButton(!1),o.isVisibleVenderButton(!0),o.isVisibleCotizar(!1),o.showPrices(!1),o.showFinancing(!1),e.Topic("OCC_SHOW_FINANCING").publish(!1)):o.product().x_preStock()?o.reservarButton(!1):!o.product().x_preStock()});var f=o.product().childSKUs()[0];if(f){var l=f.repositoryId();this.variantOptionsArray().length>0&&(l=""),this.showStockStatus(!1),o.product().getAvailability(o.product().id(),l,a),o.product().getPrices(o.product().id(),l)}else o.stockStatus(!1),o.disableOptions(!0),o.showStockStatus(!0);this.priceRange(this.product().hasPriceRange),o.mainImgUrl(o.product().primaryFullImageURL()),e.Topic(n.topicNames.PRODUCT_VIEWED).publish(o.product()),e.Topic(n.topicNames.PRODUCT_PRICE_CHANGED).subscribe(function(){o.listPrice(o.product().listPrice()),o.salePrice(o.product().salePrice()),o.shippingSurcharge(o.product().shippingSurcharge()),o.secondaryCurrencyShippingSurcharge(o.product().secondaryCurrencyShippingSurcharge&&o.product().secondaryCurrencyShippingSurcharge()?o.product().secondaryCurrencyShippingSurcharge():null)})}}v.loadAllPrices(),v.product().allPrices.subscribe(function(e){v.lowerPrice()}),e.Topic(n.topicNames.USER_LOGOUT_SUBMIT).subscribe(function(e){localStorage.clear(),localStorage.removeItem("occsRecVisitorId"),localStorage.removeItem("occsRecSessionId"),localStorage.removeItem("redirectedToWebPayment"),localStorage.removeItem("occs_pricelistgroup_id-storefrontUI"),localStorage.removeItem("user"),location.reload()}),v.loadUrls(),o.product().x_spincar360()?h.ajax({url:h.CCConstants.urlMiddleware()+"/v1/spincar/data?patente="+o.product().x_patente().toLowerCase(),success:function(t){if(t&&t.hasOwnProperty("vehicles")&&t.vehicles.length>0)if(t.vehicles[0].hasOwnProperty("images")){var n=t.vehicles[0].images.map(function(e){return e.url});v.assignImagesToProduct(null,n),v.showProductSpincar(!0),v.showProductImage(!0);var r='<div class="sts-spin"><iframe id="spincar360iframe" frameBorder="0" src="https://spins.spincar.com/brunofritsh/'+t.vehicles[0].id+'" style="width: 100%;height: 100%"></iframe>'+"</div>";e("#product-spincar").html(r)}else v.showProductNoImage();else v.showProductNoImage()},fail:function(e){d.error("Error verificando imagenes de patente: "+e),v.showProductNoImage()}}):v.showProductNoImage(),e.Topic("ga_view_item.memory").publish(v.product().product)},showProductNoImage:function(){v.showProductImage(!0)},loadAllPrices:function(){h.getAllPrices(v.product(),"allPrices")},goBack:function(){return e(window).scrollTop(e(window).height()),window.history.go(-1),!1},cancelZoom:function(t){e(t).parent().removeClass("zoomContainer-CC")},populateVariantOptions:function(e){var t=e.productVariantOptions();if(t&&t!==null&&t.length>0){var n=[],r,i={},s,o,u;for(var a=0,f=e.productTypes().length;a<f;a++)if(e.productTypes()[a].id==e.product().type()){u=e.productTypes()[a].variants;for(var l=0,c=u.length;l<c;l++)i[u[l].id]=u[l].values}for(var h=0;h<t.length;h++)e.product().variantValuesOrder[t[h].optionId]&&(r=e.product().variantValuesOrder[t[h].optionId]()),s=this.mapOptionsToArray(t[h].optionValueMap,r?r:i[t[h].optionId]),o=this.productVariantModel(t[h].optionName,t[h].mapKeyPropertyAttribute,s,e,t[h].optionId),n.push(o);e.variantOptionsArray(n)}else e.imgMetadata=e.product().product.productImagesMetadata,e.variantOptionsArray([])},loadUrls:function(){var e=v.categoryId,t="sin asignar",n="x_spinCar",r=function(e){e&&e.items&&e.items.length>0&&(t=e.items[0].x_spinCar,t&&(v.urlVideoReview("https://www.youtube.com/embed/"+t),v.showVideoReview(!0)))},i=function(e){console.error("Error on load product video & 360 view: ",e.message)};h.getProductsFromCategory(e,n,r,i)},productVariantModel:function(n,r,i,s,o){var u={},a={};u.optionDisplayName=n,u.parent=this,u.optionId=r,u.originalOptionValues=t.observableArray(i),u.actualOptionId=o;var f=t.observable(!0);i.length===1&&f(this.checkOptionValueWithSkus(r,i[0].value)),f()&&(u.optionCaption=s.translate("optionCaption",{optionName:n},!0)),u.selectedOptionValue=t.observable(),u.countVisibleOptions=t.computed(function(){var e=0;for(var t=0;t<u.originalOptionValues().length;t++)i[t].visible()==1&&(e+=1);return e},u),u.disable=t.computed(function(){return u.countVisibleOptions()==0?!0:!1},u),u.selectedOption=t.computed({write:function(e){this.parent.filtered(!1),u.selectedOptionValue(e),u.actualOptionId===this.parent.listingVariant()&&(e&&e.listingConfiguration?(this.parent.imgMetadata=e.listingConfiguration.imgMetadata,this.parent.assignImagesToProduct(e.listingConfiguration)):(this.parent.imgMetadata=this.parent.product().product.productImagesMetadata,this.parent.assignImagesToProduct(this.parent.product().product))),this.parent.filterOptionValues(u.optionId)},read:function(){return u.selectedOptionValue()},owner:u}),u.selectedOption.extend({required:{params:!0,message:s.translate("optionRequiredMsg",{optionName:n},!0)}}),u.optionValues=t.computed({write:function(e){u.originalOptionValues(e)},read:function(){return t.utils.arrayFilter(u.originalOptionValues(),function(e){return e.visible()==1})},owner:u});for(var l=0;l<s.productTypes().length;l++)if(s.product().type()&&s.productTypes()[l].id==s.product().type()){var c=s.productTypes()[l].variants;for(var h=0;h<c.length;h++)if(c[h].listingVariant){s.listingVariant(c[h].id);break}break}a.thumbImageURLs=s.product().product.thumbImageURLs.length==1&&s.product().product.thumbImageURLs[0].indexOf("/img/no-image.jpg&")>0?[]:s.product().product.thumbImageURLs,a.smallImageURLs=s.product().product.smallImageURLs.length==1&&s.product().product.smallImageURLs[0].indexOf("/img/no-image.jpg&")>0?[]:s.product().product.smallImageURLs,a.mediumImageURLs=s.product().product.mediumImageURLs.length==1&&s.product().product.mediumImageURLs[0].indexOf("/img/no-image.jpg&")>0?[]:s.product().product.mediumImageURLs,a.largeImageURLs=s.product().product.largeImageURLs.length==1&&s.product().product.largeImageURLs[0].indexOf("/img/no-image.jpg&")>0?[]:s.product().product.largeImageURLs,a.fullImageURLs=s.product().product.fullImageURLs.length==1&&s.product().product.fullImageURLs[0].indexOf("/img/no-image.jpg&")>0?[]:s.product().product.fullImageURLs,a.sourceImageURLs=s.product().product.sourceImageURLs.length==1&&s.product().product.sourceImageURLs[0].indexOf("/img/no-image.jpg")>0?[]:s.product().product.sourceImageURLs;var p=[];if(s.product().thumbImageURLs&&s.product().thumbImageURLs().length>0)for(var d=0;d<s.product().thumbImageURLs().length;d++)p.push(s.product().product.productImagesMetadata[d]);return t.utils.arrayForEach(u.originalOptionValues(),function(t){if(s.listingVariant()===o)for(var n=0;n<s.product().childSKUs().length;n++)if(s.product().childSKUs()[n].productListingSku()){var r=s.product().childSKUs()[n];if(r[o]()==t.key){var i={};i.thumbImageURLs=e.merge(e.merge([],r.thumbImageURLs()),a.thumbImageURLs),i.smallImageURLs=e.merge(e.merge([],r.smallImageURLs()),a.smallImageURLs),i.mediumImageURLs=e.merge(e.merge([],r.mediumImageURLs()),a.mediumImageURLs),i.largeImageURLs=e.merge(e.merge([],r.largeImageURLs()),a.largeImageURLs),i.fullImageURLs=e.merge(e.merge([],r.fullImageURLs()),a.fullImageURLs),i.sourceImageURLs=e.merge(e.merge([],r.sourceImageURLs()),a.sourceImageURLs),i.primaryFullImageURL=r.primaryFullImageURL()?r.primaryFullImageURL():s.product().product.primaryFullImageURL,i.primaryLargeImageURL=r.primaryLargeImageURL()?r.primaryLargeImageURL():s.product().product.primaryLargeImageURL,i.primaryMediumImageURL=r.primaryMediumImageURL()?r.primaryMediumImageURL():s.product().product.primaryMediumImageURL,i.primarySmallImageURL=r.primarySmallImageURL()?r.primarySmallImageURL():s.product().product.primarySmallImageURL,i.primaryThumbImageURL=r.primaryThumbImageURL()?r.primaryThumbImageURL():s.product().product.primaryThumbImageURL;var f=[];if(r.images&&r.images().length>0)for(var l=0;l<r.images().length;l++)f.push(s.product().product.childSKUs[n].images[l].metadata);i.imgMetadata=e.merge(e.merge([],f),p),t.listingConfiguration=i}}s.variantName()===o&&t.key===s.variantValue()&&u.selectedOption(t)}),u},checkOptionValueWithSkus:function(e,t){var n=this.product().childSKUs(),r=n.length;for(var i=0;i<r;i++)if(!n[i].dynamicPropertyMapLong[e]||n[i].dynamicPropertyMapLong[e]()===undefined)return!0;return!1},filterOptionValues:function(e){if(this.filtered())return;var t=this.variantOptionsArray();for(var n=0;n<t.length;n++){var r=t[n],i=this.getMatchingSKUs(t[n].optionId),s=this.updateOptionValuesFromSku(i,e,r);t[n].optionValues(s),this.filtered(!0)}this.updateSingleSelection(e)},getMatchingSKUs:function(e){var t=this.product().childSKUs(),n=[],r=this.variantOptionsArray(),i={};for(var s=0;s<r.length;s++)r[s].optionId!=e&&r[s].selectedOption()!=undefined&&(i[r[s].optionId]=r[s].selectedOption().value);for(var o=0;o<t.length;o++){var u=!0;for(var a in i)if(i.hasOwnProperty(a))if(!t[o].dynamicPropertyMapLong[a]||t[o].dynamicPropertyMapLong[a]()!=i[a]){u=!1;break}u&&n.push(t[o])}return n},updateOptionValuesFromSku:function(e,t,n){var r=n.optionId,i=[],s=n.originalOptionValues();for(var o=0;o<e.length;o++){var u=e[o].dynamicPropertyMapLong[r];u!=undefined&&i.push(u())}for(var a=0;a<s.length;a++){var f=s[a].value,l=!1,c=i.indexOf(f);c!=-1&&(l=!0),s[a].visible(l)}return s},validForSingleSelection:function(e){var t=this.variantOptionsArray();for(var n=0;n<t.length;n++){if(t[n].disable()||t[n].optionId!=e&&t[n].selectedOption()!=undefined)return!0;if(t[n].optionId!=e&&t[n].selectedOption()==undefined&&t[n].countVisibleOptions()==1)return!0}return!1},updateSingleSelection:function(e){var t=this.variantOptionsArray();for(var n=0;n<t.length;n++){var r=t[n].optionId;if(t[n].countVisibleOptions()==1&&t[n].selectedOption()==undefined&&r!=e){var i=this.validForSingleSelection(r),s=t[n].originalOptionValues();for(var o=0;o<s.length;o++)if(s[o].visible()==1){t[n].selectedOption(s[o]);break}}}},mapOptionsToArray:function(e,n){var r=[];for(var i=0,s=n.length;i<s;i++)e.hasOwnProperty(n[i])&&r.push({key:n[i],value:e[n[i]],visible:t.observable(!0)});return r},getSelectedSku:function(t){var r=[];this.product()&&(r=this.product().product.childSKUs);var i={};for(var s=0;s<r.length;s++){i=r[s];for(var o=0;o<t.length;o++)if(!t[o].disable()&&r[s].dynamicPropertyMapLong[t[o].optionId]!=t[o].selectedOption().value){i=null;break}if(i!==null)return e.Topic(n.topicNames.SKU_SELECTED).publish(this.product(),i,t),i}return null},refreshSkuPrice:function(e){if(e===null)this.product().hasPriceRange?this.priceRange(!0):(this.listPrice(this.product().listPrice()),this.salePrice(this.product().salePrice()),this.priceRange(!1));else{this.priceRange(!1);var t=this.product().getSkuPrice(e);this.listPrice(t.listPrice),this.salePrice(t.salePrice)}},refreshSkuStockStatus:function(e){var t,n=!0,r=this.product().stockStatus();e===null?t="stockStatus":(t=e.repositoryId,r!=undefined&&r.productSkuInventoryStatus!=undefined&&(n=r.productSkuInventoryStatus[t]>0?!0:!1));for(var i in r)if(i==t){r[t]!="IN_STOCK"&&r[t]!="PREORDERABLE"&&r[t]!="BACKORDERABLE"||!n?(this.stockStatus(!1),this.stockAvailable(0),this.stockState("OUT_OF_STOCK")):(this.stockStatus(!0),this.stockState(r[t]),this.availabilityDate(this.getAvailabilityDate(t)),e===null?this.stockAvailable(1):this.stockAvailable(e.quantity));return}},refreshSkuData:function(e){this.refreshSkuPrice(e),this.refreshSkuStockStatus(e)},getAvailabilityDate:function(e){var t=null,n=this.product().stockStatus().productSkuInventoryDetails;for(var r in n){var i=n[r];if(i.catRefId===e){t=i.availabilityDate;break}}return t},getSelectedSkuOptions:function(e){var t=[],n;for(var r=0;r<e.length;r++)e[r].disable()||t.push({optionName:e[r].optionDisplayName,optionValue:e[r].selectedOption().key,optionId:e[r].actualOptionId,optionValueId:e[r].selectedOption().value});return t},assignSkuIMage:function(e,t){var n,r,i={};for(var s=0,o=this.productTypes().length;s<o;s++)if(this.productTypes()[s].id==e.type){n=this.productTypes()[s].variants;for(var u=0;u<n.length;u++)if(n[u].listingVariant){r=n[u].id,i=n[u].values;break}}if(e.childSKUs)for(var a=0;a<e.childSKUs.length;a++)if(e.childSKUs[a][r]===t[r]&&!t.primaryThumbImageURL){t.primaryThumbImageURL=e.childSKUs[a].primaryThumbImageURL;break}},allOptionsSelected:function(){var e=!0;if(this.variantOptionsArray().length>0){var t=this.variantOptionsArray();for(var n=0;n<t.length;n++)if(!t[n].selectedOption.isValid()&&!t[n].disable()){e=!1,this.selectedSku(null);break}if(e){var r=this.getSelectedSku(t);if(r===null)return!1;this.selectedSku(r)}this.refreshSkuData(this.selectedSku())}return e},quantityIsValid:function(){return this.itemQuantity()>0&&this.itemQuantity()<=this.stockAvailable()},selectCarVersion:function(t){e.Topic("addRemoveCartComparator").publish(t.product())},validateAddToCart:function(){var t=this.allOptionsSelected()&&this.stockStatus()&&this.quantityIsValid()&&this.listPrice()!=null;return this.variantOptionsArray().length>0&&this.selectedSku()?t=t&&!this.selectedSku().configurable:t=t&&!this.product().isConfigurable(),t||e("#cc-prodDetailsAddToCart").attr("aria-disabled","true"),t},handleAddToCart:function(){v.user().loggedIn()?h.handleAddToCartAndRedirectToCheckout(this):e("#headerBFUserLogin").trigger("click")},getSpaces:function(e){var n=this,r=function(r){var i=[],s=[];if(r.response.code.indexOf("200")===0){var o=r.items;o.forEach(function(e,r){var o={spaceid:e.spaceId,spaceNameFull:t.observable(e.spaceName),spaceNameFormatted:t.computed(function(){return e.spaceName+" ("+e.creatorFirstName+" "+e.creatorLastName+")"},n),creatorid:e.creatorId,accessLevel:e.accessLevel,spaceOwnerFirstName:e.creatorFirstName,spaceOwnerLastName:e.creatorLastName};e.creatorId==a.apiuserid?i.push(o):s.push(o)}),i.sort(N),s.sort(C),n.user().myWishLists(i),n.user().joinedWishLists(s),n.spaceOptionsGrpMySpacesArr(i),n.spaceOptionsGrpJoinedSpacesArr(s);var u=[],f={label:n.translate("mySpacesGroupText"),children:t.observableArray(n.spaceOptionsGrpMySpacesArr())},l={label:n.translate("joinedSpacesGroupText"),children:t.observableArray(n.spaceOptionsGrpJoinedSpacesArr())},c=[],h={spaceid:"createnewspace",spaceNameFull:t.observable(n.translate("createNewSpaceOptText"))};c.push(h);var p={label:"",children:t.observableArray(c)};u.push(f),u.push(l),u.push(p),n.spaceOptionsArray(u),n.mySpaces(i),e&&e()}},i=function(e,t,n){};a.request("GET","/swm/rs/v1/sites/{siteid}/spaces","",r,i,{})},openAddToWishlistDropdownSelector:function(){var e=this;e.spaceOptionsArray().length===0&&e.getSpaces()},validateAddToSpace:function(){var t=!0;if(this.variantOptionsArray().length>0){var n=this.variantOptionsArray();for(var r=0;r<n.length;r++)if(!n[r].selectedOption.isValid()&&!n[r].disable()){t=!1;break}if(t){var i=this.getSelectedSku(n);if(i==null)return!1;var s=this.product().getSkuPrice(i);if(s.listPrice===null)return!1}}else if(this.listPrice()==null)return!1;this.variantOptionsArray().length>0&&this.selectedSku()?t=t&&!this.selectedSku().configurable:t=t&&this.product()&&!this.product().isConfigurable();var o=this.itemQuantity();if(o.toString()!="")if(!o.toString().match(/^\d+$/)||Number(o)<0)return!1;var u=t&&this.product().childSKUs().length>0;return u||e("#cc-prodDetailsAddToSpace").attr("aria-disabled","true"),u},validateAndSetSelectedSku:function(e){var t=!0;if(this.variantOptionsArray().length>0){var n=this.variantOptionsArray();for(var r=0;r<n.length;r++)if(!n[r].selectedOption.isValid()&&!n[r].disable()){t=!1,this.selectedSku(null);break}if(t){var i=this.getSelectedSku(n);if(i===null)return!1;this.selectedSku(i)}e&&this.refreshSkuData(this.selectedSku())}return t},addToSpaceClick:function(t){var r=this.variantOptionsArray();s.clearSuccess(this.WIDGET_ID);var i=this.getSelectedSkuOptions(r),o={selectedOptions:i},u=e.extend(!0,{},this.product().product,o);u.desiredQuantity=this.itemQuantity(),this.variantOptionsArray().length>0&&(u.childSKUs=[this.selectedSku()]),u.productPrice=u.salePrice!=null?u.salePrice:u.listPrice,e.Topic(n.topicNames.SOCIAL_SPACE_ADD).publishWith(u,[{message:"success"}])},addToSpaceSelectorClick:function(t){var r=this.variantOptionsArray();s.clearSuccess(this.WIDGET_ID);var i=this.getSelectedSkuOptions(r),o={selectedOptions:i},u=e.extend(!0,{},this.product().product,o);u.desiredQuantity=this.itemQuantity(),this.variantOptionsArray().length>0&&(u.childSKUs=[this.selectedSku()]),u.productPrice=u.salePrice!=null?u.salePrice:u.listPrice,e.Topic(n.topicNames.SOCIAL_SPACE_SELECTOR_ADD).publishWith(u,[{message:"success"}])},addToSpaceSelect:function(t,r){var i=this.variantOptionsArray();s.clearSuccess(this.WIDGET_ID);var o=this.getSelectedSkuOptions(i),u={selectedOptions:o},a=e.extend(!0,{},this.product().product,u);a.desiredQuantity=this.itemQuantity(),this.variantOptionsArray().length>0&&(a.childSKUs=[this.selectedSku()]),a.productPrice=a.salePrice!=null?a.salePrice:a.listPrice,e.Topic(n.topicNames.SOCIAL_SPACE_ADD_TO_SELECTED_SPACE).publishWith(a,[r])},addToWishListSelected:function(t){if(v.user().loggedIn()){var t=this,r="";for(var i=0;i<v.mySpaces().length;i++)v.mySpaces()[i].spaceNameFull()=="Autos usados"&&(r=v.mySpaces()[i]);var o=this.variantOptionsArray();s.clearSuccess(this.WIDGET_ID);var u=this.getSelectedSkuOptions(o),a={selectedOptions:u},f=e.extend(!0,{},this.product().product,a);f.desiredQuantity=this.itemQuantity(),this.variantOptionsArray().length>0&&(f.childSKUs=[this.selectedSku()]),f.productPrice=f.salePrice!=null?f.salePrice:f.listPrice,e.Topic(n.topicNames.SOCIAL_SPACE_ADD_TO_SELECTED_SPACE).publishWith(f,[r])}else e("#headerBFUserLogin").trigger("click")},fetchFacebookAppId:function(){var e=this,t=r.EXTERNALDATA_PRODUCTION_FACEBOOK;e.isPreview()&&(t=r.EXTERNALDATA_PREVIEW_FACEBOOK),c.request(r.ENDPOINT_MERCHANT_GET_EXTERNALDATA,null,e.fetchFacebookAppIdSuccessHandler.bind(e),e.fetchFacebookAppIdErrorHandler.bind(e),t)},fetchFacebookAppIdSuccessHandler:function(e){var t=this;t.siteFbAppId(e.serviceData.applicationId)},fetchFacebookAppIdErrorHandler:function(e){logger.debug("Failed to get Facebook appId.",result)},shareProductFbClick:function(){var e=this,t=window.location.protocol,n=window.location.host,r="";window.siteBaseURLPath&&window.siteBaseURLPath!=="/"&&(r=window.siteBaseURLPath);var i=encodeURIComponent(t+"//"+n+r+e.product().route()),s=e.siteFbAppId(),o="https://www.facebook.com/sharer/sharer.php?app_id="+s+"&u="+i,u=window.open(o,"facebookWin","width=720, height=500");u&&u.focus()},shareProductEmailClick:function(){var e=this,t=[],n=window.location.protocol,r=window.location.host,i="";window.siteBaseURLPath&&window.siteBaseURLPath!=="/"&&(i=window.siteBaseURLPath);var s=n+"//"+r+i+e.product().route();t.push("mailto:?"),t.push("subject="),t.push(encodeURIComponent(e.translate("shareProductEmailSubject",{productName:e.product().displayName()}))),t.push("&body=");var o=[];o.push(e.translate("shareProductEmailBodyIntro",{productName:e.product().displayName()})),o.push("\n\n"),o.push(s),t.push(encodeURIComponent(o.join(""))),window.location.href=t.join("")},handleLoadEvents:function(t){t.toUpperCase()===g?(f.create(y),e("#cc-product-spinner").css("z-index",1)):t.toUpperCase()===m&&this.removeSpinner()},loadImage:function(){if(b){var t=e("#cc-image-viewer").html();t?this.loadViewer(this.handleLoadEvents.bind(this)):this.viewportWidth()>r.VIEWPORT_TABLET_UPPER_WIDTH?this.loadMagnifier():this.viewportWidth()>=r.VIEWPORT_TABLET_LOWER_WIDTH?this.loadZoom():this.loadCarouselZoom()}else w++<E&&setTimeout(this.loadImage,500)},groupImages:function(e){var n=this,r=[];if(e)for(var i=0;i<e.length;i++)i%3==0?r.push(t.observableArray([e[i]])):r[r.length-1]().push(e[i]);return r},handleCarouselArrows:function(t,n){n.keyCode==37&&e("#prodDetails-imgCarousel").carousel("prev"),n.keyCode==39&&e("#prodDetails-imgCarousel").carousel("next")},handleCycleImages:function(t,n,r,i){var s=r+i*4;n.keyCode==37&&(s==0?(e("#carouselLink"+(this.product().thumbImageURLs.length-1)).focus(),e("#carouselLink"+(this.product().thumbImageURLs.length-1)).click()):r==0?(e("#prodDetails-imgCarousel").carousel("prev"),e("#carouselLink"+(s-1)).focus(),e("#carouselLink"+(s-1)).click()):(e("#carouselLink"+(s-1)).focus(),e("#carouselLink"+(s-1)).click())),n.keyCode==39&&(r==3?(e("#prodDetails-imgCarousel").carousel("next"),e("#carouselLink"+(s+1)).focus(),e("#carouselLink"+(s+1)).click()):s==this.product().thumbImageURLs.length-1?(e("#prodDetails-imgCarousel").carousel("next"),e("#carouselLink0").focus(),e("#carouselLink0").click()):(e("#carouselLink"+(s+1)).focus(),e("#carouselLink"+(s+1)).click()))},loadImageToMain:function(e){return this.activeImgIndex(e),this.activeImgIndexModal(e),typeof e=="number"&&this.mainImgUrl(this.product().fullImageURLs[e]),!1},assignImagesToProduct:function(e,t){var n={};t?(n.primaryFullImageURL=t[0],n.primaryLargeImageURL=t[0],n.primaryMediumImageURL=t[0],n.primarySmallImageURL=t[0],n.primaryThumbImageURL=t[0],n.thumbImageURLs=t,n.smallImageURLs=t,n.mediumImageURLs=t,n.largeImageURLs=t,n.fullImageURLs=t,n.sourceImageURLs=t):n=e,this.firstTimeRender==1&&(this.product().primaryFullImageURL(n.primaryFullImageURL),this.product().primaryLargeImageURL(n.primaryLargeImageURL),this.product().primaryMediumImageURL(n.primaryMediumImageURL),this.product().primarySmallImageURL(n.primarySmallImageURL),this.product().primaryThumbImageURL(n.primaryThumbImageURL),this.firstTimeRender=!1),this.product().thumbImageURLs(n.thumbImageURLs),this.product().smallImageURLs(n.smallImageURLs),this.product().mediumImageURLs(n.mediumImageURLs),this.product().largeImageURLs(n.largeImageURLs),this.product().fullImageURLs([]),this.product().fullImageURLs(n.fullImageURLs),this.product().sourceImageURLs(n.sourceImageURLs),this.mainImgUrl(n.primaryFullImageURL),this.imgGroups(this.groupImages(n.thumbImageURLs)),this.activeImgIndex(0),this.activeImgIndex.valueHasMutated()},checkResponsiveFeatures:function(e){e>978?this.isMobile(!1):e<=978&&this.isMobile(!0)},priceUnavailableText:function(){return o.t("ns.OCS_productDetailsUsedCar:resources.priceUnavailable")},isInDialog:function(){return e("#CC-prodDetails-addToCart").closest(".modal").length},getSelectedProducts:function(){if(!!this.validateAddToPurchaseList()){var t=this.variantOptionsArray(),n=this.getSelectedSkuOptions(t),r={selectedOptions:n},i=e.extend(!0,{},this.product().product,r);i.desiredQuantity=parseInt(this.itemQuantity(),10),this.variantOptionsArray().length>0&&(i.childSKUs=[this.selectedSku()]);var o={productId:i.id,catRefId:i.childSKUs[0].repositoryId,quantityDesired:i.desiredQuantity,displayName:i.displayName},u=[];return u.push(o),u}s.sendError(this.WIDGET_ID,this.translate("productAddError"))},validateAddToPurchaseList:function(){var e=!0;if(this.variantOptionsArray().length>0){var t=this.variantOptionsArray();for(var n=0;n<t.length;n++)if(!t[n].selectedOption.isValid()&&!t[n].disable()){e=!1;break}if(e){var r=this.getSelectedSku(t);if(r===null)return!1}}this.variantOptionsArray().length>0&&this.selectedSku()?e=e&&!this.selectedSku().configurable:e=e&&!this.product().isConfigurable();var i=this.itemQuantity();if(i.toString()!="")if(!i.toString().match(/^\d+$/)||Number(i)<0)return!1;var s=e&&this.product().childSKUs().length>0;return s},clickCotizarButton:function(t){var n=t;e.Topic("SendUsados").publish(n.product().product)},clickReservarButton:function(n){e.Topic("ga_add_to_cart.memory").publish(v.product().product),localStorage.clear();var n=n;h.utils.removeCache("actionType"),localStorage.setItem("flow_id",Date.now()),localStorage.setItem("ocs_product_id",n.product().id()),localStorage.setItem("ocw_product_x_patente",n.product().id()),localStorage.setItem("ocw_product_x_Ubicacion_Fisica",n.product().product.x_Ubicacion_Fisica),localStorage.setItem("ocw_product_x_modelo",n.product().product.x_modelo),localStorage.setItem("ocw_product_x_cilindrada",n.product().product.x_cilindrada),localStorage.setItem("ocw_product_x_kilometraje",n.product().product.x_kilometraje),localStorage.setItem("ocw_product_x_transmision",n.product().product.x_transmision),localStorage.setItem("ocw_product_x_marca",n.product().product.x_marca),localStorage.setItem("ocw_product_x_combustible",n.product().product.x_combustible),localStorage.setItem("ocw_product_x_color",n.product().product.x_color),localStorage.setItem("ocw_product_x_tipo",n.product().product.x_tipo),localStorage.setItem("ocw_product_x_agno",n.product().product.x_agno),localStorage.setItem("ocw_product_brand",n.product().product.x_marca),localStorage.setItem("cotiPrimaryLargeImageURL",n.product().product.primaryLargeImageURL),localStorage.setItem("cotiPrimarySmallImageURL",n.product().product.primarySmallImageURL),localStorage.setItem("modelo",n.product().x_modelo()),localStorage.setItem("version",n.product().x_version()),localStorage.setItem("patente",n.product().id()),localStorage.setItem("imagen",n.product().fullImageURLs()[0]),localStorage.setItem("agno",n.product().x_agno()),localStorage.setItem("kilometraje",n.product().x_kilometraje()),localStorage.setItem("combustible",n.product().x_combustible()),localStorage.setItem("transmision",n.product().x_transmision()),localStorage.setItem("pg_financiadoConvencional",n.product().allPrices().pg_financiadoConvencional),localStorage.setItem("montoDescuento",n.product().allPrices().montoDescuento),localStorage.setItem("pg_bonoDeMarca",n.product().allPrices().pg_bonoDeMarca),localStorage.setItem("pg_financiadoInteligenteBF",n.product().allPrices().pg_financiadoInteligenteBF),localStorage.setItem("pg_precioLista",n.product().allPrices().pg_precioLista);var r=Object.assign({},t.toJS(n.product()));r.variantOptionsArray&&r.variantOptionsArray.forEach(function(e){delete e.parent}),localStorage.setItem("x_product",JSON.stringify(r)),h.utils.cache("actionType","reserve"),p.goTo("/eleccion/"+n.product().id())},selectColorOption:function(t){e(".ocs-color-picker-option").removeClass("active"),e("#ocs-color-item-"+this.key.toLowerCase()).addClass("active"),t.selectedOption(this)},shareProductWhatsAppClick:function(){v.isMobile()?v.shareProductMobileWhatsapp():v.shareProductWebWhatsapp()},shareProductWebWhatsapp:function(){var e=v.product().route(),t=encodeURIComponent(v.product().displayName()),n=window.location.protocol,r=window.location.host,i=window.location.pathname,s=encodeURIComponent(n+"//"+r+i),o=encodeURIComponent(n+"//"+r+v.product().primaryLargeImageURL()),u=window.open("https://web.whatsapp.com://send?text="+s+"&description="+t+"&media="+o,"googlePlusWindow","width=720, height=500");u&&u.focus()},shareProductMobileWhatsapp:function(){var e=encodeURIComponent(v.product().displayName()),t=window.location.protocol,n=window.location.host,r=window.location.pathname,i=encodeURIComponent(t+"//"+n+r),s=encodeURIComponent(t+"//"+n+v.product().primaryLargeImageURL()),o=window.open("whatsapp://send?text="+i+"&description="+e+"&media="+s,"googlePlusWindow","width=720, height=500");o&&o.focus()},shareProductMobile:function(){navigator.share&&navigator.share({title:v.product().displayName(),text:"Mira este "+v.product().displayName()+" en Bruno Fritsch",url:window.location.href})},verSucursal:function(){h.goToLocations("autos-usados")},getPriceGroupName:function(e){var t;return e&&(t=h.pricesGropNames()[e]),t},lowerPrice:function(){var e=v.product().allPrices()[v.getPriceGroupName("financiadoConvencional")],t=v.product().allPrices()[v.getPriceGroupName("lista")],n=v.product().allPrices()[v.getPriceGroupName("bonoDeMarca")],r=v.product().allPrices()[v.getPriceGroupName("reservaWeb")];t>=8e6?v.autoenpagovis(!0):v.autoenpagovis(!1),e&&e<t?v.lowerActivepgFinanciadoConvencional(!0):n?v.lowerActivepgBonoMarca(!0):r?v.lowerActivepgReservaWeb(!0):t&&v.lowerActivepgPrecioLista(!0)},ocs_reservar:function(){v.user().loggedIn()!==!0&&e("#ocs-modal-validate").modal("show")},validate:function(){if(v.cl_id()===""||v.user_email()===""){var t=e("#widget_iduser").val(),n=e("#widget_original_email").val(),r=e("#widget_confirmation_email").val();t!==""&&n!==""&&r!==""?n!=r?e("#widget_message_event").html('<p><i class="fa fa-exclamation-circle" aria-hidden="true"></i> Correos deben coincidir</p>'):T.validaRut(t)===!1?e("#widget_message_event").html('<p><i class="fa fa-exclamation-circle" aria-hidden="true"></i> Formato de RUT incorrecto</p>'):(localStorage.setItem("ocs_reserva_user",t),localStorage.setItem("ocs_reserva_email",n),e("#ocs-modal-validate").modal("hide"),p.goTo("/reserva-automovil")):e("#widget_message_event").html('<p><i class="fa fa-exclamation-circle" aria-hidden="true"></i> Falta información</p>')}else v.user_email()!=v.confirmation_user_email()?e("#widget_message_event").html('<p><i class="fa fa-exclamation-circle" aria-hidden="true"></i> Correos deben coincidir</p>'):x(v.user_email())===!1?e("#widget_message_event").html('<p><i class="fa fa-exclamation-circle" aria-hidden="true"></i> Formato de correo incorrecto</p>'):T.validaRut(v.cl_id())===!1?e("#widget_message_event").html('<p><i class="fa fa-exclamation-circle" aria-hidden="true"></i> Formato de RUT incorrecto</p>'):(localStorage.setItem("ocs_reserva_user",v.cl_id()),localStorage.setItem("ocs_reserva_email",v.user_email()),e("#ocs-modal-validate").modal("hide"),p.goTo("/reserva-automovil"))}}})
|