https://upstox.com/copilot-page-assets/_next/static/chunks/pages/contact-us/chat-378e0e3274668967.js
1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[281],{51260:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/contact-us/chat",function(){return n(19716)}])},19716:function(e,t,n){"use strict";n.r(t);var o=n(85893),i=n(55772),l=n(82442),s=n(47304),u=n(28276),c=n(28294),a=n(60722),r=n(99389),d=n(98450),f=n(4011),v=n(20747),h=n(17421),E=n(28586),g=n(18698),_=n(87468),C=n(1881),p=n(71042),m=n(90384),w=n(84851),T=n(78647),I=n(11163),A=n(67294);t.default=(0,w.Pi)(()=>{var e,t;let n=(0,I.useRouter)(),[w,b]=(0,A.useState)(r.$A.LEAD),[x,L]=(0,A.useState)(""),[P,S]=(0,A.useState)(!1),[O,k]=(0,A.useState)(!0),{isRefreshInProgress:N,copilotChatTarget:y,updateChatData:R,setIsAwaitingForResponse:B,setIsFetchingMessages:H,isAwaitingForResponse:M,isFetchingMessages:D,threadMetaData:Q,setQuestionItemInChatData:U,chatData:j,documentsToUploadList:X,copilotChatSource:W,setCopilotChatSource:Z,setShowRaiseTicketEntryAnimation:q,showRaiseTicketEntryAnimation:G,isVoiceInput:K,setIsVoiceInput:z,sttOutput:F,setSttOutput:V,sendNotificationSound:$,setSendNotificationSound:J,maxSocketRetryAttemptExceeded:Y,setMaxSocketRetryAttemptExceeded:ee}=m.default,{wsKey:et,wsConnectionData:en,userProfile:eo,isLoggedIn:ei,isRemoteConfigInitialised:el,setIsRaiseTicketInCopilotChatbot:es,isRaiseTicketInCopilotChatbot:eu,userType:ec,resetWsReconnectionAttempts:ea}=p.default,{threadId:er,conversationId:ed,fcUserId:ef,isConvOpen:ev}=Q,eh=(0,A.useRef)(!1),eE=(0,A.useRef)(null),eg=(0,A.useRef)(null),{playNotificationSound:e_,triggerHapticFeedback:eC,hasSpeakerPermission:ep,hasHapticSupport:em,initializeNotification:ew,isInitialized:eT}=(0,f.S)(),eI=null==en?void 0:null===(e=en.COPILOT_CHATBOT)||void 0===e?void 0:e.connected,eA=(null==X?void 0:X.filter(e=>e.fileSource!==r.Uo.COPILOT_EMAIL_TICKET&&e.fileSource!==r.Uo.WEB_EMAIL_TICKET))||[],eb=(null==eA?void 0:eA.length)>0,ex=M&&y===r.A9.COLPILOT_ENGINE,eL=(0,A.useMemo)(()=>{var e;return el?null===v.B||void 0===v.B?void 0:null===(e=v.B.remotConfig)||void 0===e?void 0:e.showCopilotChatbot():h.Q.show_copilot_chatbot},[el]),eP=(0,A.useCallback)(()=>{eg.current&&clearTimeout(eg.current)},[]),eS=(0,A.useCallback)(()=>{eP(),eg.current=setTimeout(()=>{eE.current&&(eE.current.scrollTop=eE.current.scrollHeight)},0)},[eP]),eO=(0,A.useCallback)(()=>{var e;(null==en?void 0:null===(e=en[et])||void 0===e?void 0:e.connected)||eh.current||(E.Z.log("initiate socket connection"),eh.current=!0,C.Z.connect())},[en,et]),ek=(0,A.useCallback)(async()=>{if(null===ei)return!1;if(D){k(!1);return}H(!0);let e=await (0,i._U)(ei,1,()=>H(!1));if(e){let{messages:t,threadMetadata:n,pageMetadata:o}=e;t&&n&&o&&(R(t,n,o),1===n.isAgentHandover&&1===n.isOpenCopilotAgentHandover||1===n.isAgentHandoverTransition?(0,d.yQ)():1===n.isLoginTransition&&(0,d.Ss)()),k(!1)}else k(!1)},[ei,D,H,R]),eN=(0,A.useCallback)(()=>{b(g.D.getCookie("user_type")||r.$A.LEAD)},[]),ey=(0,A.useCallback)(async()=>{let e=await (0,i.nQ)();if(e){var t,n,o;(0,d.wX)(e);let i=null==e?void 0:null===(t=e.userInfo)||void 0===t?void 0:t.ucc;i&&(null===(n=v.B.fireBaseAnalytics)||void 0===n||n.setUserProperties({UCC:i}),await (null===(o=v.B.remotConfig)||void 0===o?void 0:o.refetchConfig()))}},[]),eR=(0,A.useCallback)(()=>{Z(r.cX.RAISE_EMAIL_TICKET),q(!0),es(!1)},[Z,q,es]);(0,A.useEffect)(()=>{{let e=window.innerWidth>=1024;(e||!eL)&&n.replace("/contact-us")}n.asPath.includes("#raiseTicket")?eR():Z(r.cX.GENERAL_SUPPORT_INAPP)},[n,n.asPath,eL,eR,Z,es]),(0,A.useEffect)(()=>{function appHeight(){let e=document.documentElement;e.style.setProperty("--vh",.01*window.innerHeight+"px")}return document.body.style.overflow="hidden",window.addEventListener("resize",appHeight),()=>{Z(r.cX.GENERAL_SUPPORT),q(!1),es(!1),document.body.style.overflow="auto",window.removeEventListener("resize",appHeight)}},[]),(0,A.useEffect)(()=>{ei&&(eN(),ey())},[ey,ei,eN]),(0,A.useEffect)(()=>(eI&&j.length&&eS(),eP),[eI,j,eS,eP]),(0,A.useEffect)(()=>{{let e=window.innerWidth>=1024;e&&n.replace("/contact-us")}},[]),(0,A.useEffect)(()=>{null!==ei&&eO()},[eO,ei]),(0,A.useEffect)(()=>{var e;null!==ei&&(null==en?void 0:null===(e=en[et])||void 0===e?void 0:e.connected)&&el&&ek()},[ei,null==en?void 0:null===(t=en[et])||void 0===t?void 0:t.connected,el]),(0,A.useEffect)(()=>{N&&ek()},[N,ek]),(0,A.useEffect)(()=>{!eI&&M&&B(!1)},[M,B,eI]),(0,A.useEffect)(()=>{(0,d.sQ)({threadMetaData:Q})},[Q]),(0,A.useEffect)(()=>{$&&document.hidden&&(ep&&e_(),em&&eC()),J(!1)},[$,e_,eC,J,em,ep]);let eB=(0,A.useMemo)(()=>{var e;return el?null===v.B||void 0===v.B?void 0:null===(e=v.B.remotConfig)||void 0===e?void 0:e.getCopilotDefaultQuestions():h.Q.copilot_chatbot_default_questions},[el]),eH=(0,A.useMemo)(()=>(0,d.Br)(ec||w,eB),[ec,w,eB]),eM=(0,A.useCallback)(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(y!==r.A9.COLPILOT_ENGINE){let e=g.H.getCookie("copilot_chat_flow");e&&(0,d._n)("new"===e)}let o=2===K&&(null==F?void 0:F.trim())!==(null==e?void 0:e.trim()),i={question:e,questionId:"QUES-".concat((0,T.x0)().replace(/_/g,"-")),questionTimestamp:Date.now(),isPrompt:t?1:0,isFunctionPrompt:n?1:0,isVoiceInput:2===K?o?1:2:K,sttOutput:K&&o?F:null}
1,l=(0,d.Pu)(),s={...i,requestId:"WUPW-".concat((0,T.x0)().replace(/_/g,"-")),source:W,threadId:G&&W===r.cX.RAISE_EMAIL_TICKET?null:er,conversationId:ed,target:(0,d.Af)((0,d.sG)(Q)?r.A9.FRESHCHAT_USER_REOPEN_CONV:y),fcSignedUrls:l,...(0,d.mM)(ef,y),...(0,d.z8)(eo,y)};C.Z.send(s),K&&z(0),F&&V(null),eT||ew(),U({...i,attachmentUrls:l,responses:[]}),eu&&es(!1),G&&q(!1),B(!0)},[Q,y,eo,eu,G,q,es,B,er,ed,ef,U,W,K,z,F,V,ew,eT]);return(0,o.jsxs)("div",{className:"custom-scroll-bar dynamic-view-height fixed inset-0 flex w-screen flex-col overflow-x-hidden bg-white",children:[(0,o.jsx)(u.R,{isLoggedIn:ei}),!eu&&(0,o.jsx)(l.K,{showLoadingIndicator:ex,shouldExpandChatbotWidget:!0,chatData:j,isConvOpen:ev,isDefaultStaticQuestionsExpanded:P,chatBodyDivElementRef:eE,isLoggedIn:ei,isFetchingMessages:D}),!eu&&eb&&(0,o.jsx)(c.sB,{documents:eA}),eu&&(0,o.jsx)(a.Z,{}),Y&&(0,o.jsxs)("div",{className:"z-50 flex text-sm justify-center gap-1 mb-2",children:[(0,o.jsx)("p",{className:"text-center font-semibold leading-5",children:"Looks like we lost connection."}),(0,o.jsx)("p",{className:"cursor-pointer text-center font-semibold leading-5 text-danger underline",onClick:()=>{var e;(null==en?void 0:null===(e=en[et])||void 0===e?void 0:e.connected)||(ee(!1),ea(_.q.COPILOT_CHATBOT),C.Z.connect())},role:"button",children:"Refresh Chat"})]}),!eu&&(0,o.jsx)(s.Z,{selectedCategory:x,setSelectedCategory:L,handleSendMessage:eM,chatData:j,disableMsgSendAction:ex||!eI||O,defaultQuestionsList:eH,showDefaultStaticQuestions:P,toggleDefaultStaticQuestions:S})]})})}},function(e){e.O(0,[296,530,997,774,888,179],function(){return e(e.s=51260)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.