import{o as e,t}from"./chunk-mlkTr37E.js";import{t as n}from"./lodash-DulIlzb9.js";import{i as r}from"./utils-BlhIOnbm.js";import{t as i}from"./src-BB3-yf7b.js";var a=t(((e,t)=>{var n=t.exports={};n.Millisecond=.001,n.Second=1,n.Minute=60,n.Hour=60*n.Minute,n.Day=24*n.Hour,n.Week=7*n.Day,n.Month=30.436875*n.Day,n.Year=12*n.Month;var r=RegExp(`^\\s*([-+]?)\\s*`+[`y`,`M`,`w`,`d`,`h`,`m`,`s`,`ms`].map(function(e){return`(?:(\\d+)\\s*`+e+`)?`}).join(`\\s*`)+`\\s*$`),i=a;function a(e){return e}function o(e){return Math.round(e)}Object.defineProperty(n,`round`,{get:function(){return i===o},set:function(e){i=e?o:a}}),n.now=function(e){let t=Date.now()/1e3;return i(e?n.add(t,e):t)},n.add=function(e,t){if(!c(e))throw Error(`Time must be a number`);if(s(t)){let e=r.exec(t);if(!e)throw Error(`Expected offset string format: [+|-] [{years}y] [{months}M] [{weeks}w] [{days}d] [{hours}h] [{minutes}m] [{seconds}s] [{milliseconds}ms]`);t=(e[1]===`-`?-1:1)*((e[2]||0)*n.Year+(e[3]||0)*n.Month+(e[4]||0)*n.Week+(e[5]||0)*n.Day+(e[6]||0)*n.Hour+(e[7]||0)*n.Minute+(e[8]||0)*n.Second+(e[9]||0)*n.Millisecond)}else if(!c(t))throw Error(`Offset must be either a string or a number`);return i(e+t)},n.duration=function(e){return n.add(0,e)},n.fromDate=function(e){if(s(e))e=new Date(e);else if(!l(e))throw Error(`Expected either a string or a date`);return i(e.getTime()/1e3)},n.toDate=function(e){if(!c(e))throw Error(`Expected a number`);return new Date(e*1e3)};function s(e){return typeof e==`string`||Object.prototype.toString.call(e)===`[object String]`}function c(e){return typeof e==`number`||Object.prototype.toString.call(e)===`[object Number]`}function l(e){return Object.prototype.toString.call(e)===`[object Date]`}}));function o(e,t){return t===void 0&&(t=15),+parseFloat(Number(e).toPrecision(t))}function s(e){var t=e.toString().split(/[eE]/),n=(t[0].split(`.`)[1]||``).length-+(t[1]||0);return n>0?n:0}function c(e){if(e.toString().indexOf(`e`)===-1)return Number(e.toString().replace(`.`,``));var t=s(e);return t>0?o(Number(e)*10**t):Number(e)}function l(e){g&&(e>2**53-1||e<-(2**53-1))&&console.warn(e+` is beyond boundary when transfer to integer, the results may not be accurate`)}function u(e){return function(){var t=[...arguments],n=t[0];return t.slice(1).reduce(function(t,n){return e(t,n)},n)}}var d=u(function(e,t){var n=c(e),r=c(t),i=s(e)+s(t),a=n*r;return l(a),a/10**i}),f=u(function(e,t){var n=10**Math.max(s(e),s(t));return(d(e,n)+d(t,n))/n}),p=u(function(e,t){var n=10**Math.max(s(e),s(t));return(d(e,n)-d(t,n))/n}),m=u(function(e,t){var n=c(e),r=c(t);return l(n),l(r),d(n/r,o(10**(s(t)-s(e))))});function h(e,t){var n=10**t,r=m(Math.round(Math.abs(d(e,n))),n);return e<0&&r!==0&&(r=d(r,-1)),r}var g=!0;function _(e){e===void 0&&(e=!0),g=e}var v={strip:o,plus:f,minus:p,times:d,divide:m,round:h,digitLength:s,float2Fixed:c,enableBoundaryChecking:_},y=e(a()),b=e(n()),x=e(i()),S=(e=0,t=0)=>!e||!t||e===t?0:100-v.round(t*100/e,0),C=e=>{let t={name:e.name,description:e.description,image:e.image,video:e.video,currency:e.currency,timeCreate:y.default.toDate(e.ctime).toLocaleString(),totalVaritaion:0,totalSale:0,totalSold:0},n=e.shop_data||{},i={name:n.name,image:r(n.account.portrait),username:n.account.username,phone:``,email:``,isMall:n.is_official_shop,shopId:n.shopid,userId:n.userid,location:n.place||n.shop_location,totalSold:n.sold_total,totalProduct:n.item_count,totalFollower:n.follower_count,ratingStar:n.rating_star,ratingBad:n.rating_bad,ratingGood:n.rating_good,ratingNormal:n.rating_normal,timeCreate:y.default.toDate(n.ctime).toLocaleString(),timeOnline:y.default.toDate(n.last_active_time).toLocaleString()},a=(e.description.match(/#(\w+)/g)||[]).map(e=>e.replace(/\#/g,``)),o=e.models.map(e=>({id:e.modelid,name:e.name,image:``,price:e.price_before_discount,promotion:e.price||0,stock:e.stock,discount:S(e.price_before_discount,e.price),sold:e.sold,sale:e.sold*e.price})),s=[...e.images.map((e,t)=>({url:e,fileName:`main-${t+1}.jpg`,type:`main`})),...(e.long_images||[]).map((e,t)=>({url:e,fileName:`long-${t+1}.jpg`,type:`long`}))];return e.rich_text_description&&e.rich_text_description.paragraph_list&&e.rich_text_description.paragraph_list.filter(e=>e.img_id).forEach((e,t)=>{let n=r(e.img_id);s.push({url:n,fileName:`description-${t+1}.jpg`,type:`description`})}),e.tier_variations&&e.tier_variations.map(e=>{e.images&&e.images.length&&s.push(...e.images.map((t,n)=>({url:t,fileName:`${b.default.snakeCase(e.options[n])}.jpg`,type:`variation`})))}),t.totalSale=(0,x.default)(o,e=>e.sale),t.totalSold=(0,x.default)(o,e=>e.sold),t.totalVaritaion=o.length,{metaData:t,shopData:i,listVariation:o,listImage:s,listTag:a}};export{v as n,a as r,C as t};