import{o as e}from"./chunk-mlkTr37E.js";import"./env-B6Bovx8H.js";import{t}from"./lodash-DulIlzb9.js";import{d as n,o as r}from"./cache-hsasTrVL.js";import{n as i}from"./joi-whecr9ip.js";import{t as a}from"./init-QitreBcL.js";import{t as o}from"./adapter-DJCtt7vM.js";import"./list-CEf-heeX.js";var s=i.object({width:i.number().allow(0).default(0),height:i.number().allow(0).default(0),length:i.number().allow(0).default(0)}),c=i.object({sellable_stock:i.number().required()}),l=i.object({id:i.number().allow(0),sku:i.string().allow(``),name:i.string().allow(``),stock:i.number().required(),price:i.string().pattern(/^\d+$/).required(),tier_index:i.array().items(i.number()).required(),stock_setting_list:i.array().items(c).required()}),u=i.object({name:i.string().allow(``).required(),images:i.array().items(i.string().allow(``)).default([]),options:i.array().items(i.string().allow(``)).default([])}),d=i.object({price:i.string().pattern(/^\d+$/).required(),cover_shipping_fee:i.boolean().required(),enabled:i.boolean().required(),item_flag:i.string().required(),channelid:i.number().required(),sizeid:i.number().required()}),f=i.object({attribute_name:i.string(),attribute_id:i.number(),mandatory:i.boolean(),attribute_value_id:i.number(),attribute_text:i.string(),custom_value:i.object({raw_value:i.string().allow(``),unit:i.string().allow(``)})}).xor(`attribute_value_id`,`custom_value`);i.object({id:i.number().required(),name:i.string().required(),brand:i.string().required(),brand_id:i.number().required(),images:i.array().items(i.string()).required(),long_images:i.array().items(i.string()).required(),description:i.string().required(),category_path:i.array().items(i.number()).required(),attributes:i.array().items(f).required(),category_recommend:i.array().items(i.any()).required(),price:i.string().pattern(/^\d+$/).required(),parent_sku:i.string().required(),wholesale_list:i.array().items(i.any()).required(),installment_tenures:i.object().required(),weight:i.number().min(0).required(),dimension:s.required(),model_list:i.array().items(l).required(),tier_variation:i.array().items(u).required(),logistics_channels:i.array().items(d).required(),unlisted:i.boolean().required(),add_on_deal:i.array().items(i.any()).required(),video_list:i.array().optional().default([]),days_to_ship:i.number().required(),ds_cat_rcmd_id:i.string().allow(``),condition:i.number().required(),size_chart:i.any().allow(null),size_chart_info:i.any().allow(null),pre_order:i.boolean().required(),installment_tenrues:i.object().allow({}),stock:i.number().required(),stock_setting_list:i.array().items(c).required()});var p=async(e,t)=>{let n={is_draft:!1,product_id:e,product_info:t};return await a.post(`/api/v3/product/update_product_info/`,n)},m=async e=>{let t={is_draft:!1,product_info:await o(e)};return await a.post(`/api/v3/product/create_product_info`,t)},h=e(t()),g=async(e,t=!0)=>{let r=new n(e);if(t){let e=await r.get();if(e)return e}let i=(await a.get(`/api/v3/product/get_product_info`,{params:{product_id:e,is_draft:!1}})).data.product_info;return i&&await r.set(i),i},_=async e=>{let t=new r(`category-attribute-${e}`),n=await t.get();if(n)return n;let i=await a.get(`/api/v3/category/get_attribute_tree/`,{params:{category_ids:e}}),o=h.default.get(i,`data.list[0].attribute_tree`,[]);return await t.set(o),o};export{p as i,g as n,m as r,_ as t};