import { defineComponent, ref, reactive, computed, withAsyncContext, resolveDirective, unref, mergeProps, withCtx, createVNode, createBlock, openBlock, withDirectives, Fragment, renderList, watch, createTextVNode, toDisplayString, useSSRContext } from 'vue'; import { ssrRenderComponent, ssrRenderAttrs, ssrInterpolate, ssrGetDirectiveProps, ssrRenderAttr, ssrRenderList, ssrRenderClass } from 'vue/server-renderer'; import { u as useRouter$1, a as useConfigStore, t as useCartStore, b as useUserStore, aw as getOneProduct, q as __nuxt_component_0, C as getSupabaseStorageUrl, E as APP_TYPE, G as Badge, D as reactiveProjectName, ae as useProduct, j as __nuxt_component_1$3, aq as Tag, ac as __nuxt_component_4 } from './server.mjs'; import { _ as _imports_0, a as _imports_1 } from './cart-DMkYna66.mjs'; import { B as BasicIconOld } from './BasicIconOld-93vAWohq.mjs'; import { i as img_gif } from './post_loading-BiySI7bp.mjs'; import { Swiper, SwiperSlide } from 'swiper/vue'; import { Zoom, Navigation, Pagination } from 'swiper/modules'; import { e as empty_user } from './empty_user-BaUNCdgf.mjs'; import { cloneDeep } from 'lodash-es'; import { u as usePrice } from './usePrice-B-5-jXKQ.mjs'; import { B as BasicSelect } from './BasicSelect-DMW6tJJc.mjs'; import { _ as _sfc_main$6, a as _sfc_main$7$1, b as _sfc_main$5$1, e as _sfc_main$6$1, C as CommentAddEdit } from './moreOptionProduct-N01tC6Zc.mjs'; import { _ as _sfc_main$7 } from './like-BhIOg3YL.mjs'; import { u as useAsyncData } from './asyncData-BzPAimvL.mjs'; import { _ as _export_sfc } from './_plugin-vue_export-helper-1tPrXgE0.mjs'; import '../_/nitro.mjs'; import 'node:http'; import 'node:https'; import 'node:events'; import 'node:buffer'; import 'node:fs'; import 'node:url'; import 'consola'; import 'ipx'; import 'node:path'; import 'node:crypto'; import 'pinia'; import '@supabase/supabase-js'; import '@babel/runtime/helpers/esm/extends'; import '@babel/runtime/helpers/esm/objectSpread2'; import '@ant-design/colors'; import '@ctrl/tinycolor'; import 'stylis'; import 'vue-types'; import 'axios'; import '@ant-design/icons-vue'; import 'resize-observer-polyfill'; import 'dom-align'; import 'lodash-es/uniq.js'; import 'lodash-es/pick.js'; import 'lodash-es/isPlainObject.js'; import 'lodash-es/debounce.js'; import 'lodash-es/cloneDeep.js'; import 'async-validator'; import 'lodash-es/find.js'; import 'lodash-es/isEqual.js'; import 'compute-scroll-into-view'; import 'lodash-es/intersection.js'; import 'lodash-es/omit.js'; import 'lodash-es/isNumber.js'; import 'throttle-debounce'; import 'lodash-es/fromPairs.js'; import 'lodash-es/partition.js'; import '../routes/renderer.mjs'; import 'vue-bundle-renderer/runtime'; import 'unhead/server'; import 'devalue'; import 'unhead/utils'; import './index-CM92jef_.mjs'; import '@vueuse/gesture'; import '@headlessui/vue'; import 'framesync'; import 'popmotion'; import 'style-value-types'; import './UserProfilePic-CmaGJi8K.mjs'; import './BasicButton-B9iMRxfW.mjs'; import './useDateTime-D8RCoGwW.mjs'; import 'moment'; import 'moment-timezone'; import 'moment-jalaali'; import 'date-fns'; import 'date-fns/locale'; import 'vue-content-loader'; import './product-EzgZgQkP.mjs'; import './handle-B6YUQ-uU.mjs'; const _sfc_main$5 = /* @__PURE__ */ defineComponent({ __name: "ProductInf", __ssrInlineRender: true, props: { inf: {} }, setup(__props) { const props = __props; useRouter$1(); const config = useConfigStore(); const userStore = useUserStore(); const _product = computed(() => { return useProduct(props.inf, variantSelected.value); }); useCartStore(); const variantPrice = ref(0); const variantPriceWithDiscount = ref(0); const variantStock = ref(0); const variantSelected = ref(void 0); const variantAllSelected = ref(false); computed(() => { return (_product.value.priceWithDiscount.value && _product.value.price.value) <= 0 ? 0 : (100 - (_product.value.priceWithDiscount.value ?? 0) * 100 / (_product.value.price.value ?? 0)).toFixed(0); }); computed(() => { return (variantPriceWithDiscount.value && variantPrice.value) <= 0 ? 0 : (100 - (variantPriceWithDiscount.value ?? 0) * 100 / (variantPrice.value ?? 0)).toFixed(0); }); computed(() => { let available = false; if (props.inf?.type === "variant") { if (variantStock.value > 0) { available = true; } } else { if (props?.inf?.count > 0) { available = true; } } return available; }); computed(() => { return _product.value?.attributesUsedInVariants?.value ?? []; }); const variantsAttrsToShow = ref([]); const variantsSelected = ref([]); const variantsAttrsToShowPrimary = ref([]); let wholeVariantsArrayHasThisVal; const lastIndex = ref(-1); function doNullValue(index) { for (let i = index; i < variantsSelected.value.length; i++) { variantsSelected.value[i].selected_variant = void 0; } } watch(variantsSelected, () => { handleChange(); }, { deep: true }); function checkPrice() { let isFull = true; variantsSelected.value.every((x, index) => { if (variantsAttrsToShow.value[index].attribute_values_arr?.length != 0 && !x?.selected_variant) { isFull = false; return false; } else { return true; } }); if (isFull) { _product.value.variants.value?.forEach((x) => { let isEqual = true; x.variant_attribute_values?.forEach((y, index) => { if (!variantsSelected.value.some((val) => val.selected_variant == y.attribute_values.id)) { isEqual = false; } }); if (isEqual) { variantPrice.value = x.price; variantPriceWithDiscount.value = x.price_with_discount; variantStock.value = x.stock; variantSelected.value = x; variantAllSelected.value = true; } }); } else { variantPrice.value = 0; variantPriceWithDiscount.value = 0; variantStock.value = 0; variantSelected.value = void 0; variantAllSelected.value = false; } } function variantsArrayHasThisVal(val) { const oldWholeVariantsArrayHasThisVal = cloneDeep(wholeVariantsArrayHasThisVal); wholeVariantsArrayHasThisVal = oldWholeVariantsArrayHasThisVal?.filter((z) => z.variant_attribute_values?.some((j) => j.attribute_values.id === val)); } function handleChange(val, index) { variantsAttrsToShowPrimary.value.push(variantsAttrsToShow.value); wholeVariantsArrayHasThisVal = cloneDeep(_product.value.variants.value); variantsAttrsToShow.value.forEach((x) => { const itemSelected = variantsSelected.value.find((y) => y.attribute_id == x.attribute_id)?.selected_variant; if (itemSelected) { lastIndex.value++; variantsArrayHasThisVal(itemSelected); } variantsAttrsToShow.value.forEach((x2) => { if (x2.attribute_id !== val?.attribute_id) { x2.attribute_values_arr = []; x2.attribute_values = []; wholeVariantsArrayHasThisVal?.forEach((y) => { y?.variant_attribute_values?.forEach((z) => { if (z.attribute_values.attributes.id === x2.attribute_id && !x2.attribute_values?.includes(z.attribute_values.id)) { x2.attribute_values_arr?.push({ attribute_id: z.attribute_values.attributes.id, id: z.attribute_values.id, value: z.attribute_values.value }); x2.attribute_values?.push(z.attribute_values.id); } }); }); } }); }); checkPrice(); } return (_ctx, _push, _parent, _attrs) => { const _component_ClientOnly = __nuxt_component_0; const _component_AFormItem = __nuxt_component_1$3; _push(`