more-desk-one 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +12 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
chat_handover
|
|
113
113
|
is_new
|
|
114
114
|
}
|
|
115
|
-
}`,Do=10,Sm=()=>{const[e,t]=N.useState([]),[n,r]=N.useState(!0),[o,s]=N.useState(null),[i,a]=N.useState(!1),[c,l]=N.useState(""),u=N.useRef(!0),{accessToken:d}=_t(),m=()=>{cn(No,{limit:Do,search_key:c},d).then(async p=>{t(p?.EmployeeAssistTickets??[])}).catch(p=>{s(p)}).finally(()=>{r(!1)})};return N.useEffect(()=>{if(u.current){u.current=!1,m();return}const p=setTimeout(()=>{m()},400);return()=>clearTimeout(p)},[c]),{ticketData:e,loading:n,error:o,getNextPageTicketData:p=>{d&&(i||(a(!0),cn(No,{limit:Do,offset:p},d).then(async h=>{const{EmployeeAssistTickets:b}=h;t(y=>[...y,...b])}).catch(h=>{s(h)}).finally(()=>{a(!1)})))},isLoadingMore:i,setSearchText:l}};function zn(e){return(e?new Date(e):new Date).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:"Asia/Kolkata"})}function Rm(e,t="Asia/Kolkata",n="en-GB"){const r=new Date(e);if(Number.isNaN(r.getTime()))return"";const o=new Intl.DateTimeFormat(n,{day:"2-digit",month:"short",year:"2-digit",timeZone:t}).formatToParts(r),s=o.find(l=>l.type==="day")?.value??"",i=o.find(l=>l.type==="month")?.value??"",a=o.find(l=>l.type==="year")?.value??"",c=new Intl.DateTimeFormat(n,{hour:"2-digit",minute:"2-digit",hour12:!1,timeZone:t}).format(r);return`${s} ${i} ‘${a}, ${c}`}const cr=(e,t)=>{sessionStorage.setItem(e,JSON.stringify(t))},ft=e=>{const t=sessionStorage.getItem(e);return t?JSON.parse(t):null},Am=()=>{const e=N.useRef(null),t=N.useRef(null),n=N.useRef(null),{ticketData:r,loading:o,getNextPageTicketData:s,isLoadingMore:i,setSearchText:a}=Sm(),{setIsChatScreen:c,profileInfo:l}=_t();N.useLayoutEffect(()=>{e.current},[r.length]);const u=v=>{const p=v.currentTarget;if(n.current?.blur(),p.scrollHeight<=p.clientHeight)return;const h=p.scrollHeight-p.scrollTop-p.clientHeight,b=r.length;t.current!==b&&h<=20&&!o&&(t.current=b,s(b))},d=v=>{cr("userAndTicket",{ticket_id:v,employee_id:l?.employee_id}),c(p=>!p)},m=v=>{v.preventDefault();const p=n.current?.value?.trim();a(p??null)};return g.jsxs("div",{className:"mhb-flex mhb-flex-col mhb-h-full mhb-min-h-0",children:[g.jsx("div",{className:"mhb-searchbarContainer mhb-flex mhb-flex-col mhb-border-b mhb-border-neutral-20",children:g.jsx(bm,{ref:n,onChangeHandler:m})}),g.jsx("div",{ref:e,onScroll:u,className:"mhb-history-main-container mhb-no-scrollbar mhb-py-3 mhb-flex mhb-flex-col mhb-gap-1 mhb-overflow-y-auto mhb-flex-1 mhb-min-h-0",children:o?g.jsx(sr,{}):g.jsxs(g.Fragment,{children:[r.map(v=>g.jsxs("button",{type:"button",className:"mhb-history-container mhb-p-3 mhb-flex mhb-flex-col mhb-rounded-[12px] mhb-bg-neutral-10 mhb-gap-2 mhb-items-start",onClick:()=>d(v.ticket_id),children:[g.jsx("div",{className:"mhb-flex mhb-
|
|
115
|
+
}`,Do=10,Sm=()=>{const[e,t]=N.useState([]),[n,r]=N.useState(!0),[o,s]=N.useState(null),[i,a]=N.useState(!1),[c,l]=N.useState(""),u=N.useRef(!0),{accessToken:d}=_t(),m=()=>{cn(No,{limit:Do,search_key:c},d).then(async p=>{t(p?.EmployeeAssistTickets??[])}).catch(p=>{s(p)}).finally(()=>{r(!1)})};return N.useEffect(()=>{if(u.current){u.current=!1,m();return}const p=setTimeout(()=>{m()},400);return()=>clearTimeout(p)},[c]),{ticketData:e,loading:n,error:o,getNextPageTicketData:p=>{d&&(i||(a(!0),cn(No,{limit:Do,offset:p},d).then(async h=>{const{EmployeeAssistTickets:b}=h;t(y=>[...y,...b])}).catch(h=>{s(h)}).finally(()=>{a(!1)})))},isLoadingMore:i,setSearchText:l}};function zn(e){return(e?new Date(e):new Date).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:"Asia/Kolkata"})}function Rm(e,t="Asia/Kolkata",n="en-GB"){const r=new Date(e);if(Number.isNaN(r.getTime()))return"";const o=new Intl.DateTimeFormat(n,{day:"2-digit",month:"short",year:"2-digit",timeZone:t}).formatToParts(r),s=o.find(l=>l.type==="day")?.value??"",i=o.find(l=>l.type==="month")?.value??"",a=o.find(l=>l.type==="year")?.value??"",c=new Intl.DateTimeFormat(n,{hour:"2-digit",minute:"2-digit",hour12:!1,timeZone:t}).format(r);return`${s} ${i} ‘${a}, ${c}`}const cr=(e,t)=>{sessionStorage.setItem(e,JSON.stringify(t))},ft=e=>{const t=sessionStorage.getItem(e);return t?JSON.parse(t):null},Am=()=>{const e=N.useRef(null),t=N.useRef(null),n=N.useRef(null),{ticketData:r,loading:o,getNextPageTicketData:s,isLoadingMore:i,setSearchText:a}=Sm(),{setIsChatScreen:c,profileInfo:l}=_t();N.useLayoutEffect(()=>{e.current},[r.length]);const u=v=>{const p=v.currentTarget;if(n.current?.blur(),p.scrollHeight<=p.clientHeight)return;const h=p.scrollHeight-p.scrollTop-p.clientHeight,b=r.length;t.current!==b&&h<=20&&!o&&(t.current=b,s(b))},d=v=>{cr("userAndTicket",{ticket_id:v,employee_id:l?.employee_id}),c(p=>!p)},m=v=>{v.preventDefault();const p=n.current?.value?.trim();a(p??null)};return g.jsxs("div",{className:"mhb-flex mhb-flex-col mhb-h-full mhb-min-h-0",children:[g.jsx("div",{className:"mhb-searchbarContainer mhb-flex mhb-flex-col mhb-border-b mhb-border-neutral-20",children:g.jsx(bm,{ref:n,onChangeHandler:m})}),g.jsx("div",{ref:e,onScroll:u,className:"mhb-history-main-container mhb-no-scrollbar mhb-py-3 mhb-flex mhb-flex-col mhb-gap-1 mhb-overflow-y-auto mhb-flex-1 mhb-min-h-0",children:o?g.jsx(sr,{}):g.jsxs(g.Fragment,{children:[r.map(v=>g.jsxs("button",{type:"button",className:"mhb-btn-reset mhb-history-container mhb-p-3 mhb-flex mhb-flex-col mhb-rounded-[12px] mhb-bg-neutral-10 mhb-gap-2 mhb-items-start",onClick:()=>d(v.ticket_id),children:[g.jsx("div",{className:"mhb-flex mhb-items-start",children:g.jsx("p",{className:"mhb-typography-para-thick-30 mhb-text-neutral-110 mhb-m-0 mhb-min-w-0 mhb-break-words mhb-whitespace-normal mhb-text-left",children:v.title})}),g.jsx("p",{className:"mhb-typography-para-30 mhb-text-neutral-60 mhb-m-0",children:Rm(v.created_at)})]},v.ticket_id)),i&&g.jsx(sr,{})]})})]})},km=({isChatScreen:e,setIsChatScreen:t})=>{const n=()=>{t(o=>!o)},r=()=>{sessionStorage.removeItem("userAndTicket"),t(o=>!o)};return g.jsxs("div",{className:"mhb-header mhb-border-b mhb-border-neutral-20 mhb-flex mhb-items-center mhb-justify-between",children:[g.jsx(am,{className:"h-[36px] w-[36px] fill-current"}),g.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[e?g.jsx("div",{className:"mhb-btn-reset mhb-p-3 mhb-invisible mhb-typography-para-thick-30",children:"new chat"}):g.jsx("button",{type:"button",onClick:r,className:"mhb-btn-reset mhb-p-3 mhb-bg-neutral-10 mhb-typography-para-thick-30 mhb-rounded-[9999px]",children:"new chat"}),g.jsx("button",{type:"button",className:"mhb-btn-reset mhb-h-[36px] mhb-w-[36px] mhb-flex mhb-items-center mhb-justify-center mhb-rounded-full mhb-bg-neutral-10",onClick:n,children:e?g.jsx(dm,{className:"mhb-h-[16px] mhb-w-[16px] fill-current"}):g.jsx(cm,{className:"mhb-h-[16px] mhb-w-[16px]"})})]})]})},Io=`
|
|
116
116
|
mutation AssistChat(
|
|
117
117
|
$message: String!
|
|
118
118
|
$ticket_id: Int
|
|
@@ -156,7 +156,10 @@ mutation AssistChat(
|
|
|
156
156
|
onAssistChat(ticket_id: $ticket_id) {
|
|
157
157
|
message_id
|
|
158
158
|
text
|
|
159
|
-
attachments
|
|
159
|
+
attachments {
|
|
160
|
+
filename
|
|
161
|
+
url
|
|
162
|
+
}
|
|
160
163
|
created_at
|
|
161
164
|
ticket_id
|
|
162
165
|
handover
|
|
@@ -168,5 +171,5 @@ mutation AssistChat(
|
|
|
168
171
|
}
|
|
169
172
|
}`,Vn=10,Om=()=>{const[e,t]=N.useState([]),[n,r]=N.useState(!0),[o,s]=N.useState(null),[i,a]=N.useState(!1),[c,l]=N.useState(!1),[u,d]=N.useState(!0),{accessToken:m,profileInfo:v}=_t(),p=ft("userAndTicket")?.ticket_id,h=ft("userAndTicket")?.employee_id,b=N.useMemo(()=>e.find(R=>R.ticket_id!=null)?.ticket_id??null,[e]);let y=p??b??null;return N.useEffect(()=>{if(!y||!v)return;if(h&&v?.employee_id!=h){sessionStorage.removeItem("userAndTicket");return}const R=Em(Pm,{ticket_id:y},x=>{const E=x;E?.onAssistChat?.user?.user_type==="agent"&&t(S=>[...S,E.onAssistChat])});return()=>R()},[y,v]),N.useEffect(()=>{if(!m||!v)return;h&&v?.employee_id!==h&&(sessionStorage.removeItem("userAndTicket"),y=null);const R={...y&&{ticket_id:y},limit:Vn};cn(Fo,R,m).then(async x=>{t(x?.assistHistory??[])}).catch(x=>{s(x)}).finally(()=>{r(!1)})},[v]),{historyData:e,msgLoading:n,msgError:o,isSending:c,sendMessage:R=>{const x=e.find(P=>P.ticket_id!=null)?.ticket_id??null,E=e.find(P=>P.handover==!0)?.handover??!1,S={...x&&{ticket_id:x},message:R,handover:E,attachments:[],text:R,message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:v?.full_name,user_type:"employee"}};l(!0),t(P=>[...P,S]),Hn(Io,S,m).then(async P=>{const F=P;F.assistChat.user.user_type!=="employee"&&t(L=>[...L,F.assistChat]),!ft("userAndTicket")&&F.assistChat?.ticket_id&&v&&cr("userAndTicket",{ticket_id:F.assistChat?.ticket_id,employee_id:v.employee_id})}).catch(()=>t(P=>P.slice(0,-1))).finally(()=>l(!1))},getNextPageData:R=>{if(!m||i)return;const x=ft("userAndTicket")?.ticket_id,E={...x&&{ticket_id:x},limit:Vn,offset:R};a(!0),cn(Fo,E,m).then(async S=>{const F=S?.assistHistory??[];t(L=>[...F,...L]),F.length<Vn&&d(!1)}).catch(S=>{s(S)}).finally(()=>{a(!1)})},isLoadingMore:i,upload:async R=>{l(!0);const x={files:R.files.map(E=>`${R.ticketId}/${E.name}`),signature_type:R.signature_type};try{const E=await Hn(_m,x,m);for(const[j,W]of R.files.entries()){const D=E.GetPresignedLink[j]?.url;D&&await fetch(D,{method:"PUT",body:W,headers:{"Content-Type":W.type}})}const S=e.find(j=>j.handover)?.handover??!1,P=R.files.map(j=>({url:URL.createObjectURL(j),filename:j.name})),F={ticket_id:R.ticketId,handover:S,attachments:P,text:"",message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:v?.full_name,user_type:"employee"}};t(j=>[...j,F]);const L={ticket_id:R.ticketId,handover:S,attachments:R.files.map(j=>`${R.ticketId}/${j.name}`),message:"",text:"",message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:v?.full_name,user_type:"employee"}},B=await Hn(Io,L,m);B.assistChat.user.user_type!=="employee"&&t(j=>[...j,B.assistChat]),!ft("userAndTicket")&&B.assistChat?.ticket_id&&v&&cr("userAndTicket",{ticket_id:B.assistChat.ticket_id,employee_id:v.employee_id})}catch{t(S=>S.slice(0,-1))}finally{l(!1)}},hasMore:u}},Tm=({toastMsg:e})=>g.jsxs("div",{id:"toast-simple",className:"mhb-border-red-60 mhb-fixed mhb-bottom-6 mhb-right-6 mhb-z-50 mhb-flex mhb-max-w-xs mhb-items-center mhb-space-x-4 mhb-divide-x mhb-divide-gray-200 mhb-rounded-lg mhb-border mhb-bg-white mhb-p-4 mhb-text-gray-700 mhb-shadow-lg dark:mhb-divide-gray-700 dark:mhb-border-gray-600 dark:mhb-bg-gray-800 dark:mhb-text-gray-300",role:"alert",children:[g.jsx("svg",{className:"mhb-text-red-60 mhb-h-3 mhb-w-3","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 14 14",children:g.jsx("path",{stroke:"currentColor",d:"m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"})}),g.jsx("div",{className:"mhb-text-red-60 mhb-typography-label-thick-30 mhb-ps-4",children:e})]}),Mm=N.memo(({url:e,msg:t,isFirstInGroup:n,fileType:r})=>{const[o,s]=N.useState(!1),i=async()=>{const a=t.attachments[0],l=await(await fetch(a.url)).blob(),u=URL.createObjectURL(l),d=document.createElement("a");d.href=u,d.download=a.filename||"download.pdf",d.click(),URL.revokeObjectURL(u)};return g.jsxs(g.Fragment,{children:[(r==="jpg"||r==="jpeg"||r==="png")&&g.jsx("div",{className:"mhb-flex",children:g.jsx("div",{className:`mhb-rounded-[16px] mhb-bg-white ${t?.user?.user_type==="customer"?"mhb-ml-auto":"mhb-mr-auto"} ${n?t?.user?.user_type==="customer"?"mhb-rounded-tr-[4px]":"mhb-rounded-tl-[4px]":""}`,children:g.jsx("div",{className:"mhb-overflow-x-auto mhb-rounded-[16px] mhb-bg-neutral-10 mhb-px-1 mhb-py-1",children:g.jsx("div",{className:"mhb-flex mhb-w-fit mhb-space-x-1",children:g.jsx("div",{className:"mhb-h-[44px] mhb-w-[44px] mhb-flex-shrink-0 mhb-rounded-[12px] mhb-bg-white",children:g.jsx("img",{src:e,alt:"Attachment",className:"mhb-h-[44px] mhb-w-[44px] mhb-rounded-[12px] mhb-object-cover",onClick:()=>s(!0)})})})})})}),r==="pdf"&&g.jsxs("button",{className:"mhb-flex mhb-w-full mhb-items-center mhb-justify-between mhb-gap-3 mhb-rounded-[20px] mhb-mhb-border mhb-border-neutral-10 mhb-bg-white p-3 focus:mhb-outline-none",onClick:()=>i(),children:[g.jsx("div",{className:"mhb-relative mhb-flex mhb-h-[36px] mhb-w-[36px] mhb-items-center mhb-justify-center mhb-rounded-[8px] mhb-bg-neutral-20",children:g.jsx("p",{className:"mhb-absolute mhb-text-white mhb-typography-para-40",children:"pdf"})}),g.jsx("p",{className:"mhb-max-w-[50px] mhb-overflow-hidden mhb-text-ellipsis mhb-whitespace-nowrap mhb-text-neutral-110 mhb-typography-para-thick-30",children:t.attachments[0].filename.split(/[/_]/).pop()})]})]})},(e,t)=>e.url===t.url&&e.isFirstInGroup===t.isFirstInGroup&&e.msg.user?.user_type===t.msg.user?.user_type&&e.fileType===t.fileType),jo=["image/jpeg","image/jpg","image/png","application/pdf"],Fm=()=>{const[e,t]=N.useState(""),n=N.useRef(null),r=N.useRef(null),o=N.useRef(null),s=N.useRef(0),i=N.useRef(0),a=N.useRef(!1),{historyData:c,sendMessage:l,getNextPageData:u,isLoadingMore:d,isSending:m,upload:v,msgLoading:p,hasMore:h}=Om();N.useLayoutEffect(()=>{const x=n.current;if(x)if(a.current){const E=s.current,S=i.current,F=x.scrollHeight-E;x.scrollTop=S+F,a.current=!1}else x.scrollTop=x.scrollHeight},[c?.length]);const b=()=>{const x=r.current?.value?.trim();h||(a.current=!1),x&&(l(x),r.current&&(r.current.value=""))},y=x=>{m||x.key==="Enter"&&(x.preventDefault(),b())},k=x=>{const E=x.currentTarget;if(E.scrollHeight>E.clientHeight&&E.scrollTop<=20&&!d){const P=c.length;s.current=E.scrollHeight,i.current=E.scrollTop,a.current=!0,u(P)}},C=x=>{const E=Array.from(x.target.files||[]),S=E.filter(L=>jo.includes(L.type));if(E.filter(L=>!jo.includes(L.type)).length>0){t("Only JPG, PNG, and PDF files are allowed. Other files like videos are not supported."),setTimeout(()=>t(null),3e3),x.target.value="";return}const F=c[c?.length-1]?.ticket_id;S.length>0&&F&&v({files:S,signature_type:"upload",ticketId:F})},A=()=>{o.current?.click()},R=N.useMemo(()=>c?.some(x=>x.handover==!0),[c]);return g.jsxs("div",{className:"mhb-flex mhb-h-full mhb-flex-col mhb-overflow-hidden mhb-bg-white",children:[g.jsx(g.Fragment,{children:p?g.jsx("div",{className:"mhb-py-3",children:g.jsx(sr,{})}):g.jsxs(g.Fragment,{children:[g.jsx("div",{ref:n,className:"mhb-flex-grow mhb-overflow-y-auto mhb-py-3 [&>*]:[mhb-overflow-anchor:none]",onScroll:k,children:g.jsx("div",{className:"mhb-flex mhb-min-h-full mhb-flex-col mhb-justify-end mhb-gap-1",children:c?.map((x,E)=>{const S="user"in x&&E===0||c[E-1]?.user?.user_type!==x?.user?.user_type,P=new Date(x.created_at??""),F=E>0?new Date(c[E-1].created_at??""):null,L=!F||P.getDate()!==F.getDate()||P.getMonth()!==F.getMonth()||P.getFullYear()!==F.getFullYear(),V=F&&P.getTime()-F.getTime()>120*1e3,B=x.hasOwnProperty("user")&&(S||L||V),j=x?.attachments?.some(W=>{const D=W.filename.match(/\.([a-zA-Z0-9]+)(?:\?|$)/)?.[1]?.toLowerCase();return["jpg","jpeg","png"].includes(D||"")});return g.jsx("div",{className:`mhb-flex ${x.user.user_type==="bot"||x.user.user_type==="agent"?"mhb-justify-start":"mhb-justify-end"}`,children:g.jsxs("div",{className:"mhb-max-w-[75%]",children:[B&&g.jsx("div",{className:`mhb-mb-1 mhb-flex mhb-items-center ${x.user.user_type==="bot"||x.user.user_type==="agent"?"mhb-justify-start":"mhb-justify-end"}`,children:x.user.user_type==="bot"?g.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[g.jsxs("div",{className:"mhb-flex mhb-items-center mhb-gap-1",children:[g.jsx(mm,{}),g.jsx("div",{className:"mhb-mb-1",children:g.jsx(pm,{})})]}),g.jsxs("div",{className:"mhb-flex mhb-gap-1 mhb-mt-[2px] mhb-items-center",children:[g.jsx("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60"}),g.jsx("p",{className:"mhb-typography-para-40 mhb-text-neutral-60",children:zn(x.created_at)})]})]}):x.user.user_type==="employee"?g.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[g.jsxs("div",{className:"mhb-flex mhb-gap-1",children:[g.jsx("p",{className:"mhb-typography-para-40 mhb-text-neutral-60",children:zn(x.created_at)}),g.jsx("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60 mhb-flex mhb-self-center"})]}),g.jsx(To,{name:x?.user?.user_name||"",employeeId:"",className:"mhb-size-4 mhb-shrink-0 mhb-rounded-full mhb-select-none"})]}):x.user.user_type==="agent"?g.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[g.jsx(To,{name:x?.user?.user_name||"",employeeId:"",className:"mhb-size-4 mhb-shrink-0 mhb-rounded-full mhb-select-none"}),g.jsxs("div",{className:"mhb-flex mhb-gap-1 mhb-mt-1 mhb-items-center",children:[g.jsx("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60"}),g.jsx("p",{className:"mhb-typography-para-40 mhb-text-neutral-60",children:zn(x.created_at)})]})]}):null}),g.jsx("div",{className:"mhb-flex mhb-overflow-hidden mhb-min-w-0",children:Array.isArray(x?.attachments)&&x?.attachments?.length>0?g.jsx("div",{className:`mhb-p-1 mhb-rounded-[16px] ${x.user.user_type==="bot"||x.user.user_type==="agent"?`mhb-bg-orange-60 ${B?"mhb-rounded-tl-[4px]":"mhb-rounded-[20px]"}`:`mhb-bg-neutral-10 ${B?"mhb-rounded-tr-[4px]":"mhb-rounded-[20px]"}`} ${j?"mhb-overflow-x-auto mhb-flex":"mhb-flex mhb-flex-col mhb-gap-1"}`,children:x.attachments.map((W,D)=>g.jsx("div",{children:g.jsx(Mm,{url:W.url,msg:x,isFirstInGroup:!1,fileType:W?.filename.match(/\.([a-zA-Z0-9]+)(?:\?|$)/)?.[1]?.toLowerCase()||""})},D))}):g.jsx("p",{className:`mhb-whitespace-pre-line mhb-break-words mhb-rounded-[16px] mhb-p-3
|
|
170
173
|
mhb-typography-para-30 mhb-ml-auto ${x.user.user_type==="bot"||x.user.user_type==="agent"?`mhb-bg-orange-60 mhb-text-white ${B?"mhb-rounded-tl-[4px]":"mhb-rounded-[20px]"} `:`mhb-bg-neutral-10 mhb-text-neutral-110 ${B?"mhb-rounded-tr-[4px]":"mhb-rounded-[20px]"} `}
|
|
171
|
-
`,children:x?.text})})]})},x.message_id)})})}),g.jsx("div",{className:"mhb-chat-input-container mhb-sticky mhb-bottom-0 mhb-bg-white mhb-py-3 mhb-flex mhb-items-center mhb-gap-2",children:g.jsxs("div",{className:"mhb-bg-neutral-10 mhb-flex mhb-h-[80px] mhb-flex-1 mhb-rounded-xl mhb-p-3",children:[g.jsx("div",{className:"mhb-flex mhb-flex-1",children:g.jsx("textarea",{ref:r,placeholder:"Type your message here...",className:"mhb-textarea mhb-flex-grow mhb-text-neutral-70 mhb-caret-orange-70 mhb-typography-para-30 mhb-bg-transparent mhb-resize-none placeholder:mhb-text-neutral-40",
|
|
174
|
+
`,children:x?.text})})]})},x.message_id)})})}),g.jsx("div",{className:"mhb-chat-input-container mhb-sticky mhb-bottom-0 mhb-bg-white mhb-py-3 mhb-flex mhb-items-center mhb-gap-2",children:g.jsxs("div",{className:"mhb-bg-neutral-10 mhb-flex mhb-h-[80px] mhb-flex-1 mhb-rounded-xl mhb-p-3",children:[g.jsx("div",{className:"mhb-flex mhb-flex-1",children:g.jsx("textarea",{ref:r,placeholder:"Type your message here...",className:"mhb-btn-reset mhb-textarea mhb-flex-grow mhb-text-neutral-70 mhb-caret-orange-70 mhb-typography-para-30 mhb-bg-transparent mhb-resize-none placeholder:mhb-text-neutral-40",onKeyDown:y})}),g.jsxs("div",{className:"mhb-flex mhb-gap-1 mhb-justify-end mhb-items-end",children:[R&&g.jsxs("button",{type:"button",className:"mhb-btn-reset mhb-h-[36px] mhb-w-[36px] mhb-rounded-full mhb-bg-neutral-100 mhb-flex mhb-items-center mhb-justify-center mhb-outline-none",disabled:m,onClick:A,children:[g.jsx(fm,{className:"h-[16px] w-[16px] mhb-fill-current"}),g.jsx("input",{type:"file",multiple:!0,accept:".jpg,.jpeg,.png,.pdf",ref:o,onChange:C,className:"hidden"})]}),g.jsx("button",{type:"button",className:"mhb-btn-reset mhb-h-[36px] mhb-rounded-[9999px] mhb-bg-orange-60 mhb-flex mhb-p-3 mhb-items-center mhb-justify-center mhb-shadow-[0_4px_12px_0_rgba(250,75,22,0.50)] mhb-outline-none",disabled:m,onClick:b,children:g.jsx("p",{className:"mhb-typography-label-thick-30 mhb-text-white",children:"Send"})})]})]})})]})}),e&&g.jsx(Tm,{toastMsg:e})]})};function Nm({side:e="top",align:t="end"}){const{authorized:n,isChatScreen:r,setIsChatScreen:o,accessToken:s,setProfileInfo:i}=_t(),a=async()=>{const c=await an.getProfileDetails();i(c)};return N.useEffect(()=>{s&&a()},[]),g.jsx("div",{className:"mhb-root",children:g.jsx(hm,{side:e,align:t,children:g.jsxs("div",{className:"mhb-h-full mhb-w-full mhb-flex mhb-flex-col mhb-min-h-0",children:[g.jsx(km,{isChatScreen:r,setIsChatScreen:o}),r?g.jsx(Fm,{}):g.jsx(Am,{})]})})})}function Dm(e){const{apiKey:t,accessToken:n}=e;if(!t||!n)throw new Error("Missing parameters: apiKey, and accessToken are required")}let lr=null,ln=!1,Yt=[];function Im(){for(const e of Yt)e()}function jm(e){ln||(Dm(e),an.init({env:e.env,redirectUrl:e.redirectUrl,app:e.app,idp:e.idp}),lr=e,ln=!0,Im(),Cm({apiKey:e.apiKey,apiURL:e.apiURL}))}function Lm(e){const[t,n]=N.useState({initialized:ln,sdkOptions:lr});return N.useEffect(()=>{const r=()=>{n({initialized:ln,sdkOptions:lr})};return Yt.push(r),()=>{Yt=Yt.filter(o=>o!==r)}},[]),!t.initialized||!t.sdkOptions?null:g.jsx(Gp,{appName:t.sdkOptions.app,apiKey:t.sdkOptions.apiKey,token:t.sdkOptions.accessToken,children:g.jsx(Nm,{...e})})}exports.ChatButton=Lm;exports.init=jm;
|
|
172
175
|
//# sourceMappingURL=index.cjs.map
|