(()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var r in s)e.o(s,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:s[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{YWCAS_RESULTS_VIEW_STORE_KEY:()=>p});var s={};e.r(s),e.d(s,{getCategories:()=>l,getLastQuery:()=>u,getResults:()=>c,getSearchedResults:()=>o});var r={};e.r(r),e.d(r,{CHANGE_QUERYSTRING:()=>y,fetchFromAPI:()=>g,setCategories:()=>d,setSearchedResults:()=>S});const a=window.wp.data,o=e=>e.results,c=e=>e.results,l=e=>e.categories,u=e=>e.lastQuery,i="SET_SEARCHED_RESULTS",n="SET_CATEGORIES",y="CHANGE_QUERYSTRING",S=e=>({type:i,results:e}),d=e=>({type:n,categories:e}),g=e=>({type:"FETCH_FROM_API",path:e}),_={lastQuery:"",results:{totalResults:0,query:"",results:[],relatedContent:{}},categories:[]},C=window.wp.apiFetch;var E=e.n(C);const h=window.ywcas.ywcasSettings,p="yith/store/ywcas-search-view",w={reducer:(e=_,t)=>{let s=e;switch(t.type){case i:s={...e,lastQuery:t.results.query,results:t.results};break;case n:s={...e,categories:t.categories}}return s},selectors:s,actions:r,controls:{FETCH_FROM_API:e=>E()({cache:"no-cache",path:e.path})},resolvers:{*getSearchedResults(e,t=0,s=!1,r=5,a=0,o=!1){if(!o&&(void 0===e||""===e||!h.YWCAS_HAS_AUTOCOMPLETE||e.length<h.YWCAS_MIN_CHARS))return S({totalResults:0,query:"",results:[],relatedContent:{}});let c=`/ywcas/v1/search?query=${e}&lang=${h.YWCAS_LANG}&category=${t}&showCategories=${s}&maxResults=${r}`;c+="&security="+h.YWCAS_NONCE,c+=o?"&test=1":"",a>=0&&(c+="&page="+a);const l=yield g(c);return S(l)},*getCategories(e){const t="/ywcas/v1/categories?type="+e+"&lang="+h.YWCAS_LANG+"&security="+h.YWCAS_NONCE,s=yield g(t);return d(s)}},__experimentalUseThunks:!0},R=(0,a.createReduxStore)(p,w);(0,a.register)(R),(this.ywcas=this.ywcas||{}).ywcasBlocksData=t})();