khoj 1.27.2.dev29__py3-none-any.whl → 1.27.2.dev130__py3-none-any.whl

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.
Files changed (72) hide show
  1. khoj/database/adapters/__init__.py +34 -10
  2. khoj/interface/compiled/404/index.html +1 -1
  3. khoj/interface/compiled/_next/static/chunks/1034-da58b679fcbb79c1.js +1 -0
  4. khoj/interface/compiled/_next/static/chunks/1467-5a191c1cd5bf0b83.js +1 -0
  5. khoj/interface/compiled/_next/static/chunks/1603-5d70d9dfcdcb1f10.js +1 -0
  6. khoj/interface/compiled/_next/static/chunks/3423-fa918f4e5365a35e.js +1 -0
  7. khoj/interface/compiled/_next/static/chunks/8423-3ad0bfb299801220.js +1 -0
  8. khoj/interface/compiled/_next/static/chunks/app/agents/{page-5ae1e540bb5be8a9.js → page-2beaba7c9bb750bd.js} +1 -1
  9. khoj/interface/compiled/_next/static/chunks/app/automations/{page-774ae3e033f938cd.js → page-9b5c77e0b0dd772c.js} +1 -1
  10. khoj/interface/compiled/_next/static/chunks/app/chat/page-7dc98df9c88828f0.js +1 -0
  11. khoj/interface/compiled/_next/static/chunks/app/factchecker/page-d887f55fe6d4f35d.js +1 -0
  12. khoj/interface/compiled/_next/static/chunks/app/{page-4dc472cf6d674004.js → page-d46244282af16509.js} +1 -1
  13. khoj/interface/compiled/_next/static/chunks/app/search/{page-9b64f61caa5bd7f9.js → page-ab2995529ece3140.js} +1 -1
  14. khoj/interface/compiled/_next/static/chunks/app/settings/{page-7a8c382af2a7e870.js → page-89e6737b2cc9fb3a.js} +1 -1
  15. khoj/interface/compiled/_next/static/chunks/app/share/chat/{page-eb9e282691858f2e.js → page-505b07bce608b34e.js} +1 -1
  16. khoj/interface/compiled/_next/static/chunks/{webpack-2b720658ccc746f2.js → webpack-8ae5ce45161bd98e.js} +1 -1
  17. khoj/interface/compiled/_next/static/css/{2272c73fc7a3b571.css → 26c1c33d0423a7d8.css} +1 -1
  18. khoj/interface/compiled/_next/static/css/592ca99f5122e75a.css +1 -0
  19. khoj/interface/compiled/_next/static/css/b70402177a7c3207.css +1 -0
  20. khoj/interface/compiled/_next/static/css/e9c5fe555dd3050b.css +25 -0
  21. khoj/interface/compiled/agents/index.html +1 -1
  22. khoj/interface/compiled/agents/index.txt +2 -2
  23. khoj/interface/compiled/automations/index.html +1 -1
  24. khoj/interface/compiled/automations/index.txt +2 -2
  25. khoj/interface/compiled/chat/index.html +1 -1
  26. khoj/interface/compiled/chat/index.txt +2 -2
  27. khoj/interface/compiled/factchecker/index.html +1 -1
  28. khoj/interface/compiled/factchecker/index.txt +2 -2
  29. khoj/interface/compiled/index.html +1 -1
  30. khoj/interface/compiled/index.txt +2 -2
  31. khoj/interface/compiled/search/index.html +1 -1
  32. khoj/interface/compiled/search/index.txt +2 -2
  33. khoj/interface/compiled/settings/index.html +1 -1
  34. khoj/interface/compiled/settings/index.txt +2 -2
  35. khoj/interface/compiled/share/chat/index.html +1 -1
  36. khoj/interface/compiled/share/chat/index.txt +2 -2
  37. khoj/processor/conversation/anthropic/anthropic_chat.py +14 -10
  38. khoj/processor/conversation/anthropic/utils.py +13 -2
  39. khoj/processor/conversation/google/gemini_chat.py +15 -11
  40. khoj/processor/conversation/offline/chat_model.py +10 -9
  41. khoj/processor/conversation/openai/gpt.py +11 -8
  42. khoj/processor/conversation/prompts.py +131 -22
  43. khoj/processor/conversation/utils.py +132 -6
  44. khoj/processor/tools/online_search.py +5 -3
  45. khoj/processor/tools/run_code.py +144 -0
  46. khoj/routers/api.py +6 -6
  47. khoj/routers/api_chat.py +156 -88
  48. khoj/routers/helpers.py +91 -47
  49. khoj/routers/research.py +321 -0
  50. khoj/search_filter/date_filter.py +1 -3
  51. khoj/search_filter/file_filter.py +1 -2
  52. khoj/search_type/text_search.py +3 -3
  53. khoj/utils/helpers.py +15 -2
  54. khoj/utils/yaml.py +4 -0
  55. {khoj-1.27.2.dev29.dist-info → khoj-1.27.2.dev130.dist-info}/METADATA +1 -1
  56. {khoj-1.27.2.dev29.dist-info → khoj-1.27.2.dev130.dist-info}/RECORD +63 -60
  57. khoj/interface/compiled/_next/static/chunks/1603-5138bb7c8035d9a6.js +0 -1
  58. khoj/interface/compiled/_next/static/chunks/2697-61fcba89fd87eab4.js +0 -1
  59. khoj/interface/compiled/_next/static/chunks/3423-0b533af8bf6ac218.js +0 -1
  60. khoj/interface/compiled/_next/static/chunks/9479-ff7d8c4dae2014d1.js +0 -1
  61. khoj/interface/compiled/_next/static/chunks/app/chat/page-97f5b61aaf46d364.js +0 -1
  62. khoj/interface/compiled/_next/static/chunks/app/factchecker/page-d82403db2866bad8.js +0 -1
  63. khoj/interface/compiled/_next/static/css/4cae6c0e5c72fb2d.css +0 -1
  64. khoj/interface/compiled/_next/static/css/76d55eb435962b19.css +0 -25
  65. khoj/interface/compiled/_next/static/css/ddcc0cf73e062476.css +0 -1
  66. /khoj/interface/compiled/_next/static/{atzIseFarmC7TIwq2BgHC → N19uqHAJYqRAVxvuVwHfE}/_buildManifest.js +0 -0
  67. /khoj/interface/compiled/_next/static/{atzIseFarmC7TIwq2BgHC → N19uqHAJYqRAVxvuVwHfE}/_ssgManifest.js +0 -0
  68. /khoj/interface/compiled/_next/static/chunks/{1970-60c96aed937a4928.js → 1970-444843bea1d17d61.js} +0 -0
  69. /khoj/interface/compiled/_next/static/chunks/{9417-2ca87207387fc790.js → 9417-19cfd1a9cb758e71.js} +0 -0
  70. {khoj-1.27.2.dev29.dist-info → khoj-1.27.2.dev130.dist-info}/WHEEL +0 -0
  71. {khoj-1.27.2.dev29.dist-info → khoj-1.27.2.dev130.dist-info}/entry_points.txt +0 -0
  72. {khoj-1.27.2.dev29.dist-info → khoj-1.27.2.dev130.dist-info}/licenses/LICENSE +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3423],{53423:function(e,t,a){"use strict";a.d(t,{H:function(){return en},Z:function(){return er}});var s=a(57437),n=a(34531),l=a.n(n),r=a(14944),o=a(39952),c=a.n(o),i=a(2265),d=a(34040);a(7395);var h=a(26100),u=a(36013),m=a(13304),g=a(12218),p=a(74697),f=a(37440);let x=m.fC,j=m.xz;m.x8;let w=m.h_,b=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(m.aV,{className:(0,f.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...n,ref:t})});b.displayName=m.aV.displayName;let y=(0,g.j)("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),N=i.forwardRef((e,t)=>{let{side:a="right",className:n,children:l,...r}=e;return(0,s.jsxs)(w,{children:[(0,s.jsx)(b,{}),(0,s.jsxs)(m.VY,{ref:t,className:(0,f.cn)(y({side:a}),n),...r,children:[l,(0,s.jsxs)(m.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[(0,s.jsx)(p.Z,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});N.displayName=m.VY.displayName;let k=e=>{let{className:t,...a}=e;return(0,s.jsx)("div",{className:(0,f.cn)("flex flex-col space-y-2 text-center sm:text-left",t),...a})};k.displayName="SheetHeader";let C=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(m.Dx,{ref:t,className:(0,f.cn)("text-lg font-semibold text-foreground",a),...n})});C.displayName=m.Dx.displayName;let M=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(m.dk,{ref:t,className:(0,f.cn)("text-sm text-muted-foreground",a),...n})});M.displayName=m.dk.displayName;var _=a(19573),v=a(11838),R=a.n(v),E=a(89417);let T=new r.Z({html:!0,linkify:!0,typographer:!0});function D(e){let t=(0,E.Le)(e.title||".txt","w-6 h-6 text-muted-foreground inline-flex mr-2"),a=function(e){let t=["org","md","markdown"].includes(e.title.split(".").pop()||"")?e.content.split("\n").slice(1).join("\n"):e.content;return e.showFullContent?R().sanitize(T.render(t)):R().sanitize(t)}(e),[n,l]=(0,i.useState)(!1);return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(_.J2,{open:n&&!e.showFullContent,onOpenChange:l,children:[(0,s.jsx)(_.xo,{asChild:!0,children:(0,s.jsxs)(u.Zb,{onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words text-balance rounded-lg p-2 bg-muted border-none"),children:[(0,s.jsxs)("h3",{className:"".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground}"),children:[t,e.title]}),(0,s.jsx)("p",{className:"".concat(e.showFullContent?"block":"overflow-hidden line-clamp-2"),dangerouslySetInnerHTML:{__html:a}})]})}),(0,s.jsx)(_.yk,{className:"w-[400px] mx-2",children:(0,s.jsxs)(u.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg p-2 border-none",children:[(0,s.jsxs)("h3",{className:"line-clamp-2 text-muted-foreground}",children:[t,e.title]}),(0,s.jsx)("p",{className:"overflow-hidden line-clamp-3",dangerouslySetInnerHTML:{__html:a}})]})})]})})}function L(e){let[t,a]=(0,i.useState)(!1);if(!e.link||e.link.split(" ").length>1)return null;let n="https://www.google.com/s2/favicons?domain=globe",l="unknown";try{l=new URL(e.link).hostname,n="https://www.google.com/s2/favicons?domain=".concat(l)}catch(t){return console.warn("Error parsing domain from link: ".concat(e.link)),null}return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(_.J2,{open:t&&!e.showFullContent,onOpenChange:a,children:[(0,s.jsx)(_.xo,{asChild:!0,children:(0,s.jsx)(u.Zb,{onMouseEnter:()=>{a(!0)},onMouseLeave:()=>{a(!1)},className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words rounded-lg text-balance p-2 bg-muted border-none"),children:(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline p-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("img",{src:n,alt:"",className:"!w-4 h-4 mr-2 flex-shrink-0"}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground flex-grow"),children:l})]}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," font-bold"),children:e.title}),(0,s.jsx)("p",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"),children:e.description})]})})})}),(0,s.jsx)(_.yk,{className:"w-[400px] mx-2",children:(0,s.jsx)(u.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg border-none",children:(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline p-2",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("img",{src:n,alt:"",className:"!w-4 h-4 mr-2"}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," text-muted-foreground"),children:l})]}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," font-bold"),children:e.title}),(0,s.jsx)("p",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-3"),children:e.description})]})})})})]})})}function S(e){let[t,a]=(0,i.useState)(3);(0,i.useEffect)(()=>{a(e.isMobileWidth?1:3)},[e.isMobileWidth]);let n=e.notesReferenceCardData.slice(0,t),l=n.length<t?e.onlineReferenceCardData.slice(0,t-n.length):[],r=e.notesReferenceCardData.length>0||e.onlineReferenceCardData.length>0,o=e.notesReferenceCardData.length+e.onlineReferenceCardData.length;return 0===o?null:(0,s.jsxs)("div",{className:"pt-0 px-4 pb-4 md:px-6",children:[(0,s.jsxs)("h3",{className:"inline-flex items-center",children:["References",(0,s.jsxs)("p",{className:"text-gray-400 m-2",children:[o," sources"]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[n.map((e,t)=>(0,i.createElement)(D,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),l.map((e,t)=>(0,i.createElement)(L,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),r&&(0,s.jsx)(F,{notesReferenceCardData:e.notesReferenceCardData,onlineReferenceCardData:e.onlineReferenceCardData})]})]})}function F(e){return e.notesReferenceCardData||e.onlineReferenceCardData?(0,s.jsxs)(x,{children:[(0,s.jsxs)(j,{className:"text-balance w-auto md:w-[200px] justify-start overflow-hidden break-words p-0 bg-transparent border-none text-gray-400 align-middle items-center !m-2 inline-flex",children:["View references",(0,s.jsx)(h.o,{className:"m-1"})]}),(0,s.jsxs)(N,{className:"overflow-y-scroll",children:[(0,s.jsxs)(k,{children:[(0,s.jsx)(C,{children:"References"}),(0,s.jsx)(M,{children:"View all references for this response"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[e.notesReferenceCardData.map((e,t)=>(0,i.createElement)(D,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)})),e.onlineReferenceCardData.map((e,t)=>(0,i.createElement)(L,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)}))]})]})]}):null}var B=a(34149),H=a(29386),A=a(31784),O=a(60665),W=a(96006),Z=a(18444),q=a(35304),z=a(8589),P=a(13493),G=a(63205),U=a(32970),I=a(84120),V=a(92880),$=a(48408),J=a(67722),Y=a(58485),K=a(58575),Q=a(25800);let X=(0,a(57818).default)(()=>Promise.all([a.e(6555),a.e(7293),a.e(1459),a.e(1210)]).then(a.bind(a,51210)).then(e=>e.default),{loadableGenerated:{webpack:()=>[51210]},ssr:!1});function ee(e){return(0,s.jsx)(i.Suspense,{fallback:(0,s.jsx)(Y.Z,{}),children:(0,s.jsx)(X,{data:e.data})})}let et=new r.Z({html:!0,linkify:!0,typographer:!0});function ea(e,t,a){fetch("/api/chat/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uquery:e,kquery:t,sentiment:a})})}function es(e){let{uquery:t,kquery:a}=e,[n,r]=(0,i.useState)(null);return(0,i.useEffect)(()=>{null!==n&&setTimeout(()=>{r(null)},2e3)},[n]),(0,s.jsxs)("div",{className:"".concat(l().feedbackButtons," flex align-middle justify-center items-center"),children:[(0,s.jsx)("button",{title:"Like",className:l().thumbsUpButton,disabled:null!==n,onClick:()=>{ea(t,a,"positive"),r(!0)},children:!0===n?(0,s.jsx)(B.V,{alt:"Liked Message",className:"text-green-500",weight:"fill"}):(0,s.jsx)(B.V,{alt:"Like Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),(0,s.jsx)("button",{title:"Dislike",className:l().thumbsDownButton,disabled:null!==n,onClick:()=>{ea(t,a,"negative"),r(!1)},children:!1===n?(0,s.jsx)(H.L,{alt:"Disliked Message",className:"text-red-500",weight:"fill"}):(0,s.jsx)(H.L,{alt:"Dislike Message",className:"hsl(var(--muted-foreground)) hover:text-red-500"})})]})}function en(e){let t=e.message.match(/\*\*(.*)\*\*/),a=function(e,t){let a=e.toLowerCase(),n="inline mt-1 mr-2 ".concat(t," h-4 w-4");return a.includes("understanding")?(0,s.jsx)(A.a,{className:"".concat(n)}):a.includes("generating")?(0,s.jsx)(O.Z,{className:"".concat(n)}):a.includes("data sources")||a.includes("notes")?(0,s.jsx)(W.g,{className:"".concat(n)}):a.includes("read")?(0,s.jsx)(Z.f,{className:"".concat(n)}):a.includes("search")?(0,s.jsx)(q.Y,{className:"".concat(n)}):a.includes("summary")||a.includes("summarize")||a.includes("enhanc")?(0,s.jsx)(z.u,{className:"".concat(n)}):a.includes("diagram")?(0,s.jsx)(P.j,{className:"".concat(n)}):a.includes("paint")?(0,s.jsx)(G.Y,{className:"".concat(n)}):(0,s.jsx)(A.a,{className:"".concat(n)})}(t?t[1]:"",e.primary?(0,K.oz)(e.agentColor):"text-gray-500"),n=R().sanitize(et.render(e.message));return(0,s.jsxs)("div",{className:"".concat(l().trainOfThoughtElement," break-all items-center ").concat(e.primary?"text-gray-400":"text-gray-300"," ").concat(l().trainOfThought," ").concat(e.primary?l().primary:""),children:[a,(0,s.jsx)("div",{dangerouslySetInnerHTML:{__html:n}})]})}et.use(c(),{inline:!0,code:!0});let el=(0,i.forwardRef)((e,t)=>{var a,n;let r,o,c,h,u;let[m,g]=(0,i.useState)(!1),[p,f]=(0,i.useState)(!1),[x,j]=(0,i.useState)(""),[w,b]=(0,i.useState)(""),[y,N]=(0,i.useState)(!1),[k,C]=(0,i.useState)(!1),[M,_]=(0,i.useState)(""),v=(0,i.useRef)(!1),E=(0,i.useRef)(null);async function T(){let t=e.chatMessage.message.match(/[^.!?]+[.!?]*/g)||[];if(!t||0===t.length||!t[0])return;N(!0);let a=D(t[0]);for(let e=0;e<t.length&&!v.current;e++){let s=a;e<t.length-1&&(a=D(t[e+1]));try{let e=await s,t=URL.createObjectURL(e);await function(e){return new Promise((t,a)=>{let s=new Audio(e);s.onended=t,s.onerror=a,s.play()})}(t)}catch(e){console.error("Error:",e);break}}N(!1),C(!1)}async function D(e){let t=await fetch("/api/chat/speech?text=".concat(encodeURIComponent(e)),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Network response was not ok");return await t.blob()}(0,i.useEffect)(()=>{v.current=k},[k]),(0,i.useEffect)(()=>{let e=new MutationObserver((e,t)=>{if(E.current)for(let t of e)"childList"===t.type&&t.addedNodes.length>0&&(0,Q.Z)(E.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]})});return E.current&&e.observe(E.current,{childList:!0}),()=>e.disconnect()},[E.current]),(0,i.useEffect)(()=>{let t=e.chatMessage.message;e.chatMessage.intent&&"excalidraw"==e.chatMessage.intent.type&&(t=e.chatMessage.intent["inferred-queries"][0],_(e.chatMessage.message)),t=t.replace(/\\\(/g,"LEFTPAREN").replace(/\\\)/g,"RIGHTPAREN").replace(/\\\[/g,"LEFTBRACKET").replace(/\\\]/g,"RIGHTBRACKET");let a={"text-to-image":e=>"![generated image](data:image/png;base64,".concat(e,")"),"text-to-image2":e=>"![generated image](".concat(e,")"),"text-to-image-v3":e=>"![generated image](data:image/webp;base64,".concat(e,")"),excalidraw:e=>e};if(e.chatMessage.intent){let{type:s,"inferred-queries":n}=e.chatMessage.intent;console.log("intent type",s),s in a&&(t=a[s](t)),s.includes("text-to-image")&&(null==n?void 0:n.length)>0&&(t+="\n\n".concat(n[0]))}let s=t,n=t;if(e.chatMessage.images&&e.chatMessage.images.length>0){let t=e.chatMessage.images.map(e=>{let t=e.startsWith("data%3Aimage")?decodeURIComponent(e):e;return R().sanitize(t)}),a=t.map((e,t)=>"![uploaded image ".concat(t+1,"](").concat(e,")")).join("\n"),r=t.map((e,t)=>'<div class="'.concat(l().imageWrapper,'"><img src="').concat(e,'" alt="uploaded image ').concat(t+1,'" /></div>')).join(""),o='<div class="'.concat(l().imagesContainer,'">').concat(r,"</div>");s="".concat(a,"\n\n").concat(s),n="".concat(o).concat(n)}j(s);let r=et.render(n);r=r.replace(/LEFTPAREN/g,"\\(").replace(/RIGHTPAREN/g,"\\)").replace(/LEFTBRACKET/g,"\\[").replace(/RIGHTBRACKET/g,"\\]"),b(R().sanitize(r))},[e.chatMessage.message,e.chatMessage.images,e.chatMessage.intent]),(0,i.useEffect)(()=>{m&&setTimeout(()=>{g(!1)},2e3)},[m]),(0,i.useEffect)(()=>{E.current&&(E.current.querySelectorAll("pre > .hljs").forEach(e=>{if(!e.querySelector("".concat(l().codeCopyButton))){let t=document.createElement("button"),a=(0,s.jsx)(U.w,{size:24});(0,d.createRoot)(t).render(a),t.className="hljs ".concat(l().codeCopyButton),t.addEventListener("click",()=>{let a=e.textContent||"";a=(a=(a=a.replace(/^\$+/,"")).replace(/^Copy/,"")).trim(),navigator.clipboard.writeText(a);let n=(0,s.jsx)(I.J,{size:24});(0,d.createRoot)(t).render(n)}),e.prepend(t)}}),(0,Q.Z)(E.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]}))},[w,p,E]);let L=function(e,t){let a=[],s=[];if(t){let e=[];for(let[a,s]of Object.entries(t)){if(s.answerBox&&e.push({title:s.answerBox.title,description:s.answerBox.answer,link:s.answerBox.source}),s.knowledgeGraph&&e.push({title:s.knowledgeGraph.title,description:s.knowledgeGraph.description,link:s.knowledgeGraph.descriptionLink}),s.webpages){if(s.webpages instanceof Array){let t=s.webpages.map(e=>({title:e.query,description:e.snippet,link:e.link}));e.push(...t)}else{let t=s.webpages;e.push({title:t.query,description:t.snippet,link:t.link})}}if(s.organic){let t=s.organic.map(e=>({title:e.title,description:e.snippet,link:e.link}));e.push(...t)}}a.push(...e)}if(e){let t=e.map(e=>e.compiled?{title:e.file,content:e.compiled}:{title:e.split("\n")[0],content:e.split("\n").slice(1).join("\n")});s.push(...t)}return{notesReferenceCardData:s,onlineReferenceCardData:a}}(e.chatMessage.context,e.chatMessage.onlineContext);return(0,s.jsxs)("div",{ref:t,className:(a=e.chatMessage,(r=[l().chatMessageContainer,"shadow-md"]).push(l()[a.by]),a.message||r.push(l().emptyChatMessage),e.customClassName&&r.push(l()["".concat(a.by).concat(e.customClassName)]),r.join(" ")),onMouseLeave:e=>f(!1),onMouseEnter:e=>f(!0),children:[(0,s.jsxs)("div",{className:(n=e.chatMessage,(o=[l().chatMessageWrapper]).push(l()[n.by]),"khoj"===n.by&&o.push("border-l-4 border-opacity-50 ".concat("border-l-"+e.borderLeftColor)),o.join(" ")),children:[(0,s.jsx)("div",{ref:E,className:l().chatMessage,dangerouslySetInnerHTML:{__html:w}}),M&&(0,s.jsx)(ee,{data:M})]}),(0,s.jsx)("div",{className:l().teaserReferencesContainer,children:(0,s.jsx)(S,{isMobileWidth:e.isMobileWidth,notesReferenceCardData:L.notesReferenceCardData,onlineReferenceCardData:L.onlineReferenceCardData})}),(0,s.jsx)("div",{className:l().chatFooter,children:(p||e.isMobileWidth||e.isLastMessage||y)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{title:(h=(c=new Date(e.chatMessage.created+"Z")).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0}).toUpperCase(),u=c.toLocaleString("en-US",{year:"numeric",month:"short",day:"2-digit"}).replaceAll("-"," "),"".concat(h," on ").concat(u)),className:"text-gray-400 relative top-0 left-4",children:function(e){e.endsWith("Z")||(e+="Z");let t=new Date(e),a=new Date().getTime()-t.getTime();return a<6e4?"Just now":a<36e5?"".concat(Math.round(a/6e4),"m ago"):a<864e5?"".concat(Math.round(a/36e5),"h ago"):"".concat(Math.round(a/864e5),"d ago")}(e.chatMessage.created)}),(0,s.jsxs)("div",{className:"".concat(l().chatButtons," shadow-sm"),children:["khoj"===e.chatMessage.by&&(y?k?(0,s.jsx)(Y.l,{iconClassName:"p-0",className:"m-0"}):(0,s.jsx)("button",{title:"Pause Speech",onClick:e=>C(!0),children:(0,s.jsx)(V.d,{alt:"Pause Message",className:"hsl(var(--muted-foreground))"})}):(0,s.jsx)("button",{title:"Speak",onClick:e=>T(),children:(0,s.jsx)($.j,{alt:"Speak Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})})),(0,s.jsx)("button",{title:"Copy",className:"".concat(l().copyButton),onClick:()=>{navigator.clipboard.writeText(x),g(!0)},children:m?(0,s.jsx)(J.C,{alt:"Copied Message",weight:"fill",className:"text-green-500"}):(0,s.jsx)(J.C,{alt:"Copy Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),"khoj"===e.chatMessage.by&&(e.chatMessage.intent?(0,s.jsx)(es,{uquery:e.chatMessage.intent.query,kquery:e.chatMessage.message}):(0,s.jsx)(es,{uquery:e.chatMessage.rawQuery||e.chatMessage.message,kquery:e.chatMessage.message}))]})]})})]})});el.displayName="ChatMessage";var er=el},34531:function(e){e.exports={chatMessageContainer:"chatMessage_chatMessageContainer__sAivf",chatMessageWrapper:"chatMessage_chatMessageWrapper__u5m8A",khojfullHistory:"chatMessage_khojfullHistory__NPu2l",youfullHistory:"chatMessage_youfullHistory__ioyfH",you:"chatMessage_you__6GUC4",khoj:"chatMessage_khoj__cjWON",khojChatMessage:"chatMessage_khojChatMessage__BabQz",emptyChatMessage:"chatMessage_emptyChatMessage__J9JRn",imagesContainer:"chatMessage_imagesContainer__HTRjT",imageWrapper:"chatMessage_imageWrapper__DF92M",author:"chatMessage_author__muRtC",chatFooter:"chatMessage_chatFooter__0vR8s",chatButtons:"chatMessage_chatButtons__Lbk8T",codeCopyButton:"chatMessage_codeCopyButton__Y_Ujv",feedbackButtons:"chatMessage_feedbackButtons___Brdy",copyButton:"chatMessage_copyButton__jd7q7",trainOfThought:"chatMessage_trainOfThought__mR2Gg",primary:"chatMessage_primary__WYPEb",trainOfThoughtElement:"chatMessage_trainOfThoughtElement__le_bC"}}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9479],{59479:function(e,t,a){"use strict";a.d(t,{a:function(){return eL}});var r=a(57437),n=a(37649),l=a.n(n),o=a(2265),s=a(11838),i=a.n(s);a(7395);var c=a(52195);let d=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M212.48,136.49l-82.06,82a60,60,0,0,1-84.85-84.88l98.16-97.89a40,40,0,0,1,56.56,56.59l-.17.16-95.8,92.22a12,12,0,1,1-16.64-17.3l95.71-92.12a16,16,0,0,0-22.7-22.56L62.53,150.57a36,36,0,0,0,50.93,50.91l82.06-82a12,12,0,0,1,17,17Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M180.75,104.75,204,128l-82.06,81.94a48,48,0,0,1-67.88-67.88L153.37,41.37a32,32,0,0,1,45.26,45.26Z",opacity:"0.2"}),o.createElement("path",{d:"M209.66,122.34a8,8,0,0,1,0,11.32l-82.05,82a56,56,0,0,1-79.2-79.21L147.67,35.73a40,40,0,1,1,56.61,56.55L105,193A24,24,0,1,1,71,159L154.3,74.38A8,8,0,1,1,165.7,85.6L82.39,170.31a8,8,0,1,0,11.27,11.36L192.93,81A24,24,0,1,0,159,47L59.76,147.68a40,40,0,1,0,56.53,56.62l82.06-82A8,8,0,0,1,209.66,122.34Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm37.66,50.34a8,8,0,0,0-11.32,0L87.09,143A24,24,0,1,0,121,177l49.32-50.32a8,8,0,1,1,11.42,11.2l-49.37,50.38a40,40,0,1,1-56.62-56.51L143,63.09A24,24,0,1,1,177,97L109.71,165.6a8,8,0,1,1-11.42-11.2L165.6,85.71a8,8,0,0,0,.06-11.37Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M208.25,123.76a6,6,0,0,1,0,8.49l-82.06,82a54,54,0,0,1-76.36-76.39L149.1,37.14a38,38,0,1,1,53.77,53.72L103.59,191.54a22,22,0,1,1-31.15-31.09l83.28-84.67a6,6,0,0,1,8.56,8.42L81,168.91a10,10,0,1,0,14.11,14.18L194.35,82.4a26,26,0,1,0-36.74-36.8L58.33,146.28a42,42,0,1,0,59.37,59.44l82.06-82A6,6,0,0,1,208.25,123.76Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M209.66,122.34a8,8,0,0,1,0,11.32l-82.05,82a56,56,0,0,1-79.2-79.21L147.67,35.73a40,40,0,1,1,56.61,56.55L105,193A24,24,0,1,1,71,159L154.3,74.38A8,8,0,1,1,165.7,85.6L82.39,170.31a8,8,0,1,0,11.27,11.36L192.93,81A24,24,0,1,0,159,47L59.76,147.68a40,40,0,1,0,56.53,56.62l82.06-82A8,8,0,0,1,209.66,122.34Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M206.83,125.17a4,4,0,0,1,0,5.66l-82.06,82a52,52,0,0,1-73.54-73.55L150.52,38.55a36,36,0,1,1,50.94,50.9l-99.3,100.69a20,20,0,1,1-28.3-28.27l83.29-84.68a4,4,0,1,1,5.7,5.61L79.54,167.5a12,12,0,1,0,16.95,17L195.78,83.81A28,28,0,1,0,156.2,44.18L56.91,144.87a44,44,0,1,0,62.21,62.26l82-82A4,4,0,0,1,206.83,125.17Z"}))]]);var u=Object.defineProperty,m=Object.defineProperties,h=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,b=(e,t,a)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,x=(e,t)=>{for(var a in t||(t={}))f.call(t,a)&&b(e,a,t[a]);if(p)for(var a of p(t))g.call(t,a)&&b(e,a,t[a]);return e},j=(e,t)=>m(e,h(t));let v=(0,o.forwardRef)((e,t)=>o.createElement(c.Z,j(x({ref:t},e),{weights:d})));v.displayName="Paperclip";let y=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),o.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM181.66,170.34a8,8,0,0,1-11.32,11.32L128,139.31,85.66,181.66a8,8,0,0,1-11.32-11.32L116.69,128,74.34,85.66A8,8,0,0,1,85.66,74.34L128,116.69l42.34-42.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M204.24,195.76a6,6,0,1,1-8.48,8.48L128,136.49,60.24,204.24a6,6,0,0,1-8.48-8.48L119.51,128,51.76,60.24a6,6,0,0,1,8.48-8.48L128,119.51l67.76-67.75a6,6,0,0,1,8.48,8.48L136.49,128Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M202.83,197.17a4,4,0,0,1-5.66,5.66L128,133.66,58.83,202.83a4,4,0,0,1-5.66-5.66L122.34,128,53.17,58.83a4,4,0,0,1,5.66-5.66L128,122.34l69.17-69.17a4,4,0,1,1,5.66,5.66L133.66,128Z"}))]]);var w=Object.defineProperty,E=Object.defineProperties,L=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,M=(e,t,a)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,V=(e,t)=>{for(var a in t||(t={}))O.call(t,a)&&M(e,a,t[a]);if(A)for(var a of A(t))Z.call(t,a)&&M(e,a,t[a]);return e},N=(e,t)=>E(e,L(t));let F=(0,o.forwardRef)((e,t)=>o.createElement(c.Z,N(V({ref:t},e),{weights:y})));F.displayName="X";let C=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M200,36H56A20,20,0,0,0,36,56V200a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Zm-4,160H60V60H196Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M208,56V200a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H200A8,8,0,0,1,208,56Z",opacity:"0.2"}),o.createElement("path",{d:"M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M200,42H56A14,14,0,0,0,42,56V200a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V56A14,14,0,0,0,200,42Zm2,158a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2H200a2,2,0,0,1,2,2Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M200,44H56A12,12,0,0,0,44,56V200a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V56A12,12,0,0,0,200,44Zm4,156a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4H200a4,4,0,0,1,4,4Z"}))]]);var H=Object.defineProperty,k=Object.defineProperties,P=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable,I=(e,t,a)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,T=(e,t)=>{for(var a in t||(t={}))S.call(t,a)&&I(e,a,t[a]);if(D)for(var a of D(t))R.call(t,a)&&I(e,a,t[a]);return e},z=(e,t)=>k(e,P(t));let _=(0,o.forwardRef)((e,t)=>o.createElement(c.Z,z(T({ref:t},e),{weights:C})));_.displayName="Stop";let U=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M128,180a52.06,52.06,0,0,0,52-52V64A52,52,0,0,0,76,64v64A52.06,52.06,0,0,0,128,180ZM100,64a28,28,0,0,1,56,0v64a28,28,0,0,1-56,0Zm40,155.22V240a12,12,0,0,1-24,0V219.22A92.14,92.14,0,0,1,36,128a12,12,0,0,1,24,0,68,68,0,0,0,136,0,12,12,0,0,1,24,0A92.14,92.14,0,0,1,140,219.22Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M168,64v64a40,40,0,0,1-40,40h0a40,40,0,0,1-40-40V64a40,40,0,0,1,40-40h0A40,40,0,0,1,168,64Z",opacity:"0.2"}),o.createElement("path",{d:"M128,176a48.05,48.05,0,0,0,48-48V64a48,48,0,0,0-96,0v64A48.05,48.05,0,0,0,128,176ZM96,64a32,32,0,0,1,64,0v64a32,32,0,0,1-64,0Zm40,143.6V240a8,8,0,0,1-16,0V207.6A80.11,80.11,0,0,1,48,128a8,8,0,0,1,16,0,64,64,0,0,0,128,0,8,8,0,0,1,16,0A80.11,80.11,0,0,1,136,207.6Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M80,128V64a48,48,0,0,1,96,0v64a48,48,0,0,1-96,0Zm128,0a8,8,0,0,0-16,0,64,64,0,0,1-128,0,8,8,0,0,0-16,0,80.11,80.11,0,0,0,72,79.6V240a8,8,0,0,0,16,0V207.6A80.11,80.11,0,0,0,208,128Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M128,174a46.06,46.06,0,0,0,46-46V64a46,46,0,0,0-92,0v64A46.06,46.06,0,0,0,128,174ZM94,64a34,34,0,0,1,68,0v64a34,34,0,0,1-68,0Zm40,141.75V240a6,6,0,0,1-12,0V205.75A78.09,78.09,0,0,1,50,128a6,6,0,0,1,12,0,66,66,0,0,0,132,0,6,6,0,0,1,12,0A78.09,78.09,0,0,1,134,205.75Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M128,176a48.05,48.05,0,0,0,48-48V64a48,48,0,0,0-96,0v64A48.05,48.05,0,0,0,128,176ZM96,64a32,32,0,0,1,64,0v64a32,32,0,0,1-64,0Zm40,143.6V240a8,8,0,0,1-16,0V207.6A80.11,80.11,0,0,1,48,128a8,8,0,0,1,16,0,64,64,0,0,0,128,0,8,8,0,0,1,16,0A80.11,80.11,0,0,1,136,207.6Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M128,172a44.05,44.05,0,0,0,44-44V64a44,44,0,0,0-88,0v64A44.05,44.05,0,0,0,128,172ZM92,64a36,36,0,0,1,72,0v64a36,36,0,0,1-72,0Zm40,139.89V240a4,4,0,0,1-8,0V203.89A76.09,76.09,0,0,1,52,128a4,4,0,0,1,8,0,68,68,0,0,0,136,0,4,4,0,0,1,8,0A76.09,76.09,0,0,1,132,203.89Z"}))]]);var Y=Object.defineProperty,W=Object.defineProperties,$=Object.getOwnPropertyDescriptors,J=Object.getOwnPropertySymbols,K=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable,X=(e,t,a)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,q=(e,t)=>{for(var a in t||(t={}))K.call(t,a)&&X(e,a,t[a]);if(J)for(var a of J(t))B.call(t,a)&&X(e,a,t[a]);return e},G=(e,t)=>W(e,$(t));let Q=(0,o.forwardRef)((e,t)=>o.createElement(c.Z,G(q({ref:t},e),{weights:U})));Q.displayName="Microphone";let ee=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M208.49,120.49a12,12,0,0,1-17,0L140,69V216a12,12,0,0,1-24,0V69L64.49,120.49a12,12,0,0,1-17-17l72-72a12,12,0,0,1,17,0l72,72A12,12,0,0,1,208.49,120.49Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M200,112H56l72-72Z",opacity:"0.2"}),o.createElement("path",{d:"M205.66,106.34l-72-72a8,8,0,0,0-11.32,0l-72,72A8,8,0,0,0,56,120h64v96a8,8,0,0,0,16,0V120h64a8,8,0,0,0,5.66-13.66ZM75.31,104,128,51.31,180.69,104Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M207.39,115.06A8,8,0,0,1,200,120H136v96a8,8,0,0,1-16,0V120H56a8,8,0,0,1-5.66-13.66l72-72a8,8,0,0,1,11.32,0l72,72A8,8,0,0,1,207.39,115.06Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M204.24,116.24a6,6,0,0,1-8.48,0L134,54.49V216a6,6,0,0,1-12,0V54.49L60.24,116.24a6,6,0,0,1-8.48-8.48l72-72a6,6,0,0,1,8.48,0l72,72A6,6,0,0,1,204.24,116.24Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M205.66,117.66a8,8,0,0,1-11.32,0L136,59.31V216a8,8,0,0,1-16,0V59.31L61.66,117.66a8,8,0,0,1-11.32-11.32l72-72a8,8,0,0,1,11.32,0l72,72A8,8,0,0,1,205.66,117.66Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M202.83,114.83a4,4,0,0,1-5.66,0L132,49.66V216a4,4,0,0,1-8,0V49.66L58.83,114.83a4,4,0,0,1-5.66-5.66l72-72a4,4,0,0,1,5.66,0l72,72A4,4,0,0,1,202.83,114.83Z"}))]]);var et=Object.defineProperty,ea=Object.defineProperties,er=Object.getOwnPropertyDescriptors,en=Object.getOwnPropertySymbols,el=Object.prototype.hasOwnProperty,eo=Object.prototype.propertyIsEnumerable,es=(e,t,a)=>t in e?et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,ei=(e,t)=>{for(var a in t||(t={}))el.call(t,a)&&es(e,a,t[a]);if(en)for(var a of en(t))eo.call(t,a)&&es(e,a,t[a]);return e},ec=(e,t)=>ea(e,er(t));let ed=(0,o.forwardRef)((e,t)=>o.createElement(c.Z,ec(ei({ref:t},e),{weights:ee})));ed.displayName="ArrowUp";var eu=a(42491),em=a(6780),eh=a(50495),ep=a(70571),ef=a(19573),eg=a(61485),eb=a(93146),ex=a(19666),ej=a(58575),ev=a(66820),ey=a(9557),ew=a(58485),eE=a(89417);let eL=(0,o.forwardRef)((e,t)=>{let[a,n]=(0,o.useState)(""),s=(0,o.useRef)(null),[c,d]=(0,o.useState)(null),[u,m]=(0,o.useState)(null),[h,p]=(0,o.useState)(!1),[f,g]=(0,o.useState)(null),[b,x]=(0,o.useState)(!1),[j,y]=(0,o.useState)(!1),[w,E]=(0,o.useState)([]),[L,A]=(0,o.useState)([]),[O,Z]=(0,o.useState)(!1),[M,V]=(0,o.useState)(null),[N,C]=(0,o.useState)(0),[H,k]=(0,o.useState)(!1);function P(){if(j&&(y(!1),E([]),L.forEach(t=>e.sendImage(t))),a.trim()){if(!e.isLoggedIn){g("Hey there, you need to be signed in to send messages to Khoj AI"),x(!0);return}e.sendMessage(a.trim()),n("")}}function D(a){var r,n;if(!e.isLoggedIn){g("Please login to chat with your files"),x(!0);return}let l=["jpg","jpeg","png","webp"],o=[];for(let e=0;e<a.length;e++){let t=a[e],r=t.name.split(".").pop();l.includes(r||"")&&o.push(i().sanitize(URL.createObjectURL(t)))}if(o.length>0){y(!0),E(e=>[...e,...o]),null==t||null===(n=t.current)||void 0===n||n.focus();return}(0,ey.ko)(a,d,p,m,e.setUploadedFiles,e.conversationId),null==t||null===(r=t.current)||void 0===r||r.focus()}async function S(){try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=new MediaRecorder(e,{mimeType:"audio/webm"}),a=[];t.ondataavailable=async e=>{a.push(e.data);let t=new Blob(a,{type:"audio/webm"}),r=new FormData;r.append("file",t);try{let e=await fetch("/api/transcribe",{method:"POST",body:r});if(!e.ok)throw Error("Network response was not ok");let t=await e.json();n(t.text.trim())}catch(e){console.error("Error sending audio to server:",e)}},t.start(1500),t.onstop=async()=>{let e=new Blob(a,{type:"audio/webm"}),r=new FormData;r.append("file",e);try{let e=await fetch("/api/transcribe",{method:"POST",body:r});if(!e.ok)throw Error("Network response was not ok");let a=await e.json();t.stream.getTracks().forEach(e=>e.stop()),V(null),n(a.text.trim())}catch(e){console.error("Error sending audio to server:",e)}},V(t)}catch(e){console.error("Error getting microphone",e)}}return(0,o.useEffect)(()=>{if(h||C(0),h){let e=setInterval(()=>{C(e=>{let t=e+(Math.floor(5*Math.random())+1);return t<100?t:100})},800);return()=>clearInterval(e)}},[h]),(0,o.useEffect)(()=>{async function e(){w.length>0&&A(await Promise.all(w.map(async e=>{let t=await fetch(e),a=await t.blob();return new Promise(e=>{let t=new FileReader;t.onload=()=>e(t.result),t.readAsDataURL(a)})}))),p(!1)}p(!0),e()},[w]),(0,o.useEffect)(()=>{!O&&M&&M.stop(),O&&!M&&S()},[O,M]),(0,o.useEffect)(()=>{(null==t?void 0:t.current)&&(t.current.style.height="auto",t.current.style.height=Math.max(t.current.scrollHeight-24,64)+"px")},[a]),(0,r.jsxs)(r.Fragment,{children:[b&&f&&(0,r.jsx)(ev.Z,{onOpenChange:x,loginRedirectMessage:f}),h&&(0,r.jsx)(em.aR,{open:h,children:(0,r.jsxs)(em._T,{children:[(0,r.jsx)(em.fY,{children:(0,r.jsx)(em.f$,{children:"Uploading data. Please wait."})}),(0,r.jsx)(em.yT,{children:(0,r.jsx)(ep.E,{indicatorColor:"bg-slate-500",className:"w-full h-2 rounded-full",value:N})}),(0,r.jsx)(em.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>p(!1),children:"Dismiss"})]})}),c&&(0,r.jsx)(em.aR,{open:null!==c,children:(0,r.jsxs)(em._T,{children:[(0,r.jsx)(em.fY,{children:(0,r.jsx)(em.f$,{children:"Data Upload Warning"})}),(0,r.jsx)(em.yT,{children:c}),(0,r.jsx)(em.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>d(null),children:"Close"})]})}),u&&(0,r.jsx)(em.aR,{open:null!==u,children:(0,r.jsxs)(em._T,{children:[(0,r.jsxs)(em.fY,{children:[(0,r.jsx)(em.f$,{children:"Oh no!"}),(0,r.jsx)(em.yT,{children:"Something went wrong while uploading your data"})]}),(0,r.jsx)(em.yT,{children:u}),(0,r.jsx)(em.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>m(null),children:"Close"})]})}),a.startsWith("/")&&1===a.split(" ").length&&(0,r.jsx)("div",{className:"flex justify-center text-center",children:(0,r.jsxs)(ef.J2,{open:a.startsWith("/"),children:[(0,r.jsx)(eg.xo,{className:"flex justify-center text-center"}),(0,r.jsx)(ef.yk,{onOpenAutoFocus:e=>e.preventDefault(),className:"".concat(e.isMobileWidth?"w-[100vw]":"w-full"," rounded-md"),side:"top",align:"center",sideOffset:e.conversationId?0:80,alignOffset:0,children:(0,r.jsxs)(eu.mY,{className:"max-w-full",children:[(0,r.jsx)(eu.sZ,{placeholder:"Type a command or search...",value:a,className:"hidden"}),(0,r.jsxs)(eu.e8,{children:[(0,r.jsx)(eu.rb,{children:"No matching commands."}),(0,r.jsx)(eu.fu,{heading:"Agent Tools",children:e.chatOptionsData&&Object.entries(e.chatOptionsData).map(e=>{let[t,a]=e;return(0,r.jsx)(eu.di,{className:"text-md",onSelect:()=>{n("/".concat(t," "))},children:(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-1",children:[(0,r.jsxs)("div",{className:"font-bold flex items-center",children:[(0,eE.vH)(t,"h-4 w-4 mr-2"),"/",t]}),(0,r.jsx)("div",{children:a})]})},t)})}),(0,r.jsx)(eu.zz,{})]})]})})]})}),(0,r.jsxs)("div",{className:"".concat(l().actualInputArea," justify-between dark:bg-neutral-700 relative ").concat(H&&"animate-pulse"),onDragOver:function(e){e.preventDefault(),k(!0)},onDragLeave:function(e){e.preventDefault(),k(!1)},onDrop:function(e){e.preventDefault(),k(!1),e.dataTransfer.files&&D(e.dataTransfer.files)},children:[(0,r.jsx)("input",{type:"file",multiple:!0,ref:s,onChange:function(e){e.target.files&&D(e.target.files)},style:{display:"none"}}),(0,r.jsx)("div",{className:"flex items-end pb-4",children:(0,r.jsx)(eh.z,{variant:"ghost",className:"!bg-none p-0 m-2 h-auto text-3xl rounded-full text-gray-300 hover:text-gray-500",disabled:e.sendDisabled,onClick:function(){s.current&&s.current.click()},children:(0,r.jsx)(v,{className:"w-8 h-8"})})}),(0,r.jsxs)("div",{className:"flex-grow flex flex-col w-full gap-1.5 relative pb-2",children:[(0,r.jsx)("div",{className:"flex items-center gap-2 overflow-x-auto",children:j&&w.map((e,t)=>(0,r.jsxs)("div",{className:"relative flex-shrink-0 pb-3 pt-2 group",children:[(0,r.jsx)("img",{src:e,alt:"img-".concat(t),className:"w-auto h-16 object-cover rounded-xl"}),(0,r.jsx)(eh.z,{variant:"ghost",size:"icon",className:"absolute -top-0 -right-2 h-5 w-5 rounded-full bg-neutral-200 dark:bg-neutral-600 hover:bg-neutral-300 dark:hover:bg-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{E(e=>e.filter((e,a)=>a!==t)),A(e=>e.filter((e,a)=>a!==t)),1===w.length&&y(!1)},children:(0,r.jsx)(F,{className:"h-3 w-3"})})]},t))}),(0,r.jsx)(eb.g,{ref:t,className:"border-none w-full h-16 min-h-16 max-h-[128px] md:py-4 rounded-lg resize-none dark:bg-neutral-700 ".concat(e.isMobileWidth?"text-md":"text-lg"),placeholder:"Type / to see a list of commands",id:"message",autoFocus:!0,value:a,onKeyDown:t=>{"Enter"!==t.key||t.shiftKey||e.isMobileWidth||(y(!1),E([]),t.preventDefault(),P())},onChange:e=>n(e.target.value),disabled:e.sendDisabled||O})]}),(0,r.jsxs)("div",{className:"flex items-end pb-4",children:[O?(0,r.jsx)(ex.pn,{children:(0,r.jsxs)(ex.u,{children:[(0,r.jsx)(ex.aJ,{asChild:!0,children:(0,r.jsx)(eh.z,{variant:"default",className:"".concat(!O&&"hidden"," ").concat(e.agentColor?(0,ej.tp)(e.agentColor):"bg-orange-300 hover:bg-orange-500"," rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1"),onClick:()=>{Z(!O)},disabled:e.sendDisabled,children:(0,r.jsx)(_,{weight:"fill",className:"w-6 h-6"})})}),(0,r.jsx)(ex._v,{children:"Click to stop recording and transcribe your voice."})]})}):M?(0,r.jsx)(ew.l,{}):(0,r.jsx)(ex.pn,{children:(0,r.jsxs)(ex.u,{children:[(0,r.jsx)(ex.aJ,{asChild:!0,children:(0,r.jsx)(eh.z,{variant:"default",className:"".concat(!a||O||"hidden"," ").concat(e.agentColor?(0,ej.tp)(e.agentColor):"bg-orange-300 hover:bg-orange-500"," rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1"),onClick:()=>{n("Listening..."),Z(!O)},disabled:e.sendDisabled,children:(0,r.jsx)(Q,{weight:"fill",className:"w-6 h-6"})})}),(0,r.jsx)(ex._v,{children:"Click to transcribe your message with voice."})]})}),(0,r.jsx)(eh.z,{className:"".concat((!a||O)&&"hidden"," ").concat(e.agentColor?(0,ej.tp)(e.agentColor):"bg-orange-300 hover:bg-orange-500"," rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1"),onClick:P,disabled:e.sendDisabled,children:(0,r.jsx)(ed,{className:"w-6 h-6",weight:"bold"})})]})]})]})});eL.displayName="ChatInputArea"},66820:function(e,t,a){"use strict";a.d(t,{Z:function(){return o}});var r=a(57437),n=a(6780),l=a(87138);function o(e){return(0,r.jsx)(n.aR,{open:!0,onOpenChange:e.onOpenChange,children:(0,r.jsxs)(n._T,{children:[(0,r.jsx)(n.fY,{children:(0,r.jsx)(n.f$,{children:"Sign in to Khoj to continue"})}),(0,r.jsxs)(n.yT,{children:[e.loginRedirectMessage,". By logging in, you agree to our"," ",(0,r.jsx)(l.default,{href:"https://khoj.dev/terms-of-service",children:"Terms of Service."})]}),(0,r.jsxs)(n.xo,{children:[(0,r.jsx)(n.le,{children:"Dismiss"}),(0,r.jsx)(n.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>{window.location.href="/login?next=".concat(encodeURIComponent(window.location.pathname))},children:(0,r.jsxs)(l.default,{href:"/login?next=".concat(encodeURIComponent(window.location.pathname)),children:[" ","Login"]})})]})]})})}},70571:function(e,t,a){"use strict";a.d(t,{E:function(){return s}});var r=a(57437),n=a(2265),l=a(52431),o=a(37440);let s=n.forwardRef((e,t)=>{let{className:a,value:n,indicatorColor:s,...i}=e;return(0,r.jsx)(l.fC,{ref:t,className:(0,o.cn)("relative h-4 w-full overflow-hidden rounded-full bg-secondary",a),...i,children:(0,r.jsx)(l.z$,{className:"h-full w-full flex-1 bg-primary transition-all ".concat(s),style:{transform:"translateX(-".concat(100-(n||0),"%)")}})})});s.displayName=l.fC.displayName},93146:function(e,t,a){"use strict";a.d(t,{g:function(){return o}});var r=a(57437),n=a(2265),l=a(37440);let o=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,r.jsx)("textarea",{className:(0,l.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:t,...n})});o.displayName="Textarea"},19666:function(e,t,a){"use strict";a.d(t,{_v:function(){return d},aJ:function(){return c},pn:function(){return s},u:function(){return i}});var r=a(57437),n=a(2265),l=a(27071),o=a(37440);let s=l.zt,i=l.fC,c=l.xz,d=n.forwardRef((e,t)=>{let{className:a,sideOffset:n=4,...s}=e;return(0,r.jsx)(l.VY,{ref:t,sideOffset:n,className:(0,o.cn)("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...s})});d.displayName=l.VY.displayName},37649:function(e){e.exports={actualInputArea:"chatInputArea_actualInputArea__Ha6cN"}}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1929],{39929:function(e,t,s){Promise.resolve().then(s.bind(s,38874))},38874:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return p}});var a=s(57437),o=s(65104),n=s.n(o),i=s(2265),r=s(48861),c=s(82697),l=s(16463),d=s(58485),u=s(9557);s(7395);var h=s(69591),m=s(59479),g=s(79306);function f(e){let t=(0,l.useSearchParams)().get("conversationId"),[s,o]=(0,i.useState)(""),[r,d]=(0,i.useState)([]),[u,h]=(0,i.useState)(!1),[g,f]=(0,i.useState)(null),p=(0,i.useRef)(null),x=e.setQueryToProcess,_=e.onConversationIdChange,w=e.isMobileWidth?"w-full":"w-4/6";if((0,i.useEffect)(()=>{if(r.length>0){let t=r.map(e=>encodeURIComponent(e));e.setImages(t)}},[r,e.setImages]),(0,i.useEffect)(()=>{let t=localStorage.getItem("images");if(t){let s=JSON.parse(t);d(s);let a=s.map(e=>encodeURIComponent(e));e.setImages(a),localStorage.removeItem("images")}let s=localStorage.getItem("message");s&&(h(!0),x(s))},[x,e.setImages]),(0,i.useEffect)(()=>{s&&(h(!0),x(s))},[s,x]),(0,i.useEffect)(()=>{t&&(null==_||_(t))},[t,_]),(0,i.useEffect)(()=>{e.streamedMessages&&e.streamedMessages.length>0&&e.streamedMessages[e.streamedMessages.length-1].completed?(h(!1),d([])):o("")},[e.streamedMessages]),!t){window.location.href="/";return}return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:n().chatBodyFull,children:(0,a.jsx)(c.Z,{conversationId:t,setTitle:e.setTitle,setAgent:f,pendingMessage:u?s:"",incomingMessages:e.streamedMessages,customClassName:w})}),(0,a.jsx)("div",{className:"".concat(n().inputBox," p-1 md:px-2 shadow-md bg-background align-middle items-center justify-center dark:bg-neutral-700 dark:border-0 dark:shadow-sm rounded-t-2xl rounded-b-none md:rounded-xl h-fit ").concat(w," mr-auto ml-auto"),children:(0,a.jsx)(m.a,{agentColor:null==g?void 0:g.color,isLoggedIn:e.isLoggedIn,sendMessage:e=>o(e),sendImage:e=>d(t=>[...t,e]),sendDisabled:u,chatOptionsData:e.chatOptionsData,conversationId:t,isMobileWidth:e.isMobileWidth,setUploadedFiles:e.setUploadedFiles,ref:p})})]})}function p(){let e="Khoj AI - Chat",[t,s]=(0,i.useState)(null),[o,c]=(0,i.useState)(!0),[l,m]=(0,i.useState)(e),[p,x]=(0,i.useState)(null),[_,w]=(0,i.useState)([]),[y,I]=(0,i.useState)(""),[S,b]=(0,i.useState)(!1),[v,j]=(0,i.useState)([]),[B,C]=(0,i.useState)([]),E=(0,h.k6)()||{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone},T=(0,g.GW)(),k=(0,h.IC)();async function M(e){if(!e.ok)throw Error(e.statusText);if(!e.body)throw Error("Response body is null");let t=e.body.getReader(),s=new TextDecoder,a="␃\uD83D\uDD1A␗",o="",n=[],i={};for(;;){let e;let{done:r,value:c}=await t.read();if(r){I(""),b(!1),C([]);break}for(o+=s.decode(c,{stream:!0});-1!==(e=o.indexOf(a));){let t=o.slice(0,e);if(o=o.slice(e+a.length),t){let e=_.find(e=>!e.completed);if(!e){console.error("No current message found");return}({context:n,onlineContext:i}=(0,u.VK)(t,e,n,i)),w([..._])}}}}async function R(){if(localStorage.removeItem("message"),!y||!p)return;let e={q:y,conversation_id:p,stream:!0,...E&&{city:E.city,region:E.region,country:E.country,country_code:E.countryCode,timezone:E.timezone},...B.length>0&&{images:B}},t=await fetch("/api/chat?client=web",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});try{await M(t)}catch(o){let e=await t.json();console.error(e);let s=_.find(e=>!e.completed);if(!s)return;let a=o.message;a.includes("Error in input stream")?s.rawResponse="Woops! The connection broke while I was writing my thoughts down. Maybe try again in a bit or dislike this message if the issue persists?":429===t.status?"detail"in e?s.rawResponse="".concat(e.detail):s.rawResponse="I'm a bit overwhelmed at the moment. Could you try again in a bit or dislike this message if the issue persists?":s.rawResponse="Umm, not sure what just happened. I see this error message: ".concat(a,". Could you try again or dislike this message if the issue persists?"),s.completed=!0,w([..._]),I(""),b(!1)}}return((0,i.useEffect)(()=>{fetch("/api/chat/options").then(e=>e.json()).then(e=>{c(!1),e&&s(e)}).catch(e=>{console.error(e)}),(0,h.EK)()},[]),(0,i.useEffect)(()=>{if(y){let e={rawResponse:"",trainOfThought:[],context:[],onlineContext:{},completed:!1,timestamp:new Date().toISOString(),rawQuery:y||"",images:B};w(t=>[...t,e]),b(!0)}},[y]),(0,i.useEffect)(()=>{S&&R()},[S]),o)?(0,a.jsx)(d.Z,{}):(0,a.jsxs)("div",{className:"".concat(n().main," ").concat(n().chatLayout),children:[(0,a.jsx)("title",{children:"".concat(e).concat(l&&l!==e?": ".concat(l):"")}),(0,a.jsx)("div",{children:(0,a.jsx)(r.ZP,{conversationId:p,uploadedFiles:v,isMobileWidth:k})}),(0,a.jsx)("div",{className:n().chatBox,children:(0,a.jsxs)("div",{className:n().chatBoxBody,children:[!k&&p&&(0,a.jsxs)("div",{className:"".concat(n().chatTitleWrapper," text-nowrap text-ellipsis overflow-hidden max-w-screen-md grid items-top font-bold mr-8 pt-6 col-auto h-fit"),children:[l&&(0,a.jsx)("h2",{className:"text-lg text-ellipsis whitespace-nowrap overflow-x-hidden",children:l}),(0,a.jsx)(r.En,{conversationId:p,setTitle:m,sizing:"md"})]}),(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(d.Z,{}),children:(0,a.jsx)(f,{isLoggedIn:null!==T,streamedMessages:_,chatOptionsData:t,setTitle:m,setQueryToProcess:I,setUploadedFiles:j,isMobileWidth:k,onConversationIdChange:e=>{x(e)},setImages:C})})]})})]})}},16463:function(e,t,s){"use strict";var a=s(71169);s.o(a,"useRouter")&&s.d(t,{useRouter:function(){return a.useRouter}}),s.o(a,"useSearchParams")&&s.d(t,{useSearchParams:function(){return a.useSearchParams}})},65104:function(e){e.exports={main:"chat_main__8xQu5",suggestions:"chat_suggestions__m8n2t",inputBox:"chat_inputBox__LOFws",chatBodyFull:"chat_chatBodyFull__FfKEK",chatBody:"chat_chatBody__sS1LX",chatLayout:"chat_chatLayout__pR203",chatBox:"chat_chatBox__FBct_",titleBar:"chat_titleBar__R5QlK",chatBoxBody:"chat_chatBoxBody__qT_SC",agentIndicator:"chat_agentIndicator__8V55w",chatTitleWrapper:"chat_chatTitleWrapper__6ChWq"}}},function(e){e.O(0,[7812,9848,929,3954,9001,3062,8840,7113,3110,394,1603,9417,3423,9479,2697,2971,7023,1744],function(){return e(e.s=39929)}),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6894],{71884:function(e,t,n){Promise.resolve().then(n.bind(n,69769))},18642:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var i=n(57437),a=n(90837),r=n(50495),s=n(83102),o=n(67135),l=n(34797);function c(e){var t;return(0,i.jsxs)(a.Vq,{children:[(0,i.jsx)(a.hg,{asChild:!0,onClick:e.onShare,children:(0,i.jsxs)(r.z,{size:"sm",className:"".concat(e.buttonClassName||"px-3"),variant:null!==(t=e.buttonVariant)&&void 0!==t?t:"default",children:[e.includeIcon&&(0,i.jsx)(l.m,{className:"w-4 h-4 mr-2"}),e.buttonTitle]})}),(0,i.jsxs)(a.cZ,{children:[(0,i.jsxs)(a.fK,{children:[(0,i.jsx)(a.$N,{children:e.title}),(0,i.jsx)(a.Be,{children:e.description})]}),(0,i.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,i.jsxs)("div",{className:"grid flex-1 gap-2",children:[(0,i.jsx)(o._,{htmlFor:"link",className:"sr-only",children:"Link"}),(0,i.jsx)(s.I,{id:"link",defaultValue:e.url,readOnly:!0})]}),(0,i.jsx)(r.z,{type:"submit",size:"sm",className:"px-3",onClick:()=>(function(e){let t=navigator.clipboard;t&&t.writeText(e)})(e.url),children:(0,i.jsx)("span",{children:"Copy"})})]})]})]})}},69769:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return E}});var i=n(57437),a=n(34209),r=n.n(a),s=n(79306),o=n(2265),l=n(53423),c=n(29039),d=n(6780),f=n(53907),h=n.n(f);let u=async e=>(await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}})).json(),m=e=>{let{data:t,error:n}=(0,c.ZP)(e,u);return{data:t,isLoading:!n&&!t,isError:n}},p=async e=>(await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}})).json(),x=e=>{let{data:t,error:n}=(0,c.ZP)(e,p);return{data:t,isLoading:!n&&!t,isError:n}},k=e=>{let{data:t}=m("/api/model/chat/options"),{data:n}=x("/api/model/chat"),[a,r]=o.useState(!1),l=(0,s.GW)(),c=e.setModelUsed;return((0,o.useEffect)(()=>{c&&n&&c(n)},[n,c]),t)?(0,i.jsxs)("div",{className:h().modelPicker,children:[(0,i.jsx)("select",{className:h().modelPicker,onChange:n=>{let i=Number(n.target.value),a=t.find(e=>e.id===i);a?function(t){if(!l){r(!0);return}e.setModelUsed&&e.setModelUsed(t),fetch("/api/model/chat?id="+String(t.id),{method:"POST",body:JSON.stringify(t)}).then(e=>{if(!e.ok)throw Error("Failed to select model")}).catch(e=>{console.error("Failed to select model",e)})}(a):console.error("Selected model not found",n.target.value)},disabled:e.disabled,children:null==t?void 0:t.map(t=>(0,i.jsx)("option",{value:t.id,selected:e.initialModel?t.id===e.initialModel.id:(null==n?void 0:n.id)===t.id,children:t.chat_model},t.id))}),(0,i.jsx)(d.aR,{open:a,onOpenChange:r,children:(0,i.jsxs)(d._T,{children:[(0,i.jsxs)(d.fY,{children:[(0,i.jsx)(d.f$,{children:"You must be logged in to configure your model."}),(0,i.jsxs)(d.yT,{children:["Once you create an account with Khoj, you can configure your model and use a whole suite of other features. Check out our"," ",(0,i.jsx)("a",{href:"https://docs.khoj.dev/",children:"documentation"})," to learn more."]})]}),(0,i.jsxs)(d.xo,{children:[(0,i.jsx)(d.le,{children:"Cancel"}),(0,i.jsx)(d.OL,{onClick:()=>{window.location.href=window.location.origin+"/login"},children:"Sign in"})]})]})})]}):(0,i.jsx)("div",{children:"Loading..."})};var j=n(18642),v=n(83102),b=n(50495),g=n(36013),y=n(87138),_=n(48861),C=n(69591);let w=()=>(0,i.jsx)("div",{className:r().loading,children:(0,i.jsxs)("div",{className:r().loadingVerification,children:["Researching...",(0,i.jsxs)("div",{className:r().spinner,children:[(0,i.jsx)("div",{className:"".concat(r().dot1," bg-blue-300")}),(0,i.jsx)("div",{className:"".concat(r().dot2," bg-blue-300")})]})]})});async function N(e,t,n,i,a){n(!0);let r="".concat("Limit your search to reputable sources. Search the internet for relevant supporting or refuting information. Do not reference my notes. Refuse to answer any queries that are not falsifiable by informing me that you will not answer the question. You're not permitted to ask follow-up questions, so do the best with what you have. Respond with **TRUE** or **FALSE** or **INCONCLUSIVE**, then provide your justification. Fact Check:"," ").concat(e);try{var s;let e=await fetch("".concat("/api/chat","?client=web"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({q:r,conversation_id:t,stream:!0})});if(!e.body)throw Error("No response body found");let n=null===(s=e.body)||void 0===s?void 0:s.getReader(),o=new TextDecoder,l="";for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=o.decode(t,{stream:!0});if(r.includes("### compiled references:")){let e=function(e,t){let n=e.split("### compiled references:")[1],i=e.split("### compiled references:")[0],a={};a.response=t+i;let r=JSON.parse(n);return r instanceof Array?a.context=r:"object"==typeof r&&null!==r&&(a.online=r),a}(r,l);e.response&&(l=e.response,i(e.response),a(e))}else l+=r,i(l)}}catch(e){console.error("Error verifying statement: ",e)}finally{n(!1)}}async function S(e){let t=await fetch("/api/chat/sessions?client=web",{method:"POST"});e((await t.json()).conversation_id)}function T(e){let[t,n]=(0,o.useState)(""),[a,r]=(0,o.useState)(!0),s="".concat(e.message,". Use this link for reference: ").concat(e.additionalLink),c=(0,C.IC)();return(0,o.useEffect)(()=>{e.prefilledResponse?(n(e.prefilledResponse),r(!1)):N(s,e.conversationId,r,n,()=>{})},[s,e.conversationId,e.prefilledResponse]),(0,o.useEffect)(()=>{""!==t&&(e.prefilledResponse||a||e.setChildReferencesCallback(e.additionalLink,t,e.linkTitle))},[t,a,e]),(0,i.jsxs)("div",{children:[a&&(0,i.jsx)(w,{}),(0,i.jsx)(l.Z,{chatMessage:{automationId:"",by:"AI",message:t,context:[],created:new Date().toISOString(),onlineContext:{}},isMobileWidth:c})]})}function I(e){var t,n,a;let s=e.linkTitle||(null===(a=e.onlineData)||void 0===a?void 0:null===(n=a.organic)||void 0===n?void 0:null===(t=n[0])||void 0===t?void 0:t.title)||"Reference",o={link:e.additionalLink};return(0,i.jsxs)(g.Zb,{className:"mt-2 mb-4",children:[(0,i.jsxs)(g.Ol,{children:[(0,i.jsx)("a",{className:r().titleLink,href:e.additionalLink,target:"_blank",rel:"noreferrer",children:s}),(0,i.jsx)(L,{...o})]}),(0,i.jsx)(g.aY,{children:(0,i.jsx)(T,{additionalLink:e.additionalLink,message:e.officialFactToVerify,linkTitle:s,conversationId:e.conversationId,setChildReferencesCallback:e.setChildReferencesCallback,prefilledResponse:e.prefilledResponse})})]})}let L=e=>{let t=new URL(e.link).hostname;return(0,i.jsx)("div",{className:r().subLinks,children:(0,i.jsx)("a",{className:"".concat(r().subLinks," bg-blue-200 px-2"),href:e.link,target:"_blank",rel:"noreferrer",children:t})})};function E(){let[e,t]=(0,o.useState)(""),[n,a]=(0,o.useState)(""),[c,d]=(0,o.useState)(!1),[f,h]=(0,o.useState)(""),[u,m]=(0,o.useState)(!1),[p,x]=(0,o.useState)(),[T,E]=(0,o.useState)(),[R,F]=(0,o.useState)(),O=(0,C.IC)(),[A,P]=(0,o.useState)(""),[V,M]=(0,o.useState)(""),[U,D]=(0,o.useState)(!1),[q,Z]=(0,o.useState)();function B(e,t,n){let i=T||[];i.find(t=>t.additionalLink===e)||(i.push({additionalLink:e,response:t,linkTitle:n}),E(i))}let z=(0,s.GW)();function W(){if(u)return;if(!e){alert("Please enter a fact to verify.");return}if(m(!0),!z){let e=window.location.href;window.location.href="/login?next=".concat(e)}x(void 0),h(""),S(P);let t=[...Array(16)].map(()=>Math.random().toString(36)[2]).join("");M(t),window.history.pushState({},document.title,window.location.pathname+"?runId=".concat(t)),a(e),m(!1)}(0,o.useEffect)(()=>{e?document.title="AI Fact Check: ".concat(e):document.title="AI Fact Checker"},[e]),(0,o.useEffect)(()=>{let e=localStorage.getItem("factToVerify");e&&t(e);let n=new URLSearchParams(window.location.search),i=n.get("factToVerify");i&&t(i);let r=n.get("runId");r&&(M(r),(async()=>{try{let e=await fetch("/api/chat/store/factchecker?runId=".concat(r));if(200!==e.status)throw Error("Failed to fetch stored data");let t=JSON.parse(await e.json());t&&(a(t.factToVerify),h(t.response),x(t.references),E(t.childReferences),Z(t.modelUsed)),D(!0)}catch(e){console.error("Error fetching stored data: ",e)}})())},[]),(0,o.useEffect)(()=>{A&&N(n,A,d,h,x)},[A,n]),(0,o.useEffect)(()=>{localStorage.setItem("factToVerify",e)},[e]),(0,o.useEffect)(()=>{let e=document.querySelector('meta[name="description"]');e&&e.setAttribute("content",f);let t=document.querySelector('meta[property="og:description"]');t||((t=document.createElement("meta")).setAttribute("property","og:description"),document.getElementsByTagName("head")[0].appendChild(t)),t.setAttribute("content",f)},[f]);let J=e=>e.map((e,t)=>(0,i.jsx)(I,{additionalLink:e.additionalLink,officialFactToVerify:n,conversationId:A,linkTitle:e.linkTitle,setChildReferencesCallback:B,prefilledResponse:e.response},t)),Y=e=>e instanceof Array?e.map((e,t)=>L(e)):L(e);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"relative md:fixed h-full",children:(0,i.jsx)(_.ZP,{conversationId:null,uploadedFiles:[],isMobileWidth:O})}),(0,i.jsxs)("div",{className:r().factCheckerContainer,children:[(0,i.jsx)("h1",{className:"".concat(r().response," pt-8 md:pt-4 font-large outline-slate-800 dark:outline-slate-200"),children:"AI Fact Checker"}),(0,i.jsx)("footer",{className:"".concat(r().footer," mt-4"),children:"This is an experimental AI tool. It may make mistakes."}),f&&p&&T?(0,i.jsxs)("div",{className:r().reportActions,children:[(0,i.jsx)(b.z,{asChild:!0,variant:"secondary",children:(0,i.jsx)(y.default,{href:"/factchecker",target:"_blank",rel:"noopener noreferrer",children:"Try Another"})}),(0,i.jsx)(j.Z,{buttonTitle:"Share report",title:"AI Fact Checking Report",description:"Share this fact checking report with others. Anyone who has this link will be able to view the report.",url:function(){let e=new URL(window.location.href);return e.searchParams.set("runId",V),e.href}(),onShare:U?()=>{}:function(){fetch("/api/chat/store/factchecker",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runId:V,storeData:{factToVerify:e,response:f,references:p,childReferences:T,runId:V,modelUsed:R}})})}})]}):(0,i.jsxs)("div",{className:r().newReportActions,children:[(0,i.jsxs)("div",{className:"".concat(r().inputFields," mt-4"),children:[(0,i.jsx)(v.I,{type:"text",maxLength:200,placeholder:"Enter a falsifiable statement to verify",disabled:c,onChange:e=>t(e.target.value),value:e,onKeyDown:e=>{"Enter"===e.key&&W()},onFocus:e=>e.target.placeholder="",onBlur:e=>e.target.placeholder="Enter a falsifiable statement to verify"}),(0,i.jsx)(b.z,{disabled:u,onClick:()=>W(),children:"Verify"})]}),(0,i.jsxs)("h3",{className:"mt-4 mb-4",children:["Try with a particular model. You must be"," ",(0,i.jsx)("a",{href:"/settings",className:"font-medium text-blue-600 dark:text-blue-500 hover:underline",children:"subscribed"})," ","to configure the model."]})]}),(0,i.jsx)(k,{disabled:c||U,setModelUsed:F,initialModel:q}),c&&(0,i.jsx)("div",{className:r().loading,children:(0,i.jsx)(w,{})}),f&&(0,i.jsxs)(g.Zb,{className:"mt-4",children:[(0,i.jsx)(g.Ol,{children:(0,i.jsx)(g.ll,{children:n})}),(0,i.jsx)(g.aY,{children:(0,i.jsx)("div",{className:r().responseText,children:(0,i.jsx)(l.Z,{chatMessage:{automationId:"",by:"AI",message:f,context:[],created:new Date().toISOString(),onlineContext:{}},isMobileWidth:O})})}),(0,i.jsx)(g.eW,{children:p&&p.online&&Object.keys(p.online).length>0&&(0,i.jsx)("div",{className:r().subLinks,children:Object.entries(p.online).map((e,t)=>{let[n,i]=e;return Y((null==i?void 0:i.webpages)||[])})})})]}),p&&(0,i.jsxs)("div",{className:r().referenceContainer,children:[(0,i.jsx)("h2",{className:"mt-4 mb-4",children:"Supplements"}),(0,i.jsx)("div",{className:r().references,children:void 0!==p.online&&((e,t,n,a,r)=>{if(a&&r)return J(r);let s=new Set;return Object.entries(t.online||{}).map((e,t)=>{let[n,i]=e,a=(null==i?void 0:i.webpages)||[];if(a instanceof Array)for(let e=0;e<a.length;e++){let t=a[e].link||"";if(s.has(t))return null;s.add(t)}else{let e=a.link||"";if(s.has(e))return null;s.add(e)}}),Object.entries(t.online||{}).map((t,a)=>{var r,o;let[l,c]=t,d="";for(let e=0;e<(null==c?void 0:null===(r=c.organic)||void 0===r?void 0:r.length)&&(d=(null==c?void 0:null===(o=c.organic)||void 0===o?void 0:o[e]).link||"",s.has(d));e++);return(s.add(d),""===d)?null:(0,i.jsx)(I,{onlineData:c,officialFactToVerify:n,conversationId:e,additionalLink:d,setChildReferencesCallback:B},a)}).filter(Boolean)})(A,p,n,U,T)})]})]})]})}},67135:function(e,t,n){"use strict";n.d(t,{_:function(){return c}});var i=n(57437),a=n(2265),r=n(38364),s=n(12218),o=n(37440);let l=(0,s.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=a.forwardRef((e,t)=>{let{className:n,...a}=e;return(0,i.jsx)(r.f,{ref:t,className:(0,o.cn)(l(),n),...a})});c.displayName=r.f.displayName},53907:function(e){e.exports={modelPicker:"modelPicker_modelPicker__chlCh"}},34209:function(e){e.exports={factVerification:"factChecker_factVerification__UCbIf",factCheckerContainer:"factChecker_factCheckerContainer__Brqjv",responseText:"factChecker_responseText__HzSck",response:"factChecker_response__HaFuc",titleLink:"factChecker_titleLink__FA5mt",subLinks:"factChecker_subLinks__iaFHn",reference:"factChecker_reference___6Fwh",footer:"factChecker_footer__Tbj3t",reportActions:"factChecker_reportActions__2_tFq",factCheckButton:"factChecker_factCheckButton__2XPTv",spinner:"factChecker_spinner__T26Jv","sk-rotate":"factChecker_sk-rotate__ogES_",inputFields:"factChecker_inputFields__LU3cQ",dot1:"factChecker_dot1__n9Bu5",dot2:"factChecker_dot2__HDdBs","sk-bounce":"factChecker_sk-bounce__q4XFt"}},38364:function(e,t,n){"use strict";n.d(t,{f:function(){return o}});var i=n(2265),a=n(25171),r=n(57437),s=i.forwardRef((e,t)=>(0,r.jsx)(a.WV.label,{...e,ref:t,onMouseDown:t=>{var n;t.target.closest("button, input, select, textarea")||(null===(n=e.onMouseDown)||void 0===n||n.call(e,t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));s.displayName="Label";var o=s}},function(e){e.O(0,[6129,9848,929,3954,9001,3062,8840,7113,394,1603,9417,3423,2971,7023,1744],function(){return e(e.s=71884)}),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- div.automations_automationsLayout__Atoh_{display:grid;grid-template-columns:1fr 1fr;gap:1rem}div.automations_automationCard__BKidA{display:grid;grid-template-rows:auto 1fr auto}div.automations_pageLayout__OaoYA{max-width:60vw;margin:auto auto 2rem}div.automations_sidePanel__MPciO{position:fixed;height:100%;z-index:1}@media screen and (max-width:768px){div.automations_automationsLayout__Atoh_{grid-template-columns:1fr}div.automations_pageLayout__OaoYA{max-width:90vw}div.automations_sidePanel__MPciO{position:relative;height:100%}}