(()=>{"use strict";const t="ProductItemListViewLayout",n="ProductItem",o="QuickView",i="SearchProductItem",a=[];let r=0;const s=(e,t,n)=>{const o=e?.metafields?.filter((function(e){return e?.namespace===t&&e.key===n}));return o?.[0]?.value??""},d=(e,a)=>{const r=e.getNearestParentElm(a,n)||e.getNearestParentElm(a,t)||e.getNearestParentElm(a,o)||e.getNearestParentElm(a,i),{props:s}=r?.getParams()||{};return s?s.product||s.productData:null},c=(e,t)=>{r++;const n=e+r;a[n]&&clearInterval(a[n]);let o=0;return new Promise(((i,r)=>{a[n]=setInterval((()=>{try{const n=document.querySelectorAll(e),a=t?n.length===t:n.length;(100===o||a)&&(clearInterval(window.intervalGetElement),i(n.length?n:null)),o++}catch(e){r(e)}}),100)}))},l=()=>{!function(e){window.jdgm=window.jdgm||{},jdgm.CDN_HOST="https://cdn.judge.me/",jdgm.docReady=function(t){(e.attachEvent?"complete"===e.readyState:"loading"!==e.readyState)?setTimeout(t,0):e.addEventListener("DOMContentLoaded",t)},jdgm.loadCSS=function(t,n,o,i){!o&&jdgm.loadCSS.requestedUrls.indexOf(t)>=0||(jdgm.loadCSS.requestedUrls.push(t),(i=e.createElement("link")).rel="stylesheet",i.class="jdgm-stylesheet",i.media="nope!",i.href=t,i.onload=function(){this.media="all",n&&setTimeout(n)},e.body.appendChild(i))},jdgm.loadCSS.requestedUrls=[],jdgm.loadJS=function(e,t){var n=new XMLHttpRequest;n.onreadystatechange=function(){4===n.readyState&&(Function(n.response)(),t&&t(n.response))},n.open("GET",e),n.send()},jdgm.docReady((function(){(window.jdgmLoadCSS||e.querySelectorAll(".jdgm-widget, .jdgm-all-reviews-page").length>0)&&"undefined"!=typeof jdgmSettings&&(jdgmSettings.widget_load_with_code_splitting?parseFloat(jdgmSettings.widget_version)>=3?jdgm.loadCSS(jdgm.CDN_HOST+"widget_v3/base.css"):jdgm.loadCSS(jdgm.CDN_HOST+"widget/base.css"):jdgm.loadCSS(jdgm.CDN_HOST+"shopify_v2.css"),jdgm.loadJS(jdgm.CDN_HOST+"loader.js"))}))}(document)},u=(e,t)=>{let n=!1;const o={name:"Product Review",apply:()=>({props(n,o){const i=d(e,o);return i&&("ryviu"!==t&&"okendo"!==t&&"aliReview"!==t||(n.ignoreCheckingTemplate=!0),n.template=(e=>{switch(t){case"aliReview":return`\n \n \n `;case"judgeme":const t=s(e,"judgeme","badge");return t?`\n
\n ${t}\n
\n `:null;case"LAIAliExpress":const n=s(e,"scm_review_importer","reviewsData")||"";if(!n)return null;const o=JSON.parse(n);return`\n \n \n `;case"loox":const i=s(e,"loox","avg_rating"),a=s(e,"loox","num_reviews");return null===i||null===a?null:`\n
\n
\n `;case"okendo":return(document&&document.getElementById("okendo-reviews-script")?null!==s(e,"okendo","StarRatingSnippet")?s(e,"okendo","StarRatingSnippet"):"":null!==s(e,"okendo","ProductListingSnippet")?s(e,"okendo","ProductListingSnippet"):"")??"";case"prs":return``;case"reviewsLoyaltyWishlist":let r=0,d=0,c="";const l=s(e,"ssw","review")??"";if(!l)return null;const u=JSON.parse(l)||{};r=u?.count,d=u?.avg;let p="";const m=Math.floor(d);for(let e=1;e<=m;e++)p+='';const w=5-d;let g=Math.floor(w);const y=d-m;y>.74?p+='':y>.24?p+='':y>0&&(g+=1);let v="";for(let e=0;e';return c+=`\n \n ${p}\n ${v}\n (${r})\n \n `,c;case"rivyo":return`\n \n \n `;case"ryviu":return`\n
\n \n \n
\n `;case"stamped":return`\n \n \n `;case"yotpo":let h=`\n
\n \n
\n \n `,f=e?.body_html??"";return f=f.substr(0,f.indexOf("##highlights##")),h=h.replace(/{{itemDescription}}/g,f),h=h.replace(/{{itemTags}}/g,e?.tags?.join(";")),h;default:return null}})(i)),n}})},i={name:"Product Review - Call Callback Func",apply:()=>({afterRender(){(()=>{try{switch(t){case"judgeme":if(!n&&document.querySelectorAll(".boost-sd__integration-product-rating").length>0)return n=!0,l();case"aliReview":if("function"==typeof window.aliReviewsAddRatingCollection)return window.aliReviewsAddRatingCollection();case"LAIAliExpress":if(window.SMARTIFYAPPS?.rv?.installed&&"function"==typeof window.SMARTIFYAPPS?.rv?.scmReviewsRate?.actionCreateReviews)return window.SMARTIFYAPPS?.rv?.scmReviewsRate?.actionCreateReviews();case"prs":if(!window.SPR)return;"function"==typeof window.SPR?.initDomEls&&window.SPR?.initDomEls(),"function"==typeof window.SPR?.loadBadges&&window.SPR?.loadBadges();break;case"rivyo":const e=e=>new Promise(((t,n)=>{const o=new XMLHttpRequest;o.open("POST","//thimatic-apps.com/product_review/get_review_rating_update.php"),o.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8"),o.onload=function(){try{const e=JSON.parse(o.responseText);o.readyState>3&&(200===o.status?t(e):n(null))}catch(e){n(null)}},o.send(e)})),t=window.boostSDAppConfig?.shop?.domain||"",o=document.querySelectorAll(".wc_product_review_badge_boostcommerce");let i=`shop=${t}`,a=0;o.forEach((async(n,r)=>{let s=n?.dataset?.product_id;if(0==n.querySelectorAll(".wc_review_badge_inner").length&&0==n.querySelectorAll(".wc_review_badge_inner_empty").length&&""!=s&&(i+="&product_ids[]="+s,a+=1),r===o.length-1&&0!=a&&""!=t){const t=await e(i);if(t){o.forEach((e=>{e&&(e.innerHtml=t?.empty?.html||"")}));for(const e in t){const n=document.querySelectorAll(`.wc_product_review_badge_boostcommerce[data-product_id="${e}"]`);n?.forEach((n=>{n&&(n.innerHTML=t[e]?.html)}))}}}}));break;case"stamped":if("function"==typeof window.StampedFn?.loadBadges||document.getElementById("stamped-script-widget"))return window.StampedFn.loadBadges();case"yotpo":window?.yotpo&&"function"==typeof window?.yotpo.initWidgets&&yotpo.initWidgets(),window?.yotpoWidgetsContainer&&"function"==typeof window?.yotpoWidgetsContainer.initWidgets&&yotpoWidgetsContainer.initWidgets();break;default:return null}}catch(e){console.log("Error when try to callbackFunc() from 3rd app"),console.log(e.stack)}})()}})},a=boostSDAppConfig?.themeSettings?.productItems?.productImg?.elements?.rating,r=boostSDAppConfig?.themeSettings?.productItems?.productInfo?.elements?.rating;(a||r)&&(e.useComponentPlugin("IntegrationProductRating",o),e.useComponentPlugin("ProductList",i),e.useComponentPlugin("SearchProductList",i),e.useComponentPlugin("QuickView",i),e.useComponentPlugin("Slider",i),e.useComponentPlugin("RecommendationBundle",i))},p=e=>{let t=null;return"auto"===e&&(t=window.Currency??window.ACSCurrency),"best"===e&&(t=window.DoublyGlobalCurrency),t},m=(e,t)=>{const n={name:"Multiple Currency - Append Props",apply:()=>({props:e=>(e.getRateCurrency=(e=>t=>{const n=p(e);if(n){const e=n.rates?.[t||n.currentCurrency],o=n.rates?.[window.boostSDAppConfig?.shop?.currency];return e&&o?o/e:1}return 1})(t),e.getUnitCurrency=(e=>t=>{const n=p(e);return n?n.moneyFormats[t||n.currentCurrency]?.money_format:null})(t),e)})},o={name:"Multiple Currency - Append Props",apply:()=>({props:e=>(e.appendClassName="money",e)})},i={name:"Multiple Currency - Set Event Element",apply:()=>({afterInit(e){const n=e.getHelpers();(async(e,t,n)=>{const o=await c(t);if(o&&e){const t=p(n).currentCurrency;e({target:{dataset:{value:t}}}),"currency-switcher"!==o?.[0].classList[0]||o?.[1]?o.forEach((t=>{t.classList.contains("currency-switcher")||t.addEventListener("click",e)})):o[0].addEventListener("change",(t=>{e({target:{dataset:{value:t.target?.value}}})}))}})(n?.setInfoCurrency,"auto"===t?".nice-select .option":"best"===t?".doubly-nice-select .option, .currency-switcher-btn, .currency-switcher":"",t)}})},a=()=>{const e=p(t);if(e){if(void 0!==e&&void 0!==e.moneyFormats&&void 0!==e.moneyFormats[window?.mlvShopCurrency]&&void 0!==window?.mlvedaload)try{window?.mlvedaload()}catch(e){console.log(e)}"function"==typeof window.DoublyGlobalCurrency?.convertAll&&window.DoublyGlobalCurrency.convertAll(window.DoublyGlobalCurrency.currentCurrency)}},r={name:"Multiple Currency - Callback Func",apply:()=>({props:e=>(e.callbackFuncAppIntegration=(e.callbackFuncAppIntegration??[]).concat(a),e),afterRender(){a()}})};e.useComponentPlugin("FormatCurrency",o),e.useComponentPlugin("CurrencyProvider",n),e.useComponentPlugin("CurrencyProvider",i),e.useComponentPlugin("SearchProductList",r),e.useComponentPlugin("ProductList",r),e.useComponentPlugin("QuickView",r),e.useComponentPlugin("Slider",r),e.useComponentPlugin("RecommendationBundle",r)},w=e=>{const t="en",n=e=>new Promise((n=>{(window.Weglot?.initialized&&"function"==typeof window.Weglot?.getCurrentLang&&window.Weglot.getCurrentLang()||t)===t&&n(e),window.Weglot?.search(e,(function(e){n(e)}))})),o={name:"Multiple Language - Weglot - Change Locale Plugin With Search Key",apply(e){e.on("beforeMethodCall","get",(async e=>{e.args[1].translateSearchParams=await n(e.args[0])}))}};e.useModulePlugin("SearchAPI",o)},g=e=>{const t={name:"Other - Fera Review - Append Template Product Review",apply:()=>({props(t,n){const o=d(e,n);var i;return o&&(t.template=(i=o,`
`)),t}})};e.useComponentPlugin("IntegrationProductReviewFera",t)},y=e=>{const t={name:"Other - Secomapp Quick View - Append Template Product Quick View",apply:()=>({props(t,n){const o=d(e,n);var i;return o&&(t.template=(i=o,`\n
\n \n
\n \n \n `)),t}})},n={name:"Other - Secomapp Quick View - Apply Event Remove Class",apply:()=>({afterRender(){window.SCAShopify&&(window.SCAShopify?.jQuery(document).unbind("click.fb-start"),window.SCAShopify.loaded=!1,window.SCAQVinit=void 0,window.SCAShopify?.jQuery.getScript(SCAShopify.jQuery('script[src*="sca-qv-"]').attr("src"))),(async()=>{const e=document.querySelectorAll(".boost-sd__product-item");if(e.length){const t=await c(".sca-qv-image",e.length);t&&(t.forEach((e=>{e.classList.remove("sca-qv-image")})),e.forEach((e=>{e.classList.add("sca-qv-image")})),e.forEach((e=>{const t=e.getElementsByClassName("sca-qv-button")?.[0]?.parentElement;e.addEventListener("mouseover",(()=>{window.SCAShopify?.jQuery(t).show()}))})))}})()}})};e.useComponentPlugin("ProductList",n),e.useComponentPlugin("IntegrationProductQuickView",t),e.useComponentPlugin("Slider",n),e.useComponentPlugin("Slider.IntegrationProductQuickView",t),e.useComponentPlugin("RecommendationBundle",n),e.useComponentPlugin("IntegrationProductQuickView",t)},v=t=>{const n=t=>function(t){if(!t)return{};try{var n=t.handle,o="",i="";if(t.collections&&t.collections.length>0)for(var a=0;a0?100*s.price:0,"data-limoniapps-discountninja-product-compareatprice":s&&s.compare_at_price>0?100*s.compare_at_price:0,"data-limoniapps-discountninja-product-pricevaries":t.price_min!=t.price_max,"data-limoniapps-discountninja-product-pricemin":t.price_min?100*t.price_min:0,"data-limoniapps-discountninja-product-tags":function(t){try{return null==t?"":"string"==typeof t?t?t.replace(/"/g,"""):"":Array.isArray(t)?t.join(",").replace(/"/g,"""):(console.error("Boost PFS buildTags failed, unexpected data type of tags",e),"")}catch(e){return console.error("Boost PFS buildTags failed",e),""}}(t.tags)}}catch(e){return console.error("Boost SD buildDiscountNinjaDataTags failed",e),""}}(t),o={name:"Other - Discount Ninja - Append Template Product",apply:()=>({props:e=>(e?.product&&(e.attributes=n(e?.product)),e),afterRender(){document.dispatchEvent(new CustomEvent("limoniapps:discountninja:collection:productsadded")),void 0!==window?.discountNinja&&window?.discountNinja.DynamicPricing.UpdatePrice()}})};t.useComponentPlugin("ProductItem",o)},h=(e,t)=>"fera"===t?g(e):"secomapp"===t?y(e):"discount-ninja"===t?v(e):void 0,f=(e,t)=>{const n={name:"Product Label - Append Template Label",enabled:!0,apply:()=>({props:(n,o)=>{const i=d(e,o);var a;return i&&(n.template=(a=i,"flair"===t?`\n
\n `:"")),n}})},o=()=>{try{switch(t){case"deco":"function"==typeof window.SECOMAPP?.pl?.labelCollections&&window.SECOMAPP.pl.labelCollections(!0);break;case"flair":"function"==typeof window.FlairApp?.refreshProductBadges&&window.FlairApp.refreshProductBadges();break;default:return null}}catch(e){console.log("Error when try to callbackFunc() from 3rd app"),console.log(e.stack)}},i={name:"Product Label - Append Class Product Item",apply:()=>({className:"grid-product__content",props:e=>e})},a={name:"Product Label - Append Class Product Link",apply:()=>({className:"grid-product__link",props:e=>e})},r={name:"Product Label - Call Callback Func",apply:()=>({props:e=>(e.callbackFuncAppIntegration=(e.callbackFuncAppIntegration??[]).concat(o),e),afterRender(){o()}})};e.useComponentPlugin("IntegrationProductLabel",n),e.useComponentPlugin("ProductList",r),"deco"===t&&(e.useComponentPlugin("ProductItem",i),e.useComponentPlugin("ProductLink",a)),e.useComponentPlugin("Slider",r),e.useComponentPlugin("RecommendationBundle",r)},C=(e,t)=>{const n=e=>{switch(t){case"growave":return`\n
\n \n \n ...\n
\n `;case"i-wishlist":return`\n \n `;case"smart":return``;case"plus":return`\n \n `;default:return null}},o={name:"Product Wishlist - Append Template Wishlist",apply:()=>({props(t,o){const i=e.getNearestParentElm(o,"ProductItem"),{props:a}=i?.getParams()||{};return a&&(t.template=n(a.product)),t}})},i={name:"Product Wishlist - Append Style Image Wishlist",apply:()=>({props:e=>("wishlist-1"===t&&(e.displayBlock=!0),e)})},a=()=>{try{switch(t){case"plus":window?._swat?.initializeActionButtons?.(".boost-sd__product-list"),document.dispatchEvent(new CustomEvent("swym:collections-loaded"));break;case"smart":window?.ReloadSmartWishlist?.();break;case"i-wishlist":"undefined"!=typeof jQuery&&jQuery(".iWishAddColl").click((function(e){e.preventDefault();var t=jQuery(this).attr("data-variant");return iwish_addCollection(jQuery(this),t),!1}));break;case"king":try{if(!window?.WishlistKing)return;const e=window.WishlistKing?.theme;e?e.watch?.({selector:".boost-sd__product-link-image"},(t=>{t.insertAfter(e.createComponent?.("wishlist-button-collection",{dataset:{productHandle:e.getProductHandle?.(t.element.href),variantId:e.getVariantId?.(t.element.href)},props:{showIcon:!0,showText:!1,floating:{reference:t,position:{placement:"top-end",inset:!0}}}}))})):window.WishlistKing?.observe?.({selector:".boost-sd__product-item"},(e=>{e.append?.(window.WishlistKing?.createComponent?.("wishlist-button-floating",{id:e.container?.getAttribute?.("id")}))}))}catch(e){}break;default:return null}}catch(e){console.log("Error when try to callbackFunc() from 3rd app - Product Wishlist"),console.log(e.stack)}},r={name:"Product Wishlist - Call Callback Func",apply:()=>({props:e=>(e.callbackFuncAppIntegration=(e.callbackFuncAppIntegration??[]).concat(a),e),afterRender(){a()}})};e.useComponentPlugin("IntegrationProductWishlist",o),e.useComponentPlugin("ProductImage",i),e.useComponentPlugin("ProductList",r),e.useComponentPlugin("Slider",r),e.useComponentPlugin("RecommendationBundle",r)},S=window.boostSDAppConfig?.integration;if(S){const e={reviews:e=>u(e,S.reviews),currencies:e=>m(e,S.currencies),languages:e=>w(e,S.languages),others:e=>h(e,S.others),labels:e=>f(e,S.labels),wishlists:e=>C(e,S.wishlists)},t=[];for(const n in S)e[n]&&t.push(e[n]);window.__BoostCustomization__=(window.__BoostCustomization__??[]).concat(t)}})(); //# sourceMappingURL=boost-sd-integration.js.map