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