Files
appco_dist/.output/public/_nuxt/zwKv7OGi.js
T
2025-07-27 10:51:22 +03:30

2 lines
6.7 KiB
JavaScript

import{d as w,C as d,dv as V,a2 as M,G as D,J as j,r as _,k as q,a1 as G,dF as J,y as k,z as h,a3 as K,dG as Q,N as X,a4 as W,A as o,B as A,u as Y,o as Z,d5 as ee,dH as te,dI as ae,S as se,H as g,F as T,D as re,aj as ne,U as oe,dJ as ie}from"./vNwORUzZ.js";import{b as C,c as B,h as F,w as N,m as H,f as le,t as L,l as ue}from"./DmeoQcPT.js";import{B as U}from"./DSh6TMV1.js";import{U as de}from"./Cp4vHarM.js";import{_ as ce}from"./DYK3k91P.js";import{_ as E}from"./DlAUqK2U.js";import"./BqtpcZoZ.js";import"./DWEdiVkG.js";/* empty css */import"./DEYQXqOP.js";import"./C1A0Ol0M.js";import"./CBmaeoJK.js";import"./Bx0AlLRd.js";import"./CW2jPw-_.js";import"./BwA8VTN1.js";import"./y7aiIjb0.js";import"./DsBtkfRw.js";import"./B1PUzC5B.js";import"./BwPyxH4J.js";const[ve,me]=B("skeleton-title"),he={round:Boolean,titleWidth:C};var fe=w({name:ve,props:he,setup(e){return()=>d("h3",{class:me([{round:e.round}]),style:{width:F(e.titleWidth)}},null)}});const _e=N(fe);var pe=_e;const[ge,we]=B("skeleton-avatar"),ye={avatarSize:C,avatarShape:H("round")};var ke=w({name:ge,props:ye,setup(e){return()=>d("div",{class:we([e.avatarShape]),style:le(e.avatarSize)},null)}});const Se=N(ke);var xe=Se;const R="100%",be={round:Boolean,rowWidth:{type:C,default:R}},[Ie,$e]=B("skeleton-paragraph");var Ce=w({name:Ie,props:be,setup(e){return()=>d("div",{class:$e([{round:e.round}]),style:{width:e.rowWidth}},null)}});const Pe=N(Ce);var We=Pe;const[Te,z]=B("skeleton"),Ae="60%",Be={row:ue(0),round:Boolean,title:Boolean,titleWidth:C,avatar:Boolean,avatarSize:C,avatarShape:H("round"),loading:L,animate:L,rowWidth:{type:[Number,String,Array],default:R}};var Ne=w({name:Te,inheritAttrs:!1,props:Be,setup(e,{slots:n,attrs:i}){const f=()=>{if(e.avatar)return d(xe,{avatarShape:e.avatarShape,avatarSize:e.avatarSize},null)},c=()=>{if(e.title)return d(pe,{round:e.round,titleWidth:e.titleWidth},null)},l=t=>{const{rowWidth:m}=e;return m===R&&t===+e.row-1?Ae:Array.isArray(m)?m[t]:m},v=()=>Array(+e.row).fill("").map((t,m)=>d(We,{key:m,round:e.round,rowWidth:F(l(m))},null)),y=()=>n.template?n.template():d(M,null,[f(),d("div",{class:z("content")},[c(),v()])]);return()=>{var t;return e.loading?d("div",V({class:z({animate:e.animate,round:e.round})},i),[y()]):(t=n.default)==null?void 0:t.call(n)}}});const Re="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",Le={class:"chat-container"},Ue={class:"message-bubble"},ze={class:"time"},Me=w({__name:"Conversation",props:{chatId:{}},setup(e){D();const n=j();_(!1);const i=_(0),f=_(10),c=_([]),l=q(()=>n.user),v=e,y=a=>new Date(a).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),t=async()=>{if(v.chatId){const a=await Q(v.chatId,++i.value,f.value);console.log("res ===>",a),c.value=a}},m=()=>{X.channel("realtime:chat_messages").on("postgres_changes",{event:"INSERT",schema:"public",table:"chat_messages"},a=>{var s;((s=a.new)==null?void 0:s.chat_id)==v.chatId&&c.value.push(a.new)}).subscribe()};return G(()=>v.chatId,()=>{v.chatId&&(t(),m(),J(v.chatId,n.user.id))},{immediate:!0}),(a,s)=>(h(),k("div",Le,[(h(!0),k(M,null,K(c.value,u=>(h(),k("div",{key:u.id,class:W(["message",{sent:u.sender_id===l.value.id,received:u.sender_id!==l.value.id}])},[o("div",Ue,[o("p",null,A(u.text),1),o("span",ze,A(y(u.created_at)),1)])],2))),128))]))}}),De=E(Me,[["__scopeId","data-v-d14597e8"]]),je={class:"flex justify-between items-center w-full p4"},qe={class:"flex items-center gap-5"},Fe={key:0,class:"flex gap-24px items-center"},He={class:"font-semibold flex items-center"},Ee={class:"flex font-200 text-xs items-center"},Oe={dir:"ltr",class:"h-96vh pt-8vh overflow-y-auto pb-20"},Ve=["alt"],Ge=w({__name:"index",setup(e){const n=Y(),i=D(),f=j(),c=_(""),l=_(void 0);q(()=>{var a,s,u,p;return((s=(a=i.sellerConfig)==null?void 0:a.store)==null?void 0:s.main)&&f.user.id!==((p=(u=i.sellerConfig)==null?void 0:u.store)==null?void 0:p.id)});const v=_(!1),y=_(!1),t=_(void 0);Z(async()=>{var a,s,u,p,S,x,b,I,$;try{if(v.value=!0,(s=(a=n.currentRoute.value.query)==null?void 0:a.id)!=null&&s.length){const r=await ee((u=n.currentRoute.value.query)==null?void 0:u.id);f.user.id===(r==null?void 0:r.user1_id)?l.value=r==null?void 0:r.user2:r.user1&&(l.value=r==null?void 0:r.user1),t.value={chat_id:n.currentRoute.value.query.id}}else{const r=((p=n.currentRoute.value.query)==null?void 0:p.user_id)??((x=(S=i.sellerConfig)==null?void 0:S.store)==null?void 0:x.id),P=await te(r,f.user.id);if(P!=null&&P.length)t.value=P[0];else{const O=await ae(r,f.user.id);t.value=O}f.user.id===((b=t.value)==null?void 0:b.user1_id)?l.value=(I=t.value)==null?void 0:I.user2:t.value.user1&&(l.value=($=t.value)==null?void 0:$.user1)}}catch(r){console.log("e ===>",r)}finally{v.value=!1}});const m=async()=>{if(c.value.length)try{y.value=!0;const a=await ie(t.value.chat_id,c.value);setTimeout(()=>{c.value=""},100)}catch(a){console.log("e ===>",a)}finally{y.value=!1}};return(a,s)=>{var p,S,x,b,I;const u=Ne;return h(),k("div",null,[o("div",{class:W(["fixed top-0 w-inherit right-0 left-0",g(i).isNightStore?"bg-black":"bg-white"])},[o("div",je,[o("div",qe,[d(U,{icon:g(i).isRTL?"vuesax-linear:arrow-right":"vuesax-linear:arrow-left",onClick:s[0]||(s[0]=$=>g(n).back())},null,8,["icon"]),(p=l.value)!=null&&p.id?(h(),k("div",Fe,[d(de,{width:"40",src:(S=l.value)==null?void 0:S.avatar,justShowProfile:""},null,8,["src"]),o("div",null,[o("div",He,A((x=l.value)==null?void 0:x.name),1),o("div",Ee,A((b=l.value)==null?void 0:b.username),1)])])):se("",!0)]),s[2]||(s[2]=o("div",{class:"flex w-fit gap-4 h-1.3rem items-center"},null,-1))])],2),o("div",Oe,[v.value?(h(),T(u,{key:0})):(h(),T(De,{key:1,chatId:(I=t.value)==null?void 0:I.chat_id},null,8,["chatId"]))]),o("div",{class:W(["fixed bottom-0 w-inherit right-0 left-0 p-3",g(i).isNightStore?"bg-black":"bg-white"])},[o("div",{class:W(["flex items-center gap-5 rounded-full px-2",g(i).isNightStore?"bg-gray-700":"bg-gray-100"])},[d(ce,{value:c.value,"onUpdate:value":s[1]||(s[1]=$=>c.value=$),"place-holder":`${g(i).useString("message")}...`,class:"!rounded-full border-transparent !bg-transparent message-placeholder !py-3 flex-1",rows:1},null,8,["value","place-holder"]),d(oe,{name:"fade",mode:"out-in"},{default:re(()=>[c.value===""?(h(),T(U,{key:0,icon:"vuesax-linear:add-circle"})):(h(),k("div",{key:1,class:"w-4rem h-2rem bg-#733af9 flex items-center rounded-full p-1 pt-2 text-white justify-center",onClick:m},[o("img",{src:Re,alt:g(ne),class:"h-full rtl:-scale-x-100"},null,8,Ve)]))]),_:1})],2)],2)])}}}),Je=E(Ge,[["__scopeId","data-v-026d121e"]]),ht=w({__name:"detail_message",setup(e){return(n,i)=>(h(),T(Je))}});export{ht as default};