2025-08-25 15:52:41 +03:30
|
|
|
import{d as j,a$ as Ye,s as ne,e as Ze,C as x,k as Y,aJ as f,bv as qe,aY as X,aZ as Ge,aL as Pe,r as S,L as Ie,bi as Je,b1 as Qe,bX as _e,bV as et,af as Z,bu as Te,aQ as ge,aR as ie,cu as U,aX as tt,aW as nt,b5 as ot,bd as be,cA as st,aM as it,a2 as xe,bS as at,b_ as rt,H as G,y as $,I as g,z as w,F as se,V as lt,D as q,a3 as ee,aA as Me,K as te,az as we,al as Be,A as c,a8 as ye,am as Fe,ak as Ne,B as R,T as oe,a4 as ve,cH as ut,o as Ee,O as ct,u as Re,a6 as dt,a5 as ce,aa as de,a9 as pt,R as he,cJ as mt,cK as ft}from"./CYzE2ijA.js";import{B as je}from"./DIYOB6kv.js";import{a as Ae}from"./DfjKl8r9.js";import{e as ae}from"./DWEdiVkG.js";import{_ as He}from"./BOVRWyqt.js";import{C as gt}from"./BXnhylk6.js";import{U as vt}from"./CF-aW0C7.js";import"./CsFPOKP-.js";import{B as ht}from"./BGt43vt9.js";import{B as re}from"./DD5Ys7CO.js";import{T as xt}from"./u7T2d_Xu.js";import{M as wt,_ as pe,u as yt}from"./DJo9GsCO.js";import{S as ze}from"./5Tcs8R9X.js";import{B as _t}from"./CbhVGPK6.js";import{u as bt,b as Ct}from"./BaWKP4Oo.js";import{g as St,a as Ce}from"./MNTfBqFg.js";import{i as kt,g as $t,c as Lt,d as Ot,a as Pt,e as It}from"./CiQmnpgl.js";import"./CN5YK6VA.js";import{u as Tt}from"./cnyNrgym.js";function Mt(e){const{selectionStart:s}=e;return e.value.slice(0,s)}function Bt(e){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";return(Array.isArray(s)?s:[s]).reduce((t,o)=>{const l=e.lastIndexOf(o);return l>t.location?{location:l,prefix:o}:t},{location:-1,prefix:""})}function Se(e){return(e||"").toLowerCase()}function Ft(e,s,n){const t=e[0];if(!t||t===n)return e;let o=e;const l=s.length;for(let i=0;i<l;i+=1)if(Se(o[i])!==Se(s[i])){o=o.slice(i);break}else i===l-1&&(o=o.slice(l));return o}function Nt(e,s){const{measureLocation:n,prefix:t,targetText:o,selectionStart:l,split:i}=s;let a=e.slice(0,n);a[a.length-i.length]===i&&(a=a.slice(0,a.length-i.length)),a&&(a=`${a}${i}`);let p=Ft(e.slice(l),o.slice(l-n-t.length),i);p.slice(0,i.length)===i&&(p=p.slice(i.length));const r=`${a}${t}${o}${i}`;return{text:`${r}${p}`,selectionLocation:r.length}}function Et(e,s){e.setSelectionRange(s,s),e.blur(),e.focus()}function Rt(e,s){const{split:n}=s;return!n||e.indexOf(n)===-1}function jt(e,s){let{value:n=""}=s;const t=e.toLowerCase();return n.toLowerCase().indexOf(t)!==-1}const De=Symbol("MentionsContextKey");function At(){}const Ht=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:l,onFocus:i=At,loading:a}=Ye(De,{activeIndex:ne(),loading:ne(!1)});let p;const r=y=>{clearTimeout(p),p=setTimeout(()=>{i(y)})};return Ze(()=>{clearTimeout(p)}),()=>{var y;const{prefixCls:_,options:L}=e,v=L[t.value]||{};return x(wt,{prefixCls:`${_}-menu`,activeKey:v.value,onSelect:O=>{let{key:I}=O;const B=L.find(N=>{let{value:T}=N;return T===I});l(B)},onMousedown:r},{default:()=>[!a.value&&L.map((O,I)=>{var B,N;const{value:T,disabled:E,label:H=O.value,class:z,style:K}=O;return x(pe,{key:T,disabled:E,onMouseenter:()=>{o(I)},class:z,style:K},{default:()=>[(N=(B=n.option)===null||B===void 0?void 0:B.call(n,O))!==null&&N!==void 0?N:typeof H=="function"?H(O):H]})}),!a.value&&L.length===0?x(pe,{key:"notFoundContent",disabled:!0},{default:()=>[(y=n.notFoundContent)===null||y===void 0?void 0:y.call(n)]}):null,a.value&&x(pe,{key:"loading",disabled:!0},{default:()=>[x(ze,{size:"small"},null)]})]})}}}),zt={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}}},Dt=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:void 0},transitionName:String,getPopupContainer:Function,direction:String,dropdownClassName:String},setup(e,s){let{slots:n}=s;const t=()=>`${
|
|
|
|
|
)`).eq("product_id",e).is("parent_id",null).range(t,o).order("created_at",{ascending:!1}))?.data},Oe=async(e,s,n=void 0)=>await we.post("/media/add-comment",{message:e,product_id:s,parent_id:n}),Rn={flex:"","justify-center":"","items-center":"","flex-col":"","p-2":""},jn={"mt-1":"","font-semibold":""},An={class:"flex items-center"},Hn={class:"me-1"},zn={class:"flex items-center p1"},Dn=j({__name:"CommentAddEdit",props:{open:{type:Boolean},id:{}},emits:["update:open","addCommentId"],setup(e,{emit:s}){const n=Re(),t=G(),o=te(),l=S(null),i=S(!0),a=S(null),p=S(!1),r=S(!1),y=S(!1);te();const _=S(void 0),L=()=>{i.value=a.value.scrollTop<=5};function v(){_.value=void 0}function O(){setTimeout(()=>{document.activeElement?.scrollIntoView({behavior:"smooth",block:"center"}),p.value=!0},300)}Ee(()=>{Z(()=>{a.value&&L()})});const I=e,B=s,N=S(!1),T=S([]),E=S(""),H=S(null),z=S(!1),K=S(0),W=S(20),D=async()=>{try{if(!z.value){N.value=!0;const m=await En(I.id,++K.value,W.value);m?.length<W.value&&(z.value=!0),T.value.push(...m)}}catch(m){console.log("e ===>",m)}finally{N.value=!1}};async function le(){await D(),await Z(),await l.value?.setOpen(),await H.value?.focus()}async function ue(){await Z(),await l.value?.setClose(),d(),v()}function d(){T.value=[],K.value=0,z.value=!1}const u=async()=>{try{if(E.value?.length>0){if(r.value=!0,_.value){const m=await Oe(E.value,I.id,_.value.id);_.value?.replies||(_.value.replies=[]),_.value?.replies.push({message:E.value,user:{name:o.user.name,avatar:o.user.avatar},like:[],...m}),B("addCommentId",m.id)}else{const m=await Oe(E.value,I.id);T.value?.unshift({message:E.value,user:{name:o.user.name,avatar:o.user.avatar},like:[],replies:[],...m}),B("addCommentId",m.id)}await Z(()=>{E.value="",_.value=void 0})}}catch(m){console.log(m)}finally{r.value=!1}};function h(m,C,A,k){try{if(y.value=!0,de())if(m)if(vn(C),A){const M=T.value.find(P=>P.id===k)?.replies.find(P=>P.id===C);M?.like.splice(M.like?.findIndex(P=>P.user_id===o.user?.id))}else{const F=T.value.find(M=>M.id===k);F?.like.splice(F?.like?.findIndex(M=>M.user_id===o.user?.id))}else gn(C),A?T.value.find(P=>P.id===k)?.replies.find(P=>P.id===C)?.like.push({product_id:C,user_id:o.user.id}):T.value.find(M=>M.id===k)?.like?.push({product_id:C,user_id:o.user.id});else n.push({name:"auth-login"}),he.warn(t.useString("pleaseLoginOrRegister"))}catch(F){console.log(F)}finally{y.value=!1}}const b=S();return dt(b,([{isIntersecting:m}])=>{m&&I.open&&setTimeout(()=>{D()},100)}),xe(I,m=>{m.open?le():ue()}),(m,C)=>{const A=Gt;return w(),se(je,{title:"",ref_key:"sheetRef",ref:l,headerCls:"",allowCloseScrollup:i.value,closeOnClickOutside:"",onOnClickOutside:C[3]||(C[3]=k=>B("update:open",!1)),onOnClose:C[4]||(C[4]=k=>B("update:open",!1))},{header:q(()=>[c("div",Rn,[C[5]||(C[5]=c("div",{"bg-gray-500":"","h-2px":"","w-2.5rem":""},null,-1)),c("div",jn,R(g(t).useString("comments")),1)])]),default:q(()=>[c("div",{class:ce(["h-70vh w-full relative relative",g(de)()?"pb-4rem":""])},[c("div",{class:"h-full px-4 overflow-auto",ref_key:"scrollArea",ref:a,onScroll:L},[(w(!0),$(ee,null,ve(T.value,k=>(w(),se(Bn,{item:k,onLikeComment:h,onReply:F=>_.value=k,addLikeLoading:y.value},null,8,["item","onReply","addLikeLoading"]))),256)),N.value?(w(),$(ee,{key:0},ve(5,k=>x(Nn)),64)):oe("",!0),ye(c("div",{ref_key:"observer",ref:b,class:"w-full opacity-0 relative"}," load ",512),[[pt,!N.value]])],544),g(de)()?(w(),$("div",{key:0,class:"flex w-inherit fixed gap-1 items-center my-2 px2 py-1 bottom-1",onFocusin:O,onFocusout:C[2]||(C[2]=k=>p.value=!1)},[x(vt,{width:"40",class:"w-40 ms-2",src:g(o).user?.avatar,"just-show-profile":""},null,8,["src"]),c("div",{class:ce(["border-solid flex-1 border-1 comment_input",_.value?"rounded-3xl":"rounded-full"])},[_.value?(w(),$("div",{key:0,class:ce(["rounded-t-3xl text-xs p3 mb1 flex justify-between",g(t).isNightStore?"bg-zinc-7 text-gray-2":"bg-gray-50 text-gray-4"])},[c("div",An,[c("span",null,[c("span",Hn,R(g(t).useString("replyingTo")),1),c("span",null,R(_.value?.user?.name),1)])]),x(re,{icon:"vuesax-linear:add",class:"rotate-45",color:g(t).isN
|