const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-audio-visualize.es.0ccda538-CJK3OQ76.js","assets/vendor-react-BBazpZul.js","assets/vendor-utils-BveVE6Uf.js"])))=>i.map(i=>d[i]);
import{j as e,M as E,S as b,r as Q,p as w,aD as re,o as k,D as ie,c as oe,X as F,a7 as le,aN as ce,b3 as de}from"./vendor-mui-CBBEb17G.js";import{a as n,c as N}from"./vendor-react-BBazpZul.js";import{g3 as ue,at as ge,J as Me,al as K,Y,dp as X,aP as q,aT as me,r as xe,a_ as G,e as pe,_ as je,dR as $,iA as Ie,iG as Ne,aQ as Le}from"./index-DdWwwZXu.js";import{a as O,g as P}from"./vendor-utils-BveVE6Uf.js";import{r as H}from"./vendor-charts-tGnAgELZ.js";const De=()=>({addMessageAsync:async l=>{l.message=ue(l.message);var c=new FormData;return c.append("OnlineConsultantId",l.onlineConsultantId.toString()),l.message&&c.append("Message",l.message),l.file&&c.append("File",l.file),(await O({method:"post",url:"OnlineConsultant/AddMessage",data:c,headers:{"Content-Type":"multipart/form-data"}})).data},getConsultantAsync:async()=>(await O.get("OnlineConsultant/GetConsultant")).data,getConsultantMessagesAsync:async l=>(await O.get(`OnlineConsultant/GetConsultantMessages/${l}`)).data,closeConsultantAsync:async l=>(await O.post("OnlineConsultant/CloseConsultants",l)).data}),ee=n.createContext(void 0),ye=({children:t})=>{const{getConsultantAsync:a,getConsultantMessagesAsync:i,addMessageAsync:r,closeConsultantAsync:l}=De(),c=ge(),[x,o]=n.useState(!1),[u,g]=n.useState(!1),[M,p]=n.useState(),[s,y]=n.useState(),[d,L]=n.useState(),h=async()=>{try{o(!0);const{data:m}=await a();m&&p(m.sort((v,Z)=>Z.id-v.id))}finally{o(!1)}},C=async()=>{try{if(g(!0),!s)return;const{data:m}=await i(s.id);m&&L(m)}finally{g(!1)}},j=async m=>{try{if(g(!0),!s){Me.error("لطفا یک مشاوره را انتخاب نمایید");return}await r({message:m.message,file:m.file,onlineConsultantId:s==null?void 0:s.id}),await C()}finally{g(!1)}},I=async m=>{try{o(!0),c({content:"آیا می خواهید این مشاوره بسته شود؟"}).then(async()=>{await l({ids:[m]}),await h()}).catch(()=>{})}finally{o(!1)}};n.useEffect(()=>{h()},[]),n.useEffect(()=>{s&&C()},[s]);const D={chatLoading:u,listLoading:x,consulingList:M,selectedConsuling:s,consultantMessageList:d,setSelectedConsuling:y,fetchConsulingList:h,addMessage:j,toggleClosed:I};return e.jsx(ee.Provider,{value:D,children:t})},te=()=>n.useContext(ee),Ce=K(E)`
  box-shadow: 0 3px 20px rgb(0 0 0 / 4%);
  background-color: rgb(255, 255, 255);
  padding: 10px;
  min-height: 100vh;

  .MuiDataGrid-cell {
    cursor: pointer !important;
  }
`,he=K(b)`

    width:90%;
    margin:10px;
    padding:10px 5px;
    cursor:pointer;
    background-color:#cdebf7;
    border-radius:12px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    &:hover {
      background-color:#96e2ff;
    }


`;var z={},B;function we(){if(B)return z;B=1;var t=H();Object.defineProperty(z,"__esModule",{value:!0}),z.default=void 0;var a=t(Y()),i=Q(),r=(0,a.default)((0,i.jsx)("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6h2c0-1.66 1.34-3 3-3s3 1.34 3 3v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm0 12H6V10h12v10zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z"}),"LockOpenOutlined");return z.default=r,z}var be=we();const fe=P(be);var S={},J;function ve(){if(J)return S;J=1;var t=H();Object.defineProperty(S,"__esModule",{value:!0}),S.default=void 0;var a=t(Y()),i=Q(),r=(0,a.default)((0,i.jsx)("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zM9 6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9V6zm9 14H6V10h12v10zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z"}),"LockOutlined");return S.default=r,S}var ze=ve();const Se=P(ze),Te=[{label:"نمایش همه",value:0},{label:"مشاوره های فعال",value:1},{label:"مشاوره های بسته شده",value:2}],U=()=>{const{consulingList:t,listLoading:a,setSelectedConsuling:i,toggleClosed:r,selectedConsuling:l}=te(),[c,x]=n.useState(""),[o,u]=n.useState(0),[g,M]=n.useState(),p=()=>{switch(o){case 0:M(t==null?void 0:t.filter(s=>s.patientFullName.includes(c)));break;case 1:M(t==null?void 0:t.filter(s=>!s.isClosed).filter(s=>s.patientFullName.includes(c)));break;case 2:M(t==null?void 0:t.filter(s=>s.isClosed).filter(s=>s.patientFullName.includes(c)));break}};return n.useEffect(()=>{p()},[o,c]),n.useEffect(()=>{p()},[t]),e.jsxs(w,{className:"border border-solid border-gray-400 rounded-xl h-full p-2",children:[a&&e.jsx(X,{}),e.jsxs(b,{style:{overflowY:"auto",height:"85vh"},spacing:1,alignItems:"center",children:[e.jsxs(b,{direction:{sx:"column",md:"row"},className:" w-full p-1 gap-2 ",children:[e.jsx(q,{className:"mt-1",fullWidth:!0,label:"جستجو",InputProps:{endAdornment:e.jsx(re,{position:"end",children:e.jsx(me,{})})},value:c,onChange:s=>x(s)}),e.jsx(xe,{className:"mt-1",items:Te,label:"فیلتر",value:o,onchange:s=>u(+s),defaultValue:0})]}),g==null?void 0:g.map(s=>e.jsxs(he,{onClick:()=>i(s),direction:"row",spacing:1,justifyContent:"space-evenly",alignItems:"center",sx:s.id===(l==null?void 0:l.id)?{backgroundColor:"#00c3ff"}:{},children:[e.jsx(w,{className:"whitespace-nowrap text-[0.8rem]",children:s.patientFullName}),e.jsx(w,{className:"text-[0.7rem] text-gray-500",children:G(s.createDate)}),e.jsx(k,{onClick:()=>r(s.id),children:s.isClosed?e.jsx(Se,{color:"error"}):e.jsx(fe,{color:"success"})})]},s.id))]})]})};var T={},W;function Ae(){if(W)return T;W=1;var t=H();Object.defineProperty(T,"__esModule",{value:!0}),T.default=void 0;var a=t(Y()),i=Q(),r=(0,a.default)((0,i.jsx)("path",{d:"M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm-1.2-9.1c0-.66.54-1.2 1.2-1.2.66 0 1.2.54 1.2 1.2l-.01 6.2c0 .66-.53 1.2-1.19 1.2-.66 0-1.2-.54-1.2-1.2V4.9zm6.5 6.1c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z"}),"MicNone");return T.default=r,T}var Oe=Ae();const Ee=P(Oe),ke=({message:t})=>{const{userInfo:a}=pe(r=>r.user),i=()=>{var r;return t.message?e.jsx(e.Fragment,{children:t.message}):(r=t.fileName)!=null&&r.endsWith(".mp3")?e.jsx("audio",{src:t.fileName,controls:!0}):e.jsx("a",{href:t.fileName,target:"_blank",rel:"noreferrer",children:e.jsx("img",{width:50,height:50,alt:"تصویر",src:t.fileName})})};return e.jsx("div",{className:"flex",children:t.senderId==(a==null?void 0:a.id)?e.jsxs(b,{className:"p-3 mt-1 text-[0.8rem] bg-green-300 rounded-xl",children:[i(),e.jsx("span",{className:" mt-1 text-[0.7rem] text-gray-500",children:G(t.createDate,"date-time")})]}):e.jsxs(b,{className:"mr-[auto] p-3 mt-1 text-[0.8rem] bg-blue-300 rounded-xl",children:[i(),e.jsx("span",{className:" mt-1 text-[0.7rem] text-gray-500",children:G(t.createDate,"date-time")})]})})};(function(){(t=>{try{if(typeof window>"u")return;var a=document.createElement("style");a.appendChild(document.createTextNode(t)),document.head.appendChild(a)}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})(".audio-recorder{background-color:#ebebeb;box-shadow:0 2px 5px #bebebe;border-radius:20px;box-sizing:border-box;color:#000;width:40px;display:flex;align-items:center;transition:all .2s ease-in;-webkit-tap-highlight-color:transparent}.audio-recorder-mic{box-sizing:content-box;cursor:pointer;height:16px;color:#000;padding:12px}.audio-recorder .audio-recorder-mic{border-radius:20px}.audio-recorder.recording .audio-recorder-mic{border-radius:0}.audio-recorder-timer,.audio-recorder-status{color:#000;margin-left:10px;font-family:Segoe UI,Tahoma,Geneva,Verdana,sans-serif;font-size:14px;font-weight:400;line-height:1}.audio-recorder-status{margin-left:15px;display:flex;align-items:baseline;flex-grow:1;animation-name:fading-ar-status;animation-duration:2s;animation-iteration-count:infinite}.audio-recorder-status-dot{background-color:#d00;border-radius:50%;height:10px;width:9px;margin-right:5px}.audio-recorder-options{box-sizing:content-box;height:16px;cursor:pointer;padding:12px 6px 12px 12px}.audio-recorder-options~.audio-recorder-options{padding:12px 12px 12px 6px;border-radius:0 5px 5px 0}.recording{border-radius:12px;width:300px;transition:all .2s ease-out}.display-none{display:none}.audio-recorder-visualizer{margin-left:15px;flex-grow:1;align-self:center;display:flex;align-items:center}@keyframes fading-ar-status{0%{opacity:1}50%{opacity:0}to{opacity:1}}")})();const Qe=(t,a)=>{const[i,r]=n.useState(!1),[l,c]=n.useState(!1),[x,o]=n.useState(0),[u,g]=n.useState(),[M,p]=n.useState(),[s,y]=n.useState(),d=n.useCallback(()=>{const I=setInterval(()=>{o(D=>D+1)},1e3);p(I)},[o,p]),L=n.useCallback(()=>{M!=null&&clearInterval(M),p(void 0)},[M,p]),h=n.useCallback(()=>{M==null&&navigator.mediaDevices.getUserMedia({audio:t??!0}).then(I=>{r(!0);const D=new MediaRecorder(I);g(D),D.start(),d(),D.addEventListener("dataavailable",m=>{y(m.data),D.stream.getTracks().forEach(v=>v.stop()),g(void 0)})}).catch(I=>{console.log(I.name,I.message,I.cause),a==null||a(I)})},[M,r,g,d,y,a]),C=n.useCallback(()=>{u==null||u.stop(),L(),o(0),r(!1),c(!1)},[u,o,r,c,L]),j=n.useCallback(()=>{l?(c(!1),u==null||u.resume(),d()):(c(!0),L(),u==null||u.pause())},[u,c,d,L]);return{startRecording:h,stopRecording:C,togglePauseResume:j,recordingBlob:s,isRecording:i,isPaused:l,recordingTime:x,mediaRecorder:u}},Ye="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pg0KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgdmlld0JveD0iMCAwIDQ3MCA0NzAiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDQ3MCA0NzA7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCgk8Zz4NCgkJPHBhdGggZD0iTTIzNSwzMDIuMjk2YzQ3LjE3NywwLDg1LjQyMy0zOC4yNDUsODUuNDIzLTg1LjQyM1Y4NS40MjNDMzIwLjQyMywzOC4yNDUsMjgyLjE3NywwLDIzNSwwcy04NS40MjMsMzguMjQ1LTg1LjQyMyw4NS40MjMNCgkJCXYxMzEuNDUxQzE0OS41NzcsMjY0LjA1MSwxODcuODIzLDMwMi4yOTYsMjM1LDMwMi4yOTZ6Ii8+DQoJCTxwYXRoIGQ9Ik0zNTAuNDIzLDEzNi4xNDh2MzBoMTV2NTAuNzI2YzAsNzEuOTE1LTU4LjUwOCwxMzAuNDIzLTEzMC40MjMsMTMwLjQyM3MtMTMwLjQyMy01OC41MDctMTMwLjQ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Mub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgNDYuNzM0IDQ2LjczNCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNDYuNzM0IDQ2LjczNDsiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPGc+DQoJPHBhdGggZD0iTTQxLjM0NiwwSDUuMzg4QzIuNDE3LDAsMCwyLjQxNywwLDUuMzg4djM1Ljk1OGMwLDIuOTcxLDIuNDE3LDUuMzg4LDUuMzg4LDUuMzg4aDM1Ljk1OGMyLjk3MSwwLDUuMzg4LTIuNDE3LDUuMzg4LTUuMzg4DQoJCVY1LjM4OEM0Ni43MzMsMi40MTcsNDQuMzE2LDAsNDEuMzQ2LDB6Ii8+DQo8L2c+DQo8L3N2Zz4NCg==",Ge=N.lazy(async()=>{const{LiveAudioVisualizer:t}=await je(async()=>{const{LiveAudioVisualizer:a}=await import("./react-audio-visualize.es.0ccda538-CJK3OQ76.js");return{LiveAudioVisualizer:a}},__vite__mapDeps([0,1,2]));return{default:t}}),Ve=({onRecordingComplete:t,onNotAllowedOrFound:a,recorderControls:i,audioTrackConstraints:r,downloadOnSavePress:l=!1,downloadFileExtension:c="mp3",showVisualizer:x=!1,classes:o})=>{var u,g,M,p,s,y;const{startRecording:d,stopRecording:L,togglePauseResume:h,recordingBlob:C,isRecording:j,isPaused:I,recordingTime:D,mediaRecorder:m}=i??Qe(r,a),[v,Z]=n.useState(!1),V=(R=!0)=>{Z(R),L()},ae=R=>{const se=new Blob([R],{type:`audio/${c}`}),ne=URL.createObjectURL(se),f=document.createElement("a");f.style.display="none",f.href=ne,f.download=`audio.${c}`,document.body.appendChild(f),f.click(),f.remove()};return n.useEffect(()=>{(v||i)&&C!=null&&t!=null&&(t(C),l&&ae(C))},[C]),N.createElement("div",{className:`audio-recorder ${j?"recording":""} ${(u=o==null?void 0:o.AudioRecorderClass)!=null?u:""}`,"data-testid":"audio_recorder"},N.createElement("img",{src:j?Ze:Ye,className:`audio-recorder-mic ${(g=o==null?void 0:o.AudioRecorderStartSaveClass)!=null?g:""}`,onClick:j?()=>V():d,"data-testid":"ar_mic",title:j?"Save recording":"Start recording"}),N.createElement("span",{className:`audio-recorder-timer ${j?"":"display-none"} ${(M=o==null?void 0:o.AudioRecorderTimerClass)!=null?M:""}`,"data-testid":"ar_timer"},Math.floor(D/60),":",String(D%60).padStart(2,"0")),x?N.createElement("span",{className:`audio-recorder-visualizer ${j?"":"display-none"}`},m&&N.createElement(n.Suspense,{fallback:N.createElement(N.Fragment,null)},N.createElement(Ge,{mediaRecorder:m,barWidth:2,gap:2,width:140,height:30,fftSize:512,maxDecibels:-10,minDecibels:-80,smoothingTimeConstant:.4}))):N.createElement("span",{className:`audio-recorder-status ${j?"":"display-none"} ${(p=o==null?void 0:o.AudioRecorderStatusClass)!=null?p:""}`},N.createElement("span",{className:"audio-recorder-status-dot"}),"Recording"),N.createElement("img",{src:I?He:Pe,className:`audio-recorder-options ${j?"":"display-none"} ${(s=o==null?void 0:o.AudioRecorderPauseResumeClass)!=null?s:""}`,onClick:h,title:I?"Resume recording":"Pause recording","data-testid":"ar_pause"}),N.createElement("img",{src:Re,className:`audio-recorder-options ${j?"":"display-none"} ${(y=o==null?void 0:o.AudioRecorderDiscardClass)!=null?y:""}`,onClick:()=>V(!1),title:"Discard Recording","data-testid":"ar_cancel"}))},Be=({onClose:t,onSave:a})=>{const[i,r]=n.useState(!0),l=async x=>{const o=URL.createObjectURL(x),u=await fetch(o).then(M=>M.blob()),g=new File([u],"audiofile.mp3",{type:"audio/mp3"});a(g)},c=()=>{r(!1),t()};return e.jsx(ie,{open:i,onClose:c,children:e.jsx(oe,{children:e.jsx(Ve,{onRecordingComplete:l,audioTrackConstraints:{noiseSuppression:!0,echoCancellation:!0},downloadOnSavePress:!1,downloadFileExtension:"mp3"})})})},Je=()=>{const{selectedConsuling:t,consultantMessageList:a,addMessage:i,chatLoading:r}=te(),l=$();F(l.breakpoints.up("sm"));const c=n.useRef(),[x,o]=n.useState(""),[u,g]=n.useState(!1),M=async()=>{!x.length||!t||(await i({onlineConsultantId:t.id,message:x}),o(""))},p=async d=>{if(!(!d||!t))for(var L=0;L<d.length;L++)await i({onlineConsultantId:t.id,file:d[L]})},s=async d=>{t&&await i({onlineConsultantId:t.id,file:d})},y=()=>{var d;(d=c.current)==null||d.scrollIntoView({behavior:"smooth"})};return n.useEffect(()=>{y()},[a]),e.jsxs(w,{className:"border border-solid border-gray-400 rounded-xl h-[90vh] relative ",children:[r&&e.jsx(X,{}),u&&e.jsx(Be,{onClose:()=>g(!1),onSave:s}),e.jsx(w,{className:"absolute top-0 left-0 right-0 rounded-t-xl bg-indigo-500 p-3 h-[80px] ",children:e.jsx(b,{direction:"row",justifyContent:"start",alignItems:"center",spacing:1,children:t&&e.jsxs(e.Fragment,{children:[e.jsx(le,{component:"h6",color:"white",className:"!mr-[auto]",children:t==null?void 0:t.patientFullName}),e.jsx(ce,{sx:{width:56,height:56},src:`data:image/png;base64,${t.patientAvatar}`})]})})}),e.jsxs(w,{className:" h-[80%] mt-[80px] mb-[60px] p-[10px] overflow-y-auto  ",children:[!t&&e.jsx("div",{className:"flex justify-center items-center p-5",children:e.jsx("h4",{className:"text-gray-700",children:"لطفا یک مشاوره را انتخاب نمایید"})}),t&&!(a!=null&&a.length)&&e.jsx("div",{className:"flex justify-center items-center p-5",children:e.jsx("h4",{className:"text-gray-700",children:"پیامی برای نمایش وجود ندارد"})}),a==null?void 0:a.map(d=>e.jsx(ke,{message:d},d.id)),e.jsx("div",{ref:c})]}),e.jsx(w,{className:"absolute bottom-0 left-0 right-0 border-t-2 border-solid border-gray-400 rounded-b-xl h-[60px]  p-3 ",children:e.jsxs(b,{direction:"row",justifyContent:"start",alignItems:"center",spacing:1,mb:1,children:[e.jsx(k,{onClick:M,disabled:!t,children:e.jsx(Ie,{color:"info"})}),e.jsx(q,{disabled:!t,sx:{backgroundColor:"white !important"},value:x,onChange:d=>o(d),onKeyDown:d=>{d.key==="Enter"&&M()}}),e.jsx(k,{component:"label",onClick:()=>g(!0),disabled:!t,children:e.jsx(Ee,{color:"primary"})}),e.jsxs(k,{component:"label",disabled:!t,children:[e.jsx(Ne,{color:"success"}),e.jsx("input",{onChange:d=>{p(d.target.files)},hidden:!0,accept:"image/*,audio/mp3",type:"file"})]})]})})]})};var A={},_;function Ue(){if(_)return A;_=1;var t=H();Object.defineProperty(A,"__esModule",{value:!0}),A.default=void 0;var a=t(Y()),i=Q(),r=(0,a.default)((0,i.jsx)("path",{d:"M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"}),"MenuOutlined");return A.default=r,A}var We=Ue();const _e=P(We),Fe=()=>{const t=$(),a=F(t.breakpoints.up("md")),[i,r]=n.useState(!0);return e.jsxs(Ce,{container:!0,spacing:2,children:[e.jsx(E,{item:!0,xs:12,className:"flex",children:!a&&e.jsx(Le,{className:"!mr-[auto]",onClick:()=>r(l=>!l),children:e.jsx(_e,{color:"primary"})})}),!a&&e.jsx(de,{anchor:"right",open:i,onClose:()=>r(!1),onOpen:()=>r(!0),children:e.jsx(U,{})}),a&&e.jsx(E,{item:!0,md:4,lg:3,children:e.jsx(U,{})}),e.jsx(E,{item:!0,xs:12,md:8,lg:9,children:e.jsx(Je,{})})]})},tt=()=>e.jsx(ye,{children:e.jsx(Fe,{})});export{tt as default};
