8 lines
32 KiB
JavaScript
8 lines
32 KiB
JavaScript
import{d as j,a$ as Je,s as se,e as Qe,C as w,k as G,aJ as x,bv as et,aY as Y,aZ as tt,aL as Re,r as L,K as _e,bi as nt,b1 as ot,bX as $e,bV as st,af as oe,bu as ze,aQ as ye,aR as le,cu as U,aX as it,aW as at,b5 as rt,bd as Le,cA as lt,aM as ut,a1 as Ae,bS as dt,b_ as ct,u as be,G as X,o as ce,al as pe,y as b,z as h,A as r,H as c,D as K,a2 as J,a3 as ue,F as ie,am as ae,a7 as re,ak as Ce,B as P,U as pt,J as Q,S as q,E as Pe,I as Ie,cH as He,aA as Ve,az as ke,N as mt,a5 as ft,a4 as ve,a9 as ge,a8 as vt,Q as gt}from"./G_17LgpR.js";import{e as ne}from"./DWEdiVkG.js";import{f as ht,a as De}from"./C3gkR5pj.js";import{S as wt,a as xt}from"./DiiZMebn.js";/* empty css *//* empty css */import{P as yt}from"./5EiETixP.js";import{i as Oe}from"./B9nbzEx0.js";import{B as de}from"./DUAMdf4s.js";import{_ as _t}from"./DlAUqK2U.js";import{_ as Se}from"./CNxSHjm0.js";import{C as Ue}from"./CgJkSVJR.js";import{B as bt}from"./C_gIYN7y.js";import{U as Ct}from"./wt3vyHO9.js";import"./DFUQTW3o.js";import{B as kt}from"./C1vz2RTh.js";import{T as St}from"./CKbLd5ES.js";import{M as $t,_ as he,u as Lt}from"./CL-FXKZS.js";import{S as We}from"./aNyYT5DR.js";import{B as Pt}from"./ToDZsT2k.js";import{u as It,b as Ot}from"./DYXDK3m5.js";import{g as Mt,a as Me}from"./ycclw7qJ.js";import{i as Tt,g as Bt,c as Ft,d as Et,a as Nt,e as jt}from"./C7wQ3vfD.js";function Rt(e){const{selectionStart:s}=e;return e.value.slice(0,s)}function zt(e){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";return(Array.isArray(s)?s:[s]).reduce((t,o)=>{const u=e.lastIndexOf(o);return u>t.location?{location:u,prefix:o}:t},{location:-1,prefix:""})}function Te(e){return(e||"").toLowerCase()}function At(e,s,n){const t=e[0];if(!t||t===n)return e;let o=e;const u=s.length;for(let i=0;i<u;i+=1)if(Te(o[i])!==Te(s[i])){o=o.slice(i);break}else i===u-1&&(o=o.slice(u));return o}function Ht(e,s){const{measureLocation:n,prefix:t,targetText:o,selectionStart:u,split:i}=s;let l=e.slice(0,n);l[l.length-i.length]===i&&(l=l.slice(0,l.length-i.length)),l&&(l=`${l}${i}`);let p=At(e.slice(u),o.slice(u-n-t.length),i);p.slice(0,i.length)===i&&(p=p.slice(i.length));const d=`${l}${t}${o}${i}`;return{text:`${d}${p}`,selectionLocation:d.length}}function Vt(e,s){e.setSelectionRange(s,s),e.blur(),e.focus()}function Dt(e,s){const{split:n}=s;return!n||e.indexOf(n)===-1}function Ut(e,s){let{value:n=""}=s;const t=e.toLowerCase();return n.toLowerCase().indexOf(t)!==-1}const Ke=Symbol("MentionsContextKey");function Wt(){}const Kt=j({compatConfig:{MODE:3},name:"DropdownMenu",props:{prefixCls:String,options:{type:Array,default:()=>[]}},setup(e,s){let{slots:n}=s;const{activeIndex:t,setActiveIndex:o,selectOption:u,onFocus:i=Wt,loading:l}=Je(Ke,{activeIndex:se(),loading:se(!1)});let p;const d=y=>{clearTimeout(p),p=setTimeout(()=>{i(y)})};return Qe(()=>{clearTimeout(p)}),()=>{var y;const{prefixCls:C,options:M}=e,a=M[t.value]||{};return w($t,{prefixCls:`${C}-menu`,activeKey:a.value,onSelect:g=>{let{key:I}=g;const _=M.find(T=>{let{value:F}=T;return F===I});u(_)},onMousedown:d},{default:()=>[!l.value&&M.map((g,I)=>{var _,T;const{value:F,disabled:R,label:A=g.value,class:H,style:W}=g;return w(he,{key:F,disabled:R,onMouseenter:()=>{o(I)},class:H,style:W},{default:()=>[(T=(_=n.option)===null||_===void 0?void 0:_.call(n,g))!==null&&T!==void 0?T:typeof A=="function"?A(g):A]})}),!l.value&&M.length===0?w(he,{key:"notFoundContent",disabled:!0},{default:()=>[(y=n.notFoundContent)===null||y===void 0?void 0:y.call(n)]}):null,l.value&&w(he,{key:"loading",disabled:!0},{default:()=>[w(We,{size:"small"},null)]})]})}}}),qt={bottomRight:{points:["tl","br"],offset:[0,4],overflow:{adjustX:0,adjustY:1}},bottomLeft:{points:["tr","bl"],offset:[0,4],overflow:{adjustX:0,adjustY:1}},topRight:{points:["bl","tr"],offset:[0,-4],overflow:{adjustX:0,adjustY:1}},topLeft:{points:["br","tl"],offset:[0,-4],overflow:{adjustX:0,adjustY:1}}},Xt=j({compatConfig:{MODE:3},name:"KeywordTrigger",props:{loading:{type:Boolean,default:void 0},options:{type:Array,default:()=>[]},prefixCls:String,placement:String,visible:{type:Boolean,default:vo
|
|||
|
|
user:users(name, avatar),
|
||
|
|
like:likes(user_id),
|
||
|
|
replies:comments(*,
|
||
|
|
user:users(name, avatar),
|
||
|
|
like:likes(user_id)
|
||
|
|
)`).eq("product_id",e).is("parent_id",null).range(t,o).order("created_at",{ascending:!1}))?.data},je=async(e,s,n=void 0)=>await ke.post("/media/add-comment",{message:e,product_id:s,parent_id:n}),_o={flex:"","justify-center":"","items-center":"","flex-col":"","p-2":""},bo={"mt-1":"","font-semibold":""},Co={class:"flex items-center"},ko={class:"me-1"},So={class:"flex items-center p1"},$o=j({__name:"CommentAddEdit",props:{open:{type:Boolean},id:{}},emits:["update:open","addCommentId"],setup(e,{emit:s}){const n=be(),t=X(),o=Q(),u=L(null),i=L(!0),l=L(null),p=L(!1),d=L(!1),y=L(!1);Q();const C=L(void 0),M=()=>{i.value=l.value.scrollTop<=5};function a(){C.value=void 0}function g(){setTimeout(()=>{document.activeElement?.scrollIntoView({behavior:"smooth",block:"center"}),p.value=!0},300)}ce(()=>{oe(()=>{l.value&&M()})});const I=e,_=s,T=L(!1),F=L([]),R=L(""),A=L(null),H=L(!1),W=L(0),Z=L(20),V=async()=>{try{if(!H.value){T.value=!0;const v=await yo(I.id,++W.value,Z.value);v?.length<Z.value&&(H.value=!0),F.value.push(...v)}}catch(v){console.log("e ===>",v)}finally{T.value=!1}};async function me(){await V(),await oe(),await u.value?.setOpen(),await A.value?.focus()}async function fe(){await oe(),await u.value?.setClose(),f(),a()}function f(){F.value=[],W.value=0,H.value=!1}const m=async()=>{try{if(R.value?.length>0){if(d.value=!0,C.value){const v=await je(R.value,I.id,C.value.id);C.value?.replies||(C.value.replies=[]),C.value?.replies.push({message:R.value,user:{name:o.user.name,avatar:o.user.avatar},like:[],...v}),_("addCommentId",v.id)}else{const v=await je(R.value,I.id);F.value?.unshift({message:R.value,user:{name:o.user.name,avatar:o.user.avatar},like:[],replies:[],...v}),_("addCommentId",v.id)}await oe(()=>{R.value="",C.value=void 0})}}catch(v){console.log(v)}finally{d.value=!1}};function k(v,$,z,O){try{if(y.value=!0,ge())if(v)if(Qn($),z){const E=F.value.find(B=>B.id===O)?.replies.find(B=>B.id===$);E?.like.splice(E.like?.findIndex(B=>B.user_id===o.user?.id))}else{const N=F.value.find(E=>E.id===O);N?.like.splice(N?.like?.findIndex(E=>E.user_id===o.user?.id))}else Jn($),z?F.value.find(B=>B.id===O)?.replies.find(B=>B.id===$)?.like.push({product_id:$,user_id:o.user.id}):F.value.find(E=>E.id===O)?.like?.push({product_id:$,user_id:o.user.id});else n.push({name:"auth-login"}),gt.warn(t.useString("pleaseLoginOrRegister"))}catch(N){console.log(N)}finally{y.value=!1}}const S=L();return ft(S,([{isIntersecting:v}])=>{v&&I.open&&setTimeout(()=>{V()},100)}),Ae(I,v=>{v.open?me():fe()}),(v,$)=>{const z=on;return h(),ie(bt,{title:"",ref_key:"sheetRef",ref:u,headerCls:"",allowCloseScrollup:i.value,closeOnClickOutside:"",onOnClickOutside:$[3]||($[3]=O=>_("update:open",!1)),onOnClose:$[4]||($[4]=O=>_("update:open",!1))},{header:K(()=>[r("div",_o,[$[5]||($[5]=r("div",{"bg-gray-500":"","h-2px":"","w-2.5rem":""},null,-1)),r("div",bo,P(c(t).useString("comments")),1)])]),default:K(()=>[r("div",{class:ve(["h-70vh w-full relative relative",c(ge)()?"pb-4rem":""])},[r("div",{class:"h-full px-4 overflow-auto",ref_key:"scrollArea",ref:l,onScroll:M},[(h(!0),b(J,null,ue(F.value,O=>(h(),ie(ho,{item:O,onLikeComment:k,onReply:N=>C.value=O,addLikeLoading:y.value},null,8,["item","onReply","addLikeLoading"]))),256)),T.value?(h(),b(J,{key:0},ue(5,O=>w(xo)),64)):q("",!0),re(r("div",{ref_key:"observer",ref:S,class:"w-full opacity-0 relative"}," load ",512),[[vt,!T.value]])],544),c(ge)()?(h(),b("div",{key:0,class:"flex w-inherit fixed gap-2 items-end my-2 px4 py-1 bottom-1",onFocusin:g,onFocusout:$[2]||($[2]=O=>p.value=!1)},[w(Ct,{width:"40",src:c(o).user?.avatar,"just-show-profile":""},null,8,["src"]),r("div",{class:ve(["border-solid w-full border-1 comment_input",C.value?"rounded-3xl":"rounded-full"])},[C.value?(h(),b("div",{key:0,class:ve(["rounded-t-3xl text-xs p3 mb1 flex justify-between",c(t).isNightStore?"bg-zinc-7 text-gray-2":"bg-gray-50 text-gray-4"])},[r("div",Co,[r("span",null,[r("span",ko,P(c(t).useString("replyingTo")),1),r("span",null,P(C.value?.user?.name),1)])]),w(de,{icon:"vuesax-linear:add",class:"rotate-45",color:c(t).isNightStore?"bg-zinc-7":
|