Files
appco_dist/.output/public/_nuxt/BTOqHjdW.js
T
2025-08-05 21:16:09 +03:30

2 lines
6.8 KiB
JavaScript

import{d as x,C as u,dv as G,a2 as M,J as j,k as q,r as _,a1 as J,o as H,y as k,z as d,a3 as K,dF as Q,ae as X,a4 as I,A as l,B as A,u as Y,G as Z,d5 as ee,dG as te,dH as ae,S as re,H as y,F as W,D as se,aj as ne,U as oe,dI as ie}from"./l4qGU2QO.js";import{b as B,c as L,h as F,w as U,m as V,k as le,t as R,l as ue}from"./BtU3wRKV.js";import{s as de}from"./B6xVuD4Y.js";import{B as z}from"./CnoIXQ4P.js";import{U as ce}from"./DjrQXN3k.js";import{_ as ve}from"./B8NUXj0_.js";import{_ as O}from"./DlAUqK2U.js";import"./BqtpcZoZ.js";import"./DWEdiVkG.js";/* empty css */import"./DEzhoBDQ.js";import"./Bq72Mi_i.js";import"./9L842f8O.js";import"./B5y9z2Zl.js";import"./CqHWvl_e.js";import"./IcDXfOe5.js";import"./BN3nLNTV.js";import"./Cd1Zrbp0.js";import"./B1PUzC5B.js";import"./DwTRIgmt.js";const[me,fe]=L("skeleton-title"),he={round:Boolean,titleWidth:B};var _e=x({name:me,props:he,setup(e){return()=>u("h3",{class:fe([{round:e.round}]),style:{width:F(e.titleWidth)}},null)}});const pe=U(_e);var ge=pe;const[we,ye]=L("skeleton-avatar"),ke={avatarSize:B,avatarShape:V("round")};var xe=x({name:we,props:ke,setup(e){return()=>u("div",{class:ye([e.avatarShape]),style:le(e.avatarSize)},null)}});const Se=U(xe);var be=Se;const N="100%",Ce={round:Boolean,rowWidth:{type:B,default:N}},[$e,Te]=L("skeleton-paragraph");var Ie=x({name:$e,props:Ce,setup(e){return()=>u("div",{class:Te([{round:e.round}]),style:{width:e.rowWidth}},null)}});const We=U(Ie);var Be=We;const[Pe,D]=L("skeleton"),Ae="60%",Le={row:ue(0),round:Boolean,title:Boolean,titleWidth:B,avatar:Boolean,avatarSize:B,avatarShape:V("round"),loading:R,animate:R,rowWidth:{type:[Number,String,Array],default:N}};var Ue=x({name:Pe,inheritAttrs:!1,props:Le,setup(e,{slots:i,attrs:s}){const f=()=>{if(e.avatar)return u(be,{avatarShape:e.avatarShape,avatarSize:e.avatarSize},null)},c=()=>{if(e.title)return u(ge,{round:e.round,titleWidth:e.titleWidth},null)},h=o=>{const{rowWidth:t}=e;return t===N&&o===+e.row-1?Ae:Array.isArray(t)?t[o]:t},n=()=>Array(+e.row).fill("").map((o,t)=>u(Be,{key:t,round:e.round,rowWidth:F(h(t))},null)),p=()=>i.template?i.template():u(M,null,[f(),u("div",{class:D("content")},[c(),n()])]);return()=>{var o;return e.loading?u("div",G({class:D({animate:e.animate,round:e.round})},s),[p()]):(o=i.default)==null?void 0:o.call(i)}}});const Ne="data:image/svg+xml,%3csvg%20width='22'%20height='20'%20viewBox='0%200%2022%2020'%20fill='white'%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='%23733af9'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e",Re={class:"message-bubble"},ze={class:"time"},De=x({__name:"Conversation",props:{chatId:{}},setup(e,{expose:i}){const s=e,f=j(),c=q(()=>f.user),h=_([]),n=_(null),p=v=>new Date(v).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});async function o(){if(!s.chatId)return;const v=await Q(s.chatId,1,1e3);h.value=Array.isArray(v)?v:v.data||[]}function t(){n.value&&X(()=>{const v=n.value;v.scrollTo({top:v.scrollHeight,behavior:"smooth"})})}return J(h,()=>{t()}),i({request:o,scrollToBottom:t}),H(async()=>{await o()}),(v,m)=>(d(),k("div",{class:"chat-container",ref_key:"chatContainer",ref:n},[(d(!0),k(M,null,K(h.value,a=>(d(),k("div",{key:a.id,class:I(["message",{sent:a.sender_id===c.value.id,received:a.sender_id!==c.value.id}])},[l("div",Re,[l("p",null,A(a.text),1),l("span",ze,A(p(a.created_at)),1)])],2))),128))],512))}}),Me=O(De,[["__scopeId","data-v-3b999e95"]]),je={class:"flex justify-between items-center w-full p4"},qe={class:"flex items-center gap-5"},He={key:0,class:"flex gap-24px items-center"},Fe={class:"font-semibold flex items-center"},Ve={class:"flex font-200 text-xs items-center"},Oe={dir:"ltr",class:"h-98vh pb-10 overflow-hidden"},Ee=["alt"],Ge=x({__name:"index",setup(e){const i=Y(),s=Z(),f=j(),c=_(""),h=_(null),n=_(void 0);q(()=>{var m,a,g,w;return((a=(m=s.sellerConfig)==null?void 0:m.store)==null?void 0:a.main)&&f.user.id!==((w=(g=s.sellerConfig)==null?void 0:g.store)==null?void 0:w.id)});const p=_(!1),o=_(!1),t=_(void 0);H(async()=>{var m,a,g,w,S,b,C,$,T;try{if(p.value=!0,(a=(m=i.currentRoute.value.query)==null?void 0:m.id)!=null&&a.length){const r=await ee((g=i.currentRoute.value.query)==null?void 0:g.id);f.user.id===(r==null?void 0:r.user1_id)?n.value=r==null?void 0:r.user2:r.user1&&(n.value=r==null?void 0:r.user1),t.value={chat_id:i.currentRoute.value.query.id}}else{const r=((w=i.currentRoute.value.query)==null?void 0:w.user_id)??((b=(S=s.sellerConfig)==null?void 0:S.store)==null?void 0:b.id),P=await te(r,f.user.id);if(P!=null&&P.length)t.value=P[0];else{const E=await ae(r,f.user.id);t.value=E}f.user.id===((C=t.value)==null?void 0:C.user1_id)?n.value=($=t.value)==null?void 0:$.user2:t.value.user1&&(n.value=(T=t.value)==null?void 0:T.user1)}}catch(r){console.log("e ===>",r)}finally{p.value=!1}});const v=async()=>{if(c.value.length)try{o.value=!0;const m=await ie(t.value.chat_id,c.value);await h.value.request(),h.value.scrollToBottom(),setTimeout(()=>{c.value=""},100)}catch(m){console.log("e ===>",m)}finally{o.value=!1}};return(m,a)=>{var S,b,C,$,T;const g=Ue,w=de;return d(),k("div",null,[l("div",{class:I(["fixed top-0 w-inherit right-0 left-0",y(s).isNightStore?"bg-black":"bg-white"])},[l("div",je,[l("div",qe,[u(z,{icon:y(s).isRTL?"vuesax-linear:arrow-right":"vuesax-linear:arrow-left",onClick:a[0]||(a[0]=r=>y(i).back())},null,8,["icon"]),(S=n.value)!=null&&S.id?(d(),k("div",He,[u(ce,{width:"40",src:(b=n.value)==null?void 0:b.avatar,justShowProfile:""},null,8,["src"]),l("div",null,[l("div",Fe,A((C=n.value)==null?void 0:C.name),1),l("div",Ve,A(($=n.value)==null?void 0:$.username),1)])])):re("",!0)]),a[2]||(a[2]=l("div",{class:"flex w-fit gap-4 h-1.3rem items-center"},null,-1))])],2),l("div",Oe,[p.value?(d(),W(g,{key:0})):(d(),W(Me,{key:1,ref_key:"conversation",ref:h,chatId:(T=t.value)==null?void 0:T.chat_id},null,8,["chatId"]))]),l("div",{class:I(["fixed bottom-0 w-inherit right-0 left-0 p-3",y(s).isNightStore?"bg-black":"bg-white"])},[l("div",{class:I(["flex items-center gap-5 rounded-full px-2",y(s).isNightStore?"bg-gray-700":"bg-gray-100"])},[u(ve,{value:c.value,"onUpdate:value":a[1]||(a[1]=r=>c.value=r),"place-holder":`${y(s).useString("message")}...`,class:"!rounded-full border-transparent !bg-transparent message-placeholder !py-3 flex-1",rows:1},null,8,["value","place-holder"]),u(oe,{name:"fade",mode:"out-in"},{default:se(()=>[c.value===""?(d(),W(z,{key:0,icon:"vuesax-linear:add-circle"})):(d(),k("div",{key:1,class:I(["w-4rem h-2rem bg-#733af9 flex items-center rounded-full p-1 pt-2 text-white justify-center",{"bg-gray-500":o.value}]),onClick:v},[o.value?(d(),W(w,{key:1,class:"!text-white",type:"spinner",size:"20px"})):(d(),k("img",{key:0,src:Ne,alt:y(ne),class:"h-full rtl:-scale-x-100"},null,8,Ee))],2))]),_:1})],2)],2)])}}}),Je=O(Ge,[["__scopeId","data-v-61d04548"]]),ht=x({__name:"detail_message",setup(e){return(i,s)=>(d(),W(Je))}});export{ht as default};