PK
Current Path : /home/wallqcyy/www/wp-content/plugins/woocommerce/assets/client/blocks/ |
Current File : //home/wallqcyy/www/wp-content/plugins/woocommerce/assets/client/blocks/products-by-attribute.js |
(()=>{var e,t,r,s={1829:(e,t,r)=>{"use strict";var s=r(4530),o=r(5536);const i=window.wp.blocks,c=window.wc.wcSettings;r(4747);const n=JSON.parse('{"name":"woocommerce/products-by-attribute","title":"Products by Attribute","category":"woocommerce","keywords":["WooCommerce"],"description":"Display a grid of products with selected attributes.","supports":{"interactivity":{"clientNavigation":false},"align":["wide","full"],"html":false,"inserter":false},"attributes":{"attributes":{"type":"array","default":[]},"attrOperator":{"type":"string","enum":["all","any"],"default":"any"},"columns":{"type":"number","default":3},"contentVisibility":{"type":"object","default":{"image":true,"title":true,"price":true,"rating":true,"button":true},"properties":{"image":{"type":"boolean","default":true},"title":{"type":"boolean","default":true},"price":{"type":"boolean","default":true},"rating":{"type":"boolean","default":true},"button":{"type":"boolean","default":true}}},"orderby":{"type":"string","enum":["date","popularity","price_asc","price_desc","rating","title","menu_order"],"default":"date"},"rows":{"type":"number","default":3},"alignButtons":{"type":"boolean","default":false},"isPreview":{"type":"boolean","default":false},"stockStatus":{"type":"array"}},"textdomain":"woocommerce","apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json"}'),l=window.wp.blockEditor,a=window.wp.components;var d=r(6087),m=r(7723),u=r(790);const h=(e,t,r)=>r?Math.min(e,t)===e?t:Math.max(e,r)===e?r:e:Math.max(e,t)===t?e:t,x=({columns:e,rows:t,setAttributes:r,alignButtons:s,minColumns:o=1,maxColumns:i=6,minRows:c=1,maxRows:n=6})=>(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(a.RangeControl,{label:(0,m.__)("Columns","woocommerce"),value:e,onChange:e=>{const t=h(e,o,i);r({columns:Number.isNaN(t)?"":t})},min:o,max:i}),(0,u.jsx)(a.RangeControl,{label:(0,m.__)("Rows","woocommerce"),value:t,onChange:e=>{const t=h(e,c,n);r({rows:Number.isNaN(t)?"":t})},min:c,max:n}),(0,u.jsx)(a.ToggleControl,{label:(0,m.__)("Align the last block to the bottom","woocommerce"),help:s?(0,m.__)("Align the last block to the bottom.","woocommerce"):(0,m.__)("The last inner block will follow other content.","woocommerce"),checked:s,onChange:()=>r({alignButtons:!s})})]}),p=({onChange:e,settings:t})=>{const{image:r,button:s,price:o,rating:i,title:c}=t,n=!1!==r;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(a.ToggleControl,{label:(0,m.__)("Product image","woocommerce"),checked:n,onChange:()=>e({...t,image:!n})}),(0,u.jsx)(a.ToggleControl,{label:(0,m.__)("Product title","woocommerce"),checked:c,onChange:()=>e({...t,title:!c})}),(0,u.jsx)(a.ToggleControl,{label:(0,m.__)("Product price","woocommerce"),checked:o,onChange:()=>e({...t,price:!o})}),(0,u.jsx)(a.ToggleControl,{label:(0,m.__)("Product rating","woocommerce"),checked:i,onChange:()=>e({...t,rating:!i})}),(0,u.jsx)(a.ToggleControl,{label:(0,m.__)("Add to Cart button","woocommerce"),checked:s,onChange:()=>e({...t,button:!s})})]})};var g=r(4921);function w(e,t,r){const s=new Set(t.map((e=>e[r])));return e.filter((e=>!s.has(e[r])))}const b=window.wp.htmlEntities,_={clear:(0,m.__)("Clear all selected items","woocommerce"),noItems:(0,m.__)("No items found.","woocommerce"), /* Translators: %s search term */ noResults:(0,m.__)("No results for %s","woocommerce"),search:(0,m.__)("Search for items","woocommerce"),selected:e=>(0,m.sprintf)(/* translators: Number of items selected from list. */ /* translators: Number of items selected from list. */ (0,m._n)("%d item selected","%d items selected",e,"woocommerce"),e),updated:(0,m.__)("Search results updated.","woocommerce")},f=(e,t=e)=>{const r=e.reduce(((e,t)=>{const r=t.parent||0;return e[r]||(e[r]=[]),e[r].push(t),e}),{}),s=t.reduce(((e,t)=>(e[String(t.id)]=t,e)),{});const o=["0"],i=(e={})=>e.parent?[...i(s[e.parent]),e.name]:e.name?[e.name]:[],c=e=>e.map((e=>{const t=r[e.id];return o.push(""+e.id),{...e,breadcrumbs:i(s[e.parent]),children:t&&t.length?c(t):[]}})),n=c(r[0]||[]);return Object.entries(r).forEach((([e,t])=>{o.includes(e)||n.push(...c(t||[]))})),n},j=(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)))},E=({label:e})=>(0,u.jsx)("span",{className:"woocommerce-search-list__item-count",children:e}),y=e=>{const{item:t,search:r}=e,s=t.breadcrumbs&&t.breadcrumbs.length;return(0,u.jsxs)("span",{className:"woocommerce-search-list__item-label",children:[s?(0,u.jsx)("span",{className:"woocommerce-search-list__item-prefix",children:(o=t.breadcrumbs,1===o.length?o.slice(0,1).toString():2===o.length?o.slice(0,1).toString()+" › "+o.slice(-1).toString():o.slice(0,1).toString()+" … "+o.slice(-1).toString())}):null,(0,u.jsx)("span",{className:"woocommerce-search-list__item-name",children:j((0,b.decodeEntities)(t.name),r)})]});var o},v=({countLabel:e,className:t,depth:r=0,controlId:s="",item:o,isSelected:i,isSingle:c,onSelect:n,search:l="",selected:m,useExpandedPanelId:h,...x})=>{const[p,_]=h,f=null!=e&&void 0!==o.count&&null!==o.count,v=!!o.breadcrumbs?.length,k=!!o.children?.length,C=p===o.id,S=(0,g.A)(["woocommerce-search-list__item",`depth-${r}`,t],{"has-breadcrumbs":v,"has-children":k,"has-count":f,"is-expanded":C,"is-radio-button":c});(0,d.useEffect)((()=>{k&&i&&_(o.id)}),[o,k,i,_]);const N=x.name||`search-list-item-${s}`,O=`${N}-${o.id}`,A=(0,d.useCallback)((()=>{_(C?-1:Number(o.id))}),[C,o.id,_]);return k?(0,u.jsx)("div",{className:S,onClick:A,onKeyDown:e=>"Enter"===e.key||" "===e.key?A():null,role:"treeitem",tabIndex:0,children:c?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("input",{type:"radio",id:O,name:N,value:o.value,onChange:n(o),onClick:e=>e.stopPropagation(),checked:i,className:"woocommerce-search-list__item-input",...x}),(0,u.jsx)(y,{item:o,search:l}),f?(0,u.jsx)(E,{label:e||o.count}):null]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(a.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:i,...!i&&o.children.some((e=>m.find((t=>t.id===e.id))))?{indeterminate:!0}:{},label:j((0,b.decodeEntities)(o.name),l),onChange:()=>{i?n(w(m,o.children,"id"))():n(function(e,t){const r=w(t,e,"id");return[...e,...r]}(m,o.children))()},onClick:e=>e.stopPropagation()}),f?(0,u.jsx)(E,{label:e||o.count}):null]})}):(0,u.jsxs)("label",{htmlFor:O,className:S,children:[c?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("input",{...x,type:"radio",id:O,name:N,value:o.value,onChange:n(o),checked:i,className:"woocommerce-search-list__item-input"}),(0,u.jsx)(y,{item:o,search:l})]}):(0,u.jsx)(a.CheckboxControl,{...x,id:O,name:N,className:"woocommerce-search-list__item-input",value:(0,b.decodeEntities)(o.value),label:j((0,b.decodeEntities)(o.name),l),onChange:n(o),checked:i}),f?(0,u.jsx)(E,{label:e||o.count}):null]})},k=v;var C=r(2624),S=r(9491),N=r(3028);r(5022);const O=({id:e,label:t,popoverContents:r,remove:o,screenReaderLabel:i,className:c=""})=>{const[n,l]=(0,d.useState)(!1),h=(0,S.useInstanceId)(O);if(i=i||t,!t)return null;t=(0,b.decodeEntities)(t);const x=(0,g.A)("woocommerce-tag",c,{"has-remove":!!o}),p=`woocommerce-tag__label-${h}`,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:x,children:[r?(0,u.jsx)(a.Button,{className:"woocommerce-tag__text",id:p,onClick:()=>l(!0),children:w}):(0,u.jsx)("span",{className:"woocommerce-tag__text",id:p,children:w}),r&&n&&(0,u.jsx)(a.Popover,{onClose:()=>l(!1),children:r}),o&&(0,u.jsx)(a.Button,{className:"woocommerce-tag__remove",onClick:o(e),label:(0,m.sprintf)( // Translators: %s label. // Translators: %s label. (0,m.__)("Remove %s","woocommerce"),t),"aria-describedby":p,children:(0,u.jsx)(s.A,{icon:N.A,size:20,className:"clear-icon",role:"img"})})]})},A=O;r(1939);const P=e=>(0,u.jsx)(k,{...e}),I=e=>{const{list:t,selected:r,renderItem:s,depth:o=0,onSelect:i,instanceId:c,isSingle:n,search:l,useExpandedPanelId:a}=e,[m]=a;return t?(0,u.jsx)(u.Fragment,{children:t.map((t=>{const h=t.children?.length&&!n?t.children.every((({id:e})=>r.find((t=>t.id===e)))):!!r.find((({id:e})=>e===t.id)),x=t.children?.length&&m===t.id;return(0,u.jsxs)(d.Fragment,{children:[(0,u.jsx)("li",{children:s({item:t,isSelected:h,onSelect:i,isSingle:n,selected:r,search:l,depth:o,useExpandedPanelId:a,controlId:c})}),x?(0,u.jsx)(I,{...e,list:t.children,depth:o+1}):null]},t.id)}))}):null},B=({isLoading:e,isSingle:t,selected:r,messages:s,onChange:o,onRemove:i})=>{if(e||t||!r)return null;const c=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:s.selected(c)}),c>0?(0,u.jsx)(a.Button,{variant:"link",isDestructive:!0,onClick:()=>o([]),"aria-label":s.clear,children:(0,m.__)("Clear all","woocommerce")}):null]}),c>0?(0,u.jsx)("ul",{children:r.map(((e,t)=>(0,u.jsx)("li",{children:(0,u.jsx)(A,{label:e.name,id:e.id,remove:i})},t)))}):null]})},R=({filteredList:e,search:t,onSelect:r,instanceId:o,useExpandedPanelId:i,...c})=>{const{messages:n,renderItem:l,selected:a,isSingle:d}=c,h=l||P;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:C.A,role:"img"})}),(0,u.jsx)("span",{className:"woocommerce-search-list__not-found-text",children:t?(0,m.sprintf)(n.noResults,t):n.noItems})]}):(0,u.jsx)("ul",{className:"woocommerce-search-list__list",children:(0,u.jsx)(I,{useExpandedPanelId:i,list:e,selected:a,renderItem:h,onSelect:r,instanceId:o,isSingle:d,search:t})})},T=e=>{const{className:t="",isCompact:r,isHierarchical:s,isLoading:o,isSingle:i,list:c,messages:n=_,onChange:l,onSearch:h,selected:x,type:p="text",debouncedSpeak:w}=e,[b,j]=(0,d.useState)(""),E=(0,d.useState)(-1),y=(0,S.useInstanceId)(T),v=(0,d.useMemo)((()=>({..._,...n})),[n]),k=(0,d.useMemo)((()=>((e,t,r)=>{if(!t)return r?f(e):e;const s=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),o=e.map((e=>!!s.test(e.name)&&e)).filter(Boolean);return r?f(o,e):o})(c,b,s)),[c,b,s]);(0,d.useEffect)((()=>{w&&w(v.updated)}),[w,v]),(0,d.useEffect)((()=>{"function"==typeof h&&h(b)}),[b,h]);const C=(0,d.useCallback)((e=>()=>{i&&l([]);const t=x.findIndex((({id:t})=>t===e));l([...x.slice(0,t),...x.slice(t+1)])}),[i,x,l]),N=(0,d.useCallback)((e=>()=>{Array.isArray(e)?l(e):-1===x.findIndex((({id:t})=>t===e.id))?l(i?[e]:[...x,e]):C(e.id)()}),[i,C,l,x]),O=(0,d.useCallback)((e=>{const[t]=x.filter((t=>!e.find((e=>t.id===e.id))));C(t.id)()}),[C,x]);return(0,u.jsxs)("div",{className:(0,g.A)("woocommerce-search-list",t,{"is-compact":r,"is-loading":o,"is-token":"token"===p}),children:["text"===p&&(0,u.jsx)(B,{...e,onRemove:C,messages:v}),(0,u.jsx)("div",{className:"woocommerce-search-list__search",children:"text"===p?(0,u.jsx)(a.TextControl,{label:v.search,type:"search",value:b,onChange:e=>j(e)}):(0,u.jsx)(a.FormTokenField,{disabled:o,label:v.search,onChange:O,onInputChange:e=>j(e),suggestions:[],__experimentalValidateInput:()=>!1,value:o?[(0,m.__)("Loading…","woocommerce")]:x.map((e=>({...e,value:e.name}))),__experimentalShowHowTo:!1})}),o?(0,u.jsx)("div",{className:"woocommerce-search-list__list",children:(0,u.jsx)(a.Spinner,{})}):(0,u.jsx)(R,{...e,search:b,filteredList:k,messages:v,onSelect:N,instanceId:y,useExpandedPanelId:E})]})},$=((0,a.withSpokenMessages)(T),window.wp.url,window.wp.apiFetch);var L=r.n($);const F=e=>L()({path:`wc/store/v1/products/attributes/${e}/terms`});const M=window.wp.escapeHtml,D=({message:e,type:t})=>e?"general"===t?(0,u.jsxs)("span",{children:[(0,m.__)("The following error was returned","woocommerce"),(0,u.jsx)("br",{}),(0,u.jsx)("code",{children:(0,M.escapeHTML)(e)})]}):"api"===t?(0,u.jsxs)("span",{children:[(0,m.__)("The following error was returned from the API","woocommerce"),(0,u.jsx)("br",{}),(0,u.jsx)("code",{children:(0,M.escapeHTML)(e)})]}):e:(0,m.__)("An error has prevented the block from being updated.","woocommerce"),H=({error:e})=>(0,u.jsx)("div",{className:"wc-block-error-message",children:D(e)});var V=r(1609);const J=({className:e,item:t,isSelected:r,isLoading:s,onSelect:o,disabled:i,...c})=>(0,u.jsxs)(u.Fragment,{children:[(0,V.createElement)(v,{...c,key:t.id,className:e,isSelected:r,item:t,onSelect:o,disabled:i}),r&&s&&(0,u.jsx)("div",{className:(0,g.A)("woocommerce-search-list__item","woocommerce-product-attributes__item","depth-1","is-loading","is-not-active"),children:(0,u.jsx)(a.Spinner,{})},"loading")]}),W=window.wc.wcTypes,G=((window.wp.data,(0,c.getSetting)("attributes",[])).reduce(((e,t)=>{const r=(s=t)&&s.attribute_name?{id:parseInt(s.attribute_id,10),name:s.attribute_name,taxonomy:"pa_"+s.attribute_name,label:s.attribute_label,orderby:s.attribute_orderby}:null;var s;return r&&r.id&&e.push(r),e}),[]),e=>{const{count:t,id:r,name:s,parent:o}=e;return{count:t,id:r,name:s,parent:o,breadcrumbs:[],children:[],value:(0,W.isAttributeTerm)(e)?e.attr_slug:""}});r(2663);const z=(0,S.withInstanceId)((({onChange:e,onOperatorChange:t,instanceId:r,isCompact:s=!1,messages:o={},operator:i="any",selected:c,type:n="text"})=>{const{errorLoadingAttributes:l,isLoadingAttributes:h,productsAttributes:x}=function(e){const[t,r]=(0,d.useState)(null),[s,o]=(0,d.useState)(!1),[i,c]=(0,d.useState)([]),n=(0,d.useRef)(!1);return(0,d.useEffect)((()=>{if(e&&!s&&!n.current)return async function(){o(!0);try{const e=await L()({path:"wc/store/v1/products/attributes"}),t=[];for(const r of e){const e=await F(r.id);t.push({...r,parent:0,terms:e.map((e=>({...e,attr_slug:r.taxonomy,parent:r.id})))})}c(t),n.current=!0}catch(e){e instanceof Error&&r(await(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"}}})(e))}finally{o(!1)}}(),()=>{n.current=!0}}),[s,e]),{errorLoadingAttributes:t,isLoadingAttributes:s,productsAttributes:i}}(!0),p=x.reduce(((e,t)=>{const{terms:r,...s}=t;return[...e,G(s),...r.map(G)]}),[]);return o={clear:(0,m.__)("Clear all product attributes","woocommerce"),noItems:(0,m.__)("Your store doesn't have any product attributes.","woocommerce"),search:(0,m.__)("Search for product attributes","woocommerce"),selected:e=>(0,m.sprintf)(/* translators: %d is the count of attributes selected. */ /* translators: %d is the count of attributes selected. */ (0,m._n)("%d attribute selected","%d attributes selected",e,"woocommerce"),e),updated:(0,m.__)("Product attribute search results updated.","woocommerce"),...o},l?(0,u.jsx)(H,{error:l}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(T,{className:"woocommerce-product-attributes",isCompact:s,isHierarchical:!0,isLoading:h,isSingle:!1,list:p,messages:o,onChange:e,renderItem:e=>{const{item:t,search:s,depth:o=0}=e,i=t.count||0,c=["woocommerce-product-attributes__item","woocommerce-search-list__item",{"is-searching":s.length>0,"is-skip-level":0===o&&0!==t.parent}];if(!t.breadcrumbs.length)return(0,u.jsx)(J,{...e,className:(0,g.A)(c),item:t,isLoading:h,disabled:0===t.count,name:`attributes-${r}`,countLabel:(0,m.sprintf)(/* translators: %d is the count of terms. */ /* translators: %d is the count of terms. */ (0,m._n)("%d term","%d terms",i,"woocommerce"),i),"aria-label":(0,m.sprintf)(/* translators: %1$s is the item name, %2$d is the count of terms for the item. */ /* translators: %1$s is the item name, %2$d is the count of terms for the item. */ (0,m._n)("%1$s, has %2$d term","%1$s, has %2$d terms",i,"woocommerce"),t.name,i)});const n=`${t.breadcrumbs[0]}: ${t.name}`;return(0,u.jsx)(v,{...e,name:`terms-${r}`,className:(0,g.A)(...c,"has-count"),countLabel:(0,m.sprintf)(/* translators: %d is the count of products. */ /* translators: %d is the count of products. */ (0,m._n)("%d product","%d products",i,"woocommerce"),i),"aria-label":(0,m.sprintf)(/* translators: %1$s is the attribute name, %2$d is the count of products for that attribute. */ /* translators: %1$s is the attribute name, %2$d is the count of products for that attribute. */ (0,m._n)("%1$s, has %2$d product","%1$s, has %2$d products",i,"woocommerce"),n,i)})},selected:c.map((({id:e})=>p.find((t=>t.id===e)))).filter(Boolean),type:n}),!!t&&(0,u.jsx)("div",{hidden:c.length<2,children:(0,u.jsx)(a.SelectControl,{className:"woocommerce-product-attributes__operator",label:(0,m.__)("Display products matching","woocommerce"),help:(0,m.__)("Pick at least two attributes to use this setting.","woocommerce"),value:i,onChange:t,options:[{label:(0,m.__)("Any selected attributes","woocommerce"),value:"any"},{label:(0,m.__)("All selected attributes","woocommerce"),value:"all"}]})})]})})),K=({value:e,setAttributes:t})=>(0,u.jsx)(a.SelectControl,{label:(0,m.__)("Order products by","woocommerce"),value:e,options:[{label:(0,m.__)("Newness - newest first","woocommerce"),value:"date"},{label:(0,m.__)("Price - low to high","woocommerce"),value:"price_asc"},{label:(0,m.__)("Price - high to low","woocommerce"),value:"price_desc"},{label:(0,m.__)("Rating - highest first","woocommerce"),value:"rating"},{label:(0,m.__)("Sales - most first","woocommerce"),value:"popularity"},{label:(0,m.__)("Title - alphabetical","woocommerce"),value:"title"},{label:(0,m.__)("Menu Order","woocommerce"),value:"menu_order"}],onChange:e=>t({orderby:e})}),X=(0,c.getSetting)("hideOutOfStockItems",!1),Y=(0,c.getSetting)("stockStatusOptions",{}),q=({value:e,setAttributes:t})=>{const{outofstock:r,...s}=Y,o=X?s:Y,i=Object.entries(o).map((([e,t])=>({value:e,label:t}))).filter((e=>!!e.label)),c=Object.keys(o).filter((e=>!!e)),[n,l]=(0,d.useState)(e||c);(0,d.useEffect)((()=>{t({stockStatus:["",...n]})}),[n,t]);const h=(0,d.useCallback)((e=>{const t=n.includes(e),r=n.filter((t=>t!==e));t||(r.push(e),r.sort()),l(r)}),[n]);return(0,u.jsx)(u.Fragment,{children:i.map((e=>{const t=n.includes(e.value)?/* translators: %s stock status. */ /* translators: %s stock status. */(0,m.__)('Stock status "%s" visible.',"woocommerce"):/* translators: %s stock status. */ /* translators: %s stock status. */(0,m.__)('Stock status "%s" hidden.',"woocommerce");return(0,u.jsx)(a.ToggleControl,{label:e.label,help:(0,m.sprintf)(t,e.label),checked:n.includes(e.value),onChange:()=>h(e.value)},e.value)}))})},Q=e=>{const{setAttributes:t}=e,{attributes:r,attrOperator:s,columns:o,contentVisibility:i,orderby:n,rows:d,alignButtons:h,stockStatus:g}=e.attributes;return(0,u.jsxs)(l.InspectorControls,{children:[(0,u.jsx)(a.PanelBody,{title:(0,m.__)("Layout","woocommerce"),initialOpen:!0,children:(0,u.jsx)(x,{columns:o,rows:d,alignButtons:h,setAttributes:t,minColumns:(0,c.getSetting)("minColumns",1),maxColumns:(0,c.getSetting)("maxColumns",6),minRows:(0,c.getSetting)("minRows",1),maxRows:(0,c.getSetting)("maxRows",6)})}),(0,u.jsx)(a.PanelBody,{title:(0,m.__)("Content","woocommerce"),initialOpen:!0,children:(0,u.jsx)(p,{settings:i,onChange:e=>t({contentVisibility:e})})}),(0,u.jsx)(a.PanelBody,{title:(0,m.__)("Filter by Product Attribute","woocommerce"),initialOpen:!1,children:(0,u.jsx)(z,{selected:r,onChange:(e=[])=>{const r=e.map((({id:e,value:t})=>({id:e,attr_slug:t})));t({attributes:r})},operator:s,onOperatorChange:(e="any")=>t({attrOperator:e}),isCompact:!0})}),(0,u.jsx)(a.PanelBody,{title:(0,m.__)("Order By","woocommerce"),initialOpen:!1,children:(0,u.jsx)(K,{setAttributes:t,value:n})}),(0,u.jsx)(a.PanelBody,{title:(0,m.__)("Filter by stock status","woocommerce"),initialOpen:!1,children:(0,u.jsx)(q,{setAttributes:t,value:g})})]},"inspector")},U=e=>{const{attributes:t,setAttributes:r,setIsEditing:i,isEditing:c,debouncedSpeak:n}=e;return(0,u.jsxs)(a.Placeholder,{icon:(0,u.jsx)(s.A,{icon:o.A}),label:(0,m.__)("Products by Attribute","woocommerce"),className:"wc-block-products-grid wc-block-products-by-attribute",children:[(0,m.__)("Display a grid of products from your selected attributes.","woocommerce"),(0,u.jsxs)("div",{className:"wc-block-products-by-attribute__selection",children:[(0,u.jsx)(z,{selected:t.attributes,onChange:(e=[])=>{const t=e.map((({id:e,value:t})=>({id:e,attr_slug:t})));r({attributes:t})},operator:t.attrOperator,onOperatorChange:(e="any")=>r({attrOperator:e})}),(0,u.jsx)(a.Button,{variant:"primary",onClick:()=>{i(!c),n((0,m.__)("Showing Products by Attribute block preview.","woocommerce"))},children:(0,m.__)("Done","woocommerce")})]})]})},Z=window.wp.serverSideRender;var ee=r.n(Z);const te=(0,u.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"},children:[(0,u.jsx)("title",{children:"Grid Block Preview"}),(0,u.jsx)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,u.jsx)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,u.jsx)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,u.jsx)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,u.jsx)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,u.jsx)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,u.jsx)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,u.jsx)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,u.jsx)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,u.jsx)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,u.jsx)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,u.jsx)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,u.jsx)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"})]}),re=e=>{const{attributes:t,name:r}=e;return t.isPreview?te:(0,u.jsx)(ee(),{block:r,attributes:t})},se=(0,a.withSpokenMessages)((e=>{const t=(0,l.useBlockProps)(),{attributes:{attributes:r}}=e,[s,o]=(0,d.useState)(!r.length);return(0,u.jsxs)("div",{...t,children:[(0,u.jsx)(l.BlockControls,{children:(0,u.jsx)(a.ToolbarGroup,{controls:[{icon:"edit",title:(0,m.__)("Edit selected attribute","woocommerce"),onClick:()=>o(!s),isActive:s}]})}),(0,u.jsx)(Q,{...e}),s?(0,u.jsx)(U,{isEditing:s,setIsEditing:o,...e}):(0,u.jsx)(a.Disabled,{children:(0,u.jsx)(re,{...e})})]})}));(0,i.registerBlockType)(n,{icon:{src:(0,u.jsx)(s.A,{icon:o.A,className:"wc-block-editor-components-block-icon"})},attributes:{...n.attributes,columns:{type:"number",default:(0,c.getSetting)("defaultColumns",3)},rows:{type:"number",default:(0,c.getSetting)("defaultRows",3)},stockStatus:{type:"array",default:Object.keys((0,c.getSetting)("stockStatusOptions",[]))}},edit:se,save:()=>null})},4747:()=>{},2663:()=>{},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},5573:e=>{"use strict";e.exports=window.wp.primitives}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return s[e].call(r.exports,r,r.exports,i),r.exports}i.m=s,e=[],i.O=(t,r,s,o)=>{if(!r){var c=1/0;for(d=0;d<e.length;d++){for(var[r,s,o]=e[d],n=!0,l=0;l<r.length;l++)(!1&o||c>=o)&&Object.keys(i.O).every((e=>i.O[e](r[l])))?r.splice(l--,1):(n=!1,o<c&&(c=o));if(n){e.splice(d--,1);var a=s();void 0!==a&&(t=a)}}return t}o=o||0;for(var d=e.length;d>0&&e[d-1][2]>o;d--)e[d]=e[d-1];e[d]=[r,s,o]},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,s){if(1&s&&(e=this(e)),8&s)return e;if("object"==typeof e&&e){if(4&s&&e.__esModule)return e;if(16&s&&"function"==typeof e.then)return e}var o=Object.create(null);i.r(o);var c={};t=t||[null,r({}),r([]),r(r)];for(var n=2&s&&e;"object"==typeof n&&!~t.indexOf(n);n=r(n))Object.getOwnPropertyNames(n).forEach((t=>c[t]=()=>e[t]));return c.default=()=>e,i.d(o,c),o},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=8848,(()=>{var e={8848:0};i.O.j=t=>0===e[t];var t=(t,r)=>{var s,o,[c,n,l]=r,a=0;if(c.some((t=>0!==e[t]))){for(s in n)i.o(n,s)&&(i.m[s]=n[s]);if(l)var d=l(i)}for(t&&t(r);a<c.length;a++)o=c[a],i.o(e,o)&&e[o]&&e[o][0](),e[o]=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 c=i.O(void 0,[94],(()=>i(1829)));c=i.O(c),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["products-by-attribute"]=c})();