import{t as e}from"./query-string-RcCSSKcJ.js";import{n as t}from"./axios-fetch-adapter-m8Kx6J-y.js";import{c as n}from"./cache-hsasTrVL.js";import{n as r}from"./api-DzB1tprs.js";var i=async(i={},a=50,o=0)=>{let s={order:`desc`,by:`relevancy`,scenario:`PAGE_GLOBAL_SEARCH`,version:2,limit:a,...i};o&&(s.newest=a*o),s.page_type===`search`&&s.keyword&&Number(s.newest)>=500&&(s.scenario=`PAGE_GLOBAL_SEARCH`,s.version=`2`,s.by=`relevancy`);let c=new n(JSON.stringify(s)),l=await c.get();if(l)return l;let u={listProduct:[],totalProduct:0};try{let n=await r(e.stringifyUrl({url:`${t}/api/v4/search/search_items`,query:s}));if(!(n&&n.items))return u;u.listProduct=n.items.map(e=>({...e.item_basic,...e})),u.totalProduct=n.total_count,await c.set(u)}catch{}return u},a=async(e,t=50,n=0)=>i({by:`sales`,match_id:e,order:`desc`,page_type:`search`,scenario:`PAGE_CATEGORY`,source:`SRP`},t,n),o=(e,t=50,n=0)=>i({keyword:e,page_type:`search`,by:`relevancy`,order:`desc`},t,n);export{o as n,a as t};