%PDF- %PDF-
Direktori : /home/tradesc/www/relax/wp-content/plugins/woocommerce/assets/client/blocks/ |
Current File : /home/tradesc/www/relax/wp-content/plugins/woocommerce/assets/client/blocks/product-collection.js |
(()=>{var e,t,o,r={8240:(e,t,o)=>{"use strict";o.r(t);const r=window.wp.blocks,n=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"woocommerce/product-collection","version":"1.0.0","title":"Product Collection","description":"Display a collection of products from your store.","category":"woocommerce","keywords":["WooCommerce","Products (Beta)","products"],"textdomain":"woocommerce","attributes":{"queryId":{"type":"number"},"query":{"type":"object"},"tagName":{"type":"string"},"displayLayout":{"type":"object"},"convertedFromProducts":{"type":"boolean","default":false},"collection":{"type":"string"},"hideControls":{"default":[],"type":"array"},"queryContextIncludes":{"type":"array"},"forcePageReload":{"type":"boolean","default":false},"__privatePreviewState":{"type":"object"}},"providesContext":{"queryId":"queryId","query":"query","displayLayout":"displayLayout","queryContextIncludes":"queryContextIncludes","collection":"collection","__privateProductCollectionPreviewState":"__privatePreviewState"},"usesContext":["templateSlug","postId"],"supports":{"align":["wide","full"],"anchor":true,"html":false,"__experimentalLayout":true,"interactivity":true}}');var c=o(1609);const l=window.wp.blockEditor;var a=o(6087);const s=window.wp.data,i=window.wp.coreData;let u=function(e){return e.Product="product",e.Archive="archive",e.Cart="cart",e.Order="order",e.Site="site",e}({});const m="single-product",d="taxonomy-product_cat",p="taxonomy-product_tag",_=async(e,t,o,r)=>{var n,c;r((n=await(0,s.resolveSelect)(i.store).getEntityRecords(e,t,{_fields:["id"],slug:o}))&&n.length&&null!==(c=n[0])&&void 0!==c&&c.id?n[0].id:null)},g=(e,t={})=>({type:e,sourceData:t}),w=window.wp.components;let E=function(e){return e.COLLECTION_PICKER="collection_chooser",e.PRODUCT_REFERENCE_PICKER="product_context_picker",e.VALID_WITH_PREVIEW="uses_reference_preview_mode",e.VALID="valid",e.DELETED_PRODUCT_REFERENCE="deleted_product_reference",e}({}),h=function(e){return e.GRID="flex",e.STACK="list",e}({}),v=function(e){return e.IN="in",e.NOT_IN="not-in",e}({}),b=function(e){return e.PRODUCT_CATALOG="woocommerce/product-collection/product-catalog",e.BEST_SELLERS="woocommerce/product-collection/best-sellers",e.FEATURED="woocommerce/product-collection/featured",e.NEW_ARRIVALS="woocommerce/product-collection/new-arrivals",e.ON_SALE="woocommerce/product-collection/on-sale",e.TOP_RATED="woocommerce/product-collection/top-rated",e}({}),y=function(e){return e.ATTRIBUTES="attributes",e.CREATED="created",e.FEATURED="featured",e.HAND_PICKED="hand-picked",e.INHERIT="inherit",e.KEYWORD="keyword",e.ON_SALE="on-sale",e.ORDER="order",e.STOCK_STATUS="stock-status",e.TAXONOMY="taxonomy",e.PRICE_RANGE="price-range",e.FILTERABLE="filterable",e}({});var f=o(7723),k=o(4922),C=o.n(k);C()("wc-admin:tracks:stats");const S=C()("wc-admin:tracks");function A(e,t){return S("recordevent %s %o","wcadmin_"+e,t,{_tqk:window._tkq,shouldRecord:!(!window._tkq||!window.wcTracks||!window.wcTracks.isEnabled)}),!(!window.wcTracks||"function"!=typeof window.wcTracks.recordEvent)&&void window.wcTracks.recordEvent(e,t)}var I=o(9491);const R=window.wc.wcBlocksRegistry;var T=o(7104),P=o(4552);const x=window.wc.wcSettings;let N=function(e){return e.SINGLE="single",e.THUMBNAIL="thumbnail",e}({});const O=`${n.name}/product-title`,L=(0,x.getSetting)("stockStatusOptions",[]),D=(0,x.getSetting)("hideOutOfStockItems",!1),B=()=>D?Object.keys(function(e,t){const{[t]:o,...r}=e;return r}(L,"outofstock")):Object.keys(L),F={perPage:9,pages:0,offset:0,postType:"product",order:"asc",orderBy:"title",search:"",exclude:[],inherit:!1,taxQuery:{},isProductCollectionBlock:!0,featured:!1,woocommerceOnSale:!1,woocommerceStockStatus:B(),woocommerceAttributes:[],woocommerceHandPickedProducts:[],timeFrame:void 0,priceRange:void 0,filterable:!1},q={query:F,tagName:"div",displayLayout:{type:h.GRID,columns:3,shrinkColumns:!0},queryContextIncludes:["collection"],forcePageReload:!1},V={woocommerceOnSale:F.woocommerceOnSale,woocommerceStockStatus:F.woocommerceStockStatus,woocommerceAttributes:F.woocommerceAttributes,woocommerceHandPickedProducts:F.woocommerceHandPickedProducts,taxQuery:F.taxQuery,featured:F.featured,timeFrame:F.timeFrame,priceRange:F.priceRange},M=["woocommerce/product-template",{},[["woocommerce/product-image",{imageSizing:N.THUMBNAIL}],["core/post-title",{textAlign:"center",level:3,fontSize:"medium",style:{spacing:{margin:{bottom:"0.75rem",top:"0"}}},isLink:!0,__woocommerceNamespace:O}],["woocommerce/product-price",{textAlign:"center",fontSize:"small"}],["woocommerce/product-button",{textAlign:"center",fontSize:"small"}]]],$="core/query-pagination",H=[M,[$,{layout:{type:"flex",justifyContent:"center"}}],["woocommerce/product-collection-no-results"]],U={name:b.PRODUCT_CATALOG,title:(0,f.__)("Product Catalog","woocommerce"),icon:(0,c.createElement)(T.A,{icon:P.A}),description:"Display all products in your catalog. Results can (change to) match the current template, page, or search term.",keywords:["all products"],scope:[],innerBlocks:H};var G=o(9948);const j={name:b.NEW_ARRIVALS,title:(0,f.__)("New Arrivals","woocommerce"),icon:(0,c.createElement)(T.A,{icon:G.A}),description:(0,f.__)("Recommend your newest products.","woocommerce"),keywords:["newest products","product collection"],scope:[],attributes:{displayLayout:{type:"flex",columns:5,shrinkColumns:!0},query:{orderBy:"date",order:"desc",perPage:5,pages:1,timeFrame:{operator:v.IN,value:"-7 days"}},hideControls:[y.ORDER,y.FILTERABLE]},innerBlocks:[["core/heading",{textAlign:"center",level:2,content:(0,f.__)("New arrivals","woocommerce"),style:{spacing:{margin:{bottom:"1rem"}}}}],M]};var K=o(846);const Q={name:b.TOP_RATED,title:(0,f.__)("Top Rated","woocommerce"),icon:(0,c.createElement)(T.A,{icon:K.A}),description:(0,f.__)("Recommend products with the highest review ratings.","woocommerce"),keywords:["product collection"],scope:[],attributes:{displayLayout:{type:"flex",columns:5,shrinkColumns:!0},query:{orderBy:"rating",order:"desc",perPage:5,pages:1},hideControls:[y.ORDER,y.FILTERABLE]},innerBlocks:[["core/heading",{textAlign:"center",level:2,content:(0,f.__)("Top rated products","woocommerce"),style:{spacing:{margin:{bottom:"1rem"}}}}],M]};var W=o(9744);const z={name:b.BEST_SELLERS,title:(0,f.__)("Best Sellers","woocommerce"),icon:(0,c.createElement)(T.A,{icon:W.A}),description:(0,f.__)("Recommend your best-selling products.","woocommerce"),keywords:["best selling","product collection"],scope:[],attributes:{displayLayout:{type:"flex",columns:5,shrinkColumns:!0},query:{orderBy:"popularity",order:"desc",perPage:5,pages:1},hideControls:[y.ORDER,y.FILTERABLE]},innerBlocks:[["core/heading",{textAlign:"center",level:2,content:(0,f.__)("Best selling products","woocommerce"),style:{spacing:{margin:{bottom:"1rem"}}}}],M]};var Y=o(1173);const J={name:b.ON_SALE,title:(0,f.__)("On Sale","woocommerce"),icon:(0,c.createElement)(T.A,{icon:Y.A}),description:(0,f.__)("Highlight products that are currently on sale.","woocommerce"),keywords:["product collection"],scope:[],attributes:{displayLayout:{type:"flex",columns:5,shrinkColumns:!0},query:{woocommerceOnSale:!0,perPage:5,pages:1},hideControls:[y.ON_SALE,y.FILTERABLE]},innerBlocks:[["core/heading",{textAlign:"center",level:2,content:(0,f.__)("On sale products","woocommerce"),style:{spacing:{margin:{bottom:"1rem"}}}}],M]};var Z=o(43);const X=[U,{name:b.FEATURED,title:(0,f.__)("Featured","woocommerce"),icon:(0,c.createElement)(T.A,{icon:Z.A}),description:(0,f.__)("Showcase your featured products.","woocommerce"),keywords:["product collection"],scope:[],attributes:{displayLayout:{type:"flex",columns:5,shrinkColumns:!0},query:{featured:!0,perPage:5,pages:1},hideControls:[y.FEATURED,y.FILTERABLE]},innerBlocks:[["core/heading",{textAlign:"center",level:2,content:(0,f.__)("Featured products","woocommerce"),style:{spacing:{margin:{bottom:"1rem"}}}}],M]},Q,J,z,j],ee=e=>e?(0,s.select)(r.store).getBlockVariations(n.name).find((({name:t})=>t===e)):null,te=window.wp.hooks,oe=window.wp.url,re=window.wp.apiFetch;var ne,ce,le,ae,se,ie,ue,me,de,pe,_e=o.n(re);const ge=(0,x.getSetting)("wcBlocksConfig",{pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),we=(ge.pluginUrl,ge.pluginUrl,null===(ne=x.STORE_PAGES.shop)||void 0===ne||ne.permalink,null===(ce=x.STORE_PAGES.checkout)||void 0===ce||ce.id,null===(le=x.STORE_PAGES.checkout)||void 0===le||le.permalink,null===(ae=x.STORE_PAGES.privacy)||void 0===ae||ae.permalink,null===(se=x.STORE_PAGES.privacy)||void 0===se||se.title,null===(ie=x.STORE_PAGES.terms)||void 0===ie||ie.permalink,null===(ue=x.STORE_PAGES.terms)||void 0===ue||ue.title,null===(me=x.STORE_PAGES.cart)||void 0===me||me.id,null===(de=x.STORE_PAGES.cart)||void 0===de||de.permalink,null!==(pe=x.STORE_PAGES.myaccount)&&void 0!==pe&&pe.permalink?x.STORE_PAGES.myaccount.permalink:(0,x.getSetting)("wpLoginUrl","/wp-login.php"),(0,x.getSetting)("localPickupEnabled",!1),(0,x.getSetting)("countries",{})),Ee=(0,x.getSetting)("countryData",{}),he=(Object.fromEntries(Object.keys(Ee).filter((e=>!0===Ee[e].allowBilling)).map((e=>[e,we[e]||""]))),Object.fromEntries(Object.keys(Ee).filter((e=>!0===Ee[e].allowBilling)).map((e=>[e,Ee[e].states||[]]))),Object.fromEntries(Object.keys(Ee).filter((e=>!0===Ee[e].allowShipping)).map((e=>[e,we[e]||""]))),Object.fromEntries(Object.keys(Ee).filter((e=>!0===Ee[e].allowShipping)).map((e=>[e,Ee[e].states||[]]))),Object.fromEntries(Object.keys(Ee).map((e=>[e,Ee[e].locale||[]]))),{address:["first_name","last_name","company","address_1","address_2","city","postcode","country","state","phone"],contact:["email"],order:[]}),ve=((0,x.getSetting)("addressFieldsLocations",he).address,(0,x.getSetting)("addressFieldsLocations",he).contact,(0,x.getSetting)("addressFieldsLocations",he).order,(0,x.getSetting)("additionalOrderFields",{}),(0,x.getSetting)("additionalContactFields",{}),(0,x.getSetting)("additionalAddressFields",{}),(e,t)=>{const o=new Map;return e.filter((e=>{const r=t(e);return!o.has(r)&&(o.set(r,e),!0)}))}),be=({selected:e=[],search:t="",queryArgs:o={}})=>{const r=(({selected:e=[],search:t="",queryArgs:o={}})=>{const r=ge.productCount>100,n={per_page:r?100:0,catalog_visibility:"any",search:t,orderby:"title",order:"asc"},c=[(0,oe.addQueryArgs)("/wc/store/v1/products",{...n,...o})];return r&&e.length&&c.push((0,oe.addQueryArgs)("/wc/store/v1/products",{catalog_visibility:"any",include:e,per_page:0})),c})({selected:e,search:t,queryArgs:o});return Promise.all(r.map((e=>_e()({path:e})))).then((e=>{const t=e.flat(),o=ve(t,(e=>e.id));return o.map((e=>({...e,parent:0})))})).catch((e=>{throw e}))},ye=e=>_e()({path:`wc/store/v1/products/attributes/${e}/terms`});function fe(e,t){const{query:o}=e.attributes;e.setAttributes({query:{...o,...t}})}const ke=()=>{var e;const t=null===(e=(0,s.select)("core/edit-site"))||void 0===e?void 0:e.getEditedPostId();return!!t&&["woocommerce/woocommerce//archive-product","woocommerce/woocommerce//taxonomy-product_attribute","woocommerce/woocommerce//product-search-results","//taxonomy-product_cat","//taxonomy-product_tag"].some((e=>t.includes(e)))},Ce=e=>{const{__experimentalGetGlobalBlocksByName:t,getBlock:o}=(0,s.select)(l.store);return!t("woocommerce/product-collection").find((t=>{var r,n;return null===(r=o(t).attributes)||void 0===r||null===(n=r.query)||void 0===n?void 0:n[e]}))};function Se(){return!!ke()&&Ce("inherit")}function Ae(){return!ke()&&Ce("filterable")}const Ie=e=>({...e,orderBy:F.orderBy,order:F.order,inherit:Se(),filterable:Ae()}),Re=()=>q.displayLayout,Te=(e,t,o)=>{const c=ee(e);c&&o(t,c.name===b.PRODUCT_CATALOG?(0,r.createBlock)(n.name,{...q,query:{...q.query,inherit:Se(),filterable:Ae()}},(0,r.createBlocksFromInnerBlocksTemplate)(H)):(0,r.createBlock)(n.name,c.attributes,(0,r.createBlocksFromInnerBlocksTemplate)(c.innerBlocks)))},Pe=({title:e,icon:t,description:o,onClick:r})=>(0,c.createElement)(w.Tooltip,{text:o,placement:"top"},(0,c.createElement)(w.Button,{className:"wc-blocks-product-collection__collection-button",onClick:r},(0,c.createElement)("div",{className:"wc-blocks-product-collection__collection-button-icon"},(0,c.createElement)(w.Icon,{icon:t})),(0,c.createElement)("p",{className:"wc-blocks-product-collection__collection-button-title"},e))),xe=e=>{const{description:t,onClick:o}=e;return(0,c.createElement)("div",{className:"wc-blocks-product-collection__collections-create"},(0,c.createElement)("span",null,(0,f.__)("or","woocommerce")),(0,c.createElement)(w.Tooltip,{text:t,placement:"top"},(0,c.createElement)(w.Button,{onClick:o},(0,f.__)("create your own","woocommerce"))))},Ne=e=>{const{onCollectionClick:t,catalogVariation:o,collectionVariations:r}=e;return(0,c.createElement)("div",{className:"wc-blocks-product-collection__collections-grid"},(0,c.createElement)("div",{className:"wc-blocks-product-collection__collections-section"},r.map((({name:e,title:o,icon:r,description:n})=>(0,c.createElement)(Pe,{key:e,title:o,description:n,icon:r,onClick:()=>t(e)})))),(0,c.createElement)(xe,{title:o.title,description:o.description,icon:o.icon,onClick:()=>t(o.name)}))},Oe=e=>{const{onCollectionClick:t,catalogVariation:o,collectionVariations:r}=e;return(0,c.createElement)("div",{className:"wc-blocks-product-collection__collections-dropdown"},(0,c.createElement)(w.Dropdown,{className:"wc-blocks-product-collection__collections-dropdown-toggle",contentClassName:"wc-blocks-product-collection__collections-dropdown-content",renderToggle:({isOpen:e,onToggle:t})=>(0,c.createElement)(w.Button,{variant:"secondary",onClick:t,"aria-expanded":e},(0,f.__)("Choose collection","woocommerce")),renderContent:()=>(0,c.createElement)(c.Fragment,null,r.map((({name:e,title:o,icon:r,description:n})=>(0,c.createElement)(Pe,{key:e,title:o,description:n,icon:r,onClick:()=>t(e)}))))}),(0,c.createElement)(xe,{title:o.title,description:o.description,icon:o.icon,onClick:()=>t(o.name)}))},Le=e=>{const t=(0,s.useSelect)((e=>{const{getBlockVariations:t}=e(r.store);return t(n.name)}),[]),o=(0,a.useMemo)((()=>t.find((({name:e})=>e===b.PRODUCT_CATALOG))),[t]),l=(0,a.useMemo)((()=>t.filter((({name:e})=>e!==b.PRODUCT_CATALOG))),[t]),[i,{width:u}]=(0,I.useResizeObserver)();let m;return m=null!==u&&u>=600?Ne:Oe,(0,c.createElement)(c.Fragment,null,i,!!u&&(0,c.createElement)(m,{...e,catalogVariation:o,collectionVariations:l}))},De=window.wp.editor;var Be=function(e){return e.SINGLE_PRODUCT="single-product",e.PRODUCT_CATALOG="product-catalog",e.PRODUCT_ARCHIVE="product-archive",e.ORDER_CONFIRMATION="order-confirmation",e.CART="cart",e.CHECKOUT="checkout",e.POST="post",e.PAGE="page",e.OTHER="other",e}(Be||{});const Fe={"single-product":Be.SINGLE_PRODUCT,"archive-product":Be.PRODUCT_CATALOG,"taxonomy-product_cat":Be.PRODUCT_ARCHIVE,"taxonomy-product_tag":Be.PRODUCT_ARCHIVE,"taxonomy-product_attribute":Be.PRODUCT_ARCHIVE,"product-search-results":Be.PRODUCT_ARCHIVE,"order-confirmation":Be.ORDER_CONFIRMATION,"page-cart":Be.CART,"page-checkout":Be.CHECKOUT},qe=e=>{const t=(0,s.useSelect)((e=>e(De.store).getCurrentPostType()),[]);if(t===Be.PAGE||t===Be.POST)return t;if(!e)return Be.OTHER;return Fe[e]||(e.includes("single-product")?Be.SINGLE_PRODUCT:e.includes("taxonomy-product_cat")||e.includes("taxonomy-product_tag")?Be.PRODUCT_ARCHIVE:Be.OTHER)},Ve=e=>{const t=(0,l.useBlockProps)(),{clientId:o,context:r}=e,{replaceBlock:n}=(0,s.useDispatch)(l.store),a=qe(r.templateSlug);return(0,c.createElement)("div",{...t},(0,c.createElement)(w.Placeholder,{className:"wc-blocks-product-collection__placeholder",instructions:(0,f.__)("What products do you want to show?","woocommerce")},(0,c.createElement)(Le,{onCollectionClick:e=>{A("blocks_product_collection_collection_chosen_from_placeholder",{collection:e,location:a}),Te(e,o,n)}})))};var Me=o(458),$e=o.n(Me),He=o(361),Ue=o(4133);o(1598);const Ge=({text:e,title:t=(0,f.__)("Feedback?","woocommerce"),url:o})=>{const[r,n]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{n(!0)}),[]),(0,c.createElement)(c.Fragment,null,r&&(0,c.createElement)("div",{className:"wc-block-feedback-prompt"},(0,c.createElement)(T.A,{icon:He.A}),(0,c.createElement)("h2",{className:"wc-block-feedback-prompt__title"},t),(0,c.createElement)("p",{className:"wc-block-feedback-prompt__text"},e),(0,c.createElement)("a",{href:o,className:"wc-block-feedback-prompt__link",rel:"noreferrer noopener",target:"_blank"},(0,f.__)("Give us your feedback.","woocommerce"),(0,c.createElement)(T.A,{icon:Ue.A,size:16}))))},je=()=>(0,c.createElement)(Ge,{text:(0,f.__)("Thanks for trying out the Product Collection block! Help us make it better by sharing your feedback.","woocommerce"),title:(0,f.__)("Share your feedback!","woocommerce"),url:"https://airtable.com/shrqsMSDPvAKoY99u"}),Ke="wc-blocks_upgraded-products-to-product-collection",Qe=()=>({status:"notseen",time:Date.now(),displayCount:0}),We=window.wc.wcTypes,ze=e=>"woocommerce/product-collection"===e.name&&e.attributes.convertedFromProducts,Ye=(e,t)=>{let o=[];return e.forEach((e=>{t(e)&&(o=[...o,e.clientId]),o=[...o,...Ye(e.innerBlocks,t)]})),o},Je=(0,x.getSettingWithCoercion)("postTemplateHasSupportForGridView",!1,We.isBoolean),Ze=()=>{const e=window.localStorage.getItem(Ke);return e?JSON.parse(e):Qe()},Xe=e=>{window.localStorage.setItem(Ke,JSON.stringify(e))},et=e=>"flex"===e?"grid":"list"===e?"default":"grid",tt=e=>{const{type:t,columns:o}=e;return{type:et(t),columnCount:o}},ot=(e,t)=>{const o=e.map((e=>{const{name:o,attributes:n}=e,c=ot(e.innerBlocks);return(({name:e})=>"woocommerce/product-template"===e)(e)?((e,t,o)=>(0,r.createBlock)("core/post-template",{className:"products-block-post-template",layout:Je?tt(o):void 0,__woocommerceNamespace:"woocommerce/product-query/product-template",...e.attributes},t))(e,c,t):(({name:e,attributes:t})=>"core/post-title"===e&&"woocommerce/product-collection/product-title"===t.__woocommerceNamespace)(e)?((e,t)=>{const{__woocommerceNamespace:o,...n}=e.attributes;return(0,r.createBlock)("core/post-title",{__woocommerceNamespace:"woocommerce/product-collection/product-title",...n},t)})(e,c):(({name:e,attributes:t})=>"core/post-excerpt"===e&&"woocommerce/product-collection/product-summary"===t.__woocommerceNamespace)(e)?((e,t)=>{const{__woocommerceNamespace:o,...n}=e.attributes;return(0,r.createBlock)("core/post-excerpt",{__woocommerceNamespace:"woocommerce/product-collection/product-summary",...n},t)})(e,c):(0,r.createBlock)(o,n,c)}));return o},rt=e=>{const t=(0,s.select)("core/block-editor").getBlock(e),o=((e,t)=>{const o=(0,s.select)("core/block-editor").getBlockRootClientId(e)||void 0;return(0,s.select)("core/block-editor").canInsertBlockType("core/query",o)})(e);if(t&&o){const{attributes:o={},innerBlocks:n=[]}=t,{displayLayout:c,...l}=o,a=(e=>{const{query:t,...o}=e,{woocommerceAttributes:r,woocommerceStockStatus:n,woocommerceOnSale:c,woocommerceHandPickedProducts:l,taxQuery:a,isProductCollectionBlock:s,...i}=t,u={...i};return l&&(u.include=l),c&&(u.__woocommerceOnSale=c),a&&(u.taxQuery=a),{...o,namespace:"woocommerce/product-query",query:{__woocommerceAttributes:r||[],__woocommerceStockStatus:n||[],...u}}})(Je?l:o),i=ot(n,c),u=(0,r.createBlock)("core/query",a,i);return(0,s.dispatch)("core/block-editor").replaceBlock(e,u),!0}return!1},nt=()=>{var e;Xe({status:"reverted",time:Date.now()}),(e=(0,s.select)("core/block-editor").getBlocks(),Ye(e,ze)).map(rt)},ct=(0,a.createInterpolateElement)((0,f.__)("Products (Beta) block was upgraded to <strongText />, an updated version with new features and simplified settings.","woocommerce"),{strongText:(0,c.createElement)("strong",null,(0,f.__)("Product Collection","woocommerce"))}),lt=(0,f.__)("Revert to Products (Beta)","woocommerce"),at=({revertMigration:e})=>{const[t,o]=((e,t)=>{const[o,r]=(0,a.useState)((()=>{const o=window.localStorage.getItem(e);if(o)try{return JSON.parse(o)}catch{console.error(`Value for key '${e}' could not be retrieved from localStorage because it can't be parsed.`)}return t}));return(0,a.useEffect)((()=>{try{window.localStorage.setItem(e,JSON.stringify(o))}catch{console.error(`Value for key '${e}' could not be saved in localStorage because it can't be converted into a string.`)}}),[e,o]),[o,r]})(Ke,Qe()),r=(0,a.useRef)(!0),{status:n}=t;return(0,a.useEffect)((()=>()=>{r.current&&((()=>{const e=Ze(),t=(0,We.isNumber)(e.displayCount)?e.displayCount+1:0;Xe({...e,displayCount:t})})(),r.current=!1)}),[r]),"notseen"===n?(0,c.createElement)(w.Notice,{onRemove:()=>{o({status:"seen",time:Date.now()})}},(0,c.createElement)(c.Fragment,null,ct," "),(0,c.createElement)("br",null),(0,c.createElement)("br",null),(0,c.createElement)(w.Button,{variant:"link",onClick:()=>{e()}},lt)):null},st=(0,f.__)("Columns","woocommerce"),it=(0,f.__)("Responsive","woocommerce"),ut=(0,f.__)("Automatically adjust the number of columns to better fit smaller screens.","woocommerce"),mt=e=>{const{type:t,columns:o,shrinkColumns:r}=e.displayLayout,n="flex"===t,l=Re(),a=()=>{e.setAttributes({displayLayout:l})};return n?(0,c.createElement)(c.Fragment,null,(0,c.createElement)(w.__experimentalToolsPanelItem,{label:st,hasValue:()=>(null==l?void 0:l.columns)!==o,isShownByDefault:!0,onDeselect:a},(0,c.createElement)(w.RangeControl,{label:st,onChange:t=>e.setAttributes({displayLayout:{...e.displayLayout,columns:t}}),value:o,min:2,max:Math.max(6,o)})),(0,c.createElement)(w.__experimentalToolsPanelItem,{label:it,hasValue:()=>(null==l?void 0:l.shrinkColumns)!==r,isShownByDefault:!0,onDeselect:a},(0,c.createElement)(w.ToggleControl,{checked:!!r,label:it,help:ut,onChange:t=>{e.setAttributes({displayLayout:{...e.displayLayout,shrinkColumns:t}})}}))):null},dt=(0,f.__)("Sync with current query","woocommerce"),pt=(0,f.__)("Enable to adjust the displayed products based on the current template and any applied filters.","woocommerce"),_t=(0,f.__)("Enable to adjust the displayed products based on the current category and any applied filters.","woocommerce"),gt=(0,f.__)("Enable to adjust the displayed products based on the current tag and any applied filters.","woocommerce"),wt=(0,f.__)("Enable to adjust the displayed products based on the current attribute and any applied filters.","woocommerce"),Et=(0,f.__)("Enable to adjust the displayed products based on the current search and any applied filters.","woocommerce"),ht=(0,f.__)("Adjust the displayed products depending on the current template and any applied query filters.","woocommerce"),vt=({setQueryAttribute:e,trackInteraction:t,query:o})=>{const r=null==o?void 0:o.inherit,n=(0,s.select)("core/edit-site"),l=function(e,t){const o=(0,a.useRef)();return(0,a.useEffect)((()=>{o.current===e||t&&!t(e,o.current)||(o.current=e)}),[e,t]),o.current}(o,(e=>!1===(null==e?void 0:e.inherit))),i=(0,a.useMemo)((()=>Se()),[]),u=(m=n.getEditedPostId()).includes("//taxonomy-product_cat")?_t:m.includes("//taxonomy-product_tag")?gt:m.includes("//taxonomy-product_attribute")?wt:m.includes("//product-search-results")?Et:pt;var m;return(0,c.createElement)(w.__experimentalToolsPanelItem,{label:dt,hasValue:()=>r!==i,isShownByDefault:!0,onDeselect:()=>{e({inherit:i}),t(y.INHERIT)}},(0,c.createElement)(w.ToggleControl,{className:"wc-block-product-collection__inherit-query-control",label:dt,help:u,checked:!!r,onChange:o=>{e(o?{...F,inherit:o}:{...F,...l,inherit:o}),t(y.INHERIT)}}))},bt=({setQueryAttribute:e,trackInteraction:t,query:o})=>{const r=null==o?void 0:o.filterable,n=(0,a.useMemo)((()=>Ae()),[]);return(0,c.createElement)(w.__experimentalToolsPanelItem,{label:dt,hasValue:()=>r!==n,isShownByDefault:!0,onDeselect:()=>{e({filterable:n}),t(y.FILTERABLE)}},(0,c.createElement)(w.ToggleControl,{className:"wc-block-product-collection__inherit-query-control",label:dt,help:ht,checked:!!r,onChange:o=>{e({filterable:o}),t(y.FILTERABLE)}}))},yt=[{label:(0,f.__)("A → Z","woocommerce"),value:"title/asc"},{label:(0,f.__)("Z → A","woocommerce"),value:"title/desc"},{label:(0,f.__)("Newest to oldest","woocommerce"),value:"date/desc"},{label:(0,f.__)("Oldest to newest","woocommerce"),value:"date/asc"},{value:"popularity/desc",label:(0,f.__)("Best Selling","woocommerce")},{value:"rating/desc",label:(0,f.__)("Top Rated","woocommerce")}],ft=e=>{const{query:t,trackInteraction:o,setQueryAttribute:r}=e,{order:n,orderBy:l}=t,a=Ie(t),s=()=>{r({orderBy:a.orderBy}),o(y.ORDER)};return(0,c.createElement)(w.__experimentalToolsPanelItem,{label:(0,f.__)("Order by","woocommerce"),hasValue:()=>n!==(null==a?void 0:a.order)||l!==(null==a?void 0:a.orderBy),isShownByDefault:!0,onDeselect:s,resetAllFilter:s},(0,c.createElement)(w.SelectControl,{value:`${l}/${n}`,options:yt,label:(0,f.__)("Order by","woocommerce"),onChange:e=>{const[t,n]=e.split("/");r({order:n,orderBy:t}),o(y.ORDER)}}))},kt=e=>{const{query:t,trackInteraction:o,setQueryAttribute:r}=e,n=()=>{r({woocommerceOnSale:V.woocommerceOnSale}),o(y.ON_SALE)};return(0,c.createElement)(w.__experimentalToolsPanelItem,{label:(0,f.__)("On Sale","woocommerce"),hasValue:()=>!0===t.woocommerceOnSale,isShownByDefault:!0,onDeselect:n,resetAllFilter:n},(0,c.createElement)(w.ToggleControl,{label:(0,f.__)("Show only products on sale","woocommerce"),checked:t.woocommerceOnSale||!1,onChange:e=>{r({woocommerceOnSale:e}),o(y.ON_SALE)}}))};function Ct(e){var t;const o="string"==typeof e?e:e.value;return null===(t=Object.entries(L).find((([,e])=>e===o)))||void 0===t?void 0:t[0]}const St=e=>{var t;const{query:o,trackInteraction:r,setQueryAttribute:n}=e,l=()=>{n({woocommerceStockStatus:V.woocommerceStockStatus}),r(y.STOCK_STATUS)};return(0,c.createElement)(w.__experimentalToolsPanelItem,{label:(0,f.__)("Stock status","woocommerce"),hasValue:()=>!$e()(o.woocommerceStockStatus,B()),onDeselect:l,resetAllFilter:l,isShownByDefault:!0},(0,c.createElement)(w.FormTokenField,{label:(0,f.__)("Stock status","woocommerce"),onChange:e=>{const t=e.map(Ct).filter(Boolean);n({woocommerceStockStatus:t}),r(y.STOCK_STATUS)},suggestions:Object.values(L),validateInput:e=>Object.values(L).includes(e),value:(null==o||null===(t=o.woocommerceStockStatus)||void 0===t?void 0:t.map((e=>L[e])))||[],__experimentalExpandOnFocus:!0,__experimentalShowHowTo:!1}))},At=e=>{const{query:t,trackInteraction:o,setQueryAttribute:r}=e,[n,l]=(0,a.useState)(t.search),s=(0,I.useDebounce)((()=>{t.search!==n&&(r({search:n}),o(y.KEYWORD))}),250);(0,a.useEffect)((()=>(s(),s.cancel)),[n,s]);const i=()=>{l(""),o(y.KEYWORD)};return(0,c.createElement)(w.__experimentalToolsPanelItem,{hasValue:()=>!!n,label:(0,f.__)("Keyword","woocommerce"),onDeselect:i,resetAllFilter:i},(0,c.createElement)(w.TextControl,{label:(0,f.__)("Keyword","woocommerce"),value:n,onChange:l}))};var It=o(851);function Rt(e,t,o){const r=new Set(t.map((e=>e[o])));return e.filter((e=>!r.has(e[o])))}const Tt=window.wp.htmlEntities,Pt={clear:(0,f.__)("Clear all selected items","woocommerce"),noItems:(0,f.__)("No items found.","woocommerce"), /* Translators: %s search term */ noResults:(0,f.__)("No results for %s","woocommerce"),search:(0,f.__)("Search for items","woocommerce"),selected:e=>(0,f.sprintf)(/* translators: Number of items selected from list. */ /* translators: Number of items selected from list. */ (0,f._n)("%d item selected","%d items selected",e,"woocommerce"),e),updated:(0,f.__)("Search results updated.","woocommerce")},xt=(e,t=e)=>{const o=e.reduce(((e,t)=>{const o=t.parent||0;return e[o]||(e[o]=[]),e[o].push(t),e}),{}),r=("id",t.reduce(((e,t)=>(e[String(t.id)]=t,e)),{}));const n=["0"],c=(e={})=>e.parent?[...c(r[e.parent]),e.name]:e.name?[e.name]:[],l=e=>e.map((e=>{const t=o[e.id];return n.push(""+e.id),{...e,breadcrumbs:c(r[e.parent]),children:t&&t.length?l(t):[]}})),a=l(o[0]||[]);return Object.entries(o).forEach((([e,t])=>{n.includes(e)||a.push(...l(t||[]))})),a},Nt=(e,t)=>{if(!t)return e;const o=new RegExp(`(${t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")})`,"ig");return e.split(o).map(((e,t)=>o.test(e)?(0,c.createElement)("strong",{key:t},e):(0,c.createElement)(a.Fragment,{key:t},e)))},Ot=({label:e})=>(0,c.createElement)("span",{className:"woocommerce-search-list__item-count"},e),Lt=e=>{const{item:t,search:o}=e,r=t.breadcrumbs&&t.breadcrumbs.length;return(0,c.createElement)("span",{className:"woocommerce-search-list__item-label"},r?(0,c.createElement)("span",{className:"woocommerce-search-list__item-prefix"},1===(n=t.breadcrumbs).length?n.slice(0,1).toString():2===n.length?n.slice(0,1).toString()+" › "+n.slice(-1).toString():n.slice(0,1).toString()+" … "+n.slice(-1).toString()):null,(0,c.createElement)("span",{className:"woocommerce-search-list__item-name"},Nt((0,Tt.decodeEntities)(t.name),o)));var n},Dt=({countLabel:e,className:t,depth:o=0,controlId:r="",item:n,isSelected:l,isSingle:s,onSelect:i,search:u="",selected:m,useExpandedPanelId:d,...p})=>{var _,g;const[E,h]=d,v=null!=e&&void 0!==n.count&&null!==n.count,b=!(null===(_=n.breadcrumbs)||void 0===_||!_.length),y=!(null===(g=n.children)||void 0===g||!g.length),f=E===n.id,k=(0,It.A)(["woocommerce-search-list__item",`depth-${o}`,t],{"has-breadcrumbs":b,"has-children":y,"has-count":v,"is-expanded":f,"is-radio-button":s});(0,a.useEffect)((()=>{y&&l&&h(n.id)}),[n,y,l,h]);const C=p.name||`search-list-item-${r}`,S=`${C}-${n.id}`,A=(0,a.useCallback)((()=>{h(f?-1:Number(n.id))}),[f,n.id,h]);return y?(0,c.createElement)("div",{className:k,onClick:A,onKeyDown:e=>"Enter"===e.key||" "===e.key?A():null,role:"treeitem",tabIndex:0},s?(0,c.createElement)(c.Fragment,null,(0,c.createElement)("input",{type:"radio",id:S,name:C,value:n.value,onChange:i(n),onClick:e=>e.stopPropagation(),checked:l,className:"woocommerce-search-list__item-input",...p}),(0,c.createElement)(Lt,{item:n,search:u}),v?(0,c.createElement)(Ot,{label:e||n.count}):null):(0,c.createElement)(c.Fragment,null,(0,c.createElement)(w.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:l,...!l&&n.children.some((e=>m.find((t=>t.id===e.id))))?{indeterminate:!0}:{},label:Nt((0,Tt.decodeEntities)(n.name),u),onChange:()=>{l?i(Rt(m,n.children,"id"))():i(function(e,t,o){const r=Rt(t,e,"id");return[...e,...r]}(m,n.children))()},onClick:e=>e.stopPropagation()}),v?(0,c.createElement)(Ot,{label:e||n.count}):null)):(0,c.createElement)("label",{htmlFor:S,className:k},s?(0,c.createElement)(c.Fragment,null,(0,c.createElement)("input",{...p,type:"radio",id:S,name:C,value:n.value,onChange:i(n),checked:l,className:"woocommerce-search-list__item-input"}),(0,c.createElement)(Lt,{item:n,search:u})):(0,c.createElement)(w.CheckboxControl,{...p,id:S,name:C,className:"woocommerce-search-list__item-input",value:(0,Tt.decodeEntities)(n.value),label:Nt((0,Tt.decodeEntities)(n.name),u),onChange:i(n),checked:l}),v?(0,c.createElement)(Ot,{label:e||n.count}):null)},Bt=Dt;var Ft=o(2478),qt=o(2370);o(6636);const Vt=({id:e,label:t,popoverContents:o,remove:r,screenReaderLabel:n,className:l=""})=>{const[s,i]=(0,a.useState)(!1),u=(0,I.useInstanceId)(Vt);if(n=n||t,!t)return null;t=(0,Tt.decodeEntities)(t);const m=(0,It.A)("woocommerce-tag",l,{"has-remove":!!r}),d=`woocommerce-tag__label-${u}`,p=(0,c.createElement)(c.Fragment,null,(0,c.createElement)("span",{className:"screen-reader-text"},n),(0,c.createElement)("span",{"aria-hidden":"true"},t));return(0,c.createElement)("span",{className:m},o?(0,c.createElement)(w.Button,{className:"woocommerce-tag__text",id:d,onClick:()=>i(!0)},p):(0,c.createElement)("span",{className:"woocommerce-tag__text",id:d},p),o&&s&&(0,c.createElement)(w.Popover,{onClose:()=>i(!1)},o),r&&(0,c.createElement)(w.Button,{className:"woocommerce-tag__remove",onClick:r(e),label:(0,f.sprintf)( // Translators: %s label. // Translators: %s label. (0,f.__)("Remove %s","woocommerce"),t),"aria-describedby":d},(0,c.createElement)(T.A,{icon:qt.A,size:20,className:"clear-icon",role:"img"})))},Mt=Vt;o(8137);const $t=e=>(0,c.createElement)(Bt,{...e}),Ht=e=>{const{list:t,selected:o,renderItem:r,depth:n=0,onSelect:l,instanceId:s,isSingle:i,search:u,useExpandedPanelId:m}=e,[d]=m;return t?(0,c.createElement)(a.Fragment,null,t.map((t=>{var p,_;const g=null!==(p=t.children)&&void 0!==p&&p.length&&!i?t.children.every((({id:e})=>o.find((t=>t.id===e)))):!!o.find((({id:e})=>e===t.id)),w=(null===(_=t.children)||void 0===_?void 0:_.length)&&d===t.id;return(0,c.createElement)(a.Fragment,{key:t.id},(0,c.createElement)("li",null,r({item:t,isSelected:g,onSelect:l,isSingle:i,selected:o,search:u,depth:n,useExpandedPanelId:m,controlId:s})),w?(0,c.createElement)(Ht,{...e,list:t.children,depth:n+1}):null)}))):null},Ut=({isLoading:e,isSingle:t,selected:o,messages:r,onChange:n,onRemove:l})=>{if(e||t||!o)return null;const a=o.length;return(0,c.createElement)("div",{className:"woocommerce-search-list__selected"},(0,c.createElement)("div",{className:"woocommerce-search-list__selected-header"},(0,c.createElement)("strong",null,r.selected(a)),a>0?(0,c.createElement)(w.Button,{variant:"link",isDestructive:!0,onClick:()=>n([]),"aria-label":r.clear},(0,f.__)("Clear all","woocommerce")):null),a>0?(0,c.createElement)("ul",null,o.map(((e,t)=>(0,c.createElement)("li",{key:t},(0,c.createElement)(Mt,{label:e.name,id:e.id,remove:l}))))):null)},Gt=({filteredList:e,search:t,onSelect:o,instanceId:r,useExpandedPanelId:n,...l})=>{const{messages:a,renderItem:s,selected:i,isSingle:u}=l,m=s||$t;return 0===e.length?(0,c.createElement)("div",{className:"woocommerce-search-list__list is-not-found"},(0,c.createElement)("span",{className:"woocommerce-search-list__not-found-icon"},(0,c.createElement)(T.A,{icon:Ft.A,role:"img"})),(0,c.createElement)("span",{className:"woocommerce-search-list__not-found-text"},t?(0,f.sprintf)(a.noResults,t):a.noItems)):(0,c.createElement)("ul",{className:"woocommerce-search-list__list"},(0,c.createElement)(Ht,{useExpandedPanelId:n,list:e,selected:i,renderItem:m,onSelect:o,instanceId:r,isSingle:u,search:t}))},jt=e=>{const{className:t="",isCompact:o,isHierarchical:r,isLoading:n,isSingle:l,list:s,messages:i=Pt,onChange:u,onSearch:m,selected:d,type:p="text",debouncedSpeak:_}=e,[g,E]=(0,a.useState)(""),h=(0,a.useState)(-1),v=(0,I.useInstanceId)(jt),b=(0,a.useMemo)((()=>({...Pt,...i})),[i]),y=(0,a.useMemo)((()=>((e,t,o)=>{if(!t)return o?xt(e):e;const r=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),n=e.map((e=>!!r.test(e.name)&&e)).filter(Boolean);return o?xt(n,e):n})(s,g,r)),[s,g,r]);(0,a.useEffect)((()=>{_&&_(b.updated)}),[_,b]),(0,a.useEffect)((()=>{"function"==typeof m&&m(g)}),[g,m]);const k=(0,a.useCallback)((e=>()=>{l&&u([]);const t=d.findIndex((({id:t})=>t===e));u([...d.slice(0,t),...d.slice(t+1)])}),[l,d,u]),C=(0,a.useCallback)((e=>()=>{Array.isArray(e)?u(e):-1===d.findIndex((({id:t})=>t===e.id))?u(l?[e]:[...d,e]):k(e.id)()}),[l,k,u,d]),S=(0,a.useCallback)((e=>{const[t]=d.filter((t=>!e.find((e=>t.id===e.id))));k(t.id)()}),[k,d]);return(0,c.createElement)("div",{className:(0,It.A)("woocommerce-search-list",t,{"is-compact":o,"is-loading":n,"is-token":"token"===p})},"text"===p&&(0,c.createElement)(Ut,{...e,onRemove:k,messages:b}),(0,c.createElement)("div",{className:"woocommerce-search-list__search"},"text"===p?(0,c.createElement)(w.TextControl,{label:b.search,type:"search",value:g,onChange:e=>E(e)}):(0,c.createElement)(w.FormTokenField,{disabled:n,label:b.search,onChange:S,onInputChange:e=>E(e),suggestions:[],__experimentalValidateInput:()=>!1,value:n?[(0,f.__)("Loading…","woocommerce")]:d.map((e=>({...e,value:e.name}))),__experimentalShowHowTo:!1})),n?(0,c.createElement)("div",{className:"woocommerce-search-list__list"},(0,c.createElement)(w.Spinner,null)):(0,c.createElement)(Gt,{...e,search:g,filteredList:y,messages:b,onSelect:C,instanceId:v,useExpandedPanelId:h}))},Kt=((0,w.withSpokenMessages)(jt),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"}}});const Qt=window.wp.escapeHtml,Wt=({error:e})=>(0,c.createElement)("div",{className:"wc-block-error-message"},(({message:e,type:t})=>e?"general"===t?(0,c.createElement)("span",null,(0,f.__)("The following error was returned","woocommerce"),(0,c.createElement)("br",null),(0,c.createElement)("code",null,(0,Qt.escapeHTML)(e))):"api"===t?(0,c.createElement)("span",null,(0,f.__)("The following error was returned from the API","woocommerce"),(0,c.createElement)("br",null),(0,c.createElement)("code",null,(0,Qt.escapeHTML)(e))):e:(0,f.__)("An error has prevented the block from being updated.","woocommerce"))(e)),zt=({className:e,item:t,isSelected:o,isLoading:r,onSelect:n,disabled:l,...a})=>(0,c.createElement)(c.Fragment,null,(0,c.createElement)(Dt,{...a,key:t.id,className:e,isSelected:o,item:t,onSelect:n,disabled:l}),o&&r&&(0,c.createElement)("div",{key:"loading",className:(0,It.A)("woocommerce-search-list__item","woocommerce-product-attributes__item","depth-1","is-loading","is-not-active")},(0,c.createElement)(w.Spinner,null))),Yt=((0,x.getSetting)("attributes",[]).reduce(((e,t)=>{const o=(r=t)&&r.attribute_name?{id:parseInt(r.attribute_id,10),name:r.attribute_name,taxonomy:"pa_"+r.attribute_name,label:r.attribute_label,orderby:r.attribute_orderby}:null;var r;return o&&o.id&&e.push(o),e}),[]),e=>{const{count:t,id:o,name:r,parent:n}=e;return{count:t,id:o,name:r,parent:n,breadcrumbs:[],children:[],value:(0,We.isAttributeTerm)(e)?e.attr_slug:""}});o(2777);const Jt=(0,I.withInstanceId)((({onChange:e,onOperatorChange:t,instanceId:o,isCompact:r=!1,messages:n={},operator:l="any",selected:s,type:i="text"})=>{const{errorLoadingAttributes:u,isLoadingAttributes:m,productsAttributes:d}=function(e){const[t,o]=(0,a.useState)(null),[r,n]=(0,a.useState)(!1),[c,l]=(0,a.useState)([]),s=(0,a.useRef)(!1);return(0,a.useEffect)((()=>{if(e&&!r&&!s.current)return async function(){n(!0);try{const e=await _e()({path:"wc/store/v1/products/attributes"}),t=[];for(const o of e){const e=await ye(o.id);t.push({...o,parent:0,terms:e.map((e=>({...e,attr_slug:o.taxonomy,parent:o.id})))})}l(t),s.current=!0}catch(e){e instanceof Error&&o(await Kt(e))}finally{n(!1)}}(),()=>{s.current=!0}}),[r,e]),{errorLoadingAttributes:t,isLoadingAttributes:r,productsAttributes:c}}(!0),p=d.reduce(((e,t)=>{const{terms:o,...r}=t;return[...e,Yt(r),...o.map(Yt)]}),[]);return n={clear:(0,f.__)("Clear all product attributes","woocommerce"),noItems:(0,f.__)("Your store doesn't have any product attributes.","woocommerce"),search:(0,f.__)("Search for product attributes","woocommerce"),selected:e=>(0,f.sprintf)(/* translators: %d is the count of attributes selected. */ /* translators: %d is the count of attributes selected. */ (0,f._n)("%d attribute selected","%d attributes selected",e,"woocommerce"),e),updated:(0,f.__)("Product attribute search results updated.","woocommerce"),...n},u?(0,c.createElement)(Wt,{error:u}):(0,c.createElement)(c.Fragment,null,(0,c.createElement)(jt,{className:"woocommerce-product-attributes",isCompact:r,isHierarchical:!0,isLoading:m,isSingle:!1,list:p,messages:n,onChange:e,renderItem:e=>{const{item:t,search:r,depth:n=0}=e,l=t.count||0,a=["woocommerce-product-attributes__item","woocommerce-search-list__item",{"is-searching":r.length>0,"is-skip-level":0===n&&0!==t.parent}];if(!t.breadcrumbs.length)return(0,c.createElement)(zt,{...e,className:(0,It.A)(a),item:t,isLoading:m,disabled:0===t.count,name:`attributes-${o}`,countLabel:(0,f.sprintf)(/* translators: %d is the count of terms. */ /* translators: %d is the count of terms. */ (0,f._n)("%d term","%d terms",l,"woocommerce"),l),"aria-label":(0,f.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,f._n)("%1$s, has %2$d term","%1$s, has %2$d terms",l,"woocommerce"),t.name,l)});const s=`${t.breadcrumbs[0]}: ${t.name}`;return(0,c.createElement)(Dt,{...e,name:`terms-${o}`,className:(0,It.A)(...a,"has-count"),countLabel:(0,f.sprintf)(/* translators: %d is the count of products. */ /* translators: %d is the count of products. */ (0,f._n)("%d product","%d products",l,"woocommerce"),l),"aria-label":(0,f.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,f._n)("%1$s, has %2$d product","%1$s, has %2$d products",l,"woocommerce"),s,l)})},selected:s.map((({id:e})=>p.find((t=>t.id===e)))).filter(Boolean),type:i}),!!t&&(0,c.createElement)("div",{hidden:s.length<2},(0,c.createElement)(w.SelectControl,{className:"woocommerce-product-attributes__operator",label:(0,f.__)("Display products matching","woocommerce"),help:(0,f.__)("Pick at least two attributes to use this setting.","woocommerce"),value:l,onChange:t,options:[{label:(0,f.__)("Any selected attributes","woocommerce"),value:"any"},{label:(0,f.__)("All selected attributes","woocommerce"),value:"all"}]})))})),Zt=`${x.ADMIN_URL}edit.php?post_type=product&page=product_attributes`,Xt=({query:e,trackInteraction:t,setQueryAttribute:o})=>{const r=e.woocommerceAttributes||[],n=null==r?void 0:r.map((({termId:e})=>({id:e}))),l=()=>{o({woocommerceAttributes:V.woocommerceAttributes}),t(y.ATTRIBUTES)};return(0,c.createElement)(w.__experimentalToolsPanelItem,{label:(0,f.__)("Product Attributes","woocommerce"),hasValue:()=>!(null==r||!r.length),onDeselect:l,resetAllFilter:l},(0,c.createElement)(Jt,{messages:{search:(0,f.__)("Attributes","woocommerce")},selected:n||[],onChange:e=>{const r=e.map((({id:e,value:t})=>({termId:e,taxonomy:t})));o({woocommerceAttributes:r}),t(y.ATTRIBUTES)},operator:"any",isCompact:!0,type:"token"}),(0,c.createElement)(w.ExternalLink,{className:"wc-block-editor-product-collection-panel__manage-attributes-link",href:Zt},(0,f.__)("Manage attributes","woocommerce")))},eo={_fields:"id,name",order:"asc",orderby:"name",context:"view"},to=e=>{var t;const o=e.match(/^(?:(.+) )?\(#(\d+)\)$/);return!!o&&{name:null!==(t=o[1])&&void 0!==t?t:"",id:parseInt(o[2],10)}},oo=({taxonomy:e,termIds:t,onChange:o})=>{const{existingTerms:r,isLoadingExistingTerms:n}=(0,s.useSelect)((o=>{if(!t||!t.length)return{existingTerms:[],isLoadingExistingTerms:!1};const{getEntityRecords:r,hasFinishedResolution:n}=o("core"),c=["taxonomy",e.slug,{...eo,include:t}];return{existingTerms:r(...c),isLoadingExistingTerms:!n("getEntityRecords",c)}}),[e,t]),[l,i]=(0,a.useState)(""),{searchTerms:u}=(0,s.useSelect)((o=>{if(l.length<=1)return{searchTerms:[]};const{getEntityRecords:r}=o("core");return{searchTerms:r("taxonomy",e.slug,{...eo,exclude:t,search:l})}}),[e,t,l]),m=(0,I.useDebounce)(i,250),d=new Set,p=new Set,_=e=>(d.has(e.name)&&p.add(e.name),d.add(e.name),(e=>`${e.name} (#${e.id})`)(e)),g=r?r.map(_):[],E=u?u.map(_):[];if(r&&t.length!==r.length){const e=r.reduce(((e,t)=>(e[t.id]=t,e)),{});t.forEach((t=>{e[t]||g.push(`(#${t})`)}))}return(0,c.createElement)("div",{className:"wc-block-editor-product-collection-inspector__taxonomy-control"},(0,c.createElement)(w.FormTokenField,{label:e.name,value:g,onInputChange:m,onChange:e=>{const t=[];e.forEach((e=>{const o=to(e);o&&t.push(o.id)})),o(t)},suggestions:E,disabled:n,displayTransform:e=>{const t=to(e);return t&&(e=t.name?p.has(t.name)?`${t.name} (#${t.id})`:t.name:`(#${t.id} ${(0,f.__)("Missing","woocommerce")})`),(0,Tt.decodeEntities)(e)||""},__experimentalShowHowTo:!1}))},ro=function({setQueryAttribute:e,trackInteraction:t,query:o}){const{taxQuery:r}=o,n=(()=>{const e=(0,s.useSelect)((e=>{const{getTaxonomies:t}=e(i.store);return t({type:"product",per_page:-1})}),[]);return(0,a.useMemo)((()=>null==e?void 0:e.filter((({visibility:e})=>!(null==e||!e.publicly_queryable)))),[e])})();return n&&0!==n.length?(0,c.createElement)(c.Fragment,null,n.map((o=>{const{slug:n,name:l}=o,a=(null==r?void 0:r[n])||[],s=o=>{e({taxQuery:{...r,[n]:o}}),t(`${y.TAXONOMY}__${n}`)},i=()=>{s([]),t(`${y.TAXONOMY}__${n}`)};return(0,c.createElement)(w.__experimentalToolsPanelItem,{key:n,label:l,hasValue:()=>a.length,onDeselect:i,resetAllFilter:i},(0,c.createElement)(oo,{key:n,taxonomy:o,termIds:a,onChange:s}))}))):null},no=({query:e,trackInteraction:t,setQueryAttribute:o})=>{const r=(ge.productCount||0)>100,n=e.woocommerceHandPickedProducts,[l,s]=(0,a.useState)(""),{productsMap:i,productsList:u}=function(e,t,o=[]){const[r,n]=(0,a.useState)(new Map),[c,l]=(0,a.useState)([]);return(0,a.useEffect)((()=>{const r={selected:e?o.map(Number):[],queryArgs:e?{search:t,per_page:40}:{per_page:0}};be(r).then((e=>{const t=new Map;e.forEach((e=>{t.set(e.id,e),t.set(e.name,e)})),l(e),n(t)}))}),[e,t,o]),{productsMap:r,productsList:c}}(r,l,n),m=(0,I.useDebounce)(s,250),d=(0,a.useCallback)((e=>{const r=e.reduce(((e,t)=>{const o=i.get(t)||i.get(Number(t));return o&&e.add(String(o.id)),e}),new Set);o({woocommerceHandPickedProducts:Array.from(r)}),t(y.HAND_PICKED)}),[o,t,i]),p=(0,a.useMemo)((()=>u.filter((e=>!(null!=n&&n.includes(String(e.id))))).map((e=>e.name))),[u,n]),_=()=>{o({woocommerceHandPickedProducts:V.woocommerceHandPickedProducts}),t(y.HAND_PICKED)};return(0,c.createElement)(w.__experimentalToolsPanelItem,{label:(0,f.__)("Hand-picked Products","woocommerce"),hasValue:()=>!(null==n||!n.length),onDeselect:_,resetAllFilter:_},(0,c.createElement)(w.FormTokenField,{displayTransform:e=>{const t=Number(e);if(Number.isNaN(t))return(0,Tt.decodeEntities)(e)||"";const o=i.get(t);return(0,Tt.decodeEntities)(null==o?void 0:o.name)||""},label:(0,f.__)("Hand-picked Products","woocommerce"),onChange:d,onInputChange:r?m:void 0,suggestions:p,__experimentalValidateInput:e=>i.has(e),value:i.size?n||[]:[(0,f.__)("Loading…","woocommerce")],__experimentalExpandOnFocus:!0,__experimentalShowHowTo:!1}))},co=e=>{switch(e){case h.GRID:return(0,f.__)("Display products using rows and columns.","woocommerce");case h.STACK:return(0,f.__)("Display products in a single column.","woocommerce");default:return""}},lo=h.GRID,ao=e=>{const{type:t,columns:o,shrinkColumns:r}=e.displayLayout,n=t=>{e.setAttributes({displayLayout:{type:t,columns:o,shrinkColumns:r}})};return(0,c.createElement)(w.__experimentalToolsPanelItem,{label:(0,f.__)("Layout","woocommerce"),hasValue:()=>t!==lo,isShownByDefault:!0,onDeselect:()=>{n(h.GRID)}},(0,c.createElement)(w.__experimentalToggleGroupControl,{label:(0,f.__)("Layout","woocommerce"),isBlock:!0,onChange:e=>{n(e)},help:co(t),value:t},(0,c.createElement)(w.__experimentalToggleGroupControlOption,{value:h.STACK,label:(0,f.__)("Stack","woocommerce")}),(0,c.createElement)(w.__experimentalToggleGroupControlOption,{value:h.GRID,label:(0,f.__)("Grid","woocommerce")})))},so=e=>{const{query:t,trackInteraction:o,setQueryAttribute:r}=e,n=()=>{r({featured:V.featured}),o(y.FEATURED)};return(0,c.createElement)(w.__experimentalToolsPanelItem,{label:(0,f.__)("Featured","woocommerce"),hasValue:()=>!0===t.featured,onDeselect:n,resetAllFilter:n},(0,c.createElement)(w.BaseControl,{id:"product-collection-featured-products-control",label:(0,f.__)("Featured","woocommerce")},(0,c.createElement)(w.ToggleControl,{label:(0,f.__)("Show only featured products","woocommerce"),checked:t.featured||!1,onChange:e=>{r({featured:e}),o(y.FEATURED)}})))},io=e=>{const{query:t,trackInteraction:o,setQueryAttribute:r}=e,{timeFrame:n}=t,l=()=>{r({timeFrame:V.timeFrame}),o(y.CREATED)};return(0,c.createElement)(w.__experimentalToolsPanelItem,{label:(0,f.__)("Created","woocommerce"),hasValue:()=>(null==n?void 0:n.operator)&&(null==n?void 0:n.value),onDeselect:l,resetAllFilter:l},(0,c.createElement)(w.Flex,{direction:"column",gap:3},(0,c.createElement)(w.FlexItem,null,(0,c.createElement)(w.__experimentalToggleGroupControl,{label:(0,f.__)("Created","woocommerce"),isBlock:!0,onChange:e=>{r({timeFrame:{...n,operator:e}}),o(y.CREATED)},value:(null==n?void 0:n.operator)||v.IN},(0,c.createElement)(w.__experimentalToggleGroupControlOption,{value:v.IN,label:(0,f._x)("Within","Product Collection query operator","woocommerce")}),(0,c.createElement)(w.__experimentalToggleGroupControlOption,{value:v.NOT_IN,label:(0,f._x)("Before","Product Collection query operator","woocommerce")}))),(0,c.createElement)(w.FlexItem,null,(0,c.createElement)(w.RadioControl,{onChange:e=>{r({timeFrame:{operator:v.IN,...n,value:e}}),o(y.CREATED)},options:[{label:"last 24 hours",value:"-1 day"},{label:"last 7 days",value:"-7 days"},{label:"last 30 days",value:"-30 days"},{label:"last 3 months",value:"-3 months"}],selected:null==n?void 0:n.value}))))},uo=window.wc.priceFormat,mo=({value:e,onChange:t,label:o})=>{const[r,n]=(0,a.useState)(`${e||""}`),l=(0,uo.getCurrency)(),s=((e="",t)=>{const o=e.replace(new RegExp(`[^0-9\\${t.decimalSeparator||""}]`,"g"),"").replace(new RegExp(`\\${t.decimalSeparator}`,"g"),"."),r=Number(o);if(""!==o&&!isNaN(r))return r<0?0:r})(r,l),i=((e,t)=>{if(void 0===e||isNaN(e))return;let o=((e,t)=>{const o=Math.pow(10,t.minorUnit),r=""+Math.round(e*o)/o;let[n,c]=r.split(".");return t.thousandSeparator&&(n=n.replace(/\B(?=(\d{3})+(?!\d))/g,t.thousandSeparator)),c?`${n}${t.decimalSeparator||"."}${c}`:n})(e,t);return null!=t&&t.prefix&&(o=`${t.prefix}${o}`),null!=t&&t.suffix&&(o=`${o}${t.suffix}`),o})(s,l);return(0,c.createElement)(w.__experimentalInputControl,{value:i,onChange:e=>{n(e)},onBlur:()=>{t(s)},onKeyDown:e=>{"Enter"===e.key&&t(s)},label:o,prefix:(0,c.createElement)(w.__experimentalInputControlPrefixWrapper,null,o),placeholder:(0,f.__)("Auto","woocommerce"),hideLabelFromVision:!0,type:"text",style:{textAlign:"right"},__next40pxDefaultSize:!0})},po=e=>{const{query:t,trackInteraction:o,setQueryAttribute:r}=e,n=t.priceRange,l=()=>{r({priceRange:V.priceRange}),o(y.PRICE_RANGE)};return(0,c.createElement)(w.__experimentalToolsPanelItem,{label:(0,f.__)("Price Range","woocommerce"),hasValue:()=>void 0!==(null==n?void 0:n.min)||void 0!==(null==n?void 0:n.max),onDeselect:l,resetAllFilter:l,className:"wc-block-product-price-range-control"},(0,c.createElement)(w.BaseControl.VisualLabel,null,(0,f.__)("PRICE RANGE","woocommerce")),(0,c.createElement)(w.__experimentalHStack,{spacing:"2"},(0,c.createElement)(mo,{label:(0,f.__)("MIN","woocommerce"),value:null==n?void 0:n.min,onChange:e=>{r({priceRange:{min:0===e?void 0:e,max:null==n?void 0:n.max}}),o(y.PRICE_RANGE)}}),(0,c.createElement)(mo,{label:(0,f.__)("MAX","woocommerce"),value:null==n?void 0:n.max,onChange:e=>{const t=0===e?void 0:e;r({priceRange:{min:null==n?void 0:n.min,max:t}}),o(y.PRICE_RANGE)}})))};var _o=o(4717);var go=o(2294),wo=o(923),Eo=o.n(wo);const ho=(0,I.createHigherOrderComponent)((e=>{class t extends a.Component{constructor(...e){super(...e),(0,go.A)(this,"state",{error:null,loading:!1,variations:{}}),(0,go.A)(this,"prevSelectedItem",void 0),(0,go.A)(this,"loadVariations",(()=>{const{products:e}=this.props,{loading:t,variations:o}=this.state;if(t)return;const r=this.getExpandedProduct();if(!r||o[r])return;const n=e.find((e=>e.id===r));var c;null!=n&&n.variations&&0!==n.variations.length?(this.setState({loading:!0}),(c=r,_e()({path:(0,oe.addQueryArgs)("wc/store/v1/products",{per_page:0,type:"variation",parent:c})})).then((e=>{const t=e.map((e=>({...e,parent:r})));this.setState({variations:{...this.state.variations,[r]:t},loading:!1,error:null})})).catch((async e=>{const t=await Kt(e);this.setState({variations:{...this.state.variations,[r]:null},loading:!1,error:t})}))):this.setState({variations:{...this.state.variations,[r]:null},loading:!1,error:null})}))}componentDidMount(){const{selected:e,showVariations:t}=this.props;e&&t&&this.loadVariations()}componentDidUpdate(e){const{isLoading:t,selected:o,showVariations:r}=this.props;r&&(!Eo()(e.selected,o)||e.isLoading&&!t)&&this.loadVariations()}isProductId(e){const{products:t}=this.props;return t.some((t=>t.id===e))}findParentProduct(e){var t;const{products:o}=this.props;return null===(t=o.filter((t=>t.variations&&t.variations.find((({id:t})=>t===e))))[0])||void 0===t?void 0:t.id}getExpandedProduct(){const{isLoading:e,selected:t,showVariations:o}=this.props;if(!o)return null;let r=t&&t.length?t[0]:null;return r?this.prevSelectedItem=r:!this.prevSelectedItem||e||this.isProductId(this.prevSelectedItem)||(r=this.prevSelectedItem),!e&&r?this.isProductId(r)?r:this.findParentProduct(r):null}render(){const{error:t,isLoading:o}=this.props,{error:r,loading:n,variations:l}=this.state;return(0,c.createElement)(e,{...this.props,error:r||t,expandedProduct:this.getExpandedProduct(),isLoading:o,variations:l,variationsLoading:n})}}return t}),"withProductVariations"),vo=e=>{const{id:t,name:o,parent:r}=e;return{id:t,name:o,parent:r,breadcrumbs:[],children:[],details:e,value:e.slug}};o(7369);const bo={list:(0,f.__)("Products","woocommerce"),noItems:(0,f.__)("Your store doesn't have any products.","woocommerce"),search:(0,f.__)("Search for a product to display","woocommerce"),updated:(0,f.__)("Product search results updated.","woocommerce")},yo=(e=>t=>{let{selected:o}=t;o=void 0===o?null:o;const r=null===o;return Array.isArray(o)?(0,c.createElement)(e,{...t}):(0,c.createElement)(e,{...t,selected:r?[]:[o]})})((Ro=ho((0,I.withInstanceId)((e=>{const{expandedProduct:t=null,error:o,instanceId:r,isCompact:n=!1,isLoading:l,onChange:a,onSearch:s,products:i,renderItem:u,selected:m=[],showVariations:d=!1,variations:p,variationsLoading:_}=e;if(o)return(0,c.createElement)(Wt,{error:o});const g=[...i,...p&&t&&p[t]?p[t]:[]].map(vo);return(0,c.createElement)(jt,{className:"woocommerce-products",list:g,isCompact:n,isLoading:l,isSingle:!0,selected:g.filter((({id:e})=>m.includes(Number(e)))),onChange:a,renderItem:u||(d?e=>{var t,o,n,a;const{item:s,search:i,depth:u=0,isSelected:m,onSelect:d}=e,p=null!==(t=s.details)&&void 0!==t&&t.variations&&Array.isArray(s.details.variations)?s.details.variations.length:0,g=(0,It.A)("woocommerce-search-product__item","woocommerce-search-list__item",`depth-${u}`,"has-count",{"is-searching":i.length>0,"is-skip-level":0===u&&0!==s.parent,"is-variable":p>0});if(!s.breadcrumbs.length){var w,E,h,v,b;const t=(null===(w=s.details)||void 0===w?void 0:w.variations)&&s.details.variations.length>0;return(0,c.createElement)(zt,{...e,className:(0,It.A)(g,{"is-selected":m}),isSelected:m,item:s,onSelect:()=>()=>{d(s)()},isLoading:l||_,countLabel:t?(0,f.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,f.__)("%1$d variations","woocommerce"),null===(E=s.details)||void 0===E?void 0:E.variations.length):null,name:`products-${r}`,"aria-label":t?(0,f.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,f._n)("%1$s, has %2$d variation","%1$s, has %2$d variations",null===(h=s.details)||void 0===h||null===(v=h.variations)||void 0===v?void 0:v.length,"woocommerce"),s.name,null===(b=s.details)||void 0===b?void 0:b.variations.length):void 0})}const y=(0,We.isEmpty)(null===(o=s.details)||void 0===o?void 0:o.variation)?e:{...e,item:{...e.item,name:null===(n=s.details)||void 0===n?void 0:n.variation},"aria-label":`${s.breadcrumbs[0]}: ${null===(a=s.details)||void 0===a?void 0:a.variation}`};return(0,c.createElement)(Dt,{...y,className:g,name:`variations-${r}`})}:void 0),onSearch:s,messages:{...bo,...e.messages},isHierarchical:!0})}))),({selected:e,...t})=>{const[o,r]=(0,a.useState)(!0),[n,l]=(0,a.useState)(null),[s,i]=(0,a.useState)([]),u=ge.productCount>100,m=async e=>{const t=await Kt(e);l(t),r(!1)},d=(0,a.useRef)(e);(0,a.useEffect)((()=>{be({selected:d.current}).then((e=>{i(e),r(!1)})).catch(m)}),[d]);const p=(0,_o.YQ)((t=>{be({selected:e,search:t}).then((e=>{i(e),r(!1)})).catch(m)}),400),_=(0,a.useCallback)((e=>{r(!0),p(e)}),[r,p]);return(0,c.createElement)(Ro,{...t,selected:e,error:n,products:s,isLoading:o,onSearch:u?_:null})})),fo=({isOpen:e,onToggle:t,product:o,isLoading:r})=>{var n,l;return r&&!o?(0,c.createElement)(w.Spinner,null):(0,c.createElement)(w.Button,{className:"wc-block-product-collection-linked-product-control__button",onClick:t,"aria-expanded":e,disabled:r},(0,c.createElement)(w.Flex,{direction:"row",expanded:!0,justify:"flex-start"},(0,c.createElement)(w.FlexItem,{className:"wc-block-product-collection-linked-product-control__image-container"},(0,c.createElement)("img",{src:null==o||null===(n=o.images)||void 0===n||null===(l=n[0])||void 0===l?void 0:l.src,alt:null==o?void 0:o.name})),(0,c.createElement)(w.Flex,{direction:"column",align:"flex-start",gap:1,className:"wc-block-product-collection-linked-product-control__content"},(0,c.createElement)(w.FlexItem,null,(0,c.createElement)(w.__experimentalText,{color:"inherit",lineHeight:1},null!=o&&o.name?(0,Tt.decodeEntities)(o.name):"")),(0,c.createElement)(w.FlexItem,null,(0,c.createElement)(w.__experimentalText,{color:"inherit",lineHeight:1},null==o?void 0:o.sku)))))},ko=({query:e,setAttributes:t,setIsDropdownOpen:o})=>(0,c.createElement)(yo,{selected:null==e?void 0:e.productReference,onChange:(r=[])=>{var n,c;const l=null!==(n=null===(c=r[0])||void 0===c?void 0:c.id)&&void 0!==n?n:null;null!==l&&(t({query:{...e,productReference:l}}),o(!1))},messages:{search:(0,f.__)("Select a product","woocommerce")}}),Co=({query:e,setAttributes:t,location:o,usesReference:r})=>{const[n,l]=(0,a.useState)(!1),{product:s,isLoading:i}=(e=>{const[t,o]=(0,a.useState)(null),[r,n]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{(async()=>{if(e){n(!0);try{const t=await(e=>_e()({path:`/wc/store/v1/products/${e}`}))(e);o(t)}catch(e){o(null)}finally{n(!1)}}else o(null),n(!1)})()}),[e]),{product:t,isLoading:r}})(e.productReference);return(0,a.useMemo)((()=>{var t;const n=null==r?void 0:r.includes(o.type),c=null==r?void 0:r.includes("product"),l=null!==(null!==(t=null==e?void 0:e.productReference)&&void 0!==t?t:null);return c&&!n&&l}),[o.type,null==e?void 0:e.productReference,r])?(0,c.createElement)(w.PanelBody,{title:(0,f.__)("Linked Product","woocommerce")},(0,c.createElement)(w.PanelRow,null,(0,c.createElement)(w.Dropdown,{className:"wc-block-product-collection-linked-product-control",contentClassName:"wc-block-product-collection-linked-product__popover-content",popoverProps:{placement:"left-start"},renderToggle:({isOpen:e,onToggle:t})=>(0,c.createElement)(fo,{isOpen:e,onToggle:t,product:s,isLoading:i}),renderContent:()=>(0,c.createElement)(ko,{query:e,setAttributes:t,setIsDropdownOpen:l}),open:n,onToggle:()=>l(!n)}))):null},So=e=>{const{attributes:t,context:o,setAttributes:r}=e,{query:n,hideControls:s,displayLayout:i}=t,u=qe(o.templateSlug),m=(null==n?void 0:n.inherit)||!1,d=(e=>t=>!e.includes(t))(s),p="product-catalog"===u||"product-archive"===u,_=!1===m,g=p&&d(y.INHERIT),E=!p&&d(y.FILTERABLE),h=_&&d(y.ORDER),v=d(y.ON_SALE),b=d(y.STOCK_STATUS),k=d(y.HAND_PICKED),C=d(y.KEYWORD),S=d(y.ATTRIBUTES),I=d(y.TAXONOMY),R=d(y.FEATURED),T=d(y.CREATED),P=d(y.PRICE_RANGE),x={setAttributes:r,displayLayout:i},N={setQueryAttribute:(0,a.useMemo)((()=>fe.bind(null,e)),[e]),trackInteraction:e=>A("blocks_product_collection_inspector_control_clicked",{collection:t.collection,location:u,filter:e}),query:n};return(0,c.createElement)(l.InspectorControls,null,(0,c.createElement)(Co,{query:e.attributes.query,setAttributes:e.setAttributes,usesReference:e.usesReference,location:e.location}),(0,c.createElement)(w.__experimentalToolsPanel,{label:(0,f.__)("Settings","woocommerce"),resetAll:()=>{const t=(o=e.attributes,{displayLayout:Re(),query:Ie(o.query)});var o;e.setAttributes(t)}},g&&(0,c.createElement)(vt,{...N}),E&&(0,c.createElement)(bt,{...N}),(0,c.createElement)(ao,{...x}),(0,c.createElement)(mt,{...x}),h&&(0,c.createElement)(ft,{...N})),_?(0,c.createElement)(w.__experimentalToolsPanel,{label:(0,f.__)("Filters","woocommerce"),resetAll:e=>{e.forEach((e=>{e()}))},className:"wc-block-editor-product-collection-inspector-toolspanel__filters"},v&&(0,c.createElement)(kt,{...N}),b&&(0,c.createElement)(St,{...N}),k&&(0,c.createElement)(no,{...N}),C&&(0,c.createElement)(At,{...N}),S&&(0,c.createElement)(Xt,{...N}),I&&(0,c.createElement)(ro,{...N}),R&&(0,c.createElement)(so,{...N}),T&&(0,c.createElement)(io,{...N}),P&&(0,c.createElement)(po,{...N})):null,(0,c.createElement)(je,null))},Ao=e=>{const t=e+2592e5;return Date.now()<t},Io=(e=0)=>e<=4;var Ro;(0,te.addFilter)("editor.BlockEdit",n.name,(e=>t=>{if(t.name!==n.name)return(0,c.createElement)(e,{...t});const o=(e=>{const{attributes:t}=e,{convertedFromProducts:o}=t,{status:r,time:n,displayCount:c}=Ze();return o&&"notseen"===r&&Ao(n)&&Io(c)})(t),r=(e=>{const{attributes:t}=e,{convertedFromProducts:o}=t,{status:r,time:n,displayCount:c}=Ze();return o&&("seen"===r||!Ao(n)||!Io(c))})(t);return r&&t.setAttributes({convertedFromProducts:!1}),(0,c.createElement)(c.Fragment,null,o&&(0,c.createElement)(l.InspectorControls,null,(0,c.createElement)(at,{revertMigration:nt})),(0,c.createElement)(e,{...t}))}));const To=["core/post-content","woocommerce/mini-cart","woocommerce/featured-product"],Po=["core/","woocommerce/"],xo=(0,f.__)("Enforce full page reload on certain interactions, like using paginations controls.","woocommerce"),No=(0,f.__)("Force page reload can't be disabled because there are non-compatible blocks inside the Product Collection block.","woocommerce"),Oo=e=>{const{clientId:t,forcePageReload:o,setAttributes:r}=e,n=(e=>(0,s.useSelect)((t=>{const{getClientIdsOfDescendants:o,getBlockName:r}=t(l.store);return o(e).find((e=>{var t;return t=r(e),!(!To.includes(t)&&Po.find((e=>t.startsWith(e))))}))||!1}),[e]))(t);(0,a.useEffect)((()=>{!o&&n&&r({forcePageReload:!0})}),[o,n,r]);const i=n?No:xo;return(0,c.createElement)(w.ToggleControl,{label:(0,f.__)("Force Page Reload","woocommerce"),help:i,checked:o,onChange:()=>r({forcePageReload:!o}),disabled:n})};function Lo(e){const{clientId:t,attributes:o,setAttributes:r}=e,{forcePageReload:n}=o;return(0,c.createElement)(l.InspectorAdvancedControls,null,(0,c.createElement)(Oo,{clientId:t,forcePageReload:n,setAttributes:r}))}var Do=o(6287);const Bo=({onToggle:e})=>(0,c.createElement)(w.ToolbarButton,{icon:Do.A,label:(0,f.__)("Display settings","woocommerce"),onClick:e}),Fo=({query:e,setQueryAttribute:t})=>{const o=e=>{const o=Number(e);!isNaN(o)&&o>=1&&o<=100&&t({perPage:o})},r=e=>{const o=Number(e);!isNaN(o)&&o>=0&&o<=100&&t({offset:o})},n=e=>{const o=Number(e);!isNaN(o)&&o>=0&&t({pages:o})},l={__unstableInputWidth:"60px",labelPosition:"edge",step:"1",isDragEnabled:!1};return(0,c.createElement)(w.ToolbarGroup,null,(0,c.createElement)(w.Dropdown,{contentClassName:"wc-block-editor-product-collection__display-settings",renderToggle:({onToggle:e})=>(0,c.createElement)(Bo,{onToggle:e}),renderContent:()=>(0,c.createElement)(c.Fragment,null,(0,c.createElement)(w.__experimentalNumberControl,{...l,label:(0,f.__)("Items per Page","woocommerce"),min:1,max:100,onChange:o,value:e.perPage}),(0,c.createElement)(w.__experimentalNumberControl,{...l,label:(0,f.__)("Offset","woocommerce"),min:0,max:100,onChange:r,value:e.offset}),(0,c.createElement)(w.BaseControl,{help:(0,f.__)("Limit the pages you want to show, even if the query has more results. To show all pages use 0 (zero).","woocommerce"),id:"woocommerce-products-block__display-settings-pages"},(0,c.createElement)(w.__experimentalNumberControl,{...l,label:(0,f.__)("Max page to show","woocommerce"),min:0,onChange:n,value:e.pages})))}))};var qo=o(5866),Vo=o(6554);const Mo=e=>{const{type:t,columns:o,shrinkColumns:r}=e.displayLayout,n=t=>{e.setAttributes({displayLayout:t})},l=[{icon:qo.A,title:(0,f.__)("List view","woocommerce"),onClick:()=>n({type:h.STACK,columns:o,shrinkColumns:r}),isActive:t===h.STACK},{icon:Vo.A,title:(0,f.__)("Grid view","woocommerce"),onClick:()=>n({type:h.GRID,columns:o,shrinkColumns:r}),isActive:t===h.GRID}];return(0,c.createElement)(w.ToolbarGroup,{controls:l})},$o=e=>(0,c.createElement)(w.ToolbarGroup,null,(0,c.createElement)(w.ToolbarButton,{onClick:e.openCollectionSelectionModal},(0,f.__)("Choose collection","woocommerce")));function Ho(e){const{attributes:t,openCollectionSelectionModal:o,setAttributes:r}=e,{query:n,displayLayout:s}=t,i=(0,a.useMemo)((()=>fe.bind(null,e)),[e]);return(0,c.createElement)(l.BlockControls,null,(0,c.createElement)($o,{openCollectionSelectionModal:o}),!n.inherit&&(0,c.createElement)(c.Fragment,null,(0,c.createElement)(Fo,{query:n,setQueryAttribute:i}),(0,c.createElement)(Mo,{displayLayout:s,setAttributes:r})))}const Uo=({preview:{setPreviewState:e,initialPreviewState:t}={},...o})=>{var r,n;const i=(0,a.useRef)(!1),{clientId:m,attributes:d,setAttributes:p,location:_,isUsingReferencePreviewMode:g}=o;(({setPreviewState:e,location:t,attributes:o,setAttributes:r,isUsingReferencePreviewMode:n})=>{var c,l;const s=e=>{r({__privatePreviewState:{...o.__privatePreviewState,...e}})},i=((e,t)=>t?e.type===u.Product?(0,f.__)("Actual products will vary depending on the product being viewed.","woocommerce"):(0,f.__)("Actual products will vary depending on the page being viewed.","woocommerce"):"")(t,n);(0,a.useLayoutEffect)((()=>{n&&r({__privatePreviewState:{isPreview:i.length>0,previewMessage:i}})}),[r,i,n]),(0,a.useLayoutEffect)((()=>{if(e||n)return(null==e?void 0:e({setState:s,location:t,attributes:o}))||void 0}),[e]);const m=t.type===u.Archive?null===(c=t.sourceData)||void 0===c?void 0:c.termId:null;(0,a.useLayoutEffect)((()=>{if(!e&&!n){var c;const e=t.type===u.Archive&&null===m;r({__privatePreviewState:{isPreview:!!e&&!(null==o||null===(c=o.query)||void 0===c||!c.inherit),previewMessage:(0,f.__)("Actual products will vary depending on the page being viewed.","woocommerce")}})}}),[null==o||null===(l=o.query)||void 0===l?void 0:l.inherit,i,m,t.type,r,e,n])})({setPreviewState:e,setAttributes:p,location:_,attributes:d,isUsingReferencePreviewMode:g});const E=(0,l.useBlockProps)(),h=(0,l.useInnerBlocksProps)(E,{template:H}),v=((e,t,o)=>{const r=(0,I.useInstanceId)(o),{getBlockParentsByBlockName:n}=(0,s.useSelect)(l.store);let c=r;return(0,a.useMemo)((()=>n(e,"core/block")),[n,e]).length>0&&(c=t.queryId),c})(m,d,Uo),b={...q,query:{...q.query,inherit:Se(),filterable:Ae()},...d,queryId:v,...!!d.collection&&t&&{__privatePreviewState:t}};return(0,a.useEffect)((()=>{p(b),i.current=!0}),[]),i.current=i.current||$e()(d,b),i.current?(0,c.createElement)("div",{...E},(null===(r=d.__privatePreviewState)||void 0===r?void 0:r.isPreview)&&o.isSelected&&(0,c.createElement)(w.Button,{variant:"primary",size:"small",showTooltip:!0,label:null===(n=d.__privatePreviewState)||void 0===n?void 0:n.previewMessage,className:"wc-block-product-collection__preview-button","data-testid":"product-collection-preview-button"},"Preview"),(0,c.createElement)(So,{...o}),(0,c.createElement)(Lo,{...o}),(0,c.createElement)(Ho,{...o}),(0,c.createElement)("div",{...h})):null},Go=Uo,jo=e=>{const{clientId:t,attributes:o}=e,{replaceBlock:r}=(0,s.useDispatch)(l.store),[n,i]=(0,a.useState)(o.collection);return(0,c.createElement)(w.Modal,{overlayClassName:"wc-blocks-product-collection__modal",title:(0,f.__)("What products do you want to show?","woocommerce"),onRequestClose:e.closePatternSelectionModal,size:"large"},(0,c.createElement)("div",{className:"wc-blocks-product-collection__content"},(0,c.createElement)(Le,{chosenCollection:n,onCollectionClick:i}),(0,c.createElement)("div",{className:"wc-blocks-product-collection__footer"},(0,c.createElement)(w.Button,{variant:"tertiary",onClick:e.closePatternSelectionModal},(0,f.__)("Cancel","woocommerce")),(0,c.createElement)(w.Button,{variant:"primary",onClick:()=>{n&&Te(n,t,r)}},(0,f.__)("Continue","woocommerce")))))};o(6818);const Ko=e=>{var t;const o=(0,l.useBlockProps)(),{attributes:r,isDeletedProductReference:n}=e,s=ee(r.collection);if(!s)return null;const i=n?(0,f.__)("Previously selected product is no longer available.","woocommerce"):(0,a.createInterpolateElement)((0,f.sprintf)(/* translators: %s: collection title */ /* translators: %s: collection title */ (0,f.__)("<strong>%s</strong> requires a product to be selected in order to display associated items.","woocommerce"),s.title),{strong:(0,c.createElement)("strong",null)});return(0,c.createElement)("div",{...o},(0,c.createElement)(w.Placeholder,{className:"wc-blocks-product-collection__editor-product-picker"},(0,c.createElement)(w.__experimentalHStack,{alignment:"center"},(0,c.createElement)(T.A,{icon:Ft.A,className:"wc-blocks-product-collection__info-icon"}),(0,c.createElement)(w.__experimentalText,null,i)),(0,c.createElement)(yo,{selected:null===(t=r.query)||void 0===t?void 0:t.productReference,onChange:(t=[])=>{var o,n;null!==(null!==(o=null===(n=t[0])||void 0===n?void 0:n.id)&&void 0!==o?o:null)&&e.setAttributes({query:{...r.query,productReference:t[0].id}})},messages:{search:(0,f.__)("Select a product","woocommerce")}})))};var Qo=o(6465);function Wo(e,{blockDescription:t,blockIcon:o,blockTitle:n,variationName:c}){(0,r.registerBlockVariation)(e,{description:t,name:c,title:n,isActive:e=>e.__woocommerceNamespace===c,icon:{src:o},attributes:{__woocommerceNamespace:c},scope:["block","inserter"]})}const zo=(0,f.__)("Product Summary","woocommerce"),Yo=((0,c.createElement)(T.A,{icon:Qo.A,className:"wc-block-editor-components-block-icon"}),(0,f.__)("Display a short description about a product.","woocommerce")),Jo=`${n.name}/product-summary`;var Zo=o(4478);const Xo=(0,f.__)("Product Title","woocommerce"),er=((0,c.createElement)(T.A,{icon:Zo.A,className:"wc-block-editor-components-block-icon"}),(0,f.__)("Display the title of a product.","woocommerce")),tr=`${n.name}/product-title`;(0,r.registerBlockType)(n,{icon:()=>(0,c.createElement)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,c.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 11H5C4.72386 11 4.5 11.2239 4.5 11.5V17.5C4.5 17.7761 4.72386 18 5 18H19C19.2761 18 19.5 17.7761 19.5 17.5V11.5C19.5 11.2239 19.2761 11 19 11ZM5 9.5H19C20.1046 9.5 21 10.3954 21 11.5V17.5C21 18.6046 20.1046 19.5 19 19.5H5C3.89543 19.5 3 18.6046 3 17.5V11.5C3 10.3954 3.89543 9.5 5 9.5Z",fill:"currentColor"}),(0,c.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18 7.5C18 7.77614 17.7761 8 17.5 8L6.5 8C6.22386 8 6 7.77614 6 7.5V7.5C6 7.22386 6.22386 7 6.5 7L17.5 7C17.7761 7 18 7.22386 18 7.5V7.5Z",fill:"currentColor"}),(0,c.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16 5C16 5.27614 15.7761 5.5 15.5 5.5L8.5 5.5C8.22386 5.5 8 5.27614 8 5V5C8 4.72386 8.22386 4.5 8.5 4.5L15.5 4.5C15.7761 4.5 16 4.72386 16 5V5Z",fill:"currentColor"})),edit:e=>{const{clientId:t,attributes:o}=e,r=((e,t)=>{const o=e.templateSlug||"",r=e.postId||null,n=(e=>t=>e.replace(`${t}-`,""))(o),c=(e=>t=>e.includes(t)&&e!==t)(o),i=c(m),w=c(d),E=c(p),[h,v]=(0,a.useState)(null),[b,y]=(0,a.useState)(null),[f,k]=(0,a.useState)(null);(0,a.useEffect)((()=>{if(i){const e=n(m);_("postType","product",e,v)}if(w){const e=n(d);_("taxonomy","product_cat",e,y)}if(E){const e=n(p);_("taxonomy","product_tag",e,k)}}),[i,w,E,n]);const{isInSingleProductBlock:C,isInSomeCartCheckoutBlock:S}=(0,s.useSelect)((e=>{const{getBlockParentsByBlockName:o}=e(l.store),r=e=>o(t,e).length>0;return{isInSingleProductBlock:r(["woocommerce/single-product"]),isInSomeCartCheckoutBlock:r(["woocommerce/cart","woocommerce/checkout","woocommerce/mini-cart-contents"])}}),[t]);if(C)return g(u.Product,{productId:r});if(S)return g(u.Cart);if(i)return g(u.Product,{productId:h});const A=(e=>t=>e===t)(o);if(A(m))return g(u.Product,{productId:null});if(w)return g(u.Archive,{taxonomy:"product_cat",termId:b});if(E)return g(u.Archive,{taxonomy:"product_tag",termId:f});if(A(d))return g(u.Archive,{taxonomy:"product_cat",termId:null});if(A(p))return g(u.Archive,{taxonomy:"product_tag",termId:null});if(A("taxonomy-product_attribute"))return g(u.Archive,{taxonomy:null,termId:null});if("page-cart"===o||"page-checkout"===o)return g(u.Cart);const I=A("order-confirmation");return g(I?u.Order:u.Site)})(e.context,e.clientId),[n,h]=(0,a.useState)(!1),v=(0,s.useSelect)((e=>!!e(l.store).getBlocks(t).length),[t]),{productCollectionUIStateInEditor:b,isLoading:y}=(({location:e,usesReference:t,attributes:o,hasInnerBlocks:r})=>{var n,c,l,m;const d=null===(n=o.query)||void 0===n?void 0:n.productReference,{product:p,hasResolved:_}=(0,s.useSelect)((e=>{if(!d)return{product:null,hasResolved:!0};const{getEntityRecord:t,hasFinishedResolution:o}=e(i.store),r=["postType","product",d];return{product:t(...r),hasResolved:o("getEntityRecord",r)}}),[d]);return{productCollectionUIStateInEditor:(0,a.useMemo)((()=>{var n,c;const l=null==t?void 0:t.includes(e.type),a=!!o.collection,s=null==t?void 0:t.includes("product"),i=null!==(null!==(n=null===(c=o.query)||void 0===c?void 0:c.productReference)&&void 0!==n?n:null);if(a&&s&&!l&&!i)return E.PRODUCT_REFERENCE_PICKER;if(a&&s&&!l&&i&&d&&(void 0===p||"trash"===(null==p?void 0:p.status)))return E.DELETED_PRODUCT_REFERENCE;if(l){var m,_,g,w;const t=e.type===u.Archive&&null!==(null!==(m=null===(_=e.sourceData)||void 0===_?void 0:_.termId)&&void 0!==m?m:null),o=e.type===u.Product&&null!==(null!==(g=null===(w=e.sourceData)||void 0===w?void 0:w.productId)&&void 0!==g?g:null);if(!t&&!o)return E.VALID_WITH_PREVIEW}return r||a?E.VALID:E.COLLECTION_PICKER}),[e.type,null===(c=e.sourceData)||void 0===c?void 0:c.termId,null===(l=e.sourceData)||void 0===l?void 0:l.productId,t,o.collection,d,p,r,null===(m=o.query)||void 0===m?void 0:m.productReference]),isLoading:!_}})({location:r,attributes:o,hasInnerBlocks:v,usesReference:e.usesReference});if(y)return(0,c.createElement)(w.Flex,{justify:"center",align:"center"},(0,c.createElement)(w.Spinner,null));const f={...e,openCollectionSelectionModal:()=>h(!0),location:r,isUsingReferencePreviewMode:b===E.VALID_WITH_PREVIEW};return(0,c.createElement)(c.Fragment,null,(()=>{switch(b){case E.COLLECTION_PICKER:return(0,c.createElement)(Ve,{...e});case E.PRODUCT_REFERENCE_PICKER:return(0,c.createElement)(Ko,{...e,isDeletedProductReference:!1});case E.DELETED_PRODUCT_REFERENCE:return(0,c.createElement)(Ko,{...e,isDeletedProductReference:!0});case E.VALID:case E.VALID_WITH_PREVIEW:return(0,c.createElement)(Go,{...f});default:return(0,c.createElement)(Ve,{...e})}})(),n&&(0,c.createElement)(jo,{clientId:t,attributes:o,closePatternSelectionModal:()=>h(!1)}))},save:function({attributes:{tagName:e="div"}}){const t=l.useBlockProps.save(),o=l.useInnerBlocksProps.save(t);return(0,c.createElement)(e,{...o})}}),Wo("core/post-excerpt",{blockDescription:Yo,blockIcon:(0,c.createElement)(w.Icon,{icon:Qo.A}),blockTitle:zo,variationName:Jo}),Wo("core/post-title",{blockDescription:er,blockIcon:(0,c.createElement)(w.Icon,{icon:Zo.A}),blockTitle:Xo,variationName:tr}),X.forEach((e=>(0,R.__experimentalRegisterProductCollection)(e))),(0,x.isWpVersion)("6.1",">=")&&(0,te.addFilter)("blocks.registerBlockType","woocommerce/add-product-collection-block-to-parent-array-of-pagination-block",((e,t)=>t!==$?e:null!=e&&e.ancestor?{...e,ancestor:[...e.ancestor,n.name]}:null!=e&&e.parent?{...e,parent:[...e.parent,n.name]}:e))},6818:()=>{},1598:()=>{},2777:()=>{},7369:()=>{},8137:()=>{},6636:()=>{},1609:e=>{"use strict";e.exports=window.React},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}},n={};function c(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return r[e].call(o.exports,o,o.exports,c),o.exports}c.m=r,e=[],c.O=(t,o,r,n)=>{if(!o){var l=1/0;for(u=0;u<e.length;u++){for(var[o,r,n]=e[u],a=!0,s=0;s<o.length;s++)(!1&n||l>=n)&&Object.keys(c.O).every((e=>c.O[e](o[s])))?o.splice(s--,1):(a=!1,n<l&&(l=n));if(a){e.splice(u--,1);var i=r();void 0!==i&&(t=i)}}return t}n=n||0;for(var u=e.length;u>0&&e[u-1][2]>n;u--)e[u]=e[u-1];e[u]=[o,r,n]},c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},o=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,c.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var n=Object.create(null);c.r(n);var l={};t=t||[null,o({}),o([]),o(o)];for(var a=2&r&&e;"object"==typeof a&&!~t.indexOf(a);a=o(a))Object.getOwnPropertyNames(a).forEach((t=>l[t]=()=>e[t]));return l.default=()=>e,c.d(n,l),n},c.d=(e,t)=>{for(var o in t)c.o(t,o)&&!c.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.j=5201,(()=>{var e={5201:0};c.O.j=t=>0===e[t];var t=(t,o)=>{var r,n,[l,a,s]=o,i=0;if(l.some((t=>0!==e[t]))){for(r in a)c.o(a,r)&&(c.m[r]=a[r]);if(s)var u=s(c)}for(t&&t(o);i<l.length;i++)n=l[i],c.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return c.O(u)},o=self.webpackChunkwebpackWcBlocksMainJsonp=self.webpackChunkwebpackWcBlocksMainJsonp||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var l=c.O(void 0,[94],(()=>c(8240)));l=c.O(l),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["product-collection"]=l})();