Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
wp-content
/
test
/
wp-content
/
plugins
/
woocommerce
/
assets
/
client
/
blocks
:
product-on-sale.js
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
(()=>{var e,t={3572:(e,t,r)=>{"use strict";r.r(t);var l=r(9196),o=r(5736);const c=window.wp.blocks;var n=r(2911),a=r(7138);const i=window.wp.components,s=window.wp.serverSideRender;var m=r.n(s);const d=(0,l.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"}},(0,l.createElement)("title",null,"Grid Block Preview"),(0,l.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,l.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,l.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,l.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,l.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,l.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,l.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,l.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,l.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,l.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,l.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,l.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,l.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"})),u=window.wp.blockEditor,h=({onChange:e,settings:t})=>{const{image:r,button:c,price:n,rating:a,title:s}=t,m=!1!==r;return(0,l.createElement)(l.Fragment,null,(0,l.createElement)(i.ToggleControl,{label:(0,o.__)("Product image","woocommerce"),checked:m,onChange:()=>e({...t,image:!m})}),(0,l.createElement)(i.ToggleControl,{label:(0,o.__)("Product title","woocommerce"),checked:s,onChange:()=>e({...t,title:!s})}),(0,l.createElement)(i.ToggleControl,{label:(0,o.__)("Product price","woocommerce"),checked:n,onChange:()=>e({...t,price:!n})}),(0,l.createElement)(i.ToggleControl,{label:(0,o.__)("Product rating","woocommerce"),checked:a,onChange:()=>e({...t,rating:!a})}),(0,l.createElement)(i.ToggleControl,{label:(0,o.__)("Add to Cart button","woocommerce"),checked:c,onChange:()=>e({...t,button:!c})}))},E=(e,t,r)=>r?Math.min(e,t)===e?t:Math.max(e,r)===e?r:e:Math.max(e,t)===t?e:t,g=({columns:e,rows:t,setAttributes:r,alignButtons:c,minColumns:n=1,maxColumns:a=6,minRows:s=1,maxRows:m=6})=>(0,l.createElement)(l.Fragment,null,(0,l.createElement)(i.RangeControl,{label:(0,o.__)("Columns","woocommerce"),value:e,onChange:e=>{const t=E(e,n,a);r({columns:Number.isNaN(t)?"":t})},min:n,max:a}),(0,l.createElement)(i.RangeControl,{label:(0,o.__)("Rows","woocommerce"),value:t,onChange:e=>{const t=E(e,s,m);r({rows:Number.isNaN(t)?"":t})},min:s,max:m}),(0,l.createElement)(i.ToggleControl,{label:(0,o.__)("Align the last block to the bottom","woocommerce"),help:c?(0,o.__)("Align the last block to the bottom.","woocommerce"):(0,o.__)("The last inner block will follow other content.","woocommerce"),checked:c,onChange:()=>r({alignButtons:!c})}));var w=r(3849),p=r.n(w),_=r(9307);function b(e,t,r){const l=new Set(t.map((e=>e[r])));return e.filter((e=>!l.has(e[r])))}const f=window.wp.htmlEntities,x={clear:(0,o.__)("Clear all selected items","woocommerce"),noItems:(0,o.__)("No items found.","woocommerce"), /* Translators: %s search term */ noResults:(0,o.__)("No results for %s","woocommerce"),search:(0,o.__)("Search for items","woocommerce"),selected:e=>(0,o.sprintf)(/* translators: Number of items selected from list. */ /* translators: Number of items selected from list. */ (0,o._n)("%d item selected","%d items selected",e,"woocommerce"),e),updated:(0,o.__)("Search results updated.","woocommerce")},y=(e,t=e)=>{const r=e.reduce(((e,t)=>{const r=t.parent||0;return e[r]||(e[r]=[]),e[r].push(t),e}),{}),l=("id",t.reduce(((e,t)=>(e[String(t.id)]=t,e)),{}));const o=["0"],c=(e={})=>e.parent?[...c(l[e.parent]),e.name]:e.name?[e.name]:[],n=e=>e.map((e=>{const t=r[e.id];return o.push(""+e.id),{...e,breadcrumbs:c(l[e.parent]),children:t&&t.length?n(t):[]}})),a=n(r[0]||[]);return Object.entries(r).forEach((([e,t])=>{o.includes(e)||a.push(...n(t||[]))})),a},v=(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,l.createElement)("strong",{key:t},e):(0,l.createElement)(_.Fragment,{key:t},e)))},k=({label:e})=>(0,l.createElement)("span",{className:"woocommerce-search-list__item-count"},e),C=e=>{const{item:t,search:r}=e,o=t.breadcrumbs&&t.breadcrumbs.length;return(0,l.createElement)("span",{className:"woocommerce-search-list__item-label"},o?(0,l.createElement)("span",{className:"woocommerce-search-list__item-prefix"},1===(c=t.breadcrumbs).length?c.slice(0,1).toString():2===c.length?c.slice(0,1).toString()+" › "+c.slice(-1).toString():c.slice(0,1).toString()+" … "+c.slice(-1).toString()):null,(0,l.createElement)("span",{className:"woocommerce-search-list__item-name"},v((0,f.decodeEntities)(t.name),r)));var c},S=({countLabel:e,className:t,depth:r=0,controlId:o="",item:c,isSelected:n,isSingle:a,onSelect:s,search:m="",selected:d,useExpandedPanelId:u,...h})=>{var E,g;const[w,x]=u,y=null!=e&&void 0!==c.count&&null!==c.count,S=!(null===(E=c.breadcrumbs)||void 0===E||!E.length),N=!(null===(g=c.children)||void 0===g||!g.length),O=w===c.id,P=p()(["woocommerce-search-list__item",`depth-${r}`,t],{"has-breadcrumbs":S,"has-children":N,"has-count":y,"is-expanded":O,"is-radio-button":a}),I=h.name||`search-list-item-${o}`,R=`${I}-${c.id}`,B=(0,_.useCallback)((()=>{x(O?-1:Number(c.id))}),[O,c.id,x]);return N?(0,l.createElement)("div",{className:P,onClick:B,onKeyDown:e=>"Enter"===e.key||" "===e.key?B():null,role:"treeitem",tabIndex:0},a?(0,l.createElement)(l.Fragment,null,(0,l.createElement)("input",{type:"radio",id:R,name:I,value:c.value,onChange:s(c),onClick:e=>e.stopPropagation(),checked:n,className:"woocommerce-search-list__item-input",...h}),(0,l.createElement)(C,{item:c,search:m}),y?(0,l.createElement)(k,{label:e||c.count}):null):(0,l.createElement)(l.Fragment,null,(0,l.createElement)(i.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:n,...!n&&c.children.some((e=>d.find((t=>t.id===e.id))))?{indeterminate:!0}:{},label:v((0,f.decodeEntities)(c.name),m),onChange:()=>{n?s(b(d,c.children,"id"))():s(function(e,t,r){const l=b(t,e,"id");return[...e,...l]}(d,c.children))()},onClick:e=>e.stopPropagation()}),y?(0,l.createElement)(k,{label:e||c.count}):null)):(0,l.createElement)("label",{htmlFor:R,className:P},a?(0,l.createElement)(l.Fragment,null,(0,l.createElement)("input",{...h,type:"radio",id:R,name:I,value:c.value,onChange:s(c),checked:n,className:"woocommerce-search-list__item-input"}),(0,l.createElement)(C,{item:c,search:m})):(0,l.createElement)(i.CheckboxControl,{...h,id:R,name:I,className:"woocommerce-search-list__item-input",value:(0,f.decodeEntities)(c.value),label:v((0,f.decodeEntities)(c.name),m),onChange:s(c),checked:n}),y?(0,l.createElement)(k,{label:e||c.count}):null)},N=S;var O=r(2720),P=r(4333),I=r(837);r(1058);const R=({id:e,label:t,popoverContents:r,remove:c,screenReaderLabel:a,className:s=""})=>{const[m,d]=(0,_.useState)(!1),u=(0,P.useInstanceId)(R);if(a=a||t,!t)return null;t=(0,f.decodeEntities)(t);const h=p()("woocommerce-tag",s,{"has-remove":!!c}),E=`woocommerce-tag__label-${u}`,g=(0,l.createElement)(l.Fragment,null,(0,l.createElement)("span",{className:"screen-reader-text"},a),(0,l.createElement)("span",{"aria-hidden":"true"},t));return(0,l.createElement)("span",{className:h},r?(0,l.createElement)(i.Button,{className:"woocommerce-tag__text",id:E,onClick:()=>d(!0)},g):(0,l.createElement)("span",{className:"woocommerce-tag__text",id:E},g),r&&m&&(0,l.createElement)(i.Popover,{onClose:()=>d(!1)},r),c&&(0,l.createElement)(i.Button,{className:"woocommerce-tag__remove",onClick:c(e),label:(0,o.sprintf)( // Translators: %s label. // Translators: %s label. (0,o.__)("Remove %s","woocommerce"),t),"aria-describedby":E},(0,l.createElement)(n.Z,{icon:I.Z,size:20,className:"clear-icon",role:"img"})))},B=R;r(9658);const T=e=>(0,l.createElement)(N,{...e}),$=e=>{const{list:t,selected:r,renderItem:o,depth:c=0,onSelect:n,instanceId:a,isSingle:i,search:s,useExpandedPanelId:m}=e,[d]=m;return t?(0,l.createElement)(_.Fragment,null,t.map((t=>{var u,h;const E=null!==(u=t.children)&&void 0!==u&&u.length&&!i?t.children.every((({id:e})=>r.find((t=>t.id===e)))):!!r.find((({id:e})=>e===t.id)),g=(null===(h=t.children)||void 0===h?void 0:h.length)&&d===t.id;return(0,l.createElement)(_.Fragment,{key:t.id},(0,l.createElement)("li",null,o({item:t,isSelected:E,onSelect:n,isSingle:i,selected:r,search:s,depth:c,useExpandedPanelId:m,controlId:a})),g?(0,l.createElement)($,{...e,list:t.children,depth:c+1}):null)}))):null},A=({isLoading:e,isSingle:t,selected:r,messages:c,onChange:n,onRemove:a})=>{if(e||t||!r)return null;const s=r.length;return(0,l.createElement)("div",{className:"woocommerce-search-list__selected"},(0,l.createElement)("div",{className:"woocommerce-search-list__selected-header"},(0,l.createElement)("strong",null,c.selected(s)),s>0?(0,l.createElement)(i.Button,{variant:"link",isDestructive:!0,onClick:()=>n([]),"aria-label":c.clear},(0,o.__)("Clear all","woocommerce")):null),s>0?(0,l.createElement)("ul",null,r.map(((e,t)=>(0,l.createElement)("li",{key:t},(0,l.createElement)(B,{label:e.name,id:e.id,remove:a}))))):null)},F=({filteredList:e,search:t,onSelect:r,instanceId:c,useExpandedPanelId:a,...i})=>{const{messages:s,renderItem:m,selected:d,isSingle:u}=i,h=m||T;return 0===e.length?(0,l.createElement)("div",{className:"woocommerce-search-list__list is-not-found"},(0,l.createElement)("span",{className:"woocommerce-search-list__not-found-icon"},(0,l.createElement)(n.Z,{icon:O.Z,role:"img"})),(0,l.createElement)("span",{className:"woocommerce-search-list__not-found-text"},t?(0,o.sprintf)(s.noResults,t):s.noItems)):(0,l.createElement)("ul",{className:"woocommerce-search-list__list"},(0,l.createElement)($,{useExpandedPanelId:a,list:e,selected:d,renderItem:h,onSelect:r,instanceId:c,isSingle:u,search:t}))},j=e=>{const{className:t="",isCompact:r,isHierarchical:c,isLoading:n,isSingle:a,list:s,messages:m=x,onChange:d,onSearch:u,selected:h,type:E="text",debouncedSpeak:g}=e,[w,b]=(0,_.useState)(""),f=(0,_.useState)(-1),v=(0,P.useInstanceId)(j),k=(0,_.useMemo)((()=>({...x,...m})),[m]),C=(0,_.useMemo)((()=>((e,t,r)=>{if(!t)return r?y(e):e;const l=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),o=e.map((e=>!!l.test(e.name)&&e)).filter(Boolean);return r?y(o,e):o})(s,w,c)),[s,w,c]);(0,_.useEffect)((()=>{g&&g(k.updated)}),[g,k]),(0,_.useEffect)((()=>{"function"==typeof u&&u(w)}),[w,u]);const S=(0,_.useCallback)((e=>()=>{a&&d([]);const t=h.findIndex((({id:t})=>t===e));d([...h.slice(0,t),...h.slice(t+1)])}),[a,h,d]),N=(0,_.useCallback)((e=>()=>{Array.isArray(e)?d(e):-1===h.findIndex((({id:t})=>t===e.id))?d(a?[e]:[...h,e]):S(e.id)()}),[a,S,d,h]),O=(0,_.useCallback)((e=>{const[t]=h.filter((t=>!e.find((e=>t.id===e.id))));S(t.id)()}),[S,h]);return(0,l.createElement)("div",{className:p()("woocommerce-search-list",t,{"is-compact":r,"is-loading":n,"is-token":"token"===E})},"text"===E&&(0,l.createElement)(A,{...e,onRemove:S,messages:k}),(0,l.createElement)("div",{className:"woocommerce-search-list__search"},"text"===E?(0,l.createElement)(i.TextControl,{label:k.search,type:"search",value:w,onChange:e=>b(e)}):(0,l.createElement)(i.FormTokenField,{disabled:n,label:k.search,onChange:O,onInputChange:e=>b(e),suggestions:[],__experimentalValidateInput:()=>!1,value:n?[(0,o.__)("Loading…","woocommerce")]:h.map((e=>({...e,value:e.name}))),__experimentalShowHowTo:!1})),n?(0,l.createElement)("div",{className:"woocommerce-search-list__list"},(0,l.createElement)(i.Spinner,null)):(0,l.createElement)(F,{...e,search:w,filteredList:C,messages:k,onSelect:N,instanceId:v,useExpandedPanelId:f}))},L=((0,i.withSpokenMessages)(j),window.wp.url),M=window.wp.apiFetch;var Z=r.n(M);const H=window.wc.wcSettings,D=window.wp.escapeHtml,V=({error:e})=>(0,l.createElement)("div",{className:"wc-block-error-message"},(({message:e,type:t})=>e?"general"===t?(0,l.createElement)("span",null,(0,o.__)("The following error was returned","woocommerce"),(0,l.createElement)("br",null),(0,l.createElement)("code",null,(0,D.escapeHTML)(e))):"api"===t?(0,l.createElement)("span",null,(0,o.__)("The following error was returned from the API","woocommerce"),(0,l.createElement)("br",null),(0,l.createElement)("code",null,(0,D.escapeHTML)(e))):e:(0,o.__)("An error has prevented the block from being updated.","woocommerce"))(e)),W=e=>{const{id:t,name:r,parent:l,count:o}=e;return{id:t,name:r,parent:l,count:o,breadcrumbs:[],children:[],details:e,value:e.slug}};r(8103);const J=(X=({categories:e=[],error:t=null,isLoading:r=!1,onChange:c,onOperatorChange:n,operator:a="any",selected:s,isCompact:m=!1,isSingle:d=!1,showReviewCount:u})=>{const h={clear:(0,o.__)("Clear all product categories","woocommerce"),list:(0,o.__)("Product Categories","woocommerce"),noItems:(0,o.__)("Your store doesn't have any product categories.","woocommerce"),search:(0,o.__)("Search for product categories","woocommerce"),selected:e=>(0,o.sprintf)(/* translators: %d is the count of selected categories. */ /* translators: %d is the count of selected categories. */ (0,o._n)("%d category selected","%d categories selected",e,"woocommerce"),e),updated:(0,o.__)("Category search results updated.","woocommerce")};if(t)return(0,l.createElement)(V,{error:t});const E=e.map(W);return(0,l.createElement)(l.Fragment,null,(0,l.createElement)(j,{className:"woocommerce-product-categories",list:E,isLoading:r,selected:E.filter((({id:e})=>s.includes(Number(e)))),onChange:c,renderItem:e=>{var t,r,c,n,a,i,s,m;const{item:d,search:h,depth:E=0}=e,g=d.breadcrumbs.length?`${d.breadcrumbs.join(", ")}, ${d.name}`:d.name,w=u?(0,o.sprintf)(/* translators: %1$s is the item name, %2$d is the count of reviews for the item. */ /* translators: %1$s is the item name, %2$d is the count of reviews for the item. */ (0,o._n)("%1$s, has %2$d review","%1$s, has %2$d reviews",(null===(t=d.details)||void 0===t?void 0:t.review_count)||0,"woocommerce"),g,(null===(r=d.details)||void 0===r?void 0:r.review_count)||0):(0,o.sprintf)(/* translators: %1$s is the item name, %2$d is the count of products for the item. */ /* translators: %1$s is the item name, %2$d is the count of products for the item. */ (0,o._n)("%1$s, has %2$d product","%1$s, has %2$d products",(null===(c=d.details)||void 0===c?void 0:c.count)||0,"woocommerce"),g,(null===(n=d.details)||void 0===n?void 0:n.count)||0),_=u?(0,o.sprintf)(/* translators: %d is the count of reviews. */ /* translators: %d is the count of reviews. */ (0,o._n)("%d review","%d reviews",(null===(a=d.details)||void 0===a?void 0:a.review_count)||0,"woocommerce"),(null===(i=d.details)||void 0===i?void 0:i.review_count)||0):(0,o.sprintf)(/* translators: %d is the count of products. */ /* translators: %d is the count of products. */ (0,o._n)("%d product","%d products",(null===(s=d.details)||void 0===s?void 0:s.count)||0,"woocommerce"),(null===(m=d.details)||void 0===m?void 0:m.count)||0);return(0,l.createElement)(S,{className:p()("woocommerce-product-categories__item","has-count",{"is-searching":h.length>0,"is-skip-level":0===E&&0!==d.parent}),...e,countLabel:_,"aria-label":w})},messages:h,isCompact:m,isHierarchical:!0,isSingle:d}),!!n&&(0,l.createElement)("div",{hidden:s.length<2},(0,l.createElement)(i.SelectControl,{className:"woocommerce-product-categories__operator",label:(0,o.__)("Display products matching","woocommerce"),help:(0,o.__)("Pick at least two categories to use this setting.","woocommerce"),value:a,onChange:n,options:[{label:(0,o.__)("Any selected categories","woocommerce"),value:"any"},{label:(0,o.__)("All selected categories","woocommerce"),value:"all"}]})))},({selected:e,...t})=>{const[r,o]=(0,_.useState)(!0),[c,n]=(0,_.useState)(null),[a,i]=(0,_.useState)([]),s=async e=>{const t=await(async e=>{if(!("json"in e))return{message:e.message,type:e.type||"general"};try{const t=await e.json();return{message:t.message,type:t.type||"api"}}catch(e){return{message:e.message,type:"general"}}})(e);n(t),o(!1)},m=(0,_.useRef)(e);return(0,_.useEffect)((()=>{var e;(e={selected:m.current},Z()({path:(0,L.addQueryArgs)("wc/store/v1/products/categories",{per_page:0,...e})})).then((e=>{i(e),o(!1)})).catch(s)}),[m]),(0,l.createElement)(X,{...t,selected:e,error:c,categories:a,isLoading:r})}),z=({value:e,setAttributes:t})=>(0,l.createElement)(i.SelectControl,{label:(0,o.__)("Order products by","woocommerce"),value:e,options:[{label:(0,o.__)("Newness - newest first","woocommerce"),value:"date"},{label:(0,o.__)("Price - low to high","woocommerce"),value:"price_asc"},{label:(0,o.__)("Price - high to low","woocommerce"),value:"price_desc"},{label:(0,o.__)("Rating - highest first","woocommerce"),value:"rating"},{label:(0,o.__)("Sales - most first","woocommerce"),value:"popularity"},{label:(0,o.__)("Title - alphabetical","woocommerce"),value:"title"},{label:(0,o.__)("Menu Order","woocommerce"),value:"menu_order"}],onChange:e=>t({orderby:e})}),G=(0,H.getSetting)("hideOutOfStockItems",!1),K=(0,H.getSetting)("stockStatusOptions",{}),Q=({value:e,setAttributes:t})=>{const{outofstock:r,...c}=K,n=G?c:K,a=Object.entries(n).map((([e,t])=>({value:e,label:t}))).filter((e=>!!e.label)),s=Object.keys(n).filter((e=>!!e)),[m,d]=(0,_.useState)(e||s);(0,_.useEffect)((()=>{t({stockStatus:["",...m]})}),[m,t]);const u=(0,_.useCallback)((e=>{const t=m.includes(e),r=m.filter((t=>t!==e));t||(r.push(e),r.sort()),d(r)}),[m]);return(0,l.createElement)(l.Fragment,null,a.map((e=>{const t=m.includes(e.value)?/* translators: %s stock status. */ /* translators: %s stock status. */(0,o.__)('Stock status "%s" visible.',"woocommerce"):/* translators: %s stock status. */ /* translators: %s stock status. */(0,o.__)('Stock status "%s" hidden.',"woocommerce");return(0,l.createElement)(i.ToggleControl,{label:e.label,key:e.value,help:(0,o.sprintf)(t,e.label),checked:m.includes(e.value),onChange:()=>u(e.value)})})))},Y=e=>{const{attributes:t,setAttributes:r}=e,{categories:c,catOperator:n,columns:a,contentVisibility:s,rows:m,orderby:d,alignButtons:E,stockStatus:w}=t;return(0,l.createElement)(u.InspectorControls,{key:"inspector"},(0,l.createElement)(i.PanelBody,{title:(0,o.__)("Layout","woocommerce"),initialOpen:!0},(0,l.createElement)(g,{columns:a,rows:m,alignButtons:E,setAttributes:r,minColumns:(0,H.getSetting)("minColumns",1),maxColumns:(0,H.getSetting)("maxColumns",6),minRows:(0,H.getSetting)("minRows",1),maxRows:(0,H.getSetting)("maxRows",6)})),(0,l.createElement)(i.PanelBody,{title:(0,o.__)("Content","woocommerce"),initialOpen:!0},(0,l.createElement)(h,{settings:s,onChange:e=>r({contentVisibility:e})})),(0,l.createElement)(i.PanelBody,{title:(0,o.__)("Order By","woocommerce"),initialOpen:!1},(0,l.createElement)(z,{setAttributes:r,value:d})),(0,l.createElement)(i.PanelBody,{title:(0,o.__)("Filter by Product Category","woocommerce"),initialOpen:!1},(0,l.createElement)(J,{selected:c,onChange:(e=[])=>{const t=e.map((({id:e})=>e));r({categories:t})},operator:n,onOperatorChange:(e="any")=>r({catOperator:e})})),(0,l.createElement)(i.PanelBody,{title:(0,o.__)("Filter by stock status","woocommerce"),initialOpen:!1},(0,l.createElement)(Q,{setAttributes:r,value:w})))},q=()=>(0,l.createElement)(i.Placeholder,{icon:(0,l.createElement)(n.Z,{icon:a.Z}),label:(0,o.__)("On Sale Products","woocommerce"),className:"wc-block-product-on-sale"},(0,o.__)("This block shows on-sale products. There are currently no discounted products in your store.","woocommerce")),U=e=>{const{attributes:t,setAttributes:r,name:o}=e;return t.isPreview?d:(0,l.createElement)(l.Fragment,null,(0,l.createElement)(Y,{attributes:t,setAttributes:r}),(0,l.createElement)(i.Disabled,null,(0,l.createElement)(m(),{block:o,attributes:t,EmptyResponsePlaceholder:q})))};var X;r(3761);const ee={columns:{type:"number",default:(0,H.getSetting)("defaultColumns",3)},rows:{type:"number",default:(0,H.getSetting)("defaultRows",3)},alignButtons:{type:"boolean",default:!1},categories:{type:"array",default:[]},catOperator:{type:"string",default:"any"},contentVisibility:{type:"object",default:{image:!0,title:!0,price:!0,rating:!0,button:!0}},isPreview:{type:"boolean",default:!1},stockStatus:{type:"array",default:Object.keys((0,H.getSetting)("stockStatusOptions",[]))}};(0,c.registerBlockType)("woocommerce/product-on-sale",{title:(0,o.__)("On Sale Products","woocommerce"),icon:{src:(0,l.createElement)(n.Z,{icon:a.Z,className:"wc-block-editor-components-block-icon"})},category:"woocommerce",keywords:[(0,o.__)("WooCommerce","woocommerce")],description:(0,o.__)("Display a grid of products currently on sale.","woocommerce"),supports:{align:["wide","full"],html:!1},attributes:{...ee,orderby:{type:"string",default:"date"}},transforms:{from:[{type:"block",blocks:["woocommerce/product-best-sellers","woocommerce/product-category","woocommerce/product-new","woocommerce/product-on-sale","woocommerce/product-top-rated"].filter((e=>"woocommerce/product-on-sale"!==e)),transform:e=>(0,c.createBlock)("woocommerce/product-on-sale",e)}]},edit:e=>(0,l.createElement)(U,{...e}),save:()=>null})},3761:()=>{},8103:()=>{},9658:()=>{},1058:()=>{},9196:e=>{"use strict";e.exports=window.React},4333:e=>{"use strict";e.exports=window.wp.compose},9307:e=>{"use strict";e.exports=window.wp.element},5736:e=>{"use strict";e.exports=window.wp.i18n},444:e=>{"use strict";e.exports=window.wp.primitives}},r={};function l(e){var o=r[e];if(void 0!==o)return o.exports;var c=r[e]={exports:{}};return t[e].call(c.exports,c,c.exports,l),c.exports}l.m=t,e=[],l.O=(t,r,o,c)=>{if(!r){var n=1/0;for(m=0;m<e.length;m++){for(var[r,o,c]=e[m],a=!0,i=0;i<r.length;i++)(!1&c||n>=c)&&Object.keys(l.O).every((e=>l.O[e](r[i])))?r.splice(i--,1):(a=!1,c<n&&(n=c));if(a){e.splice(m--,1);var s=o();void 0!==s&&(t=s)}}return t}c=c||0;for(var m=e.length;m>0&&e[m-1][2]>c;m--)e[m]=e[m-1];e[m]=[r,o,c]},l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},l.d=(e,t)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.j=9597,(()=>{var e={9597:0};l.O.j=t=>0===e[t];var t=(t,r)=>{var o,c,[n,a,i]=r,s=0;if(n.some((t=>0!==e[t]))){for(o in a)l.o(a,o)&&(l.m[o]=a[o]);if(i)var m=i(l)}for(t&&t(r);s<n.length;s++)c=n[s],l.o(e,c)&&e[c]&&e[c][0](),e[c]=0;return l.O(m)},r=self.webpackChunkwebpackWcBlocksJsonp=self.webpackChunkwebpackWcBlocksJsonp||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var o=l.O(void 0,[2869],(()=>l(3572)));o=l.O(o),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["product-on-sale"]=o})();