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