!async function(){const e=k("#trustoo-card-carousel-widget");if(!e||e&&null!==e.getAttribute("filled"))return;let t;e.setAttribute("filled",!0),k("#seal_shop_id")&&(t=JSON.parse(document.querySelector("#seal_shop_id").textContent));const r=new Date("2023-11-20 10:50:43").getTime()/1e3;if(!k(".tt-review-detail-js")){const e=document.createElement("script");let t="";t="https://cdn.vstar.app/static/js/tt-review-detail.js?",t+=r,e.setAttribute("src",t),e.setAttribute("defer",!0),e.className="tt-review-detail-js",e.onload=function(){insertReviewDetail(v),k(".close-wrapper",v.revDetail).addEventListener("click",(function(){E()}))},document.head.appendChild(e)}let s="",i=0,n=12,a=0,o=0,l=!1,d=null,c={};const u=function(){let e=navigator.userAgent,t=/(?:Android)/.test(e),r=/(?:Firefox)/.test(e),s=/(?:iPad|PlayBook)/.test(e)||t&&!/(?:Mobile)/.test(e)||r&&/(?:Tablet)/.test(e),i=/(?:iPhone)/.test(e)&&!s;return t||i}(),v={userSetting:{},isMobile:u,isMixReview:!0,revDetailInfo:{page:0,imageIndex:0},reviewsList:null,env:"production",staticBaseUrl:"cdn.vstar.app",constructTime:r};"undefined"!=typeof vstar_review_settings&&(v.userSetting.is_del_powered=vstar_review_settings.is_del_powered);const _={getSetting:{url:"get_card_carousel_setting",params:{shop_id:t}},getLang:{url:"get_customer_self_define_lang",params:{shop_id:t,lang:"en"}},getReviews:{url:"get_product_reviews",params:{shop_id:t}}};let w={},p=[],h=[],g=await O("getSetting");w=g[1];const f=w;if(!w)return;let m=f.max_columns;u&&(m=1),2===m?o=210:3===m?o=230:4!==m&&1!==m||(o=250),document.head.insertAdjacentHTML("beforeend",''),k("#tt-swiper-style").textContent+=`\n.tt-swiper {\n --column:${m};\n --common-height: ${o}px;\n --header-card-bd:${w.header_card_bg_color};\n --header-star-color:${w.header_star_color};\n --header-nostar-color:${w.header_disabled_star_color};\n --header-text:${w.header_text_color};\n --card-bd-color:${w.widget_layout_card_bg_color};\n --star-color:${w.widget_layout_star_color};\n --nostar-color:${w.widget_layout_disabled_star_color};\n --text-color:${w.widget_layout_text_color};\n --badge-color:${w.widget_layout_badge_color};\n --badge-text-color:${w.widget_layout_badge_text_color};\n --button-color:${w.scroll_buttons_icon_color};\n}\n#trustoo-review-detail{\n\t--star-color:${w.widget_layout_star_color};\n--nostar-color:${w.widget_layout_disabled_star_color};\n}\n}\n`;let y="",x="";1===f.is_show_header?y='
':x="no-header";const b=w.scroll_buttons_icon_color;s=`\n \n ${y}\n
\n
\n ${s}\n
\n
${H("pre",b)}
\n
${H("next",b)}
\n
\n
\n `,e.insertAdjacentHTML("beforeend",s),langReq=O("getLang"),langReq.then((e=>{const t=k(".tt-swiper-header");c=JSON.parse(e[1].lang_json);const r=c.card_carousel;q(".tt-review-verify").forEach((e=>e.textContent=c.verified_purchase)),1===w.is_show_header&&(k(".swiper-header-title",t).textContent=r.header_title,k(".swiper-header-rating",t).textContent+=" "+r.header_review_rating_text,k(".swiper-header-count",t).textContent+=" "+r.header_review_count_text),q(".tt-card .tt-review-verify").forEach((e=>e.textContent=c.verified_purchase))})),1===w.show_reviews?_.getReviews.params.is_show_all=1:2===w.show_reviews&&(_.getReviews.params.is_feature=1);let $=await O("getReviews");if($[0])return;if(p=$[1],h=p.list,v.reviewsList=h,1===w.is_show_header){let t=p.total_rating.total_reviews;if(t>1e3){let e=String(t);const r=e.length;t=e.substring(0,r-3)+","+e.substring(r-3,r)}const r=k(".tt-swiper-header .swiper-header-rating"),s=k(".tt-swiper-header .swiper-header-count");k(".swiper-header-stars",e).innerHTML=D(p.total_rating.rating),r.textContent=p.total_rating.rating+r.textContent,s.textContent=t+s.textContent}n=h.length-m,a=n,h=p.list,sessionStorage.setItem("trustoo_swiper_reviews",JSON.stringify(h));let C="",L=c.verified_purchase?c.verified_purchase:"";h.forEach(((e,t)=>{let r="",s="",i="";1===w.is_show_verified_purchase&&1===e.verified_badge&&(r=`\n ${H("verified",w.widget_layout_badge_color)}\n ${L}
`);const n=e.commented_at.split("-");1===w.review_date_format_type?s=n[1]+"/"+n[2]+"/"+n[0]:2===w.review_date_format_type&&(s=n[2]+"/"+n[1]+"/"+n[0]),1===w.is_show_country_flag&&(i=e.author_country);let a="";e.resources.forEach(((e,t)=>{if(1===e.resource_type){let r="";r=e.width
\n\t\t\t\t`}})),a=`${a}
`,C+=`\n \n
\n
\n
\n
${e.author}
\n
${D(e.star)}
\n
\n ${r}\n
\n
\n ${e.content}\n
\n \n
\n
\n `})),k(".tt-card-list",e).insertAdjacentHTML("afterBegin",C),q(".tt-card .tt-review-verify").forEach((e=>e.textContent=c.verified_purchase));const S=B(E,300),T=B((function(){d&&(clearInterval(d),d=null)}),300),M=k(".tt-card-list"),j=k(".tt-swiper-pre"),A=k(".tt-swiper-next");function E(){null===d&&k("#trustoo-mask")&&"none"===getComputedStyle(k("#trustoo-mask")).display&&(d=setInterval((()=>{R(1)}),3e3))}function I(){let e=l?"instant":"smooth";const t=(n-a)*i;M.scrollTo({left:t,behavior:e})}function R(e){1===e?(a--,a<0?(a=n,l=!0):l=!1,I()):2===e&&(a++,a>n?(a=0,l=!0):l=!1,I())}function k(e,t){let r;return r=t?t.querySelector(e):document.querySelector(e),r}function q(e,t){let r;return r=t?t.querySelectorAll(e):document.querySelectorAll(e),r}function D(e){parseInt(e)||(e=0);for(var t="",r=Math.floor(e),s=0;s';for(e>r&&(t+=`
`,r++),s=r;s<5;s++)t+='
';return t}function H(e,t="#000"){let r="";switch(e){case"verified":r=``;break;case"pre":r=`\n `;break;case"next":r=`\n `}return r}function O(e){let t="";const r=_[e];return"undefined"!=typeof vstar_review_settings&&(1===vstar_review_settings.auto_switch_language?t=Shopify.locale?Shopify.locale:"":1===vstar_review_settings.is_translate_review&&(t=vstar_review_settings.language)),"getReviews"===e?(r.params.t=(new Date).getTime(),t&&(r.params.lang=t)):"getLang"===e&&w.card_lang&&(r.params.lang=w.card_lang),new Promise(((e,t)=>{Object.assign(r,{res:e,rej:t}),function(e){const{params:t,method:r="GET"}=e,s=e.res,i=e.rej;let n=new XMLHttpRequest,a="https://api.trustoo.io/api/v1/reviews/"+e.url,o="";"object"==typeof t&&(o=Object.keys(t).reduce(((e,r)=>e+"&"+r+"="+t[r]),"")),"POST"==r?(n.open(r,a,!0),o=o&&!isOss?o.slice(1):t,n.send(o)):"GET"==r&&(o&&(o=o.replace("&","?"),a+=o),n.open(r,a,!0),n.send()),n.onreadystatechange=()=>{if(4==n.readyState){let e=n.responseText;200==n.status||203==n.status?s&&s(e):i&&i({responseText:e,statusText:n.statusText})}}}(r)})).then((e=>{if(-1===(e=JSON.parse(e)).code)throw new Error(e.message);return[null,e=e.data]})).catch((e=>[{error:e}]))}function B(e,t){var r=null;return function(...s){r&&clearTimeout(r),r=setTimeout((()=>{e(...s)}),t)}}i=parseInt(getComputedStyle(M).width)/m,j.onclick=function(){R(2)},A.onclick=function(){R(1)},j.onmouseenter=A.onmouseenter=T,j.onmouseleave=A.onmouseleave=S,q(".tt-card",M).forEach((e=>{e.onmouseenter=T,e.onmouseleave=S,e.onclick=function(){document.body.classList.add("trustoo-open");const t=this.getAttribute("no");v.revDetailInfo.no=t,v.revDetailInfo.imageIndex=0;let r=k(".tt-card-head",e).outerHTML+k(".tt-card-footer",e).outerHTML+k(".tt-card-body",e).outerHTML;showReviewDetail(v,r,h[t],"trustoo_swiper_review")}})),window.addEventListener("resize",(function(){const e=window.innerWidth;e<500?m=1:e<968&&e>=500?m=2:e>=968&&(m=f.max_columns);const t=n-a;n=h.length-m,a=n-t,i=parseInt(getComputedStyle(M).width)/m,I()})),E()}();
//# sourceMappingURL=swiper-reviews.min.js.map