import{t as e}from"./query-string-RcCSSKcJ.js";import{n as t}from"./axios-fetch-adapter-m8Kx6J-y.js";import{h as n,m as r}from"./cache-hsasTrVL.js";import{n as i,t as a}from"./cookies-BrZOFRUC.js";import{t as o}from"./init-TbIhQyad.js";import{n as s}from"./api-DzB1tprs.js";import{t as c}from"./fetch-BE0PHwMd.js";var l={popup:async e=>s(e),content:async e=>c(e)},u=async(n,i)=>{i||=`popup`;let a=new r(n),o=await a.get();if(o)return o;let s={entry_point:`ShopByPDP`,need_cancel_rate:!0,request_source:`shop_home_page`,shopid:n,version:1},c=e.stringifyUrl({url:`${t}/api/v4/shop/get_shop_base`,query:s}),u=await l[i](c);return u.data&&await a.set(u.data),u.data},d={popup:async e=>s(e),content:async e=>c(e)},f=async(n,i)=>{i||=`popup`;let a=new r(n),o=await a.get();if(o)return o;let s={entry_point:`ShopByPDP`,need_cancel_rate:!0,request_source:`shop_home_page`,username:n,version:1},c=e.stringifyUrl({url:`${t}/api/v4/shop/get_shop_base`,query:s}),l=await d[i](c);return l.data&&await a.set(l.data),l.data},p=async(r,i=40,a=0)=>{let o={bundle:`shop_page_category_tab_main`,shop_id:r,limit:i,offset:0,upstream:`pdp`,step2_upstream:`dd`,sort_type:1,item_card_use_scene:`category_product_list_popular`,version:1};a&&(o.offset=i*a);let c=new n(JSON.stringify(o)),l=await c.get();if(l)return l;let u={listProduct:[],totalProduct:0};try{let n=await s(e.stringifyUrl({url:`${t}/api/v4/shop/rcmd_items`,query:o}));return n.data?(u.totalProduct=n.data.total||0,u.listProduct=n.data.items||[],u.totalProduct&&u.listProduct.length&&await c.set(u),u):u}catch{return u}},m=()=>i(`SPC_F`,t),h=()=>a(t),g=async()=>{let e=await h(),[t,n,r,i]=[`SPC_U`,`SPC_SC_UD`,`SPC_STK`,`SPC_IA`].map(t=>{let n=e.find(({name:e})=>e===t);return n?n.value:``});return!!(t&&!isNaN(t)||n&&!isNaN(n)||r&&r!==`-`||i&&i===`1`)},_=async()=>{try{let e=await o.get(`/api/v2/user/profile/get/`);return e.data?(e.data.shop_id=e.data.shop_id||e.data.shopid,e.data.user_id=e.data.userid||e.data.userid,e.data):null}catch{return null}};export{p as a,g as i,_ as n,f as o,m as r,u as s,h as t};