"use strict";const e=require("../../../common/vendor.js"),r=require("../../index.js"),t=require("../../hooks/useGoods.js");if(require("../../url/index.js"),require("../../store/index.js"),require("../../store/app.js"),require("../../api/promotion/diy.js"),require("../../request/index.js"),require("../../config/index.js"),require("../../platform/index.js"),require("../../platform/provider/wechat/index.js"),require("../../platform/provider/wechat/miniProgram.js"),require("../../api/member/auth.js"),require("../../api/member/social.js"),require("../../api/member/user.js"),require("../../platform/provider/apple/index.js"),require("../../platform/share.js"),require("../../router/index.js"),require("../../hooks/useModal.js"),require("../../helper/index.js"),require("../../helper/test.js"),require("../../helper/digit.js"),require("../../api/member/signin.js"),require("../../helper/throttle.js"),require("../../platform/pay.js"),require("../../api/pay/order.js"),require("../../store/user.js"),require("../../store/cart.js"),require("../../api/trade/cart.js"),require("../../api/pay/wallet.js"),require("../../api/trade/order.js"),require("../../api/promotion/coupon.js"),require("../../store/sys.js"),require("../../store/modal.js"),require("../../config/zIndex.js"),require("../../util/index.js"),!Array){(e.resolveComponent("su-number-box")+e.resolveComponent("su-popup"))()}Math||((()=>"../../ui/su-number-box/su-number-box.js")+(()=>"../../ui/su-popup/su-popup.js"))();const o={__name:"s-select-seckill-sku",props:{modelValue:{type:Object,default(){}},show:{type:Boolean,default:!1},singleLimitCount:{type:Number,default:1}},emits:["change","addCart","buy","close"],setup(o,{emit:s}){const u=s,i=o,a=e.reactive({goodsInfo:e.computed((()=>i.modelValue)),selectedSku:{},currentPropertyArray:[]}),n=t.convertProductPropertyList(a.goodsInfo.skus),d=e.computed((()=>{let e=a.goodsInfo.skus;for(let r of e)r.value_id_array=r.properties.map((e=>e.valueId));return e}));a.goodsInfo.is_sku||(a.selectedSku=a.goodsInfo.skus[0]),e.watch((()=>a.selectedSku),(e=>{u("change",e)}),{immediate:!0,deep:!0});const l=()=>{a.selectedSku.id?a.selectedSku.stock<=0?r.sheep.$helper.toast("库存不足"):u("buy",a.selectedSku):r.sheep.$helper.toast("请选择规格")};const c=(e=!1,r=0,t=0)=>{let o=[];if(e)for(let i of d.value)i.stock<=0||i.value_id_array.indexOf(t)>=0&&o.push(i);else o=p();let s=[];for(let i of o)s=s.concat(i.value_id_array);if(s=Array.from(new Set(s)),e){let e=s.indexOf(t);s.splice(e,1)}else a.currentPropertyArray.forEach((e=>{if(""!==e.toString())return;let r=s.indexOf(e);r>=0&&s.splice(r,1)}));let u=[];e?u=[r]:a.currentPropertyArray.forEach(((e,r)=>{""!==e&&u.push(r)}));for(let i in n)if(!(u.indexOf(n[i].id)>=0))for(let e in n[i].values)n[i].values[e].disabled=s.indexOf(n[i].values[e].id)<0},p=()=>{let e=[];for(let r of d.value){if(r.stock<=0)continue;let t=!0;a.currentPropertyArray.forEach((e=>{""!==e.toString()&&r.value_id_array.indexOf(e)<0&&(t=!1)})),t&&e.push(r)}return e};return c(!1),(s,i)=>({a:e.unref(r.sheep).$url.cdn(a.selectedSku.picUrl||a.goodsInfo.picUrl),b:e.t(a.goodsInfo.name),c:e.t(e.unref(t.fen2yuan)(a.selectedSku.price||a.goodsInfo.price)),d:e.t(a.selectedSku.stock||a.goodsInfo.stock),e:e.f(e.unref(n),((r,t,o)=>({a:e.t(r.name),b:e.f(r.values,((t,o,s)=>({a:e.t(t.name),b:e.n({"checked-btn":a.currentPropertyArray[r.id]===t.id}),c:e.n({"disabled-btn":!0===t.disabled}),d:t.id,e:!0===t.disabled,f:e.o((e=>((e,r)=>{let t=!0;void 0!==a.currentPropertyArray[e]&&a.currentPropertyArray[e]===r?(t=!1,a.currentPropertyArray.splice(e,1,"")):a.currentPropertyArray[e]=r;let o=[];a.currentPropertyArray.forEach((e=>{""!==e&&o.push(e)}));let s=p();o.length===n.length&&s.length?(s[0].count=a.selectedSku.count||1,a.selectedSku=s[0]):a.selectedSku={},c(t,e,r)})(r.id,t.id)),t.id)}))),c:r.id}))),f:e.o((e=>{var r;(r=e)>0&&a.selectedSku.count!==r&&(a.selectedSku.count=r)})),g:e.o((e=>a.selectedSku.count=e)),h:e.p({min:1,max:e.unref(e.lodashExports.min)([o.singleLimitCount,a.selectedSku.stock]),step:1,activity:"seckill",modelValue:a.selectedSku.count}),i:e.o(l),j:e.o((e=>u("close"))),k:e.p({show:o.show,round:"10"})})}},s=e._export_sfc(o,[["__scopeId","data-v-bd8b32ba"]]);wx.createComponent(s);
