khoj 1.26.5.dev29__py3-none-any.whl → 1.27.1.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. khoj/configure.py +2 -2
  2. khoj/database/adapters/__init__.py +41 -28
  3. khoj/database/admin.py +2 -0
  4. khoj/database/management/commands/change_default_model.py +182 -0
  5. khoj/database/migrations/0071_subscription_enabled_trial_at_and_more.py +32 -0
  6. khoj/database/migrations/0072_entry_search_model.py +24 -0
  7. khoj/database/models/__init__.py +4 -1
  8. khoj/interface/compiled/404/index.html +1 -1
  9. khoj/interface/compiled/_next/static/chunks/{3423-aad88d6c1f029135.js → 3423-0b533af8bf6ac218.js} +1 -1
  10. khoj/interface/compiled/_next/static/chunks/{3678-ef0d20e267e9f010.js → 7883-b1305ec254213afe.js} +2 -2
  11. khoj/interface/compiled/_next/static/chunks/app/{page-75bbfb564884054b.js → page-bf90ab8e0431b578.js} +1 -1
  12. khoj/interface/compiled/_next/static/chunks/app/settings/page-7a8c382af2a7e870.js +1 -0
  13. khoj/interface/compiled/_next/static/chunks/{webpack-8f4afe09848e24e1.js → webpack-60a713fe80176ab8.js} +1 -1
  14. khoj/interface/compiled/agents/index.html +1 -1
  15. khoj/interface/compiled/agents/index.txt +2 -2
  16. khoj/interface/compiled/automations/index.html +1 -1
  17. khoj/interface/compiled/automations/index.txt +1 -1
  18. khoj/interface/compiled/chat/index.html +1 -1
  19. khoj/interface/compiled/chat/index.txt +2 -2
  20. khoj/interface/compiled/factchecker/index.html +1 -1
  21. khoj/interface/compiled/factchecker/index.txt +2 -2
  22. khoj/interface/compiled/index.html +1 -1
  23. khoj/interface/compiled/index.txt +2 -2
  24. khoj/interface/compiled/search/index.html +1 -1
  25. khoj/interface/compiled/search/index.txt +2 -2
  26. khoj/interface/compiled/settings/index.html +1 -1
  27. khoj/interface/compiled/settings/index.txt +2 -2
  28. khoj/interface/compiled/share/chat/index.html +1 -1
  29. khoj/interface/compiled/share/chat/index.txt +2 -2
  30. khoj/processor/content/text_to_entries.py +4 -2
  31. khoj/processor/conversation/anthropic/anthropic_chat.py +21 -21
  32. khoj/processor/conversation/anthropic/utils.py +51 -1
  33. khoj/processor/conversation/google/utils.py +2 -15
  34. khoj/processor/conversation/prompts.py +1 -1
  35. khoj/processor/conversation/utils.py +39 -1
  36. khoj/processor/image/generate.py +2 -1
  37. khoj/routers/api.py +5 -2
  38. khoj/routers/api_model.py +0 -33
  39. khoj/routers/{subscription.py → api_subscription.py} +20 -2
  40. khoj/routers/helpers.py +22 -23
  41. khoj/search_type/text_search.py +6 -2
  42. khoj/utils/helpers.py +1 -1
  43. {khoj-1.26.5.dev29.dist-info → khoj-1.27.1.dev1.dist-info}/METADATA +1 -1
  44. {khoj-1.26.5.dev29.dist-info → khoj-1.27.1.dev1.dist-info}/RECORD +52 -49
  45. khoj/interface/compiled/_next/static/chunks/app/settings/page-989cf38b87b19427.js +0 -1
  46. /khoj/interface/compiled/_next/static/{ZLHCGFLxZSUj0jEJSc99T → _uA36nxS-kekBHGobT8yS}/_buildManifest.js +0 -0
  47. /khoj/interface/compiled/_next/static/{ZLHCGFLxZSUj0jEJSc99T → _uA36nxS-kekBHGobT8yS}/_ssgManifest.js +0 -0
  48. /khoj/interface/compiled/_next/static/chunks/{1970-1d6d0c1b00b4f343.js → 1970-60c96aed937a4928.js} +0 -0
  49. /khoj/interface/compiled/_next/static/chunks/{9417-759984ad62caa3dc.js → 9417-2ca87207387fc790.js} +0 -0
  50. /khoj/interface/compiled/_next/static/chunks/{9479-4b443fdcc99141c9.js → 9479-646dff2911c5d2e1.js} +0 -0
  51. {khoj-1.26.5.dev29.dist-info → khoj-1.27.1.dev1.dist-info}/WHEEL +0 -0
  52. {khoj-1.26.5.dev29.dist-info → khoj-1.27.1.dev1.dist-info}/entry_points.txt +0 -0
  53. {khoj-1.26.5.dev29.dist-info → khoj-1.27.1.dev1.dist-info}/licenses/LICENSE +0 -0
khoj/configure.py CHANGED
@@ -108,7 +108,7 @@ class UserAuthenticationBackend(AuthenticationBackend):
108
108
  password="default",
109
109
  )
110
110
  renewal_date = make_aware(datetime.strptime("2100-04-01", "%Y-%m-%d"))
111
- Subscription.objects.create(user=default_user, type="standard", renewal_date=renewal_date)
111
+ Subscription.objects.create(user=default_user, type=Subscription.Type.STANDARD, renewal_date=renewal_date)
112
112
 
113
113
  async def authenticate(self, request: HTTPConnection):
114
114
  current_user = request.session.get("user")
@@ -312,7 +312,7 @@ def configure_routes(app):
312
312
  logger.info("🔑 Enabled Authentication")
313
313
 
314
314
  if state.billing_enabled:
315
- from khoj.routers.subscription import subscription_router
315
+ from khoj.routers.api_subscription import subscription_router
316
316
 
317
317
  app.include_router(subscription_router, prefix="/api/subscription")
318
318
  logger.info("💳 Enabled Billing")
@@ -70,6 +70,9 @@ from khoj.utils.helpers import (
70
70
  logger = logging.getLogger(__name__)
71
71
 
72
72
 
73
+ LENGTH_OF_FREE_TRIAL = 7 #
74
+
75
+
73
76
  class SubscriptionState(Enum):
74
77
  TRIAL = "trial"
75
78
  SUBSCRIBED = "subscribed"
@@ -168,7 +171,7 @@ async def acreate_user_by_phone_number(phone_number: str) -> KhojUser:
168
171
  )
169
172
  await user.asave()
170
173
 
171
- await Subscription.objects.acreate(user=user, type="trial")
174
+ await Subscription.objects.acreate(user=user, type=Subscription.Type.STANDARD)
172
175
 
173
176
  return user
174
177
 
@@ -185,11 +188,29 @@ async def aget_or_create_user_by_email(email: str) -> tuple[KhojUser, bool]:
185
188
 
186
189
  user_subscription = await Subscription.objects.filter(user=user).afirst()
187
190
  if not user_subscription:
188
- await Subscription.objects.acreate(user=user, type="trial")
191
+ await Subscription.objects.acreate(user=user, type=Subscription.Type.STANDARD)
189
192
 
190
193
  return user, is_new
191
194
 
192
195
 
196
+ async def astart_trial_subscription(user: KhojUser) -> Subscription:
197
+ subscription = await Subscription.objects.filter(user=user).afirst()
198
+ if not subscription:
199
+ raise HTTPException(status_code=400, detail="User does not have a subscription")
200
+
201
+ if subscription.type == Subscription.Type.TRIAL:
202
+ raise HTTPException(status_code=400, detail="User already has a trial subscription")
203
+
204
+ if subscription.enabled_trial_at:
205
+ raise HTTPException(status_code=400, detail="User already has a trial subscription")
206
+
207
+ subscription.type = Subscription.Type.TRIAL
208
+ subscription.enabled_trial_at = datetime.now(tz=timezone.utc)
209
+ subscription.renewal_date = datetime.now(tz=timezone.utc) + timedelta(days=LENGTH_OF_FREE_TRIAL)
210
+ await subscription.asave()
211
+ return subscription
212
+
213
+
193
214
  async def aget_user_validated_by_email_verification_code(code: str) -> KhojUser:
194
215
  user = await KhojUser.objects.filter(email_verification_code=code).afirst()
195
216
  if not user:
@@ -221,7 +242,7 @@ async def create_user_by_google_token(token: dict) -> KhojUser:
221
242
  user=user,
222
243
  )
223
244
 
224
- await Subscription.objects.acreate(user=user, type="trial")
245
+ await Subscription.objects.acreate(user=user, type=Subscription.Type.STANDARD)
225
246
 
226
247
  return user
227
248
 
@@ -279,16 +300,15 @@ def subscription_to_state(subscription: Subscription) -> str:
279
300
  if not subscription:
280
301
  return SubscriptionState.INVALID.value
281
302
  elif subscription.type == Subscription.Type.TRIAL:
282
- # Trial subscription is valid for 7 days
283
- if datetime.now(tz=timezone.utc) - subscription.created_at > timedelta(days=14):
303
+ # Check if the trial has expired
304
+ if subscription.renewal_date and datetime.now(tz=timezone.utc) > subscription.renewal_date:
284
305
  return SubscriptionState.EXPIRED.value
285
-
286
306
  return SubscriptionState.TRIAL.value
287
- elif subscription.is_recurring and subscription.renewal_date >= datetime.now(tz=timezone.utc):
307
+ elif subscription.is_recurring and subscription.renewal_date > datetime.now(tz=timezone.utc):
288
308
  return SubscriptionState.SUBSCRIBED.value
289
309
  elif not subscription.is_recurring and subscription.renewal_date is None:
290
310
  return SubscriptionState.EXPIRED.value
291
- elif not subscription.is_recurring and subscription.renewal_date >= datetime.now(tz=timezone.utc):
311
+ elif not subscription.is_recurring and subscription.renewal_date > datetime.now(tz=timezone.utc):
292
312
  return SubscriptionState.UNSUBSCRIBED.value
293
313
  elif not subscription.is_recurring and subscription.renewal_date < datetime.now(tz=timezone.utc):
294
314
  return SubscriptionState.EXPIRED.value
@@ -446,18 +466,26 @@ async def set_user_github_config(user: KhojUser, pat_token: str, repos: list):
446
466
  return config
447
467
 
448
468
 
449
- def get_user_search_model_or_default(user=None):
450
- if user and UserSearchModelConfig.objects.filter(user=user).exists():
451
- return UserSearchModelConfig.objects.filter(user=user).first().setting
469
+ def get_default_search_model() -> SearchModelConfig:
470
+ default_search_model = SearchModelConfig.objects.filter(name="default").first()
452
471
 
453
- if SearchModelConfig.objects.filter(name="default").exists():
454
- return SearchModelConfig.objects.filter(name="default").first()
472
+ if default_search_model:
473
+ return default_search_model
455
474
  else:
456
475
  SearchModelConfig.objects.create()
457
476
 
458
477
  return SearchModelConfig.objects.first()
459
478
 
460
479
 
480
+ def get_user_default_search_model(user: KhojUser = None) -> SearchModelConfig:
481
+ if user:
482
+ user_search_model = UserSearchModelConfig.objects.filter(user=user).first()
483
+ if user_search_model:
484
+ return user_search_model.setting
485
+
486
+ return get_default_search_model()
487
+
488
+
461
489
  def get_or_create_search_models():
462
490
  search_models = SearchModelConfig.objects.all()
463
491
  if search_models.count() == 0:
@@ -467,21 +495,6 @@ def get_or_create_search_models():
467
495
  return search_models
468
496
 
469
497
 
470
- async def aset_user_search_model(user: KhojUser, search_model_config_id: int):
471
- config = await SearchModelConfig.objects.filter(id=search_model_config_id).afirst()
472
- if not config:
473
- return None
474
- new_config, _ = await UserSearchModelConfig.objects.aupdate_or_create(user=user, defaults={"setting": config})
475
- return new_config
476
-
477
-
478
- async def aget_user_search_model(user: KhojUser):
479
- config = await UserSearchModelConfig.objects.filter(user=user).prefetch_related("setting").afirst()
480
- if not config:
481
- return None
482
- return config.setting
483
-
484
-
485
498
  class ProcessLockAdapters:
486
499
  @staticmethod
487
500
  def get_process_lock(process_name: str):
khoj/database/admin.py CHANGED
@@ -126,6 +126,7 @@ class EntryAdmin(admin.ModelAdmin):
126
126
  "created_at",
127
127
  "updated_at",
128
128
  "user",
129
+ "agent",
129
130
  "file_source",
130
131
  "file_type",
131
132
  "file_name",
@@ -135,6 +136,7 @@ class EntryAdmin(admin.ModelAdmin):
135
136
  list_filter = (
136
137
  "file_type",
137
138
  "user__email",
139
+ "search_model__name",
138
140
  )
139
141
  ordering = ("-created_at",)
140
142
 
@@ -0,0 +1,182 @@
1
+ import logging
2
+ from typing import List
3
+
4
+ from django.core.management.base import BaseCommand
5
+ from django.db import transaction
6
+ from django.db.models import Count, Q
7
+ from tqdm import tqdm
8
+
9
+ from khoj.database.adapters import get_default_search_model
10
+ from khoj.database.models import (
11
+ Agent,
12
+ Entry,
13
+ KhojUser,
14
+ SearchModelConfig,
15
+ UserSearchModelConfig,
16
+ )
17
+ from khoj.processor.embeddings import EmbeddingsModel
18
+
19
+ logging.basicConfig(level=logging.INFO)
20
+ logger = logging.getLogger(__name__)
21
+
22
+
23
+ class Command(BaseCommand):
24
+ help = "Convert all existing Entry objects to use a new default Search model."
25
+
26
+ def add_arguments(self, parser):
27
+ # Pass default SearchModelConfig ID
28
+ parser.add_argument(
29
+ "--search_model_id",
30
+ action="store",
31
+ help="ID of the SearchModelConfig object to set as the default search model for all existing Entry objects and UserSearchModelConfig objects.",
32
+ required=True,
33
+ )
34
+
35
+ # Set the apply flag to apply the new default Search model to all existing Entry objects and UserSearchModelConfig objects.
36
+ parser.add_argument(
37
+ "--apply",
38
+ action="store_true",
39
+ help="Apply the new default Search model to all existing Entry objects and UserSearchModelConfig objects. Otherwise, only display the number of Entry objects and UserSearchModelConfig objects that will be affected.",
40
+ )
41
+
42
+ def handle(self, *args, **options):
43
+ @transaction.atomic
44
+ def regenerate_entries(entry_filter: Q, embeddings_model: EmbeddingsModel, search_model: SearchModelConfig):
45
+ entries = Entry.objects.filter(entry_filter).all()
46
+ compiled_entries = [entry.compiled for entry in entries]
47
+ updated_entries: List[Entry] = []
48
+ try:
49
+ embeddings = embeddings_model.embed_documents(compiled_entries)
50
+
51
+ except Exception as e:
52
+ logger.error(f"Error embedding documents: {e}")
53
+ return
54
+
55
+ for i, entry in enumerate(tqdm(entries)):
56
+ entry.embeddings = embeddings[i]
57
+ entry.search_model_id = search_model.id
58
+ updated_entries.append(entry)
59
+
60
+ Entry.objects.bulk_update(updated_entries, ["embeddings", "search_model_id", "file_path"])
61
+
62
+ search_model_config_id = options.get("search_model_id")
63
+ apply = options.get("apply")
64
+
65
+ logger.info(f"SearchModelConfig ID: {search_model_config_id}")
66
+ logger.info(f"Apply: {apply}")
67
+
68
+ embeddings_model = dict()
69
+
70
+ search_models = SearchModelConfig.objects.all()
71
+ for model in search_models:
72
+ embeddings_model.update(
73
+ {
74
+ model.name: EmbeddingsModel(
75
+ model.bi_encoder,
76
+ model.embeddings_inference_endpoint,
77
+ model.embeddings_inference_endpoint_api_key,
78
+ query_encode_kwargs=model.bi_encoder_query_encode_config,
79
+ docs_encode_kwargs=model.bi_encoder_docs_encode_config,
80
+ model_kwargs=model.bi_encoder_model_config,
81
+ )
82
+ }
83
+ )
84
+
85
+ new_default_search_model_config = SearchModelConfig.objects.get(id=search_model_config_id)
86
+ logger.info(f"New default Search model: {new_default_search_model_config}")
87
+ user_search_model_configs_to_update = UserSearchModelConfig.objects.exclude(
88
+ setting_id=search_model_config_id
89
+ ).all()
90
+ logger.info(f"Number of UserSearchModelConfig objects to update: {user_search_model_configs_to_update.count()}")
91
+
92
+ for user_config in user_search_model_configs_to_update:
93
+ affected_user = user_config.user
94
+ entry_filter = Q(user=affected_user)
95
+ relevant_entries = Entry.objects.filter(entry_filter).all()
96
+ logger.info(f"Number of Entry objects to update for user {affected_user}: {relevant_entries.count()}")
97
+
98
+ if apply:
99
+ try:
100
+ regenerate_entries(
101
+ entry_filter,
102
+ embeddings_model[new_default_search_model_config.name],
103
+ new_default_search_model_config,
104
+ )
105
+ user_config.setting = new_default_search_model_config
106
+ user_config.save()
107
+
108
+ logger.info(
109
+ f"Updated UserSearchModelConfig object for user {affected_user} to use the new default Search model."
110
+ )
111
+ logger.info(
112
+ f"Updated {relevant_entries.count()} Entry objects for user {affected_user} to use the new default Search model."
113
+ )
114
+
115
+ except Exception as e:
116
+ logger.error(f"Error embedding documents: {e}")
117
+
118
+ logger.info("----")
119
+
120
+ # There are also plenty of users who have indexed documents without explicitly creating a UserSearchModelConfig object. You would have to migrate these users as well, if the default is different from search_model_config_id.
121
+ current_default = get_default_search_model()
122
+ if current_default.id != new_default_search_model_config.id:
123
+ users_without_user_search_model_config = KhojUser.objects.annotate(
124
+ user_search_model_config_count=Count("usersearchmodelconfig")
125
+ ).filter(user_search_model_config_count=0)
126
+
127
+ logger.info(f"Number of User objects to update: {users_without_user_search_model_config.count()}")
128
+ for user in users_without_user_search_model_config:
129
+ entry_filter = Q(user=user)
130
+ relevant_entries = Entry.objects.filter(entry_filter).all()
131
+ logger.info(f"Number of Entry objects to update for user {user}: {relevant_entries.count()}")
132
+
133
+ if apply:
134
+ try:
135
+ regenerate_entries(
136
+ entry_filter,
137
+ embeddings_model[new_default_search_model_config.name],
138
+ new_default_search_model_config,
139
+ )
140
+
141
+ UserSearchModelConfig.objects.create(user=user, setting=new_default_search_model_config)
142
+
143
+ logger.info(
144
+ f"Created UserSearchModelConfig object for user {user} to use the new default Search model."
145
+ )
146
+ logger.info(
147
+ f"Updated {relevant_entries.count()} Entry objects for user {user} to use the new default Search model."
148
+ )
149
+ except Exception as e:
150
+ logger.error(f"Error embedding documents: {e}")
151
+ else:
152
+ logger.info("Default is the same as search_model_config_id.")
153
+
154
+ all_agents = Agent.objects.all()
155
+ logger.info(f"Number of Agent objects to update: {all_agents.count()}")
156
+ for agent in all_agents:
157
+ entry_filter = Q(agent=agent)
158
+ relevant_entries = Entry.objects.filter(entry_filter).all()
159
+ logger.info(f"Number of Entry objects to update for agent {agent}: {relevant_entries.count()}")
160
+
161
+ if apply:
162
+ try:
163
+ regenerate_entries(
164
+ entry_filter,
165
+ embeddings_model[new_default_search_model_config.name],
166
+ new_default_search_model_config,
167
+ )
168
+ logger.info(
169
+ f"Updated {relevant_entries.count()} Entry objects for agent {agent} to use the new default Search model."
170
+ )
171
+ except Exception as e:
172
+ logger.error(f"Error embedding documents: {e}")
173
+ if apply and current_default.id != new_default_search_model_config.id:
174
+ # Get the existing default SearchModelConfig object and update its name
175
+ current_default.name = f"prev_default_{current_default.id}"
176
+ current_default.save()
177
+
178
+ # Update the new default SearchModelConfig object's name
179
+ new_default_search_model_config.name = "default"
180
+ new_default_search_model_config.save()
181
+ if not apply:
182
+ logger.info("Run the command with the --apply flag to apply the new default Search model.")
@@ -0,0 +1,32 @@
1
+ # Generated by Django 5.0.8 on 2024-10-20 19:24
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ def set_enabled_trial_at(apps, schema_editor):
7
+ Subscription = apps.get_model("database", "Subscription")
8
+ for subscription in Subscription.objects.all():
9
+ subscription.enabled_trial_at = subscription.created_at
10
+ subscription.save()
11
+
12
+
13
+ class Migration(migrations.Migration):
14
+ dependencies = [
15
+ ("database", "0070_alter_agent_input_tools_alter_agent_output_modes"),
16
+ ]
17
+
18
+ operations = [
19
+ migrations.AddField(
20
+ model_name="subscription",
21
+ name="enabled_trial_at",
22
+ field=models.DateTimeField(blank=True, default=None, null=True),
23
+ ),
24
+ migrations.AlterField(
25
+ model_name="subscription",
26
+ name="type",
27
+ field=models.CharField(
28
+ choices=[("trial", "Trial"), ("standard", "Standard")], default="standard", max_length=20
29
+ ),
30
+ ),
31
+ migrations.RunPython(set_enabled_trial_at),
32
+ ]
@@ -0,0 +1,24 @@
1
+ # Generated by Django 5.0.8 on 2024-10-21 21:09
2
+
3
+ import django.db.models.deletion
4
+ from django.db import migrations, models
5
+
6
+
7
+ class Migration(migrations.Migration):
8
+ dependencies = [
9
+ ("database", "0071_subscription_enabled_trial_at_and_more"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AddField(
14
+ model_name="entry",
15
+ name="search_model",
16
+ field=models.ForeignKey(
17
+ blank=True,
18
+ default=None,
19
+ null=True,
20
+ on_delete=django.db.models.deletion.SET_NULL,
21
+ to="database.searchmodelconfig",
22
+ ),
23
+ ),
24
+ ]
@@ -73,9 +73,10 @@ class Subscription(BaseModel):
73
73
  STANDARD = "standard"
74
74
 
75
75
  user = models.OneToOneField(KhojUser, on_delete=models.CASCADE, related_name="subscription")
76
- type = models.CharField(max_length=20, choices=Type.choices, default=Type.TRIAL)
76
+ type = models.CharField(max_length=20, choices=Type.choices, default=Type.STANDARD)
77
77
  is_recurring = models.BooleanField(default=False)
78
78
  renewal_date = models.DateTimeField(null=True, default=None, blank=True)
79
+ enabled_trial_at = models.DateTimeField(null=True, default=None, blank=True)
79
80
 
80
81
 
81
82
  class OpenAIProcessorConversationConfig(BaseModel):
@@ -448,6 +449,7 @@ class UserVoiceModelConfig(BaseModel):
448
449
  setting = models.ForeignKey(VoiceModelOption, on_delete=models.CASCADE, default=None, null=True, blank=True)
449
450
 
450
451
 
452
+ # TODO Delete this model once all users have been migrated to the server's default settings
451
453
  class UserSearchModelConfig(BaseModel):
452
454
  user = models.OneToOneField(KhojUser, on_delete=models.CASCADE)
453
455
  setting = models.ForeignKey(SearchModelConfig, on_delete=models.CASCADE)
@@ -534,6 +536,7 @@ class Entry(BaseModel):
534
536
  url = models.URLField(max_length=400, default=None, null=True, blank=True)
535
537
  hashed_value = models.CharField(max_length=100)
536
538
  corpus_id = models.UUIDField(default=uuid.uuid4, editable=False)
539
+ search_model = models.ForeignKey(SearchModelConfig, on_delete=models.SET_NULL, default=None, null=True, blank=True)
537
540
 
538
541
  def save(self, *args, **kwargs):
539
542
  if self.user and self.agent:
@@ -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/467a524c75e7d7c0.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/76d55eb435962b19.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-8f4afe09848e24e1.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 &#x27;self&#x27; https://assets.khoj.dev; media-src * blob:; script-src &#x27;self&#x27; https://assets.khoj.dev &#x27;unsafe-inline&#x27; &#x27;unsafe-eval&#x27;; connect-src &#x27;self&#x27; blob: https://ipapi.co/json ws://localhost:42110; style-src &#x27;self&#x27; https://assets.khoj.dev &#x27;unsafe-inline&#x27; https://fonts.googleapis.com; img-src &#x27;self&#x27; data: blob: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src &#x27;self&#x27; https://assets.khoj.dev https://fonts.gstatic.com; child-src &#x27;none&#x27;; object-src &#x27;none&#x27;;"/><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_e594dd"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;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-8f4afe09848e24e1.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/467a524c75e7d7c0.css\",\"style\"]\n3:HL[\"/_next/static/css/76d55eb435962b19.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\":\"ZLHCGFLxZSUj0jEJSc99T\",\"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/467a524c75e7d7c0.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/76d55eb435962b19.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_e594dd\",\"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/467a524c75e7d7c0.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/76d55eb435962b19.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-60a713fe80176ab8.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 &#x27;self&#x27; https://assets.khoj.dev; media-src * blob:; script-src &#x27;self&#x27; https://assets.khoj.dev &#x27;unsafe-inline&#x27; &#x27;unsafe-eval&#x27;; connect-src &#x27;self&#x27; blob: https://ipapi.co/json ws://localhost:42110; style-src &#x27;self&#x27; https://assets.khoj.dev &#x27;unsafe-inline&#x27; https://fonts.googleapis.com; img-src &#x27;self&#x27; data: blob: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src &#x27;self&#x27; https://assets.khoj.dev https://fonts.gstatic.com; child-src &#x27;none&#x27;; object-src &#x27;none&#x27;;"/><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_e594dd"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;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-60a713fe80176ab8.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/467a524c75e7d7c0.css\",\"style\"]\n3:HL[\"/_next/static/css/76d55eb435962b19.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\":\"_uA36nxS-kekBHGobT8yS\",\"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/467a524c75e7d7c0.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/76d55eb435962b19.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_e594dd\",\"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 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3423],{53423:function(e,t,a){"use strict";a.d(t,{H:function(){return en},Z:function(){return er}});var s=a(57437),n=a(34531),l=a.n(n),r=a(14944),o=a(39952),c=a.n(o),i=a(2265),d=a(34040);a(7395);var h=a(26100),u=a(36013),m=a(13304),g=a(12218),p=a(74697),f=a(37440);let x=m.fC,j=m.xz;m.x8;let w=m.h_,b=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(m.aV,{className:(0,f.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...n,ref:t})});b.displayName=m.aV.displayName;let y=(0,g.j)("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),N=i.forwardRef((e,t)=>{let{side:a="right",className:n,children:l,...r}=e;return(0,s.jsxs)(w,{children:[(0,s.jsx)(b,{}),(0,s.jsxs)(m.VY,{ref:t,className:(0,f.cn)(y({side:a}),n),...r,children:[l,(0,s.jsxs)(m.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[(0,s.jsx)(p.Z,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});N.displayName=m.VY.displayName;let k=e=>{let{className:t,...a}=e;return(0,s.jsx)("div",{className:(0,f.cn)("flex flex-col space-y-2 text-center sm:text-left",t),...a})};k.displayName="SheetHeader";let C=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(m.Dx,{ref:t,className:(0,f.cn)("text-lg font-semibold text-foreground",a),...n})});C.displayName=m.Dx.displayName;let M=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(m.dk,{ref:t,className:(0,f.cn)("text-sm text-muted-foreground",a),...n})});M.displayName=m.dk.displayName;var _=a(19573),v=a(11838),R=a.n(v),E=a(89417);let T=new r.Z({html:!0,linkify:!0,typographer:!0});function D(e){let t=(0,E.Le)(e.title||".txt","w-6 h-6 text-muted-foreground inline-flex mr-2"),a=function(e){let t=["org","md","markdown"].includes(e.title.split(".").pop()||"")?e.content.split("\n").slice(1).join("\n"):e.content;return e.showFullContent?R().sanitize(T.render(t)):R().sanitize(t)}(e),[n,l]=(0,i.useState)(!1);return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(_.J2,{open:n&&!e.showFullContent,onOpenChange:l,children:[(0,s.jsx)(_.xo,{asChild:!0,children:(0,s.jsxs)(u.Zb,{onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words text-balance rounded-lg p-2 bg-muted border-none"),children:[(0,s.jsxs)("h3",{className:"".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground}"),children:[t,e.title]}),(0,s.jsx)("p",{className:"".concat(e.showFullContent?"block":"overflow-hidden line-clamp-2"),dangerouslySetInnerHTML:{__html:a}})]})}),(0,s.jsx)(_.yk,{className:"w-[400px] mx-2",children:(0,s.jsxs)(u.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg p-2 border-none",children:[(0,s.jsxs)("h3",{className:"line-clamp-2 text-muted-foreground}",children:[t,e.title]}),(0,s.jsx)("p",{className:"overflow-hidden line-clamp-3",dangerouslySetInnerHTML:{__html:a}})]})})]})})}function L(e){let[t,a]=(0,i.useState)(!1);if(!e.link||e.link.split(" ").length>1)return null;let n="https://www.google.com/s2/favicons?domain=globe",l="unknown";try{l=new URL(e.link).hostname,n="https://www.google.com/s2/favicons?domain=".concat(l)}catch(t){return console.warn("Error parsing domain from link: ".concat(e.link)),null}return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(_.J2,{open:t&&!e.showFullContent,onOpenChange:a,children:[(0,s.jsx)(_.xo,{asChild:!0,children:(0,s.jsx)(u.Zb,{onMouseEnter:()=>{a(!0)},onMouseLeave:()=>{a(!1)},className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words rounded-lg text-balance p-2 bg-muted border-none"),children:(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline p-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("img",{src:n,alt:"",className:"!w-4 h-4 mr-2 flex-shrink-0"}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground flex-grow"),children:l})]}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," font-bold"),children:e.title}),(0,s.jsx)("p",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"),children:e.description})]})})})}),(0,s.jsx)(_.yk,{className:"w-[400px] mx-2",children:(0,s.jsx)(u.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg border-none",children:(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline p-2",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("img",{src:n,alt:"",className:"!w-4 h-4 mr-2"}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," text-muted-foreground"),children:l})]}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," font-bold"),children:e.title}),(0,s.jsx)("p",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-3"),children:e.description})]})})})})]})})}function S(e){let[t,a]=(0,i.useState)(3);(0,i.useEffect)(()=>{a(e.isMobileWidth?1:3)},[e.isMobileWidth]);let n=e.notesReferenceCardData.slice(0,t),l=n.length<t?e.onlineReferenceCardData.slice(0,t-n.length):[],r=e.notesReferenceCardData.length>0||e.onlineReferenceCardData.length>0,o=e.notesReferenceCardData.length+e.onlineReferenceCardData.length;return 0===o?null:(0,s.jsxs)("div",{className:"pt-0 px-4 pb-4 md:px-6",children:[(0,s.jsxs)("h3",{className:"inline-flex items-center",children:["References",(0,s.jsxs)("p",{className:"text-gray-400 m-2",children:[o," sources"]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[n.map((e,t)=>(0,i.createElement)(D,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),l.map((e,t)=>(0,i.createElement)(L,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),r&&(0,s.jsx)(F,{notesReferenceCardData:e.notesReferenceCardData,onlineReferenceCardData:e.onlineReferenceCardData})]})]})}function F(e){return e.notesReferenceCardData||e.onlineReferenceCardData?(0,s.jsxs)(x,{children:[(0,s.jsxs)(j,{className:"text-balance w-auto md:w-[200px] justify-start overflow-hidden break-words p-0 bg-transparent border-none text-gray-400 align-middle items-center !m-2 inline-flex",children:["View references",(0,s.jsx)(h.o,{className:"m-1"})]}),(0,s.jsxs)(N,{className:"overflow-y-scroll",children:[(0,s.jsxs)(k,{children:[(0,s.jsx)(C,{children:"References"}),(0,s.jsx)(M,{children:"View all references for this response"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[e.notesReferenceCardData.map((e,t)=>(0,i.createElement)(D,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)})),e.onlineReferenceCardData.map((e,t)=>(0,i.createElement)(L,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)}))]})]})]}):null}var B=a(34149),H=a(29386),A=a(31784),O=a(60665),W=a(96006),Z=a(18444),q=a(35304),z=a(8589),P=a(13493),G=a(63205),U=a(32970),I=a(84120),V=a(92880),$=a(48408),J=a(67722),Y=a(58485),K=a(58575),Q=a(25800);let X=(0,a(57818).default)(()=>Promise.all([a.e(6555),a.e(7293),a.e(1459),a.e(1210)]).then(a.bind(a,51210)).then(e=>e.default),{loadableGenerated:{webpack:()=>[51210]},ssr:!1});function ee(e){return(0,s.jsx)(i.Suspense,{fallback:(0,s.jsx)(Y.Z,{}),children:(0,s.jsx)(X,{data:e.data})})}let et=new r.Z({html:!0,linkify:!0,typographer:!0});function ea(e,t,a){fetch("/api/chat/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uquery:e,kquery:t,sentiment:a})})}function es(e){let{uquery:t,kquery:a}=e,[n,r]=(0,i.useState)(null);return(0,i.useEffect)(()=>{null!==n&&setTimeout(()=>{r(null)},2e3)},[n]),(0,s.jsxs)("div",{className:"".concat(l().feedbackButtons," flex align-middle justify-center items-center"),children:[(0,s.jsx)("button",{title:"Like",className:l().thumbsUpButton,disabled:null!==n,onClick:()=>{ea(t,a,"positive"),r(!0)},children:!0===n?(0,s.jsx)(B.V,{alt:"Liked Message",className:"text-green-500",weight:"fill"}):(0,s.jsx)(B.V,{alt:"Like Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),(0,s.jsx)("button",{title:"Dislike",className:l().thumbsDownButton,disabled:null!==n,onClick:()=>{ea(t,a,"negative"),r(!1)},children:!1===n?(0,s.jsx)(H.L,{alt:"Disliked Message",className:"text-red-500",weight:"fill"}):(0,s.jsx)(H.L,{alt:"Dislike Message",className:"hsl(var(--muted-foreground)) hover:text-red-500"})})]})}function en(e){let t=e.message.match(/\*\*(.*)\*\*/),a=function(e,t){let a=e.toLowerCase(),n="inline mt-1 mr-2 ".concat(t," h-4 w-4");return a.includes("understanding")?(0,s.jsx)(A.a,{className:"".concat(n)}):a.includes("generating")?(0,s.jsx)(O.Z,{className:"".concat(n)}):a.includes("data sources")||a.includes("notes")?(0,s.jsx)(W.g,{className:"".concat(n)}):a.includes("read")?(0,s.jsx)(Z.f,{className:"".concat(n)}):a.includes("search")?(0,s.jsx)(q.Y,{className:"".concat(n)}):a.includes("summary")||a.includes("summarize")||a.includes("enhanc")?(0,s.jsx)(z.u,{className:"".concat(n)}):a.includes("diagram")?(0,s.jsx)(P.j,{className:"".concat(n)}):a.includes("paint")?(0,s.jsx)(G.Y,{className:"".concat(n)}):(0,s.jsx)(A.a,{className:"".concat(n)})}(t?t[1]:"",e.primary?(0,K.oz)(e.agentColor):"text-gray-500"),n=R().sanitize(et.render(e.message));return(0,s.jsxs)("div",{className:"".concat(l().trainOfThoughtElement," break-all items-center ").concat(e.primary?"text-gray-400":"text-gray-300"," ").concat(l().trainOfThought," ").concat(e.primary?l().primary:""),children:[a,(0,s.jsx)("div",{dangerouslySetInnerHTML:{__html:n}})]})}et.use(c(),{inline:!0,code:!0});let el=(0,i.forwardRef)((e,t)=>{var a,n;let r,o,c,h,u;let[m,g]=(0,i.useState)(!1),[p,f]=(0,i.useState)(!1),[x,j]=(0,i.useState)(""),[w,b]=(0,i.useState)(""),[y,N]=(0,i.useState)(!1),[k,C]=(0,i.useState)(!1),[M,_]=(0,i.useState)(""),v=(0,i.useRef)(!1),E=(0,i.useRef)(null);async function T(){let t=e.chatMessage.message.match(/[^.!?]+[.!?]*/g)||[];if(!t||0===t.length||!t[0])return;N(!0);let a=D(t[0]);for(let e=0;e<t.length&&!v.current;e++){let s=a;e<t.length-1&&(a=D(t[e+1]));try{let e=await s,t=URL.createObjectURL(e);await function(e){return new Promise((t,a)=>{let s=new Audio(e);s.onended=t,s.onerror=a,s.play()})}(t)}catch(e){console.error("Error:",e);break}}N(!1),C(!1)}async function D(e){let t=await fetch("/api/chat/speech?text=".concat(encodeURIComponent(e)),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Network response was not ok");return await t.blob()}(0,i.useEffect)(()=>{v.current=k},[k]),(0,i.useEffect)(()=>{let e=new MutationObserver((e,t)=>{if(E.current)for(let t of e)"childList"===t.type&&t.addedNodes.length>0&&(0,Q.Z)(E.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]})});return E.current&&e.observe(E.current,{childList:!0}),()=>e.disconnect()},[E.current]),(0,i.useEffect)(()=>{let t=e.chatMessage.message;if(e.chatMessage.intent&&"excalidraw"==e.chatMessage.intent.type&&(t=e.chatMessage.intent["inferred-queries"][0],_(e.chatMessage.message)),t=t.replace(/\\\(/g,"LEFTPAREN").replace(/\\\)/g,"RIGHTPAREN").replace(/\\\[/g,"LEFTBRACKET").replace(/\\\]/g,"RIGHTBRACKET"),e.chatMessage.images&&e.chatMessage.images.length>0){let a=e.chatMessage.images.map((e,t)=>{let a=e.startsWith("data%3Aimage")?decodeURIComponent(e):e,s=R().sanitize(a);return'<div class="'.concat(l().imageWrapper,'"><img src="').concat(s,'" alt="uploaded image ').concat(t+1,'" /></div>')}).join("");t='<div class="'.concat(l().imagesContainer,'">').concat(a,"</div>").concat(t)}let a={"text-to-image":e=>"![generated image](data:image/png;base64,".concat(e,")"),"text-to-image2":e=>"![generated image](".concat(e,")"),"text-to-image-v3":e=>"![generated image](data:image/webp;base64,".concat(e,")"),excalidraw:e=>e};if(e.chatMessage.intent){let{type:s,"inferred-queries":n}=e.chatMessage.intent;console.log("intent type",s),s in a&&(t=a[s](t)),s.includes("text-to-image")&&(null==n?void 0:n.length)>0&&(t+="\n\n".concat(n[0]))}j(t);let s=et.render(t);s=s.replace(/LEFTPAREN/g,"\\(").replace(/RIGHTPAREN/g,"\\)").replace(/LEFTBRACKET/g,"\\[").replace(/RIGHTBRACKET/g,"\\]"),b(R().sanitize(s))},[e.chatMessage.message,e.chatMessage.images,e.chatMessage.intent]),(0,i.useEffect)(()=>{m&&setTimeout(()=>{g(!1)},2e3)},[m]),(0,i.useEffect)(()=>{E.current&&(E.current.querySelectorAll("pre > .hljs").forEach(e=>{if(!e.querySelector("".concat(l().codeCopyButton))){let t=document.createElement("button"),a=(0,s.jsx)(U.w,{size:24});(0,d.createRoot)(t).render(a),t.className="hljs ".concat(l().codeCopyButton),t.addEventListener("click",()=>{let a=e.textContent||"";a=(a=(a=a.replace(/^\$+/,"")).replace(/^Copy/,"")).trim(),navigator.clipboard.writeText(a);let n=(0,s.jsx)(I.J,{size:24});(0,d.createRoot)(t).render(n)}),e.prepend(t)}}),(0,Q.Z)(E.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]}))},[w,p,E]);let L=function(e,t){let a=[],s=[];if(t){let e=[];for(let[a,s]of Object.entries(t)){if(s.answerBox&&e.push({title:s.answerBox.title,description:s.answerBox.answer,link:s.answerBox.source}),s.knowledgeGraph&&e.push({title:s.knowledgeGraph.title,description:s.knowledgeGraph.description,link:s.knowledgeGraph.descriptionLink}),s.webpages){if(s.webpages instanceof Array){let t=s.webpages.map(e=>({title:e.query,description:e.snippet,link:e.link}));e.push(...t)}else{let t=s.webpages;e.push({title:t.query,description:t.snippet,link:t.link})}}if(s.organic){let t=s.organic.map(e=>({title:e.title,description:e.snippet,link:e.link}));e.push(...t)}}a.push(...e)}if(e){let t=e.map(e=>e.compiled?{title:e.file,content:e.compiled}:{title:e.split("\n")[0],content:e.split("\n").slice(1).join("\n")});s.push(...t)}return{notesReferenceCardData:s,onlineReferenceCardData:a}}(e.chatMessage.context,e.chatMessage.onlineContext);return(0,s.jsxs)("div",{ref:t,className:(a=e.chatMessage,(r=[l().chatMessageContainer,"shadow-md"]).push(l()[a.by]),a.message||r.push(l().emptyChatMessage),e.customClassName&&r.push(l()["".concat(a.by).concat(e.customClassName)]),r.join(" ")),onMouseLeave:e=>f(!1),onMouseEnter:e=>f(!0),children:[(0,s.jsxs)("div",{className:(n=e.chatMessage,(o=[l().chatMessageWrapper]).push(l()[n.by]),"khoj"===n.by&&o.push("border-l-4 border-opacity-50 ".concat("border-l-"+e.borderLeftColor)),o.join(" ")),children:[(0,s.jsx)("div",{ref:E,className:l().chatMessage,dangerouslySetInnerHTML:{__html:w}}),M&&(0,s.jsx)(ee,{data:M})]}),(0,s.jsx)("div",{className:l().teaserReferencesContainer,children:(0,s.jsx)(S,{isMobileWidth:e.isMobileWidth,notesReferenceCardData:L.notesReferenceCardData,onlineReferenceCardData:L.onlineReferenceCardData})}),(0,s.jsx)("div",{className:l().chatFooter,children:(p||e.isMobileWidth||e.isLastMessage||y)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{title:(h=(c=new Date(e.chatMessage.created+"Z")).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0}).toUpperCase(),u=c.toLocaleString("en-US",{year:"numeric",month:"short",day:"2-digit"}).replaceAll("-"," "),"".concat(h," on ").concat(u)),className:"text-gray-400 relative top-0 left-4",children:function(e){e.endsWith("Z")||(e+="Z");let t=new Date(e),a=new Date().getTime()-t.getTime();return a<6e4?"Just now":a<36e5?"".concat(Math.round(a/6e4),"m ago"):a<864e5?"".concat(Math.round(a/36e5),"h ago"):"".concat(Math.round(a/864e5),"d ago")}(e.chatMessage.created)}),(0,s.jsxs)("div",{className:"".concat(l().chatButtons," shadow-sm"),children:["khoj"===e.chatMessage.by&&(y?k?(0,s.jsx)(Y.l,{iconClassName:"p-0",className:"m-0"}):(0,s.jsx)("button",{title:"Pause Speech",onClick:e=>C(!0),children:(0,s.jsx)(V.d,{alt:"Pause Message",className:"hsl(var(--muted-foreground))"})}):(0,s.jsx)("button",{title:"Speak",onClick:e=>T(),children:(0,s.jsx)($.j,{alt:"Speak Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})})),(0,s.jsx)("button",{title:"Copy",className:"".concat(l().copyButton),onClick:()=>{navigator.clipboard.writeText(x),g(!0)},children:m?(0,s.jsx)(J.C,{alt:"Copied Message",weight:"fill",className:"text-green-500"}):(0,s.jsx)(J.C,{alt:"Copy Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),"khoj"===e.chatMessage.by&&(e.chatMessage.intent?(0,s.jsx)(es,{uquery:e.chatMessage.intent.query,kquery:e.chatMessage.message}):(0,s.jsx)(es,{uquery:e.chatMessage.rawQuery||e.chatMessage.message,kquery:e.chatMessage.message}))]})]})})]})});el.displayName="ChatMessage";var er=el},34531:function(e){e.exports={chatMessageContainer:"chatMessage_chatMessageContainer__sAivf",chatMessageWrapper:"chatMessage_chatMessageWrapper__u5m8A",khojfullHistory:"chatMessage_khojfullHistory__NPu2l",youfullHistory:"chatMessage_youfullHistory__ioyfH",you:"chatMessage_you__6GUC4",khoj:"chatMessage_khoj__cjWON",khojChatMessage:"chatMessage_khojChatMessage__BabQz",emptyChatMessage:"chatMessage_emptyChatMessage__J9JRn",imagesContainer:"chatMessage_imagesContainer__HTRjT",imageWrapper:"chatMessage_imageWrapper__DF92M",author:"chatMessage_author__muRtC",chatFooter:"chatMessage_chatFooter__0vR8s",chatButtons:"chatMessage_chatButtons__Lbk8T",codeCopyButton:"chatMessage_codeCopyButton__Y_Ujv",feedbackButtons:"chatMessage_feedbackButtons___Brdy",copyButton:"chatMessage_copyButton__jd7q7",trainOfThought:"chatMessage_trainOfThought__mR2Gg",primary:"chatMessage_primary__WYPEb",trainOfThoughtElement:"chatMessage_trainOfThoughtElement__le_bC"}}}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3423],{53423:function(e,t,a){"use strict";a.d(t,{H:function(){return en},Z:function(){return er}});var s=a(57437),n=a(34531),l=a.n(n),r=a(14944),o=a(39952),c=a.n(o),i=a(2265),d=a(34040);a(7395);var h=a(26100),u=a(36013),m=a(13304),g=a(12218),p=a(74697),f=a(37440);let x=m.fC,j=m.xz;m.x8;let w=m.h_,b=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(m.aV,{className:(0,f.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...n,ref:t})});b.displayName=m.aV.displayName;let y=(0,g.j)("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),N=i.forwardRef((e,t)=>{let{side:a="right",className:n,children:l,...r}=e;return(0,s.jsxs)(w,{children:[(0,s.jsx)(b,{}),(0,s.jsxs)(m.VY,{ref:t,className:(0,f.cn)(y({side:a}),n),...r,children:[l,(0,s.jsxs)(m.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[(0,s.jsx)(p.Z,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});N.displayName=m.VY.displayName;let k=e=>{let{className:t,...a}=e;return(0,s.jsx)("div",{className:(0,f.cn)("flex flex-col space-y-2 text-center sm:text-left",t),...a})};k.displayName="SheetHeader";let C=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(m.Dx,{ref:t,className:(0,f.cn)("text-lg font-semibold text-foreground",a),...n})});C.displayName=m.Dx.displayName;let M=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(m.dk,{ref:t,className:(0,f.cn)("text-sm text-muted-foreground",a),...n})});M.displayName=m.dk.displayName;var _=a(19573),v=a(11838),R=a.n(v),E=a(89417);let T=new r.Z({html:!0,linkify:!0,typographer:!0});function D(e){let t=(0,E.Le)(e.title||".txt","w-6 h-6 text-muted-foreground inline-flex mr-2"),a=function(e){let t=["org","md","markdown"].includes(e.title.split(".").pop()||"")?e.content.split("\n").slice(1).join("\n"):e.content;return e.showFullContent?R().sanitize(T.render(t)):R().sanitize(t)}(e),[n,l]=(0,i.useState)(!1);return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(_.J2,{open:n&&!e.showFullContent,onOpenChange:l,children:[(0,s.jsx)(_.xo,{asChild:!0,children:(0,s.jsxs)(u.Zb,{onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words text-balance rounded-lg p-2 bg-muted border-none"),children:[(0,s.jsxs)("h3",{className:"".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground}"),children:[t,e.title]}),(0,s.jsx)("p",{className:"".concat(e.showFullContent?"block":"overflow-hidden line-clamp-2"),dangerouslySetInnerHTML:{__html:a}})]})}),(0,s.jsx)(_.yk,{className:"w-[400px] mx-2",children:(0,s.jsxs)(u.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg p-2 border-none",children:[(0,s.jsxs)("h3",{className:"line-clamp-2 text-muted-foreground}",children:[t,e.title]}),(0,s.jsx)("p",{className:"overflow-hidden line-clamp-3",dangerouslySetInnerHTML:{__html:a}})]})})]})})}function L(e){let[t,a]=(0,i.useState)(!1);if(!e.link||e.link.split(" ").length>1)return null;let n="https://www.google.com/s2/favicons?domain=globe",l="unknown";try{l=new URL(e.link).hostname,n="https://www.google.com/s2/favicons?domain=".concat(l)}catch(t){return console.warn("Error parsing domain from link: ".concat(e.link)),null}return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(_.J2,{open:t&&!e.showFullContent,onOpenChange:a,children:[(0,s.jsx)(_.xo,{asChild:!0,children:(0,s.jsx)(u.Zb,{onMouseEnter:()=>{a(!0)},onMouseLeave:()=>{a(!1)},className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words rounded-lg text-balance p-2 bg-muted border-none"),children:(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline p-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("img",{src:n,alt:"",className:"!w-4 h-4 mr-2 flex-shrink-0"}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground flex-grow"),children:l})]}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," font-bold"),children:e.title}),(0,s.jsx)("p",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"),children:e.description})]})})})}),(0,s.jsx)(_.yk,{className:"w-[400px] mx-2",children:(0,s.jsx)(u.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg border-none",children:(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline p-2",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("img",{src:n,alt:"",className:"!w-4 h-4 mr-2"}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," text-muted-foreground"),children:l})]}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," font-bold"),children:e.title}),(0,s.jsx)("p",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-3"),children:e.description})]})})})})]})})}function S(e){let[t,a]=(0,i.useState)(3);(0,i.useEffect)(()=>{a(e.isMobileWidth?1:3)},[e.isMobileWidth]);let n=e.notesReferenceCardData.slice(0,t),l=n.length<t?e.onlineReferenceCardData.slice(0,t-n.length):[],r=e.notesReferenceCardData.length>0||e.onlineReferenceCardData.length>0,o=e.notesReferenceCardData.length+e.onlineReferenceCardData.length;return 0===o?null:(0,s.jsxs)("div",{className:"pt-0 px-4 pb-4 md:px-6",children:[(0,s.jsxs)("h3",{className:"inline-flex items-center",children:["References",(0,s.jsxs)("p",{className:"text-gray-400 m-2",children:[o," sources"]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[n.map((e,t)=>(0,i.createElement)(D,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),l.map((e,t)=>(0,i.createElement)(L,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),r&&(0,s.jsx)(F,{notesReferenceCardData:e.notesReferenceCardData,onlineReferenceCardData:e.onlineReferenceCardData})]})]})}function F(e){return e.notesReferenceCardData||e.onlineReferenceCardData?(0,s.jsxs)(x,{children:[(0,s.jsxs)(j,{className:"text-balance w-auto md:w-[200px] justify-start overflow-hidden break-words p-0 bg-transparent border-none text-gray-400 align-middle items-center !m-2 inline-flex",children:["View references",(0,s.jsx)(h.o,{className:"m-1"})]}),(0,s.jsxs)(N,{className:"overflow-y-scroll",children:[(0,s.jsxs)(k,{children:[(0,s.jsx)(C,{children:"References"}),(0,s.jsx)(M,{children:"View all references for this response"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[e.notesReferenceCardData.map((e,t)=>(0,i.createElement)(D,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)})),e.onlineReferenceCardData.map((e,t)=>(0,i.createElement)(L,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)}))]})]})]}):null}var B=a(34149),H=a(29386),A=a(31784),O=a(60665),W=a(96006),Z=a(18444),q=a(35304),z=a(8589),P=a(13493),G=a(63205),U=a(32970),I=a(84120),V=a(92880),$=a(48408),J=a(67722),Y=a(58485),K=a(58575),Q=a(25800);let X=(0,a(57818).default)(()=>Promise.all([a.e(6555),a.e(7293),a.e(1459),a.e(1210)]).then(a.bind(a,51210)).then(e=>e.default),{loadableGenerated:{webpack:()=>[51210]},ssr:!1});function ee(e){return(0,s.jsx)(i.Suspense,{fallback:(0,s.jsx)(Y.Z,{}),children:(0,s.jsx)(X,{data:e.data})})}let et=new r.Z({html:!0,linkify:!0,typographer:!0});function ea(e,t,a){fetch("/api/chat/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uquery:e,kquery:t,sentiment:a})})}function es(e){let{uquery:t,kquery:a}=e,[n,r]=(0,i.useState)(null);return(0,i.useEffect)(()=>{null!==n&&setTimeout(()=>{r(null)},2e3)},[n]),(0,s.jsxs)("div",{className:"".concat(l().feedbackButtons," flex align-middle justify-center items-center"),children:[(0,s.jsx)("button",{title:"Like",className:l().thumbsUpButton,disabled:null!==n,onClick:()=>{ea(t,a,"positive"),r(!0)},children:!0===n?(0,s.jsx)(B.V,{alt:"Liked Message",className:"text-green-500",weight:"fill"}):(0,s.jsx)(B.V,{alt:"Like Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),(0,s.jsx)("button",{title:"Dislike",className:l().thumbsDownButton,disabled:null!==n,onClick:()=>{ea(t,a,"negative"),r(!1)},children:!1===n?(0,s.jsx)(H.L,{alt:"Disliked Message",className:"text-red-500",weight:"fill"}):(0,s.jsx)(H.L,{alt:"Dislike Message",className:"hsl(var(--muted-foreground)) hover:text-red-500"})})]})}function en(e){let t=e.message.match(/\*\*(.*)\*\*/),a=function(e,t){let a=e.toLowerCase(),n="inline mt-1 mr-2 ".concat(t," h-4 w-4");return a.includes("understanding")?(0,s.jsx)(A.a,{className:"".concat(n)}):a.includes("generating")?(0,s.jsx)(O.Z,{className:"".concat(n)}):a.includes("data sources")||a.includes("notes")?(0,s.jsx)(W.g,{className:"".concat(n)}):a.includes("read")?(0,s.jsx)(Z.f,{className:"".concat(n)}):a.includes("search")?(0,s.jsx)(q.Y,{className:"".concat(n)}):a.includes("summary")||a.includes("summarize")||a.includes("enhanc")?(0,s.jsx)(z.u,{className:"".concat(n)}):a.includes("diagram")?(0,s.jsx)(P.j,{className:"".concat(n)}):a.includes("paint")?(0,s.jsx)(G.Y,{className:"".concat(n)}):(0,s.jsx)(A.a,{className:"".concat(n)})}(t?t[1]:"",e.primary?(0,K.oz)(e.agentColor):"text-gray-500"),n=R().sanitize(et.render(e.message));return(0,s.jsxs)("div",{className:"".concat(l().trainOfThoughtElement," break-all items-center ").concat(e.primary?"text-gray-400":"text-gray-300"," ").concat(l().trainOfThought," ").concat(e.primary?l().primary:""),children:[a,(0,s.jsx)("div",{dangerouslySetInnerHTML:{__html:n}})]})}et.use(c(),{inline:!0,code:!0});let el=(0,i.forwardRef)((e,t)=>{var a,n;let r,o,c,h,u;let[m,g]=(0,i.useState)(!1),[p,f]=(0,i.useState)(!1),[x,j]=(0,i.useState)(""),[w,b]=(0,i.useState)(""),[y,N]=(0,i.useState)(!1),[k,C]=(0,i.useState)(!1),[M,_]=(0,i.useState)(""),v=(0,i.useRef)(!1),E=(0,i.useRef)(null);async function T(){let t=e.chatMessage.message.match(/[^.!?]+[.!?]*/g)||[];if(!t||0===t.length||!t[0])return;N(!0);let a=D(t[0]);for(let e=0;e<t.length&&!v.current;e++){let s=a;e<t.length-1&&(a=D(t[e+1]));try{let e=await s,t=URL.createObjectURL(e);await function(e){return new Promise((t,a)=>{let s=new Audio(e);s.onended=t,s.onerror=a,s.play()})}(t)}catch(e){console.error("Error:",e);break}}N(!1),C(!1)}async function D(e){let t=await fetch("/api/chat/speech?text=".concat(encodeURIComponent(e)),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Network response was not ok");return await t.blob()}(0,i.useEffect)(()=>{v.current=k},[k]),(0,i.useEffect)(()=>{let e=new MutationObserver((e,t)=>{if(E.current)for(let t of e)"childList"===t.type&&t.addedNodes.length>0&&(0,Q.Z)(E.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]})});return E.current&&e.observe(E.current,{childList:!0}),()=>e.disconnect()},[E.current]),(0,i.useEffect)(()=>{let t=e.chatMessage.message;e.chatMessage.intent&&"excalidraw"==e.chatMessage.intent.type&&(t=e.chatMessage.intent["inferred-queries"][0],_(e.chatMessage.message)),t=t.replace(/\\\(/g,"LEFTPAREN").replace(/\\\)/g,"RIGHTPAREN").replace(/\\\[/g,"LEFTBRACKET").replace(/\\\]/g,"RIGHTBRACKET");let a={"text-to-image":e=>"![generated image](data:image/png;base64,".concat(e,")"),"text-to-image2":e=>"![generated image](".concat(e,")"),"text-to-image-v3":e=>"![generated image](data:image/webp;base64,".concat(e,")"),excalidraw:e=>e};if(e.chatMessage.intent){let{type:s,"inferred-queries":n}=e.chatMessage.intent;console.log("intent type",s),s in a&&(t=a[s](t)),s.includes("text-to-image")&&(null==n?void 0:n.length)>0&&(t+="\n\n".concat(n[0]))}let s=t,n=t;if(e.chatMessage.images&&e.chatMessage.images.length>0){let t=e.chatMessage.images.map(e=>{let t=e.startsWith("data%3Aimage")?decodeURIComponent(e):e;return R().sanitize(t)}),a=t.map((e,t)=>"![uploaded image ".concat(t+1,"](").concat(e,")")).join("\n"),r=t.map((e,t)=>'<div class="'.concat(l().imageWrapper,'"><img src="').concat(e,'" alt="uploaded image ').concat(t+1,'" /></div>')).join(""),o='<div class="'.concat(l().imagesContainer,'">').concat(r,"</div>");s="".concat(a,"\n\n").concat(s),n="".concat(o).concat(n)}j(s);let r=et.render(n);r=r.replace(/LEFTPAREN/g,"\\(").replace(/RIGHTPAREN/g,"\\)").replace(/LEFTBRACKET/g,"\\[").replace(/RIGHTBRACKET/g,"\\]"),b(R().sanitize(r))},[e.chatMessage.message,e.chatMessage.images,e.chatMessage.intent]),(0,i.useEffect)(()=>{m&&setTimeout(()=>{g(!1)},2e3)},[m]),(0,i.useEffect)(()=>{E.current&&(E.current.querySelectorAll("pre > .hljs").forEach(e=>{if(!e.querySelector("".concat(l().codeCopyButton))){let t=document.createElement("button"),a=(0,s.jsx)(U.w,{size:24});(0,d.createRoot)(t).render(a),t.className="hljs ".concat(l().codeCopyButton),t.addEventListener("click",()=>{let a=e.textContent||"";a=(a=(a=a.replace(/^\$+/,"")).replace(/^Copy/,"")).trim(),navigator.clipboard.writeText(a);let n=(0,s.jsx)(I.J,{size:24});(0,d.createRoot)(t).render(n)}),e.prepend(t)}}),(0,Q.Z)(E.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]}))},[w,p,E]);let L=function(e,t){let a=[],s=[];if(t){let e=[];for(let[a,s]of Object.entries(t)){if(s.answerBox&&e.push({title:s.answerBox.title,description:s.answerBox.answer,link:s.answerBox.source}),s.knowledgeGraph&&e.push({title:s.knowledgeGraph.title,description:s.knowledgeGraph.description,link:s.knowledgeGraph.descriptionLink}),s.webpages){if(s.webpages instanceof Array){let t=s.webpages.map(e=>({title:e.query,description:e.snippet,link:e.link}));e.push(...t)}else{let t=s.webpages;e.push({title:t.query,description:t.snippet,link:t.link})}}if(s.organic){let t=s.organic.map(e=>({title:e.title,description:e.snippet,link:e.link}));e.push(...t)}}a.push(...e)}if(e){let t=e.map(e=>e.compiled?{title:e.file,content:e.compiled}:{title:e.split("\n")[0],content:e.split("\n").slice(1).join("\n")});s.push(...t)}return{notesReferenceCardData:s,onlineReferenceCardData:a}}(e.chatMessage.context,e.chatMessage.onlineContext);return(0,s.jsxs)("div",{ref:t,className:(a=e.chatMessage,(r=[l().chatMessageContainer,"shadow-md"]).push(l()[a.by]),a.message||r.push(l().emptyChatMessage),e.customClassName&&r.push(l()["".concat(a.by).concat(e.customClassName)]),r.join(" ")),onMouseLeave:e=>f(!1),onMouseEnter:e=>f(!0),children:[(0,s.jsxs)("div",{className:(n=e.chatMessage,(o=[l().chatMessageWrapper]).push(l()[n.by]),"khoj"===n.by&&o.push("border-l-4 border-opacity-50 ".concat("border-l-"+e.borderLeftColor)),o.join(" ")),children:[(0,s.jsx)("div",{ref:E,className:l().chatMessage,dangerouslySetInnerHTML:{__html:w}}),M&&(0,s.jsx)(ee,{data:M})]}),(0,s.jsx)("div",{className:l().teaserReferencesContainer,children:(0,s.jsx)(S,{isMobileWidth:e.isMobileWidth,notesReferenceCardData:L.notesReferenceCardData,onlineReferenceCardData:L.onlineReferenceCardData})}),(0,s.jsx)("div",{className:l().chatFooter,children:(p||e.isMobileWidth||e.isLastMessage||y)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{title:(h=(c=new Date(e.chatMessage.created+"Z")).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0}).toUpperCase(),u=c.toLocaleString("en-US",{year:"numeric",month:"short",day:"2-digit"}).replaceAll("-"," "),"".concat(h," on ").concat(u)),className:"text-gray-400 relative top-0 left-4",children:function(e){e.endsWith("Z")||(e+="Z");let t=new Date(e),a=new Date().getTime()-t.getTime();return a<6e4?"Just now":a<36e5?"".concat(Math.round(a/6e4),"m ago"):a<864e5?"".concat(Math.round(a/36e5),"h ago"):"".concat(Math.round(a/864e5),"d ago")}(e.chatMessage.created)}),(0,s.jsxs)("div",{className:"".concat(l().chatButtons," shadow-sm"),children:["khoj"===e.chatMessage.by&&(y?k?(0,s.jsx)(Y.l,{iconClassName:"p-0",className:"m-0"}):(0,s.jsx)("button",{title:"Pause Speech",onClick:e=>C(!0),children:(0,s.jsx)(V.d,{alt:"Pause Message",className:"hsl(var(--muted-foreground))"})}):(0,s.jsx)("button",{title:"Speak",onClick:e=>T(),children:(0,s.jsx)($.j,{alt:"Speak Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})})),(0,s.jsx)("button",{title:"Copy",className:"".concat(l().copyButton),onClick:()=>{navigator.clipboard.writeText(x),g(!0)},children:m?(0,s.jsx)(J.C,{alt:"Copied Message",weight:"fill",className:"text-green-500"}):(0,s.jsx)(J.C,{alt:"Copy Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),"khoj"===e.chatMessage.by&&(e.chatMessage.intent?(0,s.jsx)(es,{uquery:e.chatMessage.intent.query,kquery:e.chatMessage.message}):(0,s.jsx)(es,{uquery:e.chatMessage.rawQuery||e.chatMessage.message,kquery:e.chatMessage.message}))]})]})})]})});el.displayName="ChatMessage";var er=el},34531:function(e){e.exports={chatMessageContainer:"chatMessage_chatMessageContainer__sAivf",chatMessageWrapper:"chatMessage_chatMessageWrapper__u5m8A",khojfullHistory:"chatMessage_khojfullHistory__NPu2l",youfullHistory:"chatMessage_youfullHistory__ioyfH",you:"chatMessage_you__6GUC4",khoj:"chatMessage_khoj__cjWON",khojChatMessage:"chatMessage_khojChatMessage__BabQz",emptyChatMessage:"chatMessage_emptyChatMessage__J9JRn",imagesContainer:"chatMessage_imagesContainer__HTRjT",imageWrapper:"chatMessage_imageWrapper__DF92M",author:"chatMessage_author__muRtC",chatFooter:"chatMessage_chatFooter__0vR8s",chatButtons:"chatMessage_chatButtons__Lbk8T",codeCopyButton:"chatMessage_codeCopyButton__Y_Ujv",feedbackButtons:"chatMessage_feedbackButtons___Brdy",copyButton:"chatMessage_copyButton__jd7q7",trainOfThought:"chatMessage_trainOfThought__mR2Gg",primary:"chatMessage_primary__WYPEb",trainOfThoughtElement:"chatMessage_trainOfThoughtElement__le_bC"}}}]);