(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[531],{40067:function(e,t,s){Promise.resolve().then(s.bind(s,4741)),Promise.resolve().then(s.bind(s,92158)),Promise.resolve().then(s.t.bind(s,58325,23)),Promise.resolve().then(s.t.bind(s,66927,23)),Promise.resolve().then(s.bind(s,51770)),Promise.resolve().then(s.t.bind(s,73994,23))},84579:function(e,t,s){"use strict";var l=s(57437);t.Z=e=>{let{size:t="default"}=e,s="small"===t?"h-2 w-2":"medium"===t?"h-3 w-3":"large"===t?"h-8 w-8":"h-5 w-5 ";return(0,l.jsxs)("div",{className:"flex",children:[(0,l.jsx)("div",{className:"".concat(s," rounded-full mr-2 animate-bounce bg-sky-400")}),(0,l.jsx)("div",{className:"".concat(s," rounded-full mr-2 animate-bounce200 bg-sky-500")}),(0,l.jsx)("div",{className:"".concat(s," rounded-full mr-2 animate-bounce300 bg-sky-600")}),(0,l.jsx)("div",{className:"".concat(s," rounded-full animate-bounce400 bg-sky-700")})]})}},73228:function(e,t,s){"use strict";var l=s(57437),n=s(78311),a=s(53159),r=s(84579);t.Z=e=>{let{loading:t,failure:s,noData:i,coloredBg:o,children:c,minHeight:d,className:u,fullHeight:m}=e;return(0,l.jsxs)("div",{className:"flex justify-center items-center !bg-white "+(o?" ".concat(o||" bg-cyan-200 "," "):"")+(t&&" min-h-screen z-50 ")+(m&&" min-h-screen "),children:[t&&(0,l.jsx)(r.Z,{}),s&&(0,l.jsx)(n.W2,{className:"".concat(d||"min-h-[400px] "," w-full flex justify-center !p-0 ").concat(u||" "),containerFluid:!0,children:(0,l.jsxs)("div",{className:"p-4 text-red-900 text-center ",children:[(0,l.jsx)(a.DAO,{}),(0,l.jsx)("div",{children:c||"Some error occurred! Please try again later"})]})}),i&&(0,l.jsx)(n.W2,{className:"".concat(d||"min-h-[400px] "," flex justify-center items-center !p-0 ").concat(u||" "),containerFluid:!0,children:(0,l.jsxs)("div",{className:"p-4 text-red-900 text-center",children:[(0,l.jsx)(a.DAO,{}),(0,l.jsx)("div",{children:c||"Sorry! No data Found"})]})})]})}},35362:function(e,t,s){"use strict";s.d(t,{Z:function(){return chat_ChatInputBox}});var l=s(57437),n=s(2265),a=s(43164),r=s(36468),i=s(4741),o=s(41697),c=s(24033);function getChatInputCharacterLimit(e){if(void 0===e)return 200;let t=Number(e);return isNaN(t)?200:t}s(24765),s(25566);var chat_ChatInputBox=e=>{let{value:t,disabled:s,onChange:d,intermediateStepsLoading:u,chatEndpointIsLoading:m,onClickStop:h,handelSubmit:x,providerName:f,showRestChat:p,onResetChat:g,customDisclaimer:v,showPoweredBy:j,chatInputCharacterLimit:w,setInput:y}=e,[b,N]=(0,n.useState)(null),[C,S]=(0,n.useState)(null),[k,I]=(0,n.useState)(!1),_=(0,c.useSearchParams)(),A=_.get("isEmbed"),L=(0,n.useRef)(null);return(0,n.useEffect)(()=>{L.current&&L.current.focus()},[]),(0,n.useEffect)(()=>{let handleMessage=e=>{var t;(null===(t=e.data)||void 0===t?void 0:t.action)==="handelOpeningBot"&&L.current&&L.current.focus()};return window.addEventListener("message",handleMessage,!1),()=>{window.removeEventListener("message",handleMessage)}},[]),(0,n.useEffect)(()=>{t||N(null)},[t]),(0,l.jsxs)("div",{className:"fle flex-col w-full",children:[(0,l.jsxs)("div",{className:"flex flex-col w-full items-center justify-center gap-2",children:[p()&&(0,l.jsx)(a.o,{isSmallBtn:!0,isGhostBtn:!0,iconBtn:!0,icon:r.A$d,iconSize:15,iconClass:"inline-block",isLeftIcon:!0,onClick:g,disabled:m||u,title:"Reset Chat",children:"Reset Chat"}),(0,l.jsxs)("div",{className:"flex relative w-full flex-row gap-1 items-center",children:[s?(0,l.jsx)("textarea",{className:" bg-gray-50 w-full py-2 pl-4 pr-8 md:pr-12 text-sm max-h-36 md:max-h-48 rounded-lg border border-linen focus:outline-none focus:border-linen resize-none no-scrollbar ",value:t,disabled:!0,placeholder:"",style:{height:b||"auto",overflowY:"auto"}}):(0,l.jsx)(l.Fragment,{children:(0,l.jsx)("textarea",{ref:L,className:" w-full py-2 pl-4 pr-8 md:pr-12 text-sm max-h-36 md:max-h-48 rounded-lg border border-linen focus:outline-none focus:border-linen resize-none no-scrollbar ",value:t,disabled:k,onChange:e=>{d(e);let t=getChatInputCharacterLimit(w);e.target.value.length>t?S("Maximum allowed character limit is ".concat(t)):S(null)},onInput:e=>{e.target.style.height="auto",e.target.style.height=e.target.scrollHeight+"px",N(e.target.scrollHeight)},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),null===C&&(x(e),N(null)))},placeholder:k?"Recording...":"Type something...",style:{height:b||"auto",overflowY:"auto"}})}),(0,l.jsx)("div",{className:"flex items-center justify-center ",children:(0,l.jsx)("div",{className:"absolute ".concat("right-4"," z-10 "),children:(0,l.jsx)("div",{className:"flex flex-row gap-2",children:m?(0,l.jsx)("div",{title:"Stop responding",onClick:h,className:"!bg-primary-800 w-7 h-7 rounded-full flex items-center justify-center cursor-pointer",children:(0,l.jsx)(r.Wcw,{className:" h-3.5 w-3.5 text-white "})}):(0,l.jsx)(a.o,{type:"submit",title:"Send Message",iconBtn:!0,isReactIcon:!0,icon:o.XnA,isGhostBtn:!0,disabled:""===t||null!==C||m&&u||k,iconClass:"!m-0 w-6 h-6 !text-black ".concat(m||u?"opacity-50":"opacity-100"," ")})})})}),!1]})]}),C&&(0,l.jsx)("div",{className:"text-xs text-red-500",children:C}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("span",{className:" mt-1 text-gray-500 text-center text-xs sm:text-sm",children:["*",v&&(null==v?void 0:v.length)>0?v:"".concat(f||"GovAI"," assistant can make\n mistakes. Consider checking important information.")]}),(0,l.jsx)("div",{className:"flex flex-col items-center justify-center text-xs text-gray-500",children:"Please note: Audio transcription is still processing. Kindly use the text input to proceed."}),"true"!==A&&(!0===j||void 0===j)&&(0,l.jsxs)("div",{className:"flex flex-row gap-2 justify-center items-center text-xs",children:[(0,l.jsx)("span",{children:"Powered by "}),(0,l.jsx)(i.CustomImage,{src:"/images/logo.svg",height:20,width:40,alt:"GovAI Logo"})," ","| NeGD | MeitY"]})]})]})}},39734:function(e,t,s){"use strict";s.d(t,{Z:function(){return chat_Sources}});var l=s(57437),n=s(2265),common_ExpandableText=e=>{let{children:t,className:s}=e,[a,r]=(0,n.useState)(!1),[i,o]=(0,n.useState)(!1),c=(0,n.useRef)(null);return(0,n.useEffect)(()=>{let checkClamping=()=>{c.current&&o(c.current.scrollHeight>c.current.offsetHeight)};return checkClamping(),window.addEventListener("resize",checkClamping),()=>window.removeEventListener("resize",checkClamping)},[t]),(0,l.jsx)("div",{className:"text-sm",children:(0,l.jsx)("div",{ref:c,className:"inline-block transition-all duration-300 ease-in-out ".concat(a?"line-clamp-none":"line-clamp-2"," ").concat(i?"cursor-pointer":"cursor-default"," ").concat(s||""),style:{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:a?"none":"2",overflow:a?"visible":"hidden"},onClick:()=>r(!a),children:t})})};let leaveSite=e=>{document.body.classList.remove("overflow-y-hidden"),window.open(e,"_blank")};var a=s(62510),r=s(62031),i=s(23611),o=s(58910);let extractKeys=e=>{let t="",s="",l="",n=e,a="",r="",i=/{.*?}/,o=e.match(i);if(o)try{let c=JSON.parse(o[0].replace(/'/g,'"'));t=c.source_url||"",s=c.act_name||"",l=c.file||"",a=c.doc_type||"",r=c.document_name||"",n=e.replace(i,"").trim()}catch(t){console.error("Invalid JSON format",t),n=e}return{description:n,actName:s,sourceUrl:t,fileName:l,docType:a,docName:r}};var Custom_HighlightLinksWithText=e=>{let{className:t,text:s,providerName:c,customIcon:d,itemNumber:u}=e,{description:m,actName:h,sourceUrl:x,fileName:f,docName:p,docType:g}=extractKeys(s),[v,j]=(0,n.useState)(!1);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(r.Vq,{open:v,onOpenChange:j,children:(0,l.jsxs)(r.cZ,{children:[(0,l.jsx)(o.eJU,{className:"text-center text-red-500",size:30}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(r.$N,{className:" leading-6",children:"This will redirect you to an external site"}),(0,l.jsx)(r.Be,{className:"mb-2",children:"Are you sure you want to continue?"})]}),(0,l.jsxs)("div",{className:"flex flex-row justify-end items-center gap-2 ",children:[(0,l.jsx)(i.z,{variant:"secondary",onClick:()=>j(!1),children:"No"}),(0,l.jsx)(i.z,{type:"submit",onClick:()=>{x&&(leaveSite(x),j(!1))},children:"Yes"})]})]})}),(0,l.jsxs)("div",{className:"flex flex-col gap-1 mb-1 rounded px-4 py-2 ".concat(x||!h?"cursor-pointer hover:bg-gray-100":"cursor-default"," group "),children:[h?(0,l.jsxs)("div",{className:"flex flex-row gap-1 items-center justify-start",children:[(0,l.jsx)("span",{className:"line-clamp-2 text-sm font-semibold ".concat(x?"group-hover:underline":""),onClick:()=>{x&&j(!0)},children:h}),x&&(0,l.jsx)(a.gjK,{className:"text-blue-700"})]}):(0,l.jsx)(l.Fragment,{}),g&&p&&"ACT"!==g&&(0,l.jsx)("div",{className:"flex flex-row gap-1 items-center justify-start",children:(0,l.jsxs)("span",{className:"text-xs line-clamp-1 font-medium text-gray-600",children:[g," - ",p]})}),(0,l.jsx)(common_ExpandableText,{className:"text-xs font-normal leading-snug",children:m}),f&&(0,l.jsxs)("span",{className:"text-xs text-gray-500 font-normal leading-snug",children:["File: ",f]}),x&&!h&&(0,l.jsxs)("div",{className:"flex flex-row gap-1 items-center justify-start cursor-pointer max-w-fit ",onClick:()=>{j(!0)},children:[(0,l.jsx)("span",{className:"text-xs text-gray-500 group-hover:text-blue-700 font-normal leading-snug group-hover:underline",children:"Source"}),(0,l.jsx)(a.gjK,{className:"text-gray-500 group-hover:text-blue-700"})]})]})]})},chat_Sources=e=>{var t;return(0,l.jsx)("div",{className:"rounded text-sm text-left",children:null===(t=e.sources)||void 0===t?void 0:t.map((t,s)=>(0,l.jsx)("div",{className:"mt-2 flex flex-col",children:t.page_content&&(0,l.jsx)(Custom_HighlightLinksWithText,{className:"font-normal text-sm",text:t.page_content,customIcon:e.customIcon,providerName:e.providerName,itemNumber:s+1})},"source:"+s))})}},92158:function(e,t,s){"use strict";s.r(t),s.d(t,{ChatWindow:function(){return ChatWindow}});var l=s(57437),n=s(63014);s(83343);var a=s(56443),r=s(2265),i=s(62510),o=s(88984),c=s(4741),d=s(36354),u=s(83473),CustomMarkDownRenderer=e=>{let{children:t}=e;return(0,l.jsx)(u.U,{components:{a:e=>{let{href:t,children:s}=e,n=t&&!t.match(/^https?:\/\//)?"https://".concat(t):t;return(0,l.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:"".concat(s)})}},children:t})},m=s(39734),h=s(91133),x=s(58910),modal_Overlay=e=>{let{isOpen:t,children:s,title:n,onClose:a,footer:r,customTitle:i,isAccessability:o,customHeight:c}=e;return(0,h.Z)(t),(0,l.jsx)("div",{onClick:()=>a(),className:"h-screen w-screen fixed top-0 left-0 z-50 transform transition-transform ease-in-out duration-500 ".concat(t?"translate-x-0 backdrop-blur-sm":"translate-x-full"),children:(0,l.jsx)("div",{className:"relative h-full w-full right-0 overflow-y-auto",children:(0,l.jsxs)("div",{onClick:e=>e.stopPropagation(),className:"absolute z-50 w-full md:w-[70%] lg:w-[60%] xl:w-[50%] overflow-y-auto right-0 bg-white rounded-tl-lg rounded-bl-lg transition-transform ease-in-out duration-500 ".concat(t?"translate-x-0":"translate-x-full"," ").concat(c||"top-0 h-full"),children:[(0,l.jsxs)("div",{className:"sticky top-0 flex flex-row items-center justify-between border-0 border-solid border-b-2 border-b-gray-300 py-3 px-6 bg-white mb-2",children:[i||(0,l.jsx)("h3",{className:"text-base font-semibold ",children:n}),(0,l.jsx)("div",{className:"z-10",children:(0,l.jsx)(x.FU5,{className:" cursor-pointer ",size:20,onClick:a})})]}),(0,l.jsx)("div",{className:"px-2 py-2 overflow-y-auto",children:s}),r]})})})},f=s(24033),p=s(62031),g=s(23611);function ChatMessageBubble(e){let{showPDFGenerate:t=!0,loading:n=!1,stateName:a=null,...u}=e,[h,x]=(0,r.useState)(!1),v="",j=[];if((0,d.tp)(u.message.content)){let e=JSON.parse(u.message.content);v=null==e?void 0:e.answer,j=null==e?void 0:e.documents}else v=u.message.content;let w=(0,f.useSearchParams)(),[y,b]=(0,r.useState)(!1),[N,C]=(0,r.useState)(null),S=(0,r.useRef)(null),handleDownloadPdf=()=>{if(null==S?void 0:S.current){let e={margin:[.5,.5,.5,.5],filename:"chat-message-".concat(new Date().toISOString(),".pdf"),jsPDF:{unit:"in",format:"a4",orientation:"portrait"},html2canvas:{scale:1}};Promise.all([s.e(505),s.e(632),s.e(337),s.e(198)]).then(s.t.bind(s,42846,23)).then(t=>{if(t&&t.default){let s=t.default;s().from(S.current).set(e).toPdf().save()}}).catch(e=>{console.log("Import Error: ",e)})}};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(p.Vq,{open:y,onOpenChange:b,children:(0,l.jsxs)(p.cZ,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2 w-full h-full",children:[(0,l.jsx)(p.$N,{className:" leading-6",children:"PDF Preview"}),(0,l.jsx)("iframe",{src:N||"",className:"w-full h-full my-3",title:"PDF Preview"})]}),(0,l.jsxs)("div",{className:"flex flex-row justify-end items-center gap-2 ",children:[(0,l.jsx)(g.z,{variant:"secondary",onClick:()=>b(!1),children:"Cancel"}),(0,l.jsx)(g.z,{type:"submit",onClick:()=>{handleDownloadPdf(),b(!1),C(null)},children:"Download"})]})]})}),(null==w?void 0:w.get("isEmbed"))?(0,l.jsx)(modal_Overlay,{title:"Sources",isOpen:h,onClose:()=>x(!1),customHeight:"top-[7%] h-[93%]",children:(0,l.jsx)(m.Z,{sources:j,customIcon:u.customIcon,providerName:u.providerName})}):(0,l.jsx)(modal_Overlay,{title:"Sources",isOpen:h,onClose:()=>x(!1),children:(0,l.jsx)(m.Z,{sources:j,customIcon:u.customIcon,providerName:u.providerName})}),(0,l.jsx)("div",{className:" mb-4 sm:mb-6 flex flex-col gap-x-4 text-base mx-auto w-full",children:"user"===u.message.role?(0,l.jsx)("div",{className:"flex w-full items-start ",children:(0,l.jsxs)("div",{className:"flex items-center justify-start text-left gap-2 max-w-full sm:max-w-[80%] ",children:[(0,l.jsx)("div",{className:"flex-shrink-0 flex flex-col relative items-end",children:(0,l.jsx)("div",{className:"bg-secondary-200 bg-opacity-25 rounded-full w-10 h-10 flex items-center justify-center text-secondary-700",children:(0,l.jsx)(i.BKo,{})})}),(0,l.jsx)("div",{className:"px-4 py-3 rounded-r-2xl rounded-bl-2xl bg-secondary-200 bg-opacity-25 shadow-sm",children:(0,l.jsx)("p",{className:"flex-col gap-1 mt-0 text-sm leading-6",children:a?u.message.content.replace("State Name - ".concat(a,", "),""):u.message.content})})]})}):(0,l.jsxs)("div",{className:"flex w-full gap-2 items-start ",children:[(0,l.jsx)("div",{className:"flex-shrink-0 flex flex-col relative items-end h-[2rem] w-[2rem] sm:h-[2.5rem] sm:w-[2.5rem]",children:(0,l.jsx)(c.CustomImage,{src:u.customIcon?"".concat("https://cdngovai.myscheme.in/").concat(u.customIcon):"/images/logoIcon.svg",layout:"fill",alt:"".concat(u.providerName||"GovAI",' Logo"'),title:"".concat(u.providerName||"GovAI",' Logo"'),objectFit:"contain"})}),(0,l.jsxs)("div",{className:"relative flex max-w-full flex-col ",children:[(0,l.jsxs)("div",{className:"markdownText px-4 py-3 rounded-r-2xl rounded-bl-2xl bg-[#F3F4F6] shadow-sm text-sm leading-6",children:[(0,l.jsx)(CustomMarkDownRenderer,{children:(0,d.ns)(v)}),(null==j?void 0:j.length)!==0&&!u.isStreaming&&(0,l.jsx)("div",{className:"max-w-fit cursor-pointer flex items-center justify-center px-2 py-1 rounded-md mt-2 border border-solid border-blue-700",onClick:()=>x(!0),children:(0,l.jsx)("span",{className:"text-xs font-medium text-blue-700",children:"Sources"})})]}),(0,l.jsxs)("div",{className:"flex items-center gap-3 flex-row",children:[!1===u.showFeedback?(0,l.jsx)(l.Fragment,{}):(0,l.jsx)(o.Z,{copyValue:(0,d.ns)(v),messages:u.messages,domainId:u.domainId,chatContentId:u.message.id,feedback_setting:u.feedback_setting}),"AqHqQWO6KHYLxJsku3170"===u.domainId&&!n&&t&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"cursor-pointer mt-2 text-gray-500 hover:text-blue-700",onClick:()=>{if(null==S?void 0:S.current){let e={margin:[.5,.5,.5,.5],filename:"chat-message-".concat(new Date().toISOString(),".pdf"),jsPDF:{unit:"in",format:"a4",orientation:"portrait"},html2canvas:{scale:1}};Promise.all([s.e(505),s.e(632),s.e(337),s.e(198)]).then(s.t.bind(s,42846,23)).then(t=>{if(t&&t.default){let s=t.default;s().from(S.current).set(e).toPdf().output("blob").then(e=>{let t=URL.createObjectURL(e);C(t),b(!0)})}}).catch(e=>{console.log("Import Error: ",e)})}},children:(0,l.jsx)("span",{className:"text-xs ",children:"Generate PDF"})}),(0,l.jsx)("div",{className:"hidden",children:(0,l.jsx)("div",{ref:S,style:{padding:"10px",boxSizing:"border-box"},children:(0,l.jsx)(CustomMarkDownRenderer,{children:(0,d.ns)(v)})})})]})]})]})]})})]})}function IntermediateStep(e){console.log("Intermediate step",e.message);let t=JSON.parse(e.message.content),s=t.action,n=t.observation,[a,i]=(0,r.useState)(!1);return(0,l.jsxs)("div",{className:"ml-auto bg-green-600 rounded px-4 py-2 max-w-[80%] mb-8 whitespace-pre-wrap flex flex-col cursor-pointer",children:[(0,l.jsxs)("div",{className:"text-right ".concat(a?"w-full":""),onClick:e=>i(!a),children:[(0,l.jsxs)("code",{className:"mr-2 bg-slate-600 px-2 py-1 rounded hover:text-blue-600",children:["\uD83D\uDEE0️ ",(0,l.jsx)("b",{children:s.tool})]}),(0,l.jsx)("span",{className:a?"hidden":"",children:"\uD83D\uDD3D"}),(0,l.jsx)("span",{className:a?"":"hidden",children:"\uD83D\uDD3C"})]}),(0,l.jsxs)("div",{className:"overflow-hidden max-h-[0px] transition-[max-height] ease-in-out ".concat(a?"max-h-[360px]":""),children:[(0,l.jsx)("div",{className:"bg-slate-600 rounded p-4 mt-1 max-w-0 ".concat(a?"max-w-full":"transition-[max-width] delay-100"),children:(0,l.jsxs)("code",{className:"opacity-0 max-h-[100px] overflow-auto transition ease-in-out delay-150 ".concat(a?"opacity-100":""),children:["Tool Input:",(0,l.jsx)("br",{}),(0,l.jsx)("br",{}),JSON.stringify(s.toolInput)]})}),(0,l.jsx)("div",{className:"bg-slate-600 rounded p-4 mt-1 max-w-0 ".concat(a?"max-w-full":"transition-[max-width] delay-100"),children:(0,l.jsx)("code",{className:"opacity-0 max-h-[260px] overflow-auto transition ease-in-out delay-150 ".concat(a?"opacity-100":""),children:n})})]})]})}var v=s(24026),j=s(87700),w=s(35362);s(54829);var v9_Prompts=e=>{var t;let{initialMessage:s,conversationOpener:n,messages:a,onClick:i}=e;(0,f.useSearchParams)();let[o,c]=(0,r.useState)([]),d=(null==n?void 0:null===(t=n.questions)||void 0===t?void 0:t.length)&&0===a.length,u=d?null==n?void 0:n.questions.reduce((e,t,s)=>(s%2==0?e.push([t]):e[e.length-1].push(t),e),[]):[];return(0,l.jsx)(l.Fragment,{children:d?(0,l.jsx)("div",{className:"flex flex-col gap-2 md:gap-3 my-2 overflow-hidden",children:u.map((e,t)=>(0,l.jsx)("div",{className:"conv-starter-cont flex w-full flex-col gap-2 md:gap-3 md:flex-row justify-start md:justify-between",children:e.map((e,s)=>{let a=2*t+s,r=o[t]===a,d=a===n.questions.length-1&&n.questions.length%2!=0;return(0,l.jsx)("div",{onClick:()=>i(e.question),onMouseEnter:()=>{let e=[...o];e[t]=a,c(e)},onMouseLeave:()=>{let e=[...o];e[t]=null,c(e)},className:"text-center cursor-pointer bg-zinc-50 text-zinc-950 rounded-2xl conv-starter-item conv-item-".concat(a," p-3 sm:p-4 hover:bg-zinc-100 transition-all duration-200 ease-in-out ").concat(d&&"!w-full"),children:(0,l.jsx)("span",{title:e.question,className:"text-xs sm:text-sm ".concat(r?"whitespace-nowrap ":"line-clamp-1"," font-medium"),children:e.question})},a)})},t))}):(0,l.jsx)(l.Fragment,{})})},y=s(3498),b=s(73228),N=s(43164),C=s(36468),S=s(21421),k=s(11064),chat_FollowupQuestions=e=>{var t,s;return(0,l.jsx)(l.Fragment,{children:(0,l.jsx)("div",{className:"w-full ",children:(null===(t=e.questions)||void 0===t?void 0:t.length)>0&&(0,l.jsx)("div",{className:"flex flex-wrap gap-2 sm:gap-3 my-2 overflow-hidden max-h-[6rem] sm:max-h-fit ",children:null===(s=e.questions)||void 0===s?void 0:s.map((t,s)=>(0,l.jsx)("div",{className:"flex justify-center items-center px-2 flex-grow rounded-lg shadow-sm border border-gray-300 cursor-pointer h-[2.5rem] ",onClick:()=>{e.onClick(t)},children:(0,l.jsx)("span",{title:t,className:"text-sm text-blue-500 line-clamp-1",children:(0,d.fm)(t)})},s))})})})},I=s(89348),chat_ChatLoading=e=>{let{customIcon:t,providerName:s,chatEndpointIsLoading:n,onClickStop:a}=e;return(0,l.jsxs)("div",{className:"flex w-full gap-2 items-start ",children:[(0,l.jsx)("div",{className:"flex-shrink-0 flex flex-col relative items-end h-[2rem] w-[2rem] sm:h-[2.5rem] sm:w-[2.5rem]",children:(0,l.jsx)(c.CustomImage,{src:t?"".concat("https://cdngovai.myscheme.in/").concat(t):"/images/logoIcon.svg",layout:"fill",alt:"".concat(s||"GovAI",' Logo"'),title:"".concat(s||"GovAI",' Logo"'),objectFit:"contain"})}),(0,l.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,l.jsx)("div",{className:"relative flex max-w-full flex-col ",children:(0,l.jsx)("div",{className:"markdownText px-8 pt-2 rounded-r-2xl rounded-bl-2xl bg-[#F3F4F6] shadow-sm text-sm leading-6",children:(0,l.jsx)(N.o,{type:"submit",title:"Send Message",iconBtn:!0,isReactIcon:!0,icon:I.F1K,isGhostBtn:!0,disabled:n,iconClass:"!m-0 animate-spin-slow w-6 h-6 !text-black "})})}),(0,l.jsx)("div",{className:"cursor-pointer",onClick:a,children:(0,l.jsx)("span",{className:"text-xs underline text-gray-500 font-medium",children:"Stop Generation"})})]})]})},_=s(43190),A=s(37911),L=s(84579);function addHttpsToLink(e){return/^https?:\/\//i.test(e)||(e="https://"+e),e}let Element=e=>{let{attributes:t,children:s,element:n}=e,a="";switch(((null==n?void 0:n.href)||(null==n?void 0:n.link)||(null==n?void 0:n.url))&&(a=addHttpsToLink((null==n?void 0:n.href)||(null==n?void 0:n.link)||(null==n?void 0:n.url))),"center"===n.align||"right"===n.align||n.align,n.type){case"block_quote":return(0,l.jsx)("blockquote",{...t,children:s});case"bulleted_list":case"ul_list":return(0,l.jsx)("ul",{...t,children:s});case"table":return(0,l.jsx)("table",{className:"border border-solid border-gray-300 w-full table-fixed border-collapse",children:(0,l.jsx)("tbody",{...t,children:s})});case"table_row":return(0,l.jsx)("tr",{className:" border-b border-gray-300",...t,children:s});case"table_cell":return(0,l.jsx)("td",{className:"border-solid border-r last:border-r-0 border-gray-300 p-2 text-sm",...t,children:s});case"ordered_list":case"ol_list":return(0,l.jsx)("ol",{type:"1",...t,children:s});case"heading_one":return(0,l.jsx)("h1",{...t,children:s});case"heading_two":return(0,l.jsx)("h2",{...t,children:s});case"heading_three":return(0,l.jsx)("h3",{...t,children:s});case"heading_four":return(0,l.jsx)("h4",{...t,children:s});case"heading_five":return(0,l.jsx)("h5",{...t,children:s});case"heading_six":return(0,l.jsx)("h6",{...t,children:s});case"list_item":return(0,l.jsx)("li",{...t,children:s});case"align_left":return(0,l.jsx)("div",{className:"text-left text-sm m-0",...t,children:s});case"align_right":return(0,l.jsx)("div",{className:"text-right text-sm m-0",...t,children:s});case"align_center":return(0,l.jsx)("div",{className:"text-center text-sm m-0",...t,children:s});case"link":return(0,l.jsx)("a",{href:a,className:"inline-block break-all",rel:"noreferrer noopener",target:"_blank",children:s});default:return(0,l.jsx)("div",{className:"mb-2",...t,children:s})}},Leaf=e=>{let{attributes:t,children:s,leaf:n}=e;return n.bold&&(s=(0,l.jsx)("strong",{children:s})),n.code&&(s=(0,l.jsx)("code",{children:s})),n.italic&&(s=(0,l.jsx)("em",{children:s})),n.strikeThrough&&(s=(0,l.jsx)("span",{style:{textDecoration:"line-through"},children:s})),n.underline&&(s=(0,l.jsx)("u",{children:s})),n.superscript&&(s=(0,l.jsx)("sup",{children:s})),n.subscript&&(s=(0,l.jsx)("sub",{children:s})),n.color&&(s=(0,l.jsx)("span",{style:{color:n.color},children:s})),n.bgColor&&(s=(0,l.jsx)("span",{style:{backgroundColor:n.bgColor},children:s})),(0,l.jsx)("span",{...t,children:s})};var slate_SlateEditor=e=>{let{value:t}=e,s=(0,r.useRef)(null),n=(0,r.useCallback)(e=>(0,l.jsx)(Leaf,{...e}),[]),a=(0,r.useCallback)(e=>(0,l.jsx)(Element,{...e}),[]);s.current||(s.current=(0,_.BU)((0,A.Jh)()));let i=s.current;return(null==t?void 0:t.length)&&(i.children=t),(null==t?void 0:t.length)?(0,l.jsx)(_.mH,{editor:i,initialValue:t,children:(0,l.jsx)(_.CX,{renderElement:a,placeholder:"",className:"markdown-options",readOnly:!0,renderLeaf:n})}):(0,l.jsx)("div",{className:"flex items-center justify-center",children:(0,l.jsx)(L.Z,{})})};let P=[{type:"paragraph",children:[{text:"A. Formulate Your Query",bold:!0}]},{type:"paragraph",children:[{text:"a. "},{text:"Be Specific:",bold:!0},{text:" The more precise your question, the better the chatbot can understand your needs and provide relevant results. "}]},{type:"paragraph",children:[{text:"i. "},{text:"Example:",bold:!0},{text:' Instead of "Tell me about contracts," try "What are the essential elements of a valid contract under the Indian Contracts Act, 1872?"'}]},{type:"paragraph",children:[{text:"b. "},{text:"Use Legal Terminology:",bold:!0},{text:' Employing accurate legal terms (e.g., "jurisdiction," "limitations," "breach of contract") will enhance the chatbot\'s ability to interpret your request.'}]},{type:"paragraph",children:[{text:"B. Specify Relevant Information: Include details such as: ",bold:!0}]},{type:"orderedList",children:[{type:"list_item",children:[{text:"Jurisdiction:",bold:!0},{text:" The specific State where the law applies."}]},{type:"list_item",children:[{text:"Area of Law",bold:!0},{text:": The relevant legal field (e.g., contract law, family law, criminal law, constitutional law, commercial law)."}]},{type:"list_item",children:[{text:"Relevant Documents:",bold:!0},{text:" If applicable, mention any specific statute or rule or regulation, etc. (e.g., “Specific Relief Act” or “Aadhaar (Authentication and Offline Verification) Regulations, 2021” or “Uttar Pradesh Legal Metrology (Enforcement) Rules 2011”) related to your query."}]}]},{type:"paragraph",children:[{text:"C. Interact with the Chatbot",bold:!0}]},{type:"orderedList",children:[{type:"list_item",children:[{text:"Ask Clear Questions:",bold:!0},{text:" Pose your question directly to the chatbot."}]},{type:"list_item",children:[{text:"Review and Refine:",bold:!0},{text:" The chatbot may provide initial results. Review them carefully. If they are not accurate or complete, refine your query or ask follow-up questions."}]}]}];var B=s(67133);async function decryptToStringArray(e){try{var t;let s;let l=e.split(":");if(3!==l.length)throw Error("Invalid encrypted format");let[n,a,r]=l,i=base64ToArrayBuffer(n),o=base64ToArrayBuffer(a),c=base64ToArrayBuffer(r),d=await deriveKey("H9faT7!jQc@pL6xR2vB4*mZs8#Kd3^yFnE5&wG","V6#pK9&z6L4@mX2cR7!tB3^sN8*qF5%dA1jE");s=(null===(t=window.crypto)||void 0===t?void 0:t.subtle)?await browserDecrypt(o,d,i,c):await nodeDecrypt(o,d,i,c);let u=JSON.parse(s);return u}catch(e){return console.error("Decryption error:",e),[]}}async function deriveKey(e,t){var l;if(null===(l=window.crypto)||void 0===l?void 0:l.subtle){let s=new TextEncoder,l=await window.crypto.subtle.importKey("raw",s.encode(e),{name:"PBKDF2"},!1,["deriveBits","deriveKey"]),n=await window.crypto.subtle.deriveKey({name:"PBKDF2",salt:s.encode(t),iterations:1e5,hash:"SHA-256"},l,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);return window.crypto.subtle.exportKey("raw",n)}{let l=s(14931);return l.pbkdf2Sync(e,t,1e5,32,"sha256")}}async function browserDecrypt(e,t,s,l){try{let n=new Uint8Array(e.byteLength+l.byteLength);n.set(new Uint8Array(e),0),n.set(new Uint8Array(l),e.byteLength);let a=await window.crypto.subtle.importKey("raw",t,{name:"AES-GCM",length:256},!1,["decrypt"]),r=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:new Uint8Array(s),tagLength:128},a,n),i=new TextDecoder;return i.decode(r)}catch(e){throw console.error("Browser decryption error:",e),e}}function nodeDecrypt(e,t,l,n){try{let a=s(14931),r=a.createDecipheriv("aes-256-gcm",B.Buffer.from(t),B.Buffer.from(l));r.setAuthTag(B.Buffer.from(n));let i=r.update(B.Buffer.from(e));return(i=B.Buffer.concat([i,r.final()])).toString("utf8")}catch(e){throw console.error("Node.js decryption error:",e),e}}function base64ToArrayBuffer(e){try{if("function"==typeof atob){let t=atob(e),s=new Uint8Array(t.length);for(let e=0;e{let{customDisclaimer:t,providerName:s,showPoweredBy:n,isEmbed:a}=e;return(0,l.jsxs)("div",{className:"fle flex-col w-full",children:[(0,l.jsx)("div",{className:"flex flex-col w-full items-center justify-center gap-2",children:(0,l.jsx)("div",{className:"flex relative w-full flex-row gap-1 items-center",children:(0,l.jsx)("textarea",{className:"cursor-not-allowed bg-gray-50 w-full py-2 pl-4 pr-8 md:pr-12 text-sm max-h-36 md:max-h-48 rounded-lg border border-linen focus:outline-none focus:border-linen resize-none no-scrollbar ",value:"",disabled:!0,placeholder:"Enter your message here...",style:{height:"auto",overflowY:"auto"}})})}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("span",{className:" mt-1 text-gray-500 text-center text-xs sm:text-sm",children:["*",t&&(null==t?void 0:t.length)>0?t:"".concat(s||"GovAI"," assistant can make\n mistakes. Consider checking important information.")]}),"true"!==a&&(!0===n||void 0===n)&&(0,l.jsxs)("div",{className:"flex flex-row gap-2 justify-center items-center text-xs",children:[(0,l.jsx)("span",{children:"Powered by "}),(0,l.jsx)(c.CustomImage,{src:"/images/logo.svg",height:20,width:40,alt:"GovAI Logo"})," ","| NeGD | MeitY"]})]})]})};var v9_PlaceholderView=e=>{let{assistantData:t,title:s,subtitle:n,actionButton:a,showAssistantLogo:r=!0,customImage:i}=e,o=(0,f.useSearchParams)(),d=o.get("isEmbed");return(0,l.jsxs)("div",{className:"flex w-full h-full flex-col md:max-w-3xl mx-auto",children:[(0,l.jsxs)("div",{className:"w-full flex-1 flex flex-col items-center mb-4 justify-center",children:[r?(0,l.jsx)(l.Fragment,{children:(null==t?void 0:t.logo)?(0,l.jsx)(c.CustomImage,{src:"".concat("https://cdngovai.myscheme.in/").concat(null==t?void 0:t.logo),alt:"".concat(null==t?void 0:t.displayName," Logo"),height:200,width:200,className:"mb-4"}):(0,l.jsx)("div",{className:"mb-4",children:(0,l.jsx)(E.Z,{})})}):i?(0,l.jsx)("div",{className:"mb-4",children:i}):null,(0,l.jsx)("h1",{className:" text-center text-lg leading-tight mb-0",children:s}),n&&n.length>0&&(0,l.jsx)("p",{className:"m-0 mt-2 text-sm text-gray-500 text-center",children:n}),a&&(0,l.jsx)("div",{className:"mt-4",children:a})]}),(0,l.jsx)("div",{className:"pt-2 md:pt-0 dark:border-white/20 md:border-transparent md:dark:border-transparent",children:(0,l.jsx)("form",{onSubmit:e=>{e.preventDefault()},className:"stretch mx-0 flex flex-row gap-3 last:mb-2 md:last:mb-6",children:(0,l.jsx)("div",{className:"relative flex h-full flex-1 items-stretch md:flex-col",children:(0,l.jsx)("div",{className:"flex relative w-full flex-col",children:(0,l.jsx)(PlaceholderView_ChatInputBox,{customDisclaimer:null==t?void 0:t.customDisclaimer,providerName:null==t?void 0:t.displayName,showPoweredBy:null==t?void 0:t.showPoweredBy,isEmbed:d})})})})})]})};function ChatWindow(e){var t,s,i,o,u;let m=(0,r.useRef)(null),navigateToChatEnd=()=>{m.current&&m.current.scrollTo({top:m.current.scrollHeight,behavior:"smooth"})},[h,I]=(0,r.useState)(null);(0,r.useEffect)(()=>{(0,d.YI)().then(e=>{I(e)})},[]);let{endpoint:_,showIntermediateStepsToggle:A,emoji:L,assistantData:B}=e,E=(0,f.useRouter)(),{updateChatSessionMessages:D,createNewChatSession:M}=(0,S.Z)(),{state:O}=(0,v.j_)(),{actions:F}=(0,v.j_)({updateAssistant:j.updateAssistant,createChatSession:j.createChatSession,setSelectedChatSession:j.setSelectedChatSession,updateChatSession:j.updateChatSession}),{token:T,loginStatus:R,login:z,decodedToken:Z}=(0,y.aC)(),[q,K]=(0,r.useState)(!1),[H,G]=(0,r.useState)(!1),[V,J]=(0,r.useState)(),[Y,U]=(0,r.useState)(!1),[W,X]=(0,r.useState)({}),[Q,$]=(0,r.useState)(!1),[ee,et]=(0,r.useState)(""),[es,el]=(0,r.useState)(!1),[en,ea]=(0,r.useState)([]),[er,ei]=(0,r.useState)([]),[eo,ec]=(0,r.useState)();(0,f.useSearchParams)();let ed=null==O?void 0:null===(t=O.selectedChatSession)||void 0===t?void 0:t._id,[eu,em]=(0,r.useState)(!1),[eh,ex]=(0,r.useState)(!1),ef=(0,r.useRef)(null),[ep,eg]=(0,r.useState)("showLoading"),[ev,ej]=(0,r.useState)(!0),[ew,ey]=(0,r.useState)(null),{messages:eb,input:eN,setInput:eC,handleInputChange:eS,handleSubmit:ek,isLoading:eI,setMessages:e_,stop:eA,append:eL}=(0,a.RJ)({api:_,headers:{"Content-Type":"application/json",Authorization:"Basic ".concat("bXlzY2hlbWVfcmFnX3NlcnZpY2U6a2pqZ2V0dXBieDg5MDY3ODc4"),"X-Bearer-Token":T&&(null==B?void 0:B.isAuthenticated)?"Bearer ".concat(T):"","x-api-key":"MEpg04&*@%^Vng!KL","x-fp-id":h||""},body:{app_id:null==B?void 0:B.domainId,app_type:"system",entity_id:null==B?void 0:B.orgId,session_id:ed||""},onResponse(e){ej(!0);let t=e.headers.get("x-sources"),s=t?JSON.parse(atob(t)):[],l=e.headers.get("x-message-index");s.length&&null!==l&&X({...W,[l]:s})},onError:e=>{try{let t=JSON.parse(e.message);console.log("errr ",t),(null==t?void 0:t.statusCode)===429?($(!0),et(null==t?void 0:t.error)):(null==t?void 0:t.statusCode)===412||(null==t?void 0:t.statusCode)==="412"?(el(!0),$(!1),et("")):(0,n.Am)(null==t?void 0:t.error,{theme:"dark"})}catch(e){(0,n.Am)("Something went wrong",{theme:"dark"})}},initialMessages:er}),eP=A&&(0,l.jsxs)("div",{children:[(0,l.jsx)("input",{type:"checkbox",id:"show_intermediate_steps",name:"show_intermediate_steps",checked:q,onChange:e=>K(e.target.checked)}),(0,l.jsx)("label",{htmlFor:"show_intermediate_steps",children:" Show intermediate steps"})]});function getInitialMessage(e){if(e&&Array.isArray(null==e?void 0:e.openers)&&(null==e?void 0:e.openers.length)>0){var t,s,l,n;if((null==B?void 0:null===(t=B.conversationOpeners)||void 0===t?void 0:t.random)==="Yes"){let t=Math.floor(Math.random()*(null==e?void 0:e.openers.length)),l={role:"assistant",id:(0,d.O1)(8),content:null==e?void 0:null===(s=e.openers[t])||void 0===s?void 0:s.description};ei([l]),ec(null==e?void 0:e.openers[t])}else{let t=null==e?void 0:e.openers.filter(e=>"High"===e.priority);if(t.length>0){let e={role:"assistant",id:(0,d.O1)(8),content:null===(l=t[0])||void 0===l?void 0:l.description};ei([e]),ec(t[0])}else{let t={role:"assistant",id:(0,d.O1)(8),content:null==e?void 0:null===(n=e.openers[0])||void 0===n?void 0:n.description};ei([t]),ec(null==e?void 0:e.openers[0])}}}else ei(void 0),ec(void 0)}async function sendMessage(e){if(e.preventDefault(),ea([]),ej(!1),m.current&&m.current.classList.add("grow"),eb.length||await new Promise(e=>setTimeout(e,300)),null!=eI?eI:Y)return;let t=eb.map(e=>{let t="";if((0,d.tp)(e.content)){let s=JSON.parse(e.content);t=(null==s?void 0:s.answer)||""}else t=e.content;return{role:e.role,content:t}}),s=[...t,{content:eN,role:"user"}];if(ew&&(s=null==s?void 0:s.map(e=>"user"===e.role?{...e,content:"State Name - ".concat(ew,", ").concat(e.content)}:e)),q){U(!0),eC("");let e=eb.concat({id:eb.length.toString(),content:eN,role:"user"});e_(e);let t=new Headers;t.append("x-api-key","MEpg04&*@%^Vng!KL"),t.append("x-fp-id",h||"");let s=await fetch(_,{method:"POST",body:JSON.stringify({messages:e,show_intermediate_steps:!0}),headers:t}),a=await s.json();if(U(!1),200===s.status){var l;let t=(null!==(l=a.intermediate_steps)&&void 0!==l?l:[]).map((t,s)=>({id:(e.length+s).toString(),content:JSON.stringify(t),role:"system"}));for(let s of t)e.push(s),e_([...e]),await new Promise(e=>setTimeout(e,1e3+1e3*Math.random()));e_([...e,{id:(e.length+t.length).toString(),content:a.output,role:"assistant"}])}else if(a.error)throw(0,n.Am)(a.error,{theme:"dark"}),Error(a.error)}else ek(e,{options:{body:{messages:s}}})}let handelResetChat=()=>{var e;e_([]),ea([]),null==ef||null===(e=ef.current)||void 0===e||e.cancel("Reset chat"),F.setSelectedChatSession(null)};(0,r.useEffect)(()=>{if(B){var e,t;F.updateAssistant(B),(null==O?void 0:O.selectedChatSession)&&(null==O?void 0:null===(e=O.selectedChatSession)||void 0===e?void 0:e.messages.length)>=1?(ea([]),e_(null==O?void 0:null===(t=O.selectedChatSession)||void 0===t?void 0:t.messages)):(e_([]),ea([])),getInitialMessage(null==B?void 0:B.conversationOpeners)}},[B,ed]),(0,r.useEffect)(()=>{if(!eI&&eb.length>0){let e=eb.filter(e=>"user"===e.role);e.length>=2&&(null==B||B.showSuggestions),ed&&(null==B?void 0:B.saveHistory)&&D(ed,eb)}return()=>{ef.current&&ef.current.cancel("Component unmounted, request canceled")}},[null==eb?void 0:eb.length,eI,Q,es]);let handelRenderOption=async()=>{var e;if((null==B?void 0:null===(e=B.status)||void 0===e?void 0:e.toLowerCase())==="active"){if("loading"===R)eg("showLoading");else if((null==B?void 0:B.isAuthenticated)===!0&&"loggedOut"===R)eg("showLogin");else if((null==B?void 0:B.isAuthenticated)===!0&&"loggedIn"===R){let e=(null==Z?void 0:Z.email)||"",t=await decryptToStringArray((null==B?void 0:B.allowedEmails)||"");t.length>0&&!t.find(t=>t===e)?eg("showNotAuthorized"):eg("showChat")}else B?eg("showChat"):eg("showLoading")}else eg("showNotActive")};(0,r.useEffect)(()=>{let functionCall=async()=>{await handelRenderOption()};functionCall()},[B,R]),(0,r.useEffect)(()=>{let handleMessage=e=>{var t,s,l;(null===(t=e.data)||void 0===t?void 0:t.action)==="handelCloseBotIcon"&&ex(!0),(null===(s=e.data)||void 0===s?void 0:s.action)==="handelStatePage"&&ey(null===(l=e.data)||void 0===l?void 0:l.data.stateName)};return window.addEventListener("message",handleMessage,!1),()=>{window.removeEventListener("message",handleMessage)}},[]),(0,r.useEffect)(()=>{navigateToChatEnd()},[eb]);let[eB,eE]=(0,r.useState)(!1);return(0,l.jsxs)("div",{className:"flex h-full flex-col items-center rounded grow text-base mx-auto gap-3 lg:px-1",children:[(0,l.jsx)(p.Vq,{open:eh,onOpenChange:ex,children:(0,l.jsxs)(p.cZ,{children:[(0,l.jsx)(x.eJU,{className:"text-center text-red-500",size:30}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(p.$N,{className:"leading-6",children:"Are you sure you want to end the chat session?"}),(0,l.jsx)(p.Be,{className:"mb-2",children:"This will reset the chat and clear all messages."})]}),(0,l.jsxs)("div",{className:"flex flex-row justify-end items-center gap-2 ",children:[(0,l.jsx)(g.z,{variant:"secondary",onClick:()=>ex(!1),children:"No"}),(0,l.jsx)(g.z,{type:"submit",onClick:()=>{window.parent.postMessage({action:"handelCloseBotModal"},"*"),handelResetChat(),ex(!1)},children:"Yes"})]})]})}),(0,l.jsx)(modal_Overlay,{isOpen:eB,onClose:()=>eE(!1),title:"How to use the assistant",children:(0,l.jsx)("div",{className:"h-full px-4",children:(0,l.jsx)(slate_SlateEditor,{value:P})})}),"showLoading"!==ep&&"loading"!==R||H?(0,l.jsxs)(l.Fragment,{children:["showChat"===ep&&!H&&(0,l.jsxs)("div",{className:"flex w-full h-full flex-col md:max-w-3xl mx-auto justify-between",children:[(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-1 ".concat(void 0===eb.find(e=>(null==e?void 0:e.role)==="user")?"flex-col":"flex-col-reverse"," w-full mb-4 overflow-auto no-scrollbar transition-[flex-grow] ease-in-out"),ref:m,children:[eI&&!ev&&(0,l.jsx)(chat_ChatLoading,{chatEndpointIsLoading:eI,providerName:null==B?void 0:B.displayName,customIcon:null==B?void 0:B.icon,onClickStop:eA}),void 0!==eb.find(e=>(null==e?void 0:e.role)==="user")?[...eb].reverse().map((e,t)=>{let s=(eb.length-1-t).toString();return"system"===e.role?(0,l.jsx)(IntermediateStep,{message:e},t):(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(ChatMessageBubble,{message:e,aiEmoji:L,sources:W[s],providerName:null==B?void 0:B.displayName,customIcon:null==B?void 0:B.icon,messages:eb,domainId:(null==B?void 0:B.domainId)||"",isStreaming:null==B?void 0:B.isStreaming,feedback_setting:null==B?void 0:B.feedback_setting,loading:eI,stateName:ew},(null==e?void 0:e.id)||t)})}):(0,l.jsxs)("div",{className:"flex flex-col gap-2 rounded-2xl bg-zinc-50 sm:p-8 p-4 text-sm sm:text-base mt-4",children:[(0,l.jsxs)("div",{className:"flex flex-row items-baseline justify-between gap-2",children:[(0,l.jsx)("h1",{className:"text-2xl sm:text-3xl tracking-tight font-semibold max-w-fit inline-block",children:null==B?void 0:B.displayName}),((null==B?void 0:B.domainId)==="yknv_etiZW2IKdNB9AbLo"||(null==B?void 0:B.domainId)==="KvG-Pj8r_xYJh99eEBPtZ")&&(0,l.jsx)("span",{className:"text-gray-600 cursor-pointer text-sm underline",onClick:()=>eE(!0),children:"How to use?"})]}),(0,l.jsx)("p",{className:"leading-normal text-zinc-900",children:null==B?void 0:B.description}),(0,l.jsx)("p",{className:"leading-normal text-zinc-900",children:er?null===(s=er[0])||void 0===s?void 0:s.content:""})]}),(eb.length>0||er&&(null==er?void 0:er.length)>1)&&(0,l.jsx)(l.Fragment,{children:null==er?void 0:er.map((e,t)=>(0,l.jsx)(ChatMessageBubble,{showFeedback:!1,message:{...e,content:"**".concat(null==B?void 0:B.displayName,"** \n ").concat(null==B?void 0:B.description," \n ").concat(e.content)},aiEmoji:L,sources:[],providerName:null==B?void 0:B.displayName,customIcon:null==B?void 0:B.icon,messages:eb,domainId:(null==B?void 0:B.domainId)||"",showPDFGenerate:!1},(null==e?void 0:e.id)||t))})]}),eu&&eb.length>1&&(0,l.jsxs)("div",{className:"flex flex-row items-center justify-start gap-2",children:[(0,l.jsx)(k.Z,{className:"h-4 w-4"}),(0,l.jsx)("span",{className:"text-xs text-secondary-text",children:"Loading followup questions..."})]}),(0,l.jsx)(chat_FollowupQuestions,{questions:en,onClick:e=>{ew?eL({role:"user",content:"State Name - ".concat(ew,", ").concat(e)}):eL({role:"user",content:e}),ea([]),ej(!1)}}),Q&&(0,l.jsxs)("div",{className:"flex flex-row items-start justify-start gap-3 leading-7 p-4 text-sm mb-2 border border-red-100 bg-red-50 rounded-xl",children:[(0,l.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"text-red-500 ",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,l.jsx)("path",{d:"M13 12C13 11.4477 12.5523 11 12 11C11.4477 11 11 11.4477 11 12V16C11 16.5523 11.4477 17 12 17C12.5523 17 13 16.5523 13 16V12Z",fill:"currentColor"}),(0,l.jsx)("path",{d:"M12 9.5C12.6904 9.5 13.25 8.94036 13.25 8.25C13.25 7.55964 12.6904 7 12 7C11.3096 7 10.75 7.55964 10.75 8.25C10.75 8.94036 11.3096 9.5 12 9.5Z",fill:"currentColor"}),(0,l.jsx)("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2ZM4 12C4 7.58172 7.58172 4 12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12Z",fill:"currentColor"})]}),(0,l.jsx)("p",{children:ee})]}),es&&(0,l.jsxs)("div",{className:"flex flex-row items-start justify-start gap-3 leading-7 p-4 text-sm mb-2 border border-red-100 bg-red-50 rounded-xl",children:[(0,l.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"text-red-500 ",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,l.jsx)("path",{d:"M13 12C13 11.4477 12.5523 11 12 11C11.4477 11 11 11.4477 11 12V16C11 16.5523 11.4477 17 12 17C12.5523 17 13 16.5523 13 16V12Z",fill:"currentColor"}),(0,l.jsx)("path",{d:"M12 9.5C12.6904 9.5 13.25 8.94036 13.25 8.25C13.25 7.55964 12.6904 7 12 7C11.3096 7 10.75 7.55964 10.75 8.25C10.75 8.94036 11.3096 9.5 12 9.5Z",fill:"currentColor"}),(0,l.jsx)("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2ZM4 12C4 7.58172 7.58172 4 12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12Z",fill:"currentColor"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:" text-base leading-tight mb-0",children:V||"Sorry! ".concat(null==B?void 0:B.displayName," can not be used right now.")}),(0,l.jsx)("p",{className:"m-0 mt-1 text-sm text-gray-500 text-center",children:"We are enhancing the assistant to return better answers. Please try again later."})]})]})]}),(0,l.jsx)("div",{className:" pt-2 md:pt-0 dark:border-white/20 md:border-transparent md:dark:border-transparent",children:(0,l.jsx)("form",{onSubmit:async e=>{!ed&&(null==B?void 0:B.domainId)&&(null==B?void 0:B.saveHistory)&&await M({domainId:null==B?void 0:B.domainId}),sendMessage(e),$(!1),el(!1),et("")},className:"stretch mx-0 flex flex-row gap-3 last:mb-2 md:last:mb-6",children:(0,l.jsxs)("div",{className:"relative flex h-full flex-1 items-stretch flex-col overflow-hidden",children:[(0,l.jsx)("div",{className:"flex",children:eP}),(0,l.jsxs)("div",{className:"flex relative w-full flex-col",children:[B&&!Q&&!es&&(0,l.jsx)(v9_Prompts,{onClick:async e=>{!ed&&(null==B?void 0:B.saveHistory)&&await M({domainId:null==B?void 0:B.domainId});let t=(0,d.O1)(8);ew?eL({role:"user",content:"State Name - ".concat(ew,", ").concat(e),id:t}):eL({role:"user",content:e,id:t}),el(!1),$(!1),et(""),ej(!1)},messages:eb,initialMessage:er||null,conversationOpener:eo||null}),(0,l.jsx)(w.Z,{disabled:Q||es,intermediateStepsLoading:Y,chatEndpointIsLoading:eI,showRestChat:()=>!H&&!!eo&&eb.length>1||!H&&eb.length>1,customDisclaimer:null==B?void 0:B.customDisclaimer,showPoweredBy:null==B?void 0:B.showPoweredBy,chatInputCharacterLimit:null==B?void 0:B.chatInputCharacterLimit,value:eN,setInput:eC,onChange:eS,onClickStop:eA,handelSubmit:async e=>{!ed&&(null==B?void 0:B.domainId)&&(null==B?void 0:B.saveHistory)&&!Q&&!es&&await M({domainId:null==B?void 0:B.domainId}),sendMessage(e),el(!1),$(!1),et("")},providerName:null==B?void 0:B.displayName,onResetChat:handelResetChat})]})]})})}),(0,l.jsx)(n.Ix,{})]}),"showLogin"===ep&&!H&&(0,l.jsx)(v9_PlaceholderView,{assistantData:B,title:"Authentication Required",subtitle:"Please log in to access this service and start your conversation.",actionButton:(0,l.jsx)("div",{className:"flex flex-col gap-3",children:(null==B?void 0:null===(i=B.authType)||void 0===i?void 0:i.length)===1?(0,l.jsx)(N.o,{onClick:()=>{"meripehchaan"===B.authType[0]?z():"parichay"===B.authType[0]&&console.log("Parichay login flow initiated")},className:"flex flex-row items-center",darkBtn:!0,children:"Login with ".concat("meripehchaan"===B.authType[0]?"MeriPehchaan":"Parichay")}):(0,l.jsxs)(N.h,{className:"gap-2",children:[(null==B?void 0:null===(o=B.authType)||void 0===o?void 0:o.includes("meripehchaan"))&&(0,l.jsx)(N.o,{onClick:()=>z(),className:"flex flex-row items-center",darkBtn:!0,children:"Login with MeriPehchaan"}),(null==B?void 0:null===(u=B.authType)||void 0===u?void 0:u.includes("parichay"))&&(0,l.jsx)(N.o,{onClick:()=>{console.log("Parichay login flow initiated")},className:"flex flex-row items-center",isOutlineBtn:!0,children:"Login with Parichay"})]})}),customImage:(0,l.jsx)(c.CustomImage,{src:"/images/no-data.svg",width:250,height:250,alt:"No data available"}),showAssistantLogo:!1}),"showNotAuthorized"===ep&&!H&&(0,l.jsx)(v9_PlaceholderView,{assistantData:B,title:"Access Restricted",subtitle:"You don't have permission to use this chatbot. Please contact your administrator for access.",actionButton:(0,l.jsx)(N.o,{iconBtn:!0,icon:C.gYP,iconSize:10,onClick:()=>E.push("/"),className:"flex flex-row items-center",darkBtn:!0,iconClass:"h-4 w-4",isLeftIcon:!0,children:"Back to Home"}),customImage:(0,l.jsx)(c.CustomImage,{src:"/images/no-data.svg",width:250,height:250,alt:"No data available"}),showAssistantLogo:!1}),("showNotActive"===ep||H)&&(0,l.jsx)(v9_PlaceholderView,{assistantData:B,title:V||"Sorry! ".concat(null==B?void 0:B.displayName," can not be used right now."),subtitle:"We are enhancing the assistant to return better answers. Please try again later."})]}):(0,l.jsx)(b.Z,{loading:!0})]})}}},function(e){e.O(0,[420,582,190,306,169,33,621,815,218,603,998,114,863,769,965,2,419,409,971,472,744],function(){return e(e.s=40067)}),_N_E=e.O()}]);