Files
appco_dist/.output/public/_nuxt/uNkX2JKs.js
T
2025-08-24 13:00:31 +03:30

8 lines
14 KiB
JavaScript

import{d as B,H,y as d,I as t,z as o,F as T,W as _e,D as O,a5 as j,aN as se,K as P,aM as Y,ap as ie,A as e,aa as G,ar as oe,an as ne,B as f,C as y,r as p,U as N,a6 as K,L as ke,a$ as we,o as ae,P as ye,u as le,ah as R,a8 as xe,a4 as re,a7 as q,ac as F,ab as Ce,b1 as Le,S as W,b2 as $e,b3 as be}from"./BYv1load.js";import{B as de}from"./QnL3siKh.js";import{a as ce}from"./DpM3tgat.js";import{e as D}from"./DWEdiVkG.js";import{_ as ue}from"./BoSlxJZ1.js";import{C as Se}from"./BdncHQdI.js";import{U as Be}from"./CSuAA5jZ.js";import"./B3A7H1Au.js";import{B as Me}from"./866GWx42.js";import{B as E}from"./D-ODqOh1.js";import"./B5LCnhpw.js";import{u as Oe}from"./B5bd2Cym.js";const He="data:image/svg+xml,%3csvg%20width='21'%20height='21'%20viewBox='0%200%2021%2021'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M18.7431%2015.215C19.5381%2013.825%2020.0031%2012.22%2020.0031%2010.5C20.0031%205.255%2015.7481%201%2010.5031%201C5.25811%201%201.00311%205.255%201.00311%2010.5C1.00311%2015.745%205.25811%2020%2010.5031%2020C12.2581%2020%2013.8931%2019.515%2015.3031%2018.69L19.3581%2019.775C19.6481%2019.855%2019.9181%2019.585%2019.8381%2019.295L18.7431%2015.215Z'%20stroke='white'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",Re="data:image/svg+xml,%3csvg%20width='21'%20height='21'%20viewBox='0%200%2021%2021'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M18.7431%2015.215C19.5381%2013.825%2020.0031%2012.22%2020.0031%2010.5C20.0031%205.255%2015.7481%201%2010.5031%201C5.25811%201%201.00311%205.255%201.00311%2010.5C1.00311%2015.745%205.25811%2020%2010.5031%2020C12.2581%2020%2013.8931%2019.515%2015.3031%2018.69L19.3581%2019.775C19.6481%2019.855%2019.9181%2019.585%2019.8381%2019.295L18.7431%2015.215Z'%20stroke='black'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",je={key:0,src:He,alt:"comment","cursor-pointer":""},Pe={key:1,src:Re,alt:"comment","cursor-pointer":""},Nt=B({__name:"comment",setup(l){const r=H();return(a,i)=>t(r).isNightStore?(o(),d("img",je)):(o(),d("img",Pe))}}),Ve="data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9%2011.5L16.94%2019H17V1H1V19H1.06L9%2011.5Z'%20stroke='white'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",Ie="data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9%2011.5L16.94%2019H17V1H1V19H1.06L9%2011.5Z'%20stroke='black'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",Ne="data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9%2011.5L16.94%2019H17V1H1V19H1.06L9%2011.5Z'%20fill='white'%20stroke='white'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",Te="data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9%2011.5L16.94%2019H17V1H1V19H1.06L9%2011.5Z'%20fill='black'%20stroke='black'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",ze={key:0,src:Ve,alt:"comment","cursor-pointer":""},Ae={key:1,src:Ie,alt:"comment","cursor-pointer":""},Ue={key:0,src:Ne,alt:"comment","cursor-pointer":""},De={key:1,src:Te,alt:"comment","cursor-pointer":""},Tt=B({__name:"save",props:{isSaved:{type:Boolean}},setup(l){const r=H();return(a,i)=>(o(),T(_e,{name:"fade-nav",mode:"out-in"},{default:O(()=>[a.isSaved?(o(),d(j,{key:1},[t(r).isNightStore?(o(),d("img",Ue)):(o(),d("img",De))],64)):(o(),d(j,{key:0},[t(r).isNightStore?(o(),d("img",ze)):(o(),d("img",Ae))],64))]),_:1}))}}),Ee="data:image/svg+xml,%3csvg%20width='22'%20height='20'%20viewBox='0%200%2022%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.0031%201H1.00311L8.50311%208.5M21.0031%201L10.5031%2018.5L8.50311%208.5M21.0031%201L8.50311%208.5'%20stroke='white'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",Ze="data:image/svg+xml,%3csvg%20width='22'%20height='20'%20viewBox='0%200%2022%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.0031%201H1.00311L8.50311%208.5M21.0031%201L10.5031%2018.5L8.50311%208.5M21.0031%201L8.50311%208.5'%20stroke='black'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",qe={key:0,src:Ee,alt:"comment","cursor-pointer":""},Fe={key:1,class:"rtl:-scale-x-100",src:Ze,alt:"comment","cursor-pointer":""},zt=B({__name:"share",setup(l){const r=H();return(a,i)=>t(r).isNightStore?(o(),d("img",qe)):(o(),d("img",Fe))}}),At=async l=>await Y.post("/media/create-like",{product_id:l}),Ut=async l=>se.fetch("likes","delete",{field:["user_id","product_id"],value:[P().user.id,l]}),Ke=async l=>await Y.post("/media/create-comment-like",{comment_id:l}),We=async l=>se.fetch("likes","delete",{field:["user_id","comment_id"],value:[P().user.id,l]}),Ye={class:"mt-4"},Ge={class:"flex text-xs gap-2"},Je=["alt"],Qe={class:"flex-1"},Xe={class:"flex gap-2 items-center"},et={class:"text-xs text-gray-500"},tt=["aria-disabled"],st=B({__name:"SubCommentCard",props:{item:{},addLikeLoading:{type:Boolean}},emits:["likeComment","reply"],setup(l,{emit:r}){const a=P();H();const i=r;return(s,c)=>{const n=ie("lazy");return o(),d("div",Ye,[e("div",Ge,[e("div",null,[G(e("img",{alt:t(ne),width:"40",class:"rounded-full aspect-square"},null,8,Je),[[n,{src:t(oe)(s.item?.user?.avatar),loading:t(D),error:t(D)}]])]),e("div",Qe,[e("div",Xe,[e("div",null,f(s.item.user.name),1),e("div",et,f(t(ce)(s.item.created_at)),1)]),e("div",null,f(s.item.message),1)]),e("div",{class:"flex flex-col items-center gap-1 w-14px",onClick:c[0]||(c[0]=g=>i("likeComment",s.item.like?.some(L=>L.user_id===t(a).user?.id),s.item.id)),"aria-disabled":s.addLikeLoading},[y(ue,{"is-gray":"","is-liked":s.item.like?.some(g=>g.user_id===t(a).user?.id)},null,8,["is-liked"]),e("div",null,f(s.item.like?.length),1)],8,tt)])])}}}),it={class:"mb-5"},ot={class:"flex text-xs gap-2"},nt=["alt"],at={class:"flex-1"},lt={class:"flex gap-2 items-center"},rt={class:"text-xs text-gray-500"},dt=["aria-disabled"],ct={key:1,class:"ms11"},ut=B({__name:"CommentCard",props:{item:{},addLikeLoading:{type:Boolean}},emits:["likeComment","reply"],setup(l,{emit:r}){const a=P(),i=H(),s=r,c=p(!1);return(n,g)=>{const L=ie("lazy");return o(),d("div",it,[e("div",ot,[e("div",null,[G(e("img",{alt:t(ne),width:"40",class:"rounded-full aspect-square"},null,8,nt),[[L,{src:t(oe)(n.item.user.avatar),loading:t(D),error:t(D)}]])]),e("div",at,[e("div",lt,[e("div",null,f(n.item.user.name),1),e("div",rt,f(t(ce)(n.item.created_at)),1)]),e("div",null,f(n.item.message),1),e("div",{class:"text-gray-5",onClick:g[0]||(g[0]=h=>s("reply"))},f(t(i).useString("reply")),1)]),e("div",{class:"flex flex-col items-center gap-1 w-14px","aria-disabled":n.addLikeLoading,onClick:g[1]||(g[1]=h=>s("likeComment",n.item.like?.some(w=>w.user_id===t(a).user?.id),n.item.id,!1,n.item.id))},[y(ue,{"is-gray":"","is-liked":n.item.like?.some(h=>h.user_id===t(a).user?.id)},null,8,["is-liked"]),e("div",null,f(n.item.like?.length),1)],8,dt)]),n.item?.replies?.length>0?(o(),d(j,{key:0},[c.value?(o(),d("div",ct,[(o(!0),d(j,null,K(n.item?.replies,h=>(o(),T(st,{item:h,onLikeComment:w=>s("likeComment",h.like?.some(v=>v.user_id===t(a).user?.id),h.id,!0,n.item.id),addLikeLoading:n.addLikeLoading},null,8,["item","onLikeComment","addLikeLoading"]))),256))])):(o(),d("div",{key:0,onClick:g[2]||(g[2]=h=>c.value=!c.value),class:"text-zinc-5 text-xs mt-2 ms-20"},f(t(i).useString("viewMoreReplies",n.item?.replies?.length)),1))],64)):N("",!0)])}}}),mt=["width"],pt=B({__name:"CommentCardSkeleton",setup(l){const r=p(!1),a=p(null),i=ke(we(a,{width:0,height:0},{box:"border-box"}));return ae(async()=>{r.value=!0}),(s,c)=>r.value?(o(),d("div",{key:0,ref_key:"skeletonRatio",ref:a,class:"h-fit"},[y(t(Se),{width:i.width,height:"60"},{default:O(()=>[c[0]||(c[0]=e("circle",{cx:15,cy:"30",r:"15"},null,-1)),c[1]||(c[1]=e("rect",{x:"45",y:"15",rx:"3",ry:"3",width:"100",height:"12"},null,-1)),e("rect",{x:"45",y:"35",rx:"5",ry:"5",width:i.width-100,height:"10"},null,8,mt)]),_:1,__:[0,1]},8,["width"])],512)):N("",!0)}}),vt=async(l,r=1,a=10)=>{const i=(r-1)*a,s=i+a-1;return(await ye.from("comments").select(`*,
user:users(name, avatar),
like:likes(user_id),
replies:comments(*,
user:users(name, avatar),
like:likes(user_id)
)`).eq("product_id",l).is("parent_id",null).range(i,s).order("created_at",{ascending:!1}))?.data},te=async(l,r,a=void 0)=>await Y.post("/media/add-comment",{message:l,product_id:r,parent_id:a}),gt={flex:"","justify-center":"","items-center":"","flex-col":"","p-2":""},ft={"mt-1":"","font-semibold":""},ht={class:"flex items-center"},_t={class:"me-1"},kt={class:"flex items-center p1"},wt=B({__name:"CommentAddEdit",props:{open:{type:Boolean},id:{}},emits:["update:open","addCommentId"],setup(l,{emit:r}){const a=le(),i=H(),s=P(),c=p(null),n=p(!0),g=p(null),L=p(!1),h=p(!1),w=p(!1);P();const v=p(void 0),M=()=>{n.value=g.value.scrollTop<=5};function k(){v.value=void 0}function V(){setTimeout(()=>{document.activeElement?.scrollIntoView({behavior:"smooth",block:"center"}),L.value=!0},300)}ae(()=>{R(()=>{g.value&&M()})});const I=l,z=r,A=p(!1),$=p([]),b=p(""),me=p(null),Z=p(!1),J=p(0),Q=p(20),X=async()=>{try{if(!Z.value){A.value=!0;const u=await vt(I.id,++J.value,Q.value);u?.length<Q.value&&(Z.value=!0),$.value.push(...u)}}catch(u){console.log("e ===>",u)}finally{A.value=!1}};async function pe(){await X(),await R(),await c.value?.setOpen(),await me.value?.focus()}async function ve(){await R(),await c.value?.setClose(),ge(),k()}function ge(){$.value=[],J.value=0,Z.value=!1}const fe=async()=>{try{if(b.value?.length>0){if(h.value=!0,v.value){const u=await te(b.value,I.id,v.value.id);v.value?.replies||(v.value.replies=[]),v.value?.replies.push({message:b.value,user:{name:s.user.name,avatar:s.user.avatar},like:[],...u}),z("addCommentId",u.id)}else{const u=await te(b.value,I.id);$.value?.unshift({message:b.value,user:{name:s.user.name,avatar:s.user.avatar},like:[],replies:[],...u}),z("addCommentId",u.id)}await R(()=>{b.value="",v.value=void 0})}}catch(u){console.log(u)}finally{h.value=!1}};function he(u,m,U,_){try{if(w.value=!0,F())if(u)if(We(m),U){const x=$.value.find(C=>C.id===_)?.replies.find(C=>C.id===m);x?.like.splice(x.like?.findIndex(C=>C.user_id===s.user?.id))}else{const S=$.value.find(x=>x.id===_);S?.like.splice(S?.like?.findIndex(x=>x.user_id===s.user?.id))}else Ke(m),U?$.value.find(C=>C.id===_)?.replies.find(C=>C.id===m)?.like.push({product_id:m,user_id:s.user.id}):$.value.find(x=>x.id===_)?.like?.push({product_id:m,user_id:s.user.id});else a.push({name:"auth-login"}),W.warn(i.useString("pleaseLoginOrRegister"))}catch(S){console.log(S)}finally{w.value=!1}}const ee=p();return xe(ee,([{isIntersecting:u}])=>{u&&I.open&&setTimeout(()=>{X()},100)}),re(I,u=>{u.open?pe():ve()}),(u,m)=>{const U=Le;return o(),T(de,{title:"",ref_key:"sheetRef",ref:c,headerCls:"",allowCloseScrollup:n.value,closeOnClickOutside:"",onOnClickOutside:m[3]||(m[3]=_=>z("update:open",!1)),onOnClose:m[4]||(m[4]=_=>z("update:open",!1))},{header:O(()=>[e("div",gt,[m[5]||(m[5]=e("div",{"bg-gray-500":"","h-2px":"","w-2.5rem":""},null,-1)),e("div",ft,f(t(i).useString("comments")),1)])]),default:O(()=>[e("div",{class:q(["h-70vh w-full relative relative",t(F)()?"pb-4rem":""])},[e("div",{class:"h-full px-4 overflow-auto",ref_key:"scrollArea",ref:g,onScroll:M},[(o(!0),d(j,null,K($.value,_=>(o(),T(ut,{item:_,onLikeComment:he,onReply:S=>v.value=_,addLikeLoading:w.value},null,8,["item","onReply","addLikeLoading"]))),256)),A.value?(o(),d(j,{key:0},K(5,_=>y(pt)),64)):N("",!0),G(e("div",{ref_key:"observer",ref:ee,class:"w-full opacity-0 relative"}," load ",512),[[Ce,!A.value]])],544),t(F)()?(o(),d("div",{key:0,class:"flex w-inherit fixed gap-1 items-center my-2 px2 py-1 bottom-1",onFocusin:V,onFocusout:m[2]||(m[2]=_=>L.value=!1)},[y(Be,{width:"40",class:"w-40 ms-2",src:t(s).user?.avatar,"just-show-profile":""},null,8,["src"]),e("div",{class:q(["border-solid flex-1 border-1 comment_input",v.value?"rounded-3xl":"rounded-full"])},[v.value?(o(),d("div",{key:0,class:q(["rounded-t-3xl text-xs p3 mb1 flex justify-between",t(i).isNightStore?"bg-zinc-7 text-gray-2":"bg-gray-50 text-gray-4"])},[e("div",ht,[e("span",null,[e("span",_t,f(t(i).useString("replyingTo")),1),e("span",null,f(v.value?.user?.name),1)])]),y(E,{icon:"vuesax-linear:add",class:"rotate-45",color:t(i).isNightStore?"bg-zinc-7":"text-gray-4",onClick:m[0]||(m[0]=_=>v.value=void 0)},null,8,["color"])],2)):N("",!0),e("div",kt,[y(U,{value:b.value,"onUpdate:value":m[1]||(m[1]=_=>b.value=_),placeholder:t(i).useString("yourComment"),class:"comment_input"},null,8,["value","placeholder"]),y(Me,{onClick:fe,class:"rounded-full w-3.5rem",type:"primary",loading:h.value},{default:O(()=>[y(E,{icon:"vuesax-linear:arrow-up"})]),_:1},8,["loading"])])],2)],32)):N("",!0)],2)]),_:1},8,["allowCloseScrollup"])}}}),Dt=Object.assign(wt,{__name:"CommentAddEdit"}),yt={class:"h-fit px-4"},xt={class:"flex flex-col gap-2 mt-5 mb-5"},Ct={class:"text-sm text-white"},Lt={class:"text-red text-sm"},Et=B({__name:"moreOptionProduct",props:{open:{type:Boolean},id:{}},emits:["update:open"],setup(l,{emit:r}){const a=le(),i=H(),s=p(null),c=l,n=r;async function g(){await R(),await s.value?.setOpen()}async function L(){await R(),await s.value?.setClose()}async function h(){await $e(i.useString("areYouSureToDeleteThisProduct"),v)}const w=Oe();async function v(){w.percentUpload=0,w.loading=!0;try{await be(c.id),w.percentUpload=100,W.success(i.useString("deletedSuccessfully"))}catch(M){console.log(M),W.error(i.useString("errorInAction"))}finally{w.loading=!1,n("update:open",!1)}}return re(c,M=>{M.open?g():L()}),(M,k)=>(o(),T(de,{title:"",ref_key:"sheetRef",ref:s,headerCls:"",closeOnClickOutside:"",onOnClickOutside:k[2]||(k[2]=V=>n("update:open",!1)),onOnClose:k[3]||(k[3]=V=>n("update:open",!1))},{header:O(()=>k[4]||(k[4]=[e("div",{flex:"","justify-center":"","items-center":"","flex-col":"","p-2":""},[e("div",{"bg-gray-500":"","h-2px":"","w-2.5rem":""})],-1)])),default:O(()=>[e("div",yt,[e("div",xt,[e("div",{class:"flex items-center gap-3 p-3 rounded-lg bg-primary",onClick:k[0]||(k[0]=V=>t(a).push({name:"edit-product-id",params:{id:c.id}}))},[y(E,{icon:"vuesax-linear:edit",color:"white"}),e("div",Ct,f(t(i).useString("edit")),1)]),e("div",{class:"flex items-center gap-3 p-3 rounded-lg bg-red-100",onClick:k[1]||(k[1]=V=>h())},[y(E,{icon:"vuesax-linear:trash",color:"red"}),e("div",Lt,f(t(i).useString("delete")),1)])])])]),_:1},512))}});export{Dt as C,Et as _,zt as a,Nt as b,At as c,Ut as d,Tt as e};