PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /home/trave494/footcrew.com/wp-content/plugins/woocommerce/assets/client/blocks/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : /home/trave494/footcrew.com/wp-content/plugins/woocommerce/assets/client/blocks/attribute-filter.js

(()=>{var e,t={9281:(e,t,r)=>{"use strict";r.r(t);var o=r(9196);const n=window.wp.blocks,l=window.wp.blockEditor;var a=r(2911),s=r(3743),c=r(3849),i=r.n(c),u=r(4167),m=r(5736),d=r(9307),p=r(5656);const b=window.wp.components;var g=r(2720),_=r(4333);const h={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")},w=(e,t=e)=>{const r=e.reduce(((e,t)=>{const r=t.parent||0;return e[r]||(e[r]=[]),e[r].push(t),e}),{}),o=("id",t.reduce(((e,t)=>(e[String(t.id)]=t,e)),{}));const n=["0"],l=(e={})=>e.parent?[...l(o[e.parent]),e.name]:e.name?[e.name]:[],a=e=>e.map((e=>{const t=r[e.id];return n.push(""+e.id),{...e,breadcrumbs:l(o[e.parent]),children:t&&t.length?a(t):[]}})),s=a(r[0]||[]);return Object.entries(r).forEach((([e,t])=>{n.includes(e)||s.push(...a(t||[]))})),s},f=(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,o.createElement)("strong",{key:t},e):(0,o.createElement)(d.Fragment,{key:t},e)))};function y(e,t,r){const o=new Set(t.map((e=>e[r])));return e.filter((e=>!o.has(e[r])))}const E=window.wp.htmlEntities,v=({label:e})=>(0,o.createElement)("span",{className:"woocommerce-search-list__item-count"},e),k=e=>{const{item:t,search:r}=e,n=t.breadcrumbs&&t.breadcrumbs.length;return(0,o.createElement)("span",{className:"woocommerce-search-list__item-label"},n?(0,o.createElement)("span",{className:"woocommerce-search-list__item-prefix"},1===(l=t.breadcrumbs).length?l.slice(0,1).toString():2===l.length?l.slice(0,1).toString()+" › "+l.slice(-1).toString():l.slice(0,1).toString()+" … "+l.slice(-1).toString()):null,(0,o.createElement)("span",{className:"woocommerce-search-list__item-name"},f((0,E.decodeEntities)(t.name),r)));var l},S=({countLabel:e,className:t,depth:r=0,controlId:n="",item:l,isSelected:a,isSingle:s,onSelect:c,search:u="",selected:m,useExpandedPanelId:p,...g})=>{var _,h;const[w,S]=p,C=null!=e&&void 0!==l.count&&null!==l.count,x=!(null===(_=l.breadcrumbs)||void 0===_||!_.length),N=!(null===(h=l.children)||void 0===h||!h.length),T=w===l.id,A=i()(["woocommerce-search-list__item",`depth-${r}`,t],{"has-breadcrumbs":x,"has-children":N,"has-count":C,"is-expanded":T,"is-radio-button":s}),O=g.name||`search-list-item-${n}`,P=`${O}-${l.id}`,L=(0,d.useCallback)((()=>{S(T?-1:Number(l.id))}),[T,l.id,S]);return N?(0,o.createElement)("div",{className:A,onClick:L,onKeyDown:e=>"Enter"===e.key||" "===e.key?L():null,role:"treeitem",tabIndex:0},s?(0,o.createElement)(o.Fragment,null,(0,o.createElement)("input",{type:"radio",id:P,name:O,value:l.value,onChange:c(l),onClick:e=>e.stopPropagation(),checked:a,className:"woocommerce-search-list__item-input",...g}),(0,o.createElement)(k,{item:l,search:u}),C?(0,o.createElement)(v,{label:e||l.count}):null):(0,o.createElement)(o.Fragment,null,(0,o.createElement)(b.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:a,...!a&&l.children.some((e=>m.find((t=>t.id===e.id))))?{indeterminate:!0}:{},label:f((0,E.decodeEntities)(l.name),u),onChange:()=>{a?c(y(m,l.children,"id"))():c(function(e,t,r){const o=y(t,e,"id");return[...e,...o]}(m,l.children))()},onClick:e=>e.stopPropagation()}),C?(0,o.createElement)(v,{label:e||l.count}):null)):(0,o.createElement)("label",{htmlFor:P,className:A},s?(0,o.createElement)(o.Fragment,null,(0,o.createElement)("input",{...g,type:"radio",id:P,name:O,value:l.value,onChange:c(l),checked:a,className:"woocommerce-search-list__item-input"}),(0,o.createElement)(k,{item:l,search:u})):(0,o.createElement)(b.CheckboxControl,{...g,id:P,name:O,className:"woocommerce-search-list__item-input",value:(0,E.decodeEntities)(l.value),label:f((0,E.decodeEntities)(l.name),u),onChange:c(l),checked:a}),C?(0,o.createElement)(v,{label:e||l.count}):null)};var C=r(837);r(1058);const x=({id:e,label:t,popoverContents:r,remove:n,screenReaderLabel:l,className:s=""})=>{const[c,u]=(0,d.useState)(!1),p=(0,_.useInstanceId)(x);if(l=l||t,!t)return null;t=(0,E.decodeEntities)(t);const g=i()("woocommerce-tag",s,{"has-remove":!!n}),h=`woocommerce-tag__label-${p}`,w=(0,o.createElement)(o.Fragment,null,(0,o.createElement)("span",{className:"screen-reader-text"},l),(0,o.createElement)("span",{"aria-hidden":"true"},t));return(0,o.createElement)("span",{className:g},r?(0,o.createElement)(b.Button,{className:"woocommerce-tag__text",id:h,onClick:()=>u(!0)},w):(0,o.createElement)("span",{className:"woocommerce-tag__text",id:h},w),r&&c&&(0,o.createElement)(b.Popover,{onClose:()=>u(!1)},r),n&&(0,o.createElement)(b.Button,{className:"woocommerce-tag__remove",onClick:n(e),label:(0,m.sprintf)(
// Translators: %s label.
// Translators: %s label.
(0,m.__)("Remove %s","woocommerce"),t),"aria-describedby":h},(0,o.createElement)(a.Z,{icon:C.Z,size:20,className:"clear-icon",role:"img"})))},N=x;r(9658);const T=e=>(0,o.createElement)(S,{...e}),A=e=>{const{list:t,selected:r,renderItem:n,depth:l=0,onSelect:a,instanceId:s,isSingle:c,search:i,useExpandedPanelId:u}=e,[m]=u;return t?(0,o.createElement)(d.Fragment,null,t.map((t=>{var p,b;const g=null!==(p=t.children)&&void 0!==p&&p.length&&!c?t.children.every((({id:e})=>r.find((t=>t.id===e)))):!!r.find((({id:e})=>e===t.id)),_=(null===(b=t.children)||void 0===b?void 0:b.length)&&m===t.id;return(0,o.createElement)(d.Fragment,{key:t.id},(0,o.createElement)("li",null,n({item:t,isSelected:g,onSelect:a,isSingle:c,selected:r,search:i,depth:l,useExpandedPanelId:u,controlId:s})),_?(0,o.createElement)(A,{...e,list:t.children,depth:l+1}):null)}))):null},O=({isLoading:e,isSingle:t,selected:r,messages:n,onChange:l,onRemove:a})=>{if(e||t||!r)return null;const s=r.length;return(0,o.createElement)("div",{className:"woocommerce-search-list__selected"},(0,o.createElement)("div",{className:"woocommerce-search-list__selected-header"},(0,o.createElement)("strong",null,n.selected(s)),s>0?(0,o.createElement)(b.Button,{variant:"link",isDestructive:!0,onClick:()=>l([]),"aria-label":n.clear},(0,m.__)("Clear all","woocommerce")):null),s>0?(0,o.createElement)("ul",null,r.map(((e,t)=>(0,o.createElement)("li",{key:t},(0,o.createElement)(N,{label:e.name,id:e.id,remove:a}))))):null)},P=({filteredList:e,search:t,onSelect:r,instanceId:n,useExpandedPanelId:l,...s})=>{const{messages:c,renderItem:i,selected:u,isSingle:d}=s,p=i||T;return 0===e.length?(0,o.createElement)("div",{className:"woocommerce-search-list__list is-not-found"},(0,o.createElement)("span",{className:"woocommerce-search-list__not-found-icon"},(0,o.createElement)(a.Z,{icon:g.Z,role:"img"})),(0,o.createElement)("span",{className:"woocommerce-search-list__not-found-text"},t?(0,m.sprintf)(c.noResults,t):c.noItems)):(0,o.createElement)("ul",{className:"woocommerce-search-list__list"},(0,o.createElement)(A,{useExpandedPanelId:l,list:e,selected:u,renderItem:p,onSelect:r,instanceId:n,isSingle:d,search:t}))},L=e=>{const{className:t="",isCompact:r,isHierarchical:n,isLoading:l,isSingle:a,list:s,messages:c=h,onChange:u,onSearch:p,selected:g,type:f="text",debouncedSpeak:y}=e,[E,v]=(0,d.useState)(""),k=(0,d.useState)(-1),S=(0,_.useInstanceId)(L),C=(0,d.useMemo)((()=>({...h,...c})),[c]),x=(0,d.useMemo)((()=>((e,t,r)=>{if(!t)return r?w(e):e;const o=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),n=e.map((e=>!!o.test(e.name)&&e)).filter(Boolean);return r?w(n,e):n})(s,E,n)),[s,E,n]);(0,d.useEffect)((()=>{y&&y(C.updated)}),[y,C]),(0,d.useEffect)((()=>{"function"==typeof p&&p(E)}),[E,p]);const N=(0,d.useCallback)((e=>()=>{a&&u([]);const t=g.findIndex((({id:t})=>t===e));u([...g.slice(0,t),...g.slice(t+1)])}),[a,g,u]),T=(0,d.useCallback)((e=>()=>{Array.isArray(e)?u(e):-1===g.findIndex((({id:t})=>t===e.id))?u(a?[e]:[...g,e]):N(e.id)()}),[a,N,u,g]),A=(0,d.useCallback)((e=>{const[t]=g.filter((t=>!e.find((e=>t.id===e.id))));N(t.id)()}),[N,g]);return(0,o.createElement)("div",{className:i()("woocommerce-search-list",t,{"is-compact":r,"is-loading":l,"is-token":"token"===f})},"text"===f&&(0,o.createElement)(O,{...e,onRemove:N,messages:C}),(0,o.createElement)("div",{className:"woocommerce-search-list__search"},"text"===f?(0,o.createElement)(b.TextControl,{label:C.search,type:"search",value:E,onChange:e=>v(e)}):(0,o.createElement)(b.FormTokenField,{disabled:l,label:C.search,onChange:A,onInputChange:e=>v(e),suggestions:[],__experimentalValidateInput:()=>!1,value:l?[(0,m.__)("Loading…","woocommerce")]:g.map((e=>({...e,value:e.name}))),__experimentalShowHowTo:!1})),l?(0,o.createElement)("div",{className:"woocommerce-search-list__list"},(0,o.createElement)(b.Spinner,null)):(0,o.createElement)(P,{...e,search:E,filteredList:x,messages:C,onSelect:T,instanceId:S,useExpandedPanelId:k}))},R=((0,b.withSpokenMessages)(L),window.wc.wcSettings);r(9578);const I=(0,_.withInstanceId)((({className:e,headingLevel:t,onChange:r,heading:n,instanceId:a})=>{const s=`h${t}`;return(0,o.createElement)(s,{className:e},(0,o.createElement)("label",{className:"screen-reader-text",htmlFor:`block-title-${a}`},(0,m.__)("Block title","woocommerce")),(0,o.createElement)(l.PlainText,{id:`block-title-${a}`,className:"wc-block-editor-components-title",value:n,onChange:r,style:{backgroundColor:"transparent"}}))}));var F=r(9127),B=r.n(F);function j(e){const t=(0,d.useRef)(e);return B()(e,t.current)||(t.current=e),t.current}const q=window.wc.wcBlocksData,$=window.wp.data,D=(0,d.createContext)("page"),G=()=>(0,d.useContext)(D),V=(D.Provider,e=>{const t=G();e=e||t;const r=(0,$.useSelect)((t=>t(q.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0)),[e]),{setValueForQueryContext:o}=(0,$.useDispatch)(q.QUERY_STATE_STORE_KEY);return[r,(0,d.useCallback)((t=>{o(e,t)}),[e,o])]}),Z=(e,t,r)=>{const o=G();r=r||o;const n=(0,$.useSelect)((o=>o(q.QUERY_STATE_STORE_KEY).getValueForQueryKey(r,e,t)),[r,e]),{setQueryValue:l}=(0,$.useDispatch)(q.QUERY_STATE_STORE_KEY);return[n,(0,d.useCallback)((t=>{l(r,e,t)}),[r,e,l])]},Q=e=>{const{namespace:t,resourceName:r,resourceValues:o=[],query:n={},shouldSelect:l=!0}=e;if(!t||!r)throw new Error("The options object must have valid values for the namespace and the resource properties.");const a=(0,d.useRef)({results:[],isLoading:!0}),s=j(n),c=j(o),i=(()=>{const[,e]=(0,d.useState)();return(0,d.useCallback)((t=>{e((()=>{throw t}))}),[])})(),u=(0,$.useSelect)((e=>{if(!l)return null;const o=e(q.COLLECTIONS_STORE_KEY),n=[t,r,s,c],a=o.getCollectionError(...n);if(a){if(!(a instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");i(a)}return{results:o.getCollection(...n),isLoading:!o.hasFinishedResolution("getCollection",n)}}),[t,r,c,s,l]);return null!==u&&(a.current=u),a.current};var U=r(2600);function M(e,t){return!(e=>null===e)(r=e)&&r instanceof Object&&r.constructor===Object&&t in e;var r}const Y=window.wc.blocksComponents;r(479);const W=({name:e,count:t})=>(0,o.createElement)(o.Fragment,null,e,null!==t&&Number.isFinite(t)&&(0,o.createElement)(Y.Label,{label:t.toString(),screenReaderLabel:(0,m.sprintf)(/* translators: %s number of products. */ /* translators: %s number of products. */
(0,m._n)("%s product","%s products",t,"woocommerce"),t),wrapperElement:"span",wrapperProps:{className:"wc-filter-element-label-list-count"}}));r(2728);const K=({className:e,
/* translators: Reset button text for filters. */
label:t=(0,m.__)("Reset","woocommerce"),onClick:r,screenReaderLabel:n=(0,m.__)("Reset filter","woocommerce")})=>(0,o.createElement)("button",{className:i()("wc-block-components-filter-reset-button",e),onClick:r},(0,o.createElement)(Y.Label,{label:t,screenReaderLabel:n}));r(6099);const z=({className:e,isLoading:t,disabled:r,
/* translators: Submit button text for filters. */
label:n=(0,m.__)("Apply","woocommerce"),onClick:l,screenReaderLabel:a=(0,m.__)("Apply filter","woocommerce")})=>(0,o.createElement)("button",{type:"submit",className:i()("wp-block-button__link","wc-block-filter-submit-button","wc-block-components-filter-submit-button",{"is-loading":t},e),disabled:r,onClick:l},(0,o.createElement)(Y.Label,{label:n,screenReaderLabel:a})),H=window.wp.url,J=e=>"boolean"==typeof e,X=e=>"string"==typeof e,ee=e=>M(e,"attribute")&&M(e,"operator")&&M(e,"slug")&&"string"==typeof e.attribute&&"string"==typeof e.operator&&Array.isArray(e.slug)&&e.slug.every((e=>"string"==typeof e));var te=r(7642);const re=(0,R.getSettingWithCoercion)("isRenderingPhpTemplate",!1,J),oe="query_type_",ne="filter_";function le(e){re?((e=e.replace(/(?:query-(?:\d+-)?page=(\d+))|(?:page\/(\d+))/g,"")).endsWith("?")&&(e=e.slice(0,-1)),window.location.href=e):window.history.replaceState({},"",e)}var ae=r(1394);r(9027);const se=({className:e,style:t,suggestions:r,multiple:n=!0,saveTransform:l=(e=>e.trim().replace(/\s/g,"-")),messages:a={},validateInput:s=(e=>r.includes(e)),label:c="",...u})=>(0,o.createElement)("div",{className:i()("wc-blocks-components-form-token-field-wrapper",e,{"single-selection":!n}),style:t},(0,o.createElement)(ae.Z,{label:c,__experimentalExpandOnFocus:!0,__experimentalShowHowTo:!1,__experimentalValidateInput:s,saveTransform:l,maxLength:n?void 0:1,suggestions:r,messages:a,...u}));r(1753);const ce=({children:e})=>(0,o.createElement)("div",{className:"wc-block-filter-title-placeholder"},e),ie=(0,R.getSetting)("attributes",[]).reduce(((e,t)=>{const r=(o=t)&&o.attribute_name?{id:parseInt(o.attribute_id,10),name:o.attribute_name,taxonomy:"pa_"+o.attribute_name,label:o.attribute_label}:null;var o;return r&&r.id&&e.push(r),e}),[]),ue=(e=[],t,r,o=[],n="in")=>{if(!r||!r.taxonomy)return[];const l=e.filter((e=>e.attribute!==r.taxonomy));return 0===o.length?t(l):(l.push({attribute:r.taxonomy,operator:n,slug:o.map((({slug:e})=>e)).sort()}),t((0,u.DY)(l).asc("attribute"))),l},me=[{value:"preview-1",formattedValue:"preview-1",name:"Blue",label:(0,o.createElement)(W,{name:"Blue",count:3}),textLabel:"Blue (3)"},{value:"preview-2",formattedValue:"preview-2",name:"Green",label:(0,o.createElement)(W,{name:"Green",count:3}),textLabel:"Green (3)"},{value:"preview-3",formattedValue:"preview-3",name:"Red",label:(0,o.createElement)(W,{name:"Red",count:2}),textLabel:"Red (2)"}],de={count:0,has_archives:!0,id:0,label:"Preview",name:"preview",order:"menu_order",parent:0,taxonomy:"preview",type:""};function pe(){return Math.floor(Math.random()*Date.now())}r(3106);const be=e=>e.replace("pa_",""),ge=(e,t=[])=>{const r={};t.forEach((e=>{const{attribute:t,slug:o,operator:n}=e,l=be(t),a=o.join(","),s=`${oe}${l}`,c="in"===n?"or":"and";r[`${ne}${l}`]=a,r[s]=c}));const o=(0,H.removeQueryArgs)(e,...Object.keys(r));return(0,H.addQueryArgs)(o,r)},_e=e=>{if(e){const r=(t=`filter_${e.name}`,window?(0,H.getQueryArg)(window.location.href,t):null);return("string"==typeof r?r.split(","):[]).map((e=>encodeURIComponent(e).toLowerCase()))}var t;return[]},he=e=>e.trim().replace(/\s/g,"-").replace(/_/g,"-").replace(/-+/g,"-").replace(/[^a-zA-Z0-9-]/g,""),we=({isLoading:e=!1,options:t,checked:r,onChange:n})=>e?(0,o.createElement)(o.Fragment,null,(0,o.createElement)("span",{className:"is-loading"}),(0,o.createElement)("span",{className:"is-loading"})):(0,o.createElement)(Y.CheckboxList,{className:"wc-block-attribute-filter-list",options:t,checked:r,onChange:n,isLoading:e,isDisabled:e}),fe=(0,d.createContext)({}),ye=({attributes:e,isEditor:t=!1,getNotice:r=(()=>null)})=>{const n=(0,R.getSettingWithCoercion)("hasFilterableProducts",!1,J),l=(0,R.getSettingWithCoercion)("isRenderingPhpTemplate",!1,J),s=(0,R.getSettingWithCoercion)("pageUrl",window.location.href,X),[c,p]=(0,d.useState)(!1),b=e.isPreview&&!e.attributeId?de:(e=>{if(e)return ie.find((t=>t.id===e))})(e.attributeId),g=(0,d.useMemo)((()=>_e(b)),[b]),[_,h]=(0,d.useState)(g),[w,f]=(0,d.useState)(pe()),[y,v]=(0,d.useState)(e.isPreview&&!e.attributeId?me:[]),[k]=V(),[S,C]=Z("attributes",[]),{results:x,isLoading:N}=Q({namespace:"/wc/store/v1",resourceName:"products/attributes/terms",resourceValues:[(null==b?void 0:b.id)||0],shouldSelect:e.attributeId>0,query:{orderby:"menu_order"}}),{results:T,isLoading:A}=(({queryAttribute:e,queryPrices:t,queryStock:r,queryRating:o,queryState:n,isEditor:l=!1})=>{let a=G();a=`${a}-collection-data`;const[s]=V(a),[c,i]=Z("calculate_attribute_counts",[],a),[m,p]=Z("calculate_price_range",null,a),[b,g]=Z("calculate_stock_status_counts",null,a),[_,h]=Z("calculate_rating_counts",null,a),w=j(e||{}),f=j(t),y=j(r),E=j(o);(0,d.useEffect)((()=>{"object"==typeof w&&Object.keys(w).length&&(c.find((e=>M(w,"taxonomy")&&e.taxonomy===w.taxonomy))||i([...c,w]))}),[w,c,i]),(0,d.useEffect)((()=>{m!==f&&void 0!==f&&p(f)}),[f,p,m]),(0,d.useEffect)((()=>{b!==y&&void 0!==y&&g(y)}),[y,g,b]),(0,d.useEffect)((()=>{_!==E&&void 0!==E&&h(E)}),[E,h,_]);const[v,k]=(0,d.useState)(l),[S]=(0,U.Nr)(v,200);v||k(!0);const C=(0,d.useMemo)((()=>(e=>{const t=e;return Array.isArray(e.calculate_attribute_counts)&&(t.calculate_attribute_counts=(0,u.DY)(e.calculate_attribute_counts.map((({taxonomy:e,queryType:t})=>({taxonomy:e,query_type:t})))).asc(["taxonomy","query_type"])),t})(s)),[s]);return Q({namespace:"/wc/store/v1",resourceName:"products/collection-data",query:{...n,page:void 0,per_page:void 0,orderby:void 0,order:void 0,...C},shouldSelect:S})})({queryAttribute:{taxonomy:(null==b?void 0:b.taxonomy)||"",queryType:e.queryType},queryState:{...k},isEditor:t}),O=(0,d.useCallback)((e=>M(T,"attribute_counts")&&Array.isArray(T.attribute_counts)?T.attribute_counts.find((({term:t})=>t===e)):null),[T]);(0,d.useEffect)((()=>{if(N||A)return;if(!Array.isArray(x))return;const t=x.map((t=>{const r=O(t.id);if(!(r||_.includes(t.slug)||(n=t.slug,null!=k&&k.attributes&&k.attributes.some((({attribute:e,slug:t=[]})=>e===(null==b?void 0:b.taxonomy)&&t.includes(n))))))return null;var n;const l=r?r.count:0;return{formattedValue:he(t.slug),value:t.slug,name:(0,E.decodeEntities)(t.name),label:(0,o.createElement)(W,{name:(0,E.decodeEntities)(t.name),count:e.showCounts?l:null}),textLabel:e.showCounts?`${(0,E.decodeEntities)(t.name)} (${l})`:(0,E.decodeEntities)(t.name)}})).filter((e=>!!e));v(t),f(pe())}),[null==b?void 0:b.taxonomy,x,N,e.showCounts,A,O,_,k.attributes]);const P=(0,d.useCallback)((e=>Array.isArray(x)?x.reduce(((t,r)=>(e.includes(r.slug)&&t.push(r),t)),[]):[]),[x]),L=(0,d.useCallback)(((e,t=!1)=>{if(e=e.map((e=>({...e,slug:e.slug.map((e=>decodeURIComponent(e)))}))),t){if(null==b||!b.taxonomy)return;const t=Object.keys((0,H.getQueryArgs)(window.location.href)),r=be(b.taxonomy),o=t.reduce(((e,t)=>t.includes(oe+r)||t.includes(ne+r)?(0,H.removeQueryArgs)(e,t):e),window.location.href);le(ge(o,e))}else{const t=ge(s,e);((e,t)=>{const r=Object.entries(t).reduce(((e,[t,r])=>t.includes("query_type")?e:{...e,[t]:r}),{});return Object.entries(r).reduce(((t,[r,o])=>e[r]===o&&t),!0)})((0,H.getQueryArgs)(window.location.href),(0,H.getQueryArgs)(t))||le(t)}}),[s,null==b?void 0:b.taxonomy]),I=t=>{const r=ue(S,C,b,P(t),"or"===e.queryType?"in":"and");L(r,0===t.length)},F=(0,d.useCallback)(((r,o=!1)=>{t||(h(r),!o&&e.showFilterButton||ue(S,C,b,P(r),"or"===e.queryType?"in":"and"))}),[t,h,S,C,b,P,e.queryType,e.showFilterButton]),q=j((0,d.useMemo)((()=>{return e=S,Array.isArray(e)&&e.every(ee)?S.filter((({attribute:e})=>e===(null==b?void 0:b.taxonomy))).flatMap((({slug:e})=>e)):[];var e}),[S,null==b?void 0:b.taxonomy])),$=function(e,t){const r=(0,d.useRef)();return(0,d.useEffect)((()=>{r.current===e||(r.current=e)}),[e,t]),r.current}(q);(0,d.useEffect)((()=>{!$||B()($,q)||B()(_,q)||F(q)}),[_,q,$,F]);const D="single"!==e.selectType,Y=(0,d.useCallback)((e=>{const t=_.includes(e);let r;D?(r=_.filter((t=>t!==e)),t||(r.push(e),r.sort())):r=t?[]:[e],F(r)}),[_,D,F]);(0,d.useEffect)((()=>{b&&!e.showFilterButton&&((({currentCheckedFilters:e,hasSetFilterDefaultsFromUrl:t})=>t&&0===e.length)({currentCheckedFilters:_,hasSetFilterDefaultsFromUrl:c})?L(S,!0):L(S,!1))}),[c,L,S,b,_,e.showFilterButton]),(0,d.useEffect)((()=>{if(!c&&!N)return g.length>0?(p(!0),void F(g,!0)):void(l||p(!0))}),[b,c,N,F,g,l]);const re=(()=>{const{wrapper:e}=(0,d.useContext)(fe);return t=>{e&&e.current&&(e.current.hidden=!t)}})();if(!n)return re(!1),null;if(!b)return t?r("noAttributes"):(re(!1),null);if(0===y.length&&!N&&t)return r("noProducts");const ae=`h${e.headingLevel}`,ye=!e.isPreview&&N,Ee=!e.isPreview&&A,ve=(ye||Ee)&&0===y.length;if(!ve&&0===y.length)return re(!1),null;const ke=D?!ve&&_.length<y.length:!ve&&0===_.length,Se=(0,o.createElement)(ae,{className:"wc-block-attribute-filter__title"},e.heading),Ce=ve?(0,o.createElement)(ce,null,Se):Se;return re(!0),(0,o.createElement)(o.Fragment,null,!t&&e.heading&&Ce,(0,o.createElement)("div",{className:i()("wc-block-attribute-filter",`style-${e.displayStyle}`)},"dropdown"===e.displayStyle?(0,o.createElement)(o.Fragment,null,(0,o.createElement)(se,{key:w,className:i()({"single-selection":!D,"is-loading":ve}),suggestions:y.filter((e=>!_.includes(e.value))).map((e=>e.formattedValue)),disabled:ve,placeholder:(0,m.sprintf)(/* translators: %s attribute name. */ /* translators: %s attribute name. */
(0,m.__)("Select %s","woocommerce"),b.label),onChange:e=>{!D&&e.length>1&&(e=[e[e.length-1]]);const t=[e=e.map((e=>{const t=y.find((t=>t.formattedValue===e));return t?t.value:e})),_].reduce(((e,t)=>e.filter((e=>!t.includes(e)))));if(1===t.length)return Y(t[0]);const r=[_,e].reduce(((e,t)=>e.filter((e=>!t.includes(e)))));1===r.length&&Y(r[0])},value:_,displayTransform:e=>{const t=y.find((t=>[t.value,t.formattedValue].includes(e)));return t?t.textLabel:e},saveTransform:he,messages:{added:(0,m.sprintf)(/* translators: %s is the attribute label. */ /* translators: %s is the attribute label. */
(0,m.__)("%s filter added.","woocommerce"),b.label),removed:(0,m.sprintf)(/* translators: %s is the attribute label. */ /* translators: %s is the attribute label. */
(0,m.__)("%s filter removed.","woocommerce"),b.label),remove:(0,m.sprintf)(/* translators: %s is the attribute label. */ /* translators: %s is the attribute label. */
(0,m.__)("Remove %s filter.","woocommerce"),b.label.toLocaleLowerCase()),__experimentalInvalid:(0,m.sprintf)(/* translators: %s is the attribute label. */ /* translators: %s is the attribute label. */
(0,m.__)("Invalid %s filter.","woocommerce"),b.label.toLocaleLowerCase())}}),ke&&(0,o.createElement)(a.Z,{icon:te.Z,size:30})):(0,o.createElement)(we,{options:y,checked:_,onChange:Y,isLoading:ve,isDisabled:ve})),(0,o.createElement)("div",{className:"wc-block-attribute-filter__actions"},(_.length>0||t)&&!ve&&(0,o.createElement)(K,{onClick:()=>{h([]),f(pe()),c&&I([])},screenReaderLabel:(0,m.__)("Reset attribute filter","woocommerce")}),e.showFilterButton&&(0,o.createElement)(z,{className:"wc-block-attribute-filter__button",isLoading:ve,disabled:(()=>{if(ye||Ee)return!0;const e=_e(b);return e.length===_.length&&_.every((t=>e.includes(t)))})(),onClick:()=>I(_)})))};r(3275);const Ee=({clientId:e,setAttributes:t,filterType:r,attributes:a})=>{const{replaceBlock:s}=(0,$.useDispatch)("core/block-editor"),{heading:c,headingLevel:i}=a;if((0,$.useSelect)((t=>{const{getBlockParentsByBlockName:r}=t("core/block-editor");return r(e,"woocommerce/filter-wrapper").length>0}),[e])||!r)return null;const u=[(0,o.createElement)(b.Button,{key:"convert",onClick:()=>{const o=[(0,n.createBlock)(`woocommerce/${r}`,{...a,heading:""})];c&&""!==c&&o.unshift((0,n.createBlock)("core/heading",{content:c,level:null!=i?i:2})),s(e,(0,n.createBlock)("woocommerce/filter-wrapper",{heading:c,filterType:r},[...o])),t({heading:"",lock:{remove:!0}})},variant:"primary"},(0,m.__)("Upgrade block","woocommerce"))];return(0,o.createElement)(l.Warning,{actions:u},(0,m.__)("Filter block: We have improved this block to make styling easier. Upgrade it using the button below.","woocommerce"))},ve=(0,R.getSetting)("attributes",[]),ke={noAttributes:(0,m.__)("Please select an attribute to use this filter!","woocommerce"),noProducts:(0,m.__)("There are no products with the selected attributes.","woocommerce")},Se=e=>{const t=ke[e];return t?(0,o.createElement)(b.Notice,{status:"warning",isDismissible:!1},(0,o.createElement)("p",null,t)):null},Ce=(0,b.withSpokenMessages)((({attributes:e,setAttributes:t,debouncedSpeak:r,clientId:n})=>{const{attributeId:c,displayStyle:g,heading:_,headingLevel:h,isPreview:w,queryType:f,showCounts:y,showFilterButton:E,selectType:v}=e,[k,S]=(0,d.useState)(!c&&!w),C=(0,l.useBlockProps)(),x=e=>{if(!e||!e.length)return;const r=e[0].id;ve.find((e=>e.attribute_id===r.toString()))&&c!==r&&t({attributeId:r})},N=({isCompact:e})=>{const t={clear:(0,m.__)("Clear selected attribute","woocommerce"),list:(0,m.__)("Product Attributes","woocommerce"),noItems:(0,m.__)("Your store doesn't have any product attributes.","woocommerce"),search:(0,m.__)("Search for a product attribute:","woocommerce"),selected:e=>(0,m.sprintf)(/* translators: %d is the number of attributes selected. */ /* translators: %d is the number of attributes selected. */
(0,m._n)("%d attribute selected","%d attributes selected",e,"woocommerce"),e),updated:(0,m.__)("Product attribute search results updated.","woocommerce")},r=(0,u.DY)(ve.map((e=>({id:parseInt(e.attribute_id,10),name:e.attribute_label})))).asc("name");return(0,o.createElement)(L,{className:"woocommerce-product-attributes",list:r,selected:r.filter((({id:e})=>e===c)),onChange:x,messages:t,isSingle:!0,isCompact:e})};return 0===Object.keys(ve).length?(0,o.createElement)(b.Placeholder,{className:"wc-block-attribute-filter",icon:(0,o.createElement)(a.Z,{icon:s.Z}),label:(0,m.__)("Filter by Attribute","woocommerce"),instructions:(0,m.__)("Display a list of filters based on the selected attributes.","woocommerce")},(0,o.createElement)("p",null,(0,m.__)("Attributes are needed for filtering your products. You haven't created any attributes yet.","woocommerce")),(0,o.createElement)(b.Button,{className:"wc-block-attribute-filter__add-attribute-button",variant:"secondary",href:(0,R.getAdminLink)("edit.php?post_type=product&page=product_attributes"),target:"_top"},(0,m.__)("Add new attribute","woocommerce")+" ",(0,o.createElement)(a.Z,{icon:p.Z})),(0,o.createElement)(b.Button,{className:"wc-block-attribute-filter__read_more_button",variant:"tertiary",href:"https://docs.woocommerce.com/document/managing-product-taxonomies/",target:"_blank"},(0,m.__)("Learn more","woocommerce"))):(0,o.createElement)("div",{...C},(0,o.createElement)(l.BlockControls,null,(0,o.createElement)(b.ToolbarGroup,{controls:[{icon:"edit",title:(0,m.__)("Edit","woocommerce"),onClick:()=>S(!k),isActive:k}]})),(0,o.createElement)(l.InspectorControls,{key:"inspector"},(0,o.createElement)(b.PanelBody,{title:(0,m.__)("Display Settings","woocommerce")},(0,o.createElement)(b.ToggleControl,{label:(0,m.__)("Display product count","woocommerce"),checked:y,onChange:()=>t({showCounts:!y})}),(0,o.createElement)(b.__experimentalToggleGroupControl,{label:(0,m.__)("Allow selecting multiple options?","woocommerce"),value:v||"multiple",onChange:e=>t({selectType:e}),className:"wc-block-attribute-filter__multiple-toggle"},(0,o.createElement)(b.__experimentalToggleGroupControlOption,{value:"multiple",label:(0,m.__)("Multiple","woocommerce")}),(0,o.createElement)(b.__experimentalToggleGroupControlOption,{value:"single",label:(0,m.__)("Single","woocommerce")})),"multiple"===v&&(0,o.createElement)(b.__experimentalToggleGroupControl,{label:(0,m.__)("Filter Conditions","woocommerce"),help:"and"===f?(0,m.__)("Choose to return filter results for all of the attributes selected.","woocommerce"):(0,m.__)("Choose to return filter results for any of the attributes selected.","woocommerce"),value:f,onChange:e=>t({queryType:e}),className:"wc-block-attribute-filter__conditions-toggle"},(0,o.createElement)(b.__experimentalToggleGroupControlOption,{value:"and",label:(0,m.__)("All","woocommerce")}),(0,o.createElement)(b.__experimentalToggleGroupControlOption,{value:"or",label:(0,m.__)("Any","woocommerce")})),(0,o.createElement)(b.__experimentalToggleGroupControl,{label:(0,m.__)("Display Style","woocommerce"),value:g,onChange:e=>t({displayStyle:e}),className:"wc-block-attribute-filter__display-toggle"},(0,o.createElement)(b.__experimentalToggleGroupControlOption,{value:"list",label:(0,m.__)("List","woocommerce")}),(0,o.createElement)(b.__experimentalToggleGroupControlOption,{value:"dropdown",label:(0,m.__)("Dropdown","woocommerce")})),(0,o.createElement)(b.ToggleControl,{label:(0,m.__)("Show 'Apply filters' button","woocommerce"),help:(0,m.__)("Products will update when the button is clicked.","woocommerce"),checked:E,onChange:e=>t({showFilterButton:e})})),(0,o.createElement)(b.PanelBody,{title:(0,m.__)("Content Settings","woocommerce"),initialOpen:!1},N({isCompact:!0}))),(0,o.createElement)(Ee,{clientId:n,attributes:e,setAttributes:t,filterType:"attribute-filter"}),k?(0,o.createElement)(b.Placeholder,{className:"wc-block-attribute-filter",icon:(0,o.createElement)(a.Z,{icon:s.Z}),label:(0,m.__)("Filter by Attribute","woocommerce")},(0,o.createElement)("div",{className:"wc-block-attribute-filter__instructions"},(0,m.__)("Display a list of filters based on the selected attributes.","woocommerce")),(0,o.createElement)("div",{className:"wc-block-attribute-filter__selection"},N({isCompact:!1}),(0,o.createElement)(b.Button,{variant:"primary",onClick:()=>{S(!1),r((0,m.__)("Now displaying a preview of the Filter Products by Attribute block.","woocommerce"))}},(0,m.__)("Done","woocommerce")))):(0,o.createElement)("div",{className:i()("wc-block-attribute-filter")},_&&(0,o.createElement)(I,{className:"wc-block-attribute-filter__title",headingLevel:h,heading:_,onChange:e=>t({heading:e})}),(0,o.createElement)(b.Disabled,null,(0,o.createElement)(ye,{attributes:e,isEditor:!0,getNotice:Se}))))})),xe={heading:{type:"string",default:(0,m.__)("Filter by attribute","woocommerce")}},Ne=JSON.parse('{"name":"woocommerce/attribute-filter","version":"1.0.0","title":"Filter by Attribute Controls","description":"Enable customers to filter the product grid by selecting one or more attributes, such as color.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"html":false,"color":{"text":true,"background":false},"inserter":false,"lock":false},"attributes":{"className":{"type":"string","default":""},"attributeId":{"type":"number","default":0},"showCounts":{"type":"boolean","default":false},"queryType":{"type":"string","default":"or"},"headingLevel":{"type":"number","default":3},"displayStyle":{"type":"string","default":"list"},"showFilterButton":{"type":"boolean","default":false},"selectType":{"type":"string","default":"multiple"},"isPreview":{"type":"boolean","default":false}},"textdomain":"woocommerce","apiVersion":2,"$schema":"https://schemas.wp.org/trunk/block.json"}');var Te,Ae,Oe,Pe,Le,Re,Ie,Fe,Be,je;const qe=(0,R.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),$e=(qe.pluginUrl,qe.pluginUrl,qe.buildPhase),De=(null===(Te=R.STORE_PAGES.shop)||void 0===Te||Te.permalink,null===(Ae=R.STORE_PAGES.checkout)||void 0===Ae||Ae.id,null===(Oe=R.STORE_PAGES.checkout)||void 0===Oe||Oe.permalink,null===(Pe=R.STORE_PAGES.privacy)||void 0===Pe||Pe.permalink,null===(Le=R.STORE_PAGES.privacy)||void 0===Le||Le.title,null===(Re=R.STORE_PAGES.terms)||void 0===Re||Re.permalink,null===(Ie=R.STORE_PAGES.terms)||void 0===Ie||Ie.title,null===(Fe=R.STORE_PAGES.cart)||void 0===Fe||Fe.id,null===(Be=R.STORE_PAGES.cart)||void 0===Be||Be.permalink,null!==(je=R.STORE_PAGES.myaccount)&&void 0!==je&&je.permalink?R.STORE_PAGES.myaccount.permalink:(0,R.getSetting)("wpLoginUrl","/wp-login.php"),(0,R.getSetting)("localPickupEnabled",!1),(0,R.getSetting)("countries",{})),Ge=(0,R.getSetting)("countryData",{}),Ve=(Object.fromEntries(Object.keys(Ge).filter((e=>!0===Ge[e].allowBilling)).map((e=>[e,De[e]||""]))),Object.fromEntries(Object.keys(Ge).filter((e=>!0===Ge[e].allowBilling)).map((e=>[e,Ge[e].states||[]]))),Object.fromEntries(Object.keys(Ge).filter((e=>!0===Ge[e].allowShipping)).map((e=>[e,De[e]||""]))),Object.fromEntries(Object.keys(Ge).filter((e=>!0===Ge[e].allowShipping)).map((e=>[e,Ge[e].states||[]]))),Object.fromEntries(Object.keys(Ge).map((e=>[e,Ge[e].locale||[]]))),{address:["first_name","last_name","company","address_1","address_2","city","postcode","country","state","phone"],contact:["email"],additional:[]}),Ze=((0,R.getSetting)("addressFieldsLocations",Ve).address,(0,R.getSetting)("addressFieldsLocations",Ve).contact,(0,R.getSetting)("addressFieldsLocations",Ve).additional,[{supports:{...Ne.supports,...$e>1&&{__experimentalBorder:{radius:!1,color:!0,width:!1}}},attributes:{...Ne.attributes,showCounts:{type:"boolean",default:!0},...xe},save:({attributes:e})=>{const{className:t,showCounts:r,queryType:n,attributeId:a,heading:s,headingLevel:c,displayStyle:u,showFilterButton:m,selectType:d}=e,p={"data-attribute-id":a,"data-show-counts":r,"data-query-type":n,"data-heading":s,"data-heading-level":c};return"list"!==u&&(p["data-display-style"]=u),m&&(p["data-show-filter-button"]=m),"single"===d&&(p["data-select-type"]=d),(0,o.createElement)("div",{...l.useBlockProps.save({className:i()("is-loading",t)}),...p},(0,o.createElement)("span",{"aria-hidden":!0,className:"wc-block-product-attribute-filter__placeholder"}))}}]);(0,n.registerBlockType)(Ne,{icon:{src:(0,o.createElement)(a.Z,{icon:s.Z,className:"wc-block-editor-components-block-icon"})},supports:{...Ne.supports},attributes:{...Ne.attributes,...xe},edit:Ce,save({attributes:e}){const{className:t}=e;return(0,o.createElement)("div",{...l.useBlockProps.save({className:i()("is-loading",t)})})},deprecated:Ze})},479:()=>{},1753:()=>{},2728:()=>{},6099:()=>{},9027:()=>{},3275:()=>{},3106:()=>{},9578:()=>{},9658:()=>{},1058:()=>{},9196:e=>{"use strict";e.exports=window.React},2819:e=>{"use strict";e.exports=window.lodash},5158:e=>{"use strict";e.exports=window.wp.a11y},4333:e=>{"use strict";e.exports=window.wp.compose},7180:e=>{"use strict";e.exports=window.wp.deprecated},5904:e=>{"use strict";e.exports=window.wp.dom},9307:e=>{"use strict";e.exports=window.wp.element},5736:e=>{"use strict";e.exports=window.wp.i18n},9127:e=>{"use strict";e.exports=window.wp.isShallowEqual},9630:e=>{"use strict";e.exports=window.wp.keycodes},444:e=>{"use strict";e.exports=window.wp.primitives},2560:e=>{"use strict";e.exports=window.wp.warning}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var l=r[e]={exports:{}};return t[e].call(l.exports,l,l.exports,o),l.exports}o.m=t,e=[],o.O=(t,r,n,l)=>{if(!r){var a=1/0;for(u=0;u<e.length;u++){for(var[r,n,l]=e[u],s=!0,c=0;c<r.length;c++)(!1&l||a>=l)&&Object.keys(o.O).every((e=>o.O[e](r[c])))?r.splice(c--,1):(s=!1,l<a&&(a=l));if(s){e.splice(u--,1);var i=n();void 0!==i&&(t=i)}}return t}l=l||0;for(var u=e.length;u>0&&e[u-1][2]>l;u--)e[u]=e[u-1];e[u]=[r,n,l]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.j=3259,(()=>{var e={3259:0};o.O.j=t=>0===e[t];var t=(t,r)=>{var n,l,[a,s,c]=r,i=0;if(a.some((t=>0!==e[t]))){for(n in s)o.o(s,n)&&(o.m[n]=s[n]);if(c)var u=c(o)}for(t&&t(r);i<a.length;i++)l=a[i],o.o(e,l)&&e[l]&&e[l][0](),e[l]=0;return o.O(u)},r=self.webpackChunkwebpackWcBlocksJsonp=self.webpackChunkwebpackWcBlocksJsonp||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var n=o.O(void 0,[2869],(()=>o(9281)));n=o.O(n),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["attribute-filter"]=n})();