import { defineComponent, computed, ref, withAsyncContext, unref, useSSRContext } from 'vue'; import { ssrRenderAttrs, ssrRenderClass, ssrRenderComponent, ssrInterpolate, ssrRenderList, ssrRenderStyle } from 'vue/server-renderer'; import { B as BasicIconOld } from './BasicIconOld-I4c2ShMu.mjs'; import { u as useRouter$1, a as useConfigStore, b as useUserStore, n as useIntersectionObserver, o as getToken, e as api$1 } from './server.mjs'; import { _ as _sfc_main$2, a as _sfc_main$1, b as _sfc_main$3, d as deletePostLike, c as createPostLike } from './CommentAddEdit-DIzvwqEQ.mjs'; import { u as useUserPostStore } from './userPostsStore-CTOjnW_T.mjs'; import { d as deleteSave, c as createSave } from './save-kY8A0w-Z.mjs'; import { _ as _sfc_main$4 } from './moreOptionProduct-DIWh2yKL.mjs'; import { u as useAsyncData } from './asyncData-C9E5x-0d.mjs'; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "index", __ssrInlineRender: true, async setup(__props) { let __temp, __restore; const router = useRouter$1(); const config = useConfigStore(); const user = useUserStore(); const userId = computed(() => router.currentRoute.value.query.userId); const commentPostId = ref(); const commentVisible = ref(false); const optionVisible = ref(false); const optionPostId = ref(); const addLikeLoading = ref(false); const userPostStore = useUserPostStore(); computed(() => router.currentRoute.value.query.target || null); function handleLike(isLiked, id) { var _a, _b, _c, _d, _e, _f; try { addLikeLoading.value = true; if (getToken()) { if (isLiked) { deletePostLike(id); const index = (_a = userPostStore.posts) == null ? void 0 : _a.findIndex((x) => x.id === id); (_d = userPostStore.posts[index]) == null ? void 0 : _d.likes.splice((_c = (_b = userPostStore.posts[index]) == null ? void 0 : _b.likes) == null ? void 0 : _c.findIndex((y) => y.user_id === user.user.id)); } else { createPostLike(id); const index = (_e = userPostStore.posts) == null ? void 0 : _e.findIndex((x) => x.id === id); (_f = userPostStore.posts[index]) == null ? void 0 : _f.likes.push({ product_id: id, user_id: user.user.id }); } } else { router.push({ name: "auth-login" }); api$1.warn(config.useString("pleaseLoginOrRegister")); } } catch (e) { console.log(e); } finally { addLikeLoading.value = false; } } const observer = ref(); useIntersectionObserver(observer, async ([{ isIntersecting }]) => { if (isIntersecting && !userPostStore.loading && !userPostStore.endPage) { const nextPage = userPostStore.currentPage + 1; console.log(userPostStore.endPage, nextPage, userPostStore.currentPage); const data2 = await userPostStore.loadPosts(userId.value, nextPage); userPostStore.loadStateNextPage(data2); } }); const { data } = ([__temp, __restore] = withAsyncContext(async () => useAsyncData("productPostMainSeller", async () => { return await userPostStore.loadPosts(userId.value, 1); })), __temp = await __temp, __restore(), __temp); function handleSave(isSaved, id) { var _a, _b, _c, _d, _e, _f; if (getToken()) { if (isSaved) { deleteSave(id); const index = (_a = userPostStore.posts) == null ? void 0 : _a.findIndex((x) => x.id === id); (_d = userPostStore.posts[index]) == null ? void 0 : _d.saved.splice((_c = (_b = userPostStore.posts[index]) == null ? void 0 : _b.saved) == null ? void 0 : _c.findIndex((y) => y.user_id === user.user.id)); } else { createSave(id); const index = (_e = userPostStore.posts) == null ? void 0 : _e.findIndex((x) => x.id === id); (_f = userPostStore.posts[index]) == null ? void 0 : _f.saved.push({ product_id: id, user_id: user.user.id }); } } else { router.push({ name: "auth-login" }); api$1.warn(config.useString("pleaseLoginOrRegister")); } } function openOption(id) { optionPostId.value = id; optionVisible.value = true; } function openComment(id) { commentPostId.value = id; commentVisible.value = true; } return (_ctx, _push, _parent, _attrs) => { var _a, _b; _push(`