HEX
Server: Apache
System: Linux host17.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
User: shrsglobal (7178)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: /home/shrsglobal/www/wp-content/plugins/woocommerce/assets/client/blocks/reviews-by-product.js
(()=>{var e,t,r,o={5615:(e,t,r)=>{"use strict";const o=window.wp.blocks;var s=r(4530),i=r(3791),n=(r(4809),r(7723));const a=window.wp.blockEditor,c=window.wp.components;var l=r(4921),d=r(6087);function m(e,t,r){const o=new Set(t.map((e=>e[r])));return e.filter((e=>!o.has(e[r])))}const h=window.wp.htmlEntities;var u=r(790);const p={clear:(0,n.__)("Clear all selected items","woocommerce"),noItems:(0,n.__)("No items found.","woocommerce"),
/* Translators: %s search term */
noResults:(0,n.__)("No results for %s","woocommerce"),search:(0,n.__)("Search for items","woocommerce"),selected:e=>(0,n.sprintf)(/* translators: Number of items selected from list. */ /* translators: Number of items selected from list. */
(0,n._n)("%d item selected","%d items selected",e,"woocommerce"),e),updated:(0,n.__)("Search results updated.","woocommerce")},w=(e,t=e)=>{const r=e.reduce(((e,t)=>{const r=t.parent||0;return e[r]||(e[r]=[]),e[r].push(t),e}),{}),o=t.reduce(((e,t)=>(e[String(t.id)]=t,e)),{});const s=["0"],i=(e={})=>e.parent?[...i(o[e.parent]),e.name]:e.name?[e.name]:[],n=e=>e.map((e=>{const t=r[e.id];return s.push(""+e.id),{...e,breadcrumbs:i(o[e.parent]),children:t&&t.length?n(t):[]}})),a=n(r[0]||[]);return Object.entries(r).forEach((([e,t])=>{s.includes(e)||a.push(...n(t||[]))})),a},g=(e,t)=>{if(!t)return e;const r=new RegExp(`(${t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")})`,"ig");return e.split(r).map(((e,t)=>r.test(e)?(0,u.jsx)("strong",{children:e},t):(0,u.jsx)(d.Fragment,{children:e},t)))},v=({label:e})=>(0,u.jsx)("span",{className:"woocommerce-search-list__item-count",children:e}),_=e=>{const{item:t,search:r}=e,o=t.breadcrumbs&&t.breadcrumbs.length;return(0,u.jsxs)("span",{className:"woocommerce-search-list__item-label",children:[o?(0,u.jsx)("span",{className:"woocommerce-search-list__item-prefix",children:(s=t.breadcrumbs,1===s.length?s.slice(0,1).toString():2===s.length?s.slice(0,1).toString()+" › "+s.slice(-1).toString():s.slice(0,1).toString()+" … "+s.slice(-1).toString())}):null,(0,u.jsx)("span",{className:"woocommerce-search-list__item-name",children:g((0,h.decodeEntities)(t.name),r)})]});var s},b=({countLabel:e,className:t,depth:r=0,controlId:o="",item:s,isSelected:i,isSingle:n,onSelect:a,search:p="",selected:w,useExpandedPanelId:b,...x})=>{const[y,f]=b,j=null!=e&&void 0!==s.count&&null!==s.count,R=!!s.breadcrumbs?.length,k=!!s.children?.length,S=y===s.id,C=(0,l.A)(["woocommerce-search-list__item",`depth-${r}`,t],{"has-breadcrumbs":R,"has-children":k,"has-count":j,"is-expanded":S,"is-radio-button":n});(0,d.useEffect)((()=>{k&&i&&f(s.id)}),[s,k,i,f]);const N=x.name||`search-list-item-${o}`,P=`${N}-${s.id}`,L=(0,d.useCallback)((()=>{f(S?-1:Number(s.id))}),[S,s.id,f]);return k?(0,u.jsx)("div",{className:C,onClick:L,onKeyDown:e=>"Enter"===e.key||" "===e.key?L():null,role:"treeitem",tabIndex:0,children:n?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("input",{type:"radio",id:P,name:N,value:s.value,onChange:a(s),onClick:e=>e.stopPropagation(),checked:i,className:"woocommerce-search-list__item-input",...x}),(0,u.jsx)(_,{item:s,search:p}),j?(0,u.jsx)(v,{label:e||s.count}):null]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:i,...!i&&s.children.some((e=>w.find((t=>t.id===e.id))))?{indeterminate:!0}:{},label:g((0,h.decodeEntities)(s.name),p),onChange:()=>{i?a(m(w,s.children,"id"))():a(function(e,t){const r=m(t,e,"id");return[...e,...r]}(w,s.children))()},onClick:e=>e.stopPropagation()}),j?(0,u.jsx)(v,{label:e||s.count}):null]})}):(0,u.jsxs)("label",{htmlFor:P,className:C,children:[n?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("input",{...x,type:"radio",id:P,name:N,value:s.value,onChange:a(s),checked:i,className:"woocommerce-search-list__item-input"}),(0,u.jsx)(_,{item:s,search:p})]}):(0,u.jsx)(c.CheckboxControl,{...x,id:P,name:N,className:"woocommerce-search-list__item-input",value:(0,h.decodeEntities)(s.value),label:g((0,h.decodeEntities)(s.name),p),onChange:a(s),checked:i}),j?(0,u.jsx)(v,{label:e||s.count}):null]})},x=b,y=window.wc.wcTypes;var f=r(2624),j=r(9491),R=r(3028);r(5022);const k=({id:e,label:t,popoverContents:r,remove:o,screenReaderLabel:i,className:a=""})=>{const[m,p]=(0,d.useState)(!1),w=(0,j.useInstanceId)(k);if(i=i||t,!t)return null;t=(0,h.decodeEntities)(t);const g=(0,l.A)("woocommerce-tag",a,{"has-remove":!!o}),v=`woocommerce-tag__label-${w}`,_=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"screen-reader-text",children:i}),(0,u.jsx)("span",{"aria-hidden":"true",children:t})]});return(0,u.jsxs)("span",{className:g,children:[r?(0,u.jsx)(c.Button,{className:"woocommerce-tag__text",id:v,onClick:()=>p(!0),children:_}):(0,u.jsx)("span",{className:"woocommerce-tag__text",id:v,children:_}),r&&m&&(0,u.jsx)(c.Popover,{onClose:()=>p(!1),children:r}),o&&(0,u.jsx)(c.Button,{className:"woocommerce-tag__remove",onClick:o(e),label:(0,n.sprintf)(
// Translators: %s label.
// Translators: %s label.
(0,n.__)("Remove %s","woocommerce"),t),"aria-describedby":v,children:(0,u.jsx)(s.A,{icon:R.A,size:20,className:"clear-icon",role:"img"})})]})},S=k;r(1939);const C=e=>(0,u.jsx)(x,{...e}),N=e=>{const{list:t,selected:r,renderItem:o,depth:s=0,loadMoreChildrenText:i,onLoadMoreChildren:a,totalChildren:c,onSelect:l,instanceId:m,isSingle:h,search:p,useExpandedPanelId:w}=e,[g]=w;return t?(0,u.jsx)(u.Fragment,{children:t.map((t=>{var v;const _=null!==(v=t.children?.length)&&void 0!==v?v:0,b=_&&!h?t.children?.every((({id:e})=>r.find((t=>t.id===e)))):!!r.find((({id:e})=>e===t.id)),x=_&&g===t.id,y=c?.[t.id],f="number"==typeof y&&_<y;return(0,u.jsxs)(d.Fragment,{children:[(0,u.jsx)("li",{children:o({item:t,isSelected:b,onSelect:l,isSingle:h,selected:r,search:p,depth:s,useExpandedPanelId:w,controlId:m})}),x?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(N,{...e,list:t.children,depth:s+1}),a&&f?(0,u.jsx)("li",{children:(0,u.jsx)("button",{type:"button",className:"woocommerce-search-list__item woocommerce-search-list__item-load-more",onClick:()=>a(),children:i||(0,n.__)("Load more","woocommerce")})}):null]}):null]},t.id)}))}):null},P=({isLoading:e,isSingle:t,selected:r,messages:o,onChange:s,onRemove:i})=>{if(e||t||!r)return null;const a=r.length;return(0,u.jsxs)("div",{className:"woocommerce-search-list__selected",children:[(0,u.jsxs)("div",{className:"woocommerce-search-list__selected-header",children:[(0,u.jsx)("strong",{children:o.selected(a)}),a>0?(0,u.jsx)(c.Button,{variant:"link",isDestructive:!0,onClick:()=>s([]),"aria-label":o.clear,children:(0,n.__)("Clear all","woocommerce")}):null]}),a>0?(0,u.jsx)("ul",{children:r.map(((e,t)=>(0,u.jsx)("li",{children:(0,u.jsx)(S,{label:e.name,id:e.id,remove:i})},t)))}):null]})},L=({filteredList:e,search:t,onSelect:r,instanceId:o,useExpandedPanelId:i,...a})=>{const{messages:c,renderItem:l,selected:d,isSingle:m,loadMoreChildrenText:h,onLoadMoreChildren:p,totalChildren:w}=a,g=l||C;return 0===e.length?(0,u.jsxs)("div",{className:"woocommerce-search-list__list is-not-found",children:[(0,u.jsx)("span",{className:"woocommerce-search-list__not-found-icon",children:(0,u.jsx)(s.A,{icon:f.A,role:"img"})}),(0,u.jsx)("span",{className:"woocommerce-search-list__not-found-text",children:t?(0,n.sprintf)(c.noResults,t):c.noItems})]}):(0,u.jsx)("ul",{className:"woocommerce-search-list__list",children:(0,u.jsx)(N,{useExpandedPanelId:i,list:e,selected:d,renderItem:g,loadMoreChildrenText:h,onLoadMoreChildren:p,totalChildren:w,onSelect:r,instanceId:o,isSingle:m,search:t})})},I=e=>{const{className:t="",isCompact:r,isHierarchical:o,isLoading:s,isSingle:i,list:a,messages:m=p,onChange:h,onSearch:g,selected:v,type:_="text",debouncedSpeak:b}=e,[x,y]=(0,d.useState)(""),f=(0,d.useState)(-1),R=(0,j.useInstanceId)(I),k=(0,d.useMemo)((()=>({...p,...m})),[m]),S=(0,d.useMemo)((()=>((e,t,r)=>{if(!t)return r?w(e):e;const o=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),s=e.map((e=>!!o.test(e.name)&&e)).filter(Boolean);return r?w(s,e):s})(a,x,o)),[a,x,o]);(0,d.useEffect)((()=>{b&&b(k.updated)}),[b,k]),(0,d.useEffect)((()=>{"function"==typeof g&&g(x)}),[x,g]);const C=(0,d.useCallback)((e=>()=>{i&&h([]);const t=v.findIndex((({id:t})=>t===e));h([...v.slice(0,t),...v.slice(t+1)])}),[i,v,h]),N=(0,d.useCallback)((e=>()=>{Array.isArray(e)?h(e):-1===v.findIndex((({id:t})=>t===e.id))?h(i?[e]:[...v,e]):C(e.id)()}),[i,C,h,v]),T=(0,d.useCallback)((e=>{const[t]=v.filter((t=>!e.find((e=>t.id===e.id))));C(t.id)()}),[C,v]);return(0,u.jsxs)("div",{className:(0,l.A)("woocommerce-search-list",t,{"is-compact":r,"is-loading":s,"is-token":"token"===_}),children:["text"===_&&(0,u.jsx)(P,{...e,onRemove:C,messages:k}),(0,u.jsx)("div",{className:"woocommerce-search-list__search",children:"text"===_?(0,u.jsx)(c.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:k.search,type:"search",value:x,onChange:e=>y(e)}):(0,u.jsx)(c.FormTokenField,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,disabled:s,label:k.search,onChange:T,onInputChange:e=>y(e),suggestions:[],__experimentalValidateInput:()=>!1,value:s?[(0,n.__)("Loading…","woocommerce")]:v.map((e=>({...e,value:e.name}))),__experimentalShowHowTo:!1})}),s?(0,u.jsx)("div",{className:"woocommerce-search-list__list",children:(0,u.jsx)(c.Spinner,{})}):(0,u.jsx)(L,{...e,search:x,filteredList:S,messages:k,onSelect:N,instanceId:R,useExpandedPanelId:f})]})},T=((0,c.withSpokenMessages)(I),e=>t=>{let{selected:r}=t;r=void 0===r?null:r;const o=null===r;return Array.isArray(r)?(0,u.jsx)(e,{...t}):(0,u.jsx)(e,{...t,selected:o?[]:[r]})}),E=window.wc.wcSettings,A=(0,E.getSetting)("wcBlocksConfig",{pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),O=(A.pluginUrl,A.pluginUrl,E.STORE_PAGES.shop,E.STORE_PAGES.checkout,E.STORE_PAGES.checkout,E.STORE_PAGES.privacy,E.STORE_PAGES.privacy,E.STORE_PAGES.terms,E.STORE_PAGES.terms,E.STORE_PAGES.cart,E.STORE_PAGES.cart,E.STORE_PAGES.myaccount?.permalink?E.STORE_PAGES.myaccount.permalink:(0,E.getSetting)("wpLoginUrl","/wp-login.php"),(0,E.getSetting)("localPickupEnabled",!1),(0,E.getSetting)("shippingMethodsExist",!1),(0,E.getSetting)("shippingEnabled",!0),(0,E.getSetting)("countries",{})),M=(0,E.getSetting)("countryData",{}),D={...Object.fromEntries(Object.keys(M).filter((e=>!0===M[e].allowBilling)).map((e=>[e,O[e]||""]))),...Object.fromEntries(Object.keys(M).filter((e=>!0===M[e].allowShipping)).map((e=>[e,O[e]||""])))},$=(Object.fromEntries(Object.keys(D).map((e=>[e,M[e].states||{}]))),Object.fromEntries(Object.keys(D).map((e=>[e,M[e].locale||{}]))),{address:["first_name","last_name","company","address_1","address_2","city","postcode","country","state","phone"],contact:["email"],order:[]}),F=((0,E.getSetting)("addressFieldsLocations",$).address,(0,E.getSetting)("addressFieldsLocations",$).contact,(0,E.getSetting)("addressFieldsLocations",$).order,(0,E.getSetting)("additionalOrderFields",{}),(0,E.getSetting)("additionalContactFields",{}),(0,E.getSetting)("additionalAddressFields",{}),window.wp.url),B=window.wp.apiFetch;var H=r.n(B);const V=({selected:e=[],search:t="",queryArgs:r={}})=>{const o=(({selected:e=[],search:t="",queryArgs:r={}})=>{const o=A.productCount>100&&e.length>0,s=[(0,F.addQueryArgs)("/wc/store/v1/products",{per_page:100,catalog_visibility:"any",search:t,orderby:"title",order:"asc",exclude:o?e:[],...r})];if(o){const t=Math.ceil(e.length/100);for(let r=1;r<=t;r++)s.push((0,F.addQueryArgs)("/wc/store/v1/products",{catalog_visibility:"any",include:e,per_page:100,page:r}))}return s})({selected:e,search:t,queryArgs:r});return Promise.all(o.map((e=>H()({path:e})))).then((e=>[...new Map(e.flatMap((e=>e.map((e=>[e.id,{...e,parent:0}]))))).values()]))};var G=r(4347);const U=async e=>{if(!("json"in e))return{code:e.code||"",message:e.message,type:e.type||"general"};try{const t=await e.json();return{code:t.code||"",message:t.message,type:t.type||"api"}}catch(e){return{message:e.message,type:"general"}}};var z=r(923),W=r.n(z);const J=(0,j.createHigherOrderComponent)((e=>{class t extends d.Component{state={error:null,loading:!1,variations:{},totalVariations:{}};componentDidMount(){const{selected:e,showVariations:t}=this.props;e&&t&&this.loadVariations()}componentDidUpdate(e){const{isLoading:t,selected:r,showVariations:o}=this.props;o&&(!W()(e.selected,r)||e.isLoading&&!t)&&this.loadVariations()}loadVariations=({offset:e=0}={})=>{const{products:t}=this.props,{loading:r,variations:o,totalVariations:s}=this.state;if(r)return;const i=this.getExpandedProduct();if(!i)return;if(!e&&o?.[i])return;if(o?.[i]&&s?.[i]&&o[i].length>=s[i])return;const n=t.find((e=>e.id===i));if(!n?.variations||0===n.variations.length)return void this.setState({variations:{...this.state.variations,[i]:null},loading:!1,error:null});this.setState({loading:!0});const a=this.state.variations[i]||[];((e,t={})=>H()({path:(0,F.addQueryArgs)("wc/store/v1/products",{type:"variation",parent:e,orderby:"title",per_page:25,...t}),parse:!1}).then((e=>e.json().then((t=>{const r=e.headers.get("x-wp-total");return{variations:t,total:r?Number(r):null}})))))(i,{offset:e}).then((({variations:e,total:t})=>{const r=e.map((e=>({...e,parent:i})));this.setState({variations:{...this.state.variations,[i]:[...a,...r]},totalVariations:{...this.state.totalVariations,[i]:t},loading:!1,error:null})})).catch((async e=>{const t=await U(e);this.setState({variations:{...this.state.variations,[i]:null},totalVariations:{...this.state.totalVariations,[i]:null},loading:!1,error:t})}))};isProductId(e){const{products:t}=this.props;return t.some((t=>t.id===e))}findParentProduct(e){const{products:t}=this.props,r=t.filter((t=>t.variations&&t.variations.find((({id:t})=>t===e))));return r[0]?.id}getExpandedProduct(){const{isLoading:e,selected:t,showVariations:r}=this.props;if(!r)return null;let o=t&&t.length?t[0]:null;return o?this.prevSelectedItem=o:!this.prevSelectedItem||e||this.isProductId(this.prevSelectedItem)||(o=this.prevSelectedItem),!e&&o?this.isProductId(o)?o:this.findParentProduct(o):null}render(){const{error:t,isLoading:r}=this.props,{error:o,loading:s,variations:i,totalVariations:n}=this.state,a=this.getExpandedProduct(),c=a&&i[a]?.length||0;return(0,u.jsx)(e,{...this.props,error:o||t,onLoadMoreVariations:()=>this.loadVariations({offset:c}),expandedProduct:this.getExpandedProduct(),isLoading:r,totalVariations:n,variations:i,variationsLoading:s})}}return t}),"withProductVariations"),q=e=>{const{id:t,name:r,parent:o}=e;return{id:t,name:r,parent:o,breadcrumbs:[],children:[],details:e,value:e.slug}},Q=window.wp.escapeHtml,Y=({message:e,type:t})=>e?"general"===t?(0,u.jsxs)("span",{children:[(0,n.__)("The following error was returned","woocommerce"),(0,u.jsx)("br",{}),(0,u.jsx)("code",{children:(0,Q.escapeHTML)(e)})]}):"api"===t?(0,u.jsxs)("span",{children:[(0,n.__)("The following error was returned from the API","woocommerce"),(0,u.jsx)("br",{}),(0,u.jsx)("code",{children:(0,Q.escapeHTML)(e)})]}):e:(0,n.__)("An error has prevented the block from being updated.","woocommerce"),K=({error:e})=>(0,u.jsx)("div",{className:"wc-block-error-message",children:Y(e)});var X=r(1609);const Z=({className:e,item:t,isSelected:r,isLoading:o,onSelect:s,disabled:i,...n})=>(0,u.jsxs)(u.Fragment,{children:[(0,X.createElement)(b,{...n,key:t.id,className:e,isSelected:r,item:t,onSelect:s,disabled:i}),r&&o&&(0,u.jsx)("div",{className:(0,l.A)("woocommerce-search-list__item","woocommerce-product-attributes__item","depth-1","is-loading","is-not-active"),children:(0,u.jsx)(c.Spinner,{})},"loading")]});r(5653);const ee={list:(0,n.__)("Products","woocommerce"),noItems:(0,n.__)("Your store doesn't have any products.","woocommerce"),search:(0,n.__)("Search for a product to display","woocommerce"),updated:(0,n.__)("Product search results updated.","woocommerce")},te=T((re=J((0,j.withInstanceId)((e=>{const{expandedProduct:t=null,error:r,instanceId:o,isCompact:s=!1,isLoading:i,onChange:a,onLoadMoreVariations:c,totalVariations:d,onSearch:m,products:h,renderItem:p,selected:w=[],showVariations:g=!1,variations:v,variationsLoading:_}=e;if(r)return(0,u.jsx)(K,{error:r});const x=[...h,...v&&t&&v[t]?v[t]:[]].map(q);return(0,u.jsx)(I,{className:"woocommerce-products",list:x,isCompact:s,isLoading:i,isSingle:!0,selected:x.filter((({id:e})=>w.includes(Number(e)))),onChange:a,loadMoreChildrenText:g?(0,n.__)("Load more variations","woocommerce"):void 0,onLoadMoreChildren:g?c:void 0,totalChildren:g?d:void 0,renderItem:p||(g?e=>{const{item:t,search:r,depth:s=0,isSelected:a,onSelect:c}=e,d=t.details?.variations&&Array.isArray(t.details.variations)?t.details.variations.length:0,m=(0,l.A)("woocommerce-search-product__item","woocommerce-search-list__item",`depth-${s}`,"has-count",{"is-searching":r.length>0,"is-skip-level":0===s&&0!==t.parent,"is-variable":d>0});if(!t.breadcrumbs.length){const r=t.details?.variations&&t.details.variations.length>0;return(0,u.jsx)(Z,{...e,className:(0,l.A)(m,{"is-selected":a}),isSelected:a,item:t,onSelect:()=>()=>{c(t)()},isLoading:i||_,countLabel:r?(0,n.sprintf)(/* translators: %1$d is the number of variations of a product product. */ /* translators: %1$d is the number of variations of a product product. */
(0,n.__)("%1$d variations","woocommerce"),t.details?.variations.length):null,name:`products-${o}`,"aria-label":r?(0,n.sprintf)(/* translators: %1$s is the product name, %2$d is the number of variations of that product. */ /* translators: %1$s is the product name, %2$d is the number of variations of that product. */
(0,n._n)("%1$s, has %2$d variation","%1$s, has %2$d variations",t.details?.variations?.length,"woocommerce"),t.name,t.details?.variations.length):void 0})}const h=(0,y.isEmpty)(t.details?.variation)?e:{...e,item:{...e.item,name:t.details?.variation},"aria-label":`${t.breadcrumbs[0]}: ${t.details?.variation}`};return(0,u.jsx)(b,{...h,className:m,name:`variations-${o}`})}:void 0),onSearch:m,messages:{...ee,...e.messages},isHierarchical:!0})}))),({selected:e,...t})=>{const[r,o]=(0,d.useState)(!0),[s,i]=(0,d.useState)(null),[n,a]=(0,d.useState)([]),c=A.productCount>100,l=async e=>{const t=await U(e);i(t),o(!1)},m=(0,d.useRef)(e);(0,d.useEffect)((()=>{V({selected:m.current}).then((e=>{a(e),o(!1)})).catch(l)}),[m]);const h=(0,G.YQ)((t=>{V({selected:e,search:t}).then((e=>{a(e),o(!1)})).catch(l)}),400),p=(0,d.useCallback)((e=>{o(!0),h(e)}),[o,h]);return(0,u.jsx)(re,{...t,selected:e,error:s,products:n,isLoading:r,onSearch:c?p:null})}));var re,oe=r(2098);r(3120);const se=({className:e="",error:t,isLoading:r=!1,onRetry:o})=>(0,u.jsxs)(c.Placeholder,{icon:(0,u.jsx)(s.A,{icon:oe.A}),label:(0,n.__)("Sorry, an error occurred","woocommerce"),className:(0,l.A)("wc-block-api-error",e),children:[(0,u.jsx)(K,{error:t}),o&&(0,u.jsx)(u.Fragment,{children:r?(0,u.jsx)(c.Spinner,{}):(0,u.jsx)(c.Button,{variant:"secondary",onClick:o,children:(0,n.__)("Retry","woocommerce")})})]});r(6919);const ie=window.wc.sanitize,ne=({label:e,screenReaderLabel:t,wrapperElement:r,wrapperProps:o={},allowHTML:s=!1})=>{let i;const n=null!=e,a=null!=t;return!n&&a?(i=r||"span",o={...o,className:(0,l.A)(o.className,"screen-reader-text")},(0,u.jsx)(i,{...o,children:t})):(i=r||d.Fragment,n&&a&&e!==t?(0,u.jsxs)(i,{...o,children:[s?(0,u.jsx)(d.RawHTML,{children:(0,ie.sanitizeHTML)(e,{tags:["b","em","i","strong","p","br","span"],attr:["style"]})}):(0,u.jsx)("span",{"aria-hidden":"true",children:e}),(0,u.jsx)("span",{className:"screen-reader-text",children:t})]}):(0,u.jsx)(i,{...o,children:e}))},ae=({onClick:e,label:t=(0,n.__)("Load more","woocommerce"),screenReaderLabel:r=(0,n.__)("Load more","woocommerce")})=>(0,u.jsx)("div",{className:"wp-block-button wc-block-load-more wc-block-components-load-more",children:(0,u.jsx)("button",{className:"wp-block-button__link",onClick:e,children:(0,u.jsx)(ne,{label:t,screenReaderLabel:r})})}),ce=window.wc.blocksComponents;r(6878);const le=({onChange:e,readOnly:t,value:r})=>(0,u.jsx)(ce.SortSelect,{className:"wc-block-review-sort-select wc-block-components-review-sort-select",label:(0,n.__)("Order by","woocommerce"),onChange:e,options:[{key:"most-recent",label:(0,n.__)("Most recent","woocommerce")},{key:"highest-rating",label:(0,n.__)("Highest rating","woocommerce")},{key:"lowest-rating",label:(0,n.__)("Lowest rating","woocommerce")}],readOnly:t,screenReaderLabel:(0,n.__)("Order reviews by","woocommerce"),value:r});function de(e){let t,r,o,s=[];for(let i=0;i<e.length;i++)t=e.substring(i),r=t.match(/^&[a-z0-9#]+;/),r?(o=r[0],s.push(o),i+=o.length-1):s.push(e[i]);return s}const me=(e,t,r="...")=>{const o=function(e,t){const r=(t=t||{}).limit||100,o=void 0===t.preserveTags||t.preserveTags,s=void 0!==t.wordBreak&&t.wordBreak,i=t.suffix||"...",n=t.moreLink||"",a=t.moreText||"»",c=t.preserveWhiteSpace||!1,l=e.replace(/</g,"\n<").replace(/>/g,">\n").replace(/\n\n/g,"\n").replace(/^\n/g,"").replace(/\n$/g,"").split("\n");let d,m,h,u,p,w,g=0,v=[],_=!1;for(let e=0;e<l.length;e++){if(d=l[e],u=c?d:d.replace(/[ ]+/g," "),!d.length)continue;const t=de(u);if("<"!==d[0])if(g>=r)d="";else if(g+t.length>=r){if(m=r-g," "===t[m-1])for(;m&&(m-=1," "===t[m-1]););else h=t.slice(m).indexOf(" "),s||(-1!==h?m+=h:m=d.length);if(d=t.slice(0,m).join("")+i,n){const e=document.createElement("a");e.href=n,e.style.display="inline",e.textContent=a,d+=e.outerHTML}g=r,_=!0}else g+=t.length;else if(o){if(g>=r)if(p=d.match(/[a-zA-Z]+/),w=p?p[0]:"",w)if("</"!==d.substring(0,2))v.push(w),d="";else{for(;v[v.length-1]!==w&&v.length;)v.pop();v.length&&(d=""),v.pop()}else d=""}else d="";l[e]=d}return{html:l.join("\n").replace(/\n/g,""),more:_}}(e,{suffix:r,limit:t});return o.html},he=(e,t,r)=>(t<=r?e.start=e.middle+1:e.end=e.middle-1,e),ue=(e,t,r,o)=>{const s=((e,t,r)=>{let o={start:0,middle:0,end:e.length};for(;o.start<=o.end;)o.middle=Math.floor((o.start+o.end)/2),t.innerHTML=me(e,o.middle),o=he(o,t.clientHeight,r);return o.middle})(e,t,r);return me(e,s-o.length,o)},pe={className:"read-more-content",ellipsis:"&hellip;",lessText:(0,n.__)("Read less","woocommerce"),maxLines:3,moreText:(0,n.__)("Read more","woocommerce")};class we extends d.Component{static defaultProps=pe;constructor(e){super(e),this.state={isExpanded:!1,clampEnabled:null,content:e.children,summary:"."},this.reviewContent=(0,d.createRef)(),this.reviewSummary=(0,d.createRef)(),this.getButton=this.getButton.bind(this),this.onClick=this.onClick.bind(this)}componentDidMount(){this.setSummary()}componentDidUpdate(e){e.maxLines===this.props.maxLines&&e.children===this.props.children||this.setState({clampEnabled:null,summary:"."},this.setSummary)}setSummary(){if(this.props.children){const{maxLines:e,ellipsis:t}=this.props;if(!this.reviewSummary.current||!this.reviewContent.current)return;const r=(this.reviewSummary.current.clientHeight+1)*e+1,o=this.reviewContent.current.clientHeight+1>r;this.setState({clampEnabled:o}),o&&this.setState({summary:ue(this.reviewContent.current.innerHTML,this.reviewSummary.current,r,t)})}}getButton(){const{isExpanded:e}=this.state,{className:t,lessText:r,moreText:o}=this.props,s=e?r:o;if(s)return(0,u.jsx)("a",{href:"#more",className:t+"__read_more",onClick:this.onClick,"aria-expanded":!e,role:"button",children:s})}onClick(e){e.preventDefault();const{isExpanded:t}=this.state;this.setState({isExpanded:!t})}render(){const{className:e}=this.props,{content:t,summary:r,clampEnabled:o,isExpanded:s}=this.state;return t?!1===o?(0,u.jsx)("div",{className:e,children:(0,u.jsx)("div",{ref:this.reviewContent,children:t})}):(0,u.jsxs)("div",{className:e,children:[(!s||null===o)&&(0,u.jsx)("div",{ref:this.reviewSummary,"aria-hidden":s,dangerouslySetInnerHTML:{__html:r}}),(s||null===o)&&(0,u.jsx)("div",{ref:this.reviewContent,"aria-hidden":!s,children:t}),this.getButton()]}):null}}const ge=we;function ve(e,t,r){return r||!e?(0,u.jsx)("div",{className:"wc-block-review-list-item__image wc-block-components-review-list-item__image"}):(0,u.jsxs)("div",{className:"wc-block-review-list-item__image wc-block-components-review-list-item__image",children:["product"===t?(0,u.jsx)("img",{"aria-hidden":"true",alt:e.product_image?.alt||"",src:e.product_image?.thumbnail||""}):(0,u.jsx)("img",{"aria-hidden":"true",alt:"",src:e.reviewer_avatar_urls[96]||""}),e.verified&&(0,u.jsx)("div",{className:"wc-block-review-list-item__verified wc-block-components-review-list-item__verified",title:(0,n.__)("Verified buyer","woocommerce"),children:(0,n.__)("Verified buyer","woocommerce")})]})}function _e(e){return(0,u.jsx)(ge,{maxLines:10,moreText:(0,n.__)("Read full review","woocommerce"),lessText:(0,n.__)("Hide full review","woocommerce"),className:"wc-block-review-list-item__text wc-block-components-review-list-item__text",children:(0,u.jsx)("div",{dangerouslySetInnerHTML:{__html:e.review||""}})})}function be(e,t){return(0,u.jsx)("div",{className:"wc-block-review-list-item__product wc-block-components-review-list-item__product",children:(0,u.jsx)("a",{href:e.product_permalink,"aria-labelledby":t,children:(0,h.decodeEntities)(e.product_name)})})}function xe(e){const{reviewer:t=""}=e;return(0,u.jsx)("div",{className:"wc-block-review-list-item__author wc-block-components-review-list-item__author",children:t})}function ye(e){const{date_created:t,formatted_date_created:r}=e;return(0,u.jsx)("time",{className:"wc-block-review-list-item__published-date wc-block-components-review-list-item__published-date",dateTime:t,children:r})}function fe(e,t){const{rating:r}=e,o={width:r/5*100+"%"},s=(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"),r),i={__html:(0,n.sprintf)(/* translators: %s is referring to the average rating value */ /* translators: %s is referring to the average rating value */
(0,n.__)("Rated %s out of 5","woocommerce"),(0,n.sprintf)('<strong class="rating">%f</strong>',r))};return(0,u.jsx)("div",{id:t,"aria-label":`${(0,h.decodeEntities)(e.product_name)} ${s}`,className:"wc-block-review-list-item__rating wc-block-components-review-list-item__rating",children:(0,u.jsx)("div",{"aria-hidden":"true",className:`wc-block-review-list-item__rating__stars wc-block-components-review-list-item__rating__stars wc-block-review-list-item__rating__stars--${r}`,role:"img",children:(0,u.jsx)("span",{style:o,dangerouslySetInnerHTML:i})})})}r(7313);const je=({attributes:e,review:t={}})=>{const{imageType:r,showReviewDate:o,showReviewerName:s,showReviewImage:i,showReviewRating:n,showReviewContent:a,showProductName:c}=e,{rating:m}=t,h=!(Object.keys(t).length>0),p=Number.isFinite(m)&&n,w=(0,d.useId)();return(0,u.jsxs)("li",{className:(0,l.A)("wc-block-review-list-item__item","wc-block-components-review-list-item__item",{"is-loading":h,"wc-block-components-review-list-item__item--has-image":i}),"aria-hidden":h,children:[(c||o||s||i||p)&&(0,u.jsxs)("div",{className:"wc-block-review-list-item__info wc-block-components-review-list-item__info",children:[i&&ve(t,r,h),(c||s||p||o)&&(0,u.jsxs)("div",{className:"wc-block-review-list-item__meta wc-block-components-review-list-item__meta",children:[p&&fe(t,w),c&&be(t,w),s&&xe(t),o&&ye(t)]})]}),a&&_e(t)]})};r(5183);const Re=({attributes:e,reviews:t})=>{const r=(0,E.getSetting)("showAvatars",!0),o=(0,E.getSetting)("reviewRatingsEnabled",!0),s=(r||"product"===e.imageType)&&e.showReviewImage,i=o&&e.showReviewRating,n={...e,showReviewImage:s,showReviewRating:i};return(0,u.jsx)("ul",{className:"wc-block-review-list wc-block-components-review-list",children:0===t.length?(0,u.jsx)(je,{attributes:n}):t.map(((e,t)=>(0,u.jsx)(je,{attributes:n,review:e},e.id||t)))})},ke=e=>{const{className:t,categoryIds:r,productId:o,showReviewDate:s,showReviewerName:i,showReviewContent:n,showProductName:a,showReviewImage:c,showReviewRating:d}=e;let m="wc-block-all-reviews";return o&&(m="wc-block-reviews-by-product"),Array.isArray(r)&&(m="wc-block-reviews-by-category"),(0,l.A)(m,t,{"has-image":c,"has-name":i,"has-date":s,"has-rating":d,"has-content":n,"has-product-name":a})},Se=e=>{const{categoryIds:t,imageType:r,orderby:o,productId:s,reviewsOnPageLoad:i,reviewsOnLoadMore:n,showLoadMore:a,showOrderby:c}=e,l={"data-image-type":r,"data-orderby":o,"data-reviews-on-page-load":i,"data-reviews-on-load-more":n,"data-show-load-more":a,"data-show-orderby":c};return s&&(l["data-product-id"]=s),Array.isArray(t)&&(l["data-category-ids"]=t.join(",")),l};class Ce extends d.Component{render(){const{attributes:e,error:t,isLoading:r,noReviewsPlaceholder:o,reviews:s,totalReviews:i}=this.props;if(t)return(0,u.jsx)(se,{className:"wc-block-featured-product-error",error:t,isLoading:r});if(0===s.length&&!r)return(0,u.jsx)(o,{attributes:e});const a=(0,E.getSetting)("reviewRatingsEnabled",!0);return(0,u.jsxs)(c.Disabled,{children:[e.showOrderby&&a&&(0,u.jsx)(le,{readOnly:!0,value:e.orderby,onChange:()=>null}),(0,u.jsx)(Re,{attributes:e,reviews:s}),e.showLoadMore&&i>s.length&&(0,u.jsx)(ae,{screenReaderLabel:(0,n.__)("Load more reviews","woocommerce"),onClick:()=>null})]})}}const Ne=(e=>{var t;class r extends d.Component{isPreview=!!this.props.attributes.previewReviews;delayedAppendReviews=(null!==(t=this.props.delayFunction)&&void 0!==t?t:e=>e)(this.appendReviews);isMounted=!1;state={error:null,loading:!0,reviews:this.isPreview&&this.props.attributes?.previewReviews?this.props.attributes.previewReviews:[],totalReviews:this.isPreview&&this.props.attributes?.previewReviews?this.props.attributes.previewReviews.length:0};componentDidMount(){this.isMounted=!0,this.replaceReviews()}componentDidUpdate(e){e.reviewsToDisplay<this.props.reviewsToDisplay?this.delayedAppendReviews():this.shouldReplaceReviews(e,this.props)&&this.replaceReviews()}shouldReplaceReviews(e,t){return e.orderby!==t.orderby||e.order!==t.order||e.productId!==t.productId||!W()(e.categoryIds,t.categoryIds)}componentWillUnmount(){this.isMounted=!1,"cancel"in this.delayedAppendReviews&&"function"==typeof this.delayedAppendReviews.cancel&&this.delayedAppendReviews.cancel()}getArgs(e){const{categoryIds:t,order:r,orderby:o,productId:s,reviewsToDisplay:i}=this.props,n={order:r,orderby:o,per_page:i-e,offset:e};if(t){const e=Array.isArray(t)?t:JSON.parse(t);n.category_id=Array.isArray(e)?e.join(","):e}return s&&(n.product_id=s),n}replaceReviews(){var e;if(this.isPreview)return;const t=null!==(e=this.props.onReviewsReplaced)&&void 0!==e?e:()=>{};this.updateListOfReviews().then(t)}appendReviews(){var e;if(this.isPreview)return;const t=null!==(e=this.props.onReviewsAppended)&&void 0!==e?e:()=>{},{reviewsToDisplay:r}=this.props,{reviews:o}=this.state;r<=o.length||this.updateListOfReviews(o).then(t)}updateListOfReviews(e=[]){const{reviewsToDisplay:t}=this.props,{totalReviews:r}=this.state,o=Math.min(r,t)-e.length;return this.setState({loading:!0,reviews:e.concat(Array(o).fill({}))}),(s=this.getArgs(e.length),H()({path:"/wc/store/v1/products/reviews?"+Object.entries(s).map((e=>e.join("="))).join("&"),parse:!1}).then((e=>e.json().then((t=>({reviews:t,totalReviews:parseInt(e.headers.get("x-wp-total"),10)})))))).then((({reviews:t,totalReviews:r})=>(this.isMounted&&this.setState({reviews:e.filter((e=>Object.keys(e).length)).concat(t),totalReviews:r,loading:!1,error:null}),{newReviews:t}))).catch(this.setError);var s}setError=async e=>{var t;if(!this.isMounted)return;const r=null!==(t=this.props.onReviewsLoadError)&&void 0!==t?t:()=>{},o=await U(e);this.setState({reviews:[],loading:!1,error:o}),r(o)};render(){const{reviewsToDisplay:t}=this.props,{error:r,loading:o,reviews:s,totalReviews:i}=this.state;return(0,u.jsx)(e,{...this.props,error:r,isLoading:o,reviews:s.slice(0,t),totalReviews:i})}}const{displayName:o=e.name||"Component"}=e;return r.displayName=`WithReviews(${o})`,r})(Ce),Pe=({attributes:e,icon:t,name:r,noReviewsPlaceholder:o})=>{const{categoryIds:s,productId:i,reviewsOnPageLoad:a,showProductName:l,showReviewDate:d,showReviewerName:m,showReviewContent:h,showReviewImage:p,showReviewRating:w}=e,{order:g,orderby:v}=(e=>{if((0,E.getSetting)("reviewRatingsEnabled",!0)){if("lowest-rating"===e)return{order:"asc",orderby:"rating"};if("highest-rating"===e)return{order:"desc",orderby:"rating"}}return{order:"desc",orderby:"date_gmt"}})(e.orderby);return h||w||d||m||p||l?(0,u.jsx)(u.Fragment,{children:(0,u.jsx)(Ne,{attributes:e,categoryIds:s,delayFunction:e=>(e=>{let t,r=null;const o=(...o)=>{r=o,t&&clearTimeout(t),t=setTimeout((()=>{t=null,r&&e(...r)}),400)};return o.flush=()=>{t&&r&&(e(...r),clearTimeout(t),t=null)},o.clear=()=>{t&&clearTimeout(t),t=null},o})(e),noReviewsPlaceholder:o,orderby:v,order:g,productId:i,reviewsToDisplay:a})}):(0,u.jsx)(c.Placeholder,{icon:t,label:r,children:(0,n.__)("The content for this block is hidden due to block settings.","woocommerce")})},Le=(0,j.createHigherOrderComponent)((e=>class extends d.Component{state={error:null,loading:!1,product:"preview"===this.props.attributes.productId?this.props.attributes.previewProduct:null};componentDidMount(){this.loadProduct()}componentDidUpdate(e){e.attributes.productId!==this.props.attributes.productId&&this.loadProduct()}loadProduct=()=>{const{productId:e}=this.props.attributes;"preview"!==e&&(e?(this.setState({loading:!0}),(e=>H()({path:`/wc/store/v1/products/${e}`}))(e).then((e=>{this.setState({product:e,loading:!1,error:null})})).catch((async e=>{const t=await U(e);this.setState({product:null,loading:!1,error:t})}))):this.setState({product:null,loading:!1,error:null}))};render(){const{error:t,loading:r,product:o}=this.state;return(0,u.jsx)(e,{...this.props,error:t,getProduct:this.loadProduct,isLoading:r,product:o})}}),"withProduct")((({error:e,getProduct:t,isLoading:r,product:o})=>{if(e)return(0,u.jsx)(se,{className:"wc-block-featured-product-error",error:e,isLoading:r,onRetry:t});const a=!o||r?(0,u.jsx)(c.Spinner,{}):(0,n.sprintf)(/* translators: %s is the product name. */ /* translators: %s is the product name. */
(0,n.__)("This block lists reviews for a selected product. %s doesn't have any reviews yet, but they will show up here when it does.","woocommerce"),(0,h.decodeEntities)(o.name));return(0,u.jsx)(c.Placeholder,{className:"wc-block-reviews-by-product",icon:(0,u.jsx)(s.A,{icon:i.A,className:"block-editor-block-icon"}),label:(0,n.__)("Reviews by Product","woocommerce"),children:a})})),Ie=(e,t,r)=>(0,u.jsx)(a.BlockControls,{children:(0,u.jsx)(c.ToolbarGroup,{controls:[{icon:"edit",title:r,onClick:()=>t({editMode:!e}),isActive:e}]})}),Te=(e,t)=>{const r=(0,E.getSetting)("showAvatars",!0),o=(0,E.getSetting)("reviewRatingsEnabled",!0);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.ToggleControl,{label:(0,n.__)("Product rating","woocommerce"),checked:e.showReviewRating,onChange:()=>t({showReviewRating:!e.showReviewRating})}),e.showReviewRating&&!o&&(0,u.jsx)(c.Notice,{className:"wc-block-base-control-notice",isDismissible:!1,children:(0,d.createInterpolateElement)((0,n.__)("Product rating is disabled in your <a>store settings</a>.","woocommerce"),{a:(0,u.jsx)("a",{href:(0,E.getAdminLink)("admin.php?page=wc-settings&tab=products"),target:"_blank",rel:"noopener noreferrer"})})}),(0,u.jsx)(c.ToggleControl,{label:(0,n.__)("Reviewer name","woocommerce"),checked:e.showReviewerName,onChange:()=>t({showReviewerName:!e.showReviewerName})}),(0,u.jsx)(c.ToggleControl,{label:(0,n.__)("Image","woocommerce"),checked:e.showReviewImage,onChange:()=>t({showReviewImage:!e.showReviewImage})}),(0,u.jsx)(c.ToggleControl,{label:(0,n.__)("Review date","woocommerce"),checked:e.showReviewDate,onChange:()=>t({showReviewDate:!e.showReviewDate})}),(0,u.jsx)(c.ToggleControl,{label:(0,n.__)("Review content","woocommerce"),checked:e.showReviewContent,onChange:()=>t({showReviewContent:!e.showReviewContent})}),e.showReviewImage&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(c.__experimentalToggleGroupControl,{label:(0,n.__)("Review image","woocommerce"),isBlock:!0,value:e.imageType,onChange:e=>t({imageType:e}),children:[(0,u.jsx)(c.__experimentalToggleGroupControlOption,{value:"reviewer",label:(0,n.__)("Reviewer photo","woocommerce")}),(0,u.jsx)(c.__experimentalToggleGroupControlOption,{value:"product",label:(0,n.__)("Product","woocommerce")})]}),"reviewer"===e.imageType&&!r&&(0,u.jsx)(c.Notice,{className:"wc-block-base-control-notice",isDismissible:!1,children:(0,d.createInterpolateElement)((0,n.__)("Reviewer photo is disabled in your <a>site settings</a>.","woocommerce"),{a:(0,u.jsx)("a",{href:(0,E.getAdminLink)("options-discussion.php"),target:"_blank",rel:"noopener noreferrer"})})})]})]})},Ee=(e,t)=>(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.ToggleControl,{label:(0,n.__)("Order by","woocommerce"),checked:e.showOrderby,onChange:()=>t({showOrderby:!e.showOrderby})}),(0,u.jsx)(c.SelectControl,{label:(0,n.__)("Order Product Reviews by","woocommerce"),value:e.orderby,options:[{label:"Most recent",value:"most-recent"},{label:"Highest Rating",value:"highest-rating"},{label:"Lowest Rating",value:"lowest-rating"}],onChange:e=>t({orderby:e})}),(0,u.jsx)(c.RangeControl,{label:(0,n.__)("Starting Number of Reviews","woocommerce"),value:e.reviewsOnPageLoad,onChange:e=>t({reviewsOnPageLoad:e}),max:20,min:1}),(0,u.jsx)(c.ToggleControl,{label:(0,n.__)("Load more","woocommerce"),checked:e.showLoadMore,onChange:()=>t({showLoadMore:!e.showLoadMore})}),e.showLoadMore&&(0,u.jsx)(c.RangeControl,{label:(0,n.__)("Load More Reviews","woocommerce"),value:e.reviewsOnLoadMore,onChange:e=>t({reviewsOnLoadMore:e}),max:20,min:1})]}),Ae=(0,c.withSpokenMessages)((({attributes:e,debouncedSpeak:t,setAttributes:r})=>{const{editMode:o,productId:l}=e,d=(0,a.useBlockProps)(),m=e=>{const{item:t=0}=e;return(0,u.jsx)(b,{...e,item:{...t,count:t.details.review_count},countLabel:(0,n.sprintf)(/* translators: %d is the review count. */ /* translators: %d is the review count. */
(0,n._n)("%d review","%d reviews",t.details.review_count,"woocommerce"),t.details.review_count),"aria-label":(0,n.sprintf)(/* translators: %1$s is the item name, and %2$d is the number of reviews for the item. */ /* translators: %1$s is the item name, and %2$d is the number of reviews for the item. */
(0,n._n)("%1$s, has %2$d review","%1$s, has %2$d reviews",t.details.review_count,"woocommerce"),(0,h.decodeEntities)(t.name),t.details.review_count)})};if(!l||o)return(0,u.jsxs)(c.Placeholder,{icon:(0,u.jsx)(s.A,{icon:i.A,className:"block-editor-block-icon"}),label:(0,n.__)("Reviews by Product","woocommerce"),className:"wc-block-reviews-by-product",children:[(0,n.__)("Show reviews of your product to build trust","woocommerce"),(0,u.jsxs)("div",{className:"wc-block-reviews__selection",children:[(0,u.jsx)(te,{selected:e.productId||0,onChange:(e=[])=>{const t=e[0]?e[0].id:0;r({productId:t})},queryArgs:{orderby:"comment_count",order:"desc"},renderItem:m}),(0,u.jsx)(c.Button,{variant:"primary",onClick:()=>{r({editMode:!1}),t((0,n.__)("Showing Reviews by Product block preview.","woocommerce"))},children:(0,n.__)("Done","woocommerce")})]})]});const p=(0,n.__)("Edit selected product","woocommerce");return(0,u.jsxs)("div",{...d,children:[Ie(o,r,p),(0,u.jsxs)(a.InspectorControls,{children:[(0,u.jsx)(c.PanelBody,{title:(0,n.__)("Product","woocommerce"),initialOpen:!1,children:(0,u.jsx)(te,{selected:e.productId||0,onChange:(e=[])=>{const t=e[0]?e[0].id:0;r({productId:t})},renderItem:m,isCompact:!0})}),(0,u.jsx)(c.PanelBody,{title:(0,n.__)("Content","woocommerce"),children:Te(e,r)}),(0,u.jsx)(c.PanelBody,{title:(0,n.__)("List Settings","woocommerce"),children:Ee(e,r)})]},"inspector"),(0,u.jsx)(Pe,{attributes:e,icon:(0,u.jsx)(s.A,{icon:i.A,className:"block-editor-block-icon"}),name:(0,n.__)("Reviews by Product","woocommerce"),noReviewsPlaceholder:Le})]})})),Oe={attributes:{editMode:!1,imageType:"reviewer",orderby:"most-recent",reviewsOnLoadMore:10,reviewsOnPageLoad:10,showLoadMore:!0,showOrderby:!0,showReviewDate:!0,showReviewerName:!0,showReviewImage:!0,showReviewRating:!0,showReviewContent:!0,previewReviews:[{id:1,date_created:"2019-07-15T17:05:04",formatted_date_created:(0,n.__)("July 15, 2019","woocommerce"),date_created_gmt:"2019-07-15T15:05:04",product_id:0,product_name:(0,n.__)("WordPress Pennant","woocommerce"),product_permalink:"#",
/* translators: An example person name used for the block previews. */
reviewer:(0,n.__)("Alice","woocommerce"),review:`<p>${(0,n.__)("I bought this product last week and I'm very happy with it.","woocommerce")}</p>\n`,reviewer_avatar_urls:{48:A.defaultAvatar,96:A.defaultAvatar},rating:5,verified:!0},{id:2,date_created:"2019-07-12T12:39:39",formatted_date_created:(0,n.__)("July 12, 2019","woocommerce"),date_created_gmt:"2019-07-12T10:39:39",product_id:0,product_name:(0,n.__)("WordPress Pennant","woocommerce"),product_permalink:"#",
/* translators: An example person name used for the block previews. */
reviewer:(0,n.__)("Bob","woocommerce"),review:`<p>${(0,n.__)("This product is awesome, I love it!","woocommerce")}</p>\n`,reviewer_avatar_urls:{48:A.defaultAvatar,96:A.defaultAvatar},rating:null,verified:!1}]}},Me=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"woocommerce/reviews-by-product","title":"Reviews by Product","category":"woocommerce","keywords":["WooCommerce"],"description":"Display reviews for your products.","textdomain":"woocommerce","supports":{"html":false,"interactivity":{"clientNavigation":true},"color":{"background":false},"typography":{"fontSize":true}}}');(0,o.registerBlockType)(Me,{icon:{src:(0,u.jsx)(s.A,{icon:i.A,className:"wc-block-editor-components-block-icon"})},example:{...Oe,attributes:{...Oe.attributes,productId:1}},attributes:{editMode:{type:"boolean",default:!0},imageType:{type:"string",default:"reviewer"},orderby:{type:"string",default:"most-recent"},reviewsOnLoadMore:{type:"number",default:10},reviewsOnPageLoad:{type:"number",default:10},showLoadMore:{type:"boolean",default:!0},showOrderby:{type:"boolean",default:!0},showReviewDate:{type:"boolean",default:!0},showReviewerName:{type:"boolean",default:!0},showReviewImage:{type:"boolean",default:!0},showReviewRating:{type:"boolean",default:!0},showReviewContent:{type:"boolean",default:!0},previewReviews:{type:"array",default:null},productId:{type:"number"}},edit:e=>(0,u.jsx)(Ae,{...e}),save:({attributes:e})=>(0,u.jsx)("div",{...a.useBlockProps.save({className:ke(e)}),...Se(e)})})},6919:()=>{},7313:()=>{},5183:()=>{},6878:()=>{},4809:()=>{},3120:()=>{},5653:()=>{},1939:()=>{},5022:()=>{},1609:e=>{"use strict";e.exports=window.React},790:e=>{"use strict";e.exports=window.ReactJSXRuntime},9491:e=>{"use strict";e.exports=window.wp.compose},6087:e=>{"use strict";e.exports=window.wp.element},7723:e=>{"use strict";e.exports=window.wp.i18n},923:e=>{"use strict";e.exports=window.wp.isShallowEqual},5573:e=>{"use strict";e.exports=window.wp.primitives}},s={};function i(e){var t=s[e];if(void 0!==t)return t.exports;var r=s[e]={exports:{}};return o[e](r,r.exports,i),r.exports}i.m=o,e=[],i.O=(t,r,o,s)=>{if(!r){var n=1/0;for(d=0;d<e.length;d++){for(var[r,o,s]=e[d],a=!0,c=0;c<r.length;c++)(!1&s||n>=s)&&Object.keys(i.O).every((e=>i.O[e](r[c])))?r.splice(c--,1):(a=!1,s<n&&(n=s));if(a){e.splice(d--,1);var l=o();void 0!==l&&(t=l)}}return t}s=s||0;for(var d=e.length;d>0&&e[d-1][2]>s;d--)e[d]=e[d-1];e[d]=[r,o,s]},i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(e,o){if(1&o&&(e=this(e)),8&o)return e;if("object"==typeof e&&e){if(4&o&&e.__esModule)return e;if(16&o&&"function"==typeof e.then)return e}var s=Object.create(null);i.r(s);var n={};t=t||[null,r({}),r([]),r(r)];for(var a=2&o&&e;"object"==typeof a&&!~t.indexOf(a);a=r(a))Object.getOwnPropertyNames(a).forEach((t=>n[t]=()=>e[t]));return n.default=()=>e,i.d(s,n),s},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.j=1890,(()=>{var e={1890:0};i.O.j=t=>0===e[t];var t=(t,r)=>{var o,s,[n,a,c]=r,l=0;if(n.some((t=>0!==e[t]))){for(o in a)i.o(a,o)&&(i.m[o]=a[o]);if(c)var d=c(i)}for(t&&t(r);l<n.length;l++)s=n[l],i.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return i.O(d)},r=globalThis.webpackChunkwebpackWcBlocksMainJsonp=globalThis.webpackChunkwebpackWcBlocksMainJsonp||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var n=i.O(void 0,[94],(()=>i(5615)));n=i.O(n),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["reviews-by-product"]=n})();