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 |
Dir : /home/trave494/footcrew.com/wp-content/plugins/woocommerce/assets/client/blocks/stock-filter.js |
(()=>{var e,t={3865:(e,t,o)=>{"use strict";o.r(t);var r=o(9196);const l=window.wp.blocks;var n=o(2911),s=o(1918),c=o(3849),a=o.n(c);const i=window.wp.blockEditor;var u=o(5736),d=o(4333);o(9578);const m=(0,d.withInstanceId)((({className:e,headingLevel:t,onChange:o,heading:l,instanceId:n})=>{const s=`h${t}`;return(0,r.createElement)(s,{className:e},(0,r.createElement)("label",{className:"screen-reader-text",htmlFor:`block-title-${n}`},(0,u.__)("Block title","woocommerce")),(0,r.createElement)(i.PlainText,{id:`block-title-${n}`,className:"wc-block-editor-components-title",value:l,onChange:o,style:{backgroundColor:"transparent"}}))})),p=window.wp.components;var w=o(5158),g=o(7642),f=o(9307),b=o(9127),_=o.n(b);function h(e){const t=(0,f.useRef)(e);return _()(e,t.current)||(t.current=e),t.current}const k=window.wc.wcBlocksData,v=window.wp.data,y=(0,f.createContext)("page"),E=()=>(0,f.useContext)(y),S=(y.Provider,e=>{const t=E();e=e||t;const o=(0,v.useSelect)((t=>t(k.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0)),[e]),{setValueForQueryContext:r}=(0,v.useDispatch)(k.QUERY_STATE_STORE_KEY);return[o,(0,f.useCallback)((t=>{r(e,t)}),[e,r])]}),C=(e,t,o)=>{const r=E();o=o||r;const l=(0,v.useSelect)((r=>r(k.QUERY_STATE_STORE_KEY).getValueForQueryKey(o,e,t)),[o,e]),{setQueryValue:n}=(0,v.useDispatch)(k.QUERY_STATE_STORE_KEY);return[l,(0,f.useCallback)((t=>{n(o,e,t)}),[o,e,n])]};var x=o(2600);function T(e,t){return!(e=>null===e)(o=e)&&o instanceof Object&&o.constructor===Object&&t in e;var o}var O=o(4167);const N=({queryAttribute:e,queryPrices:t,queryStock:o,queryRating:r,queryState:l,isEditor:n=!1})=>{let s=E();s=`${s}-collection-data`;const[c]=S(s),[a,i]=C("calculate_attribute_counts",[],s),[u,d]=C("calculate_price_range",null,s),[m,p]=C("calculate_stock_status_counts",null,s),[w,g]=C("calculate_rating_counts",null,s),b=h(e||{}),_=h(t),y=h(o),N=h(r);(0,f.useEffect)((()=>{"object"==typeof b&&Object.keys(b).length&&(a.find((e=>T(b,"taxonomy")&&e.taxonomy===b.taxonomy))||i([...a,b]))}),[b,a,i]),(0,f.useEffect)((()=>{u!==_&&void 0!==_&&d(_)}),[_,d,u]),(0,f.useEffect)((()=>{m!==y&&void 0!==y&&p(y)}),[y,p,m]),(0,f.useEffect)((()=>{w!==N&&void 0!==N&&g(N)}),[N,g,w]);const[L,R]=(0,f.useState)(n),[A]=(0,x.Nr)(L,200);L||R(!0);const B=(0,f.useMemo)((()=>(e=>{const t=e;return Array.isArray(e.calculate_attribute_counts)&&(t.calculate_attribute_counts=(0,O.DY)(e.calculate_attribute_counts.map((({taxonomy:e,queryType:t})=>({taxonomy:e,query_type:t})))).asc(["taxonomy","query_type"])),t})(c)),[c]);return(e=>{const{namespace:t,resourceName:o,resourceValues:r=[],query:l={},shouldSelect:n=!0}=e;if(!t||!o)throw new Error("The options object must have valid values for the namespace and the resource properties.");const s=(0,f.useRef)({results:[],isLoading:!0}),c=h(l),a=h(r),i=(()=>{const[,e]=(0,f.useState)();return(0,f.useCallback)((t=>{e((()=>{throw t}))}),[])})(),u=(0,v.useSelect)((e=>{if(!n)return null;const r=e(k.COLLECTIONS_STORE_KEY),l=[t,o,c,a],s=r.getCollectionError(...l);if(s){if(!(s instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");i(s)}return{results:r.getCollection(...l),isLoading:!r.hasFinishedResolution("getCollection",l)}}),[t,o,a,c,n]);return null!==u&&(s.current=u),s.current})({namespace:"/wc/store/v1",resourceName:"products/collection-data",query:{...l,page:void 0,per_page:void 0,orderby:void 0,order:void 0,...B},shouldSelect:A})},L=window.wc.wcSettings,R=window.wc.blocksComponents;o(6099);const A=({className:e,isLoading:t,disabled:o, /* translators: Submit button text for filters. */ label:l=(0,u.__)("Apply","woocommerce"),onClick:n,screenReaderLabel:s=(0,u.__)("Apply filter","woocommerce")})=>(0,r.createElement)("button",{type:"submit",className:a()("wp-block-button__link","wc-block-filter-submit-button","wc-block-components-filter-submit-button",{"is-loading":t},e),disabled:o,onClick:n},(0,r.createElement)(R.Label,{label:l,screenReaderLabel:s}));o(2728);const B=({className:e, /* translators: Reset button text for filters. */ label:t=(0,u.__)("Reset","woocommerce"),onClick:o,screenReaderLabel:l=(0,u.__)("Reset filter","woocommerce")})=>(0,r.createElement)("button",{className:a()("wc-block-components-filter-reset-button",e),onClick:o},(0,r.createElement)(R.Label,{label:t,screenReaderLabel:l}));o(1753);const P=({children:e})=>(0,r.createElement)("div",{className:"wc-block-filter-title-placeholder"},e);o(479);const F=({name:e,count:t})=>(0,r.createElement)(r.Fragment,null,e,null!==t&&Number.isFinite(t)&&(0,r.createElement)(R.Label,{label:t.toString(),screenReaderLabel:(0,u.sprintf)(/* translators: %s number of products. */ /* translators: %s number of products. */ (0,u._n)("%s product","%s products",t,"woocommerce"),t),wrapperElement:"span",wrapperProps:{className:"wc-filter-element-label-list-count"}}));var j=o(1394);o(9027);const I=({className:e,style:t,suggestions:o,multiple:l=!0,saveTransform:n=(e=>e.trim().replace(/\s/g,"-")),messages:s={},validateInput:c=(e=>o.includes(e)),label:i="",...u})=>(0,r.createElement)("div",{className:a()("wc-blocks-components-form-token-field-wrapper",e,{"single-selection":!l}),style:t},(0,r.createElement)(j.Z,{label:i,__experimentalExpandOnFocus:!0,__experimentalShowHowTo:!1,__experimentalValidateInput:c,saveTransform:n,maxLength:l?void 0:1,suggestions:o,messages:s,...u})),q=window.wp.htmlEntities,Q=e=>"boolean"==typeof e,D=window.wp.url,M=(0,L.getSettingWithCoercion)("isRenderingPhpTemplate",!1,Q);function Y(e){M?((e=e.replace(/(?:query-(?:\d+-)?page=(\d+))|(?:page\/(\d+))/g,"")).endsWith("?")&&(e=e.slice(0,-1)),window.location.href=e):window.history.replaceState({},"",e)}const $=e=>{const t=(0,D.getQueryArgs)(e);return(0,D.addQueryArgs)(e,t)},W=[{value:"preview-1",name:"In Stock",label:(0,r.createElement)(F,{name:"In Stock",count:3}),textLabel:"In Stock (3)"},{value:"preview-2",name:"Out of stock",label:(0,r.createElement)(F,{name:"Out of stock",count:3}),textLabel:"Out of stock (3)"},{value:"preview-3",name:"On backorder",label:(0,r.createElement)(F,{name:"On backorder",count:2}),textLabel:"On backorder (2)"}];o(2402);function V(){return Math.floor(Math.random()*Date.now())}const G=e=>e.trim().replace(/\s/g,"").replace(/_/g,"-").replace(/-+/g,"-").replace(/[^a-zA-Z0-9-]/g,""),K=(0,f.createContext)({}),U="filter_stock_status",Z=({attributes:e,isEditor:t=!1})=>{const o=(()=>{const{wrapper:e}=(0,f.useContext)(K);return t=>{e&&e.current&&(e.current.hidden=!t)}})(),l=(0,L.getSettingWithCoercion)("isRenderingPhpTemplate",!1,Q),[s,c]=(0,f.useState)(!1),{outofstock:i,...d}=(0,L.getSetting)("stockStatusOptions",{}),m=(0,f.useRef)((0,L.getSetting)("hideOutOfStockItems",!1)?d:{outofstock:i,...d}),p=(0,f.useMemo)((()=>((e,t="filter_stock_status")=>{const o=(r=t,window?(0,D.getQueryArg)(window.location.href,r):null);var r;if(!o)return[];const l="string"==typeof o?o.split(","):o,n=Object.keys(e);return l.filter((e=>n.includes(e)))})(m.current,U)),[]),[b,k]=(0,f.useState)(p),[v,y]=(0,f.useState)(e.isPreview?W:[]),[E]=(0,f.useState)(Object.entries(m.current).map((([e,t])=>({slug:e,name:t}))).filter((e=>!!e.name)).sort(((e,t)=>e.slug.localeCompare(t.slug)))),[x]=S(),[O,j]=C("stock_status",p),{results:M,isLoading:Z}=N({queryStock:!0,queryState:x,isEditor:t}),J=(0,f.useCallback)((e=>T(M,"stock_status_counts")&&Array.isArray(M.stock_status_counts)?M.stock_status_counts.find((({status:t,count:o})=>t===e&&0!==Number(o))):null),[M]),[z,H]=(0,f.useState)(V());(0,f.useEffect)((()=>{if(Z||e.isPreview)return;const t=E.map((t=>{const o=J(t.slug);if(!(o||b.includes(t.slug)||(l=t.slug,null!=x&&x.stock_status&&x.stock_status.some((({status:e=[]})=>e.includes(l))))))return null;var l;const n=o?Number(o.count):0;return{value:t.slug,name:(0,q.decodeEntities)(t.name),label:(0,r.createElement)(F,{name:(0,q.decodeEntities)(t.name),count:e.showCounts?n:null}),textLabel:e.showCounts?`${(0,q.decodeEntities)(t.name)} (${n})`:(0,q.decodeEntities)(t.name)}})).filter((e=>!!e));y(t),H(V())}),[e.showCounts,e.isPreview,Z,J,b,x.stock_status,E]);const X="single"!==e.selectType,ee=(0,f.useCallback)((e=>{t||(e&&!l&&j(e),(e=>{if(!window)return;if(0===e.length){const e=(0,D.removeQueryArgs)(window.location.href,U);return void(e!==$(window.location.href)&&Y(e))}const t=(0,D.addQueryArgs)(window.location.href,{[U]:e.join(",")});t!==$(window.location.href)&&Y(t)})(e))}),[t,j,l]);(0,f.useEffect)((()=>{e.showFilterButton||ee(b)}),[e.showFilterButton,b,ee]);const te=h((0,f.useMemo)((()=>O),[O])),oe=function(e,t){const o=(0,f.useRef)();return(0,f.useEffect)((()=>{o.current===e||(o.current=e)}),[e,t]),o.current}(te);(0,f.useEffect)((()=>{_()(oe,te)||_()(b,te)||k(te)}),[b,te,oe]),(0,f.useEffect)((()=>{s||(j(p),c(!0))}),[j,s,c,p]);const re=(0,f.useCallback)((e=>{const t=e=>{const t=v.find((t=>t.value===e));return t?t.name:null},o=({filterAdded:e,filterRemoved:o})=>{const r=e?t(e):null,l=o?t(o):null;r?(0,w.speak)((0,u.sprintf)(/* translators: %s stock statuses (for example: 'instock'...) */ /* translators: %s stock statuses (for example: 'instock'...) */ (0,u.__)("%s filter added.","woocommerce"),r)):l&&(0,w.speak)((0,u.sprintf)(/* translators: %s stock statuses (for example:'instock'...) */ /* translators: %s stock statuses (for example:'instock'...) */ (0,u.__)("%s filter removed.","woocommerce"),l))},r=b.includes(e);if(!X){const t=r?[]:[e];return o(r?{filterRemoved:e}:{filterAdded:e}),void k(t)}if(r){const t=b.filter((t=>t!==e));return o({filterRemoved:e}),void k(t)}const l=[...b,e].sort();o({filterAdded:e}),k(l)}),[b,X,v]);if(!Z&&0===v.length)return o(!1),null;const le=`h${e.headingLevel}`,ne=!e.isPreview&&!m.current||0===v.length,se=!e.isPreview&&Z;if(!(0,L.getSettingWithCoercion)("hasFilterableProducts",!1,Q))return o(!1),null;const ce=X?!ne&&b.length<v.length:!ne&&0===b.length,ae=(0,r.createElement)(le,{className:"wc-block-stock-filter__title"},e.heading),ie=ne?(0,r.createElement)(P,null,ae):ae;return o(!0),(0,r.createElement)(r.Fragment,null,!t&&e.heading&&ie,(0,r.createElement)("div",{className:a()("wc-block-stock-filter",`style-${e.displayStyle}`,{"is-loading":ne})},"dropdown"===e.displayStyle?(0,r.createElement)(r.Fragment,null,(0,r.createElement)(I,{key:z,className:a()({"single-selection":!X,"is-loading":ne}),suggestions:v.filter((e=>!b.includes(e.value))).map((e=>e.value)),disabled:ne,placeholder:(0,u.__)("Select stock status","woocommerce"),onChange:e=>{!X&&e.length>1&&(e=e.slice(-1));const t=[e=e.map((e=>{const t=v.find((t=>t.value===e));return t?t.value:e})),b].reduce(((e,t)=>e.filter((e=>!t.includes(e)))));if(1===t.length)return re(t[0]);const o=[b,e].reduce(((e,t)=>e.filter((e=>!t.includes(e)))));1===o.length&&re(o[0])},value:b,displayTransform:e=>{const t=v.find((t=>t.value===e));return t?t.textLabel:e},saveTransform:G,messages:{added:(0,u.__)("Stock filter added.","woocommerce"),removed:(0,u.__)("Stock filter removed.","woocommerce"),remove:(0,u.__)("Remove stock filter.","woocommerce"),__experimentalInvalid:(0,u.__)("Invalid stock filter.","woocommerce")}}),ce&&(0,r.createElement)(n.Z,{icon:g.Z,size:30})):(0,r.createElement)(R.CheckboxList,{className:"wc-block-stock-filter-list",options:v,checked:b,onChange:re,isLoading:ne,isDisabled:se})),(0,r.createElement)("div",{className:"wc-block-stock-filter__actions"},(b.length>0||t)&&!ne&&(0,r.createElement)(B,{onClick:()=>{k([]),ee([])},screenReaderLabel:(0,u.__)("Reset stock filter","woocommerce")}),e.showFilterButton&&(0,r.createElement)(A,{className:"wc-block-stock-filter__button",isLoading:ne,disabled:ne||se,onClick:()=>ee(b)})))};o(1205);const J=({clientId:e,setAttributes:t,filterType:o,attributes:n})=>{const{replaceBlock:s}=(0,v.useDispatch)("core/block-editor"),{heading:c,headingLevel:a}=n;if((0,v.useSelect)((t=>{const{getBlockParentsByBlockName:o}=t("core/block-editor");return o(e,"woocommerce/filter-wrapper").length>0}),[e])||!o)return null;const d=[(0,r.createElement)(p.Button,{key:"convert",onClick:()=>{const r=[(0,l.createBlock)(`woocommerce/${o}`,{...n,heading:""})];c&&""!==c&&r.unshift((0,l.createBlock)("core/heading",{content:c,level:null!=a?a:2})),s(e,(0,l.createBlock)("woocommerce/filter-wrapper",{heading:c,filterType:o},[...r])),t({heading:"",lock:{remove:!0}})},variant:"primary"},(0,u.__)("Upgrade block","woocommerce"))];return(0,r.createElement)(i.Warning,{actions:d},(0,u.__)("Filter block: We have improved this block to make styling easier. Upgrade it using the button below.","woocommerce"))},z=(0,p.withSpokenMessages)((({clientId:e,attributes:t,setAttributes:o})=>{const{className:l,heading:n,headingLevel:s,showCounts:c,showFilterButton:d,selectType:w,displayStyle:g}=t,f=(0,i.useBlockProps)({className:a()("wc-block-stock-filter",l)});return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(i.InspectorControls,{key:"inspector"},(0,r.createElement)(p.PanelBody,{title:(0,u.__)("Display Settings","woocommerce")},(0,r.createElement)(p.ToggleControl,{label:(0,u.__)("Display product count","woocommerce"),checked:c,onChange:()=>o({showCounts:!c})}),(0,r.createElement)(p.__experimentalToggleGroupControl,{label:(0,u.__)("Allow selecting multiple options?","woocommerce"),value:w||"multiple",onChange:e=>o({selectType:e}),className:"wc-block-attribute-filter__multiple-toggle"},(0,r.createElement)(p.__experimentalToggleGroupControlOption,{value:"multiple",label:(0,u.__)("Multiple","woocommerce")}),(0,r.createElement)(p.__experimentalToggleGroupControlOption,{value:"single",label:(0,u.__)("Single","woocommerce")})),(0,r.createElement)(p.__experimentalToggleGroupControl,{label:(0,u.__)("Display Style","woocommerce"),value:g,onChange:e=>o({displayStyle:e}),className:"wc-block-attribute-filter__display-toggle"},(0,r.createElement)(p.__experimentalToggleGroupControlOption,{value:"list",label:(0,u.__)("List","woocommerce")}),(0,r.createElement)(p.__experimentalToggleGroupControlOption,{value:"dropdown",label:(0,u.__)("Dropdown","woocommerce")})),(0,r.createElement)(p.ToggleControl,{label:(0,u.__)("Show 'Apply filters' button","woocommerce"),help:(0,u.__)("Products will update when the button is clicked.","woocommerce"),checked:d,onChange:e=>o({showFilterButton:e})}))),(0,r.createElement)(J,{clientId:e,attributes:t,setAttributes:o,filterType:"stock-filter"}),(0,r.createElement)("div",{...f},n&&(0,r.createElement)(m,{className:"wc-block-stock-filter__title",headingLevel:s,heading:n,onChange:e=>o({heading:e})}),(0,r.createElement)(p.Disabled,null,(0,r.createElement)(Z,{attributes:t,isEditor:!0}))))})),H=JSON.parse('{"name":"woocommerce/stock-filter","version":"1.0.0","title":"Filter by Stock Controls","description":"Enable customers to filter the product grid by stock status.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"html":false,"multiple":false,"color":true,"inserter":false,"lock":false},"attributes":{"className":{"type":"string","default":""},"headingLevel":{"type":"number","default":3},"showCounts":{"type":"boolean","default":false},"showFilterButton":{"type":"boolean","default":false},"displayStyle":{"type":"string","default":"list"},"selectType":{"type":"string","default":"multiple"},"isPreview":{"type":"boolean","default":false}},"textdomain":"woocommerce","apiVersion":2,"$schema":"https://schemas.wp.org/trunk/block.json"}'),X={heading:{type:"string",default:(0,u.__)("Filter by stock status","woocommerce")}},ee=[{attributes:{...H.attributes,showCounts:{type:"boolean",default:!0},...X},save:({attributes:e})=>{const{className:t,showCounts:o,heading:l,headingLevel:n,showFilterButton:s}=e,c={"data-show-counts":o,"data-heading":l,"data-heading-level":n};return s&&(c["data-show-filter-button"]=s),(0,r.createElement)("div",{...i.useBlockProps.save({className:a()("is-loading",t)}),...c},(0,r.createElement)("span",{"aria-hidden":!0,className:"wc-block-product-stock-filter__placeholder"}))}}];(0,l.registerBlockType)(H,{icon:{src:(0,r.createElement)(n.Z,{icon:s.Z,className:"wc-block-editor-components-block-icon"})},attributes:{...H.attributes,...X},edit:z,save({attributes:e}){const{className:t}=e;return(0,r.createElement)("div",{...i.useBlockProps.save({className:a()("is-loading",t)})})},deprecated:ee})},479:()=>{},1753:()=>{},2728:()=>{},6099:()=>{},9027:()=>{},1205:()=>{},2402:()=>{},9578:()=>{},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}},o={};function r(e){var l=o[e];if(void 0!==l)return l.exports;var n=o[e]={exports:{}};return t[e].call(n.exports,n,n.exports,r),n.exports}r.m=t,e=[],r.O=(t,o,l,n)=>{if(!o){var s=1/0;for(u=0;u<e.length;u++){for(var[o,l,n]=e[u],c=!0,a=0;a<o.length;a++)(!1&n||s>=n)&&Object.keys(r.O).every((e=>r.O[e](o[a])))?o.splice(a--,1):(c=!1,n<s&&(s=n));if(c){e.splice(u--,1);var i=l();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,l,n]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.j=5050,(()=>{var e={5050:0};r.O.j=t=>0===e[t];var t=(t,o)=>{var l,n,[s,c,a]=o,i=0;if(s.some((t=>0!==e[t]))){for(l in c)r.o(c,l)&&(r.m[l]=c[l]);if(a)var u=a(r)}for(t&&t(o);i<s.length;i++)n=s[i],r.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return r.O(u)},o=self.webpackChunkwebpackWcBlocksJsonp=self.webpackChunkwebpackWcBlocksJsonp||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var l=r.O(void 0,[2869],(()=>r(3865)));l=r.O(l),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["stock-filter"]=l})();