@arbidocs/react 0.3.114 → 0.3.116

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.
package/dist/index.cjs CHANGED
@@ -671,7 +671,13 @@ var arbiQueryKeys = {
671
671
  health: () => ["arbi", "health"],
672
672
  tasks: () => ["arbi", "tasks"],
673
673
  memories: (workspaceId) => ["arbi", "memories", workspaceId],
674
- configs: () => ["arbi", "configs"]
674
+ configs: () => ["arbi", "configs"],
675
+ activity: () => ["arbi", "activity"],
676
+ projects: () => ["arbi", "projects"],
677
+ projectUsage: (projectExtId, monthsBack) => ["arbi", "projectUsage", projectExtId, monthsBack],
678
+ projectInvoices: (projectExtId) => ["arbi", "projectInvoices", projectExtId],
679
+ userUsageToday: () => ["arbi", "userUsageToday"],
680
+ workspaceChronology: (workspaceId) => ["arbi", "workspaceChronology", workspaceId]
675
681
  };
676
682
  function useWorkspaces(options) {
677
683
  const arbi = useArbi();
@@ -782,6 +788,119 @@ function useConfigs(options) {
782
788
  enabled: options?.enabled ?? arbi.isLoggedIn
783
789
  });
784
790
  }
791
+ function useActivity(options) {
792
+ const arbi = useArbi();
793
+ return reactQuery.useQuery({
794
+ queryKey: arbiQueryKeys.activity(),
795
+ queryFn: () => arbi.dm.listActivity({ limit: options?.limit, offset: options?.offset }),
796
+ enabled: options?.enabled ?? arbi.isLoggedIn
797
+ });
798
+ }
799
+ function useProjects(options) {
800
+ const arbi = useArbi();
801
+ return reactQuery.useQuery({
802
+ queryKey: arbiQueryKeys.projects(),
803
+ queryFn: () => arbi.projects.list(),
804
+ enabled: options?.enabled ?? arbi.isLoggedIn
805
+ });
806
+ }
807
+ function useProjectUsage(projectExtId, monthsBack = 0, options) {
808
+ const arbi = useArbi();
809
+ return reactQuery.useQuery({
810
+ queryKey: arbiQueryKeys.projectUsage(projectExtId ?? "", monthsBack),
811
+ queryFn: () => arbi.projects.usage(projectExtId, monthsBack),
812
+ enabled: (options?.enabled ?? true) && !!projectExtId && arbi.isLoggedIn
813
+ });
814
+ }
815
+ function useProjectsUsage(projectExtIds, monthsBack = 0, options) {
816
+ const arbi = useArbi();
817
+ const enabled = (options?.enabled ?? true) && arbi.isLoggedIn;
818
+ const results = reactQuery.useQueries({
819
+ queries: projectExtIds.map((id) => ({
820
+ queryKey: arbiQueryKeys.projectUsage(id, monthsBack),
821
+ queryFn: () => arbi.projects.usage(id, monthsBack),
822
+ enabled: enabled && !!id
823
+ }))
824
+ });
825
+ const signature = results.map((r) => `${r.status}:${r.dataUpdatedAt ?? 0}`).join("|");
826
+ return React.useMemo(() => {
827
+ const dailyMap = /* @__PURE__ */ new Map();
828
+ const modelMap = /* @__PURE__ */ new Map();
829
+ let totalSpend = 0;
830
+ let totalTokens = 0;
831
+ let totalRequests = 0;
832
+ for (const r of results) {
833
+ const d = r.data;
834
+ if (!d) continue;
835
+ totalSpend += d.total_spend ?? 0;
836
+ totalTokens += d.total_tokens ?? 0;
837
+ totalRequests += d.total_requests ?? 0;
838
+ for (const day of d.daily ?? []) {
839
+ const cur = dailyMap.get(day.date) ?? {
840
+ date: day.date,
841
+ spend: 0,
842
+ totalTokens: 0,
843
+ apiRequests: 0
844
+ };
845
+ cur.spend += day.spend ?? 0;
846
+ cur.totalTokens += day.total_tokens ?? 0;
847
+ cur.apiRequests += day.api_requests ?? 0;
848
+ dailyMap.set(day.date, cur);
849
+ }
850
+ for (const [model, mg] of Object.entries(d.model_groups ?? {})) {
851
+ const cur = modelMap.get(model) ?? {
852
+ model,
853
+ spend: 0,
854
+ totalTokens: 0,
855
+ promptTokens: 0,
856
+ completionTokens: 0,
857
+ successfulRequests: 0
858
+ };
859
+ cur.spend += mg.spend ?? 0;
860
+ cur.totalTokens += mg.total_tokens ?? 0;
861
+ cur.promptTokens += mg.prompt_tokens ?? 0;
862
+ cur.completionTokens += mg.completion_tokens ?? 0;
863
+ cur.successfulRequests += mg.successful_requests ?? 0;
864
+ modelMap.set(model, cur);
865
+ }
866
+ }
867
+ return {
868
+ totalSpend,
869
+ totalTokens,
870
+ totalRequests,
871
+ daily: [...dailyMap.values()].sort((a, b) => a.date.localeCompare(b.date)),
872
+ modelGroups: [...modelMap.values()].sort(
873
+ (a, b) => b.spend - a.spend || b.totalTokens - a.totalTokens
874
+ ),
875
+ isLoading: results.some((r) => r.isLoading),
876
+ isError: results.some((r) => r.isError)
877
+ };
878
+ }, [signature]);
879
+ }
880
+ function useProjectInvoices(projectExtId, options) {
881
+ const arbi = useArbi();
882
+ return reactQuery.useQuery({
883
+ queryKey: arbiQueryKeys.projectInvoices(projectExtId ?? ""),
884
+ queryFn: () => arbi.projects.invoices(projectExtId),
885
+ enabled: (options?.enabled ?? true) && !!projectExtId && arbi.isLoggedIn
886
+ });
887
+ }
888
+ function useUserUsageToday(options) {
889
+ const arbi = useArbi();
890
+ return reactQuery.useQuery({
891
+ queryKey: arbiQueryKeys.userUsageToday(),
892
+ queryFn: () => arbi.user.usageToday(),
893
+ enabled: options?.enabled ?? arbi.isLoggedIn
894
+ });
895
+ }
896
+ function useWorkspaceChronology(workspaceId, options) {
897
+ const arbi = useArbi();
898
+ return reactQuery.useQuery({
899
+ queryKey: arbiQueryKeys.workspaceChronology(workspaceId ?? ""),
900
+ queryFn: () => arbi.workspaces.chronology(workspaceId),
901
+ enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace
902
+ });
903
+ }
785
904
  function WorkspaceScreen({ theme, labels, onSelect }) {
786
905
  const arbi = useArbi();
787
906
  const { data: workspaces, isLoading } = useWorkspaces();
@@ -5166,6 +5285,500 @@ var UserEntity = React.memo(function UserEntity2({
5166
5285
  }
5167
5286
  return avatarElement;
5168
5287
  });
5288
+ var ENTITY_MAPPINGS = {
5289
+ PRODUCT: {
5290
+ NAMES: {
5291
+ SINGULAR: "ARBI Docs"
5292
+ },
5293
+ ICONS: {
5294
+ DEFAULT: lucideReact.MessageSquareLock
5295
+ }
5296
+ },
5297
+ SECTION: {
5298
+ NAMES: {
5299
+ SINGULAR: "Section"
5300
+ },
5301
+ ICONS: {
5302
+ DEFAULT: lucideReact.ChevronsDown
5303
+ }
5304
+ },
5305
+ WORKSPACE: {
5306
+ NAMES: {
5307
+ SINGULAR: "Workspace",
5308
+ PLURAL: "Workspaces"
5309
+ },
5310
+ ICONS: {
5311
+ DEFAULT: lucideReact.SquareM,
5312
+ NEW: lucideReact.SquarePlus,
5313
+ LIST: lucideReact.LayoutGrid,
5314
+ SETTINGS: lucideReact.Columns3Cog
5315
+ }
5316
+ },
5317
+ CONVERSATION: {
5318
+ NAMES: {
5319
+ SINGULAR: "Chat",
5320
+ PLURAL: "Chats",
5321
+ NEW: "New ARBI Chat"
5322
+ },
5323
+ ICONS: {
5324
+ DEFAULT: lucideReact.MessagesSquare,
5325
+ OFF: lucideReact.MessageSquareOff,
5326
+ ACTIVE: lucideReact.MessageSquareText,
5327
+ NEW: lucideReact.MessageSquarePlus,
5328
+ LIST: lucideReact.MessageSquareMore
5329
+ }
5330
+ },
5331
+ DOCUMENT: {
5332
+ NAMES: {
5333
+ SINGULAR: "File",
5334
+ PLURAL: "Files"
5335
+ },
5336
+ ICONS: {
5337
+ DEFAULT: lucideReact.FolderOpen,
5338
+ OFF: lucideReact.CaptionsOff
5339
+ }
5340
+ },
5341
+ VIEWER: {
5342
+ NAMES: {
5343
+ SINGULAR: "Viewer",
5344
+ PLURAL: "Viewers"
5345
+ },
5346
+ ICONS: {
5347
+ DEFAULT: lucideReact.Eye,
5348
+ OFF: lucideReact.EyeOff
5349
+ }
5350
+ },
5351
+ TAG: {
5352
+ NAMES: {
5353
+ SINGULAR: "Field",
5354
+ PLURAL: "Fields"
5355
+ },
5356
+ ICONS: {
5357
+ DEFAULT: lucideReact.Hash,
5358
+ NEW: lucideReact.FolderPlus
5359
+ }
5360
+ },
5361
+ ANNOTATION: {
5362
+ NAMES: {
5363
+ SINGULAR: "Annotation",
5364
+ PLURAL: "Annotations"
5365
+ },
5366
+ ICONS: {
5367
+ DEFAULT: lucideReact.StickyNote,
5368
+ NEW: lucideReact.StickyNote
5369
+ }
5370
+ },
5371
+ USER: {
5372
+ NAMES: {
5373
+ SINGULAR: "User",
5374
+ PLURAL: "Users"
5375
+ },
5376
+ ICONS: {
5377
+ DEFAULT: lucideReact.User,
5378
+ NEW: lucideReact.UserPlus,
5379
+ SETTINGS: lucideReact.Settings2
5380
+ }
5381
+ },
5382
+ WORKSPACEUSER: {
5383
+ NAMES: {
5384
+ SINGULAR: "Member",
5385
+ PLURAL: "Members"
5386
+ },
5387
+ ICONS: {
5388
+ DEFAULT: lucideReact.User,
5389
+ PLURAL: lucideReact.Users,
5390
+ NEW: lucideReact.UserPlus,
5391
+ SETTINGS: lucideReact.Settings2
5392
+ }
5393
+ },
5394
+ CONTACT: {
5395
+ NAMES: {
5396
+ SINGULAR: "Contact",
5397
+ PLURAL: "Contacts"
5398
+ },
5399
+ ICONS: {
5400
+ DEFAULT: lucideReact.Contact,
5401
+ NEW: lucideReact.UserPlus
5402
+ }
5403
+ },
5404
+ TASK: {
5405
+ NAMES: {
5406
+ SINGULAR: "Job",
5407
+ PLURAL: "Jobs"
5408
+ },
5409
+ ICONS: {
5410
+ DEFAULT: lucideReact.ClipboardList
5411
+ }
5412
+ },
5413
+ PROJECT: {
5414
+ NAMES: {
5415
+ SINGULAR: "Project",
5416
+ PLURAL: "Projects"
5417
+ },
5418
+ ICONS: {
5419
+ DEFAULT: lucideReact.Package
5420
+ }
5421
+ },
5422
+ SKILL: {
5423
+ NAMES: {
5424
+ SINGULAR: "Skill",
5425
+ PLURAL: "Skills"
5426
+ },
5427
+ ICONS: {
5428
+ DEFAULT: lucideReact.Wrench
5429
+ }
5430
+ },
5431
+ ACCOUNT: {
5432
+ NAMES: {
5433
+ SINGULAR: "Account"
5434
+ },
5435
+ ICONS: {
5436
+ DEFAULT: lucideReact.CircleUserRound
5437
+ }
5438
+ },
5439
+ NOTIFICATIONS: {
5440
+ NAMES: {
5441
+ SINGULAR: "Activity",
5442
+ PLURAL: "Activities"
5443
+ },
5444
+ ICONS: {
5445
+ DEFAULT: lucideReact.Bell
5446
+ }
5447
+ },
5448
+ MESSAGE: {
5449
+ NAMES: {
5450
+ SINGULAR: "Message",
5451
+ PLURAL: "Messages"
5452
+ },
5453
+ ICONS: {
5454
+ DEFAULT: lucideReact.MessageSquare
5455
+ }
5456
+ },
5457
+ NOTIFICATION: {
5458
+ NAMES: {
5459
+ SINGULAR: "Notification",
5460
+ PLURAL: "Notifications"
5461
+ },
5462
+ ICONS: {
5463
+ DEFAULT: lucideReact.Bell
5464
+ }
5465
+ },
5466
+ APP: {
5467
+ NAMES: {
5468
+ SINGULAR: "Application",
5469
+ PLURAL: "Applications"
5470
+ },
5471
+ ICONS: {
5472
+ DEFAULT: lucideReact.LayoutGrid,
5473
+ HOME: lucideReact.LayoutGrid,
5474
+ LOGOUT: lucideReact.LogOut,
5475
+ UPLOAD: lucideReact.Upload
5476
+ }
5477
+ },
5478
+ HELP: {
5479
+ NAMES: {
5480
+ SINGULAR: "Help",
5481
+ PLURAL: "Help"
5482
+ },
5483
+ ICONS: {
5484
+ DEFAULT: lucideReact.MessageSquareLock,
5485
+ DOCS: lucideReact.BookOpen,
5486
+ FAQ: lucideReact.FileQuestion,
5487
+ ABOUT: lucideReact.Info
5488
+ }
5489
+ },
5490
+ USERSHIELD: {
5491
+ NAMES: {
5492
+ SINGULAR: "User Shield",
5493
+ PLURAL: "User Shields"
5494
+ },
5495
+ ICONS: {
5496
+ DEFAULT: lucideReact.MessageSquareLock
5497
+ }
5498
+ }
5499
+ };
5500
+ function configureEntityRegistry(overrides) {
5501
+ for (const [type, def] of Object.entries(overrides)) {
5502
+ const target = ENTITY_MAPPINGS[type];
5503
+ if (!target) continue;
5504
+ if (def?.NAMES) Object.assign(target.NAMES, def.NAMES);
5505
+ if (def?.ICONS) Object.assign(target.ICONS, def.ICONS);
5506
+ }
5507
+ }
5508
+ var getEntityIcon = (entityType, variant = "DEFAULT") => {
5509
+ const icons = ENTITY_MAPPINGS[entityType]?.ICONS;
5510
+ return icons?.[variant] || icons?.DEFAULT;
5511
+ };
5512
+ var getEntityLabel = (entityType, form = "SINGULAR") => {
5513
+ const entityMapping = ENTITY_MAPPINGS[entityType];
5514
+ if (!entityMapping) return "";
5515
+ const names = entityMapping.NAMES;
5516
+ const singularName = names.SINGULAR || "";
5517
+ if (form === "NEW") return names.NEW !== void 0 ? names.NEW : "New " + singularName;
5518
+ if (form === "SHORT")
5519
+ return names.SHORT !== void 0 ? names.SHORT : singularName.substring(0, 3) + ".";
5520
+ if (form === "PLURAL") return names.PLURAL !== void 0 ? names.PLURAL : singularName + "s";
5521
+ return singularName;
5522
+ };
5523
+ var EntityIcon = ({ entityType, variant = "DEFAULT", ...props }) => {
5524
+ const IconComponent = getEntityIcon(entityType, variant);
5525
+ return IconComponent ? React__namespace.default.createElement(IconComponent, props) : null;
5526
+ };
5527
+ var VISIBILITY_ICONS = {
5528
+ PRIVATE: lucideReact.MessageSquareLock,
5529
+ SHARED: lucideReact.Users
5530
+ };
5531
+ var VisibilityIcon = ({
5532
+ isShared,
5533
+ ...props
5534
+ }) => {
5535
+ const IconComponent = isShared ? VISIBILITY_ICONS.SHARED : VISIBILITY_ICONS.PRIVATE;
5536
+ return React__namespace.default.createElement(IconComponent, props);
5537
+ };
5538
+
5539
+ // src/entities/colors.ts
5540
+ var OPACITY_LIGHT = 0.15;
5541
+ var OPACITY_MEDIUM = 1;
5542
+ var OPACITY_BORDER = 0.3;
5543
+ var PLACEHOLDER_COLOR = "#9ca3af";
5544
+ var NEUTRAL_GRAY2 = "#64748b";
5545
+ var BASE_COLORS2 = {
5546
+ "0": "#10b981",
5547
+ "1": "#3b82f6",
5548
+ "2": "#8b5cf6",
5549
+ "3": "#f43f5e",
5550
+ "4": "#f59e0b",
5551
+ "5": "#84cc16",
5552
+ "6": "#a855f7",
5553
+ "7": "#06b6d4",
5554
+ "8": "#f97316",
5555
+ "9": "#14b8a6",
5556
+ a: "#ef4444",
5557
+ b: "#6366f1",
5558
+ c: "#ec4899",
5559
+ d: "#22c55e",
5560
+ e: "#eab308",
5561
+ f: "#0ea5e9"
5562
+ };
5563
+ function hexToRgba(hex, opacity) {
5564
+ const r = parseInt(hex.slice(1, 3), 16);
5565
+ const g = parseInt(hex.slice(3, 5), 16);
5566
+ const b = parseInt(hex.slice(5, 7), 16);
5567
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
5568
+ }
5569
+ function getEntityColor2(entityId, variant = "medium") {
5570
+ const baseColor = BASE_COLORS2[entityId[4]] || BASE_COLORS2["0"];
5571
+ switch (variant) {
5572
+ case "light":
5573
+ return hexToRgba(baseColor, OPACITY_LIGHT);
5574
+ case "medium":
5575
+ return hexToRgba(baseColor, OPACITY_MEDIUM);
5576
+ case "text":
5577
+ return baseColor;
5578
+ }
5579
+ }
5580
+ function getEntityColorStyles(entityId) {
5581
+ const baseColor = BASE_COLORS2[entityId[4]] || BASE_COLORS2["0"];
5582
+ return {
5583
+ backgroundColor: getEntityColor2(entityId, "light"),
5584
+ color: baseColor,
5585
+ borderColor: hexToRgba(baseColor, OPACITY_BORDER)
5586
+ };
5587
+ }
5588
+ var getWorkspaceColor = (workspaceId, useWorkspaceColors) => {
5589
+ const shouldUseWorkspaceColors = useWorkspaceColors !== void 0 ? useWorkspaceColors : true;
5590
+ if (!shouldUseWorkspaceColors) return "hsl(var(--primary))";
5591
+ const isValidId = workspaceId && workspaceId.startsWith("wrk-") && workspaceId.length >= 5;
5592
+ if (!isValidId) return "hsl(var(--primary))";
5593
+ return getEntityColor2(workspaceId, "medium");
5594
+ };
5595
+ function getNotificationTypeMeta(type) {
5596
+ const WorkspaceIcon = getEntityIcon("WORKSPACE");
5597
+ switch (type) {
5598
+ case "user_message":
5599
+ return { Icon: lucideReact.MessageCircleMore, iconClassName: "text-primary", label: "Message" };
5600
+ case "workspaceuser_added_owner":
5601
+ case "workspaceuser_added_collaborator":
5602
+ case "workspaceuser_added_guest":
5603
+ return { Icon: WorkspaceIcon, iconClassName: "text-primary", label: "Added" };
5604
+ case "workspaceuser_removed":
5605
+ return { Icon: WorkspaceIcon, iconClassName: "text-primary", label: "Removed" };
5606
+ case "workspaceuser_updated_owner":
5607
+ case "workspaceuser_updated_collaborator":
5608
+ case "workspaceuser_updated_guest":
5609
+ return { Icon: WorkspaceIcon, iconClassName: "text-primary", label: "Role changed" };
5610
+ case "contact_accepted":
5611
+ return { Icon: lucideReact.UserCheck, iconClassName: "text-green-500", label: "Invitation" };
5612
+ case "signup_reward":
5613
+ return { Icon: lucideReact.PartyPopper, iconClassName: "text-green-600", label: "Signup bonus" };
5614
+ case "referral_reward":
5615
+ return { Icon: lucideReact.Gift, iconClassName: "text-green-600", label: "Reward earned" };
5616
+ case "quota_threshold_50":
5617
+ return { Icon: lucideReact.Gauge, iconClassName: "text-blue-500", label: "Usage 50%" };
5618
+ case "quota_threshold_90":
5619
+ return { Icon: lucideReact.Gauge, iconClassName: "text-orange-500", label: "Usage 90%" };
5620
+ case "quota_threshold_100":
5621
+ return { Icon: lucideReact.Gauge, iconClassName: "text-red-500", label: "Usage limit" };
5622
+ case "activity":
5623
+ return { Icon: lucideReact.Activity, iconClassName: "text-muted-foreground", label: "Activity" };
5624
+ default:
5625
+ return { Icon: lucideReact.Info, iconClassName: "text-blue-500", label: type || "Notification" };
5626
+ }
5627
+ }
5628
+ function isWorkspaceNotificationType(type) {
5629
+ return type.startsWith("workspaceuser_");
5630
+ }
5631
+ function getWorkspaceActionText(type) {
5632
+ switch (type) {
5633
+ case "workspaceuser_added_owner":
5634
+ return "added you as owner";
5635
+ case "workspaceuser_added_collaborator":
5636
+ return "added you as collaborator";
5637
+ case "workspaceuser_added_guest":
5638
+ return "added you as guest";
5639
+ case "workspaceuser_removed":
5640
+ return "removed you";
5641
+ case "workspaceuser_updated_owner":
5642
+ return "changed your role to owner";
5643
+ case "workspaceuser_updated_collaborator":
5644
+ return "changed your role to collaborator";
5645
+ case "workspaceuser_updated_guest":
5646
+ return "changed your role to guest";
5647
+ default:
5648
+ return "updated your access";
5649
+ }
5650
+ }
5651
+ function getWorkspaceSentPhrase(type) {
5652
+ switch (type) {
5653
+ case "workspaceuser_added_owner":
5654
+ return { before: "You added", after: "as owner" };
5655
+ case "workspaceuser_added_collaborator":
5656
+ return { before: "You added", after: "as collaborator" };
5657
+ case "workspaceuser_added_guest":
5658
+ return { before: "You added", after: "as guest" };
5659
+ case "workspaceuser_removed":
5660
+ return { before: "You removed", after: "" };
5661
+ case "workspaceuser_updated_owner":
5662
+ return { before: "You set", after: "as owner" };
5663
+ case "workspaceuser_updated_collaborator":
5664
+ return { before: "You set", after: "as collaborator" };
5665
+ case "workspaceuser_updated_guest":
5666
+ return { before: "You set", after: "as guest" };
5667
+ default:
5668
+ return { before: "You updated access for", after: "" };
5669
+ }
5670
+ }
5671
+ function parseActivityContent(content) {
5672
+ if (!content) return null;
5673
+ try {
5674
+ const parsed = JSON.parse(content);
5675
+ if (parsed && typeof parsed === "object" && typeof parsed.event === "string") {
5676
+ return parsed;
5677
+ }
5678
+ } catch {
5679
+ }
5680
+ return null;
5681
+ }
5682
+ function str(v) {
5683
+ return typeof v === "string" && v ? v : void 0;
5684
+ }
5685
+ function describeActivity(content) {
5686
+ const parsed = typeof content === "string" || content == null ? parseActivityContent(content) : content;
5687
+ if (!parsed) {
5688
+ return { Icon: lucideReact.Activity, iconClassName: "text-muted-foreground", title: "Activity" };
5689
+ }
5690
+ const fileName = str(parsed.file_name);
5691
+ switch (parsed.event) {
5692
+ case "workspace_opened":
5693
+ return {
5694
+ Icon: lucideReact.SquareArrowOutUpRight,
5695
+ iconClassName: "text-primary",
5696
+ title: "Opened a workspace"
5697
+ };
5698
+ case "workspace_created":
5699
+ return { Icon: lucideReact.FolderPlus, iconClassName: "text-green-600", title: "Created a workspace" };
5700
+ case "workspace_updated":
5701
+ return { Icon: lucideReact.Pencil, iconClassName: "text-primary", title: "Updated workspace settings" };
5702
+ case "workspace_deleted":
5703
+ return { Icon: lucideReact.Trash2, iconClassName: "text-red-500", title: "Deleted a workspace" };
5704
+ case "document_processing": {
5705
+ const failed = str(parsed.status) === "failed";
5706
+ const noun = fileName ? `\u201C${fileName}\u201D` : "a document";
5707
+ return failed ? { Icon: lucideReact.FileX2, iconClassName: "text-red-500", title: `Failed to process ${noun}` } : { Icon: lucideReact.FileCheck2, iconClassName: "text-green-600", title: `Processed ${noun}` };
5708
+ }
5709
+ default:
5710
+ return {
5711
+ Icon: parsed.workspace_ext_id ? getEntityIcon("WORKSPACE") : lucideReact.Activity,
5712
+ iconClassName: "text-muted-foreground",
5713
+ title: humaniseEvent(parsed.event)
5714
+ };
5715
+ }
5716
+ }
5717
+ function humaniseEvent(event) {
5718
+ const words = event.replace(/[_-]+/g, " ").trim();
5719
+ return words ? words.charAt(0).toUpperCase() + words.slice(1) : "Activity";
5720
+ }
5721
+ function formatRelative(iso) {
5722
+ const then = new Date(iso).getTime();
5723
+ if (Number.isNaN(then)) return "";
5724
+ const secs = Math.round((Date.now() - then) / 1e3);
5725
+ if (secs < 45) return "just now";
5726
+ const mins = Math.round(secs / 60);
5727
+ if (mins < 60) return `${mins}m`;
5728
+ const hours = Math.round(mins / 60);
5729
+ if (hours < 24) return `${hours}h`;
5730
+ const days = Math.round(hours / 24);
5731
+ if (days < 7) return `${days}d`;
5732
+ return new Date(iso).toLocaleDateString();
5733
+ }
5734
+ function ActivityFeed({
5735
+ limit = 20,
5736
+ className,
5737
+ emptyLabel = "No recent activity",
5738
+ enabled,
5739
+ "data-testid": testId = "activity-feed"
5740
+ }) {
5741
+ const { data, isLoading, isError } = useActivity({ limit, enabled });
5742
+ if (isLoading) {
5743
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("space-y-2", className), "data-testid": testId, "aria-busy": "true", children: Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 py-1.5", children: [
5744
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-4 shrink-0 animate-pulse rounded-full bg-muted" }),
5745
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-3 flex-1 animate-pulse rounded bg-muted" })
5746
+ ] }, i)) });
5747
+ }
5748
+ if (isError) {
5749
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("text-sm text-muted-foreground", className), "data-testid": testId, children: "Couldn\u2019t load activity." });
5750
+ }
5751
+ const items = data ?? [];
5752
+ if (items.length === 0) {
5753
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5754
+ "div",
5755
+ {
5756
+ className: cn("flex items-center gap-2 text-sm text-muted-foreground", className),
5757
+ "data-testid": testId,
5758
+ children: [
5759
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Activity, { className: "h-4 w-4 shrink-0" }),
5760
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: emptyLabel })
5761
+ ]
5762
+ }
5763
+ );
5764
+ }
5765
+ return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: cn("divide-y divide-border", className), "data-testid": testId, children: items.map((item) => {
5766
+ const desc = describeActivity(item.content);
5767
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5768
+ "li",
5769
+ {
5770
+ className: "flex items-center gap-3 py-2",
5771
+ "data-testid": "activity-feed-item",
5772
+ children: [
5773
+ /* @__PURE__ */ jsxRuntime.jsx(desc.Icon, { className: cn("h-4 w-4 shrink-0", desc.iconClassName) }),
5774
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate text-sm text-foreground", children: desc.title }),
5775
+ /* @__PURE__ */ jsxRuntime.jsx("time", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: formatRelative(item.created_at) })
5776
+ ]
5777
+ },
5778
+ item.external_id
5779
+ );
5780
+ }) });
5781
+ }
5169
5782
  var useArbiUiStore = zustand.create((set) => ({
5170
5783
  selectedDocIds: [],
5171
5784
  setSelectedDocIds: (ids) => set({ selectedDocIds: ids }),
@@ -5746,6 +6359,7 @@ Object.defineProperty(exports, "isMessageType", {
5746
6359
  enumerable: true,
5747
6360
  get: function () { return client.isMessageType; }
5748
6361
  });
6362
+ exports.ActivityFeed = ActivityFeed;
5749
6363
  exports.AiActionCard = AiActionCard;
5750
6364
  exports.AiAnswer = AiAnswer;
5751
6365
  exports.AiMarkdown = AiMarkdown;
@@ -5762,6 +6376,7 @@ exports.AudIcon = AudIcon;
5762
6376
  exports.Avatar = Avatar;
5763
6377
  exports.AvatarFallback = AvatarFallback;
5764
6378
  exports.AvatarImage = AvatarImage;
6379
+ exports.BASE_COLORS = BASE_COLORS2;
5765
6380
  exports.Badge = Badge;
5766
6381
  exports.Button = Button;
5767
6382
  exports.Card = Card;
@@ -5818,7 +6433,9 @@ exports.DropdownMenuSub = DropdownMenuSub;
5818
6433
  exports.DropdownMenuSubContent = DropdownMenuSubContent;
5819
6434
  exports.DropdownMenuSubTrigger = DropdownMenuSubTrigger;
5820
6435
  exports.DropdownMenuTrigger = DropdownMenuTrigger;
6436
+ exports.ENTITY_MAPPINGS = ENTITY_MAPPINGS;
5821
6437
  exports.EmlIcon = EmlIcon;
6438
+ exports.EntityIcon = EntityIcon;
5822
6439
  exports.EntityPill = EntityPill;
5823
6440
  exports.FILE_TYPE_COLORS = FILE_TYPE_COLORS;
5824
6441
  exports.FileIcon = FileIcon;
@@ -5835,7 +6452,9 @@ exports.Input = Input;
5835
6452
  exports.Label = Label;
5836
6453
  exports.LinkedInIcon = LinkedInIcon;
5837
6454
  exports.MessageArtifactCard = MessageArtifactCard;
6455
+ exports.NEUTRAL_GRAY = NEUTRAL_GRAY2;
5838
6456
  exports.OpenAIIcon = OpenAIIcon;
6457
+ exports.PLACEHOLDER_COLOR = PLACEHOLDER_COLOR;
5839
6458
  exports.PdfIcon = PdfIcon;
5840
6459
  exports.Popover = Popover;
5841
6460
  exports.PopoverAnchor = PopoverAnchor;
@@ -5887,20 +6506,35 @@ exports.TooltipTrigger = TooltipTrigger;
5887
6506
  exports.TxtIcon = TxtIcon;
5888
6507
  exports.TypingIndicator = TypingIndicator;
5889
6508
  exports.UserEntity = UserEntity;
6509
+ exports.VISIBILITY_ICONS = VISIBILITY_ICONS;
5890
6510
  exports.VidIcon = VidIcon;
6511
+ exports.VisibilityIcon = VisibilityIcon;
5891
6512
  exports.XlsIcon = XlsIcon;
5892
6513
  exports.arbiQueryKeys = arbiQueryKeys;
5893
6514
  exports.badgeVariants = badgeVariants;
5894
6515
  exports.buttonVariants = buttonVariants;
5895
6516
  exports.cardVariants = cardVariants;
5896
6517
  exports.cn = cn;
6518
+ exports.configureEntityRegistry = configureEntityRegistry;
6519
+ exports.describeActivity = describeActivity;
6520
+ exports.getEntityColor = getEntityColor2;
6521
+ exports.getEntityColorStyles = getEntityColorStyles;
6522
+ exports.getEntityIcon = getEntityIcon;
6523
+ exports.getEntityLabel = getEntityLabel;
6524
+ exports.getNotificationTypeMeta = getNotificationTypeMeta;
5897
6525
  exports.getTagTypeIcon = getTagTypeIcon;
5898
6526
  exports.getTagTypeLabel = getTagTypeLabel;
6527
+ exports.getWorkspaceActionText = getWorkspaceActionText;
6528
+ exports.getWorkspaceColor = getWorkspaceColor;
6529
+ exports.getWorkspaceSentPhrase = getWorkspaceSentPhrase;
6530
+ exports.isWorkspaceNotificationType = isWorkspaceNotificationType;
5899
6531
  exports.markdownBaseComponents = markdownBaseComponents;
6532
+ exports.parseActivityContent = parseActivityContent;
5900
6533
  exports.redlineStats = redlineStats;
5901
6534
  exports.textToArtifact = textToArtifact;
5902
6535
  exports.toRedlineMarkdown = toRedlineMarkdown;
5903
6536
  exports.toggleVariants = toggleVariants;
6537
+ exports.useActivity = useActivity;
5904
6538
  exports.useAgents = useAgents;
5905
6539
  exports.useAiTask = useAiTask;
5906
6540
  exports.useArbi = useArbi;
@@ -5922,11 +6556,17 @@ exports.useDocuments = useDocuments;
5922
6556
  exports.useHealth = useHealth;
5923
6557
  exports.useMemories = useMemories;
5924
6558
  exports.useParsedDocument = useParsedDocument;
6559
+ exports.useProjectInvoices = useProjectInvoices;
6560
+ exports.useProjectUsage = useProjectUsage;
6561
+ exports.useProjects = useProjects;
6562
+ exports.useProjectsUsage = useProjectsUsage;
5925
6563
  exports.useSemanticSearch = useSemanticSearch;
5926
6564
  exports.useSessions = useSessions;
5927
6565
  exports.useTags = useTags;
5928
6566
  exports.useTasks = useTasks;
5929
6567
  exports.useThumbnails = useThumbnails;
6568
+ exports.useUserUsageToday = useUserUsageToday;
6569
+ exports.useWorkspaceChronology = useWorkspaceChronology;
5930
6570
  exports.useWorkspaceDocs = useWorkspaceDocs;
5931
6571
  exports.useWorkspaces = useWorkspaces;
5932
6572
  //# sourceMappingURL=index.cjs.map