8 lines
14 KiB
JavaScript
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
|
|||
|
|
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
|