import{o as e}from"./chunk-mlkTr37E.js";import{t}from"./lodash-DulIlzb9.js";import{u as n}from"./cache-hsasTrVL.js";import{n as r}from"./shop-CjthS7Gw.js";import{t as i}from"./init-QitreBcL.js";var a=async(e={})=>{let t={};e.accountId&&(t.account_id=e.accountId),e.spcCds&&(t.SPC_CDS=e.spcCds);try{let e=await i.get(`/api/selleraccount/subaccount/get/`,{params:t});return e&&!e.code?e:null}catch{return null}},o=async()=>{try{let e=await i.get(`/api/forward/accountservice/v2/shop/`);return e.shop_id?e:null}catch{return null}},s=async()=>{try{let e=await i.get(`/api/selleraccount/shop_info/`);return e.data&&e.data.shop_id?e.data:null}catch{return null}},c=async()=>{try{let e=await i.get(`/api/framework/selleraccount/shop_info/`);return e.data&&e.data.shop_id?e.data:null}catch{return null}},l=async(e=``)=>{try{let t={};return e&&(t.SPC_CDS=e),await i.get(`/api/v2/login/`,{params:t})}catch{return null}},u=async()=>{if(typeof window<`u`&&window?.location?.href?.includes(`shopee.vn`)){let e=await r();if(e&&e.shopid)return{shopId:e.shopid,username:e.username,shopName:e.username,isPrimary:!0,isSubAccount:!1}}let e=await o();if(e&&e.shop_id)return{shopId:e.shop_id,username:e.username,shopName:e.shop_name,isPrimary:!0,isSubAccount:!1};let t=await l();if(t&&t.shopid)return{shopId:t.shopid,username:t.username,shopName:t.username,isPrimary:!1,isSubAccount:!1};let n=await s();if(n&&n.shop_id)return{shopId:n.shop_id,username:n.shop_id.toString(),shopName:n.name,isPrimary:!1,isSubAccount:!0};let i=await c();if(i&&i.shop_id)return{shopId:i.shop_id,username:i.shop_id.toString(),shopName:i.name,isPrimary:!1,isSubAccount:!0};let u=await a();if(u&&u.sub_account_id)return{shopId:u.sub_account_id,username:u.username,shopName:u.shop_name,isPrimary:!1,isSubAccount:!0};throw Error(`Get seller info failed`)},d=e(t()),f=async()=>i.post(`/webchat/api/coreapi/v1.2/mini/login/sc`),p=async(e=``)=>{let t=new n([`logistic`,e].join(`-`)),r=await i.get(`/api/v3/logistics/get_channel_list/`),a=d.default.get(r,`data.list`,[]);return await t.set(a,60),a},m=async(e=``)=>{let t=new n([`warehouse`,e].join(`-`));try{let e=await i.get(`/api/v3/product/get_shop_warehouse/`),n=d.default.get(e,`data.warehouse_list`,[]);return await t.set(n,60),n}catch{return await t.set([]),[]}};export{o as a,u as i,m as n,l as o,f as r,p as t};