this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["products-by-attribute"]=function(e){function t(t){for(var n,i,l=t[0],a=t[1],u=t[2],b=0,d=[];b100,u={per_page:a?100:0,catalog_visibility:"any",search:c,orderby:"title",order:"asc"},b=[Object(o.addQueryArgs)("/wc/store/products",d(d({},u),l))];return a&&r.length&&b.push(Object(o.addQueryArgs)("/wc/store/products",{catalog_visibility:"any",include:r,per_page:0})),b}({selected:r,search:c,queryArgs:void 0===i?{}:i});return Promise.all(u.map((function(e){return l()({path:e})}))).then((function(e){return Object(a.uniqBy)(Object(a.flatten)(e),"id").map((function(e){return d(d({},e),{},{parent:0})}))})).catch((function(e){throw e}))},g=function(e){return l()({path:"/wc/store/products/".concat(e)})},f=function(){return l()({path:"wc/store/products/attributes"})},h=function(e){return l()({path:"wc/store/products/attributes/".concat(e,"/terms")})},O=function(e){var t=e.selected,r=function(e){var t=e.selected,r=void 0===t?[]:t,n=e.search,c=Object(u.getSetting)("limitTags",!1),i=[Object(o.addQueryArgs)("wc/store/products/tags",{per_page:c?100:0,orderby:c?"count":"name",order:c?"desc":"asc",search:n})];return c&&r.length&&i.push(Object(o.addQueryArgs)("wc/store/products/tags",{include:r})),i}({selected:void 0===t?[]:t,search:e.search});return Promise.all(r.map((function(e){return l()({path:e})}))).then((function(e){return Object(a.uniqBy)(Object(a.flatten)(e),"id")}))},w=function(e){return l()({path:Object(o.addQueryArgs)("wc/store/products/categories",d({per_page:0},e))})},m=function(e){return l()({path:"wc/store/products/categories/".concat(e)})},E=function(e){return l()({path:Object(o.addQueryArgs)("wc/store/products",{per_page:0,type:"variation",parent:e})})},j=function(e,t){if(!e.title.raw)return e.slug;var r=1===t.filter((function(t){return t.title.raw===e.title.raw})).length;return e.title.raw+(r?"":" - ".concat(e.slug))}},4:function(e,t){e.exports=window.wp.components},42:function(e,t,r){"use strict";r.d(t,"a",(function(){return a})),r.d(t,"b",(function(){return u}));var n=r(29),c=r.n(n),o=r(22),i=r.n(o),l=r(1),a=function(){var e=c()(i.a.mark((function e(t){var r;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("function"!=typeof t.json){e.next=11;break}return e.prev=1,e.next=4,t.json();case 4:return r=e.sent,e.abrupt("return",{message:r.message,type:r.type||"api"});case 8:return e.prev=8,e.t0=e.catch(1),e.abrupt("return",{message:e.t0.message,type:"general"});case 11:return e.abrupt("return",{message:t.message,type:t.type||"general"});case 12:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(_x){return e.apply(this,arguments)}}(),u=function(e){if(e.data&&"rest_invalid_param"===e.code){var t=Object.values(e.data.params);if(t[0])return t[0]}return(null==e?void 0:e.message)||Object(l.__)("Something went wrong. Please contact us to get assistance.",'woocommerce')}},46:function(e,t){e.exports=window.wp.keycodes},48:function(e,t){e.exports=window.wp.escapeHtml},52:function(e,t,r){"use strict";var n=r(0),c=r(1),o=(r(2),r(48));t.a=function(e){var t,r,i,l=e.error;return Object(n.createElement)("div",{className:"wc-block-error-message"},(r=(t=l).message,i=t.type,r?"general"===i?Object(n.createElement)("span",null,Object(c.__)("The following error was returned",'woocommerce'),Object(n.createElement)("br",null),Object(n.createElement)("code",null,Object(o.escapeHTML)(r))):"api"===i?Object(n.createElement)("span",null,Object(c.__)("The following error was returned from the API",'woocommerce'),Object(n.createElement)("br",null),Object(n.createElement)("code",null,Object(o.escapeHTML)(r))):r:Object(c.__)("An unknown error occurred which prevented the block from being updated.",'woocommerce')))}},55:function(e,t){e.exports=window.wp.hooks},56:function(e,t){e.exports=window.wp.deprecated},66:function(e,t,r){"use strict";var n=r(5),c=r.n(n),o=r(16),i=r.n(o),l=r(0),a=["srcElement","size"];function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}t.a=function(e){var t=e.srcElement,r=e.size,n=void 0===r?24:r,o=i()(e,a);return Object(l.isValidElement)(t)?Object(l.cloneElement)(t,function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"id";return Array.isArray(t)?t.find((function(t){return t[r]===e})):null},q=r(52),H=r(6),U=r.n(H),W=r(131),J=(r(768),function(e){var t=e.attributes,r=e.error,o=e.expandedAttribute,i=e.onChange,l=e.onExpandAttribute,a=e.onOperatorChange,u=e.instanceId,s=e.isCompact,b=e.isLoading,d=e.operator,p=e.selected,g=e.termsAreLoading,f=e.termsList[o]||[],h=[].concat(P()(t),P()(f)),O={clear:Object(c.__)("Clear all product attributes",'woocommerce'),list:Object(c.__)("Product Attributes",'woocommerce'),noItems:Object(c.__)("Your store doesn't have any product attributes.",'woocommerce'),search:Object(c.__)("Search for product attributes",'woocommerce'),selected:function(e){return Object(c.sprintf)( /* translators: %d is the count of attributes selected. */ Object(c._n)("%d attribute selected","%d attributes selected",e,'woocommerce'),e)},updated:Object(c.__)("Product attribute search results updated.",'woocommerce')};return r?Object(n.createElement)(q.a,{error:r}):Object(n.createElement)(n.Fragment,null,Object(n.createElement)(A.b,{className:"woocommerce-product-attributes",list:h,isLoading:b,selected:p.map((function(e){var t=e.id;return h.find((function(e){return e.id===t}))})).filter(Boolean),onChange:i,renderItem:function(e){var t=e.item,r=e.search,a=e.depth,s=void 0===a?0:a,b=["woocommerce-product-attributes__item","woocommerce-search-list__item",{"is-searching":r.length>0,"is-skip-level":0===s&&0!==t.parent}];if(!t.breadcrumbs.length){var d=o===t.id;return Object(n.createElement)(W.a,C()({},e,{className:U.a.apply(void 0,b.concat([{"is-selected":d}])),isSelected:d,item:t,isLoading:g,disabled:"0"===t.count,onSelect:function(e){var t=e.id;return function(){i([]),l(t)}},name:"attributes-".concat(u),countLabel:Object(c.sprintf)( /* translators: %d is the count of terms. */ Object(c._n)("%d term","%d terms",t.count,'woocommerce'),t.count),"aria-label":Object(c.sprintf)( /* translators: %1$s is the item name, %2$d is the count of terms for the item. */ Object(c._n)("%1$s, has %2$d term","%1$s, has %2$d terms",t.count,'woocommerce'),t.name,t.count)}))}var p="".concat(t.breadcrumbs[0],": ").concat(t.name);return Object(n.createElement)(A.c,C()({},e,{name:"terms-".concat(u),className:U.a.apply(void 0,b.concat(["has-count"])),countLabel:Object(c.sprintf)( /* translators: %d is the count of products. */ Object(c._n)("%d product","%d products",t.count,'woocommerce'),t.count),"aria-label":Object(c.sprintf)( /* translators: %1$s is the attribute name, %2$d is the count of products for that attribute. */ Object(c._n)("%1$s, has %2$d product","%1$s, has %2$d products",t.count,'woocommerce'),p,t.count)}))},messages:O,isCompact:s,isHierarchical:!0}),!!a&&Object(n.createElement)("div",{hidden:p.length<2},Object(n.createElement)(v.SelectControl,{className:"woocommerce-product-attributes__operator",label:Object(c.__)("Display products matching",'woocommerce'),help:Object(c.__)("Pick at least two attributes to use this setting.",'woocommerce'),value:d,onChange:a,options:[{label:Object(c.__)("Any selected attributes",'woocommerce'),value:"any"},{label:Object(c.__)("All selected attributes",'woocommerce'),value:"all"}]})))});J.defaultProps={isCompact:!1,operator:"any"};var Y,K=(Y=Object(R.withInstanceId)(J),function(e){var t=e.selected,r=void 0===t?[]:t,c=r.length?r[0].attr_slug:null,o=Object(n.useState)(null),i=N()(o,2),l=i[0],a=i[1],u=Object(n.useState)(0),s=N()(u,2),b=s[0],d=s[1],p=Object(n.useState)({}),g=N()(p,2),f=g[0],h=g[1],O=Object(n.useState)(!0),w=N()(O,2),m=w[0],E=w[1],j=Object(n.useState)(!1),y=N()(j,2),v=y[0],_=y[1],x=Object(n.useState)(null),k=N()(x,2),P=k[0],S=k[1];return Object(n.useEffect)((function(){null===l&&Object($.b)().then((function(e){if(e=e.map((function(e){return V(V({},e),{},{parent:0})})),a(e),c){var t=Q(c,e,"taxonomy");t&&d(t.id)}})).catch(function(){var e=B()(I.a.mark((function e(t){return I.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=S,e.next=3,Object(z.a)(t);case 3:e.t1=e.sent,(0,e.t0)(e.t1);case 5:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}()).finally((function(){E(!1)}))}),[l,c]),Object(n.useEffect)((function(){var e=Q(b,l);e&&(_(!0),Object($.i)(b).then((function(t){t=t.map((function(t){return V(V({},t),{},{parent:b,attr_slug:e.taxonomy})})),h((function(e){return V(V({},e),{},L()({},b,t))}))})).catch(function(){var e=B()(I.a.mark((function e(t){return I.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=S,e.next=3,Object(z.a)(t);case 3:e.t1=e.sent,(0,e.t0)(e.t1);case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).finally((function(){_(!1)})))}),[b,l]),Object(n.createElement)(Y,C()({},e,{attributes:l||[],error:P,expandedAttribute:b,onExpandAttribute:d,isLoading:m,termsAreLoading:v,termsList:f}))}),X=r(130),Z=r(188);var ee=function(e){f()(a,e);var t,r,i=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=m()(t);if(r){var c=m()(this).constructor;e=Reflect.construct(n,arguments,c)}else e=n.apply(this,arguments);return O()(this,e)});function a(){return b()(this,a),i.apply(this,arguments)}return p()(a,[{key:"getInspectorControls",value:function(){var e=this.props.setAttributes,t=this.props.attributes,r=t.attributes,o=t.attrOperator,i=t.columns,l=t.contentVisibility,a=t.orderby,s=t.rows,b=t.alignButtons;return Object(n.createElement)(E.InspectorControls,{key:"inspector"},Object(n.createElement)(v.PanelBody,{title:Object(c.__)("Layout",'woocommerce'),initialOpen:!0},Object(n.createElement)(x.a,{columns:i,rows:s,alignButtons:b,setAttributes:e,minColumns:Object(u.getSetting)("min_columns",1),maxColumns:Object(u.getSetting)("max_columns",6),minRows:Object(u.getSetting)("min_rows",1),maxRows:Object(u.getSetting)("max_rows",6)})),Object(n.createElement)(v.PanelBody,{title:Object(c.__)("Content",'woocommerce'),initialOpen:!0},Object(n.createElement)(_.a,{settings:l,onChange:function(t){return e({contentVisibility:t})}})),Object(n.createElement)(v.PanelBody,{title:Object(c.__)("Filter by Product Attribute",'woocommerce'),initialOpen:!1},Object(n.createElement)(K,{selected:r,onChange:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=t.map((function(e){return{id:e.id,attr_slug:e.attr_slug}}));e({attributes:r})},operator:o,onOperatorChange:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"any";return e({attrOperator:t})},isCompact:!0})),Object(n.createElement)(v.PanelBody,{title:Object(c.__)("Order By",'woocommerce'),initialOpen:!1},Object(n.createElement)(X.a,{setAttributes:e,value:a})))}},{key:"renderEditMode",value:function(){var e=this.props,t=e.debouncedSpeak,r=e.setAttributes,i=this.props.attributes;return Object(n.createElement)(v.Placeholder,{icon:Object(n.createElement)(o.a,{srcElement:l}),label:Object(c.__)("Products by Attribute",'woocommerce'),className:"wc-block-products-grid wc-block-products-by-attribute"},Object(c.__)("Display a grid of products from your selected attributes.",'woocommerce'),Object(n.createElement)("div",{className:"wc-block-products-by-attribute__selection"},Object(n.createElement)(K,{selected:i.attributes,onChange:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=e.map((function(e){return{id:e.id,attr_slug:e.attr_slug}}));r({attributes:t})},operator:i.attrOperator,onOperatorChange:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"any";return r({attrOperator:e})}}),Object(n.createElement)(v.Button,{isPrimary:!0,onClick:function(){r({editMode:!1}),t(Object(c.__)("Showing Products by Attribute block preview.",'woocommerce'))}},Object(c.__)("Done",'woocommerce'))))}},{key:"render",value:function(){var e=this.props,t=e.attributes,r=e.name,o=e.setAttributes,i=t.editMode;return t.isPreview?Z.a:Object(n.createElement)(n.Fragment,null,Object(n.createElement)(E.BlockControls,null,Object(n.createElement)(v.ToolbarGroup,{controls:[{icon:"edit",title:Object(c.__)("Edit"),onClick:function(){return o({editMode:!i})},isActive:i}]})),this.getInspectorControls(),i?this.renderEditMode():Object(n.createElement)(v.Disabled,null,Object(n.createElement)(y.a,{block:r,attributes:t})))}}]),a}(n.Component),te=Object(v.withSpokenMessages)(ee);Object(a.registerBlockType)("woocommerce/products-by-attribute",{title:Object(c.__)("Products by Attribute",'woocommerce'),icon:{src:Object(n.createElement)(o.a,{srcElement:l}),foreground:"#96588a"},category:"woocommerce",keywords:[Object(c.__)("WooCommerce",'woocommerce')],description:Object(c.__)("Display a grid of products with selected attributes.",'woocommerce'),supports:{align:["wide","full"],html:!1},example:{attributes:{isPreview:!0}},attributes:{attributes:{type:"array",default:[]},attrOperator:{type:"string",default:"any"},columns:{type:"number",default:Object(u.getSetting)("default_columns",3)},editMode:{type:"boolean",default:!0},contentVisibility:{type:"object",default:{title:!0,price:!0,rating:!0,button:!0}},orderby:{type:"string",default:"date"},rows:{type:"number",default:Object(u.getSetting)("default_rows",3)},alignButtons:{type:"boolean",default:!1},isPreview:{type:"boolean",default:!1}},edit:function(e){return Object(n.createElement)(te,e)},save:function(){return null}})},87:function(e,t){e.exports=window.ReactDOM},89:function(e,t){e.exports=window.wp.viewport},92:function(e,t,r){"use strict";var n=r(5),c=r.n(n),o=r(0),i=r(1),l=(r(2),r(4));function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t