(globalThis.webpackChunkwebpackWcBlocksFrontendJsonp=globalThis.webpackChunkwebpackWcBlocksFrontendJsonp||[]).push([[462],{5547:(e,t,s)=>{"use strict";s.r(t),s.d(t,{Block:()=>i,default:()=>l});var n=s(2796),r=s(3754),o=s(1616),a=s(6980),c=(s(4053),s(790));const i=e=>{const{textAlign:t="",shouldDisplayMockedReviewsWhenProductHasNoReviews:s,isDescendentOfQueryLoop:o,product:i}=e,l=(0,r.p)(e),{parentClassName:u}=(0,n.useInnerBlockLayoutContext)(),{product:m}=(0,n.useProductDataContext)({product:i,isAdmin:e.isAdmin}),d=m?(0,a.p3)(m):0,p=m?(0,a.Nm)(m):0;if(p||s)return(0,c.jsx)(a.fb,{className:"wc-block-components-product-rating",showReviewCount:!o,showMockedReviews:s,styleProps:l,parentClassName:u,reviews:p,rating:d,textAlign:t})},l=(0,o.withProductDataContext)(i)},3754:(e,t,s)=>{"use strict";s.d(t,{p:()=>l});var n=s(4921),r=s(3993),o=s(7356),a=s(9786);function c(e={}){const t={};return(0,a.getCSSRules)(e,{selector:""}).forEach(e=>{t[e.key]=e.value}),t}function i(e,t){return e&&t?`has-${(0,o.c)(t)}-${e}`:""}const l=e=>{const t=(e=>{const t=(0,r.isObject)(e)?e:{style:{}};let s=t.style;return(0,r.isString)(s)&&(s=JSON.parse(s)||{}),(0,r.isObject)(s)||(s={}),{...t,style:s}})(e),s=function(e){const{backgroundColor:t,textColor:s,gradient:o,style:a}=e,l=i("background-color",t),u=i("color",s),m=function(e){if(e)return`has-${e}-gradient-background`}(o),d=m||a?.color?.gradient;return{className:(0,n.A)(u,m,{[l]:!d&&!!l,"has-text-color":s||a?.color?.text,"has-background":t||a?.color?.background||o||a?.color?.gradient,"has-link-color":(0,r.isObject)(a?.elements?.link)?a?.elements?.link?.color:void 0}),style:c({color:a?.color||{}})}}(t),o=function(e){const t=e.style?.border||{};return{className:function(e){const{borderColor:t,style:s}=e,r=t?i("border-color",t):"";return(0,n.A)({"has-border-color":!!t||!!s?.border?.color,[r]:!!r})}(e),style:c({border:t})}}(t),a=function(e){return{className:void 0,style:c({spacing:e.style?.spacing||{}})}}(t),l=(e=>{const t=(0,r.isObject)(e.style.typography)?e.style.typography:{},s=(0,r.isString)(t.fontFamily)?t.fontFamily:"";return{className:e.fontFamily?`has-${e.fontFamily}-font-family`:s,style:{fontSize:e.fontSize?`var(--wp--preset--font-size--${e.fontSize})`:t.fontSize,fontStyle:t.fontStyle,fontWeight:t.fontWeight,letterSpacing:t.letterSpacing,lineHeight:t.lineHeight,textDecoration:t.textDecoration,textTransform:t.textTransform}}})(t);return{className:(0,n.A)(l.className,s.className,o.className,a.className),style:{...l.style,...s.style,...o.style,...a.style}}}},6980:(e,t,s)=>{"use strict";s.d(t,{Nm:()=>i,fb:()=>p,p3:()=>c});var n=s(7723),r=s(4921),o=s(3993),a=s(790);const c=e=>{const t=parseFloat(e.average_rating);return Number.isFinite(t)&&t>0?t:0},i=e=>{if("review_count"in e){const t=(0,o.isNumber)(e.review_count)?e.review_count:parseInt(e.review_count,10);return Number.isFinite(t)&&t>0?t:0}if("rating_count"in e){const t=(0,o.isNumber)(e.rating_count)?e.rating_count:parseInt(e.rating_count,10);return Number.isFinite(t)&&t>0?t:0}return 0},l=e=>({width:e/5*100+"%"}),u=({className:e,parentClassName:t})=>{const s=l(0);return(0,a.jsxs)("div",{className:(0,r.A)(`${e}__norating-container`,`${t}-product-rating__norating-container`),children:[(0,a.jsx)("div",{className:`${e}__norating`,role:"img",children:(0,a.jsx)("span",{style:s})}),(0,a.jsx)("span",{children:(0,n.__)("No Reviews","woocommerce")})]})},m=e=>{const{className:t,rating:s,reviews:o,parentClassName:c}=e,i=l(s),u=(0,n.sprintf)(/* translators: %f is referring to the average rating value */ /* translators: %f is referring to the average rating value */
(0,n.__)("Rated %f out of 5","woocommerce"),s),m={__html:(0,n.sprintf)(/* translators: %1$s is referring to the average rating value, %2$s is referring to the number of ratings */ /* translators: %1$s is referring to the average rating value, %2$s is referring to the number of ratings */
(0,n._n)("Rated %1$s out of 5 based on %2$s customer rating","Rated %1$s out of 5 based on %2$s customer ratings",o,"woocommerce"),(0,n.sprintf)('<strong class="rating">%f</strong>',s),(0,n.sprintf)('<span class="rating">%d</span>',o))};return(0,a.jsx)("div",{className:(0,r.A)(`${t}__stars`,`${c}__product-rating__stars`),role:"img","aria-label":u,children:(0,a.jsx)("span",{style:i,dangerouslySetInnerHTML:m})})},d=e=>{const{className:t,reviews:s}=e,r=(0,n.sprintf)(/* translators: %s is referring to the total of reviews for a product */ /* translators: %s is referring to the total of reviews for a product */
(0,n._n)("(%s customer review)","(%s customer reviews)",s,"woocommerce"),s);return(0,a.jsx)("span",{className:`${t}__reviews_count`,children:r})},p=e=>{const{className:t="wc-block-components-product-rating",showReviewCount:s,showMockedReviews:n,parentClassName:o="",rating:c,reviews:i,styleProps:l,textAlign:p}=e,g=(0,r.A)(l.className,t,{[`${o}__product-rating`]:o,[`has-text-align-${p}`]:p}),f=n&&(0,a.jsx)(u,{className:t,parentClassName:o}),N=i?(0,a.jsx)(m,{className:t,rating:c,reviews:i,parentClassName:o}):f,y=i&&s;return(0,a.jsx)("div",{className:g,style:l.style,children:(0,a.jsxs)("div",{className:`${t}__container`,children:[N,y?(0,a.jsx)(d,{className:t,reviews:i}):null]})})}},4053:()=>{}}]);