@plaisolutions/react 0.15.0 → 0.16.0

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.
@@ -1,4 +1,4 @@
1
- import { Bot, Brain, Check, CheckCircle2, ChevronDown, CircleAlert, CircleX, Copy, Database, File, FileText, Globe, LoaderCircle, MessageSquare, Minus, Plug, Plus, RotateCcw, ThumbsDown, ThumbsUp, Workflow, XCircle } from "lucide-react";
1
+ import { Bot, Brain, CalendarDays, Check, CheckCircle2, ChevronDown, CircleAlert, CircleX, Clock, Copy, Database, ExternalLink, File, FileText, Globe, LoaderCircle, Mail, MessageSquare, Minus, Plug, Plus, RotateCcw, ThumbsDown, ThumbsUp, Video, Workflow, XCircle } from "lucide-react";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
4
4
  import { HttpStatusError } from "@plaisolutions/client";
@@ -2327,7 +2327,7 @@ function SourceCard({ source, locale, variant = "card" }) {
2327
2327
  });
2328
2328
  }
2329
2329
  function getTotalSourceCount(cards) {
2330
- return cards.reduce((count, source) => count + (source.kind === "web" ? getWebSearchResults(source.part).length : 1), 0);
2330
+ return cards.reduce((count$1, source) => count$1 + (source.kind === "web" ? getWebSearchResults(source.part).length : 1), 0);
2331
2331
  }
2332
2332
  function AggregatedSourceResults({ parts, locale, maxVisible = 3, className, getResourceDownloadUrl }) {
2333
2333
  const cards = getAggregatedCards(parts, locale, getResourceDownloadUrl);
@@ -2379,7 +2379,7 @@ function AggregatedSourceResults({ parts, locale, maxVisible = 3, className, get
2379
2379
 
2380
2380
  //#endregion
2381
2381
  //#region src/components/memory-proposal-card.tsx
2382
- const COPY = {
2382
+ const COPY$1 = {
2383
2383
  en: {
2384
2384
  title: "Memory proposal",
2385
2385
  user: "Personal memory",
@@ -2603,7 +2603,7 @@ const COPY = {
2603
2603
  };
2604
2604
  const REDACTED = "[redacted]";
2605
2605
  function MemoryProposalCard({ proposal: initial, actions, activeAgentId, locale, className }) {
2606
- const copy = COPY[getSupportedToolLocale(locale)];
2606
+ const copy = COPY$1[getSupportedToolLocale(locale)];
2607
2607
  const [proposal, setProposal] = useState(initial);
2608
2608
  const [resolving, setResolving] = useState(false);
2609
2609
  const [error, setError] = useState(null);
@@ -2914,7 +2914,7 @@ function ToolResultAgentInvocationCard({ part, className, onOpenThread, locale }
2914
2914
  children: copy.agent
2915
2915
  }),
2916
2916
  /* @__PURE__ */ jsx("span", {
2917
- className: "min-w-0 truncate text-neutral-600",
2917
+ className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
2918
2918
  children: agentName
2919
2919
  }),
2920
2920
  /* @__PURE__ */ jsx("span", {
@@ -3042,9 +3042,7 @@ function ToolResultBrowserCard({ part, className, locale }) {
3042
3042
  const preview = getPreview(toOutput(part.result));
3043
3043
  const url = getUrl(part.input);
3044
3044
  const error = formatToolErrorDetails(part.errorDetails);
3045
- const scraperLabel = metadata?.scraper_type ? SCRAPER_LABELS[metadata.scraper_type] : null;
3046
- const credits = metadata?.scraper_api_tokens ?? metadata?.firecrawl_credits;
3047
- const subtitle = [scraperLabel, typeof credits === "number" ? `${credits} ${credits === 1 ? copy.credit : copy.credits}` : null].filter(Boolean).join(" · ");
3045
+ const subtitle = metadata?.scraper_type ? SCRAPER_LABELS[metadata.scraper_type] : null;
3048
3046
  const failed = part.state === "error";
3049
3047
  const pending = part.state === "pending";
3050
3048
  const canExpand = Boolean(preview || error || url);
@@ -3063,7 +3061,7 @@ function ToolResultBrowserCard({ part, className, locale }) {
3063
3061
  children: copy.browser
3064
3062
  }),
3065
3063
  subtitle ? /* @__PURE__ */ jsx("span", {
3066
- className: "min-w-0 truncate text-xs text-neutral-500",
3064
+ className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
3067
3065
  children: subtitle
3068
3066
  }) : null,
3069
3067
  /* @__PURE__ */ jsxs("span", {
@@ -3201,7 +3199,7 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3201
3199
  }), /* @__PURE__ */ jsxs("div", {
3202
3200
  className: "flex items-center gap-2",
3203
3201
  children: [/* @__PURE__ */ jsx("span", {
3204
- className: joinClasses("rounded-full border px-2 py-0.5 text-xs font-medium", statusClass),
3202
+ className: joinClasses("rounded-full uppercase border px-2 py-0.5 text-xs", statusClass),
3205
3203
  children: getUiStatusLabel(part.state, copy)
3206
3204
  }), /* @__PURE__ */ jsx("button", {
3207
3205
  type: "button",
@@ -3210,28 +3208,31 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3210
3208
  "aria-controls": `tool-email-details-${part.id}`,
3211
3209
  className: "inline-flex h-6 w-6 items-center justify-center rounded border border-slate-300 bg-white text-xs text-slate-700 hover:bg-slate-100",
3212
3210
  onClick: () => setIsExpanded((previous) => !previous),
3213
- children: /* @__PURE__ */ jsx("span", {
3214
- className: "inline-block",
3215
- children: isExpanded ? "^" : "v"
3211
+ children: isExpanded ? /* @__PURE__ */ jsx(Minus, {
3212
+ className: "h-3 w-3",
3213
+ "aria-hidden": "true"
3214
+ }) : /* @__PURE__ */ jsx(Plus, {
3215
+ className: "h-3 w-3",
3216
+ "aria-hidden": "true"
3216
3217
  })
3217
3218
  })]
3218
3219
  })]
3219
3220
  }),
3220
3221
  emailInput.subject ? /* @__PURE__ */ jsxs("div", {
3221
- className: "space-y-1",
3222
- children: [/* @__PURE__ */ jsx("p", {
3222
+ className: "flex items-center gap-1",
3223
+ children: [/* @__PURE__ */ jsxs("p", {
3223
3224
  className: "text-xs font-semibold text-slate-600",
3224
- children: copy.subject
3225
+ children: [copy.subject, ":"]
3225
3226
  }), /* @__PURE__ */ jsx("p", {
3226
- className: "text-sm text-slate-900",
3227
+ className: "text-xs text-slate-900",
3227
3228
  children: emailInput.subject
3228
3229
  })]
3229
3230
  }) : null,
3230
3231
  /* @__PURE__ */ jsxs("div", {
3231
- className: "space-y-1",
3232
- children: [/* @__PURE__ */ jsx("p", {
3232
+ className: "flex items-center gap-1",
3233
+ children: [/* @__PURE__ */ jsxs("p", {
3233
3234
  className: "text-xs font-semibold text-slate-600",
3234
- children: copy.to
3235
+ children: [copy.to, ":"]
3235
3236
  }), emailInput.to.length > 0 ? /* @__PURE__ */ jsx("div", {
3236
3237
  className: "flex flex-wrap gap-2",
3237
3238
  children: emailInput.to.map((recipient) => /* @__PURE__ */ jsx("span", {
@@ -3239,7 +3240,7 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3239
3240
  children: recipient
3240
3241
  }, recipient))
3241
3242
  }) : /* @__PURE__ */ jsx("p", {
3242
- className: "text-sm text-slate-500",
3243
+ className: "text-xs text-slate-500",
3243
3244
  children: copy.noRecipientsProvided
3244
3245
  })]
3245
3246
  }),
@@ -3249,22 +3250,22 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3249
3250
  className: joinClasses(isExpanded ? "block space-y-4" : "hidden"),
3250
3251
  children: [emailInput.text ? /* @__PURE__ */ jsxs("div", {
3251
3252
  className: "space-y-1",
3252
- children: [/* @__PURE__ */ jsx("p", {
3253
+ children: [/* @__PURE__ */ jsxs("p", {
3253
3254
  className: "text-xs font-semibold text-slate-600",
3254
- children: copy.body
3255
+ children: [copy.body, ":"]
3255
3256
  }), /* @__PURE__ */ jsx("p", {
3256
- className: "whitespace-pre-wrap rounded border border-slate-200 bg-slate-50 p-2 text-sm text-slate-700",
3257
+ className: "whitespace-pre-wrap rounded border border-slate-200 bg-white p-2 text-sm text-slate-700",
3257
3258
  children: emailInput.text
3258
3259
  })]
3259
3260
  }) : null, part.result !== void 0 ? /* @__PURE__ */ jsxs("div", {
3260
- className: "space-y-2 rounded border border-slate-200 bg-white p-3",
3261
+ className: "space-y-2 rounded border border-slate-200 bg-slate-50 p-3",
3261
3262
  children: [
3262
3263
  /* @__PURE__ */ jsx("p", {
3263
3264
  className: "text-xs font-semibold uppercase tracking-wide text-slate-500",
3264
3265
  children: copy.delivery
3265
3266
  }),
3266
3267
  emailResult.status ? /* @__PURE__ */ jsxs("p", {
3267
- className: "text-sm text-slate-700",
3268
+ className: "text-xs text-slate-700",
3268
3269
  children: [
3269
3270
  /* @__PURE__ */ jsxs("span", {
3270
3271
  className: "font-semibold text-slate-900",
@@ -3275,7 +3276,7 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3275
3276
  ]
3276
3277
  }) : null,
3277
3278
  emailResult.recipientsCount !== null ? /* @__PURE__ */ jsxs("p", {
3278
- className: "text-sm text-slate-700",
3279
+ className: "text-xs text-slate-700",
3279
3280
  children: [
3280
3281
  /* @__PURE__ */ jsxs("span", {
3281
3282
  className: "font-semibold text-slate-900",
@@ -3286,7 +3287,7 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3286
3287
  ]
3287
3288
  }) : null,
3288
3289
  emailResult.receiptProvider ? /* @__PURE__ */ jsxs("p", {
3289
- className: "text-sm text-slate-700",
3290
+ className: "text-xs text-slate-700",
3290
3291
  children: [
3291
3292
  /* @__PURE__ */ jsxs("span", {
3292
3293
  className: "font-semibold text-slate-900",
@@ -3297,7 +3298,7 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3297
3298
  ]
3298
3299
  }) : null,
3299
3300
  emailResult.receiptMessageId ? /* @__PURE__ */ jsxs("p", {
3300
- className: "break-all text-sm text-slate-700",
3301
+ className: "break-all text-xs text-slate-700",
3301
3302
  children: [
3302
3303
  /* @__PURE__ */ jsxs("span", {
3303
3304
  className: "font-semibold text-slate-900",
@@ -3308,7 +3309,7 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3308
3309
  ]
3309
3310
  }) : null,
3310
3311
  emailResult.receiptRawStatus ? /* @__PURE__ */ jsxs("p", {
3311
- className: "text-sm text-slate-700",
3312
+ className: "text-xs text-slate-700",
3312
3313
  children: [
3313
3314
  /* @__PURE__ */ jsxs("span", {
3314
3315
  className: "font-semibold text-slate-900",
@@ -3319,7 +3320,7 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3319
3320
  ]
3320
3321
  }) : null,
3321
3322
  emailResult.raw ? /* @__PURE__ */ jsx("p", {
3322
- className: "whitespace-pre-wrap text-sm text-slate-700",
3323
+ className: "whitespace-pre-wrap text-xs text-slate-700",
3323
3324
  children: emailResult.raw
3324
3325
  }) : null
3325
3326
  ]
@@ -3632,7 +3633,7 @@ function ToolResultHttpRequestCard({ part, className, locale }) {
3632
3633
 
3633
3634
  //#endregion
3634
3635
  //#region src/components/tool-result-mcp-card.tsx
3635
- function text(value) {
3636
+ function text$1(value) {
3636
3637
  if (typeof value === "string") return value;
3637
3638
  if (value == null) return null;
3638
3639
  try {
@@ -3646,7 +3647,7 @@ function ToolResultMcpCard({ part, className, locale }) {
3646
3647
  const meta = part.metadata;
3647
3648
  const server = meta?.mcp_server_url ?? meta?.server_name;
3648
3649
  const tool = meta?.mcp_tool_name ?? meta?.tool_name ?? part.name;
3649
- const result = text(part.result);
3650
+ const result = text$1(part.result);
3650
3651
  const error = formatToolErrorDetails(part.errorDetails);
3651
3652
  const failed = part.state === "error";
3652
3653
  return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
@@ -3664,7 +3665,7 @@ function ToolResultMcpCard({ part, className, locale }) {
3664
3665
  children: "MCP"
3665
3666
  }),
3666
3667
  /* @__PURE__ */ jsx("span", {
3667
- className: "min-w-0 truncate text-neutral-600",
3668
+ className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
3668
3669
  children: tool
3669
3670
  }),
3670
3671
  /* @__PURE__ */ jsx("span", {
@@ -3773,7 +3774,7 @@ function ToolResultOfficeDocumentsCard({ part, className, locale }) {
3773
3774
  children: copy.officeDocuments
3774
3775
  }),
3775
3776
  /* @__PURE__ */ jsx("span", {
3776
- className: "truncate text-xs text-neutral-500",
3777
+ className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
3777
3778
  children: part.state === "pending" ? copy.pending : `${files.length} ${fileLabel}`
3778
3779
  }),
3779
3780
  /* @__PURE__ */ jsx("span", {
@@ -3848,6 +3849,1318 @@ function ToolResultOfficeDocumentsCard({ part, className, locale }) {
3848
3849
  })] });
3849
3850
  }
3850
3851
 
3852
+ //#endregion
3853
+ //#region src/components/internal/personal-connector-copy.ts
3854
+ const ENGLISH = {
3855
+ searchingMail: "Searching {{service}}",
3856
+ readingMail: "Reading an email in {{service}}",
3857
+ checkingCalendar: "Checking {{service}}",
3858
+ savingDraft: "Saving a draft in {{service}}",
3859
+ preparingMail: "Preparing an email in {{service}}",
3860
+ preparingEvent: "Preparing a change in {{service}}",
3861
+ runningConfirmed: "Running the confirmed actions",
3862
+ openIn: "Open in {{service}}",
3863
+ emailCountOne: "1 email",
3864
+ emailCountOther: "{{count}} emails",
3865
+ eventCountOne: "1 event",
3866
+ eventCountOther: "{{count}} events",
3867
+ noEmails: "No emails found",
3868
+ noEvents: "No events in this period",
3869
+ showAll: "Show all ({{count}})",
3870
+ showLess: "Show less",
3871
+ showMore: "Show more",
3872
+ allDay: "All day",
3873
+ to: "To",
3874
+ cc: "Cc",
3875
+ draftSaved: "Draft saved",
3876
+ openDraft: "Open draft",
3877
+ attendeesOne: "1 attendee",
3878
+ attendeesOther: "{{count}} attendees",
3879
+ noSubject: "(no subject)",
3880
+ unread: "Unread",
3881
+ joinMeeting: "Join",
3882
+ awaitingConfirmation: "Awaiting your confirmation",
3883
+ confirmHint: "Reply “yes” to confirm, or tell the agent what to change.",
3884
+ subject: "Subject",
3885
+ newEvent: "New event",
3886
+ eventChange: "Event change",
3887
+ deleteEvent: "Delete event",
3888
+ attendeesNotified: "Attendees will be notified.",
3889
+ title: "Title",
3890
+ when: "When",
3891
+ location: "Location",
3892
+ attendees: "Attendees",
3893
+ description: "Description",
3894
+ emailSent: "Email sent",
3895
+ eventCreated: "Event created",
3896
+ eventUpdated: "Event updated",
3897
+ eventDeleted: "Event deleted",
3898
+ actionDone: "{{tool}} done",
3899
+ actionFailed: "Failed",
3900
+ openEmail: "Open email",
3901
+ openEvent: "Open event",
3902
+ replyInThread: "Reply in the same thread"
3903
+ };
3904
+ const COPY = {
3905
+ en: {},
3906
+ es: {
3907
+ searchingMail: "Buscando en {{service}}",
3908
+ readingMail: "Leyendo un correo en {{service}}",
3909
+ checkingCalendar: "Consultando {{service}}",
3910
+ savingDraft: "Guardando un borrador en {{service}}",
3911
+ preparingMail: "Preparando un correo en {{service}}",
3912
+ preparingEvent: "Preparando un cambio en {{service}}",
3913
+ runningConfirmed: "Ejecutando las acciones confirmadas",
3914
+ openIn: "Abrir en {{service}}",
3915
+ emailCountOne: "1 correo",
3916
+ emailCountOther: "{{count}} correos",
3917
+ eventCountOne: "1 evento",
3918
+ eventCountOther: "{{count}} eventos",
3919
+ noEmails: "No se han encontrado correos",
3920
+ noEvents: "No hay eventos en este periodo",
3921
+ showAll: "Ver todos ({{count}})",
3922
+ showLess: "Ver menos",
3923
+ showMore: "Ver más",
3924
+ allDay: "Todo el día",
3925
+ to: "Para",
3926
+ cc: "CC",
3927
+ draftSaved: "Borrador guardado",
3928
+ openDraft: "Abrir borrador",
3929
+ attendeesOne: "1 asistente",
3930
+ attendeesOther: "{{count}} asistentes",
3931
+ noSubject: "(sin asunto)",
3932
+ unread: "No leído",
3933
+ joinMeeting: "Unirse",
3934
+ awaitingConfirmation: "Pendiente de tu confirmación",
3935
+ confirmHint: "Responde «sí» para confirmar, o dile al agente qué cambiar.",
3936
+ subject: "Asunto",
3937
+ newEvent: "Nuevo evento",
3938
+ eventChange: "Cambio en el evento",
3939
+ deleteEvent: "Borrar evento",
3940
+ attendeesNotified: "Se avisará a los asistentes.",
3941
+ title: "Título",
3942
+ when: "Cuándo",
3943
+ location: "Ubicación",
3944
+ attendees: "Asistentes",
3945
+ description: "Descripción",
3946
+ emailSent: "Correo enviado",
3947
+ eventCreated: "Evento creado",
3948
+ eventUpdated: "Evento actualizado",
3949
+ eventDeleted: "Evento borrado",
3950
+ actionDone: "{{tool}} hecho",
3951
+ actionFailed: "Error",
3952
+ openEmail: "Abrir correo",
3953
+ openEvent: "Abrir evento",
3954
+ replyInThread: "Respuesta en el mismo hilo"
3955
+ },
3956
+ ca: {
3957
+ searchingMail: "Cercant a {{service}}",
3958
+ readingMail: "Llegint un correu a {{service}}",
3959
+ checkingCalendar: "Consultant {{service}}",
3960
+ savingDraft: "Desant un esborrany a {{service}}",
3961
+ preparingMail: "Preparant un correu a {{service}}",
3962
+ preparingEvent: "Preparant un canvi a {{service}}",
3963
+ runningConfirmed: "Executant les accions confirmades",
3964
+ openIn: "Obre a {{service}}",
3965
+ emailCountOne: "1 correu",
3966
+ emailCountOther: "{{count}} correus",
3967
+ eventCountOne: "1 esdeveniment",
3968
+ eventCountOther: "{{count}} esdeveniments",
3969
+ noEmails: "No s’han trobat correus",
3970
+ noEvents: "No hi ha esdeveniments en aquest període",
3971
+ showAll: "Mostra-ho tot ({{count}})",
3972
+ showLess: "Mostra’n menys",
3973
+ showMore: "Mostra’n més",
3974
+ allDay: "Tot el dia",
3975
+ to: "Per a",
3976
+ cc: "CC",
3977
+ draftSaved: "Esborrany desat",
3978
+ openDraft: "Obre l’esborrany",
3979
+ attendeesOne: "1 assistent",
3980
+ attendeesOther: "{{count}} assistents",
3981
+ noSubject: "(sense assumpte)",
3982
+ unread: "No llegit",
3983
+ joinMeeting: "Uneix-t’hi",
3984
+ awaitingConfirmation: "Pendent de la teva confirmació",
3985
+ confirmHint: "Respon «sí» per confirmar, o digues a l’agent què ha de canviar.",
3986
+ subject: "Assumpte",
3987
+ newEvent: "Nou esdeveniment",
3988
+ eventChange: "Canvi a l’esdeveniment",
3989
+ deleteEvent: "Esborrar esdeveniment",
3990
+ attendeesNotified: "S’avisarà els assistents.",
3991
+ title: "Títol",
3992
+ when: "Quan",
3993
+ location: "Ubicació",
3994
+ attendees: "Assistents",
3995
+ description: "Descripció",
3996
+ emailSent: "Correu enviat",
3997
+ eventCreated: "Esdeveniment creat",
3998
+ eventUpdated: "Esdeveniment actualitzat",
3999
+ eventDeleted: "Esdeveniment esborrat",
4000
+ actionDone: "{{tool}} fet",
4001
+ actionFailed: "Error",
4002
+ openEmail: "Obre el correu",
4003
+ openEvent: "Obre l’esdeveniment",
4004
+ replyInThread: "Resposta al mateix fil"
4005
+ },
4006
+ fr: {
4007
+ searchingMail: "Recherche dans {{service}}",
4008
+ readingMail: "Lecture d’un e-mail dans {{service}}",
4009
+ checkingCalendar: "Consultation de {{service}}",
4010
+ savingDraft: "Enregistrement d’un brouillon dans {{service}}",
4011
+ preparingMail: "Préparation d’un e-mail dans {{service}}",
4012
+ preparingEvent: "Préparation d’une modification dans {{service}}",
4013
+ runningConfirmed: "Exécution des actions confirmées",
4014
+ openIn: "Ouvrir dans {{service}}",
4015
+ emailCountOne: "1 e-mail",
4016
+ emailCountOther: "{{count}} e-mails",
4017
+ eventCountOne: "1 événement",
4018
+ eventCountOther: "{{count}} événements",
4019
+ noEmails: "Aucun e-mail trouvé",
4020
+ noEvents: "Aucun événement sur cette période",
4021
+ showAll: "Tout afficher ({{count}})",
4022
+ showLess: "Afficher moins",
4023
+ showMore: "Afficher plus",
4024
+ allDay: "Toute la journée",
4025
+ to: "À",
4026
+ cc: "Cc",
4027
+ draftSaved: "Brouillon enregistré",
4028
+ openDraft: "Ouvrir le brouillon",
4029
+ attendeesOne: "1 participant",
4030
+ attendeesOther: "{{count}} participants",
4031
+ noSubject: "(sans objet)",
4032
+ unread: "Non lu",
4033
+ joinMeeting: "Rejoindre",
4034
+ awaitingConfirmation: "En attente de votre confirmation",
4035
+ confirmHint: "Répondez « oui » pour confirmer, ou dites à l’agent quoi modifier.",
4036
+ subject: "Objet",
4037
+ newEvent: "Nouvel événement",
4038
+ eventChange: "Modification de l’événement",
4039
+ deleteEvent: "Supprimer l’événement",
4040
+ attendeesNotified: "Les participants seront prévenus.",
4041
+ title: "Titre",
4042
+ when: "Quand",
4043
+ location: "Lieu",
4044
+ attendees: "Participants",
4045
+ description: "Description",
4046
+ emailSent: "E-mail envoyé",
4047
+ eventCreated: "Événement créé",
4048
+ eventUpdated: "Événement mis à jour",
4049
+ eventDeleted: "Événement supprimé",
4050
+ actionDone: "{{tool}} terminé",
4051
+ actionFailed: "Échec",
4052
+ openEmail: "Ouvrir l’e-mail",
4053
+ openEvent: "Ouvrir l’événement",
4054
+ replyInThread: "Réponse dans le même fil"
4055
+ },
4056
+ it: {
4057
+ searchingMail: "Ricerca in {{service}}",
4058
+ readingMail: "Lettura di un’email in {{service}}",
4059
+ checkingCalendar: "Consultazione di {{service}}",
4060
+ savingDraft: "Salvataggio di una bozza in {{service}}",
4061
+ preparingMail: "Preparazione di un’email in {{service}}",
4062
+ preparingEvent: "Preparazione di una modifica in {{service}}",
4063
+ runningConfirmed: "Esecuzione delle azioni confermate",
4064
+ openIn: "Apri in {{service}}",
4065
+ emailCountOne: "1 email",
4066
+ emailCountOther: "{{count}} email",
4067
+ eventCountOne: "1 evento",
4068
+ eventCountOther: "{{count}} eventi",
4069
+ noEmails: "Nessuna email trovata",
4070
+ noEvents: "Nessun evento in questo periodo",
4071
+ showAll: "Mostra tutto ({{count}})",
4072
+ showLess: "Mostra meno",
4073
+ showMore: "Mostra di più",
4074
+ allDay: "Tutto il giorno",
4075
+ to: "A",
4076
+ cc: "Cc",
4077
+ draftSaved: "Bozza salvata",
4078
+ openDraft: "Apri bozza",
4079
+ attendeesOne: "1 partecipante",
4080
+ attendeesOther: "{{count}} partecipanti",
4081
+ noSubject: "(nessun oggetto)",
4082
+ unread: "Non letta",
4083
+ joinMeeting: "Partecipa",
4084
+ awaitingConfirmation: "In attesa della tua conferma",
4085
+ confirmHint: "Rispondi «sì» per confermare, o di’ all’agente cosa cambiare.",
4086
+ subject: "Oggetto",
4087
+ newEvent: "Nuovo evento",
4088
+ eventChange: "Modifica dell’evento",
4089
+ deleteEvent: "Elimina evento",
4090
+ attendeesNotified: "I partecipanti verranno avvisati.",
4091
+ title: "Titolo",
4092
+ when: "Quando",
4093
+ location: "Luogo",
4094
+ attendees: "Partecipanti",
4095
+ description: "Descrizione",
4096
+ emailSent: "Email inviata",
4097
+ eventCreated: "Evento creato",
4098
+ eventUpdated: "Evento aggiornato",
4099
+ eventDeleted: "Evento eliminato",
4100
+ actionDone: "{{tool}} completato",
4101
+ actionFailed: "Errore",
4102
+ openEmail: "Apri email",
4103
+ openEvent: "Apri evento",
4104
+ replyInThread: "Risposta nello stesso thread"
4105
+ },
4106
+ de: {
4107
+ searchingMail: "Suche in {{service}}",
4108
+ readingMail: "E-Mail in {{service}} wird gelesen",
4109
+ checkingCalendar: "{{service}} wird abgefragt",
4110
+ savingDraft: "Entwurf wird in {{service}} gespeichert",
4111
+ preparingMail: "E-Mail in {{service}} wird vorbereitet",
4112
+ preparingEvent: "Änderung in {{service}} wird vorbereitet",
4113
+ runningConfirmed: "Bestätigte Aktionen werden ausgeführt",
4114
+ openIn: "In {{service}} öffnen",
4115
+ emailCountOne: "1 E-Mail",
4116
+ emailCountOther: "{{count}} E-Mails",
4117
+ eventCountOne: "1 Termin",
4118
+ eventCountOther: "{{count}} Termine",
4119
+ noEmails: "Keine E-Mails gefunden",
4120
+ noEvents: "Keine Termine in diesem Zeitraum",
4121
+ showAll: "Alle anzeigen ({{count}})",
4122
+ showLess: "Weniger anzeigen",
4123
+ showMore: "Mehr anzeigen",
4124
+ allDay: "Ganztägig",
4125
+ to: "An",
4126
+ cc: "Cc",
4127
+ draftSaved: "Entwurf gespeichert",
4128
+ openDraft: "Entwurf öffnen",
4129
+ attendeesOne: "1 Teilnehmer",
4130
+ attendeesOther: "{{count}} Teilnehmer",
4131
+ noSubject: "(kein Betreff)",
4132
+ unread: "Ungelesen",
4133
+ joinMeeting: "Teilnehmen",
4134
+ awaitingConfirmation: "Wartet auf deine Bestätigung",
4135
+ confirmHint: "Antworte mit „ja“, um zu bestätigen, oder sag dem Agenten, was er ändern soll.",
4136
+ subject: "Betreff",
4137
+ newEvent: "Neuer Termin",
4138
+ eventChange: "Terminänderung",
4139
+ deleteEvent: "Termin löschen",
4140
+ attendeesNotified: "Die Teilnehmer werden benachrichtigt.",
4141
+ title: "Titel",
4142
+ when: "Wann",
4143
+ location: "Ort",
4144
+ attendees: "Teilnehmer",
4145
+ description: "Beschreibung",
4146
+ emailSent: "E-Mail gesendet",
4147
+ eventCreated: "Termin erstellt",
4148
+ eventUpdated: "Termin aktualisiert",
4149
+ eventDeleted: "Termin gelöscht",
4150
+ actionDone: "{{tool}} erledigt",
4151
+ actionFailed: "Fehlgeschlagen",
4152
+ openEmail: "E-Mail öffnen",
4153
+ openEvent: "Termin öffnen",
4154
+ replyInThread: "Antwort im selben Verlauf"
4155
+ },
4156
+ da: {
4157
+ searchingMail: "Søger i {{service}}",
4158
+ readingMail: "Læser en e-mail i {{service}}",
4159
+ checkingCalendar: "Tjekker {{service}}",
4160
+ savingDraft: "Gemmer en kladde i {{service}}",
4161
+ preparingMail: "Forbereder en e-mail i {{service}}",
4162
+ preparingEvent: "Forbereder en ændring i {{service}}",
4163
+ runningConfirmed: "Udfører de bekræftede handlinger",
4164
+ openIn: "Åbn i {{service}}",
4165
+ emailCountOne: "1 e-mail",
4166
+ emailCountOther: "{{count}} e-mails",
4167
+ eventCountOne: "1 begivenhed",
4168
+ eventCountOther: "{{count}} begivenheder",
4169
+ noEmails: "Ingen e-mails fundet",
4170
+ noEvents: "Ingen begivenheder i denne periode",
4171
+ showAll: "Vis alle ({{count}})",
4172
+ showLess: "Vis mindre",
4173
+ showMore: "Vis mere",
4174
+ allDay: "Hele dagen",
4175
+ to: "Til",
4176
+ cc: "Cc",
4177
+ draftSaved: "Kladde gemt",
4178
+ openDraft: "Åbn kladde",
4179
+ attendeesOne: "1 deltager",
4180
+ attendeesOther: "{{count}} deltagere",
4181
+ noSubject: "(intet emne)",
4182
+ unread: "Ulæst",
4183
+ joinMeeting: "Deltag",
4184
+ awaitingConfirmation: "Afventer din bekræftelse",
4185
+ confirmHint: "Svar “ja” for at bekræfte, eller fortæl agenten, hvad der skal ændres.",
4186
+ subject: "Emne",
4187
+ newEvent: "Ny begivenhed",
4188
+ eventChange: "Ændring af begivenhed",
4189
+ deleteEvent: "Slet begivenhed",
4190
+ attendeesNotified: "Deltagerne får besked.",
4191
+ title: "Titel",
4192
+ when: "Hvornår",
4193
+ location: "Sted",
4194
+ attendees: "Deltagere",
4195
+ description: "Beskrivelse",
4196
+ emailSent: "E-mail sendt",
4197
+ eventCreated: "Begivenhed oprettet",
4198
+ eventUpdated: "Begivenhed opdateret",
4199
+ eventDeleted: "Begivenhed slettet",
4200
+ actionDone: "{{tool}} udført",
4201
+ actionFailed: "Mislykkedes",
4202
+ openEmail: "Åbn e-mail",
4203
+ openEvent: "Åbn begivenhed",
4204
+ replyInThread: "Svar i samme tråd"
4205
+ },
4206
+ sv: {
4207
+ searchingMail: "Söker i {{service}}",
4208
+ readingMail: "Läser ett mejl i {{service}}",
4209
+ checkingCalendar: "Kollar {{service}}",
4210
+ savingDraft: "Sparar ett utkast i {{service}}",
4211
+ preparingMail: "Förbereder ett mejl i {{service}}",
4212
+ preparingEvent: "Förbereder en ändring i {{service}}",
4213
+ runningConfirmed: "Utför de bekräftade åtgärderna",
4214
+ openIn: "Öppna i {{service}}",
4215
+ emailCountOne: "1 mejl",
4216
+ emailCountOther: "{{count}} mejl",
4217
+ eventCountOne: "1 händelse",
4218
+ eventCountOther: "{{count}} händelser",
4219
+ noEmails: "Inga mejl hittades",
4220
+ noEvents: "Inga händelser under perioden",
4221
+ showAll: "Visa alla ({{count}})",
4222
+ showLess: "Visa mindre",
4223
+ showMore: "Visa mer",
4224
+ allDay: "Heldag",
4225
+ to: "Till",
4226
+ cc: "Kopia",
4227
+ draftSaved: "Utkast sparat",
4228
+ openDraft: "Öppna utkast",
4229
+ attendeesOne: "1 deltagare",
4230
+ attendeesOther: "{{count}} deltagare",
4231
+ noSubject: "(inget ämne)",
4232
+ unread: "Oläst",
4233
+ joinMeeting: "Anslut",
4234
+ awaitingConfirmation: "Väntar på din bekräftelse",
4235
+ confirmHint: "Svara ”ja” för att bekräfta, eller säg till agenten vad som ska ändras.",
4236
+ subject: "Ämne",
4237
+ newEvent: "Ny händelse",
4238
+ eventChange: "Ändring av händelse",
4239
+ deleteEvent: "Ta bort händelse",
4240
+ attendeesNotified: "Deltagarna meddelas.",
4241
+ title: "Titel",
4242
+ when: "När",
4243
+ location: "Plats",
4244
+ attendees: "Deltagare",
4245
+ description: "Beskrivning",
4246
+ emailSent: "Mejl skickat",
4247
+ eventCreated: "Händelse skapad",
4248
+ eventUpdated: "Händelse uppdaterad",
4249
+ eventDeleted: "Händelse borttagen",
4250
+ actionDone: "{{tool}} klar",
4251
+ actionFailed: "Misslyckades",
4252
+ openEmail: "Öppna mejl",
4253
+ openEvent: "Öppna händelse",
4254
+ replyInThread: "Svar i samma tråd"
4255
+ },
4256
+ no: {
4257
+ searchingMail: "Søker i {{service}}",
4258
+ readingMail: "Leser en e-post i {{service}}",
4259
+ checkingCalendar: "Sjekker {{service}}",
4260
+ savingDraft: "Lagrer et utkast i {{service}}",
4261
+ preparingMail: "Forbereder en e-post i {{service}}",
4262
+ preparingEvent: "Forbereder en endring i {{service}}",
4263
+ runningConfirmed: "Utfører de bekreftede handlingene",
4264
+ openIn: "Åpne i {{service}}",
4265
+ emailCountOne: "1 e-post",
4266
+ emailCountOther: "{{count}} e-poster",
4267
+ eventCountOne: "1 hendelse",
4268
+ eventCountOther: "{{count}} hendelser",
4269
+ noEmails: "Fant ingen e-poster",
4270
+ noEvents: "Ingen hendelser i denne perioden",
4271
+ showAll: "Vis alle ({{count}})",
4272
+ showLess: "Vis mindre",
4273
+ showMore: "Vis mer",
4274
+ allDay: "Hele dagen",
4275
+ to: "Til",
4276
+ cc: "Kopi",
4277
+ draftSaved: "Utkast lagret",
4278
+ openDraft: "Åpne utkast",
4279
+ attendeesOne: "1 deltaker",
4280
+ attendeesOther: "{{count}} deltakere",
4281
+ noSubject: "(intet emne)",
4282
+ unread: "Ulest",
4283
+ joinMeeting: "Bli med",
4284
+ awaitingConfirmation: "Venter på bekreftelsen din",
4285
+ confirmHint: "Svar «ja» for å bekrefte, eller si til agenten hva som skal endres.",
4286
+ subject: "Emne",
4287
+ newEvent: "Ny hendelse",
4288
+ eventChange: "Endring av hendelse",
4289
+ deleteEvent: "Slett hendelse",
4290
+ attendeesNotified: "Deltakerne blir varslet.",
4291
+ title: "Tittel",
4292
+ when: "Når",
4293
+ location: "Sted",
4294
+ attendees: "Deltakere",
4295
+ description: "Beskrivelse",
4296
+ emailSent: "E-post sendt",
4297
+ eventCreated: "Hendelse opprettet",
4298
+ eventUpdated: "Hendelse oppdatert",
4299
+ eventDeleted: "Hendelse slettet",
4300
+ actionDone: "{{tool}} fullført",
4301
+ actionFailed: "Mislyktes",
4302
+ openEmail: "Åpne e-post",
4303
+ openEvent: "Åpne hendelse",
4304
+ replyInThread: "Svar i samme tråd"
4305
+ },
4306
+ pt: {
4307
+ searchingMail: "Pesquisando no {{service}}",
4308
+ readingMail: "Lendo um e-mail no {{service}}",
4309
+ checkingCalendar: "Consultando o {{service}}",
4310
+ savingDraft: "Salvando um rascunho no {{service}}",
4311
+ preparingMail: "Preparando um e-mail no {{service}}",
4312
+ preparingEvent: "Preparando uma alteração no {{service}}",
4313
+ runningConfirmed: "Executando as ações confirmadas",
4314
+ openIn: "Abrir no {{service}}",
4315
+ emailCountOne: "1 e-mail",
4316
+ emailCountOther: "{{count}} e-mails",
4317
+ eventCountOne: "1 evento",
4318
+ eventCountOther: "{{count}} eventos",
4319
+ noEmails: "Nenhum e-mail encontrado",
4320
+ noEvents: "Nenhum evento neste período",
4321
+ showAll: "Ver todos ({{count}})",
4322
+ showLess: "Ver menos",
4323
+ showMore: "Ver mais",
4324
+ allDay: "Dia inteiro",
4325
+ to: "Para",
4326
+ cc: "Cc",
4327
+ draftSaved: "Rascunho salvo",
4328
+ openDraft: "Abrir rascunho",
4329
+ attendeesOne: "1 participante",
4330
+ attendeesOther: "{{count}} participantes",
4331
+ noSubject: "(sem assunto)",
4332
+ unread: "Não lido",
4333
+ joinMeeting: "Entrar",
4334
+ awaitingConfirmation: "Aguardando sua confirmação",
4335
+ confirmHint: "Responda “sim” para confirmar, ou diga ao agente o que mudar.",
4336
+ subject: "Assunto",
4337
+ newEvent: "Novo evento",
4338
+ eventChange: "Alteração do evento",
4339
+ deleteEvent: "Excluir evento",
4340
+ attendeesNotified: "Os participantes serão avisados.",
4341
+ title: "Título",
4342
+ when: "Quando",
4343
+ location: "Local",
4344
+ attendees: "Participantes",
4345
+ description: "Descrição",
4346
+ emailSent: "E-mail enviado",
4347
+ eventCreated: "Evento criado",
4348
+ eventUpdated: "Evento atualizado",
4349
+ eventDeleted: "Evento excluído",
4350
+ actionDone: "{{tool}} concluído",
4351
+ actionFailed: "Falhou",
4352
+ openEmail: "Abrir e-mail",
4353
+ openEvent: "Abrir evento",
4354
+ replyInThread: "Resposta na mesma conversa"
4355
+ }
4356
+ };
4357
+ function getPersonalConnectorCopy(locale) {
4358
+ return {
4359
+ ...ENGLISH,
4360
+ ...COPY[getSupportedToolLocale(locale)]
4361
+ };
4362
+ }
4363
+ function fillCopy(template, values) {
4364
+ return template.replace(/\{\{(\w+)\}\}/g, (match, key) => key in values ? String(values[key]) : match);
4365
+ }
4366
+
4367
+ //#endregion
4368
+ //#region src/components/tool-result-personal-connector-card.tsx
4369
+ const COLLAPSED_ITEMS = 5;
4370
+ const COLLAPSED_BODY_CHARS = 600;
4371
+ const EVENT_OPERATIONS = [
4372
+ "create_event",
4373
+ "update_event",
4374
+ "delete_event"
4375
+ ];
4376
+ function isEventOperation(value) {
4377
+ return EVENT_OPERATIONS.includes(value);
4378
+ }
4379
+ function asRecord(value) {
4380
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
4381
+ }
4382
+ function text(value) {
4383
+ return typeof value === "string" && value.trim().length > 0 ? value : null;
4384
+ }
4385
+ function hasId(value) {
4386
+ return typeof asRecord(value)?.id === "string";
4387
+ }
4388
+ function getView(part) {
4389
+ const metadata = asRecord(part.metadata);
4390
+ if (!metadata || metadata.error) return null;
4391
+ const result = metadata.result;
4392
+ const pending = asRecord(metadata.pending_confirmation);
4393
+ if (pending) {
4394
+ const confirmation = pending;
4395
+ if (!asRecord(confirmation.action)) return null;
4396
+ if (metadata.action === "send") return {
4397
+ kind: "pending-mail",
4398
+ pending: confirmation
4399
+ };
4400
+ return isEventOperation(metadata.action) ? {
4401
+ kind: "pending-event",
4402
+ operation: metadata.action,
4403
+ pending: confirmation
4404
+ } : null;
4405
+ }
4406
+ switch (metadata.action) {
4407
+ case "search": return Array.isArray(result) ? {
4408
+ kind: "mail-list",
4409
+ messages: result.filter(hasId)
4410
+ } : null;
4411
+ case "read": return hasId(result) ? {
4412
+ kind: "mail",
4413
+ message: result
4414
+ } : null;
4415
+ case "list_events": return Array.isArray(result) ? {
4416
+ kind: "events",
4417
+ events: result.filter(hasId)
4418
+ } : null;
4419
+ case "create_draft": {
4420
+ const input = asRecord(part.input);
4421
+ return {
4422
+ kind: "draft",
4423
+ link: text(asRecord(result)?.link),
4424
+ to: Array.isArray(input?.to) ? input.to.filter((item) => typeof item === "string") : [],
4425
+ subject: text(input?.subject),
4426
+ body: text(input?.body)
4427
+ };
4428
+ }
4429
+ default: return null;
4430
+ }
4431
+ }
4432
+ /** Whether the part has a dedicated view; otherwise the generic card renders it. */
4433
+ function hasPersonalConnectorView(part) {
4434
+ return part.state === "completed" && getView(part) !== null;
4435
+ }
4436
+ function getConnector(part) {
4437
+ const connector = asRecord(asRecord(part.metadata)?.connector);
4438
+ return connector && typeof connector.label === "string" ? connector : null;
4439
+ }
4440
+ function isCalendar(connector) {
4441
+ return connector?.capability.includes("calendar") ?? false;
4442
+ }
4443
+ function dateFormatter(locale, options) {
4444
+ try {
4445
+ return new Intl.DateTimeFormat(locale ?? void 0, options);
4446
+ } catch {
4447
+ return new Intl.DateTimeFormat(void 0, options);
4448
+ }
4449
+ }
4450
+ /** All-day values come as "YYYY-MM-DD": read them as local dates, not UTC. */
4451
+ function parseDate(value) {
4452
+ if (!value) return null;
4453
+ const dateOnly = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
4454
+ const date = dateOnly ? new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3])) : new Date(value);
4455
+ return Number.isNaN(date.getTime()) ? null : date;
4456
+ }
4457
+ function isSameDay(a, b) {
4458
+ return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
4459
+ }
4460
+ function formatMailDate(value, locale) {
4461
+ const date = parseDate(value);
4462
+ if (!date) return value ?? null;
4463
+ return isSameDay(date, /* @__PURE__ */ new Date()) ? dateFormatter(locale, {
4464
+ hour: "2-digit",
4465
+ minute: "2-digit"
4466
+ }).format(date) : dateFormatter(locale, {
4467
+ day: "numeric",
4468
+ month: "short"
4469
+ }).format(date);
4470
+ }
4471
+ function formatFullDate(value, locale) {
4472
+ const date = parseDate(value);
4473
+ if (!date) return value ?? null;
4474
+ return dateFormatter(locale, {
4475
+ dateStyle: "medium",
4476
+ timeStyle: "short"
4477
+ }).format(date);
4478
+ }
4479
+ /** "Ana Pérez <ana@acme.com>" → "Ana Pérez". */
4480
+ function displayName(address) {
4481
+ if (!address) return null;
4482
+ const match = /^\s*"?([^"<]+?)"?\s*<[^>]+>\s*$/.exec(address);
4483
+ return match ? match[1] : address;
4484
+ }
4485
+ function count(copy, n, one, other) {
4486
+ return n === 1 ? one : fillCopy(other, { count: n });
4487
+ }
4488
+ function ExternalAnchor({ href, className, children, label }) {
4489
+ return /* @__PURE__ */ jsx("a", {
4490
+ href,
4491
+ target: "_blank",
4492
+ rel: "noreferrer noopener",
4493
+ "aria-label": label,
4494
+ className: joinClasses("inline-flex items-center gap-1 text-xs font-medium text-neutral-700 hover:text-neutral-950 hover:underline", className),
4495
+ children
4496
+ });
4497
+ }
4498
+ function ShowAllToggle({ total, expanded, onToggle, copy }) {
4499
+ if (total <= COLLAPSED_ITEMS) return null;
4500
+ return /* @__PURE__ */ jsx("button", {
4501
+ type: "button",
4502
+ onClick: onToggle,
4503
+ className: "w-full border-t border-neutral-200 px-3 py-2 text-left text-xs font-medium text-neutral-600 hover:bg-neutral-50 hover:text-neutral-950",
4504
+ children: expanded ? copy.showLess : fillCopy(copy.showAll, { count: total })
4505
+ });
4506
+ }
4507
+ function MailRow({ message, locale, copy }) {
4508
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [
4509
+ /* @__PURE__ */ jsxs("div", {
4510
+ className: "flex items-baseline gap-2",
4511
+ children: [
4512
+ /* @__PURE__ */ jsx("span", {
4513
+ "aria-label": message.unread ? copy.unread : void 0,
4514
+ className: joinClasses("h-2 w-2 shrink-0 self-center rounded-full", message.unread ? "bg-blue-600" : "bg-transparent")
4515
+ }),
4516
+ /* @__PURE__ */ jsx("span", {
4517
+ className: joinClasses("min-w-0 flex-1 truncate text-sm", message.unread ? "font-semibold text-neutral-950" : "text-neutral-800"),
4518
+ children: displayName(message.from) ?? "—"
4519
+ }),
4520
+ /* @__PURE__ */ jsx("span", {
4521
+ className: "shrink-0 text-xs text-neutral-500",
4522
+ children: formatMailDate(message.date, locale)
4523
+ })
4524
+ ]
4525
+ }),
4526
+ /* @__PURE__ */ jsx("p", {
4527
+ className: joinClasses("truncate pl-4 text-sm", message.unread ? "font-medium text-neutral-950" : "text-neutral-700"),
4528
+ children: text(message.subject) ?? copy.noSubject
4529
+ }),
4530
+ text(message.snippet) ? /* @__PURE__ */ jsx("p", {
4531
+ className: "line-clamp-1 pl-4 text-xs text-neutral-500",
4532
+ children: message.snippet
4533
+ }) : null
4534
+ ] });
4535
+ const className = "block space-y-0.5 px-3 py-2";
4536
+ return message.link ? /* @__PURE__ */ jsx("a", {
4537
+ href: message.link,
4538
+ target: "_blank",
4539
+ rel: "noreferrer noopener",
4540
+ className: joinClasses(className, "hover:bg-neutral-50"),
4541
+ children: content
4542
+ }) : /* @__PURE__ */ jsx("div", {
4543
+ className,
4544
+ children: content
4545
+ });
4546
+ }
4547
+ function MailList({ messages, locale, copy }) {
4548
+ const [expanded, setExpanded] = useState(false);
4549
+ if (messages.length === 0) return /* @__PURE__ */ jsx("p", {
4550
+ className: "px-3 py-3 text-sm text-neutral-600",
4551
+ children: copy.noEmails
4552
+ });
4553
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("ul", {
4554
+ className: "divide-y divide-neutral-100",
4555
+ children: (expanded ? messages : messages.slice(0, COLLAPSED_ITEMS)).map((message) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(MailRow, {
4556
+ message,
4557
+ locale,
4558
+ copy
4559
+ }) }, message.id))
4560
+ }), /* @__PURE__ */ jsx(ShowAllToggle, {
4561
+ total: messages.length,
4562
+ expanded,
4563
+ onToggle: () => setExpanded((value) => !value),
4564
+ copy
4565
+ })] });
4566
+ }
4567
+ function MailMessageView({ message, connector, locale, copy }) {
4568
+ const [expanded, setExpanded] = useState(false);
4569
+ const body = text(message.body);
4570
+ const long = (body?.length ?? 0) > COLLAPSED_BODY_CHARS;
4571
+ const shownBody = body && long && !expanded ? `${body.slice(0, COLLAPSED_BODY_CHARS).trimEnd()}…` : body;
4572
+ return /* @__PURE__ */ jsxs("div", {
4573
+ className: "space-y-3 px-3 py-3",
4574
+ children: [
4575
+ /* @__PURE__ */ jsxs("div", {
4576
+ className: "space-y-1",
4577
+ children: [
4578
+ /* @__PURE__ */ jsx("h4", {
4579
+ className: "text-sm font-semibold text-neutral-950",
4580
+ children: text(message.subject) ?? copy.noSubject
4581
+ }),
4582
+ /* @__PURE__ */ jsxs("div", {
4583
+ className: "flex items-baseline gap-2 text-xs text-neutral-600",
4584
+ children: [/* @__PURE__ */ jsx("span", {
4585
+ className: "min-w-0 flex-1 truncate font-medium text-neutral-800",
4586
+ children: message.from ?? "—"
4587
+ }), /* @__PURE__ */ jsx("span", {
4588
+ className: "shrink-0",
4589
+ children: formatFullDate(message.date, locale)
4590
+ })]
4591
+ }),
4592
+ text(message.to) ? /* @__PURE__ */ jsxs("p", {
4593
+ className: "truncate text-xs text-neutral-500",
4594
+ children: [
4595
+ copy.to,
4596
+ ": ",
4597
+ message.to
4598
+ ]
4599
+ }) : null,
4600
+ text(message.cc) ? /* @__PURE__ */ jsxs("p", {
4601
+ className: "truncate text-xs text-neutral-500",
4602
+ children: [
4603
+ copy.cc,
4604
+ ": ",
4605
+ message.cc
4606
+ ]
4607
+ }) : null
4608
+ ]
4609
+ }),
4610
+ shownBody ? /* @__PURE__ */ jsx("p", {
4611
+ className: "whitespace-pre-wrap break-words text-sm leading-6 text-neutral-800",
4612
+ children: shownBody
4613
+ }) : null,
4614
+ /* @__PURE__ */ jsxs("div", {
4615
+ className: "flex items-center gap-4",
4616
+ children: [long ? /* @__PURE__ */ jsx("button", {
4617
+ type: "button",
4618
+ onClick: () => setExpanded((value) => !value),
4619
+ className: "text-xs font-medium text-neutral-600 hover:text-neutral-950",
4620
+ children: expanded ? copy.showLess : copy.showMore
4621
+ }) : null, message.link ? /* @__PURE__ */ jsxs(ExternalAnchor, {
4622
+ href: message.link,
4623
+ children: [fillCopy(copy.openIn, { service: connector?.label ?? "" }), /* @__PURE__ */ jsx(ExternalLink, {
4624
+ className: "h-3 w-3",
4625
+ "aria-hidden": "true"
4626
+ })]
4627
+ }) : null]
4628
+ })
4629
+ ]
4630
+ });
4631
+ }
4632
+ function eventTime(event, locale, copy) {
4633
+ if (event.all_day) return copy.allDay;
4634
+ const start = parseDate(event.start);
4635
+ const end = parseDate(event.end);
4636
+ if (!start) return null;
4637
+ const time = dateFormatter(locale, {
4638
+ hour: "2-digit",
4639
+ minute: "2-digit"
4640
+ });
4641
+ return end ? `${time.format(start)} – ${time.format(end)}` : time.format(start);
4642
+ }
4643
+ function groupByDay(events) {
4644
+ const groups = [];
4645
+ for (const event of events) {
4646
+ const day = parseDate(event.start);
4647
+ const last = groups[groups.length - 1];
4648
+ if (last && (last.day && day && isSameDay(last.day, day) || !last.day && !day)) last.events.push(event);
4649
+ else groups.push({
4650
+ day,
4651
+ events: [event]
4652
+ });
4653
+ }
4654
+ return groups;
4655
+ }
4656
+ function EventRow({ event, locale, copy }) {
4657
+ const attendees = event.attendees?.length ?? 0;
4658
+ const details = [text(event.location), attendees > 0 ? count(copy, attendees, copy.attendeesOne, copy.attendeesOther) : null].filter(Boolean);
4659
+ return /* @__PURE__ */ jsxs("li", {
4660
+ className: "flex gap-3 px-3 py-2",
4661
+ children: [
4662
+ /* @__PURE__ */ jsx("span", {
4663
+ className: "w-24 shrink-0 pt-0.5 text-xs tabular-nums text-neutral-600",
4664
+ children: eventTime(event, locale, copy)
4665
+ }),
4666
+ /* @__PURE__ */ jsxs("div", {
4667
+ className: "min-w-0 flex-1 space-y-0.5",
4668
+ children: [event.link ? /* @__PURE__ */ jsx("a", {
4669
+ href: event.link,
4670
+ target: "_blank",
4671
+ rel: "noreferrer noopener",
4672
+ className: "block truncate text-sm font-medium text-neutral-950 hover:underline",
4673
+ children: text(event.title) ?? copy.noSubject
4674
+ }) : /* @__PURE__ */ jsx("p", {
4675
+ className: "truncate text-sm font-medium text-neutral-950",
4676
+ children: text(event.title) ?? copy.noSubject
4677
+ }), details.length > 0 ? /* @__PURE__ */ jsx("p", {
4678
+ className: "truncate text-xs text-neutral-500",
4679
+ children: details.join(" · ")
4680
+ }) : null]
4681
+ }),
4682
+ event.online_meeting_url ? /* @__PURE__ */ jsxs(ExternalAnchor, {
4683
+ href: event.online_meeting_url,
4684
+ className: "shrink-0 self-start",
4685
+ children: [/* @__PURE__ */ jsx(Video, {
4686
+ className: "h-3.5 w-3.5",
4687
+ "aria-hidden": "true"
4688
+ }), copy.joinMeeting]
4689
+ }) : null
4690
+ ]
4691
+ });
4692
+ }
4693
+ function Agenda({ events, locale, copy }) {
4694
+ const [expanded, setExpanded] = useState(false);
4695
+ if (events.length === 0) return /* @__PURE__ */ jsx("p", {
4696
+ className: "px-3 py-3 text-sm text-neutral-600",
4697
+ children: copy.noEvents
4698
+ });
4699
+ const visible = expanded ? events : events.slice(0, COLLAPSED_ITEMS);
4700
+ const dayFormat = dateFormatter(locale, {
4701
+ weekday: "long",
4702
+ day: "numeric",
4703
+ month: "long"
4704
+ });
4705
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
4706
+ className: "divide-y divide-neutral-100",
4707
+ children: groupByDay(visible).map((group, index) => /* @__PURE__ */ jsxs("section", { children: [group.day ? /* @__PURE__ */ jsx("h4", {
4708
+ className: "bg-neutral-50 px-3 py-1 text-xs font-medium capitalize text-neutral-600",
4709
+ children: dayFormat.format(group.day)
4710
+ }) : null, /* @__PURE__ */ jsx("ul", {
4711
+ className: "divide-y divide-neutral-100",
4712
+ children: group.events.map((event) => /* @__PURE__ */ jsx(EventRow, {
4713
+ event,
4714
+ locale,
4715
+ copy
4716
+ }, event.id))
4717
+ })] }, group.day?.toISOString() ?? `undated-${index}`))
4718
+ }), /* @__PURE__ */ jsx(ShowAllToggle, {
4719
+ total: events.length,
4720
+ expanded,
4721
+ onToggle: () => setExpanded((value) => !value),
4722
+ copy
4723
+ })] });
4724
+ }
4725
+ function CollapsibleBody({ body, copy }) {
4726
+ const [expanded, setExpanded] = useState(false);
4727
+ if (!body) return null;
4728
+ const long = body.length > COLLAPSED_BODY_CHARS;
4729
+ return /* @__PURE__ */ jsxs("div", {
4730
+ className: "space-y-1",
4731
+ children: [/* @__PURE__ */ jsx("p", {
4732
+ className: "whitespace-pre-wrap break-words text-sm leading-6 text-neutral-800",
4733
+ children: long && !expanded ? `${body.slice(0, COLLAPSED_BODY_CHARS).trimEnd()}…` : body
4734
+ }), long ? /* @__PURE__ */ jsx("button", {
4735
+ type: "button",
4736
+ onClick: () => setExpanded((value) => !value),
4737
+ className: "text-xs font-medium text-neutral-600 hover:text-neutral-950",
4738
+ children: expanded ? copy.showLess : copy.showMore
4739
+ }) : null]
4740
+ });
4741
+ }
4742
+ function DraftView({ view, copy }) {
4743
+ return /* @__PURE__ */ jsxs("div", {
4744
+ className: "space-y-2 px-3 py-3",
4745
+ children: [
4746
+ /* @__PURE__ */ jsxs("div", {
4747
+ className: "space-y-1",
4748
+ children: [
4749
+ /* @__PURE__ */ jsx("p", {
4750
+ className: "text-sm font-medium text-neutral-950",
4751
+ children: copy.draftSaved
4752
+ }),
4753
+ view.subject ? /* @__PURE__ */ jsx("p", {
4754
+ className: "truncate text-sm text-neutral-800",
4755
+ children: view.subject
4756
+ }) : null,
4757
+ view.to.length > 0 ? /* @__PURE__ */ jsxs("p", {
4758
+ className: "truncate text-xs text-neutral-500",
4759
+ children: [
4760
+ copy.to,
4761
+ ": ",
4762
+ view.to.join(", ")
4763
+ ]
4764
+ }) : null
4765
+ ]
4766
+ }),
4767
+ /* @__PURE__ */ jsx(CollapsibleBody, {
4768
+ body: view.body,
4769
+ copy
4770
+ }),
4771
+ view.link ? /* @__PURE__ */ jsxs(ExternalAnchor, {
4772
+ href: view.link,
4773
+ children: [copy.openDraft, /* @__PURE__ */ jsx(ExternalLink, {
4774
+ className: "h-3 w-3",
4775
+ "aria-hidden": "true"
4776
+ })]
4777
+ }) : null
4778
+ ]
4779
+ });
4780
+ }
4781
+ function strings(value) {
4782
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
4783
+ }
4784
+ function Field({ label, children }) {
4785
+ return /* @__PURE__ */ jsxs("div", {
4786
+ className: "flex gap-3 text-sm",
4787
+ children: [/* @__PURE__ */ jsx("dt", {
4788
+ className: "w-24 shrink-0 text-xs leading-5 text-neutral-500",
4789
+ children: label
4790
+ }), /* @__PURE__ */ jsx("dd", {
4791
+ className: "min-w-0 flex-1 break-words text-neutral-900",
4792
+ children
4793
+ })]
4794
+ });
4795
+ }
4796
+ function PendingMailView({ pending, copy }) {
4797
+ const mail = pending.action;
4798
+ const to = strings(mail.to);
4799
+ const cc = strings(mail.cc);
4800
+ return /* @__PURE__ */ jsxs("div", {
4801
+ className: "space-y-3 px-3 py-3",
4802
+ children: [
4803
+ /* @__PURE__ */ jsxs("dl", {
4804
+ className: "space-y-1.5",
4805
+ children: [
4806
+ /* @__PURE__ */ jsx(Field, {
4807
+ label: copy.to,
4808
+ children: to.join(", ") || "—"
4809
+ }),
4810
+ cc.length > 0 ? /* @__PURE__ */ jsx(Field, {
4811
+ label: copy.cc,
4812
+ children: cc.join(", ")
4813
+ }) : null,
4814
+ /* @__PURE__ */ jsx(Field, {
4815
+ label: copy.subject,
4816
+ children: /* @__PURE__ */ jsx("span", {
4817
+ className: "font-medium",
4818
+ children: text(mail.subject) ?? copy.noSubject
4819
+ })
4820
+ })
4821
+ ]
4822
+ }),
4823
+ text(mail.reply_to_message_id) ? /* @__PURE__ */ jsx("p", {
4824
+ className: "text-xs text-neutral-500",
4825
+ children: copy.replyInThread
4826
+ }) : null,
4827
+ /* @__PURE__ */ jsx("div", {
4828
+ className: "rounded-md border border-neutral-200 bg-neutral-50 px-3 py-2",
4829
+ children: /* @__PURE__ */ jsx(CollapsibleBody, {
4830
+ body: text(mail.body),
4831
+ copy
4832
+ })
4833
+ })
4834
+ ]
4835
+ });
4836
+ }
4837
+ function formatRange(start, end, allDay, locale, copy) {
4838
+ const from = parseDate(text(start));
4839
+ if (!from) return null;
4840
+ const day = dateFormatter(locale, {
4841
+ weekday: "short",
4842
+ day: "numeric",
4843
+ month: "short"
4844
+ }).format(from);
4845
+ if (allDay) return `${day} · ${copy.allDay}`;
4846
+ const time = dateFormatter(locale, {
4847
+ hour: "2-digit",
4848
+ minute: "2-digit"
4849
+ });
4850
+ const to = parseDate(text(end));
4851
+ return to ? `${day} · ${time.format(from)} – ${time.format(to)}` : `${day} · ${time.format(from)}`;
4852
+ }
4853
+ /** Old value struck through next to the new one; only the new one if unknown. */
4854
+ function Change({ before, after }) {
4855
+ if (before === null || before === void 0 || before === after) return /* @__PURE__ */ jsx(Fragment, { children: after });
4856
+ return /* @__PURE__ */ jsxs("span", {
4857
+ className: "flex flex-wrap items-baseline gap-x-2",
4858
+ children: [
4859
+ /* @__PURE__ */ jsx("span", {
4860
+ className: "text-neutral-500 line-through",
4861
+ children: before
4862
+ }),
4863
+ /* @__PURE__ */ jsx("span", {
4864
+ "aria-hidden": "true",
4865
+ children: "→"
4866
+ }),
4867
+ /* @__PURE__ */ jsx("span", { children: after })
4868
+ ]
4869
+ });
4870
+ }
4871
+ function PendingEventView({ operation, pending, locale, copy }) {
4872
+ const action = pending.action;
4873
+ const current = asRecord(pending.current);
4874
+ const has = (key) => action[key] !== void 0 && action[key] !== null;
4875
+ if (operation === "delete_event") return /* @__PURE__ */ jsxs("div", {
4876
+ className: "space-y-1 px-3 py-3",
4877
+ children: [
4878
+ /* @__PURE__ */ jsx("p", {
4879
+ className: "text-xs font-medium uppercase tracking-wide text-rose-700",
4880
+ children: copy.deleteEvent
4881
+ }),
4882
+ /* @__PURE__ */ jsx("p", {
4883
+ className: "text-sm font-medium text-neutral-900 line-through",
4884
+ children: text(current?.title) ?? text(action.event_id) ?? copy.noSubject
4885
+ }),
4886
+ current ? /* @__PURE__ */ jsx("p", {
4887
+ className: "text-xs text-neutral-500",
4888
+ children: formatRange(current.start, current.end, Boolean(current.all_day), locale, copy)
4889
+ }) : null,
4890
+ (current?.attendees?.length ?? 0) > 0 ? /* @__PURE__ */ jsx("p", {
4891
+ className: "pt-1 text-xs text-neutral-600",
4892
+ children: copy.attendeesNotified
4893
+ }) : null
4894
+ ]
4895
+ });
4896
+ const isUpdate = operation === "update_event";
4897
+ const before = (key) => isUpdate && current ? current[key] : null;
4898
+ const attendees = strings(action.attendees);
4899
+ const timesChanged = has("start") || has("end");
4900
+ const newWhen = formatRange(action.start ?? current?.start, action.end ?? current?.end, Boolean(current?.all_day) && !timesChanged, locale, copy);
4901
+ const oldWhen = isUpdate && current && timesChanged ? formatRange(current.start, current.end, Boolean(current.all_day), locale, copy) : null;
4902
+ return /* @__PURE__ */ jsxs("div", {
4903
+ className: "space-y-2 px-3 py-3",
4904
+ children: [
4905
+ /* @__PURE__ */ jsx("p", {
4906
+ className: "text-xs font-medium uppercase tracking-wide text-neutral-500",
4907
+ children: isUpdate ? copy.eventChange : copy.newEvent
4908
+ }),
4909
+ /* @__PURE__ */ jsxs("dl", {
4910
+ className: "space-y-1.5",
4911
+ children: [
4912
+ has("title") || !isUpdate ? /* @__PURE__ */ jsx(Field, {
4913
+ label: copy.title,
4914
+ children: /* @__PURE__ */ jsx("span", {
4915
+ className: "font-medium",
4916
+ children: /* @__PURE__ */ jsx(Change, {
4917
+ before: text(before("title")),
4918
+ after: text(action.title) ?? copy.noSubject
4919
+ })
4920
+ })
4921
+ }) : current ? /* @__PURE__ */ jsx(Field, {
4922
+ label: copy.title,
4923
+ children: /* @__PURE__ */ jsx("span", {
4924
+ className: "font-medium",
4925
+ children: text(current.title)
4926
+ })
4927
+ }) : null,
4928
+ newWhen && (timesChanged || !isUpdate) ? /* @__PURE__ */ jsx(Field, {
4929
+ label: copy.when,
4930
+ children: /* @__PURE__ */ jsx(Change, {
4931
+ before: oldWhen,
4932
+ after: newWhen
4933
+ })
4934
+ }) : null,
4935
+ has("location") ? /* @__PURE__ */ jsx(Field, {
4936
+ label: copy.location,
4937
+ children: /* @__PURE__ */ jsx(Change, {
4938
+ before: text(before("location")),
4939
+ after: text(action.location)
4940
+ })
4941
+ }) : null,
4942
+ has("attendees") ? /* @__PURE__ */ jsx(Field, {
4943
+ label: copy.attendees,
4944
+ children: /* @__PURE__ */ jsx(Change, {
4945
+ before: strings(before("attendees")).join(", ") || null,
4946
+ after: attendees.join(", ") || "—"
4947
+ })
4948
+ }) : null,
4949
+ has("description") ? /* @__PURE__ */ jsx(Field, {
4950
+ label: copy.description,
4951
+ children: /* @__PURE__ */ jsx("span", {
4952
+ className: "whitespace-pre-wrap",
4953
+ children: text(action.description)
4954
+ })
4955
+ }) : null
4956
+ ]
4957
+ }),
4958
+ attendees.length > 0 ? /* @__PURE__ */ jsx("p", {
4959
+ className: "text-xs text-neutral-600",
4960
+ children: copy.attendeesNotified
4961
+ }) : null
4962
+ ]
4963
+ });
4964
+ }
4965
+ function PendingBadge({ copy }) {
4966
+ return /* @__PURE__ */ jsxs("span", {
4967
+ className: "ml-auto inline-flex shrink-0 items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 font-medium text-amber-800",
4968
+ children: [/* @__PURE__ */ jsx(Clock, {
4969
+ className: "h-3 w-3",
4970
+ "aria-hidden": "true"
4971
+ }), copy.awaitingConfirmation]
4972
+ });
4973
+ }
4974
+ function PendingFooter({ copy }) {
4975
+ return /* @__PURE__ */ jsx("p", {
4976
+ className: "border-t border-amber-100 bg-amber-50/60 px-3 py-2 text-xs text-neutral-700",
4977
+ children: copy.confirmHint
4978
+ });
4979
+ }
4980
+ function headerCount(view, copy) {
4981
+ if (view.kind === "mail-list") return count(copy, view.messages.length, copy.emailCountOne, copy.emailCountOther);
4982
+ if (view.kind === "events") return count(copy, view.events.length, copy.eventCountOne, copy.eventCountOther);
4983
+ return null;
4984
+ }
4985
+ function ToolResultPersonalConnectorCard({ part, locale, className }) {
4986
+ const view = getView(part);
4987
+ if (!view) return null;
4988
+ const copy = getPersonalConnectorCopy(locale);
4989
+ const connector = getConnector(part);
4990
+ const Icon = isCalendar(connector) ? CalendarDays : Mail;
4991
+ const total = headerCount(view, copy);
4992
+ const isPending = view.kind === "pending-mail" || view.kind === "pending-event";
4993
+ return /* @__PURE__ */ jsxs("section", {
4994
+ className: joinClasses("plai-tool-result-personal-connector-card overflow-hidden rounded-lg border border-neutral-200 bg-white text-neutral-950", className),
4995
+ "data-tool-call-id": part.id,
4996
+ "data-tool-call-state": part.state,
4997
+ "data-connector-action": view.kind,
4998
+ children: [
4999
+ /* @__PURE__ */ jsxs("header", {
5000
+ className: "flex items-center gap-2 border-b border-neutral-200 px-3 py-2 text-xs text-neutral-600",
5001
+ children: [
5002
+ /* @__PURE__ */ jsx(Icon, {
5003
+ className: "h-4 w-4 shrink-0 text-neutral-700",
5004
+ "aria-hidden": "true"
5005
+ }),
5006
+ /* @__PURE__ */ jsx("span", {
5007
+ className: "shrink-0 font-medium text-neutral-900",
5008
+ children: connector?.label
5009
+ }),
5010
+ connector?.account_email ? /* @__PURE__ */ jsx("span", {
5011
+ className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
5012
+ children: connector.account_email
5013
+ }) : null,
5014
+ isPending ? /* @__PURE__ */ jsx(PendingBadge, { copy }) : total ? /* @__PURE__ */ jsx("span", {
5015
+ className: "ml-auto shrink-0",
5016
+ children: total
5017
+ }) : null
5018
+ ]
5019
+ }),
5020
+ view.kind === "mail-list" ? /* @__PURE__ */ jsx(MailList, {
5021
+ messages: view.messages,
5022
+ locale,
5023
+ copy
5024
+ }) : view.kind === "mail" ? /* @__PURE__ */ jsx(MailMessageView, {
5025
+ message: view.message,
5026
+ connector,
5027
+ locale,
5028
+ copy
5029
+ }) : view.kind === "events" ? /* @__PURE__ */ jsx(Agenda, {
5030
+ events: view.events,
5031
+ locale,
5032
+ copy
5033
+ }) : view.kind === "pending-mail" ? /* @__PURE__ */ jsx(PendingMailView, {
5034
+ pending: view.pending,
5035
+ copy
5036
+ }) : view.kind === "pending-event" ? /* @__PURE__ */ jsx(PendingEventView, {
5037
+ operation: view.operation,
5038
+ pending: view.pending,
5039
+ locale,
5040
+ copy
5041
+ }) : /* @__PURE__ */ jsx(DraftView, {
5042
+ view,
5043
+ copy
5044
+ }),
5045
+ isPending ? /* @__PURE__ */ jsx(PendingFooter, { copy }) : null
5046
+ ]
5047
+ });
5048
+ }
5049
+ const DONE_LABELS = {
5050
+ send: "emailSent",
5051
+ create_event: "eventCreated",
5052
+ update_event: "eventUpdated",
5053
+ delete_event: "eventDeleted"
5054
+ };
5055
+ function getConfirmedActions(part) {
5056
+ const actions = asRecord(part.metadata)?.actions;
5057
+ return Array.isArray(actions) ? actions.filter((action) => typeof asRecord(action)?.action_id === "string") : [];
5058
+ }
5059
+ /** Whether the confirmation result can be shown as a list of outcomes. */
5060
+ function hasToolConfirmationView(part) {
5061
+ return part.state !== "pending" && getConfirmedActions(part).length > 0;
5062
+ }
5063
+ function ConfirmedActionRow({ action, copy }) {
5064
+ const metadata = asRecord(action.metadata);
5065
+ const connector = asRecord(metadata?.connector);
5066
+ const operation = typeof metadata?.action === "string" ? metadata.action : "";
5067
+ const doneKey = DONE_LABELS[operation];
5068
+ const failed = action.status === "failed";
5069
+ const label = doneKey ? copy[doneKey] : fillCopy(copy.actionDone, { tool: action.tool_name });
5070
+ const link = text(asRecord(metadata?.result)?.link);
5071
+ return /* @__PURE__ */ jsxs("li", {
5072
+ className: "flex items-start gap-2 px-3 py-2",
5073
+ children: [
5074
+ failed ? /* @__PURE__ */ jsx(XCircle, {
5075
+ className: "mt-0.5 h-4 w-4 shrink-0 text-rose-600",
5076
+ "aria-hidden": "true"
5077
+ }) : /* @__PURE__ */ jsx(CheckCircle2, {
5078
+ className: "mt-0.5 h-4 w-4 shrink-0 text-emerald-600",
5079
+ "aria-hidden": "true"
5080
+ }),
5081
+ /* @__PURE__ */ jsxs("div", {
5082
+ className: "min-w-0 flex-1 space-y-0.5",
5083
+ children: [
5084
+ /* @__PURE__ */ jsx("p", {
5085
+ className: "text-sm font-medium text-neutral-950",
5086
+ children: failed ? `${copy.actionFailed}: ${label}` : label
5087
+ }),
5088
+ connector ? /* @__PURE__ */ jsxs("div", {
5089
+ className: "flex items-center gap-2 truncate text-xs text-neutral-500",
5090
+ children: [connector.label, connector.account_email ? /* @__PURE__ */ jsx("span", {
5091
+ className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
5092
+ children: connector.account_email
5093
+ }) : null]
5094
+ }) : null,
5095
+ failed && text(action.error) ? /* @__PURE__ */ jsx("p", {
5096
+ className: "line-clamp-2 text-xs text-rose-700",
5097
+ children: action.error
5098
+ }) : null
5099
+ ]
5100
+ }),
5101
+ !failed && link ? /* @__PURE__ */ jsx(ExternalAnchor, {
5102
+ href: link,
5103
+ className: "shrink-0",
5104
+ children: operation === "send" ? copy.openEmail : copy.openEvent
5105
+ }) : null
5106
+ ]
5107
+ });
5108
+ }
5109
+ function ToolResultToolConfirmationCard({ part, locale, className }) {
5110
+ const actions = getConfirmedActions(part);
5111
+ if (actions.length === 0) return null;
5112
+ const copy = getPersonalConnectorCopy(locale);
5113
+ return /* @__PURE__ */ jsx("ul", {
5114
+ className: joinClasses("plai-tool-result-tool-confirmation-card divide-y divide-neutral-100 overflow-hidden rounded-lg border border-neutral-200 bg-white text-neutral-950", className),
5115
+ "data-tool-call-id": part.id,
5116
+ "data-tool-call-state": part.state,
5117
+ children: actions.map((action) => /* @__PURE__ */ jsx(ConfirmedActionRow, {
5118
+ action,
5119
+ copy
5120
+ }, action.action_id))
5121
+ });
5122
+ }
5123
+ function getPendingConfirmation(part) {
5124
+ const pending = asRecord(asRecord(part.metadata)?.pending_confirmation);
5125
+ return pending && asRecord(pending.action) ? pending : null;
5126
+ }
5127
+ function formatValue(value) {
5128
+ if (typeof value === "string") return value;
5129
+ return JSON.stringify(value, null, 2);
5130
+ }
5131
+ /** Generic preview of a held tool call: its name and the exact arguments. */
5132
+ function ToolResultPendingConfirmationCard({ part, locale, className }) {
5133
+ const pending = getPendingConfirmation(part);
5134
+ if (!pending) return null;
5135
+ const copy = getPersonalConnectorCopy(locale);
5136
+ const entries = Object.entries(pending.action).filter(([key, value]) => key !== "operation" && value !== null && value !== void 0);
5137
+ return /* @__PURE__ */ jsxs("section", {
5138
+ className: joinClasses("plai-tool-result-pending-confirmation-card overflow-hidden rounded-lg border border-neutral-200 bg-white text-neutral-950", className),
5139
+ "data-tool-call-id": part.id,
5140
+ "data-tool-call-state": part.state,
5141
+ children: [
5142
+ /* @__PURE__ */ jsxs("header", {
5143
+ className: "flex items-center gap-2 border-b border-neutral-200 px-3 py-2 text-xs text-neutral-600",
5144
+ children: [/* @__PURE__ */ jsx("span", {
5145
+ className: "truncate font-mono font-medium text-neutral-900",
5146
+ children: part.name
5147
+ }), /* @__PURE__ */ jsx(PendingBadge, { copy })]
5148
+ }),
5149
+ entries.length > 0 ? /* @__PURE__ */ jsx("dl", {
5150
+ className: "space-y-1.5 px-3 py-3",
5151
+ children: entries.map(([key, value]) => /* @__PURE__ */ jsx(Field, {
5152
+ label: key,
5153
+ children: /* @__PURE__ */ jsx("span", {
5154
+ className: "whitespace-pre-wrap font-mono text-xs",
5155
+ children: formatValue(value)
5156
+ })
5157
+ }, key))
5158
+ }) : null,
5159
+ /* @__PURE__ */ jsx(PendingFooter, { copy })
5160
+ ]
5161
+ });
5162
+ }
5163
+
3851
5164
  //#endregion
3852
5165
  //#region src/components/tool-result-workflow-dispatch-card.tsx
3853
5166
  function parseResult(value) {
@@ -3898,7 +5211,7 @@ function ToolResultWorkflowDispatchCard({ part, className, locale }) {
3898
5211
  children: copy.workflow
3899
5212
  }),
3900
5213
  /* @__PURE__ */ jsx("span", {
3901
- className: "min-w-0 truncate text-neutral-600",
5214
+ className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
3902
5215
  children: workflowName
3903
5216
  }),
3904
5217
  /* @__PURE__ */ jsxs("span", {
@@ -3989,7 +5302,9 @@ const TOOL_USE_ACTIONS = {
3989
5302
  mcp_tool: "request",
3990
5303
  office_documents: "documents",
3991
5304
  perplexity: "web",
5305
+ personal_connector: "tool",
3992
5306
  structured_datasource: "query",
5307
+ tool_confirmation: "tool",
3993
5308
  workflow_dispatch: "workflow",
3994
5309
  unknown: "tool"
3995
5310
  };
@@ -4105,7 +5420,35 @@ const TOOL_USE_TRANSLATIONS = {
4105
5420
  workflow: "Executando o fluxo {{toolName}}"
4106
5421
  }
4107
5422
  };
5423
+ const PERSONAL_CONNECTOR_SERVICES = {
5424
+ gmail: "Gmail",
5425
+ google_calendar: "Google Calendar",
5426
+ outlook_mail: "Outlook Mail",
5427
+ outlook_calendar: "Outlook Calendar"
5428
+ };
5429
+ const PERSONAL_CONNECTOR_ACTIONS = {
5430
+ search: "searchingMail",
5431
+ read: "readingMail",
5432
+ list_events: "checkingCalendar",
5433
+ create_draft: "savingDraft",
5434
+ send: "preparingMail",
5435
+ create_event: "preparingEvent",
5436
+ update_event: "preparingEvent",
5437
+ delete_event: "preparingEvent"
5438
+ };
5439
+ const PERSONAL_CONNECTOR_TOOL_NAME = /^(gmail|google_calendar|outlook_mail|outlook_calendar)_(.+?)(?:_\d+)?$/;
5440
+ function getPersonalConnectorLabel(name, locale) {
5441
+ const match = PERSONAL_CONNECTOR_TOOL_NAME.exec(name);
5442
+ const key = match ? PERSONAL_CONNECTOR_ACTIONS[match[2]] : void 0;
5443
+ if (!match || !key) return null;
5444
+ return fillCopy(getPersonalConnectorCopy(locale)[key], { service: PERSONAL_CONNECTOR_SERVICES[match[1]] });
5445
+ }
4108
5446
  function getToolUseLabel(part, locale) {
5447
+ if (part.toolType === "personal_connector") {
5448
+ const label = getPersonalConnectorLabel(part.name, locale);
5449
+ if (label) return label;
5450
+ }
5451
+ if (part.toolType === "tool_confirmation") return getPersonalConnectorCopy(locale).runningConfirmed;
4109
5452
  const action = part.toolType ? TOOL_USE_ACTIONS[part.toolType] ?? "tool" : "tool";
4110
5453
  return TOOL_USE_TRANSLATIONS[getSupportedToolLocale(locale)][action].replaceAll("{{toolName}}", part.name);
4111
5454
  }
@@ -4159,11 +5502,21 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
4159
5502
  locale,
4160
5503
  className
4161
5504
  });
5505
+ if (part.toolType === "tool_confirmation" && hasToolConfirmationView(part)) return /* @__PURE__ */ jsx(ToolResultToolConfirmationCard, {
5506
+ part,
5507
+ locale,
5508
+ className
5509
+ });
4162
5510
  if (part.state === "error") return /* @__PURE__ */ jsx(ToolError, {
4163
5511
  part,
4164
5512
  locale,
4165
5513
  className
4166
5514
  });
5515
+ if (part.toolType !== "personal_connector" && getPendingConfirmation(part)) return /* @__PURE__ */ jsx(ToolResultPendingConfirmationCard, {
5516
+ part,
5517
+ locale,
5518
+ className
5519
+ });
4167
5520
  const officeMediaFiles = getOfficeDocumentMediaFiles(part);
4168
5521
  const datasourceResources = getDatasourceResources$1(part);
4169
5522
  if (part.toolType === "email_send") return /* @__PURE__ */ jsx(ToolResultEmailSendCard, {
@@ -4202,6 +5555,11 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
4202
5555
  locale,
4203
5556
  className
4204
5557
  });
5558
+ if (part.toolType === "personal_connector" && hasPersonalConnectorView(part)) return /* @__PURE__ */ jsx(ToolResultPersonalConnectorCard, {
5559
+ part,
5560
+ locale,
5561
+ className
5562
+ });
4205
5563
  if (part.toolType === "workflow_dispatch") return /* @__PURE__ */ jsx(ToolResultWorkflowDispatchCard, {
4206
5564
  part,
4207
5565
  locale,
@@ -4230,7 +5588,7 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
4230
5588
  className: "text-sm font-semibold text-slate-900",
4231
5589
  children: part.name
4232
5590
  }), /* @__PURE__ */ jsx("span", {
4233
- className: "rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-xs font-medium text-emerald-800",
5591
+ className: "rounded-full border uppercase border-emerald-200 bg-emerald-50 px-2 py-0.5 text-xs text-emerald-800",
4234
5592
  children: copy.completed
4235
5593
  })]
4236
5594
  }),
@@ -4706,14 +6064,14 @@ function Message(props) {
4706
6064
 
4707
6065
  //#endregion
4708
6066
  //#region src/components/clipboard.tsx
4709
- async function writeTextToClipboard(text$1) {
6067
+ async function writeTextToClipboard(text$2) {
4710
6068
  if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
4711
- await navigator.clipboard.writeText(text$1);
6069
+ await navigator.clipboard.writeText(text$2);
4712
6070
  return;
4713
6071
  }
4714
6072
  if (typeof document === "undefined") throw new Error("Clipboard is not available in this environment.");
4715
6073
  const textarea = document.createElement("textarea");
4716
- textarea.value = text$1;
6074
+ textarea.value = text$2;
4717
6075
  textarea.setAttribute("readonly", "");
4718
6076
  textarea.style.position = "fixed";
4719
6077
  textarea.style.opacity = "0";
@@ -4725,7 +6083,7 @@ async function writeTextToClipboard(text$1) {
4725
6083
  textarea.remove();
4726
6084
  }
4727
6085
  }
4728
- function Clipboard({ text: text$1, onCopy, copiedDuration = 2e3, copyLabel, copiedLabel, locale, children, className, disabled, onClick, type = "button",...props }) {
6086
+ function Clipboard({ text: text$2, onCopy, copiedDuration = 2e3, copyLabel, copiedLabel, locale, children, className, disabled, onClick, type = "button",...props }) {
4729
6087
  const copy = getUiCopy(locale);
4730
6088
  const resolvedCopyLabel = copyLabel ?? copy.copy;
4731
6089
  const resolvedCopiedLabel = copiedLabel ?? copy.copied;
@@ -4740,12 +6098,12 @@ function Clipboard({ text: text$1, onCopy, copiedDuration = 2e3, copyLabel, copi
4740
6098
  if (event.defaultPrevented || disabled || isCopying) return;
4741
6099
  setIsCopying(true);
4742
6100
  try {
4743
- await writeTextToClipboard(text$1);
6101
+ await writeTextToClipboard(text$2);
4744
6102
  setIsCopied(true);
4745
6103
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
4746
6104
  timeoutRef.current = setTimeout(() => setIsCopied(false), copiedDuration);
4747
6105
  try {
4748
- await onCopy?.(text$1);
6106
+ await onCopy?.(text$2);
4749
6107
  } catch {}
4750
6108
  } catch {
4751
6109
  setIsCopied(false);
@@ -4965,10 +6323,10 @@ function PromptForm({ value, onValueChange, onSubmit, status = "ready", locale,
4965
6323
  if (!canSubmit) return;
4966
6324
  setIsSubmitting(true);
4967
6325
  try {
4968
- const text$1 = value.trim();
6326
+ const text$2 = value.trim();
4969
6327
  const selectedFiles = [...files];
4970
6328
  await onSubmit({
4971
- text: text$1,
6329
+ text: text$2,
4972
6330
  ...enabledTools ? { enabledTools } : {},
4973
6331
  files: selectedFiles
4974
6332
  });
@@ -5195,10 +6553,10 @@ function useSpeechToText({ transcribe, onTranscriptionComplete, onTranscriptionE
5195
6553
  if (operationIdRef.current !== operationId) return null;
5196
6554
  const transcription = await optionsRef.current.transcribe(audio, abortController.signal);
5197
6555
  if (operationIdRef.current !== operationId) return null;
5198
- const text$1 = transcription.trim();
5199
- if (!text$1) return null;
5200
- optionsRef.current.onTranscriptionComplete?.(text$1);
5201
- return text$1;
6556
+ const text$2 = transcription.trim();
6557
+ if (!text$2) return null;
6558
+ optionsRef.current.onTranscriptionComplete?.(text$2);
6559
+ return text$2;
5202
6560
  } catch (error) {
5203
6561
  if (operationIdRef.current !== operationId || abortController.signal.aborted || isAbortError(error)) return null;
5204
6562
  optionsRef.current.onTranscriptionError?.(normalizeError(error, "Transcription failed"));
@@ -5302,5 +6660,5 @@ async function dummyTranscribeAudio(_audio, signal) {
5302
6660
  }
5303
6661
 
5304
6662
  //#endregion
5305
- export { AggregatedSourceResults, ArrowUp, AssistantMessage, ChatError, Clipboard, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, MemoryProposalCard, Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader, MessageParts, MessageRoot, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PromptForm, PromptFormAttachButton, PromptFormIconButton, Reload, ResourceCard, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SpeechToTextToggle, Stop, Thinking, ThumbDown, ThumbUp, ToolError, ToolResultAgentInvocationCard, ToolResultBrowserCard, ToolResultCard, ToolResultExternalDatasourceCard, ToolResultHttpRequestCard, ToolResultMcpCard, ToolResultOfficeDocumentsCard, ToolResultWebSearchCard, ToolResultWorkflowDispatchCard, ToolUseIndicator, UserMessage, X, dummyTranscribeAudio, getLocalizedOpenGraphValue, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, isAllowedPromptFormFile, partitionPromptFormFiles, useSpeechToText };
6663
+ export { AggregatedSourceResults, ArrowUp, AssistantMessage, ChatError, Clipboard, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, MemoryProposalCard, Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader, MessageParts, MessageRoot, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PromptForm, PromptFormAttachButton, PromptFormIconButton, Reload, ResourceCard, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SpeechToTextToggle, Stop, Thinking, ThumbDown, ThumbUp, ToolError, ToolResultAgentInvocationCard, ToolResultBrowserCard, ToolResultCard, ToolResultExternalDatasourceCard, ToolResultHttpRequestCard, ToolResultMcpCard, ToolResultOfficeDocumentsCard, ToolResultPendingConfirmationCard, ToolResultPersonalConnectorCard, ToolResultToolConfirmationCard, ToolResultWebSearchCard, ToolResultWorkflowDispatchCard, ToolUseIndicator, UserMessage, X, dummyTranscribeAudio, getLocalizedOpenGraphValue, getPendingConfirmation, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, hasPersonalConnectorView, hasToolConfirmationView, isAllowedPromptFormFile, partitionPromptFormFiles, useSpeechToText };
5306
6664
  //# sourceMappingURL=index.js.map