khoj 1.24.2.dev19__py3-none-any.whl → 1.24.2.dev34__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.
- khoj/database/adapters/__init__.py +27 -15
- khoj/interface/compiled/404/index.html +1 -1
- khoj/interface/compiled/_next/static/chunks/app/agents/page-1b494bb54aca52de.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/automations/{page-5480731341f34450.js → page-1688dead2f21270d.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/chat/{page-702057ccbcf27881.js → page-91abcb71846922b7.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/factchecker/{page-e7b34316ec6f44de.js → page-7ab093711c27041c.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/{page-421d13f70c505dd9.js → page-fada198096eab47f.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/search/{page-d56541c746fded7d.js → page-a7e036689b6507ff.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/settings/{page-e044a999468a7c5d.js → page-fa11cafaec7ab39f.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/share/chat/{page-fbbd66a4d4633438.js → page-c5d2b9076e5390b2.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/{webpack-c4376b110507dd22.js → webpack-f52083d548d804fa.js} +1 -1
- khoj/interface/compiled/_next/static/css/4cae6c0e5c72fb2d.css +1 -0
- khoj/interface/compiled/_next/static/css/dfb67a9287720a2b.css +1 -0
- khoj/interface/compiled/agents/index.html +1 -1
- khoj/interface/compiled/agents/index.txt +2 -2
- khoj/interface/compiled/automations/index.html +1 -1
- khoj/interface/compiled/automations/index.txt +2 -2
- khoj/interface/compiled/chat/index.html +1 -1
- khoj/interface/compiled/chat/index.txt +2 -2
- khoj/interface/compiled/factchecker/index.html +1 -1
- khoj/interface/compiled/factchecker/index.txt +2 -2
- khoj/interface/compiled/index.html +1 -1
- khoj/interface/compiled/index.txt +2 -2
- khoj/interface/compiled/search/index.html +1 -1
- khoj/interface/compiled/search/index.txt +2 -2
- khoj/interface/compiled/settings/index.html +1 -1
- khoj/interface/compiled/settings/index.txt +2 -2
- khoj/interface/compiled/share/chat/index.html +1 -1
- khoj/interface/compiled/share/chat/index.txt +2 -2
- khoj/processor/conversation/google/gemini_chat.py +4 -19
- khoj/processor/conversation/google/utils.py +29 -15
- khoj/processor/conversation/prompts.py +14 -3
- khoj/processor/conversation/utils.py +3 -7
- khoj/processor/embeddings.py +5 -3
- khoj/routers/api_chat.py +33 -18
- khoj/routers/helpers.py +11 -3
- khoj/utils/helpers.py +8 -8
- {khoj-1.24.2.dev19.dist-info → khoj-1.24.2.dev34.dist-info}/METADATA +1 -1
- {khoj-1.24.2.dev19.dist-info → khoj-1.24.2.dev34.dist-info}/RECORD +47 -47
- khoj/interface/compiled/_next/static/chunks/app/agents/page-4005bd96041d20f5.js +0 -1
- khoj/interface/compiled/_next/static/css/2de69f0be774c768.css +0 -1
- khoj/interface/compiled/_next/static/css/3e1f1fdd70775091.css +0 -1
- /khoj/interface/compiled/_next/static/{-g-BSlwy2eTVtQIJDFFXi → Be65WE5esb8ZOxD33psmy}/_buildManifest.js +0 -0
- /khoj/interface/compiled/_next/static/{-g-BSlwy2eTVtQIJDFFXi → Be65WE5esb8ZOxD33psmy}/_ssgManifest.js +0 -0
- /khoj/interface/compiled/_next/static/chunks/{9178-f208a3e6404714a9.js → 9178-899fe9a6b754ecfe.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{9417-1d158bf46d3a0dc9.js → 9417-29502e39c3e7d60c.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{9479-563e4d61f91d5a7c.js → 9479-7eed36fc954ef804.js} +0 -0
- {khoj-1.24.2.dev19.dist-info → khoj-1.24.2.dev34.dist-info}/WHEEL +0 -0
- {khoj-1.24.2.dev19.dist-info → khoj-1.24.2.dev34.dist-info}/entry_points.txt +0 -0
- {khoj-1.24.2.dev19.dist-info → khoj-1.24.2.dev34.dist-info}/licenses/LICENSE +0 -0
@@ -556,14 +556,18 @@ class AgentAdapters:
|
|
556
556
|
|
557
557
|
@staticmethod
|
558
558
|
async def aget_readonly_agent_by_slug(agent_slug: str, user: KhojUser):
|
559
|
-
return
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
559
|
+
return (
|
560
|
+
await Agent.objects.filter(
|
561
|
+
(Q(slug__iexact=agent_slug.lower()))
|
562
|
+
& (
|
563
|
+
Q(privacy_level=Agent.PrivacyLevel.PUBLIC)
|
564
|
+
| Q(privacy_level=Agent.PrivacyLevel.PROTECTED)
|
565
|
+
| Q(creator=user)
|
566
|
+
)
|
565
567
|
)
|
566
|
-
|
568
|
+
.prefetch_related("creator", "chat_model", "fileobject_set")
|
569
|
+
.afirst()
|
570
|
+
)
|
567
571
|
|
568
572
|
@staticmethod
|
569
573
|
async def adelete_agent_by_slug(agent_slug: str, user: KhojUser):
|
@@ -579,15 +583,23 @@ class AgentAdapters:
|
|
579
583
|
|
580
584
|
@staticmethod
|
581
585
|
async def aget_agent_by_slug(agent_slug: str, user: KhojUser):
|
582
|
-
return
|
583
|
-
|
584
|
-
|
586
|
+
return (
|
587
|
+
await Agent.objects.filter(
|
588
|
+
(Q(slug__iexact=agent_slug.lower())) & (Q(privacy_level=Agent.PrivacyLevel.PUBLIC) | Q(creator=user))
|
589
|
+
)
|
590
|
+
.prefetch_related("creator", "chat_model", "fileobject_set")
|
591
|
+
.afirst()
|
592
|
+
)
|
585
593
|
|
586
594
|
@staticmethod
|
587
595
|
async def aget_agent_by_name(agent_name: str, user: KhojUser):
|
588
|
-
return
|
589
|
-
|
590
|
-
|
596
|
+
return (
|
597
|
+
await Agent.objects.filter(
|
598
|
+
(Q(name__iexact=agent_name.lower())) & (Q(privacy_level=Agent.PrivacyLevel.PUBLIC) | Q(creator=user))
|
599
|
+
)
|
600
|
+
.prefetch_related("creator", "chat_model", "fileobject_set")
|
601
|
+
.afirst()
|
602
|
+
)
|
591
603
|
|
592
604
|
@staticmethod
|
593
605
|
def get_agent_by_slug(slug: str, user: KhojUser = None):
|
@@ -814,7 +826,7 @@ class ConversationAdapters:
|
|
814
826
|
user: KhojUser, client_application: ClientApplication = None, agent_slug: str = None, title: str = None
|
815
827
|
):
|
816
828
|
if agent_slug:
|
817
|
-
agent = await AgentAdapters.
|
829
|
+
agent = await AgentAdapters.aget_readonly_agent_by_slug(agent_slug, user)
|
818
830
|
if agent is None:
|
819
831
|
raise HTTPException(status_code=400, detail="No such agent currently exists.")
|
820
832
|
return await Conversation.objects.acreate(user=user, client=client_application, agent=agent, title=title)
|
@@ -826,7 +838,7 @@ class ConversationAdapters:
|
|
826
838
|
user: KhojUser, client_application: ClientApplication = None, agent_slug: str = None, title: str = None
|
827
839
|
):
|
828
840
|
if agent_slug:
|
829
|
-
agent = AgentAdapters.
|
841
|
+
agent = AgentAdapters.aget_readonly_agent_by_slug(agent_slug, user)
|
830
842
|
if agent is None:
|
831
843
|
raise HTTPException(status_code=400, detail="No such agent currently exists.")
|
832
844
|
return Conversation.objects.create(user=user, client=client_application, agent=agent, title=title)
|
@@ -1 +1 @@
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" href="/_next/static/media/0e790e04fd40ad16-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="stylesheet" href="/_next/static/css/1538cedb321e3a97.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/7a2b0a2d7c3d86eb.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-c4376b110507dd22.js"/><script src="/_next/static/chunks/fd9d1056-2b978342deb60015.js" async=""></script><script src="/_next/static/chunks/7023-a5bf5744d19b3bd3.js" async=""></script><script src="/_next/static/chunks/main-app-6d6ee3495efe03d4.js" async=""></script><meta name="robots" content="noindex"/><meta http-equiv="Content-Security-Policy" content="default-src 'self' https://assets.khoj.dev; media-src * blob:; script-src 'self' https://assets.khoj.dev 'unsafe-inline' 'unsafe-eval'; connect-src 'self' blob: https://ipapi.co/json ws://localhost:42110; style-src 'self' https://assets.khoj.dev 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: blob: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src 'self' https://assets.khoj.dev https://fonts.gstatic.com; child-src 'none'; object-src 'none';"/><title>404: This page could not be found.</title><title>Khoj AI - Home</title><meta name="description" content="Your Second Brain."/><link rel="manifest" href="/static/khoj.webmanifest" crossorigin="use-credentials"/><meta property="og:title" content="Khoj AI - Home"/><meta property="og:description" content="Your Second Brain."/><meta property="og:url" content="https://app.khoj.dev/"/><meta property="og:site_name" content="Khoj AI"/><meta property="og:image" content="https://assets.khoj.dev/khoj_lantern_256x256.png"/><meta property="og:image:width" content="256"/><meta property="og:image:height" content="256"/><meta property="og:image" content="https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png"/><meta property="og:image:width" content="1200"/><meta property="og:image:height" content="630"/><meta property="og:type" content="website"/><meta name="twitter:card" content="summary_large_image"/><meta name="twitter:title" content="Khoj AI - Home"/><meta name="twitter:description" content="Your Second Brain."/><meta name="twitter:image" content="https://assets.khoj.dev/khoj_lantern_256x256.png"/><meta name="twitter:image:width" content="256"/><meta name="twitter:image:height" content="256"/><meta name="twitter:image" content="https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png"/><meta name="twitter:image:width" content="1200"/><meta name="twitter:image:height" content="630"/><link rel="icon" href="/static/assets/icons/khoj_lantern.ico"/><link rel="apple-touch-icon" href="/static/assets/icons/khoj_lantern_256x256.png"/><meta name="next-size-adjust"/><script src="/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js" noModule=""></script></head><body class="__className_90df87"><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><script src="/_next/static/chunks/webpack-c4376b110507dd22.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/media/0e790e04fd40ad16-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n2:HL[\"/_next/static/css/1538cedb321e3a97.css\",\"style\"]\n3:HL[\"/_next/static/css/7a2b0a2d7c3d86eb.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"4:I[95751,[],\"\"]\n6:I[39275,[],\"\"]\n7:I[61343,[],\"\"]\nd:I[76130,[],\"\"]\n8:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n9:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\na:{\"display\":\"inline-block\"}\nb:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\ne:[]\n"])</script><script>self.__next_f.push([1,"0:[\"$\",\"$L4\",null,{\"buildId\":\"-g-BSlwy2eTVtQIJDFFXi\",\"assetPrefix\":\"\",\"urlParts\":[\"\",\"_not-found\",\"\"],\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L5\",[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null],null],null]},[null,[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/1538cedb321e3a97.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/7a2b0a2d7c3d86eb.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[[\"$\",\"meta\",null,{\"httpEquiv\":\"Content-Security-Policy\",\"content\":\"default-src 'self' https://assets.khoj.dev; media-src * blob:; script-src 'self' https://assets.khoj.dev 'unsafe-inline' 'unsafe-eval'; connect-src 'self' blob: https://ipapi.co/json ws://localhost:42110; style-src 'self' https://assets.khoj.dev 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: blob: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src 'self' https://assets.khoj.dev https://fonts.gstatic.com; child-src 'none'; object-src 'none';\"}],[\"$\",\"body\",null,{\"className\":\"__className_90df87\",\"children\":[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$8\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$9\",\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":\"$a\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$b\",\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}]}]]}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],\"$Lc\"],\"globalErrorComponent\":\"$d\",\"missingSlots\":\"$We\"}]\n"])</script><script>self.__next_f.push([1,"c:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"2\",{\"children\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"3\",{\"name\":\"description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"link\",\"4\",{\"rel\":\"manifest\",\"href\":\"/static/khoj.webmanifest\",\"crossOrigin\":\"use-credentials\"}],[\"$\",\"meta\",\"5\",{\"property\":\"og:title\",\"content\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"6\",{\"property\":\"og:description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"meta\",\"7\",{\"property\":\"og:url\",\"content\":\"https://app.khoj.dev/\"}],[\"$\",\"meta\",\"8\",{\"property\":\"og:site_name\",\"content\":\"Khoj AI\"}],[\"$\",\"meta\",\"9\",{\"property\":\"og:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"10\",{\"property\":\"og:image:width\",\"content\":\"256\"}],[\"$\",\"meta\",\"11\",{\"property\":\"og:image:height\",\"content\":\"256\"}],[\"$\",\"meta\",\"12\",{\"property\":\"og:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png\"}],[\"$\",\"meta\",\"13\",{\"property\":\"og:image:width\",\"content\":\"1200\"}],[\"$\",\"meta\",\"14\",{\"property\":\"og:image:height\",\"content\":\"630\"}],[\"$\",\"meta\",\"15\",{\"property\":\"og:type\",\"content\":\"website\"}],[\"$\",\"meta\",\"16\",{\"name\":\"twitter:card\",\"content\":\"summary_large_image\"}],[\"$\",\"meta\",\"17\",{\"name\":\"twitter:title\",\"content\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"18\",{\"name\":\"twitter:description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"meta\",\"19\",{\"name\":\"twitter:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"20\",{\"name\":\"twitter:image:width\",\"content\":\"256\"}],[\"$\",\"meta\",\"21\",{\"name\":\"twitter:image:height\",\"content\":\"256\"}],[\"$\",\"meta\",\"22\",{\"name\":\"twitter:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png\"}],[\"$\",\"meta\",\"23\",{\"name\":\"twitter:image:width\",\"content\":\"1200\"}],[\"$\",\"meta\",\"24\",{\"name\":\"twitter:image:height\",\"content\":\"630\"}],[\"$\",\"link\",\"25\",{\"rel\":\"icon\",\"href\":\"/static/assets/icons/khoj_lantern.ico\"}],[\"$\",\"link\",\"26\",{\"rel\":\"apple-touch-icon\",\"href\":\"/static/assets/icons/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"27\",{\"name\":\"next-size-adjust\"}]]\n"])</script><script>self.__next_f.push([1,"5:null\n"])</script></body></html>
|
1
|
+
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" href="/_next/static/media/0e790e04fd40ad16-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="stylesheet" href="/_next/static/css/1538cedb321e3a97.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/7a2b0a2d7c3d86eb.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-f52083d548d804fa.js"/><script src="/_next/static/chunks/fd9d1056-2b978342deb60015.js" async=""></script><script src="/_next/static/chunks/7023-a5bf5744d19b3bd3.js" async=""></script><script src="/_next/static/chunks/main-app-6d6ee3495efe03d4.js" async=""></script><meta name="robots" content="noindex"/><meta http-equiv="Content-Security-Policy" content="default-src 'self' https://assets.khoj.dev; media-src * blob:; script-src 'self' https://assets.khoj.dev 'unsafe-inline' 'unsafe-eval'; connect-src 'self' blob: https://ipapi.co/json ws://localhost:42110; style-src 'self' https://assets.khoj.dev 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: blob: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src 'self' https://assets.khoj.dev https://fonts.gstatic.com; child-src 'none'; object-src 'none';"/><title>404: This page could not be found.</title><title>Khoj AI - Home</title><meta name="description" content="Your Second Brain."/><link rel="manifest" href="/static/khoj.webmanifest" crossorigin="use-credentials"/><meta property="og:title" content="Khoj AI - Home"/><meta property="og:description" content="Your Second Brain."/><meta property="og:url" content="https://app.khoj.dev/"/><meta property="og:site_name" content="Khoj AI"/><meta property="og:image" content="https://assets.khoj.dev/khoj_lantern_256x256.png"/><meta property="og:image:width" content="256"/><meta property="og:image:height" content="256"/><meta property="og:image" content="https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png"/><meta property="og:image:width" content="1200"/><meta property="og:image:height" content="630"/><meta property="og:type" content="website"/><meta name="twitter:card" content="summary_large_image"/><meta name="twitter:title" content="Khoj AI - Home"/><meta name="twitter:description" content="Your Second Brain."/><meta name="twitter:image" content="https://assets.khoj.dev/khoj_lantern_256x256.png"/><meta name="twitter:image:width" content="256"/><meta name="twitter:image:height" content="256"/><meta name="twitter:image" content="https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png"/><meta name="twitter:image:width" content="1200"/><meta name="twitter:image:height" content="630"/><link rel="icon" href="/static/assets/icons/khoj_lantern.ico"/><link rel="apple-touch-icon" href="/static/assets/icons/khoj_lantern_256x256.png"/><meta name="next-size-adjust"/><script src="/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js" noModule=""></script></head><body class="__className_90df87"><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><script src="/_next/static/chunks/webpack-f52083d548d804fa.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/media/0e790e04fd40ad16-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n2:HL[\"/_next/static/css/1538cedb321e3a97.css\",\"style\"]\n3:HL[\"/_next/static/css/7a2b0a2d7c3d86eb.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"4:I[95751,[],\"\"]\n6:I[39275,[],\"\"]\n7:I[61343,[],\"\"]\nd:I[76130,[],\"\"]\n8:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n9:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\na:{\"display\":\"inline-block\"}\nb:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\ne:[]\n"])</script><script>self.__next_f.push([1,"0:[\"$\",\"$L4\",null,{\"buildId\":\"Be65WE5esb8ZOxD33psmy\",\"assetPrefix\":\"\",\"urlParts\":[\"\",\"_not-found\",\"\"],\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L5\",[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null],null],null]},[null,[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/1538cedb321e3a97.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/7a2b0a2d7c3d86eb.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[[\"$\",\"meta\",null,{\"httpEquiv\":\"Content-Security-Policy\",\"content\":\"default-src 'self' https://assets.khoj.dev; media-src * blob:; script-src 'self' https://assets.khoj.dev 'unsafe-inline' 'unsafe-eval'; connect-src 'self' blob: https://ipapi.co/json ws://localhost:42110; style-src 'self' https://assets.khoj.dev 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: blob: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src 'self' https://assets.khoj.dev https://fonts.gstatic.com; child-src 'none'; object-src 'none';\"}],[\"$\",\"body\",null,{\"className\":\"__className_90df87\",\"children\":[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$8\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$9\",\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":\"$a\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$b\",\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}]}]]}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],\"$Lc\"],\"globalErrorComponent\":\"$d\",\"missingSlots\":\"$We\"}]\n"])</script><script>self.__next_f.push([1,"c:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"2\",{\"children\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"3\",{\"name\":\"description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"link\",\"4\",{\"rel\":\"manifest\",\"href\":\"/static/khoj.webmanifest\",\"crossOrigin\":\"use-credentials\"}],[\"$\",\"meta\",\"5\",{\"property\":\"og:title\",\"content\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"6\",{\"property\":\"og:description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"meta\",\"7\",{\"property\":\"og:url\",\"content\":\"https://app.khoj.dev/\"}],[\"$\",\"meta\",\"8\",{\"property\":\"og:site_name\",\"content\":\"Khoj AI\"}],[\"$\",\"meta\",\"9\",{\"property\":\"og:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"10\",{\"property\":\"og:image:width\",\"content\":\"256\"}],[\"$\",\"meta\",\"11\",{\"property\":\"og:image:height\",\"content\":\"256\"}],[\"$\",\"meta\",\"12\",{\"property\":\"og:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png\"}],[\"$\",\"meta\",\"13\",{\"property\":\"og:image:width\",\"content\":\"1200\"}],[\"$\",\"meta\",\"14\",{\"property\":\"og:image:height\",\"content\":\"630\"}],[\"$\",\"meta\",\"15\",{\"property\":\"og:type\",\"content\":\"website\"}],[\"$\",\"meta\",\"16\",{\"name\":\"twitter:card\",\"content\":\"summary_large_image\"}],[\"$\",\"meta\",\"17\",{\"name\":\"twitter:title\",\"content\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"18\",{\"name\":\"twitter:description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"meta\",\"19\",{\"name\":\"twitter:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"20\",{\"name\":\"twitter:image:width\",\"content\":\"256\"}],[\"$\",\"meta\",\"21\",{\"name\":\"twitter:image:height\",\"content\":\"256\"}],[\"$\",\"meta\",\"22\",{\"name\":\"twitter:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png\"}],[\"$\",\"meta\",\"23\",{\"name\":\"twitter:image:width\",\"content\":\"1200\"}],[\"$\",\"meta\",\"24\",{\"name\":\"twitter:image:height\",\"content\":\"630\"}],[\"$\",\"link\",\"25\",{\"rel\":\"icon\",\"href\":\"/static/assets/icons/khoj_lantern.ico\"}],[\"$\",\"link\",\"26\",{\"rel\":\"apple-touch-icon\",\"href\":\"/static/assets/icons/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"27\",{\"name\":\"next-size-adjust\"}]]\n"])</script><script>self.__next_f.push([1,"5:null\n"])</script></body></html>
|
@@ -0,0 +1 @@
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9718],{1813:function(e,t,s){Promise.resolve().then(s.bind(s,45050))},45050:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return eh}});var a=s(57437),n=s(15283),l=s.n(n),r=s(29039),i=s(2265),o=s(79306),c=s(50495),d=s(58284),u=s(5989),h=s(12275),m=s(18444),x=s(31784),f=s(20319),p=s(98750),g=s(55362),j=s(57691),v=s(68029),b=s(68131),N=s(83632),w=s(9950),y=s(35418),_=s(84120),C=s(15780),k=s(26058),O=s(64945),S=s(59772),z=s(36013),T=s(90837),I=s(7951),P=s(66820),R=s(58485),M=s(48861),V=s(89417),A=s(58575),E=s(47412),Z=s(69591),q=s(32653),B=s(39343),F=s(83102),W=s(31014),L=s(93146),D=s(46294),J=s(13304),X=s(40882);let Y=X.fC,G=X.wy,U=X.Fw;var K=s(37440),Q=s(42491),$=s(9557),H=s(6780),ee=s(70571),et=s(19573),es=s(18642),ea=s(19666);async function en(e,t){let s="/login?next=/agents?agent=".concat(e);if(!t){window.location.href=s;return}let a=await fetch("/api/chat/sessions?agent_slug=".concat(encodeURIComponent(e)),{method:"POST"}),n=await a.json();200==a.status?window.location.href="/chat?conversationId=".concat(n.conversation_id):403==a.status||401==a.status?window.location.href=s:alert("Failed to start chat session")}function el(e){var t;let s=(null===(t=e.text)||void 0===t?void 0:t.replace(/^\w/,e=>e.toUpperCase()))||"";return(0,a.jsx)(ea.pn,{children:(0,a.jsxs)(ea.u,{children:[(0,a.jsx)(ea._v,{asChild:!0,children:(0,a.jsx)("div",{className:"text-sm",children:e.hoverText||s})}),(0,a.jsx)(ea.aJ,{className:"cursor-text",children:(0,a.jsxs)("div",{className:"flex items-center space-x-2 rounded-full border-accent-500 border p-1.5",children:[(0,a.jsx)("div",{className:"text-muted-foreground",children:e.icon}),s&&s.length>0&&(0,a.jsx)("div",{className:"text-muted-foreground text-sm",children:s})]})})]})})}let er=()=>window.fetch("/api/agents").then(e=>e.json()).catch(e=>console.log(e)),ei=e=>fetch(e).then(e=>e.json());function eo(e){let[t,s]=(0,i.useState)(e.agentSlug===e.data.slug),[n,r]=(0,i.useState)(!1),[o,v]=(0,i.useState)(null),b=(0,a.jsx)(d.H,{}),N="Private agents are only visible to you.";"public"===e.data.privacy_level?(b=(0,a.jsx)(u.T,{}),N="Public agents are visible to everyone."):"protected"===e.data.privacy_level&&(b=(0,a.jsx)(h.M,{}),N="Protected agents are visible to anyone with a direct link.");let w=e.userProfile,y=(0,B.cI)({resolver:(0,W.F)(ec),defaultValues:{name:e.data.name,persona:e.data.persona,color:e.data.color,icon:e.data.icon,privacy_level:e.data.privacy_level,chat_model:e.data.chat_model,files:e.data.files,input_tools:e.data.input_tools,output_modes:e.data.output_modes}});(0,i.useEffect)(()=>{y.reset({name:e.data.name,persona:e.data.persona,color:e.data.color,icon:e.data.icon,privacy_level:e.data.privacy_level,chat_model:e.data.chat_model,files:e.data.files,input_tools:e.data.input_tools,output_modes:e.data.output_modes})},[e.data]),t&&window.history.pushState({},"Khoj AI - Agent ".concat(e.data.slug),"/agents?agent=".concat(e.data.slug));let _=t=>{fetch("/api/agents",{method:e.editCard?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(t=>{200===t.status?(y.reset(),s(!1),v(null),e.setAgentChangeTriggered(!0)):t.json().then(e=>{console.error(e),y.clearErrors(),e.error&&v(e.error)})}).catch(e=>{console.error("Error:",e),v(e),y.clearErrors()})},C=(0,A.oz)(e.data.color);function k(){return(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[e.editCard&&(0,a.jsx)(el,{icon:b,text:e.data.privacy_level,hoverText:N}),e.data.files&&e.data.files.length>0&&(0,a.jsx)(el,{icon:(0,a.jsx)(m.f,{}),text:"knowledge",hoverText:"The agent has a custom knowledge base with ".concat(e.data.files.length," documents. It can use them to give you answers.")}),(0,a.jsx)(el,{icon:(0,a.jsx)(x.a,{}),text:e.data.chat_model,hoverText:"The agent uses the ".concat(e.data.chat_model," model to chat with you.")}),e.data.output_modes.map(t=>(0,a.jsx)(el,{icon:(0,V.vH)(t),hoverText:"".concat(t,": ").concat(e.outputModeOptions[t])},t)),e.data.input_tools.map(t=>(0,a.jsx)(el,{icon:(0,V.vH)(t),hoverText:"".concat(t,": ").concat(e.inputToolOptions[t])},t))]})}return(0,a.jsxs)(z.Zb,{className:"shadow-sm bg-gradient-to-b from-white 20% to-".concat(e.data.color?e.data.color:"gray","-100/50 dark:from-[hsl(var(--background))] dark:to-").concat(e.data.color?e.data.color:"gray","-950/50 rounded-xl hover:shadow-md"),children:[n&&(0,a.jsx)(P.Z,{loginRedirectMessage:"Sign in to start chatting with ".concat(e.data.name),onOpenChange:r}),(0,a.jsx)(z.Ol,{children:(0,a.jsx)(z.ll,{children:e.isMobileWidth?(0,a.jsxs)(I.dy,{open:t,onOpenChange:e=>{s(e),window.history.pushState({},"Khoj AI - Agents","/agents")},children:[(0,a.jsx)(I.Qz,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,V.TI)(e.data.icon,e.data.color),e.data.name]})}),(0,a.jsxs)("div",{className:"flex float-right",children:[e.editCard&&(0,a.jsx)("div",{className:"float-right",children:(0,a.jsxs)(et.J2,{children:[(0,a.jsx)(et.xo,{children:(0,a.jsx)(c.z,{className:"bg-[hsl(var(--background))] w-10 h-10 p-0 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100 dark:hover:bg-neutral-900",children:(0,a.jsx)(f.F,{className:"w-6 h-6 ".concat((0,A.oz)(e.data.color))})})}),(0,a.jsxs)(et.yk,{className:"w-fit grid p-1",side:"bottom",align:"end",children:[(0,a.jsxs)(c.z,{className:"items-center justify-start",variant:"ghost",onClick:()=>s(!0),children:[(0,a.jsx)(p.z,{className:"w-4 h-4 mr-2"}),"Edit"]}),e.editCard&&"private"!==e.data.privacy_level&&(0,a.jsx)(es.Z,{buttonTitle:"Share",title:"Share Agent",description:"Share a link to this agent with others. They'll be able to chat with it, and ask questions to all of its knowledge base.",buttonVariant:"ghost",includeIcon:!0,url:"".concat(window.location.origin,"/agents?agent=").concat(e.data.slug)}),e.data.creator===(null==w?void 0:w.username)&&(0,a.jsxs)(c.z,{className:"items-center justify-start",variant:"destructive",onClick:()=>{fetch("/api/agents/".concat(e.data.slug),{method:"DELETE"}).then(()=>{e.setAgentChangeTriggered(!0)})},children:[(0,a.jsx)(g.r,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]})}),(0,a.jsx)("div",{className:"float-right",children:e.userProfile?(0,a.jsx)(c.z,{className:"bg-[hsl(var(--background))] w-10 h-10 p-0 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100 dark:hover:bg-neutral-900",onClick:()=>en(e.data.slug,w),children:(0,a.jsx)(j.g,{className:"w-6 h-6 ".concat((0,A.oz)(e.data.color))})}):(0,a.jsx)(c.z,{className:"bg-[hsl(var(--background))] w-14 h-14 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100 dark:hover:bg-neutral-900",onClick:()=>r(!0),children:(0,a.jsx)(j.g,{className:"w-6 h-6 ".concat((0,A.oz)(e.data.color))})})})]}),e.editCard?(0,a.jsx)(I.sc,{className:"whitespace-pre-line p-2",children:(0,a.jsx)(ed,{form:y,onSubmit:_,create:!1,errors:o,filesOptions:e.filesOptions,modelOptions:e.modelOptions,slug:e.data.slug,inputToolOptions:e.inputToolOptions,outputModeOptions:e.outputModeOptions,isSubscribed:e.isSubscribed})}):(0,a.jsxs)(I.sc,{className:"whitespace-pre-line p-2",children:[(0,a.jsxs)(I.OX,{children:[(0,a.jsx)(I.iI,{children:e.data.name}),(0,a.jsx)(I.u6,{children:"Persona"})]}),e.data.persona,(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-1",children:k()}),(0,a.jsx)(I.ze,{children:(0,a.jsx)(I.uh,{children:"Done"})})]})]}):(0,a.jsxs)(T.Vq,{open:t,onOpenChange:()=>{s(!t),window.history.pushState({},"Khoj AI - Agents","/agents")},children:[(0,a.jsx)(T.hg,{children:(0,a.jsxs)("div",{className:"flex items-center relative top-2",children:[(0,V.TI)(e.data.icon,e.data.color),e.data.name]})}),(0,a.jsxs)("div",{className:"flex float-right",children:[e.editCard&&(0,a.jsx)("div",{className:"float-right",children:(0,a.jsxs)(et.J2,{children:[(0,a.jsx)(et.xo,{children:(0,a.jsx)(c.z,{className:"bg-[hsl(var(--background))] w-10 h-10 p-0 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100 dark:hover:bg-neutral-900",children:(0,a.jsx)(f.F,{className:"w-6 h-6 ".concat((0,A.oz)(e.data.color))})})}),(0,a.jsxs)(et.yk,{className:"w-fit grid p-1",side:"bottom",align:"end",children:[(0,a.jsxs)(c.z,{className:"items-center justify-start",variant:"ghost",onClick:()=>s(!0),children:[(0,a.jsx)(p.z,{className:"w-4 h-4 mr-2"}),"Edit"]}),e.editCard&&"private"!==e.data.privacy_level&&(0,a.jsx)(es.Z,{buttonTitle:"Share",title:"Share Agent",description:"Share a link to this agent with others. They'll be able to chat with it, and ask questions to all of its knowledge base.",buttonVariant:"ghost",includeIcon:!0,url:"".concat(window.location.origin,"/agents?agent=").concat(e.data.slug)}),e.data.creator===(null==w?void 0:w.username)&&(0,a.jsxs)(c.z,{className:"items-center justify-start",variant:"destructive",onClick:()=>{fetch("/api/agents/".concat(e.data.slug),{method:"DELETE"}).then(()=>{e.setAgentChangeTriggered(!0)})},children:[(0,a.jsx)(g.r,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]})}),(0,a.jsx)("div",{className:"float-right",children:e.userProfile?(0,a.jsx)(c.z,{className:"bg-[hsl(var(--background))] w-10 h-10 p-0 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100 dark:hover:bg-neutral-900",onClick:()=>en(e.data.slug,w),children:(0,a.jsx)(j.g,{className:"w-6 h-6 ".concat((0,A.oz)(e.data.color))})}):(0,a.jsx)(c.z,{className:"bg-[hsl(var(--background))] w-14 h-14 rounded-xl border dark:border-neutral-700 shadow-sm hover:bg-stone-100 dark:hover:bg-neutral-900",onClick:()=>r(!0),children:(0,a.jsx)(j.g,{className:"w-6 h-6 ".concat((0,A.oz)(e.data.color))})})})]}),e.editCard?(0,a.jsxs)(T.cZ,{className:"lg:max-w-screen-lg overflow-y-scroll max-h-screen",children:[(0,a.jsxs)(J.$N,{children:["Edit ",(0,a.jsx)("b",{children:e.data.name})]}),(0,a.jsx)(ed,{form:y,onSubmit:_,create:!1,errors:o,filesOptions:e.filesOptions,modelOptions:e.modelOptions,slug:e.data.slug,inputToolOptions:e.inputToolOptions,isSubscribed:e.isSubscribed,outputModeOptions:e.outputModeOptions})]}):(0,a.jsxs)(T.cZ,{className:"whitespace-pre-line max-h-[80vh]",children:[(0,a.jsx)(T.fK,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,V.TI)(e.data.icon,e.data.color),(0,a.jsx)("p",{className:"font-bold text-lg",children:e.data.name})]})}),(0,a.jsx)("div",{className:"max-h-[60vh] overflow-y-scroll text-neutral-500 dark:text-white",children:e.data.persona}),(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-1",children:k()}),(0,a.jsx)(T.cN,{children:(0,a.jsxs)(c.z,{className:"pt-6 pb-6 ".concat(C," bg-white dark:bg-[hsl(var(--background))] text-neutral-500 dark:text-white border-2 border-stone-100 shadow-sm rounded-xl hover:bg-stone-100 dark:hover:bg-neutral-900 dark:border-neutral-700"),onClick:()=>{en(e.data.slug,w),s(!1)},children:[(0,a.jsx)(j.g,{className:"w-6 h-6 m-2 ".concat((0,A.oz)(e.data.color))}),"Start Chatting"]})})]})]})})}),(0,a.jsx)(z.aY,{children:(0,a.jsx)("div",{className:l().agentPersonality,children:(0,a.jsx)("button",{className:"".concat(l().infoButton," text-neutral-500 dark:text-white"),onClick:()=>s(!0),children:(0,a.jsx)("p",{children:e.data.persona})})})}),(0,a.jsx)(z.eW,{children:(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-1",children:k()})})]})}let ec=S.z.object({name:S.z.string({required_error:"Name is required"}).min(1,"Name is required"),persona:S.z.string({required_error:"Personality is required"}).min(1,"Personality is required"),color:S.z.string({required_error:"Color is required"}).min(1,"Color is required"),icon:S.z.string({required_error:"Icon is required"}).min(1,"Icon is required"),privacy_level:S.z.string({required_error:"Privacy level is required"}).min(1,"Privacy level is required"),chat_model:S.z.string({required_error:"Chat model is required"}).min(1,"Chat model is required"),files:S.z.array(S.z.string()).default([]).optional(),input_tools:S.z.array(S.z.string()).default([]).optional(),output_modes:S.z.array(S.z.string()).default([]).optional()});function ed(e){let[t,s]=(0,i.useState)(!1),n=(0,V.BI)(),l=A.xF,r=(0,A.oz)(e.form.getValues("color")),[o,d]=(0,i.useState)(!1),[u,h]=(0,i.useState)(null),[m,x]=(0,i.useState)(null),[f,p]=(0,i.useState)(!1),[g,j]=(0,i.useState)(0),[O,S]=(0,i.useState)([]),[z,T]=(0,i.useState)([]),[I,P]=(0,i.useState)(!0),R=(0,i.useRef)(null);function M(e){e.preventDefault(),d(!0)}function Z(e){e.preventDefault(),d(!1)}function B(e){e.preventDefault(),d(!1),e.dataTransfer.files&&W(e.dataTransfer.files)}function W(e){(0,$.ko)(e,h,p,x,S)}function J(){R&&R.current&&R.current.click()}function X(e){e.target.files&&W(e.target.files)}(0,i.useEffect)(()=>{if(f||j(0),f){let e=setInterval(()=>{j(e=>{let t=e+(Math.floor(5*Math.random())+1);return t<100?t:100})},800);return()=>clearInterval(e)}},[f]),(0,i.useEffect)(()=>{let t=[...e.form.getValues("files")||[],...e.filesOptions||[]];T(e=>[...e,...t])},[]),(0,i.useEffect)(()=>{O.length>0&&(ea(O),T(e=>[...e,...O]))},[O]),(0,i.useEffect)(()=>{e.errors&&s(!1)},[e.errors]);let ea=t=>{for(let s of t){let t=e.form.getValues("files")||[],a=t.includes(s)?t.filter(e=>e!==s):[...t,s];e.form.setValue("files",a)}},en=["public","private","protected"];return!e.isSubscribed&&I?(0,a.jsx)(H.aR,{open:!0,children:(0,a.jsxs)(H._T,{children:[(0,a.jsx)(H.fY,{children:(0,a.jsx)(H.f$,{children:"Upgrade to Futurist"})}),(0,a.jsxs)(H.yT,{children:["You need to be a Futurist subscriber to create more agents."," ",(0,a.jsx)("a",{href:"/settings",children:"Upgrade now"}),"."]}),(0,a.jsxs)(H.xo,{children:[(0,a.jsx)(H.le,{onClick:()=>{P(!1)},children:"Cancel"}),(0,a.jsx)(H.OL,{onClick:()=>{window.location.href="/settings"},children:"Continue"})]})]})}):(0,a.jsx)(q.l0,{...e.form,children:(0,a.jsxs)("form",{onSubmit:e.form.handleSubmit(t=>{e.onSubmit(t),s(!0)}),className:"space-y-6",children:[(0,a.jsx)(q.Wi,{control:e.form.control,name:"name",render:e=>{let{field:t}=e;return(0,a.jsxs)(q.xJ,{className:"space-y-0 grid gap-2",children:[(0,a.jsx)(q.lX,{children:"Name"}),(0,a.jsx)(q.pf,{children:"What should this agent be called? Pick something descriptive & memorable."}),(0,a.jsx)(q.NI,{children:(0,a.jsx)(F.I,{placeholder:"Biologist",...t})}),(0,a.jsx)(q.zG,{})]})}}),(0,a.jsx)(q.Wi,{control:e.form.control,name:"persona",render:e=>{let{field:t}=e;return(0,a.jsxs)(q.xJ,{className:"space-y-1 grid gap-2",children:[(0,a.jsx)(q.lX,{children:"Personality"}),(0,a.jsx)(q.pf,{children:"What is the personality, thought process, or tuning of this agent? Get creative; this is how you can influence the agent constitution."}),(0,a.jsx)(q.NI,{children:(0,a.jsx)(L.g,{placeholder:"You are an excellent biologist, at the top of your field in marine biology.",...t})}),(0,a.jsx)(q.zG,{})]})}}),(0,a.jsx)(q.Wi,{control:e.form.control,name:"chat_model",render:t=>{let{field:s}=t;return(0,a.jsxs)(q.xJ,{className:"space-y-1 grid gap-2",children:[(0,a.jsx)(q.lX,{children:"Chat Model"}),(0,a.jsx)(q.pf,{children:"Which large language model should this agent use?"}),(0,a.jsxs)(D.Ph,{onValueChange:s.onChange,defaultValue:s.value,children:[(0,a.jsx)(q.NI,{children:(0,a.jsx)(D.i4,{className:"text-left",children:(0,a.jsx)(D.ki,{})})}),(0,a.jsx)(D.Bw,{className:"items-start space-y-1 inline-flex flex-col",children:e.modelOptions.map(e=>(0,a.jsx)(D.Ql,{value:e.name,children:(0,a.jsx)("div",{className:"flex items-center space-x-2",children:e.name})},e.id))})]}),(0,a.jsx)(q.zG,{})]})}}),(0,a.jsx)(q.Wi,{control:e.form.control,name:"privacy_level",render:e=>{let{field:t}=e;return(0,a.jsxs)(q.xJ,{className:"space-y-1 grid gap-2",children:[(0,a.jsx)(q.lX,{children:(0,a.jsx)("div",{children:"Privacy Level"})}),(0,a.jsx)(q.pf,{children:(0,a.jsxs)(et.J2,{children:[(0,a.jsx)(et.xo,{asChild:!0,children:(0,a.jsx)(c.z,{variant:"ghost",className:"p-0 h-fit",children:(0,a.jsxs)("span",{className:"items-center flex gap-1 text-sm",children:[(0,a.jsx)(v.k,{className:"inline"}),(0,a.jsx)("p",{className:"text-sm",children:"Learn more"})]})})}),(0,a.jsxs)(et.yk,{children:[(0,a.jsx)("b",{children:"Private"}),": only visible to you.",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Protected"}),": visible to anyone with a link.",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Public"}),": visible to everyone.",(0,a.jsx)("br",{}),"All public agents will be reviewed by us before they are launched."]})]})}),(0,a.jsxs)(D.Ph,{onValueChange:t.onChange,defaultValue:t.value,children:[(0,a.jsx)(q.NI,{children:(0,a.jsx)(D.i4,{className:"w-[200px]",children:(0,a.jsx)(D.ki,{placeholder:"private"})})}),(0,a.jsx)(D.Bw,{className:"items-center space-y-1 inline-flex flex-col",children:en.map(e=>(0,a.jsx)(D.Ql,{value:e,children:(0,a.jsx)("div",{className:"flex items-center space-x-2",children:e})},e))})]}),(0,a.jsx)(q.zG,{})]})}}),(0,a.jsxs)("div",{className:"grid",children:[(0,a.jsx)(q.lX,{className:"mb-2",children:"Look & Feel"}),(0,a.jsxs)("div",{className:"flex gap-1 justify-left",children:[(0,a.jsx)(q.Wi,{control:e.form.control,name:"color",render:e=>{let{field:t}=e;return(0,a.jsxs)(q.xJ,{className:"space-y-3",children:[(0,a.jsxs)(D.Ph,{onValueChange:t.onChange,defaultValue:t.value,children:[(0,a.jsx)(q.NI,{children:(0,a.jsx)(D.i4,{className:"w-[200px]",children:(0,a.jsx)(D.ki,{placeholder:"Color"})})}),(0,a.jsx)(D.Bw,{className:"items-center space-y-1 inline-flex flex-col",children:l.map(e=>(0,a.jsx)(D.Ql,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(b.C,{className:"w-6 h-6 mr-2 ".concat((0,A.oz)(e)),weight:"fill"}),e]})},e))})]}),(0,a.jsx)(q.zG,{})]})}}),(0,a.jsx)(q.Wi,{control:e.form.control,name:"icon",render:t=>{let{field:s}=t;return(0,a.jsxs)(q.xJ,{className:"space-y-3",children:[(0,a.jsxs)(D.Ph,{onValueChange:s.onChange,defaultValue:s.value,children:[(0,a.jsx)(q.NI,{children:(0,a.jsx)(D.i4,{className:"w-[200px]",children:(0,a.jsx)(D.ki,{placeholder:"Icon"})})}),(0,a.jsx)(D.Bw,{className:"items-center space-y-1 inline-flex flex-col",children:n.map(t=>(0,a.jsx)(D.Ql,{value:t,children:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,V.TI)(t,e.form.getValues("color"),"w-6","h-6"),t]})},t))})]}),(0,a.jsx)(q.zG,{})]})}})]})]}),(0,a.jsxs)(q.xJ,{className:"flex flex-col",children:[(0,a.jsx)(q.lX,{className:"text-md",children:"Advanced Settings"}),(0,a.jsx)(q.pf,{children:"These are optional settings that you can use to customize your agent."})]}),(0,a.jsx)(q.Wi,{control:e.form.control,name:"files",render:t=>{let{field:s}=t;return(0,a.jsxs)(q.xJ,{className:"flex flex-col gap-2",children:[(0,a.jsx)(q.lX,{children:"Knowledge Base"}),(0,a.jsxs)(q.pf,{children:["Which information should be part of its digital brain?"," ",(0,a.jsx)("a",{href:"/settings",children:"Manage data"}),"."]}),(0,a.jsxs)(Y,{children:[(0,a.jsxs)(G,{className:"flex items-center justify-between text-sm gap-2",children:[(0,a.jsx)(N.K,{}),s.value&&s.value.length>0?"".concat(s.value.length," files selected"):"Select files"]}),(0,a.jsx)(U,{children:(0,a.jsxs)(Q.mY,{children:[(0,a.jsx)(H.aR,{open:null!==u||null!=m,children:(0,a.jsxs)(H._T,{children:[(0,a.jsx)(H.fY,{children:(0,a.jsx)(H.f$,{children:"Alert"})}),(0,a.jsx)(H.yT,{children:u||m}),(0,a.jsx)(H.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>{h(null),x(null),p(!1)},children:"Close"})]})}),(0,a.jsxs)("div",{className:"flex flex-col h-full cursor-pointer",onDragOver:M,onDragLeave:Z,onDrop:B,onClick:J,children:[(0,a.jsx)("input",{type:"file",multiple:!0,ref:R,style:{display:"none"},onChange:X}),(0,a.jsx)("div",{className:"flex-none p-4",children:f&&(0,a.jsx)(ee.E,{indicatorColor:"bg-slate-500",className:"w-full h-2 rounded-full",value:g})}),(0,a.jsx)("div",{className:"flex-none p-4 bg-secondary border-b ".concat(o?"animate-pulse":""," rounded-lg"),children:(0,a.jsx)("div",{className:"flex items-center justify-center w-full h-16 border-2 border-dashed border-gray-300 rounded-lg",children:o?(0,a.jsxs)("div",{className:"flex items-center justify-center w-full h-full",children:[(0,a.jsx)(w.u,{className:"h-6 w-6 mr-2"}),(0,a.jsx)("span",{children:"Drop files to upload"})]}):(0,a.jsxs)("div",{className:"flex items-center justify-center w-full h-full",children:[(0,a.jsx)(y.v,{className:"h-6 w-6 mr-2"}),(0,a.jsx)("span",{children:"Drag and drop files here"})]})})})]}),(0,a.jsx)(Q.sZ,{placeholder:"Select files..."}),(0,a.jsxs)(Q.e8,{children:[(0,a.jsx)(Q.rb,{children:"No files found."}),(0,a.jsx)(Q.fu,{children:z.map(t=>(0,a.jsxs)(Q.di,{value:t,onSelect:()=>{let s=e.form.getValues("files")||[],a=s.includes(t)?s.filter(e=>e!==t):[...s,t];e.form.setValue("files",a)},children:[(0,a.jsx)(_.J,{className:(0,K.cn)("mr-2 h-4 w-4",s.value&&s.value.includes(t)?"opacity-100":"opacity-0")}),t]},t))})]})]})})]})]})}}),(0,a.jsx)(q.Wi,{control:e.form.control,name:"input_tools",render:t=>{let{field:s}=t;return(0,a.jsxs)(q.xJ,{className:"flex flex-col gap-2",children:[(0,a.jsx)(q.lX,{children:"Restrict Input Tools"}),(0,a.jsxs)(q.pf,{children:["Which knowledge retrieval tools should this agent be limited to?",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Default:"})," No limitations."]}),(0,a.jsxs)(Y,{children:[(0,a.jsxs)(G,{className:"flex items-center justify-between text-sm gap-2",children:[(0,a.jsx)(N.K,{}),s.value&&s.value.length>0?"".concat(s.value.length," tools selected"):"All tools"]}),(0,a.jsx)(U,{children:(0,a.jsx)(Q.mY,{children:(0,a.jsx)(Q.e8,{children:(0,a.jsx)(Q.fu,{children:Object.entries(e.inputToolOptions).map(t=>{let[n,l]=t;return(0,a.jsxs)(Q.di,{value:n,onSelect:()=>{let t=e.form.getValues("input_tools")||[],s=t.includes(n)?t.filter(e=>e!==n):[...t,n];e.form.setValue("input_tools",s)},children:[(0,a.jsx)(_.J,{className:(0,K.cn)("mr-2 h-4 w-4",s.value&&s.value.includes(n)?"opacity-100":"opacity-0")}),(0,a.jsx)("b",{children:n}),": ",l]},n)})})})})})]})]})}}),(0,a.jsx)(q.Wi,{control:e.form.control,name:"output_modes",render:t=>{let{field:s}=t;return(0,a.jsxs)(q.xJ,{className:"flex flex-col gap-2",children:[(0,a.jsx)(q.lX,{children:"Restrict Output Modes"}),(0,a.jsxs)(q.pf,{children:["Which output modes should this agent be limited to?",(0,a.jsx)("br",{}),(0,a.jsx)("b",{children:"Default:"})," No limitations."]}),(0,a.jsxs)(Y,{children:[(0,a.jsxs)(G,{className:"flex items-center justify-between text-sm gap-2",children:[(0,a.jsx)(N.K,{}),s.value&&s.value.length>0?"".concat(s.value.length," modes selected"):"All modes"]}),(0,a.jsx)(U,{children:(0,a.jsx)(Q.mY,{children:(0,a.jsx)(Q.e8,{children:(0,a.jsx)(Q.fu,{children:Object.entries(e.outputModeOptions).map(t=>{let[n,l]=t;return(0,a.jsxs)(Q.di,{value:n,onSelect:()=>{let t=e.form.getValues("output_modes")||[],s=t.includes(n)?t.filter(e=>e!==n):[...t,n];e.form.setValue("output_modes",s)},children:[(0,a.jsx)(_.J,{className:(0,K.cn)("mr-2 h-4 w-4",s.value&&s.value.includes(n)?"opacity-100":"opacity-0")}),(0,a.jsx)("b",{children:n}),": ",l]},n)})})})})})]})]})}}),e.errors&&(0,a.jsx)(E.bZ,{className:"bg-secondary border-none my-4",children:(0,a.jsxs)(E.X,{className:"flex items-center gap-1",children:[(0,a.jsx)(C.f,{weight:"fill",className:"h-4 w-4 text-yellow-400 inline"}),(0,a.jsx)("span",{children:e.errors})]})}),(0,a.jsxs)("fieldset",{children:[(0,a.jsxs)(c.z,{type:"submit",variant:"ghost",disabled:t||!e.isSubscribed,className:"items-center ".concat(t?"bg-stone-100 dark:bg-neutral-900":""," text-white ").concat(r),children:[(0,a.jsx)(k.B,{className:"h-4 w-4 mr-2"}),t?"Booting...":"Save"]}),!e.create&&"private"!==e.form.getValues("privacy_level")&&(0,a.jsx)(es.Z,{buttonTitle:"Share",title:"Share Agent",description:"Share a link to this agent with others. They'll be able to chat with it, and ask questions to all of its knowledge base.",buttonVariant:"ghost",buttonClassName:"".concat(r),includeIcon:!0,url:"".concat(window.location.origin,"/agents?agent=").concat(e.slug)})]})]})})}function eu(e){let[t,s]=(0,i.useState)(!1),[n,l]=(0,i.useState)(null),[r,o]=(0,i.useState)(!0),c=(0,B.cI)({resolver:(0,W.F)(ec),defaultValues:{name:e.data.name,persona:e.data.persona,color:e.data.color,icon:e.data.icon,privacy_level:e.data.privacy_level,chat_model:e.selectedChatModelOption,files:[]}});(0,i.useEffect)(()=>{c.reset({name:e.data.name,persona:e.data.persona,color:e.data.color,icon:e.data.icon,privacy_level:e.data.privacy_level,chat_model:e.selectedChatModelOption,files:[]})},[e.selectedChatModelOption,e.data]);let d=t=>{fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(t=>{200===t.status?(c.reset(),s(!1),l(null),e.setAgentChangeTriggered(!0)):t.json().then(e=>{console.error(e),e.error&&l(e.error)})}).catch(e=>{console.error("Error:",e),l(e)})};return e.isMobileWidth?(0,a.jsxs)(I.dy,{open:t,onOpenChange:s,children:[(0,a.jsx)(I.Qz,{children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(y.v,{}),"Create Agent"]})}),(0,a.jsxs)(I.sc,{className:"p-2",children:[(0,a.jsx)(I.OX,{children:(0,a.jsx)(I.iI,{children:"Create Agent"})}),!e.userProfile&&r&&(0,a.jsx)(P.Z,{loginRedirectMessage:"Sign in to start chatting with a specialized agent",onOpenChange:o}),(0,a.jsx)(ed,{form:c,onSubmit:d,create:!0,errors:n,filesOptions:e.filesOptions,modelOptions:e.modelOptions,inputToolOptions:e.inputToolOptions,outputModeOptions:e.outputModeOptions,isSubscribed:e.isSubscribed}),(0,a.jsx)(I.ze,{children:(0,a.jsx)(I.uh,{children:"Dismiss"})})]})]}):(0,a.jsxs)(T.Vq,{open:t,onOpenChange:s,children:[(0,a.jsx)(T.hg,{children:(0,a.jsxs)("div",{className:"flex items-center text-md gap-2",children:[(0,a.jsx)(y.v,{}),"Create Agent"]})}),(0,a.jsxs)(T.cZ,{className:"lg:max-w-screen-lg overflow-y-scroll max-h-screen",children:[(0,a.jsx)(T.fK,{children:"Create Agent"}),!e.userProfile&&r&&(0,a.jsx)(P.Z,{loginRedirectMessage:"Sign in to start chatting with a specialized agent",onOpenChange:o}),(0,a.jsx)(ed,{form:c,onSubmit:d,create:!0,errors:n,filesOptions:e.filesOptions,modelOptions:e.modelOptions,inputToolOptions:e.inputToolOptions,outputModeOptions:e.outputModeOptions,isSubscribed:e.isSubscribed})]})]})}function eh(){let{data:e,error:t,mutate:s}=(0,r.ZP)("agents",er,{revalidateOnFocus:!1}),n=(0,o.GW)(),{userConfig:c}=(0,o.h2)(!0),[d,u]=(0,i.useState)(!1),h=(0,Z.IC)(),[m,x]=(0,i.useState)([]),[f,p]=(0,i.useState)([]),[g,j]=(0,i.useState)(null),{data:v,error:b}=(0,r.ZP)(c?"/api/content/computer":null,ei),{data:N,error:w}=(0,r.ZP)("/api/agents/options",ei),[y,_]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{y&&(s(),_(!1))},[y]),(0,i.useEffect)(()=>{if(e){x(e.filter(e=>e.creator===(null==n?void 0:n.username))),p(e.filter(e=>"private"!==e.privacy_level&&e.creator!==(null==n?void 0:n.username)));{let t=new URLSearchParams(window.location.search).get("agent");t&&(j(t),e.find(e=>e.slug===t)||fetch("/api/agents/".concat(t)).then(e=>{if(404===e.status)throw Error("Agent not found");return e.json()}).then(e=>{"protected"===e.privacy_level&&p(t=>[...t,e])}))}}},[e]),t)return(0,a.jsxs)("main",{className:l().main,children:[(0,a.jsx)("div",{className:"".concat(l().titleBar," text-5xl"),children:"Agents"}),(0,a.jsx)("div",{className:l().agentList,children:"Error loading agents"})]});if(!e)return(0,a.jsx)("main",{className:l().main,children:(0,a.jsxs)("div",{className:l().agentList,children:[(0,a.jsx)(R.l,{})," booting up your agents"]})});let C=(null==c?void 0:c.chat_model_options)||[],k=(null==c?void 0:c.selected_chat_model_config)||0,S=(null==c?void 0:c.subscription_state)&&[o.o9.SUBSCRIBED.valueOf(),o.o9.TRIAL.valueOf(),o.o9.UNSUBSCRIBED.valueOf()].includes(c.subscription_state)||!1,z=C.find(e=>e.id===k);return(0,a.jsx)("main",{className:"w-full mx-auto",children:(0,a.jsxs)("div",{className:"grid w-full mx-auto",children:[(0,a.jsx)("div",{className:"".concat(l().sidePanel," top-0"),children:(0,a.jsx)(M.ZP,{conversationId:null,uploadedFiles:[],isMobileWidth:h})}),(0,a.jsxs)("div",{className:"".concat(l().pageLayout," w-full"),children:[(0,a.jsxs)("div",{className:"pt-6 md:pt-8 flex justify-between",children:[(0,a.jsx)("h1",{className:"text-3xl flex items-center",children:"Agents"}),(0,a.jsx)("div",{className:"ml-auto float-right border p-2 pt-3 rounded-xl font-bold hover:bg-stone-100 dark:hover:bg-neutral-900",children:(0,a.jsx)(eu,{data:{slug:"",name:"",persona:"",color:"",icon:"",privacy_level:"private",managed_by_admin:!1,chat_model:"",input_tools:[],output_modes:[]},userProfile:n,isMobileWidth:h,filesOptions:v||[],modelOptions:(null==c?void 0:c.chat_model_options)||[],selectedChatModelOption:(null==z?void 0:z.name)||"",isSubscribed:S,setAgentChangeTriggered:_,inputToolOptions:(null==N?void 0:N.input_tools)||{},outputModeOptions:(null==N?void 0:N.output_modes)||{}})})]}),d&&(0,a.jsx)(P.Z,{loginRedirectMessage:"Sign in to start chatting with a specialized agent",onOpenChange:u}),(0,a.jsx)(E.bZ,{className:"bg-secondary border-none my-4",children:(0,a.jsxs)(E.X,{children:[(0,a.jsx)(O.B,{weight:"fill",className:"h-4 w-4 text-purple-400 inline"}),(0,a.jsx)("span",{className:"font-bold",children:"How it works"})," Use any of these specialized personas to tune your conversation to your needs."]})}),(0,a.jsx)("div",{className:"pt-6 md:pt-8",children:(0,a.jsx)("div",{className:"".concat(l().agentList),children:m.map(e=>(0,a.jsx)(eo,{data:e,userProfile:n,isMobileWidth:h,filesOptions:null!=v?v:[],selectedChatModelOption:(null==z?void 0:z.name)||"",isSubscribed:S,setAgentChangeTriggered:_,modelOptions:(null==c?void 0:c.chat_model_options)||[],editCard:!0,agentSlug:g||"",inputToolOptions:(null==N?void 0:N.input_tools)||{},outputModeOptions:(null==N?void 0:N.output_modes)||{}},e.slug))})}),(0,a.jsxs)("div",{className:"pt-6 md:pt-8",children:[(0,a.jsx)("h2",{className:"text-2xl",children:"Explore"}),(0,a.jsx)("div",{className:"".concat(l().agentList),children:f.map(e=>(0,a.jsx)(eo,{data:e,userProfile:n,isMobileWidth:h,editCard:!1,filesOptions:null!=v?v:[],selectedChatModelOption:(null==z?void 0:z.name)||"",isSubscribed:S,setAgentChangeTriggered:_,modelOptions:(null==c?void 0:c.chat_model_options)||[],agentSlug:g||"",inputToolOptions:(null==N?void 0:N.input_tools)||{},outputModeOptions:(null==N?void 0:N.output_modes)||{}},e.slug))})]})]})]})})}},66820:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});var a=s(57437),n=s(6780),l=s(87138);function r(e){return(0,a.jsx)(n.aR,{open:!0,onOpenChange:e.onOpenChange,children:(0,a.jsxs)(n._T,{children:[(0,a.jsx)(n.fY,{children:(0,a.jsx)(n.f$,{children:"Sign in to Khoj to continue"})}),(0,a.jsxs)(n.yT,{children:[e.loginRedirectMessage,". By logging in, you agree to our"," ",(0,a.jsx)(l.default,{href:"https://khoj.dev/terms-of-service",children:"Terms of Service."})]}),(0,a.jsxs)(n.xo,{children:[(0,a.jsx)(n.le,{children:"Dismiss"}),(0,a.jsx)(n.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>{window.location.href="/login?next=".concat(encodeURIComponent(window.location.pathname))},children:(0,a.jsxs)(l.default,{href:"/login?next=".concat(encodeURIComponent(window.location.pathname)),children:[" ","Login"]})})]})]})})}},18642:function(e,t,s){"use strict";s.d(t,{Z:function(){return c}});var a=s(57437),n=s(90837),l=s(50495),r=s(83102),i=s(67135),o=s(34797);function c(e){var t;return(0,a.jsxs)(n.Vq,{children:[(0,a.jsx)(n.hg,{asChild:!0,onClick:e.onShare,children:(0,a.jsxs)(l.z,{size:"sm",className:"".concat(e.buttonClassName||"px-3"),variant:null!==(t=e.buttonVariant)&&void 0!==t?t:"default",children:[e.includeIcon&&(0,a.jsx)(o.m,{className:"w-4 h-4 mr-2"}),e.buttonTitle]})}),(0,a.jsxs)(n.cZ,{children:[(0,a.jsxs)(n.fK,{children:[(0,a.jsx)(n.$N,{children:e.title}),(0,a.jsx)(n.Be,{children:e.description})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsxs)("div",{className:"grid flex-1 gap-2",children:[(0,a.jsx)(i._,{htmlFor:"link",className:"sr-only",children:"Link"}),(0,a.jsx)(r.I,{id:"link",defaultValue:e.url,readOnly:!0})]}),(0,a.jsx)(l.z,{type:"submit",size:"sm",className:"px-3",onClick:()=>(function(e){let t=navigator.clipboard;t&&t.writeText(e)})(e.url),children:(0,a.jsx)("span",{children:"Copy"})})]})]})]})}},47412:function(e,t,s){"use strict";s.d(t,{X:function(){return c},bZ:function(){return o}});var a=s(57437),n=s(2265),l=s(12218),r=s(37440);let i=(0,l.j)("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),o=n.forwardRef((e,t)=>{let{className:s,variant:n,...l}=e;return(0,a.jsx)("div",{ref:t,role:"alert",className:(0,r.cn)(i({variant:n}),s),...l})});o.displayName="Alert",n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)("h5",{ref:t,className:(0,r.cn)("mb-1 font-medium leading-none tracking-tight",s),...n})}).displayName="AlertTitle";let c=n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)("div",{ref:t,className:(0,r.cn)("text-sm [&_p]:leading-relaxed",s),...n})});c.displayName="AlertDescription"},32653:function(e,t,s){"use strict";s.d(t,{NI:function(){return p},Wi:function(){return u},l0:function(){return c},lX:function(){return f},pf:function(){return g},xJ:function(){return x},zG:function(){return j}});var a=s(57437),n=s(2265),l=s(71538),r=s(39343),i=s(37440),o=s(67135);let c=r.RV,d=n.createContext({}),u=e=>{let{...t}=e;return(0,a.jsx)(d.Provider,{value:{name:t.name},children:(0,a.jsx)(r.Qr,{...t})})},h=()=>{let e=n.useContext(d),t=n.useContext(m),{getFieldState:s,formState:a}=(0,r.Gc)(),l=s(e.name,a);if(!e)throw Error("useFormField should be used within <FormField>");let{id:i}=t;return{id:i,name:e.name,formItemId:"".concat(i,"-form-item"),formDescriptionId:"".concat(i,"-form-item-description"),formMessageId:"".concat(i,"-form-item-message"),...l}},m=n.createContext({}),x=n.forwardRef((e,t)=>{let{className:s,...l}=e,r=n.useId();return(0,a.jsx)(m.Provider,{value:{id:r},children:(0,a.jsx)("div",{ref:t,className:(0,i.cn)("space-y-2",s),...l})})});x.displayName="FormItem";let f=n.forwardRef((e,t)=>{let{className:s,...n}=e,{error:l,formItemId:r}=h();return(0,a.jsx)(o._,{ref:t,className:(0,i.cn)(l&&"text-destructive",s),htmlFor:r,...n})});f.displayName="FormLabel";let p=n.forwardRef((e,t)=>{let{...s}=e,{error:n,formItemId:r,formDescriptionId:i,formMessageId:o}=h();return(0,a.jsx)(l.g7,{ref:t,id:r,"aria-describedby":n?"".concat(i," ").concat(o):"".concat(i),"aria-invalid":!!n,...s})});p.displayName="FormControl";let g=n.forwardRef((e,t)=>{let{className:s,...n}=e,{formDescriptionId:l}=h();return(0,a.jsx)("p",{ref:t,id:l,className:(0,i.cn)("text-sm text-muted-foreground",s),...n})});g.displayName="FormDescription";let j=n.forwardRef((e,t)=>{let{className:s,children:n,...l}=e,{error:r,formMessageId:o}=h(),c=r?String(null==r?void 0:r.message):n;return c?(0,a.jsx)("p",{ref:t,id:o,className:(0,i.cn)("text-sm font-medium text-destructive",s),...l,children:c}):null});j.displayName="FormMessage"},67135:function(e,t,s){"use strict";s.d(t,{_:function(){return c}});var a=s(57437),n=s(2265),l=s(38364),r=s(12218),i=s(37440);let o=(0,r.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)(l.f,{ref:t,className:(0,i.cn)(o(),s),...n})});c.displayName=l.f.displayName},70571:function(e,t,s){"use strict";s.d(t,{E:function(){return i}});var a=s(57437),n=s(2265),l=s(52431),r=s(37440);let i=n.forwardRef((e,t)=>{let{className:s,value:n,indicatorColor:i,...o}=e;return(0,a.jsx)(l.fC,{ref:t,className:(0,r.cn)("relative h-4 w-full overflow-hidden rounded-full bg-secondary",s),...o,children:(0,a.jsx)(l.z$,{className:"h-full w-full flex-1 bg-primary transition-all ".concat(i),style:{transform:"translateX(-".concat(100-(n||0),"%)")}})})});i.displayName=l.fC.displayName},46294:function(e,t,s){"use strict";s.d(t,{Bw:function(){return f},Ph:function(){return d},Ql:function(){return p},i4:function(){return h},ki:function(){return u}});var a=s(57437),n=s(2265),l=s(77539),r=s(42421),i=s(14392),o=s(22468),c=s(37440);let d=l.fC;l.ZA;let u=l.B4,h=n.forwardRef((e,t)=>{let{className:s,children:n,...i}=e;return(0,a.jsxs)(l.xz,{ref:t,className:(0,c.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...i,children:[n,(0,a.jsx)(l.JO,{asChild:!0,children:(0,a.jsx)(r.Z,{className:"h-4 w-4 opacity-50"})})]})});h.displayName=l.xz.displayName;let m=n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)(l.u_,{ref:t,className:(0,c.cn)("flex cursor-default items-center justify-center py-1",s),...n,children:(0,a.jsx)(i.Z,{className:"h-4 w-4"})})});m.displayName=l.u_.displayName;let x=n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)(l.$G,{ref:t,className:(0,c.cn)("flex cursor-default items-center justify-center py-1",s),...n,children:(0,a.jsx)(r.Z,{className:"h-4 w-4"})})});x.displayName=l.$G.displayName;let f=n.forwardRef((e,t)=>{let{className:s,children:n,position:r="popper",...i}=e;return(0,a.jsx)(l.h_,{children:(0,a.jsxs)(l.VY,{ref:t,className:(0,c.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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","popper"===r&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:r,...i,children:[(0,a.jsx)(m,{}),(0,a.jsx)(l.l_,{className:(0,c.cn)("p-1","popper"===r&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),(0,a.jsx)(x,{})]})})});f.displayName=l.VY.displayName,n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)(l.__,{ref:t,className:(0,c.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",s),...n})}).displayName=l.__.displayName;let p=n.forwardRef((e,t)=>{let{className:s,children:n,...r}=e;return(0,a.jsxs)(l.ck,{ref:t,className:(0,c.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...r,children:[(0,a.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,a.jsx)(l.wU,{children:(0,a.jsx)(o.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(l.eT,{children:n})]})});p.displayName=l.ck.displayName,n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)(l.Z0,{ref:t,className:(0,c.cn)("-mx-1 my-1 h-px bg-muted",s),...n})}).displayName=l.Z0.displayName},93146:function(e,t,s){"use strict";s.d(t,{g:function(){return r}});var a=s(57437),n=s(2265),l=s(37440);let r=n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.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",s),ref:t,...n})});r.displayName="Textarea"},19666:function(e,t,s){"use strict";s.d(t,{_v:function(){return d},aJ:function(){return c},pn:function(){return i},u:function(){return o}});var a=s(57437),n=s(2265),l=s(27071),r=s(37440);let i=l.zt,o=l.fC,c=l.xz,d=n.forwardRef((e,t)=>{let{className:s,sideOffset:n=4,...i}=e;return(0,a.jsx)(l.VY,{ref:t,sideOffset:n,className:(0,r.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",s),...i})});d.displayName=l.VY.displayName},15283:function(e){e.exports={titleBar:"agents_titleBar__FzYbY",agentPersonality:"agents_agentPersonality__o0Ysz",pageLayout:"agents_pageLayout__gR3S3",sidePanel:"agents_sidePanel__wGVGc",infoButton:"agents_infoButton__NqI7E",agentList:"agents_agentList__XVx4A"}}},function(e){e.O(0,[9460,8918,9001,3062,4086,3110,51,1269,1603,9417,2971,7023,1744],function(){return e(e.s=1813)}),_N_E=e.O()}]);
|
@@ -1 +1 @@
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4371],{2743:function(e,t,a){Promise.resolve().then(a.bind(a,19648))},19648:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return ef}});var n=a(57437),s=a(29039),r=a(58485),o=a(36013),i=a(50495),l=a(46294),c=a(18760),d=a.n(c),u=a(31014),m=a(39343),h=a(59772),f=a(2265),x=a(32653),p=a(83102),g=a(90837),j=a(13304),y=a(93146),w=a(69591),v=a(23611),b=a.n(v),N=a(18642),D=a(16463),C=a(19573),k=a(20319),S=a(22049),_=a(55362),I=a(13537),A=a(76082),M=a(52674),R=a(23751),T=a(83522),z=a(8837),P=a(21819),L=a(35418),O=a(64945),W=a(79306),q=a(66820),E=a(35657),U=a(50151),F=a(47412),B=a(48861),V=a(7951);let G=()=>window.fetch("/api/automations").then(e=>e.json()).catch(e=>console.log(e));function Z(e){let t=e.split(" "),a=t[2],n=t[4];return"*"===a&&"*"===n?"Day":"*"!==n?"Week":"*"!==a?"Month":"Day"}function J(e){let t=e.split(" ");if("*"===t[3]&&"*"!==t[4])return Number(t[4])}function Q(e){let t=e.split(" "),a=t[1],n=t[0],s=Number(a)>=12?"PM":"AM",r=Number(a)>12?Number(a)-12:a;"00"===r&&(r="12");let o=n;return 10>Number(o)&&"00"!==o&&(o="0".concat(o)),"".concat(r,":").concat(o," ").concat(s)}function X(e){return String(e.split(" ")[2])}function Y(e){return d().toString(e)}let $=["Day","Week","Month"],H=Array.from({length:31},(e,t)=>String(t+1)),K=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ee=[],et=["AM","PM"];for(var ea=0;ea<et.length;ea++)for(var en=0;en<12;en++)for(var es=0;es<60;es+=15){let e=String(es).padStart(2,"0"),t=0===en?12:en;ee.push("".concat(t,":").concat(e," ").concat(et[ea]))}let er=Date.now(),eo=[{subject:"Weekly Newsletter",query_to_run:"Compile a message including: 1. A recap of news from last week 2. An at-home workout I can do before work 3. A quote to inspire me for the week ahead",schedule:"9AM every Monday",next:"Next run at 9AM on Monday",crontime:"0 9 * * 1",id:er,scheduling_request:""},{subject:"Daily Bedtime Story",query_to_run:"Compose a bedtime story that a five-year-old might enjoy. It should not exceed five paragraphs. Appeal to the imagination, but weave in learnings.",schedule:"9PM every night",next:"Next run at 9PM today",crontime:"0 21 * * *",id:er+1,scheduling_request:""},{subject:"Front Page of Hacker News",query_to_run:"Summarize the top 5 posts from https://news.ycombinator.com/best and share them with me, including links",schedule:"9PM on every Wednesday",next:"Next run at 9PM on Wednesday",crontime:"0 21 * * 3",id:er+2,scheduling_request:""},{subject:"Market Summary",query_to_run:"Get the market summary for today and share it with me. Focus on tech stocks and the S&P 500.",schedule:"9AM on every weekday",next:"Next run at 9AM on Monday",crontime:"0 9 * * *",id:er+3,scheduling_request:""},{subject:"Market Crash Notification",query_to_run:"Notify me if the stock market fell by more than 5% today.",schedule:"5PM every evening",next:"Next run at 5PM today",crontime:"0 17 * * *",id:er+5,scheduling_request:""},{subject:"Round-up of research papers about AI in healthcare",query_to_run:"Summarize the top 3 research papers about AI in healthcare that were published in the last week. Include links to the full papers.",schedule:"9AM every Friday",next:"Next run at 9AM on Friday",crontime:"0 9 * * 5",id:er+4,scheduling_request:""}];function ei(e){let t=encodeURIComponent(e.subject),a=encodeURIComponent(e.query_to_run),n=encodeURIComponent(e.crontime);return"".concat(window.location.origin,"/automations?subject=").concat(t,"&query=").concat(a,"&crontime=").concat(n)}function el(e){let[t,a]=(0,f.useState)(!1),[s,r]=(0,f.useState)(null),[l,c]=(0,f.useState)(!1),[d,u]=(0,f.useState)(""),{toast:m}=(0,E.pm)(),h=e.automation,[x,p]=(0,f.useState)(""),[g,j]=(0,f.useState)("");return((0,f.useEffect)(()=>{let e=s||h;p(Q(e.crontime));let t=Z(e.crontime);if("Day"===t)j("Daily");else if("Week"===t){let t=J(e.crontime);void 0===t?j("Weekly"):j("".concat(K[t]))}else if("Month"===t){let t=X(e.crontime);j("Monthly on the ".concat(t))}},[s,h]),(0,f.useEffect)(()=>{let e="Automation: ".concat((null==s?void 0:s.subject)||h.subject);d&&(m({title:e,description:d,action:(0,n.jsx)(U.gD,{altText:"Dismiss",children:"Ok"})}),u(""))},[d,s,h,m]),l)?null:(0,n.jsxs)(o.Zb,{className:"bg-secondary h-full shadow-sm rounded-lg bg-gradient-to-b from-background to-slate-50 dark:to-gray-950 border ".concat(b().automationCard),children:[(0,n.jsx)(o.Ol,{children:(0,n.jsxs)(o.ll,{className:"line-clamp-2 leading-normal flex justify-between",children:[(null==s?void 0:s.subject)||h.subject,(0,n.jsxs)(C.J2,{children:[(0,n.jsx)(C.xo,{asChild:!0,children:(0,n.jsx)(i.z,{className:"bg-background",variant:"ghost",children:(0,n.jsx)(k.F,{className:"h-4 w-4"})})}),(0,n.jsxs)(C.yk,{className:"w-auto grid gap-2 text-left bg-secondary",children:[!e.suggestedCard&&e.locationData&&(0,n.jsx)(eh,{isMobileWidth:e.isMobileWidth,callToAction:"Edit",createNew:!1,setIsCreating:a,setShowLoginPrompt:e.setShowLoginPrompt,setNewAutomationData:r,authenticatedData:e.authenticatedData,isCreating:t,automation:s||h,ipLocationData:e.locationData}),(0,n.jsx)(N.Z,{buttonTitle:"Share",includeIcon:!0,buttonClassName:"justify-start px-4 py-2 h-10",buttonVariant:"outline",title:"Share Automation",description:"Copy the link below and share it with your coworkers or friends.",url:ei(h),onShare:()=>{navigator.clipboard.writeText(ei(h))}}),!e.suggestedCard&&(0,n.jsxs)(i.z,{variant:"outline",className:"justify-start",onClick:()=>{!function(e,t){fetch("/api/trigger/automation?automation_id=".concat(e),{method:"POST"}).then(e=>{if(!e.ok)throw Error("Network response was not ok");return e}).then(e=>{t("Automation triggered. Check your inbox in a few minutes!")}).catch(e=>{t("Sorry, something went wrong. Try again later.")})}(h.id.toString(),u)},children:[(0,n.jsx)(S.s,{className:"h-4 w-4 mr-2"}),"Run Now"]}),(0,n.jsxs)(i.z,{variant:"destructive",className:"justify-start",onClick:()=>{if(e.suggestedCard){c(!0);return}!function(e,t){fetch("/api/automation?automation_id=".concat(e),{method:"DELETE"}).then(e=>e.json()).then(e=>{t(!0)})}(h.id.toString(),c)},children:[(0,n.jsx)(_.r,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})}),(0,n.jsx)(o.aY,{className:"text-secondary-foreground break-all",children:(null==s?void 0:s.query_to_run)||h.query_to_run}),(0,n.jsxs)(o.eW,{className:"flex flex-col items-start md:flex-row md:justify-between md:items-center gap-2",children:[(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)("div",{className:"flex items-center bg-blue-50 rounded-lg p-1.5 border-blue-200 border dark:bg-blue-800 dark:border-blue-500",children:[(0,n.jsx)(I.T,{className:"h-4 w-4 mr-2 text-blue-700 dark:text-blue-300"}),(0,n.jsx)("div",{className:"text-s text-blue-700 dark:text-blue-300",children:x})]}),(0,n.jsxs)("div",{className:"flex items-center bg-purple-50 rounded-lg p-1.5 border-purple-200 border dark:bg-purple-800 dark:border-purple-500",children:[(0,n.jsx)(A.u,{className:"h-4 w-4 mr-2 text-purple-700 dark:text-purple-300"}),(0,n.jsx)("div",{className:"text-s text-purple-700 dark:text-purple-300",children:g})]})]}),e.suggestedCard&&e.setNewAutomationData&&(0,n.jsx)(eh,{isMobileWidth:e.isMobileWidth,callToAction:"Add",createNew:!0,setIsCreating:a,setShowLoginPrompt:e.setShowLoginPrompt,setNewAutomationData:e.setNewAutomationData,authenticatedData:e.authenticatedData,isCreating:t,automation:h,ipLocationData:e.locationData})]})]})}function ec(e){let t=(0,D.useSearchParams)(),[a,s]=(0,f.useState)(!0),r=t.get("subject"),o=t.get("query"),i=t.get("crontime");if(!r||!o||!i)return null;let l={id:0,subject:decodeURIComponent(r),query_to_run:decodeURIComponent(o),scheduling_request:"",schedule:Y(decodeURIComponent(i)),crontime:decodeURIComponent(i),next:""};return a?(0,n.jsx)(eh,{isMobileWidth:e.isMobileWidth,callToAction:"Shared",createNew:!0,setIsCreating:s,setShowLoginPrompt:e.setShowLoginPrompt,setNewAutomationData:e.setNewAutomationData,authenticatedData:e.authenticatedData,isCreating:a,automation:l,ipLocationData:e.locationData}):null}let ed=h.z.object({subject:h.z.optional(h.z.string()),everyBlah:h.z.string({required_error:"Every is required"}),dayOfWeek:h.z.optional(h.z.number()),dayOfMonth:h.z.optional(h.z.string()),timeRecurrence:h.z.string({required_error:"Time Recurrence is required"}),queryToRun:h.z.string({required_error:"Query to Run is required"})});function eu(e){let t=e.automation,a=(0,m.cI)({resolver:(0,u.F)(ed),defaultValues:{subject:null==t?void 0:t.subject,everyBlah:(null==t?void 0:t.crontime)?Z(t.crontime):"Day",dayOfWeek:(null==t?void 0:t.crontime)?J(t.crontime):void 0,timeRecurrence:(null==t?void 0:t.crontime)?Q(t.crontime):"12:00 PM",dayOfMonth:(null==t?void 0:t.crontime)?X(t.crontime):"1",queryToRun:null==t?void 0:t.query_to_run}});return(0,n.jsx)(em,{authenticatedData:e.authenticatedData,locationData:e.locationData||null,form:a,onSubmit:a=>{let n=function(e,t,a,n){let s="",r=t.split(":")[1].split(" ")[0],o=t.split(":")[1].split(" ")[1],i=Number(t.split(":")[0]),l="PM"===o&&i<12?String(i+12):i;switch(e){case"Day":s="".concat(r," ").concat(l," * * *");break;case"Week":s="".concat(r," ").concat(l," * * ").concat(void 0!==a?7===a?0:a:"*");break;case"Month":s="".concat(r," ").concat(l," ").concat(n," * *")}return s}(a.everyBlah,a.timeRecurrence,a.dayOfWeek,a.dayOfMonth),s="/api/automation?";s+="q=".concat(encodeURIComponent(a.queryToRun)),(null==t?void 0:t.id)&&!e.createNew&&(s+="&automation_id=".concat(encodeURIComponent(t.id))),a.subject&&(s+="&subject=".concat(encodeURIComponent(a.subject))),s+="&crontime=".concat(encodeURIComponent(n)),e.locationData&&e.locationData.city&&(s+="&city=".concat(encodeURIComponent(e.locationData.city))),e.locationData&&e.locationData.region&&(s+="®ion=".concat(encodeURIComponent(e.locationData.region))),e.locationData&&e.locationData.country&&(s+="&country=".concat(encodeURIComponent(e.locationData.country))),e.locationData&&e.locationData.timezone&&(s+="&timezone=".concat(encodeURIComponent(e.locationData.timezone))),fetch(s,{method:e.createNew?"POST":"PUT"}).then(e=>e.json()).then(t=>{e.setIsEditing(!1),e.setUpdatedAutomationData({id:t.id,subject:t.subject||"",query_to_run:t.query_to_run,scheduling_request:t.scheduling_request,schedule:Y(t.crontime),crontime:t.crontime,next:t.next})})},create:e.createNew,isLoggedIn:e.isLoggedIn,setShowLoginPrompt:e.setShowLoginPrompt})}function em(e){var t,a;let[s,r]=(0,f.useState)(!1),{errors:o}=e.form.formState,c=["Make a picture of","Generate a summary of","Create a newsletter of","Notify me when"];return(0,n.jsx)(x.l0,{...e.form,children:(0,n.jsxs)("form",{onSubmit:e.form.handleSubmit(t=>{e.onSubmit(t),r(!0)}),className:"space-y-6",children:[(0,n.jsx)(x.xJ,{className:"space-y-1",children:(0,n.jsxs)(x.pf,{children:["Emails will be sent to this address. Timezone and location data will be used to schedule automations.",e.locationData&&(t=e.locationData,a=e.authenticatedData,(0,n.jsxs)("div",{className:"flex flex-wrap gap-2 items-center justify-start",children:[a?(0,n.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,n.jsx)(T.w,{className:"h-4 w-4 mr-2 inline text-orange-500 shadow-sm"}),a.email]}):null,t&&(0,n.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,n.jsx)(z.x,{className:"h-4 w-4 mr-2 inline text-purple-500"}),t?"".concat(t.city,", ").concat(t.country):"Unknown"]}),t&&(0,n.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,n.jsx)(P.S,{className:"h-4 w-4 mr-2 inline text-green-500"}),t?"".concat(t.timezone):"Unknown"]})]}))]})}),!e.create&&(0,n.jsx)(x.Wi,{control:e.form.control,name:"subject",render:e=>{var t;let{field:a}=e;return(0,n.jsxs)(x.xJ,{className:"space-y-1",children:[(0,n.jsx)(x.lX,{children:"Subject"}),(0,n.jsx)(x.pf,{children:"This is the subject of the email you will receive."}),(0,n.jsx)(x.NI,{children:(0,n.jsx)(p.I,{placeholder:"Digest of Healthcare AI trends",...a})}),(0,n.jsx)(x.zG,{}),o.subject&&(0,n.jsx)(x.zG,{children:null===(t=o.subject)||void 0===t?void 0:t.message})]})}}),(0,n.jsx)(x.Wi,{control:e.form.control,name:"everyBlah",render:e=>{var t;let{field:a}=e;return(0,n.jsxs)(x.xJ,{className:"w-full space-y-1",children:[(0,n.jsx)(x.lX,{children:"Frequency"}),(0,n.jsx)(x.pf,{children:"How often should this automation run?"}),(0,n.jsxs)(l.Ph,{onValueChange:a.onChange,defaultValue:a.value,children:[(0,n.jsx)(x.NI,{children:(0,n.jsxs)(l.i4,{className:"w-[200px]",children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(M.W,{className:"h-4 w-4 mr-2 inline"}),"Every"]}),(0,n.jsx)(l.ki,{placeholder:""})]})}),(0,n.jsx)(l.Bw,{children:$.map(e=>(0,n.jsx)(l.Ql,{value:e,children:e},e))})]}),(0,n.jsx)(x.zG,{}),o.subject&&(0,n.jsx)(x.zG,{children:null===(t=o.everyBlah)||void 0===t?void 0:t.message})]})}}),"Week"===e.form.watch("everyBlah")&&(0,n.jsx)(x.Wi,{control:e.form.control,name:"dayOfWeek",render:e=>{var t;let{field:a}=e;return(0,n.jsxs)(x.xJ,{className:"w-full space-y-1",children:[(0,n.jsx)(x.pf,{children:"Every week, on which day should this automation run?"}),(0,n.jsxs)(l.Ph,{onValueChange:e=>a.onChange(Number(e)),defaultValue:String(a.value),children:[(0,n.jsx)(x.NI,{children:(0,n.jsxs)(l.i4,{className:"w-[200px]",children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(R.n,{className:"h-4 w-4 mr-2 inline"}),"On"]}),(0,n.jsx)(l.ki,{placeholder:""})]})}),(0,n.jsx)(l.Bw,{children:K.map((e,t)=>(0,n.jsx)(l.Ql,{value:String(t),children:e},e))})]}),(0,n.jsx)(x.zG,{}),o.subject&&(0,n.jsx)(x.zG,{children:null===(t=o.dayOfWeek)||void 0===t?void 0:t.message})]})}}),"Month"===e.form.watch("everyBlah")&&(0,n.jsx)(x.Wi,{control:e.form.control,name:"dayOfMonth",render:e=>{var t;let{field:a}=e;return(0,n.jsxs)(x.xJ,{className:"w-full space-y-1",children:[(0,n.jsx)(x.pf,{children:"Every month, on which day should the automation run?"}),(0,n.jsxs)(l.Ph,{onValueChange:a.onChange,defaultValue:a.value,children:[(0,n.jsx)(x.NI,{children:(0,n.jsxs)(l.i4,{className:"w-[200px]",children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(R.n,{className:"h-4 w-4 mr-2 inline"}),"On the"]}),(0,n.jsx)(l.ki,{placeholder:""})]})}),(0,n.jsx)(l.Bw,{children:H.map(e=>(0,n.jsx)(l.Ql,{value:e,children:e},e))})]}),(0,n.jsx)(x.zG,{}),o.subject&&(0,n.jsx)(x.zG,{children:null===(t=o.dayOfMonth)||void 0===t?void 0:t.message})]})}}),("Day"===e.form.watch("everyBlah")||"Week"==e.form.watch("everyBlah")||"Month"==e.form.watch("everyBlah"))&&(0,n.jsx)(x.Wi,{control:e.form.control,name:"timeRecurrence",render:e=>{var t;let{field:a}=e;return(0,n.jsxs)(x.xJ,{className:"w-full space-y-1",children:[(0,n.jsx)(x.lX,{children:"Time"}),(0,n.jsx)(x.pf,{children:"On the days this automation runs, at what time should it run?"}),(0,n.jsxs)(l.Ph,{onValueChange:a.onChange,defaultValue:a.value,children:[(0,n.jsx)(x.NI,{children:(0,n.jsxs)(l.i4,{className:"w-[200px]",children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(A.u,{className:"h-4 w-4 mr-2 inline"}),"At"]}),(0,n.jsx)(l.ki,{placeholder:""})]})}),(0,n.jsx)(l.Bw,{children:ee.map(e=>(0,n.jsx)(l.Ql,{value:e,children:e},e))})]}),(0,n.jsx)(x.zG,{}),o.subject&&(0,n.jsx)(x.zG,{children:null===(t=o.timeRecurrence)||void 0===t?void 0:t.message})]})}}),(0,n.jsx)(x.Wi,{control:e.form.control,name:"queryToRun",render:t=>{var a;let{field:s}=t;return(0,n.jsxs)(x.xJ,{className:"space-y-1",children:[(0,n.jsx)(x.lX,{children:"Instructions"}),(0,n.jsx)(x.pf,{children:"What do you want Khoj to do?"}),e.create&&(0,n.jsx)("div",{children:c.map(e=>{var t;return t=s.onChange,(0,n.jsxs)(i.z,{className:"text-xs bg-slate-50 dark:bg-slate-950 h-auto p-1.5 m-1 rounded-full",variant:"ghost",onClick:a=>{a.preventDefault(),t({target:{value:e}},a)},children:[e,"..."]},e)})}),(0,n.jsx)(x.NI,{children:(0,n.jsx)(y.g,{placeholder:"Create a summary of the latest news about AI in healthcare.",value:s.value,onChange:s.onChange})}),(0,n.jsx)(x.zG,{}),o.subject&&(0,n.jsx)(x.zG,{children:null===(a=o.queryToRun)||void 0===a?void 0:a.message})]})}}),(0,n.jsx)("fieldset",{disabled:s,children:e.isLoggedIn?s?(0,n.jsx)(i.z,{type:"submit",disabled:!0,children:"Saving..."}):(0,n.jsx)(i.z,{type:"submit",children:"Save"}):(0,n.jsx)(i.z,{onClick:t=>{t.preventDefault(),e.setShowLoginPrompt(!0)},variant:"default",children:"Login to Save"})})]})})}function eh(e){return e.isMobileWidth?(0,n.jsxs)(V.dy,{open:e.isCreating,onOpenChange:t=>{e.setIsCreating(t)},children:[(0,n.jsx)(V.Qz,{asChild:!0,children:(0,n.jsxs)(i.z,{className:"shadow-sm justify-start",variant:"outline",children:[(0,n.jsx)(L.v,{className:"h-4 w-4 mr-2"}),e.callToAction]})}),(0,n.jsxs)(V.sc,{className:"p-2",children:[(0,n.jsx)(V.iI,{children:"Automation"}),(0,n.jsx)(eu,{createNew:e.createNew,automation:e.automation,setIsEditing:e.setIsCreating,isLoggedIn:!!e.authenticatedData,authenticatedData:e.authenticatedData,setShowLoginPrompt:e.setShowLoginPrompt,setUpdatedAutomationData:e.setNewAutomationData,locationData:e.ipLocationData})]})]}):(0,n.jsxs)(g.Vq,{open:e.isCreating,onOpenChange:t=>{e.setIsCreating(t)},children:[(0,n.jsx)(g.hg,{asChild:!0,children:(0,n.jsxs)(i.z,{className:"shadow-sm justify-start",variant:"outline",children:[(0,n.jsx)(L.v,{className:"h-4 w-4 mr-2"}),e.callToAction]})}),(0,n.jsxs)(g.cZ,{className:"max-h-[98vh] overflow-y-auto",children:[(0,n.jsx)(j.$N,{children:"Automation"}),(0,n.jsx)(eu,{automation:e.automation,createNew:e.createNew,setIsEditing:e.setIsCreating,isLoggedIn:!!e.authenticatedData,authenticatedData:e.authenticatedData,setShowLoginPrompt:e.setShowLoginPrompt,setUpdatedAutomationData:e.setNewAutomationData,locationData:e.ipLocationData})]})]})}function ef(){let e=(0,W.GW)(),{data:t,error:a,isLoading:o}=(0,s.ZP)(e?"automations":null,G,{revalidateOnFocus:!1}),[l,c]=(0,f.useState)(!1),[d,u]=(0,f.useState)(null),[m,h]=(0,f.useState)([]),[x,p]=(0,f.useState)([]),[g,j]=(0,f.useState)(!1),y=(0,w.IC)(),v=(0,w.k6)();return((0,f.useEffect)(()=>{d&&(h([...m,d]),u(null))},[d,m]),(0,f.useEffect)(()=>{let e=t?t.concat(m):m;e&&p(eo.filter(t=>void 0===e.find(e=>t.subject===e.subject)))},[t,m]),a)?(0,n.jsx)(r.l,{message:"Oops, something went wrong. Please refresh the page."}):(0,n.jsx)("main",{className:"w-full mx-auto",children:(0,n.jsxs)("div",{className:"grid w-full mx-auto",children:[(0,n.jsx)("div",{className:"".concat(b().sidePanel," top-0"),children:(0,n.jsx)(B.ZP,{conversationId:null,uploadedFiles:[],isMobileWidth:y})}),(0,n.jsxs)("div",{className:"".concat(b().pageLayout," w-full"),children:[(0,n.jsxs)("div",{className:"pt-6 md:pt-8 grid gap-1 md:flex md:justify-between",children:[(0,n.jsx)("h1",{className:"text-3xl flex items-center",children:"Automations"}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2 items-center justify-start",children:[e?(0,n.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,n.jsx)(T.w,{className:"h-4 w-4 mr-2 inline text-orange-500 shadow-sm"}),e.email]}):null,v&&(0,n.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,n.jsx)(z.x,{className:"h-4 w-4 mr-2 inline text-purple-500"}),v?"".concat(v.city,", ").concat(v.country):"Unknown"]}),v&&(0,n.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,n.jsx)(P.S,{className:"h-4 w-4 mr-2 inline text-green-500"}),v?"".concat(v.timezone):"Unknown"]})]})]}),g&&(0,n.jsx)(q.Z,{loginRedirectMessage:"Create an account to make your own automation",onOpenChange:j}),(0,n.jsx)(F.bZ,{className:"bg-secondary border-none my-4",children:(0,n.jsxs)(F.X,{children:[(0,n.jsx)(O.B,{weight:"fill",className:"h-4 w-4 text-purple-400 inline"}),(0,n.jsx)("span",{className:"font-bold",children:"How it works"})," Automations help you structure your time by automating tasks you do regularly. Build your own, or try out our presets. Get results straight to your inbox."]})}),(0,n.jsxs)("div",{className:"flex justify-between items-center py-4",children:[(0,n.jsx)("h3",{className:"text-xl",children:"Your Creations"}),e?(0,n.jsx)(eh,{isMobileWidth:y,callToAction:"Create Automation",createNew:!0,setIsCreating:c,setShowLoginPrompt:j,setNewAutomationData:u,authenticatedData:e,isCreating:l,ipLocationData:v}):(0,n.jsxs)(i.z,{className:"shadow-sm",onClick:()=>j(!0),variant:"outline",children:[(0,n.jsx)(L.v,{className:"h-4 w-4 mr-2"}),"Create Automation"]})]}),(0,n.jsx)(f.Suspense,{children:(0,n.jsx)(ec,{isMobileWidth:y,authenticatedData:e,locationData:v,isLoggedIn:!!e,setShowLoginPrompt:j,setNewAutomationData:u})}),(!t||0===t.length)&&0==m.length&&!o&&(0,n.jsxs)("div",{className:"px-4",children:["So empty! Create your own automation to get started.",(0,n.jsx)("div",{className:"mt-4",children:e?(0,n.jsx)(eh,{isMobileWidth:y,callToAction:"Design Automation",createNew:!0,setIsCreating:c,setShowLoginPrompt:j,setNewAutomationData:u,authenticatedData:e,isCreating:l,ipLocationData:v}):(0,n.jsx)(i.z,{onClick:()=>j(!0),variant:"default",children:"Design"})})]}),o&&(0,n.jsx)(r.l,{message:"booting up your automations"}),(0,n.jsxs)("div",{className:"".concat(b().automationsLayout),children:[t&&t.map(t=>(0,n.jsx)(el,{isMobileWidth:y,authenticatedData:e,automation:t,locationData:v,isLoggedIn:!!e,setShowLoginPrompt:j},t.id)),m.map(t=>(0,n.jsx)(el,{isMobileWidth:y,authenticatedData:e,automation:t,locationData:v,isLoggedIn:!!e,setShowLoginPrompt:j},t.id))]}),(0,n.jsx)("h3",{className:"text-xl py-4",children:"Try these out"}),(0,n.jsx)("div",{className:"".concat(b().automationsLayout),children:x.map(t=>(0,n.jsx)(el,{isMobileWidth:y,setNewAutomationData:u,authenticatedData:e,automation:t,locationData:v,isLoggedIn:!!e,setShowLoginPrompt:j,suggestedCard:!0},t.id))})]})]})})}},66820:function(e,t,a){"use strict";a.d(t,{Z:function(){return o}});var n=a(57437),s=a(6780),r=a(87138);function o(e){return(0,n.jsx)(s.aR,{open:!0,onOpenChange:e.onOpenChange,children:(0,n.jsxs)(s._T,{children:[(0,n.jsx)(s.fY,{children:(0,n.jsx)(s.f$,{children:"Sign in to Khoj to continue"})}),(0,n.jsxs)(s.yT,{children:[e.loginRedirectMessage,". By logging in, you agree to our"," ",(0,n.jsx)(r.default,{href:"https://khoj.dev/terms-of-service",children:"Terms of Service."})]}),(0,n.jsxs)(s.xo,{children:[(0,n.jsx)(s.le,{children:"Dismiss"}),(0,n.jsx)(s.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>{window.location.href="/login?next=".concat(encodeURIComponent(window.location.pathname))},children:(0,n.jsxs)(r.default,{href:"/login?next=".concat(encodeURIComponent(window.location.pathname)),children:[" ","Login"]})})]})]})})}},18642:function(e,t,a){"use strict";a.d(t,{Z:function(){return c}});var n=a(57437),s=a(90837),r=a(50495),o=a(83102),i=a(67135),l=a(34797);function c(e){var t;return(0,n.jsxs)(s.Vq,{children:[(0,n.jsx)(s.hg,{asChild:!0,onClick:e.onShare,children:(0,n.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,n.jsx)(l.m,{className:"w-4 h-4 mr-2"}),e.buttonTitle]})}),(0,n.jsxs)(s.cZ,{children:[(0,n.jsxs)(s.fK,{children:[(0,n.jsx)(s.$N,{children:e.title}),(0,n.jsx)(s.Be,{children:e.description})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,n.jsxs)("div",{className:"grid flex-1 gap-2",children:[(0,n.jsx)(i._,{htmlFor:"link",className:"sr-only",children:"Link"}),(0,n.jsx)(o.I,{id:"link",defaultValue:e.url,readOnly:!0})]}),(0,n.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,n.jsx)("span",{children:"Copy"})})]})]})]})}},47412:function(e,t,a){"use strict";a.d(t,{X:function(){return c},bZ:function(){return l}});var n=a(57437),s=a(2265),r=a(12218),o=a(37440);let i=(0,r.j)("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),l=s.forwardRef((e,t)=>{let{className:a,variant:s,...r}=e;return(0,n.jsx)("div",{ref:t,role:"alert",className:(0,o.cn)(i({variant:s}),a),...r})});l.displayName="Alert",s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)("h5",{ref:t,className:(0,o.cn)("mb-1 font-medium leading-none tracking-tight",a),...s})}).displayName="AlertTitle";let c=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)("div",{ref:t,className:(0,o.cn)("text-sm [&_p]:leading-relaxed",a),...s})});c.displayName="AlertDescription"},32653:function(e,t,a){"use strict";a.d(t,{NI:function(){return p},Wi:function(){return u},l0:function(){return c},lX:function(){return x},pf:function(){return g},xJ:function(){return f},zG:function(){return j}});var n=a(57437),s=a(2265),r=a(71538),o=a(39343),i=a(37440),l=a(67135);let c=o.RV,d=s.createContext({}),u=e=>{let{...t}=e;return(0,n.jsx)(d.Provider,{value:{name:t.name},children:(0,n.jsx)(o.Qr,{...t})})},m=()=>{let e=s.useContext(d),t=s.useContext(h),{getFieldState:a,formState:n}=(0,o.Gc)(),r=a(e.name,n);if(!e)throw Error("useFormField should be used within <FormField>");let{id:i}=t;return{id:i,name:e.name,formItemId:"".concat(i,"-form-item"),formDescriptionId:"".concat(i,"-form-item-description"),formMessageId:"".concat(i,"-form-item-message"),...r}},h=s.createContext({}),f=s.forwardRef((e,t)=>{let{className:a,...r}=e,o=s.useId();return(0,n.jsx)(h.Provider,{value:{id:o},children:(0,n.jsx)("div",{ref:t,className:(0,i.cn)("space-y-2",a),...r})})});f.displayName="FormItem";let x=s.forwardRef((e,t)=>{let{className:a,...s}=e,{error:r,formItemId:o}=m();return(0,n.jsx)(l._,{ref:t,className:(0,i.cn)(r&&"text-destructive",a),htmlFor:o,...s})});x.displayName="FormLabel";let p=s.forwardRef((e,t)=>{let{...a}=e,{error:s,formItemId:o,formDescriptionId:i,formMessageId:l}=m();return(0,n.jsx)(r.g7,{ref:t,id:o,"aria-describedby":s?"".concat(i," ").concat(l):"".concat(i),"aria-invalid":!!s,...a})});p.displayName="FormControl";let g=s.forwardRef((e,t)=>{let{className:a,...s}=e,{formDescriptionId:r}=m();return(0,n.jsx)("p",{ref:t,id:r,className:(0,i.cn)("text-sm text-muted-foreground",a),...s})});g.displayName="FormDescription";let j=s.forwardRef((e,t)=>{let{className:a,children:s,...r}=e,{error:o,formMessageId:l}=m(),c=o?String(null==o?void 0:o.message):s;return c?(0,n.jsx)("p",{ref:t,id:l,className:(0,i.cn)("text-sm font-medium text-destructive",a),...r,children:c}):null});j.displayName="FormMessage"},67135:function(e,t,a){"use strict";a.d(t,{_:function(){return c}});var n=a(57437),s=a(2265),r=a(38364),o=a(12218),i=a(37440);let l=(0,o.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.f,{ref:t,className:(0,i.cn)(l(),a),...s})});c.displayName=r.f.displayName},46294:function(e,t,a){"use strict";a.d(t,{Bw:function(){return x},Ph:function(){return d},Ql:function(){return p},i4:function(){return m},ki:function(){return u}});var n=a(57437),s=a(2265),r=a(77539),o=a(42421),i=a(14392),l=a(22468),c=a(37440);let d=r.fC;r.ZA;let u=r.B4,m=s.forwardRef((e,t)=>{let{className:a,children:s,...i}=e;return(0,n.jsxs)(r.xz,{ref:t,className:(0,c.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),...i,children:[s,(0,n.jsx)(r.JO,{asChild:!0,children:(0,n.jsx)(o.Z,{className:"h-4 w-4 opacity-50"})})]})});m.displayName=r.xz.displayName;let h=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.u_,{ref:t,className:(0,c.cn)("flex cursor-default items-center justify-center py-1",a),...s,children:(0,n.jsx)(i.Z,{className:"h-4 w-4"})})});h.displayName=r.u_.displayName;let f=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.$G,{ref:t,className:(0,c.cn)("flex cursor-default items-center justify-center py-1",a),...s,children:(0,n.jsx)(o.Z,{className:"h-4 w-4"})})});f.displayName=r.$G.displayName;let x=s.forwardRef((e,t)=>{let{className:a,children:s,position:o="popper",...i}=e;return(0,n.jsx)(r.h_,{children:(0,n.jsxs)(r.VY,{ref:t,className:(0,c.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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","popper"===o&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",a),position:o,...i,children:[(0,n.jsx)(h,{}),(0,n.jsx)(r.l_,{className:(0,c.cn)("p-1","popper"===o&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),(0,n.jsx)(f,{})]})})});x.displayName=r.VY.displayName,s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.__,{ref:t,className:(0,c.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...s})}).displayName=r.__.displayName;let p=s.forwardRef((e,t)=>{let{className:a,children:s,...o}=e;return(0,n.jsxs)(r.ck,{ref:t,className:(0,c.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...o,children:[(0,n.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,n.jsx)(r.wU,{children:(0,n.jsx)(l.Z,{className:"h-4 w-4"})})}),(0,n.jsx)(r.eT,{children:s})]})});p.displayName=r.ck.displayName,s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.Z0,{ref:t,className:(0,c.cn)("-mx-1 my-1 h-px bg-muted",a),...s})}).displayName=r.Z0.displayName},93146:function(e,t,a){"use strict";a.d(t,{g:function(){return o}});var n=a(57437),s=a(2265),r=a(37440);let o=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)("textarea",{className:(0,r.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,...s})});o.displayName="Textarea"},50151:function(e,t,a){"use strict";a.d(t,{FN:function(){return m},Mi:function(){return x},VW:function(){return c},_i:function(){return d},gD:function(){return h},lj:function(){return p},sA:function(){return f}});var n=a(57437),s=a(2265),r=a(44504),o=a(12218),i=a(74697),l=a(37440);let c=r.zt,d=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.l_,{ref:t,className:(0,l.cn)("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",a),...s})});d.displayName=r.l_.displayName;let u=(0,o.j)("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),m=s.forwardRef((e,t)=>{let{className:a,variant:s,...o}=e;return(0,n.jsx)(r.fC,{ref:t,className:(0,l.cn)(u({variant:s}),a),...o})});m.displayName=r.fC.displayName;let h=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.aU,{ref:t,className:(0,l.cn)("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",a),...s})});h.displayName=r.aU.displayName;let f=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.x8,{ref:t,className:(0,l.cn)("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",a),"toast-close":"",...s,children:(0,n.jsx)(i.Z,{className:"h-4 w-4"})})});f.displayName=r.x8.displayName;let x=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.Dx,{ref:t,className:(0,l.cn)("text-sm font-semibold",a),...s})});x.displayName=r.Dx.displayName;let p=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.dk,{ref:t,className:(0,l.cn)("text-sm opacity-90",a),...s})});p.displayName=r.dk.displayName},35657:function(e,t,a){"use strict";a.d(t,{pm:function(){return m}});var n=a(2265);let s=0,r=new Map,o=e=>{if(r.has(e))return;let t=setTimeout(()=>{r.delete(e),d({type:"REMOVE_TOAST",toastId:e})},1e6);r.set(e,t)},i=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{let{toastId:a}=t;return a?o(a):e.toasts.forEach(e=>{o(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===a||void 0===a?{...e,open:!1}:e)}}case"REMOVE_TOAST":if(void 0===t.toastId)return{...e,toasts:[]};return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},l=[],c={toasts:[]};function d(e){c=i(c,e),l.forEach(e=>{e(c)})}function u(e){let{...t}=e,a=(s=(s+1)%Number.MAX_SAFE_INTEGER).toString(),n=()=>d({type:"DISMISS_TOAST",toastId:a});return d({type:"ADD_TOAST",toast:{...t,id:a,open:!0,onOpenChange:e=>{e||n()}}}),{id:a,dismiss:n,update:e=>d({type:"UPDATE_TOAST",toast:{...e,id:a}})}}function m(){let[e,t]=n.useState(c);return n.useEffect(()=>(l.push(t),()=>{let e=l.indexOf(t);e>-1&&l.splice(e,1)}),[e]),{...e,toast:u,dismiss:e=>d({type:"DISMISS_TOAST",toastId:e})}}},23611:function(e){e.exports={automationsLayout:"automations_automationsLayout__Atoh_",automationCard:"automations_automationCard__BKidA",pageLayout:"automations_pageLayout__OaoYA",sidePanel:"automations_sidePanel__MPciO"}}},function(e){e.O(0,[9427,9001,3062,4504,51,477,1603,2971,7023,1744],function(){return e(e.s=2743)}),_N_E=e.O()}]);
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4371],{2743:function(e,t,a){Promise.resolve().then(a.bind(a,19648))},19648:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return ef}});var n=a(57437),s=a(29039),r=a(58485),o=a(36013),i=a(50495),l=a(46294),c=a(18760),d=a.n(c),u=a(31014),m=a(39343),h=a(59772),f=a(2265),x=a(32653),p=a(83102),g=a(90837),j=a(13304),y=a(93146),w=a(69591),v=a(23611),b=a.n(v),N=a(18642),D=a(16463),C=a(19573),k=a(20319),S=a(22049),_=a(55362),I=a(13537),A=a(76082),M=a(52674),R=a(23751),T=a(83522),z=a(8837),P=a(21819),L=a(35418),O=a(64945),W=a(79306),q=a(66820),E=a(35657),U=a(50151),F=a(47412),B=a(48861),V=a(7951);let G=()=>window.fetch("/api/automations").then(e=>e.json()).catch(e=>console.log(e));function Z(e){let t=e.split(" "),a=t[2],n=t[4];return"*"===a&&"*"===n?"Day":"*"!==n?"Week":"*"!==a?"Month":"Day"}function J(e){let t=e.split(" ");if("*"===t[3]&&"*"!==t[4])return Number(t[4])}function Q(e){let t=e.split(" "),a=t[1],n=t[0],s=Number(a)>=12?"PM":"AM",r=Number(a)>12?Number(a)-12:a;"00"===r&&(r="12");let o=n;return 10>Number(o)&&"00"!==o&&(o="0".concat(o)),"".concat(r,":").concat(o," ").concat(s)}function X(e){return String(e.split(" ")[2])}function Y(e){return d().toString(e)}let $=["Day","Week","Month"],H=Array.from({length:31},(e,t)=>String(t+1)),K=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ee=[],et=["AM","PM"];for(var ea=0;ea<et.length;ea++)for(var en=0;en<12;en++)for(var es=0;es<60;es+=15){let e=String(es).padStart(2,"0"),t=0===en?12:en;ee.push("".concat(t,":").concat(e," ").concat(et[ea]))}let er=Date.now(),eo=[{subject:"Weekly Newsletter",query_to_run:"Compile a message including: 1. A recap of news from last week 2. An at-home workout I can do before work 3. A quote to inspire me for the week ahead",schedule:"9AM every Monday",next:"Next run at 9AM on Monday",crontime:"0 9 * * 1",id:er,scheduling_request:""},{subject:"Daily Bedtime Story",query_to_run:"Compose a bedtime story that a five-year-old might enjoy. It should not exceed five paragraphs. Appeal to the imagination, but weave in learnings.",schedule:"9PM every night",next:"Next run at 9PM today",crontime:"0 21 * * *",id:er+1,scheduling_request:""},{subject:"Front Page of Hacker News",query_to_run:"Summarize the top 5 posts from https://news.ycombinator.com/best and share them with me, including links",schedule:"9PM on every Wednesday",next:"Next run at 9PM on Wednesday",crontime:"0 21 * * 3",id:er+2,scheduling_request:""},{subject:"Market Summary",query_to_run:"Get the market summary for today and share it with me. Focus on tech stocks and the S&P 500.",schedule:"9AM on every weekday",next:"Next run at 9AM on Monday",crontime:"0 9 * * *",id:er+3,scheduling_request:""},{subject:"Market Crash Notification",query_to_run:"Notify me if the stock market fell by more than 5% today.",schedule:"5PM every evening",next:"Next run at 5PM today",crontime:"0 17 * * *",id:er+5,scheduling_request:""},{subject:"Round-up of research papers about AI in healthcare",query_to_run:"Summarize the top 3 research papers about AI in healthcare that were published in the last week. Include links to the full papers.",schedule:"9AM every Friday",next:"Next run at 9AM on Friday",crontime:"0 9 * * 5",id:er+4,scheduling_request:""}];function ei(e){let t=encodeURIComponent(e.subject),a=encodeURIComponent(e.query_to_run),n=encodeURIComponent(e.crontime);return"".concat(window.location.origin,"/automations?subject=").concat(t,"&query=").concat(a,"&crontime=").concat(n)}function el(e){let[t,a]=(0,f.useState)(!1),[s,r]=(0,f.useState)(null),[l,c]=(0,f.useState)(!1),[d,u]=(0,f.useState)(""),{toast:m}=(0,E.pm)(),h=e.automation,[x,p]=(0,f.useState)(""),[g,j]=(0,f.useState)("");return((0,f.useEffect)(()=>{let e=s||h;p(Q(e.crontime));let t=Z(e.crontime);if("Day"===t)j("Daily");else if("Week"===t){let t=J(e.crontime);void 0===t?j("Weekly"):j("".concat(K[t]))}else if("Month"===t){let t=X(e.crontime);j("Monthly on the ".concat(t))}},[s,h]),(0,f.useEffect)(()=>{let e="Automation: ".concat((null==s?void 0:s.subject)||h.subject);d&&(m({title:e,description:d,action:(0,n.jsx)(U.gD,{altText:"Dismiss",children:"Ok"})}),u(""))},[d,s,h,m]),l)?null:(0,n.jsxs)(o.Zb,{className:"bg-secondary h-full shadow-sm rounded-lg bg-gradient-to-b from-background to-slate-50 dark:to-gray-950 border ".concat(b().automationCard),children:[(0,n.jsx)(o.Ol,{children:(0,n.jsxs)(o.ll,{className:"line-clamp-2 leading-normal flex justify-between",children:[(null==s?void 0:s.subject)||h.subject,(0,n.jsxs)(C.J2,{children:[(0,n.jsx)(C.xo,{asChild:!0,children:(0,n.jsx)(i.z,{className:"bg-background",variant:"ghost",children:(0,n.jsx)(k.F,{className:"h-4 w-4"})})}),(0,n.jsxs)(C.yk,{className:"w-auto grid gap-2 text-left bg-secondary",children:[!e.suggestedCard&&e.locationData&&(0,n.jsx)(eh,{isMobileWidth:e.isMobileWidth,callToAction:"Edit",createNew:!1,setIsCreating:a,setShowLoginPrompt:e.setShowLoginPrompt,setNewAutomationData:r,authenticatedData:e.authenticatedData,isCreating:t,automation:s||h,ipLocationData:e.locationData}),(0,n.jsx)(N.Z,{buttonTitle:"Share",includeIcon:!0,buttonClassName:"justify-start px-4 py-2 h-10",buttonVariant:"outline",title:"Share Automation",description:"Copy the link below and share it with your coworkers or friends.",url:ei(h),onShare:()=>{navigator.clipboard.writeText(ei(h))}}),!e.suggestedCard&&(0,n.jsxs)(i.z,{variant:"outline",className:"justify-start",onClick:()=>{!function(e,t){fetch("/api/trigger/automation?automation_id=".concat(e),{method:"POST"}).then(e=>{if(!e.ok)throw Error("Network response was not ok");return e}).then(e=>{t("Automation triggered. Check your inbox in a few minutes!")}).catch(e=>{t("Sorry, something went wrong. Try again later.")})}(h.id.toString(),u)},children:[(0,n.jsx)(S.s,{className:"h-4 w-4 mr-2"}),"Run Now"]}),(0,n.jsxs)(i.z,{variant:"destructive",className:"justify-start",onClick:()=>{if(e.suggestedCard){c(!0);return}!function(e,t){fetch("/api/automation?automation_id=".concat(e),{method:"DELETE"}).then(e=>e.json()).then(e=>{t(!0)})}(h.id.toString(),c)},children:[(0,n.jsx)(_.r,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})}),(0,n.jsx)(o.aY,{className:"text-secondary-foreground break-all",children:(null==s?void 0:s.query_to_run)||h.query_to_run}),(0,n.jsxs)(o.eW,{className:"flex flex-col items-start md:flex-row md:justify-between md:items-center gap-2",children:[(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)("div",{className:"flex items-center bg-blue-50 rounded-lg p-1.5 border-blue-200 border dark:bg-blue-800 dark:border-blue-500",children:[(0,n.jsx)(I.T,{className:"h-4 w-4 mr-2 text-blue-700 dark:text-blue-300"}),(0,n.jsx)("div",{className:"text-s text-blue-700 dark:text-blue-300",children:x})]}),(0,n.jsxs)("div",{className:"flex items-center bg-purple-50 rounded-lg p-1.5 border-purple-200 border dark:bg-purple-800 dark:border-purple-500",children:[(0,n.jsx)(A.u,{className:"h-4 w-4 mr-2 text-purple-700 dark:text-purple-300"}),(0,n.jsx)("div",{className:"text-s text-purple-700 dark:text-purple-300",children:g})]})]}),e.suggestedCard&&e.setNewAutomationData&&(0,n.jsx)(eh,{isMobileWidth:e.isMobileWidth,callToAction:"Add",createNew:!0,setIsCreating:a,setShowLoginPrompt:e.setShowLoginPrompt,setNewAutomationData:e.setNewAutomationData,authenticatedData:e.authenticatedData,isCreating:t,automation:h,ipLocationData:e.locationData})]})]})}function ec(e){let t=(0,D.useSearchParams)(),[a,s]=(0,f.useState)(!0),r=t.get("subject"),o=t.get("query"),i=t.get("crontime");if(!r||!o||!i)return null;let l={id:0,subject:decodeURIComponent(r),query_to_run:decodeURIComponent(o),scheduling_request:"",schedule:Y(decodeURIComponent(i)),crontime:decodeURIComponent(i),next:""};return a?(0,n.jsx)(eh,{isMobileWidth:e.isMobileWidth,callToAction:"Shared",createNew:!0,setIsCreating:s,setShowLoginPrompt:e.setShowLoginPrompt,setNewAutomationData:e.setNewAutomationData,authenticatedData:e.authenticatedData,isCreating:a,automation:l,ipLocationData:e.locationData}):null}let ed=h.z.object({subject:h.z.optional(h.z.string()),everyBlah:h.z.string({required_error:"Every is required"}),dayOfWeek:h.z.optional(h.z.number()),dayOfMonth:h.z.optional(h.z.string()),timeRecurrence:h.z.string({required_error:"Time Recurrence is required"}),queryToRun:h.z.string({required_error:"Query to Run is required"})});function eu(e){let t=e.automation,a=(0,m.cI)({resolver:(0,u.F)(ed),defaultValues:{subject:null==t?void 0:t.subject,everyBlah:(null==t?void 0:t.crontime)?Z(t.crontime):"Day",dayOfWeek:(null==t?void 0:t.crontime)?J(t.crontime):void 0,timeRecurrence:(null==t?void 0:t.crontime)?Q(t.crontime):"12:00 PM",dayOfMonth:(null==t?void 0:t.crontime)?X(t.crontime):"1",queryToRun:null==t?void 0:t.query_to_run}});return(0,n.jsx)(em,{authenticatedData:e.authenticatedData,locationData:e.locationData||null,form:a,onSubmit:a=>{let n=function(e,t,a,n){let s="",r=t.split(":")[1].split(" ")[0],o=t.split(":")[1].split(" ")[1],i=Number(t.split(":")[0]),l="PM"===o&&i<12?String(i+12):i;switch(e){case"Day":s="".concat(r," ").concat(l," * * *");break;case"Week":s="".concat(r," ").concat(l," * * ").concat(void 0!==a?7===a?0:a:"*");break;case"Month":s="".concat(r," ").concat(l," ").concat(n," * *")}return s}(a.everyBlah,a.timeRecurrence,a.dayOfWeek,a.dayOfMonth),s="/api/automation?";s+="q=".concat(encodeURIComponent(a.queryToRun)),(null==t?void 0:t.id)&&!e.createNew&&(s+="&automation_id=".concat(encodeURIComponent(t.id))),a.subject&&(s+="&subject=".concat(encodeURIComponent(a.subject))),s+="&crontime=".concat(encodeURIComponent(n)),e.locationData&&e.locationData.city&&(s+="&city=".concat(encodeURIComponent(e.locationData.city))),e.locationData&&e.locationData.region&&(s+="®ion=".concat(encodeURIComponent(e.locationData.region))),e.locationData&&e.locationData.country&&(s+="&country=".concat(encodeURIComponent(e.locationData.country))),e.locationData&&e.locationData.timezone&&(s+="&timezone=".concat(encodeURIComponent(e.locationData.timezone))),fetch(s,{method:e.createNew?"POST":"PUT"}).then(e=>e.json()).then(t=>{e.setIsEditing(!1),e.setUpdatedAutomationData({id:t.id,subject:t.subject||"",query_to_run:t.query_to_run,scheduling_request:t.scheduling_request,schedule:Y(t.crontime),crontime:t.crontime,next:t.next})})},create:e.createNew,isLoggedIn:e.isLoggedIn,setShowLoginPrompt:e.setShowLoginPrompt})}function em(e){var t,a;let[s,r]=(0,f.useState)(!1),{errors:o}=e.form.formState,c=["Make a picture of","Generate a summary of","Create a newsletter of","Notify me when"];return(0,n.jsx)(x.l0,{...e.form,children:(0,n.jsxs)("form",{onSubmit:e.form.handleSubmit(t=>{e.onSubmit(t),r(!0)}),className:"space-y-6",children:[(0,n.jsx)(x.xJ,{className:"space-y-1",children:(0,n.jsxs)(x.pf,{children:["Emails will be sent to this address. Timezone and location data will be used to schedule automations.",e.locationData&&(t=e.locationData,a=e.authenticatedData,(0,n.jsxs)("div",{className:"flex flex-wrap gap-2 items-center justify-start",children:[a?(0,n.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,n.jsx)(T.w,{className:"h-4 w-4 mr-2 inline text-orange-500 shadow-sm"}),a.email]}):null,t&&(0,n.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,n.jsx)(z.x,{className:"h-4 w-4 mr-2 inline text-purple-500"}),t?"".concat(t.city,", ").concat(t.country):"Unknown"]}),t&&(0,n.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,n.jsx)(P.S,{className:"h-4 w-4 mr-2 inline text-green-500"}),t?"".concat(t.timezone):"Unknown"]})]}))]})}),!e.create&&(0,n.jsx)(x.Wi,{control:e.form.control,name:"subject",render:e=>{var t;let{field:a}=e;return(0,n.jsxs)(x.xJ,{className:"space-y-1",children:[(0,n.jsx)(x.lX,{children:"Subject"}),(0,n.jsx)(x.pf,{children:"This is the subject of the email you will receive."}),(0,n.jsx)(x.NI,{children:(0,n.jsx)(p.I,{placeholder:"Digest of Healthcare AI trends",...a})}),(0,n.jsx)(x.zG,{}),o.subject&&(0,n.jsx)(x.zG,{children:null===(t=o.subject)||void 0===t?void 0:t.message})]})}}),(0,n.jsx)(x.Wi,{control:e.form.control,name:"everyBlah",render:e=>{var t;let{field:a}=e;return(0,n.jsxs)(x.xJ,{className:"w-full space-y-1",children:[(0,n.jsx)(x.lX,{children:"Frequency"}),(0,n.jsx)(x.pf,{children:"How often should this automation run?"}),(0,n.jsxs)(l.Ph,{onValueChange:a.onChange,defaultValue:a.value,children:[(0,n.jsx)(x.NI,{children:(0,n.jsxs)(l.i4,{className:"w-[200px]",children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(M.W,{className:"h-4 w-4 mr-2 inline"}),"Every"]}),(0,n.jsx)(l.ki,{placeholder:""})]})}),(0,n.jsx)(l.Bw,{children:$.map(e=>(0,n.jsx)(l.Ql,{value:e,children:e},e))})]}),(0,n.jsx)(x.zG,{}),o.subject&&(0,n.jsx)(x.zG,{children:null===(t=o.everyBlah)||void 0===t?void 0:t.message})]})}}),"Week"===e.form.watch("everyBlah")&&(0,n.jsx)(x.Wi,{control:e.form.control,name:"dayOfWeek",render:e=>{var t;let{field:a}=e;return(0,n.jsxs)(x.xJ,{className:"w-full space-y-1",children:[(0,n.jsx)(x.pf,{children:"Every week, on which day should this automation run?"}),(0,n.jsxs)(l.Ph,{onValueChange:e=>a.onChange(Number(e)),defaultValue:String(a.value),children:[(0,n.jsx)(x.NI,{children:(0,n.jsxs)(l.i4,{className:"w-[200px]",children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(R.n,{className:"h-4 w-4 mr-2 inline"}),"On"]}),(0,n.jsx)(l.ki,{placeholder:""})]})}),(0,n.jsx)(l.Bw,{children:K.map((e,t)=>(0,n.jsx)(l.Ql,{value:String(t),children:e},e))})]}),(0,n.jsx)(x.zG,{}),o.subject&&(0,n.jsx)(x.zG,{children:null===(t=o.dayOfWeek)||void 0===t?void 0:t.message})]})}}),"Month"===e.form.watch("everyBlah")&&(0,n.jsx)(x.Wi,{control:e.form.control,name:"dayOfMonth",render:e=>{var t;let{field:a}=e;return(0,n.jsxs)(x.xJ,{className:"w-full space-y-1",children:[(0,n.jsx)(x.pf,{children:"Every month, on which day should the automation run?"}),(0,n.jsxs)(l.Ph,{onValueChange:a.onChange,defaultValue:a.value,children:[(0,n.jsx)(x.NI,{children:(0,n.jsxs)(l.i4,{className:"w-[200px]",children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(R.n,{className:"h-4 w-4 mr-2 inline"}),"On the"]}),(0,n.jsx)(l.ki,{placeholder:""})]})}),(0,n.jsx)(l.Bw,{children:H.map(e=>(0,n.jsx)(l.Ql,{value:e,children:e},e))})]}),(0,n.jsx)(x.zG,{}),o.subject&&(0,n.jsx)(x.zG,{children:null===(t=o.dayOfMonth)||void 0===t?void 0:t.message})]})}}),("Day"===e.form.watch("everyBlah")||"Week"==e.form.watch("everyBlah")||"Month"==e.form.watch("everyBlah"))&&(0,n.jsx)(x.Wi,{control:e.form.control,name:"timeRecurrence",render:e=>{var t;let{field:a}=e;return(0,n.jsxs)(x.xJ,{className:"w-full space-y-1",children:[(0,n.jsx)(x.lX,{children:"Time"}),(0,n.jsx)(x.pf,{children:"On the days this automation runs, at what time should it run?"}),(0,n.jsxs)(l.Ph,{onValueChange:a.onChange,defaultValue:a.value,children:[(0,n.jsx)(x.NI,{children:(0,n.jsxs)(l.i4,{className:"w-[200px]",children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(A.u,{className:"h-4 w-4 mr-2 inline"}),"At"]}),(0,n.jsx)(l.ki,{placeholder:""})]})}),(0,n.jsx)(l.Bw,{children:ee.map(e=>(0,n.jsx)(l.Ql,{value:e,children:e},e))})]}),(0,n.jsx)(x.zG,{}),o.subject&&(0,n.jsx)(x.zG,{children:null===(t=o.timeRecurrence)||void 0===t?void 0:t.message})]})}}),(0,n.jsx)(x.Wi,{control:e.form.control,name:"queryToRun",render:t=>{var a;let{field:s}=t;return(0,n.jsxs)(x.xJ,{className:"space-y-1",children:[(0,n.jsx)(x.lX,{children:"Instructions"}),(0,n.jsx)(x.pf,{children:"What do you want Khoj to do?"}),e.create&&(0,n.jsx)("div",{children:c.map(e=>{var t;return t=s.onChange,(0,n.jsxs)(i.z,{className:"text-xs bg-slate-50 dark:bg-slate-950 h-auto p-1.5 m-1 rounded-full",variant:"ghost",onClick:a=>{a.preventDefault(),t({target:{value:e}},a)},children:[e,"..."]},e)})}),(0,n.jsx)(x.NI,{children:(0,n.jsx)(y.g,{placeholder:"Create a summary of the latest news about AI in healthcare.",value:s.value,onChange:s.onChange})}),(0,n.jsx)(x.zG,{}),o.subject&&(0,n.jsx)(x.zG,{children:null===(a=o.queryToRun)||void 0===a?void 0:a.message})]})}}),(0,n.jsx)("fieldset",{disabled:s,children:e.isLoggedIn?s?(0,n.jsx)(i.z,{type:"submit",disabled:!0,children:"Saving..."}):(0,n.jsx)(i.z,{type:"submit",children:"Save"}):(0,n.jsx)(i.z,{onClick:t=>{t.preventDefault(),e.setShowLoginPrompt(!0)},variant:"default",children:"Login to Save"})})]})})}function eh(e){return e.isMobileWidth?(0,n.jsxs)(V.dy,{open:e.isCreating,onOpenChange:t=>{e.setIsCreating(t)},children:[(0,n.jsx)(V.Qz,{asChild:!0,children:(0,n.jsxs)(i.z,{className:"shadow-sm justify-start",variant:"outline",children:[(0,n.jsx)(L.v,{className:"h-4 w-4 mr-2"}),e.callToAction]})}),(0,n.jsxs)(V.sc,{className:"p-2",children:[(0,n.jsx)(V.iI,{children:"Automation"}),(0,n.jsx)(eu,{createNew:e.createNew,automation:e.automation,setIsEditing:e.setIsCreating,isLoggedIn:!!e.authenticatedData,authenticatedData:e.authenticatedData,setShowLoginPrompt:e.setShowLoginPrompt,setUpdatedAutomationData:e.setNewAutomationData,locationData:e.ipLocationData})]})]}):(0,n.jsxs)(g.Vq,{open:e.isCreating,onOpenChange:t=>{e.setIsCreating(t)},children:[(0,n.jsx)(g.hg,{asChild:!0,children:(0,n.jsxs)(i.z,{className:"shadow-sm justify-start",variant:"outline",children:[(0,n.jsx)(L.v,{className:"h-4 w-4 mr-2"}),e.callToAction]})}),(0,n.jsxs)(g.cZ,{className:"max-h-[98vh] overflow-y-auto",children:[(0,n.jsx)(j.$N,{children:"Automation"}),(0,n.jsx)(eu,{automation:e.automation,createNew:e.createNew,setIsEditing:e.setIsCreating,isLoggedIn:!!e.authenticatedData,authenticatedData:e.authenticatedData,setShowLoginPrompt:e.setShowLoginPrompt,setUpdatedAutomationData:e.setNewAutomationData,locationData:e.ipLocationData})]})]})}function ef(){let e=(0,W.GW)(),{data:t,error:a,isLoading:o}=(0,s.ZP)(e?"automations":null,G,{revalidateOnFocus:!1}),[l,c]=(0,f.useState)(!1),[d,u]=(0,f.useState)(null),[m,h]=(0,f.useState)([]),[x,p]=(0,f.useState)([]),[g,j]=(0,f.useState)(!1),y=(0,w.IC)(),v=(0,w.k6)();return((0,f.useEffect)(()=>{d&&(h([...m,d]),u(null))},[d,m]),(0,f.useEffect)(()=>{let e=t?t.concat(m):m;e&&p(eo.filter(t=>void 0===e.find(e=>t.subject===e.subject)))},[t,m]),a)?(0,n.jsx)(r.l,{message:"Oops, something went wrong. Please refresh the page."}):(0,n.jsx)("main",{className:"w-full mx-auto",children:(0,n.jsxs)("div",{className:"grid w-full mx-auto",children:[(0,n.jsx)("div",{className:"".concat(b().sidePanel," top-0"),children:(0,n.jsx)(B.ZP,{conversationId:null,uploadedFiles:[],isMobileWidth:y})}),(0,n.jsxs)("div",{className:"".concat(b().pageLayout," w-full"),children:[(0,n.jsxs)("div",{className:"pt-6 md:pt-8 grid gap-1 md:flex md:justify-between",children:[(0,n.jsx)("h1",{className:"text-3xl flex items-center",children:"Automations"}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2 items-center justify-start",children:[e?(0,n.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,n.jsx)(T.w,{className:"h-4 w-4 mr-2 inline text-orange-500 shadow-sm"}),e.email]}):null,v&&(0,n.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,n.jsx)(z.x,{className:"h-4 w-4 mr-2 inline text-purple-500"}),v?"".concat(v.city,", ").concat(v.country):"Unknown"]}),v&&(0,n.jsxs)("span",{className:"rounded-lg text-sm border-secondary border p-1 flex items-center shadow-sm",children:[(0,n.jsx)(P.S,{className:"h-4 w-4 mr-2 inline text-green-500"}),v?"".concat(v.timezone):"Unknown"]})]})]}),g&&(0,n.jsx)(q.Z,{loginRedirectMessage:"Create an account to make your own automation",onOpenChange:j}),(0,n.jsx)(F.bZ,{className:"bg-secondary border-none my-4",children:(0,n.jsxs)(F.X,{children:[(0,n.jsx)(O.B,{weight:"fill",className:"h-4 w-4 text-purple-400 inline"}),(0,n.jsx)("span",{className:"font-bold",children:"How it works"})," Automations help you structure your time by automating tasks you do regularly. Build your own, or try out our presets. Get results straight to your inbox."]})}),(0,n.jsxs)("div",{className:"flex justify-between items-center py-4",children:[(0,n.jsx)("h3",{className:"text-xl",children:"Your Creations"}),e?(0,n.jsx)(eh,{isMobileWidth:y,callToAction:"Create Automation",createNew:!0,setIsCreating:c,setShowLoginPrompt:j,setNewAutomationData:u,authenticatedData:e,isCreating:l,ipLocationData:v}):(0,n.jsxs)(i.z,{className:"shadow-sm",onClick:()=>j(!0),variant:"outline",children:[(0,n.jsx)(L.v,{className:"h-4 w-4 mr-2"}),"Create Automation"]})]}),(0,n.jsx)(f.Suspense,{children:(0,n.jsx)(ec,{isMobileWidth:y,authenticatedData:e,locationData:v,isLoggedIn:!!e,setShowLoginPrompt:j,setNewAutomationData:u})}),(!t||0===t.length)&&0==m.length&&!o&&(0,n.jsxs)("div",{className:"px-4",children:["So empty! Create your own automation to get started.",(0,n.jsx)("div",{className:"mt-4",children:e?(0,n.jsx)(eh,{isMobileWidth:y,callToAction:"Design Automation",createNew:!0,setIsCreating:c,setShowLoginPrompt:j,setNewAutomationData:u,authenticatedData:e,isCreating:l,ipLocationData:v}):(0,n.jsx)(i.z,{onClick:()=>j(!0),variant:"default",children:"Design"})})]}),o&&(0,n.jsx)(r.l,{message:"booting up your automations"}),(0,n.jsxs)("div",{className:"".concat(b().automationsLayout),children:[t&&t.map(t=>(0,n.jsx)(el,{isMobileWidth:y,authenticatedData:e,automation:t,locationData:v,isLoggedIn:!!e,setShowLoginPrompt:j},t.id)),m.map(t=>(0,n.jsx)(el,{isMobileWidth:y,authenticatedData:e,automation:t,locationData:v,isLoggedIn:!!e,setShowLoginPrompt:j},t.id))]}),(0,n.jsx)("h3",{className:"text-xl py-4",children:"Try these out"}),(0,n.jsx)("div",{className:"".concat(b().automationsLayout),children:x.map(t=>(0,n.jsx)(el,{isMobileWidth:y,setNewAutomationData:u,authenticatedData:e,automation:t,locationData:v,isLoggedIn:!!e,setShowLoginPrompt:j,suggestedCard:!0},t.id))})]})]})})}},66820:function(e,t,a){"use strict";a.d(t,{Z:function(){return o}});var n=a(57437),s=a(6780),r=a(87138);function o(e){return(0,n.jsx)(s.aR,{open:!0,onOpenChange:e.onOpenChange,children:(0,n.jsxs)(s._T,{children:[(0,n.jsx)(s.fY,{children:(0,n.jsx)(s.f$,{children:"Sign in to Khoj to continue"})}),(0,n.jsxs)(s.yT,{children:[e.loginRedirectMessage,". By logging in, you agree to our"," ",(0,n.jsx)(r.default,{href:"https://khoj.dev/terms-of-service",children:"Terms of Service."})]}),(0,n.jsxs)(s.xo,{children:[(0,n.jsx)(s.le,{children:"Dismiss"}),(0,n.jsx)(s.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>{window.location.href="/login?next=".concat(encodeURIComponent(window.location.pathname))},children:(0,n.jsxs)(r.default,{href:"/login?next=".concat(encodeURIComponent(window.location.pathname)),children:[" ","Login"]})})]})]})})}},18642:function(e,t,a){"use strict";a.d(t,{Z:function(){return c}});var n=a(57437),s=a(90837),r=a(50495),o=a(83102),i=a(67135),l=a(34797);function c(e){var t;return(0,n.jsxs)(s.Vq,{children:[(0,n.jsx)(s.hg,{asChild:!0,onClick:e.onShare,children:(0,n.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,n.jsx)(l.m,{className:"w-4 h-4 mr-2"}),e.buttonTitle]})}),(0,n.jsxs)(s.cZ,{children:[(0,n.jsxs)(s.fK,{children:[(0,n.jsx)(s.$N,{children:e.title}),(0,n.jsx)(s.Be,{children:e.description})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,n.jsxs)("div",{className:"grid flex-1 gap-2",children:[(0,n.jsx)(i._,{htmlFor:"link",className:"sr-only",children:"Link"}),(0,n.jsx)(o.I,{id:"link",defaultValue:e.url,readOnly:!0})]}),(0,n.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,n.jsx)("span",{children:"Copy"})})]})]})]})}},47412:function(e,t,a){"use strict";a.d(t,{X:function(){return c},bZ:function(){return l}});var n=a(57437),s=a(2265),r=a(12218),o=a(37440);let i=(0,r.j)("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),l=s.forwardRef((e,t)=>{let{className:a,variant:s,...r}=e;return(0,n.jsx)("div",{ref:t,role:"alert",className:(0,o.cn)(i({variant:s}),a),...r})});l.displayName="Alert",s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)("h5",{ref:t,className:(0,o.cn)("mb-1 font-medium leading-none tracking-tight",a),...s})}).displayName="AlertTitle";let c=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)("div",{ref:t,className:(0,o.cn)("text-sm [&_p]:leading-relaxed",a),...s})});c.displayName="AlertDescription"},32653:function(e,t,a){"use strict";a.d(t,{NI:function(){return p},Wi:function(){return u},l0:function(){return c},lX:function(){return x},pf:function(){return g},xJ:function(){return f},zG:function(){return j}});var n=a(57437),s=a(2265),r=a(71538),o=a(39343),i=a(37440),l=a(67135);let c=o.RV,d=s.createContext({}),u=e=>{let{...t}=e;return(0,n.jsx)(d.Provider,{value:{name:t.name},children:(0,n.jsx)(o.Qr,{...t})})},m=()=>{let e=s.useContext(d),t=s.useContext(h),{getFieldState:a,formState:n}=(0,o.Gc)(),r=a(e.name,n);if(!e)throw Error("useFormField should be used within <FormField>");let{id:i}=t;return{id:i,name:e.name,formItemId:"".concat(i,"-form-item"),formDescriptionId:"".concat(i,"-form-item-description"),formMessageId:"".concat(i,"-form-item-message"),...r}},h=s.createContext({}),f=s.forwardRef((e,t)=>{let{className:a,...r}=e,o=s.useId();return(0,n.jsx)(h.Provider,{value:{id:o},children:(0,n.jsx)("div",{ref:t,className:(0,i.cn)("space-y-2",a),...r})})});f.displayName="FormItem";let x=s.forwardRef((e,t)=>{let{className:a,...s}=e,{error:r,formItemId:o}=m();return(0,n.jsx)(l._,{ref:t,className:(0,i.cn)(r&&"text-destructive",a),htmlFor:o,...s})});x.displayName="FormLabel";let p=s.forwardRef((e,t)=>{let{...a}=e,{error:s,formItemId:o,formDescriptionId:i,formMessageId:l}=m();return(0,n.jsx)(r.g7,{ref:t,id:o,"aria-describedby":s?"".concat(i," ").concat(l):"".concat(i),"aria-invalid":!!s,...a})});p.displayName="FormControl";let g=s.forwardRef((e,t)=>{let{className:a,...s}=e,{formDescriptionId:r}=m();return(0,n.jsx)("p",{ref:t,id:r,className:(0,i.cn)("text-sm text-muted-foreground",a),...s})});g.displayName="FormDescription";let j=s.forwardRef((e,t)=>{let{className:a,children:s,...r}=e,{error:o,formMessageId:l}=m(),c=o?String(null==o?void 0:o.message):s;return c?(0,n.jsx)("p",{ref:t,id:l,className:(0,i.cn)("text-sm font-medium text-destructive",a),...r,children:c}):null});j.displayName="FormMessage"},67135:function(e,t,a){"use strict";a.d(t,{_:function(){return c}});var n=a(57437),s=a(2265),r=a(38364),o=a(12218),i=a(37440);let l=(0,o.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.f,{ref:t,className:(0,i.cn)(l(),a),...s})});c.displayName=r.f.displayName},46294:function(e,t,a){"use strict";a.d(t,{Bw:function(){return x},Ph:function(){return d},Ql:function(){return p},i4:function(){return m},ki:function(){return u}});var n=a(57437),s=a(2265),r=a(77539),o=a(42421),i=a(14392),l=a(22468),c=a(37440);let d=r.fC;r.ZA;let u=r.B4,m=s.forwardRef((e,t)=>{let{className:a,children:s,...i}=e;return(0,n.jsxs)(r.xz,{ref:t,className:(0,c.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a),...i,children:[s,(0,n.jsx)(r.JO,{asChild:!0,children:(0,n.jsx)(o.Z,{className:"h-4 w-4 opacity-50"})})]})});m.displayName=r.xz.displayName;let h=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.u_,{ref:t,className:(0,c.cn)("flex cursor-default items-center justify-center py-1",a),...s,children:(0,n.jsx)(i.Z,{className:"h-4 w-4"})})});h.displayName=r.u_.displayName;let f=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.$G,{ref:t,className:(0,c.cn)("flex cursor-default items-center justify-center py-1",a),...s,children:(0,n.jsx)(o.Z,{className:"h-4 w-4"})})});f.displayName=r.$G.displayName;let x=s.forwardRef((e,t)=>{let{className:a,children:s,position:o="popper",...i}=e;return(0,n.jsx)(r.h_,{children:(0,n.jsxs)(r.VY,{ref:t,className:(0,c.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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","popper"===o&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",a),position:o,...i,children:[(0,n.jsx)(h,{}),(0,n.jsx)(r.l_,{className:(0,c.cn)("p-1","popper"===o&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),(0,n.jsx)(f,{})]})})});x.displayName=r.VY.displayName,s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.__,{ref:t,className:(0,c.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",a),...s})}).displayName=r.__.displayName;let p=s.forwardRef((e,t)=>{let{className:a,children:s,...o}=e;return(0,n.jsxs)(r.ck,{ref:t,className:(0,c.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...o,children:[(0,n.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,n.jsx)(r.wU,{children:(0,n.jsx)(l.Z,{className:"h-4 w-4"})})}),(0,n.jsx)(r.eT,{children:s})]})});p.displayName=r.ck.displayName,s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.Z0,{ref:t,className:(0,c.cn)("-mx-1 my-1 h-px bg-muted",a),...s})}).displayName=r.Z0.displayName},93146:function(e,t,a){"use strict";a.d(t,{g:function(){return o}});var n=a(57437),s=a(2265),r=a(37440);let o=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)("textarea",{className:(0,r.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,...s})});o.displayName="Textarea"},50151:function(e,t,a){"use strict";a.d(t,{FN:function(){return m},Mi:function(){return x},VW:function(){return c},_i:function(){return d},gD:function(){return h},lj:function(){return p},sA:function(){return f}});var n=a(57437),s=a(2265),r=a(44504),o=a(12218),i=a(74697),l=a(37440);let c=r.zt,d=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.l_,{ref:t,className:(0,l.cn)("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",a),...s})});d.displayName=r.l_.displayName;let u=(0,o.j)("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),m=s.forwardRef((e,t)=>{let{className:a,variant:s,...o}=e;return(0,n.jsx)(r.fC,{ref:t,className:(0,l.cn)(u({variant:s}),a),...o})});m.displayName=r.fC.displayName;let h=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.aU,{ref:t,className:(0,l.cn)("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",a),...s})});h.displayName=r.aU.displayName;let f=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.x8,{ref:t,className:(0,l.cn)("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",a),"toast-close":"",...s,children:(0,n.jsx)(i.Z,{className:"h-4 w-4"})})});f.displayName=r.x8.displayName;let x=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.Dx,{ref:t,className:(0,l.cn)("text-sm font-semibold",a),...s})});x.displayName=r.Dx.displayName;let p=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(r.dk,{ref:t,className:(0,l.cn)("text-sm opacity-90",a),...s})});p.displayName=r.dk.displayName},35657:function(e,t,a){"use strict";a.d(t,{pm:function(){return m}});var n=a(2265);let s=0,r=new Map,o=e=>{if(r.has(e))return;let t=setTimeout(()=>{r.delete(e),d({type:"REMOVE_TOAST",toastId:e})},1e6);r.set(e,t)},i=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{let{toastId:a}=t;return a?o(a):e.toasts.forEach(e=>{o(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===a||void 0===a?{...e,open:!1}:e)}}case"REMOVE_TOAST":if(void 0===t.toastId)return{...e,toasts:[]};return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},l=[],c={toasts:[]};function d(e){c=i(c,e),l.forEach(e=>{e(c)})}function u(e){let{...t}=e,a=(s=(s+1)%Number.MAX_SAFE_INTEGER).toString(),n=()=>d({type:"DISMISS_TOAST",toastId:a});return d({type:"ADD_TOAST",toast:{...t,id:a,open:!0,onOpenChange:e=>{e||n()}}}),{id:a,dismiss:n,update:e=>d({type:"UPDATE_TOAST",toast:{...e,id:a}})}}function m(){let[e,t]=n.useState(c);return n.useEffect(()=>(l.push(t),()=>{let e=l.indexOf(t);e>-1&&l.splice(e,1)}),[e]),{...e,toast:u,dismiss:e=>d({type:"DISMISS_TOAST",toastId:e})}}},23611:function(e){e.exports={automationsLayout:"automations_automationsLayout__Atoh_",automationCard:"automations_automationCard__BKidA",pageLayout:"automations_pageLayout__OaoYA",sidePanel:"automations_sidePanel__MPciO"}}},function(e){e.O(0,[2734,8918,9001,3062,4504,51,477,1603,2971,7023,1744],function(){return e(e.s=2743)}),_N_E=e.O()}]);
|
@@ -1 +1 @@
|
|
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)(null),[u,h]=(0,i.useState)(!1),[g,f]=(0,i.useState)(null),p=e.setQueryToProcess,x=e.onConversationIdChange;if((0,i.useEffect)(()=>{r&&e.setImage64(encodeURIComponent(r))},[r,e.setImage64]),(0,i.useEffect)(()=>{let t=localStorage.getItem("image");t&&(d(t),e.setImage64(encodeURIComponent(t)),localStorage.removeItem("image"));let s=localStorage.getItem("message");s&&(h(!0),p(s))},[p]),(0,i.useEffect)(()=>{s&&(h(!0),p(s))},[s,p]),(0,i.useEffect)(()=>{t&&(null==x||x(t))},[t,x]),(0,i.useEffect)(()=>{e.streamedMessages&&e.streamedMessages.length>0&&e.streamedMessages[e.streamedMessages.length-1].completed?h(!1):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})}),(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"),children:(0,a.jsx)(m.Z,{agentColor:null==g?void 0:g.color,isLoggedIn:e.isLoggedIn,sendMessage:e=>o(e),sendImage:e=>d(e),sendDisabled:u,chatOptionsData:e.chatOptionsData,conversationId:t,isMobileWidth:e.isMobileWidth,setUploadedFiles:e.setUploadedFiles})})]})}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),[_,y]=(0,i.useState)([]),[w,I]=(0,i.useState)(""),[S,v]=(0,i.useState)(!1),[b,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(""),v(!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)),y([..._])}}}}async function D(){if(localStorage.removeItem("message"),!w||!p)return;let e={q:w,conversation_id:p,stream:!0,...E&&{city:E.city,region:E.region,country:E.country,country_code:E.countryCode,timezone:E.timezone},...B&&{image:B}},t=await fetch("/api/chat?client=web",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});try{await M(t)}catch(s){console.error(s);let e=_.find(e=>!e.completed);if(!e)return;let t=s.message;t.includes("Error in input stream")?e.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?":e.rawResponse="Umm, not sure what just happened. I see this error message: ".concat(t,". Could you try again or dislike this message if the issue persists?"),e.completed=!0,y([..._]),I(""),v(!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(w){let e={rawResponse:"",trainOfThought:[],context:[],onlineContext:{},completed:!1,timestamp:new Date().toISOString(),rawQuery:w||"",uploadedImageData:decodeURIComponent(B)};y(t=>[...t,e]),v(!0)}},[w]),(0,i.useEffect)(()=>{S&&D()},[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:b,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)},setImage64:C})})]})})]})}},16463:function(e,t,s){"use strict";var a=s(71169);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,[
|
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)(null),[u,h]=(0,i.useState)(!1),[g,f]=(0,i.useState)(null),p=e.setQueryToProcess,x=e.onConversationIdChange;if((0,i.useEffect)(()=>{r&&e.setImage64(encodeURIComponent(r))},[r,e.setImage64]),(0,i.useEffect)(()=>{let t=localStorage.getItem("image");t&&(d(t),e.setImage64(encodeURIComponent(t)),localStorage.removeItem("image"));let s=localStorage.getItem("message");s&&(h(!0),p(s))},[p]),(0,i.useEffect)(()=>{s&&(h(!0),p(s))},[s,p]),(0,i.useEffect)(()=>{t&&(null==x||x(t))},[t,x]),(0,i.useEffect)(()=>{e.streamedMessages&&e.streamedMessages.length>0&&e.streamedMessages[e.streamedMessages.length-1].completed?h(!1):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})}),(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"),children:(0,a.jsx)(m.Z,{agentColor:null==g?void 0:g.color,isLoggedIn:e.isLoggedIn,sendMessage:e=>o(e),sendImage:e=>d(e),sendDisabled:u,chatOptionsData:e.chatOptionsData,conversationId:t,isMobileWidth:e.isMobileWidth,setUploadedFiles:e.setUploadedFiles})})]})}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),[_,y]=(0,i.useState)([]),[w,I]=(0,i.useState)(""),[S,v]=(0,i.useState)(!1),[b,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(""),v(!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)),y([..._])}}}}async function D(){if(localStorage.removeItem("message"),!w||!p)return;let e={q:w,conversation_id:p,stream:!0,...E&&{city:E.city,region:E.region,country:E.country,country_code:E.countryCode,timezone:E.timezone},...B&&{image:B}},t=await fetch("/api/chat?client=web",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});try{await M(t)}catch(s){console.error(s);let e=_.find(e=>!e.completed);if(!e)return;let t=s.message;t.includes("Error in input stream")?e.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?":e.rawResponse="Umm, not sure what just happened. I see this error message: ".concat(t,". Could you try again or dislike this message if the issue persists?"),e.completed=!0,y([..._]),I(""),v(!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(w){let e={rawResponse:"",trainOfThought:[],context:[],onlineContext:{},completed:!1,timestamp:new Date().toISOString(),rawQuery:w||"",uploadedImageData:decodeURIComponent(B)};y(t=>[...t,e]),v(!0)}},[w]),(0,i.useEffect)(()=>{S&&D()},[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:b,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)},setImage64:C})})]})})]})}},16463:function(e,t,s){"use strict";var a=s(71169);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,[8918,929,3954,9001,3062,4086,121,3110,4051,1603,9417,9178,9479,2697,2971,7023,1744],function(){return e(e.s=39929)}),_N_E=e.O()}]);
|
@@ -1 +1 @@
|
|
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(89178),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,9427,929,3954,9001,3062,4086,121,4051,1603,9417,9178,2971,7023,1744],function(){return e(e.s=71884)}),_N_E=e.O()}]);
|
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(89178),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,8918,929,3954,9001,3062,4086,121,4051,1603,9417,9178,2971,7023,1744],function(){return e(e.s=71884)}),_N_E=e.O()}]);
|