@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.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { HttpStatusError, PlaiChat } from "@plaisolutions/client";
2
2
  import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
3
- 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";
3
+ 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";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
 
6
6
  //#region src/use-chat.ts
@@ -2449,7 +2449,7 @@ function SourceCard({ source, locale, variant = "card" }) {
2449
2449
  });
2450
2450
  }
2451
2451
  function getTotalSourceCount(cards) {
2452
- return cards.reduce((count, source) => count + (source.kind === "web" ? getWebSearchResults(source.part).length : 1), 0);
2452
+ return cards.reduce((count$1, source) => count$1 + (source.kind === "web" ? getWebSearchResults(source.part).length : 1), 0);
2453
2453
  }
2454
2454
  function AggregatedSourceResults({ parts, locale, maxVisible = 3, className, getResourceDownloadUrl }) {
2455
2455
  const cards = getAggregatedCards(parts, locale, getResourceDownloadUrl);
@@ -2501,7 +2501,7 @@ function AggregatedSourceResults({ parts, locale, maxVisible = 3, className, get
2501
2501
 
2502
2502
  //#endregion
2503
2503
  //#region src/components/memory-proposal-card.tsx
2504
- const COPY = {
2504
+ const COPY$1 = {
2505
2505
  en: {
2506
2506
  title: "Memory proposal",
2507
2507
  user: "Personal memory",
@@ -2725,7 +2725,7 @@ const COPY = {
2725
2725
  };
2726
2726
  const REDACTED = "[redacted]";
2727
2727
  function MemoryProposalCard({ proposal: initial, actions, activeAgentId, locale, className }) {
2728
- const copy = COPY[getSupportedToolLocale(locale)];
2728
+ const copy = COPY$1[getSupportedToolLocale(locale)];
2729
2729
  const [proposal, setProposal] = useState(initial);
2730
2730
  const [resolving, setResolving] = useState(false);
2731
2731
  const [error, setError] = useState(null);
@@ -3036,7 +3036,7 @@ function ToolResultAgentInvocationCard({ part, className, onOpenThread, locale }
3036
3036
  children: copy.agent
3037
3037
  }),
3038
3038
  /* @__PURE__ */ jsx("span", {
3039
- className: "min-w-0 truncate text-neutral-600",
3039
+ className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
3040
3040
  children: agentName
3041
3041
  }),
3042
3042
  /* @__PURE__ */ jsx("span", {
@@ -3164,9 +3164,7 @@ function ToolResultBrowserCard({ part, className, locale }) {
3164
3164
  const preview = getPreview(toOutput(part.result));
3165
3165
  const url = getUrl(part.input);
3166
3166
  const error = formatToolErrorDetails(part.errorDetails);
3167
- const scraperLabel = metadata?.scraper_type ? SCRAPER_LABELS[metadata.scraper_type] : null;
3168
- const credits = metadata?.scraper_api_tokens ?? metadata?.firecrawl_credits;
3169
- const subtitle = [scraperLabel, typeof credits === "number" ? `${credits} ${credits === 1 ? copy.credit : copy.credits}` : null].filter(Boolean).join(" · ");
3167
+ const subtitle = metadata?.scraper_type ? SCRAPER_LABELS[metadata.scraper_type] : null;
3170
3168
  const failed = part.state === "error";
3171
3169
  const pending = part.state === "pending";
3172
3170
  const canExpand = Boolean(preview || error || url);
@@ -3185,7 +3183,7 @@ function ToolResultBrowserCard({ part, className, locale }) {
3185
3183
  children: copy.browser
3186
3184
  }),
3187
3185
  subtitle ? /* @__PURE__ */ jsx("span", {
3188
- className: "min-w-0 truncate text-xs text-neutral-500",
3186
+ className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
3189
3187
  children: subtitle
3190
3188
  }) : null,
3191
3189
  /* @__PURE__ */ jsxs("span", {
@@ -3323,7 +3321,7 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3323
3321
  }), /* @__PURE__ */ jsxs("div", {
3324
3322
  className: "flex items-center gap-2",
3325
3323
  children: [/* @__PURE__ */ jsx("span", {
3326
- className: joinClasses("rounded-full border px-2 py-0.5 text-xs font-medium", statusClass),
3324
+ className: joinClasses("rounded-full uppercase border px-2 py-0.5 text-xs", statusClass),
3327
3325
  children: getUiStatusLabel(part.state, copy)
3328
3326
  }), /* @__PURE__ */ jsx("button", {
3329
3327
  type: "button",
@@ -3332,28 +3330,31 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3332
3330
  "aria-controls": `tool-email-details-${part.id}`,
3333
3331
  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",
3334
3332
  onClick: () => setIsExpanded((previous) => !previous),
3335
- children: /* @__PURE__ */ jsx("span", {
3336
- className: "inline-block",
3337
- children: isExpanded ? "^" : "v"
3333
+ children: isExpanded ? /* @__PURE__ */ jsx(Minus, {
3334
+ className: "h-3 w-3",
3335
+ "aria-hidden": "true"
3336
+ }) : /* @__PURE__ */ jsx(Plus, {
3337
+ className: "h-3 w-3",
3338
+ "aria-hidden": "true"
3338
3339
  })
3339
3340
  })]
3340
3341
  })]
3341
3342
  }),
3342
3343
  emailInput.subject ? /* @__PURE__ */ jsxs("div", {
3343
- className: "space-y-1",
3344
- children: [/* @__PURE__ */ jsx("p", {
3344
+ className: "flex items-center gap-1",
3345
+ children: [/* @__PURE__ */ jsxs("p", {
3345
3346
  className: "text-xs font-semibold text-slate-600",
3346
- children: copy.subject
3347
+ children: [copy.subject, ":"]
3347
3348
  }), /* @__PURE__ */ jsx("p", {
3348
- className: "text-sm text-slate-900",
3349
+ className: "text-xs text-slate-900",
3349
3350
  children: emailInput.subject
3350
3351
  })]
3351
3352
  }) : null,
3352
3353
  /* @__PURE__ */ jsxs("div", {
3353
- className: "space-y-1",
3354
- children: [/* @__PURE__ */ jsx("p", {
3354
+ className: "flex items-center gap-1",
3355
+ children: [/* @__PURE__ */ jsxs("p", {
3355
3356
  className: "text-xs font-semibold text-slate-600",
3356
- children: copy.to
3357
+ children: [copy.to, ":"]
3357
3358
  }), emailInput.to.length > 0 ? /* @__PURE__ */ jsx("div", {
3358
3359
  className: "flex flex-wrap gap-2",
3359
3360
  children: emailInput.to.map((recipient) => /* @__PURE__ */ jsx("span", {
@@ -3361,7 +3362,7 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3361
3362
  children: recipient
3362
3363
  }, recipient))
3363
3364
  }) : /* @__PURE__ */ jsx("p", {
3364
- className: "text-sm text-slate-500",
3365
+ className: "text-xs text-slate-500",
3365
3366
  children: copy.noRecipientsProvided
3366
3367
  })]
3367
3368
  }),
@@ -3371,22 +3372,22 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3371
3372
  className: joinClasses(isExpanded ? "block space-y-4" : "hidden"),
3372
3373
  children: [emailInput.text ? /* @__PURE__ */ jsxs("div", {
3373
3374
  className: "space-y-1",
3374
- children: [/* @__PURE__ */ jsx("p", {
3375
+ children: [/* @__PURE__ */ jsxs("p", {
3375
3376
  className: "text-xs font-semibold text-slate-600",
3376
- children: copy.body
3377
+ children: [copy.body, ":"]
3377
3378
  }), /* @__PURE__ */ jsx("p", {
3378
- className: "whitespace-pre-wrap rounded border border-slate-200 bg-slate-50 p-2 text-sm text-slate-700",
3379
+ className: "whitespace-pre-wrap rounded border border-slate-200 bg-white p-2 text-sm text-slate-700",
3379
3380
  children: emailInput.text
3380
3381
  })]
3381
3382
  }) : null, part.result !== void 0 ? /* @__PURE__ */ jsxs("div", {
3382
- className: "space-y-2 rounded border border-slate-200 bg-white p-3",
3383
+ className: "space-y-2 rounded border border-slate-200 bg-slate-50 p-3",
3383
3384
  children: [
3384
3385
  /* @__PURE__ */ jsx("p", {
3385
3386
  className: "text-xs font-semibold uppercase tracking-wide text-slate-500",
3386
3387
  children: copy.delivery
3387
3388
  }),
3388
3389
  emailResult.status ? /* @__PURE__ */ jsxs("p", {
3389
- className: "text-sm text-slate-700",
3390
+ className: "text-xs text-slate-700",
3390
3391
  children: [
3391
3392
  /* @__PURE__ */ jsxs("span", {
3392
3393
  className: "font-semibold text-slate-900",
@@ -3397,7 +3398,7 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3397
3398
  ]
3398
3399
  }) : null,
3399
3400
  emailResult.recipientsCount !== null ? /* @__PURE__ */ jsxs("p", {
3400
- className: "text-sm text-slate-700",
3401
+ className: "text-xs text-slate-700",
3401
3402
  children: [
3402
3403
  /* @__PURE__ */ jsxs("span", {
3403
3404
  className: "font-semibold text-slate-900",
@@ -3408,7 +3409,7 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3408
3409
  ]
3409
3410
  }) : null,
3410
3411
  emailResult.receiptProvider ? /* @__PURE__ */ jsxs("p", {
3411
- className: "text-sm text-slate-700",
3412
+ className: "text-xs text-slate-700",
3412
3413
  children: [
3413
3414
  /* @__PURE__ */ jsxs("span", {
3414
3415
  className: "font-semibold text-slate-900",
@@ -3419,7 +3420,7 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3419
3420
  ]
3420
3421
  }) : null,
3421
3422
  emailResult.receiptMessageId ? /* @__PURE__ */ jsxs("p", {
3422
- className: "break-all text-sm text-slate-700",
3423
+ className: "break-all text-xs text-slate-700",
3423
3424
  children: [
3424
3425
  /* @__PURE__ */ jsxs("span", {
3425
3426
  className: "font-semibold text-slate-900",
@@ -3430,7 +3431,7 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3430
3431
  ]
3431
3432
  }) : null,
3432
3433
  emailResult.receiptRawStatus ? /* @__PURE__ */ jsxs("p", {
3433
- className: "text-sm text-slate-700",
3434
+ className: "text-xs text-slate-700",
3434
3435
  children: [
3435
3436
  /* @__PURE__ */ jsxs("span", {
3436
3437
  className: "font-semibold text-slate-900",
@@ -3441,7 +3442,7 @@ function ToolResultEmailSendCard({ part, className, locale }) {
3441
3442
  ]
3442
3443
  }) : null,
3443
3444
  emailResult.raw ? /* @__PURE__ */ jsx("p", {
3444
- className: "whitespace-pre-wrap text-sm text-slate-700",
3445
+ className: "whitespace-pre-wrap text-xs text-slate-700",
3445
3446
  children: emailResult.raw
3446
3447
  }) : null
3447
3448
  ]
@@ -3754,7 +3755,7 @@ function ToolResultHttpRequestCard({ part, className, locale }) {
3754
3755
 
3755
3756
  //#endregion
3756
3757
  //#region src/components/tool-result-mcp-card.tsx
3757
- function text(value) {
3758
+ function text$1(value) {
3758
3759
  if (typeof value === "string") return value;
3759
3760
  if (value == null) return null;
3760
3761
  try {
@@ -3768,7 +3769,7 @@ function ToolResultMcpCard({ part, className, locale }) {
3768
3769
  const meta = part.metadata;
3769
3770
  const server = meta?.mcp_server_url ?? meta?.server_name;
3770
3771
  const tool = meta?.mcp_tool_name ?? meta?.tool_name ?? part.name;
3771
- const result = text(part.result);
3772
+ const result = text$1(part.result);
3772
3773
  const error = formatToolErrorDetails(part.errorDetails);
3773
3774
  const failed = part.state === "error";
3774
3775
  return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
@@ -3786,7 +3787,7 @@ function ToolResultMcpCard({ part, className, locale }) {
3786
3787
  children: "MCP"
3787
3788
  }),
3788
3789
  /* @__PURE__ */ jsx("span", {
3789
- className: "min-w-0 truncate text-neutral-600",
3790
+ className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
3790
3791
  children: tool
3791
3792
  }),
3792
3793
  /* @__PURE__ */ jsx("span", {
@@ -3895,7 +3896,7 @@ function ToolResultOfficeDocumentsCard({ part, className, locale }) {
3895
3896
  children: copy.officeDocuments
3896
3897
  }),
3897
3898
  /* @__PURE__ */ jsx("span", {
3898
- className: "truncate text-xs text-neutral-500",
3899
+ className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
3899
3900
  children: part.state === "pending" ? copy.pending : `${files.length} ${fileLabel}`
3900
3901
  }),
3901
3902
  /* @__PURE__ */ jsx("span", {
@@ -3970,6 +3971,1318 @@ function ToolResultOfficeDocumentsCard({ part, className, locale }) {
3970
3971
  })] });
3971
3972
  }
3972
3973
 
3974
+ //#endregion
3975
+ //#region src/components/internal/personal-connector-copy.ts
3976
+ const ENGLISH = {
3977
+ searchingMail: "Searching {{service}}",
3978
+ readingMail: "Reading an email in {{service}}",
3979
+ checkingCalendar: "Checking {{service}}",
3980
+ savingDraft: "Saving a draft in {{service}}",
3981
+ preparingMail: "Preparing an email in {{service}}",
3982
+ preparingEvent: "Preparing a change in {{service}}",
3983
+ runningConfirmed: "Running the confirmed actions",
3984
+ openIn: "Open in {{service}}",
3985
+ emailCountOne: "1 email",
3986
+ emailCountOther: "{{count}} emails",
3987
+ eventCountOne: "1 event",
3988
+ eventCountOther: "{{count}} events",
3989
+ noEmails: "No emails found",
3990
+ noEvents: "No events in this period",
3991
+ showAll: "Show all ({{count}})",
3992
+ showLess: "Show less",
3993
+ showMore: "Show more",
3994
+ allDay: "All day",
3995
+ to: "To",
3996
+ cc: "Cc",
3997
+ draftSaved: "Draft saved",
3998
+ openDraft: "Open draft",
3999
+ attendeesOne: "1 attendee",
4000
+ attendeesOther: "{{count}} attendees",
4001
+ noSubject: "(no subject)",
4002
+ unread: "Unread",
4003
+ joinMeeting: "Join",
4004
+ awaitingConfirmation: "Awaiting your confirmation",
4005
+ confirmHint: "Reply “yes” to confirm, or tell the agent what to change.",
4006
+ subject: "Subject",
4007
+ newEvent: "New event",
4008
+ eventChange: "Event change",
4009
+ deleteEvent: "Delete event",
4010
+ attendeesNotified: "Attendees will be notified.",
4011
+ title: "Title",
4012
+ when: "When",
4013
+ location: "Location",
4014
+ attendees: "Attendees",
4015
+ description: "Description",
4016
+ emailSent: "Email sent",
4017
+ eventCreated: "Event created",
4018
+ eventUpdated: "Event updated",
4019
+ eventDeleted: "Event deleted",
4020
+ actionDone: "{{tool}} done",
4021
+ actionFailed: "Failed",
4022
+ openEmail: "Open email",
4023
+ openEvent: "Open event",
4024
+ replyInThread: "Reply in the same thread"
4025
+ };
4026
+ const COPY = {
4027
+ en: {},
4028
+ es: {
4029
+ searchingMail: "Buscando en {{service}}",
4030
+ readingMail: "Leyendo un correo en {{service}}",
4031
+ checkingCalendar: "Consultando {{service}}",
4032
+ savingDraft: "Guardando un borrador en {{service}}",
4033
+ preparingMail: "Preparando un correo en {{service}}",
4034
+ preparingEvent: "Preparando un cambio en {{service}}",
4035
+ runningConfirmed: "Ejecutando las acciones confirmadas",
4036
+ openIn: "Abrir en {{service}}",
4037
+ emailCountOne: "1 correo",
4038
+ emailCountOther: "{{count}} correos",
4039
+ eventCountOne: "1 evento",
4040
+ eventCountOther: "{{count}} eventos",
4041
+ noEmails: "No se han encontrado correos",
4042
+ noEvents: "No hay eventos en este periodo",
4043
+ showAll: "Ver todos ({{count}})",
4044
+ showLess: "Ver menos",
4045
+ showMore: "Ver más",
4046
+ allDay: "Todo el día",
4047
+ to: "Para",
4048
+ cc: "CC",
4049
+ draftSaved: "Borrador guardado",
4050
+ openDraft: "Abrir borrador",
4051
+ attendeesOne: "1 asistente",
4052
+ attendeesOther: "{{count}} asistentes",
4053
+ noSubject: "(sin asunto)",
4054
+ unread: "No leído",
4055
+ joinMeeting: "Unirse",
4056
+ awaitingConfirmation: "Pendiente de tu confirmación",
4057
+ confirmHint: "Responde «sí» para confirmar, o dile al agente qué cambiar.",
4058
+ subject: "Asunto",
4059
+ newEvent: "Nuevo evento",
4060
+ eventChange: "Cambio en el evento",
4061
+ deleteEvent: "Borrar evento",
4062
+ attendeesNotified: "Se avisará a los asistentes.",
4063
+ title: "Título",
4064
+ when: "Cuándo",
4065
+ location: "Ubicación",
4066
+ attendees: "Asistentes",
4067
+ description: "Descripción",
4068
+ emailSent: "Correo enviado",
4069
+ eventCreated: "Evento creado",
4070
+ eventUpdated: "Evento actualizado",
4071
+ eventDeleted: "Evento borrado",
4072
+ actionDone: "{{tool}} hecho",
4073
+ actionFailed: "Error",
4074
+ openEmail: "Abrir correo",
4075
+ openEvent: "Abrir evento",
4076
+ replyInThread: "Respuesta en el mismo hilo"
4077
+ },
4078
+ ca: {
4079
+ searchingMail: "Cercant a {{service}}",
4080
+ readingMail: "Llegint un correu a {{service}}",
4081
+ checkingCalendar: "Consultant {{service}}",
4082
+ savingDraft: "Desant un esborrany a {{service}}",
4083
+ preparingMail: "Preparant un correu a {{service}}",
4084
+ preparingEvent: "Preparant un canvi a {{service}}",
4085
+ runningConfirmed: "Executant les accions confirmades",
4086
+ openIn: "Obre a {{service}}",
4087
+ emailCountOne: "1 correu",
4088
+ emailCountOther: "{{count}} correus",
4089
+ eventCountOne: "1 esdeveniment",
4090
+ eventCountOther: "{{count}} esdeveniments",
4091
+ noEmails: "No s’han trobat correus",
4092
+ noEvents: "No hi ha esdeveniments en aquest període",
4093
+ showAll: "Mostra-ho tot ({{count}})",
4094
+ showLess: "Mostra’n menys",
4095
+ showMore: "Mostra’n més",
4096
+ allDay: "Tot el dia",
4097
+ to: "Per a",
4098
+ cc: "CC",
4099
+ draftSaved: "Esborrany desat",
4100
+ openDraft: "Obre l’esborrany",
4101
+ attendeesOne: "1 assistent",
4102
+ attendeesOther: "{{count}} assistents",
4103
+ noSubject: "(sense assumpte)",
4104
+ unread: "No llegit",
4105
+ joinMeeting: "Uneix-t’hi",
4106
+ awaitingConfirmation: "Pendent de la teva confirmació",
4107
+ confirmHint: "Respon «sí» per confirmar, o digues a l’agent què ha de canviar.",
4108
+ subject: "Assumpte",
4109
+ newEvent: "Nou esdeveniment",
4110
+ eventChange: "Canvi a l’esdeveniment",
4111
+ deleteEvent: "Esborrar esdeveniment",
4112
+ attendeesNotified: "S’avisarà els assistents.",
4113
+ title: "Títol",
4114
+ when: "Quan",
4115
+ location: "Ubicació",
4116
+ attendees: "Assistents",
4117
+ description: "Descripció",
4118
+ emailSent: "Correu enviat",
4119
+ eventCreated: "Esdeveniment creat",
4120
+ eventUpdated: "Esdeveniment actualitzat",
4121
+ eventDeleted: "Esdeveniment esborrat",
4122
+ actionDone: "{{tool}} fet",
4123
+ actionFailed: "Error",
4124
+ openEmail: "Obre el correu",
4125
+ openEvent: "Obre l’esdeveniment",
4126
+ replyInThread: "Resposta al mateix fil"
4127
+ },
4128
+ fr: {
4129
+ searchingMail: "Recherche dans {{service}}",
4130
+ readingMail: "Lecture d’un e-mail dans {{service}}",
4131
+ checkingCalendar: "Consultation de {{service}}",
4132
+ savingDraft: "Enregistrement d’un brouillon dans {{service}}",
4133
+ preparingMail: "Préparation d’un e-mail dans {{service}}",
4134
+ preparingEvent: "Préparation d’une modification dans {{service}}",
4135
+ runningConfirmed: "Exécution des actions confirmées",
4136
+ openIn: "Ouvrir dans {{service}}",
4137
+ emailCountOne: "1 e-mail",
4138
+ emailCountOther: "{{count}} e-mails",
4139
+ eventCountOne: "1 événement",
4140
+ eventCountOther: "{{count}} événements",
4141
+ noEmails: "Aucun e-mail trouvé",
4142
+ noEvents: "Aucun événement sur cette période",
4143
+ showAll: "Tout afficher ({{count}})",
4144
+ showLess: "Afficher moins",
4145
+ showMore: "Afficher plus",
4146
+ allDay: "Toute la journée",
4147
+ to: "À",
4148
+ cc: "Cc",
4149
+ draftSaved: "Brouillon enregistré",
4150
+ openDraft: "Ouvrir le brouillon",
4151
+ attendeesOne: "1 participant",
4152
+ attendeesOther: "{{count}} participants",
4153
+ noSubject: "(sans objet)",
4154
+ unread: "Non lu",
4155
+ joinMeeting: "Rejoindre",
4156
+ awaitingConfirmation: "En attente de votre confirmation",
4157
+ confirmHint: "Répondez « oui » pour confirmer, ou dites à l’agent quoi modifier.",
4158
+ subject: "Objet",
4159
+ newEvent: "Nouvel événement",
4160
+ eventChange: "Modification de l’événement",
4161
+ deleteEvent: "Supprimer l’événement",
4162
+ attendeesNotified: "Les participants seront prévenus.",
4163
+ title: "Titre",
4164
+ when: "Quand",
4165
+ location: "Lieu",
4166
+ attendees: "Participants",
4167
+ description: "Description",
4168
+ emailSent: "E-mail envoyé",
4169
+ eventCreated: "Événement créé",
4170
+ eventUpdated: "Événement mis à jour",
4171
+ eventDeleted: "Événement supprimé",
4172
+ actionDone: "{{tool}} terminé",
4173
+ actionFailed: "Échec",
4174
+ openEmail: "Ouvrir l’e-mail",
4175
+ openEvent: "Ouvrir l’événement",
4176
+ replyInThread: "Réponse dans le même fil"
4177
+ },
4178
+ it: {
4179
+ searchingMail: "Ricerca in {{service}}",
4180
+ readingMail: "Lettura di un’email in {{service}}",
4181
+ checkingCalendar: "Consultazione di {{service}}",
4182
+ savingDraft: "Salvataggio di una bozza in {{service}}",
4183
+ preparingMail: "Preparazione di un’email in {{service}}",
4184
+ preparingEvent: "Preparazione di una modifica in {{service}}",
4185
+ runningConfirmed: "Esecuzione delle azioni confermate",
4186
+ openIn: "Apri in {{service}}",
4187
+ emailCountOne: "1 email",
4188
+ emailCountOther: "{{count}} email",
4189
+ eventCountOne: "1 evento",
4190
+ eventCountOther: "{{count}} eventi",
4191
+ noEmails: "Nessuna email trovata",
4192
+ noEvents: "Nessun evento in questo periodo",
4193
+ showAll: "Mostra tutto ({{count}})",
4194
+ showLess: "Mostra meno",
4195
+ showMore: "Mostra di più",
4196
+ allDay: "Tutto il giorno",
4197
+ to: "A",
4198
+ cc: "Cc",
4199
+ draftSaved: "Bozza salvata",
4200
+ openDraft: "Apri bozza",
4201
+ attendeesOne: "1 partecipante",
4202
+ attendeesOther: "{{count}} partecipanti",
4203
+ noSubject: "(nessun oggetto)",
4204
+ unread: "Non letta",
4205
+ joinMeeting: "Partecipa",
4206
+ awaitingConfirmation: "In attesa della tua conferma",
4207
+ confirmHint: "Rispondi «sì» per confermare, o di’ all’agente cosa cambiare.",
4208
+ subject: "Oggetto",
4209
+ newEvent: "Nuovo evento",
4210
+ eventChange: "Modifica dell’evento",
4211
+ deleteEvent: "Elimina evento",
4212
+ attendeesNotified: "I partecipanti verranno avvisati.",
4213
+ title: "Titolo",
4214
+ when: "Quando",
4215
+ location: "Luogo",
4216
+ attendees: "Partecipanti",
4217
+ description: "Descrizione",
4218
+ emailSent: "Email inviata",
4219
+ eventCreated: "Evento creato",
4220
+ eventUpdated: "Evento aggiornato",
4221
+ eventDeleted: "Evento eliminato",
4222
+ actionDone: "{{tool}} completato",
4223
+ actionFailed: "Errore",
4224
+ openEmail: "Apri email",
4225
+ openEvent: "Apri evento",
4226
+ replyInThread: "Risposta nello stesso thread"
4227
+ },
4228
+ de: {
4229
+ searchingMail: "Suche in {{service}}",
4230
+ readingMail: "E-Mail in {{service}} wird gelesen",
4231
+ checkingCalendar: "{{service}} wird abgefragt",
4232
+ savingDraft: "Entwurf wird in {{service}} gespeichert",
4233
+ preparingMail: "E-Mail in {{service}} wird vorbereitet",
4234
+ preparingEvent: "Änderung in {{service}} wird vorbereitet",
4235
+ runningConfirmed: "Bestätigte Aktionen werden ausgeführt",
4236
+ openIn: "In {{service}} öffnen",
4237
+ emailCountOne: "1 E-Mail",
4238
+ emailCountOther: "{{count}} E-Mails",
4239
+ eventCountOne: "1 Termin",
4240
+ eventCountOther: "{{count}} Termine",
4241
+ noEmails: "Keine E-Mails gefunden",
4242
+ noEvents: "Keine Termine in diesem Zeitraum",
4243
+ showAll: "Alle anzeigen ({{count}})",
4244
+ showLess: "Weniger anzeigen",
4245
+ showMore: "Mehr anzeigen",
4246
+ allDay: "Ganztägig",
4247
+ to: "An",
4248
+ cc: "Cc",
4249
+ draftSaved: "Entwurf gespeichert",
4250
+ openDraft: "Entwurf öffnen",
4251
+ attendeesOne: "1 Teilnehmer",
4252
+ attendeesOther: "{{count}} Teilnehmer",
4253
+ noSubject: "(kein Betreff)",
4254
+ unread: "Ungelesen",
4255
+ joinMeeting: "Teilnehmen",
4256
+ awaitingConfirmation: "Wartet auf deine Bestätigung",
4257
+ confirmHint: "Antworte mit „ja“, um zu bestätigen, oder sag dem Agenten, was er ändern soll.",
4258
+ subject: "Betreff",
4259
+ newEvent: "Neuer Termin",
4260
+ eventChange: "Terminänderung",
4261
+ deleteEvent: "Termin löschen",
4262
+ attendeesNotified: "Die Teilnehmer werden benachrichtigt.",
4263
+ title: "Titel",
4264
+ when: "Wann",
4265
+ location: "Ort",
4266
+ attendees: "Teilnehmer",
4267
+ description: "Beschreibung",
4268
+ emailSent: "E-Mail gesendet",
4269
+ eventCreated: "Termin erstellt",
4270
+ eventUpdated: "Termin aktualisiert",
4271
+ eventDeleted: "Termin gelöscht",
4272
+ actionDone: "{{tool}} erledigt",
4273
+ actionFailed: "Fehlgeschlagen",
4274
+ openEmail: "E-Mail öffnen",
4275
+ openEvent: "Termin öffnen",
4276
+ replyInThread: "Antwort im selben Verlauf"
4277
+ },
4278
+ da: {
4279
+ searchingMail: "Søger i {{service}}",
4280
+ readingMail: "Læser en e-mail i {{service}}",
4281
+ checkingCalendar: "Tjekker {{service}}",
4282
+ savingDraft: "Gemmer en kladde i {{service}}",
4283
+ preparingMail: "Forbereder en e-mail i {{service}}",
4284
+ preparingEvent: "Forbereder en ændring i {{service}}",
4285
+ runningConfirmed: "Udfører de bekræftede handlinger",
4286
+ openIn: "Åbn i {{service}}",
4287
+ emailCountOne: "1 e-mail",
4288
+ emailCountOther: "{{count}} e-mails",
4289
+ eventCountOne: "1 begivenhed",
4290
+ eventCountOther: "{{count}} begivenheder",
4291
+ noEmails: "Ingen e-mails fundet",
4292
+ noEvents: "Ingen begivenheder i denne periode",
4293
+ showAll: "Vis alle ({{count}})",
4294
+ showLess: "Vis mindre",
4295
+ showMore: "Vis mere",
4296
+ allDay: "Hele dagen",
4297
+ to: "Til",
4298
+ cc: "Cc",
4299
+ draftSaved: "Kladde gemt",
4300
+ openDraft: "Åbn kladde",
4301
+ attendeesOne: "1 deltager",
4302
+ attendeesOther: "{{count}} deltagere",
4303
+ noSubject: "(intet emne)",
4304
+ unread: "Ulæst",
4305
+ joinMeeting: "Deltag",
4306
+ awaitingConfirmation: "Afventer din bekræftelse",
4307
+ confirmHint: "Svar “ja” for at bekræfte, eller fortæl agenten, hvad der skal ændres.",
4308
+ subject: "Emne",
4309
+ newEvent: "Ny begivenhed",
4310
+ eventChange: "Ændring af begivenhed",
4311
+ deleteEvent: "Slet begivenhed",
4312
+ attendeesNotified: "Deltagerne får besked.",
4313
+ title: "Titel",
4314
+ when: "Hvornår",
4315
+ location: "Sted",
4316
+ attendees: "Deltagere",
4317
+ description: "Beskrivelse",
4318
+ emailSent: "E-mail sendt",
4319
+ eventCreated: "Begivenhed oprettet",
4320
+ eventUpdated: "Begivenhed opdateret",
4321
+ eventDeleted: "Begivenhed slettet",
4322
+ actionDone: "{{tool}} udført",
4323
+ actionFailed: "Mislykkedes",
4324
+ openEmail: "Åbn e-mail",
4325
+ openEvent: "Åbn begivenhed",
4326
+ replyInThread: "Svar i samme tråd"
4327
+ },
4328
+ sv: {
4329
+ searchingMail: "Söker i {{service}}",
4330
+ readingMail: "Läser ett mejl i {{service}}",
4331
+ checkingCalendar: "Kollar {{service}}",
4332
+ savingDraft: "Sparar ett utkast i {{service}}",
4333
+ preparingMail: "Förbereder ett mejl i {{service}}",
4334
+ preparingEvent: "Förbereder en ändring i {{service}}",
4335
+ runningConfirmed: "Utför de bekräftade åtgärderna",
4336
+ openIn: "Öppna i {{service}}",
4337
+ emailCountOne: "1 mejl",
4338
+ emailCountOther: "{{count}} mejl",
4339
+ eventCountOne: "1 händelse",
4340
+ eventCountOther: "{{count}} händelser",
4341
+ noEmails: "Inga mejl hittades",
4342
+ noEvents: "Inga händelser under perioden",
4343
+ showAll: "Visa alla ({{count}})",
4344
+ showLess: "Visa mindre",
4345
+ showMore: "Visa mer",
4346
+ allDay: "Heldag",
4347
+ to: "Till",
4348
+ cc: "Kopia",
4349
+ draftSaved: "Utkast sparat",
4350
+ openDraft: "Öppna utkast",
4351
+ attendeesOne: "1 deltagare",
4352
+ attendeesOther: "{{count}} deltagare",
4353
+ noSubject: "(inget ämne)",
4354
+ unread: "Oläst",
4355
+ joinMeeting: "Anslut",
4356
+ awaitingConfirmation: "Väntar på din bekräftelse",
4357
+ confirmHint: "Svara ”ja” för att bekräfta, eller säg till agenten vad som ska ändras.",
4358
+ subject: "Ämne",
4359
+ newEvent: "Ny händelse",
4360
+ eventChange: "Ändring av händelse",
4361
+ deleteEvent: "Ta bort händelse",
4362
+ attendeesNotified: "Deltagarna meddelas.",
4363
+ title: "Titel",
4364
+ when: "När",
4365
+ location: "Plats",
4366
+ attendees: "Deltagare",
4367
+ description: "Beskrivning",
4368
+ emailSent: "Mejl skickat",
4369
+ eventCreated: "Händelse skapad",
4370
+ eventUpdated: "Händelse uppdaterad",
4371
+ eventDeleted: "Händelse borttagen",
4372
+ actionDone: "{{tool}} klar",
4373
+ actionFailed: "Misslyckades",
4374
+ openEmail: "Öppna mejl",
4375
+ openEvent: "Öppna händelse",
4376
+ replyInThread: "Svar i samma tråd"
4377
+ },
4378
+ no: {
4379
+ searchingMail: "Søker i {{service}}",
4380
+ readingMail: "Leser en e-post i {{service}}",
4381
+ checkingCalendar: "Sjekker {{service}}",
4382
+ savingDraft: "Lagrer et utkast i {{service}}",
4383
+ preparingMail: "Forbereder en e-post i {{service}}",
4384
+ preparingEvent: "Forbereder en endring i {{service}}",
4385
+ runningConfirmed: "Utfører de bekreftede handlingene",
4386
+ openIn: "Åpne i {{service}}",
4387
+ emailCountOne: "1 e-post",
4388
+ emailCountOther: "{{count}} e-poster",
4389
+ eventCountOne: "1 hendelse",
4390
+ eventCountOther: "{{count}} hendelser",
4391
+ noEmails: "Fant ingen e-poster",
4392
+ noEvents: "Ingen hendelser i denne perioden",
4393
+ showAll: "Vis alle ({{count}})",
4394
+ showLess: "Vis mindre",
4395
+ showMore: "Vis mer",
4396
+ allDay: "Hele dagen",
4397
+ to: "Til",
4398
+ cc: "Kopi",
4399
+ draftSaved: "Utkast lagret",
4400
+ openDraft: "Åpne utkast",
4401
+ attendeesOne: "1 deltaker",
4402
+ attendeesOther: "{{count}} deltakere",
4403
+ noSubject: "(intet emne)",
4404
+ unread: "Ulest",
4405
+ joinMeeting: "Bli med",
4406
+ awaitingConfirmation: "Venter på bekreftelsen din",
4407
+ confirmHint: "Svar «ja» for å bekrefte, eller si til agenten hva som skal endres.",
4408
+ subject: "Emne",
4409
+ newEvent: "Ny hendelse",
4410
+ eventChange: "Endring av hendelse",
4411
+ deleteEvent: "Slett hendelse",
4412
+ attendeesNotified: "Deltakerne blir varslet.",
4413
+ title: "Tittel",
4414
+ when: "Når",
4415
+ location: "Sted",
4416
+ attendees: "Deltakere",
4417
+ description: "Beskrivelse",
4418
+ emailSent: "E-post sendt",
4419
+ eventCreated: "Hendelse opprettet",
4420
+ eventUpdated: "Hendelse oppdatert",
4421
+ eventDeleted: "Hendelse slettet",
4422
+ actionDone: "{{tool}} fullført",
4423
+ actionFailed: "Mislyktes",
4424
+ openEmail: "Åpne e-post",
4425
+ openEvent: "Åpne hendelse",
4426
+ replyInThread: "Svar i samme tråd"
4427
+ },
4428
+ pt: {
4429
+ searchingMail: "Pesquisando no {{service}}",
4430
+ readingMail: "Lendo um e-mail no {{service}}",
4431
+ checkingCalendar: "Consultando o {{service}}",
4432
+ savingDraft: "Salvando um rascunho no {{service}}",
4433
+ preparingMail: "Preparando um e-mail no {{service}}",
4434
+ preparingEvent: "Preparando uma alteração no {{service}}",
4435
+ runningConfirmed: "Executando as ações confirmadas",
4436
+ openIn: "Abrir no {{service}}",
4437
+ emailCountOne: "1 e-mail",
4438
+ emailCountOther: "{{count}} e-mails",
4439
+ eventCountOne: "1 evento",
4440
+ eventCountOther: "{{count}} eventos",
4441
+ noEmails: "Nenhum e-mail encontrado",
4442
+ noEvents: "Nenhum evento neste período",
4443
+ showAll: "Ver todos ({{count}})",
4444
+ showLess: "Ver menos",
4445
+ showMore: "Ver mais",
4446
+ allDay: "Dia inteiro",
4447
+ to: "Para",
4448
+ cc: "Cc",
4449
+ draftSaved: "Rascunho salvo",
4450
+ openDraft: "Abrir rascunho",
4451
+ attendeesOne: "1 participante",
4452
+ attendeesOther: "{{count}} participantes",
4453
+ noSubject: "(sem assunto)",
4454
+ unread: "Não lido",
4455
+ joinMeeting: "Entrar",
4456
+ awaitingConfirmation: "Aguardando sua confirmação",
4457
+ confirmHint: "Responda “sim” para confirmar, ou diga ao agente o que mudar.",
4458
+ subject: "Assunto",
4459
+ newEvent: "Novo evento",
4460
+ eventChange: "Alteração do evento",
4461
+ deleteEvent: "Excluir evento",
4462
+ attendeesNotified: "Os participantes serão avisados.",
4463
+ title: "Título",
4464
+ when: "Quando",
4465
+ location: "Local",
4466
+ attendees: "Participantes",
4467
+ description: "Descrição",
4468
+ emailSent: "E-mail enviado",
4469
+ eventCreated: "Evento criado",
4470
+ eventUpdated: "Evento atualizado",
4471
+ eventDeleted: "Evento excluído",
4472
+ actionDone: "{{tool}} concluído",
4473
+ actionFailed: "Falhou",
4474
+ openEmail: "Abrir e-mail",
4475
+ openEvent: "Abrir evento",
4476
+ replyInThread: "Resposta na mesma conversa"
4477
+ }
4478
+ };
4479
+ function getPersonalConnectorCopy(locale) {
4480
+ return {
4481
+ ...ENGLISH,
4482
+ ...COPY[getSupportedToolLocale(locale)]
4483
+ };
4484
+ }
4485
+ function fillCopy(template, values) {
4486
+ return template.replace(/\{\{(\w+)\}\}/g, (match, key) => key in values ? String(values[key]) : match);
4487
+ }
4488
+
4489
+ //#endregion
4490
+ //#region src/components/tool-result-personal-connector-card.tsx
4491
+ const COLLAPSED_ITEMS = 5;
4492
+ const COLLAPSED_BODY_CHARS = 600;
4493
+ const EVENT_OPERATIONS = [
4494
+ "create_event",
4495
+ "update_event",
4496
+ "delete_event"
4497
+ ];
4498
+ function isEventOperation(value) {
4499
+ return EVENT_OPERATIONS.includes(value);
4500
+ }
4501
+ function asRecord(value) {
4502
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
4503
+ }
4504
+ function text(value) {
4505
+ return typeof value === "string" && value.trim().length > 0 ? value : null;
4506
+ }
4507
+ function hasId(value) {
4508
+ return typeof asRecord(value)?.id === "string";
4509
+ }
4510
+ function getView(part) {
4511
+ const metadata = asRecord(part.metadata);
4512
+ if (!metadata || metadata.error) return null;
4513
+ const result = metadata.result;
4514
+ const pending = asRecord(metadata.pending_confirmation);
4515
+ if (pending) {
4516
+ const confirmation = pending;
4517
+ if (!asRecord(confirmation.action)) return null;
4518
+ if (metadata.action === "send") return {
4519
+ kind: "pending-mail",
4520
+ pending: confirmation
4521
+ };
4522
+ return isEventOperation(metadata.action) ? {
4523
+ kind: "pending-event",
4524
+ operation: metadata.action,
4525
+ pending: confirmation
4526
+ } : null;
4527
+ }
4528
+ switch (metadata.action) {
4529
+ case "search": return Array.isArray(result) ? {
4530
+ kind: "mail-list",
4531
+ messages: result.filter(hasId)
4532
+ } : null;
4533
+ case "read": return hasId(result) ? {
4534
+ kind: "mail",
4535
+ message: result
4536
+ } : null;
4537
+ case "list_events": return Array.isArray(result) ? {
4538
+ kind: "events",
4539
+ events: result.filter(hasId)
4540
+ } : null;
4541
+ case "create_draft": {
4542
+ const input = asRecord(part.input);
4543
+ return {
4544
+ kind: "draft",
4545
+ link: text(asRecord(result)?.link),
4546
+ to: Array.isArray(input?.to) ? input.to.filter((item) => typeof item === "string") : [],
4547
+ subject: text(input?.subject),
4548
+ body: text(input?.body)
4549
+ };
4550
+ }
4551
+ default: return null;
4552
+ }
4553
+ }
4554
+ /** Whether the part has a dedicated view; otherwise the generic card renders it. */
4555
+ function hasPersonalConnectorView(part) {
4556
+ return part.state === "completed" && getView(part) !== null;
4557
+ }
4558
+ function getConnector(part) {
4559
+ const connector = asRecord(asRecord(part.metadata)?.connector);
4560
+ return connector && typeof connector.label === "string" ? connector : null;
4561
+ }
4562
+ function isCalendar(connector) {
4563
+ return connector?.capability.includes("calendar") ?? false;
4564
+ }
4565
+ function dateFormatter(locale, options) {
4566
+ try {
4567
+ return new Intl.DateTimeFormat(locale ?? void 0, options);
4568
+ } catch {
4569
+ return new Intl.DateTimeFormat(void 0, options);
4570
+ }
4571
+ }
4572
+ /** All-day values come as "YYYY-MM-DD": read them as local dates, not UTC. */
4573
+ function parseDate(value) {
4574
+ if (!value) return null;
4575
+ const dateOnly = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
4576
+ const date = dateOnly ? new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3])) : new Date(value);
4577
+ return Number.isNaN(date.getTime()) ? null : date;
4578
+ }
4579
+ function isSameDay(a, b) {
4580
+ return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
4581
+ }
4582
+ function formatMailDate(value, locale) {
4583
+ const date = parseDate(value);
4584
+ if (!date) return value ?? null;
4585
+ return isSameDay(date, /* @__PURE__ */ new Date()) ? dateFormatter(locale, {
4586
+ hour: "2-digit",
4587
+ minute: "2-digit"
4588
+ }).format(date) : dateFormatter(locale, {
4589
+ day: "numeric",
4590
+ month: "short"
4591
+ }).format(date);
4592
+ }
4593
+ function formatFullDate(value, locale) {
4594
+ const date = parseDate(value);
4595
+ if (!date) return value ?? null;
4596
+ return dateFormatter(locale, {
4597
+ dateStyle: "medium",
4598
+ timeStyle: "short"
4599
+ }).format(date);
4600
+ }
4601
+ /** "Ana Pérez <ana@acme.com>" → "Ana Pérez". */
4602
+ function displayName(address) {
4603
+ if (!address) return null;
4604
+ const match = /^\s*"?([^"<]+?)"?\s*<[^>]+>\s*$/.exec(address);
4605
+ return match ? match[1] : address;
4606
+ }
4607
+ function count(copy, n, one, other) {
4608
+ return n === 1 ? one : fillCopy(other, { count: n });
4609
+ }
4610
+ function ExternalAnchor({ href, className, children, label }) {
4611
+ return /* @__PURE__ */ jsx("a", {
4612
+ href,
4613
+ target: "_blank",
4614
+ rel: "noreferrer noopener",
4615
+ "aria-label": label,
4616
+ className: joinClasses("inline-flex items-center gap-1 text-xs font-medium text-neutral-700 hover:text-neutral-950 hover:underline", className),
4617
+ children
4618
+ });
4619
+ }
4620
+ function ShowAllToggle({ total, expanded, onToggle, copy }) {
4621
+ if (total <= COLLAPSED_ITEMS) return null;
4622
+ return /* @__PURE__ */ jsx("button", {
4623
+ type: "button",
4624
+ onClick: onToggle,
4625
+ 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",
4626
+ children: expanded ? copy.showLess : fillCopy(copy.showAll, { count: total })
4627
+ });
4628
+ }
4629
+ function MailRow({ message, locale, copy }) {
4630
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [
4631
+ /* @__PURE__ */ jsxs("div", {
4632
+ className: "flex items-baseline gap-2",
4633
+ children: [
4634
+ /* @__PURE__ */ jsx("span", {
4635
+ "aria-label": message.unread ? copy.unread : void 0,
4636
+ className: joinClasses("h-2 w-2 shrink-0 self-center rounded-full", message.unread ? "bg-blue-600" : "bg-transparent")
4637
+ }),
4638
+ /* @__PURE__ */ jsx("span", {
4639
+ className: joinClasses("min-w-0 flex-1 truncate text-sm", message.unread ? "font-semibold text-neutral-950" : "text-neutral-800"),
4640
+ children: displayName(message.from) ?? "—"
4641
+ }),
4642
+ /* @__PURE__ */ jsx("span", {
4643
+ className: "shrink-0 text-xs text-neutral-500",
4644
+ children: formatMailDate(message.date, locale)
4645
+ })
4646
+ ]
4647
+ }),
4648
+ /* @__PURE__ */ jsx("p", {
4649
+ className: joinClasses("truncate pl-4 text-sm", message.unread ? "font-medium text-neutral-950" : "text-neutral-700"),
4650
+ children: text(message.subject) ?? copy.noSubject
4651
+ }),
4652
+ text(message.snippet) ? /* @__PURE__ */ jsx("p", {
4653
+ className: "line-clamp-1 pl-4 text-xs text-neutral-500",
4654
+ children: message.snippet
4655
+ }) : null
4656
+ ] });
4657
+ const className = "block space-y-0.5 px-3 py-2";
4658
+ return message.link ? /* @__PURE__ */ jsx("a", {
4659
+ href: message.link,
4660
+ target: "_blank",
4661
+ rel: "noreferrer noopener",
4662
+ className: joinClasses(className, "hover:bg-neutral-50"),
4663
+ children: content
4664
+ }) : /* @__PURE__ */ jsx("div", {
4665
+ className,
4666
+ children: content
4667
+ });
4668
+ }
4669
+ function MailList({ messages, locale, copy }) {
4670
+ const [expanded, setExpanded] = useState(false);
4671
+ if (messages.length === 0) return /* @__PURE__ */ jsx("p", {
4672
+ className: "px-3 py-3 text-sm text-neutral-600",
4673
+ children: copy.noEmails
4674
+ });
4675
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("ul", {
4676
+ className: "divide-y divide-neutral-100",
4677
+ children: (expanded ? messages : messages.slice(0, COLLAPSED_ITEMS)).map((message) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(MailRow, {
4678
+ message,
4679
+ locale,
4680
+ copy
4681
+ }) }, message.id))
4682
+ }), /* @__PURE__ */ jsx(ShowAllToggle, {
4683
+ total: messages.length,
4684
+ expanded,
4685
+ onToggle: () => setExpanded((value) => !value),
4686
+ copy
4687
+ })] });
4688
+ }
4689
+ function MailMessageView({ message, connector, locale, copy }) {
4690
+ const [expanded, setExpanded] = useState(false);
4691
+ const body = text(message.body);
4692
+ const long = (body?.length ?? 0) > COLLAPSED_BODY_CHARS;
4693
+ const shownBody = body && long && !expanded ? `${body.slice(0, COLLAPSED_BODY_CHARS).trimEnd()}…` : body;
4694
+ return /* @__PURE__ */ jsxs("div", {
4695
+ className: "space-y-3 px-3 py-3",
4696
+ children: [
4697
+ /* @__PURE__ */ jsxs("div", {
4698
+ className: "space-y-1",
4699
+ children: [
4700
+ /* @__PURE__ */ jsx("h4", {
4701
+ className: "text-sm font-semibold text-neutral-950",
4702
+ children: text(message.subject) ?? copy.noSubject
4703
+ }),
4704
+ /* @__PURE__ */ jsxs("div", {
4705
+ className: "flex items-baseline gap-2 text-xs text-neutral-600",
4706
+ children: [/* @__PURE__ */ jsx("span", {
4707
+ className: "min-w-0 flex-1 truncate font-medium text-neutral-800",
4708
+ children: message.from ?? "—"
4709
+ }), /* @__PURE__ */ jsx("span", {
4710
+ className: "shrink-0",
4711
+ children: formatFullDate(message.date, locale)
4712
+ })]
4713
+ }),
4714
+ text(message.to) ? /* @__PURE__ */ jsxs("p", {
4715
+ className: "truncate text-xs text-neutral-500",
4716
+ children: [
4717
+ copy.to,
4718
+ ": ",
4719
+ message.to
4720
+ ]
4721
+ }) : null,
4722
+ text(message.cc) ? /* @__PURE__ */ jsxs("p", {
4723
+ className: "truncate text-xs text-neutral-500",
4724
+ children: [
4725
+ copy.cc,
4726
+ ": ",
4727
+ message.cc
4728
+ ]
4729
+ }) : null
4730
+ ]
4731
+ }),
4732
+ shownBody ? /* @__PURE__ */ jsx("p", {
4733
+ className: "whitespace-pre-wrap break-words text-sm leading-6 text-neutral-800",
4734
+ children: shownBody
4735
+ }) : null,
4736
+ /* @__PURE__ */ jsxs("div", {
4737
+ className: "flex items-center gap-4",
4738
+ children: [long ? /* @__PURE__ */ jsx("button", {
4739
+ type: "button",
4740
+ onClick: () => setExpanded((value) => !value),
4741
+ className: "text-xs font-medium text-neutral-600 hover:text-neutral-950",
4742
+ children: expanded ? copy.showLess : copy.showMore
4743
+ }) : null, message.link ? /* @__PURE__ */ jsxs(ExternalAnchor, {
4744
+ href: message.link,
4745
+ children: [fillCopy(copy.openIn, { service: connector?.label ?? "" }), /* @__PURE__ */ jsx(ExternalLink, {
4746
+ className: "h-3 w-3",
4747
+ "aria-hidden": "true"
4748
+ })]
4749
+ }) : null]
4750
+ })
4751
+ ]
4752
+ });
4753
+ }
4754
+ function eventTime(event, locale, copy) {
4755
+ if (event.all_day) return copy.allDay;
4756
+ const start = parseDate(event.start);
4757
+ const end = parseDate(event.end);
4758
+ if (!start) return null;
4759
+ const time = dateFormatter(locale, {
4760
+ hour: "2-digit",
4761
+ minute: "2-digit"
4762
+ });
4763
+ return end ? `${time.format(start)} – ${time.format(end)}` : time.format(start);
4764
+ }
4765
+ function groupByDay(events) {
4766
+ const groups = [];
4767
+ for (const event of events) {
4768
+ const day = parseDate(event.start);
4769
+ const last = groups[groups.length - 1];
4770
+ if (last && (last.day && day && isSameDay(last.day, day) || !last.day && !day)) last.events.push(event);
4771
+ else groups.push({
4772
+ day,
4773
+ events: [event]
4774
+ });
4775
+ }
4776
+ return groups;
4777
+ }
4778
+ function EventRow({ event, locale, copy }) {
4779
+ const attendees = event.attendees?.length ?? 0;
4780
+ const details = [text(event.location), attendees > 0 ? count(copy, attendees, copy.attendeesOne, copy.attendeesOther) : null].filter(Boolean);
4781
+ return /* @__PURE__ */ jsxs("li", {
4782
+ className: "flex gap-3 px-3 py-2",
4783
+ children: [
4784
+ /* @__PURE__ */ jsx("span", {
4785
+ className: "w-24 shrink-0 pt-0.5 text-xs tabular-nums text-neutral-600",
4786
+ children: eventTime(event, locale, copy)
4787
+ }),
4788
+ /* @__PURE__ */ jsxs("div", {
4789
+ className: "min-w-0 flex-1 space-y-0.5",
4790
+ children: [event.link ? /* @__PURE__ */ jsx("a", {
4791
+ href: event.link,
4792
+ target: "_blank",
4793
+ rel: "noreferrer noopener",
4794
+ className: "block truncate text-sm font-medium text-neutral-950 hover:underline",
4795
+ children: text(event.title) ?? copy.noSubject
4796
+ }) : /* @__PURE__ */ jsx("p", {
4797
+ className: "truncate text-sm font-medium text-neutral-950",
4798
+ children: text(event.title) ?? copy.noSubject
4799
+ }), details.length > 0 ? /* @__PURE__ */ jsx("p", {
4800
+ className: "truncate text-xs text-neutral-500",
4801
+ children: details.join(" · ")
4802
+ }) : null]
4803
+ }),
4804
+ event.online_meeting_url ? /* @__PURE__ */ jsxs(ExternalAnchor, {
4805
+ href: event.online_meeting_url,
4806
+ className: "shrink-0 self-start",
4807
+ children: [/* @__PURE__ */ jsx(Video, {
4808
+ className: "h-3.5 w-3.5",
4809
+ "aria-hidden": "true"
4810
+ }), copy.joinMeeting]
4811
+ }) : null
4812
+ ]
4813
+ });
4814
+ }
4815
+ function Agenda({ events, locale, copy }) {
4816
+ const [expanded, setExpanded] = useState(false);
4817
+ if (events.length === 0) return /* @__PURE__ */ jsx("p", {
4818
+ className: "px-3 py-3 text-sm text-neutral-600",
4819
+ children: copy.noEvents
4820
+ });
4821
+ const visible = expanded ? events : events.slice(0, COLLAPSED_ITEMS);
4822
+ const dayFormat = dateFormatter(locale, {
4823
+ weekday: "long",
4824
+ day: "numeric",
4825
+ month: "long"
4826
+ });
4827
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
4828
+ className: "divide-y divide-neutral-100",
4829
+ children: groupByDay(visible).map((group, index) => /* @__PURE__ */ jsxs("section", { children: [group.day ? /* @__PURE__ */ jsx("h4", {
4830
+ className: "bg-neutral-50 px-3 py-1 text-xs font-medium capitalize text-neutral-600",
4831
+ children: dayFormat.format(group.day)
4832
+ }) : null, /* @__PURE__ */ jsx("ul", {
4833
+ className: "divide-y divide-neutral-100",
4834
+ children: group.events.map((event) => /* @__PURE__ */ jsx(EventRow, {
4835
+ event,
4836
+ locale,
4837
+ copy
4838
+ }, event.id))
4839
+ })] }, group.day?.toISOString() ?? `undated-${index}`))
4840
+ }), /* @__PURE__ */ jsx(ShowAllToggle, {
4841
+ total: events.length,
4842
+ expanded,
4843
+ onToggle: () => setExpanded((value) => !value),
4844
+ copy
4845
+ })] });
4846
+ }
4847
+ function CollapsibleBody({ body, copy }) {
4848
+ const [expanded, setExpanded] = useState(false);
4849
+ if (!body) return null;
4850
+ const long = body.length > COLLAPSED_BODY_CHARS;
4851
+ return /* @__PURE__ */ jsxs("div", {
4852
+ className: "space-y-1",
4853
+ children: [/* @__PURE__ */ jsx("p", {
4854
+ className: "whitespace-pre-wrap break-words text-sm leading-6 text-neutral-800",
4855
+ children: long && !expanded ? `${body.slice(0, COLLAPSED_BODY_CHARS).trimEnd()}…` : body
4856
+ }), long ? /* @__PURE__ */ jsx("button", {
4857
+ type: "button",
4858
+ onClick: () => setExpanded((value) => !value),
4859
+ className: "text-xs font-medium text-neutral-600 hover:text-neutral-950",
4860
+ children: expanded ? copy.showLess : copy.showMore
4861
+ }) : null]
4862
+ });
4863
+ }
4864
+ function DraftView({ view, copy }) {
4865
+ return /* @__PURE__ */ jsxs("div", {
4866
+ className: "space-y-2 px-3 py-3",
4867
+ children: [
4868
+ /* @__PURE__ */ jsxs("div", {
4869
+ className: "space-y-1",
4870
+ children: [
4871
+ /* @__PURE__ */ jsx("p", {
4872
+ className: "text-sm font-medium text-neutral-950",
4873
+ children: copy.draftSaved
4874
+ }),
4875
+ view.subject ? /* @__PURE__ */ jsx("p", {
4876
+ className: "truncate text-sm text-neutral-800",
4877
+ children: view.subject
4878
+ }) : null,
4879
+ view.to.length > 0 ? /* @__PURE__ */ jsxs("p", {
4880
+ className: "truncate text-xs text-neutral-500",
4881
+ children: [
4882
+ copy.to,
4883
+ ": ",
4884
+ view.to.join(", ")
4885
+ ]
4886
+ }) : null
4887
+ ]
4888
+ }),
4889
+ /* @__PURE__ */ jsx(CollapsibleBody, {
4890
+ body: view.body,
4891
+ copy
4892
+ }),
4893
+ view.link ? /* @__PURE__ */ jsxs(ExternalAnchor, {
4894
+ href: view.link,
4895
+ children: [copy.openDraft, /* @__PURE__ */ jsx(ExternalLink, {
4896
+ className: "h-3 w-3",
4897
+ "aria-hidden": "true"
4898
+ })]
4899
+ }) : null
4900
+ ]
4901
+ });
4902
+ }
4903
+ function strings(value) {
4904
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
4905
+ }
4906
+ function Field({ label, children }) {
4907
+ return /* @__PURE__ */ jsxs("div", {
4908
+ className: "flex gap-3 text-sm",
4909
+ children: [/* @__PURE__ */ jsx("dt", {
4910
+ className: "w-24 shrink-0 text-xs leading-5 text-neutral-500",
4911
+ children: label
4912
+ }), /* @__PURE__ */ jsx("dd", {
4913
+ className: "min-w-0 flex-1 break-words text-neutral-900",
4914
+ children
4915
+ })]
4916
+ });
4917
+ }
4918
+ function PendingMailView({ pending, copy }) {
4919
+ const mail = pending.action;
4920
+ const to = strings(mail.to);
4921
+ const cc = strings(mail.cc);
4922
+ return /* @__PURE__ */ jsxs("div", {
4923
+ className: "space-y-3 px-3 py-3",
4924
+ children: [
4925
+ /* @__PURE__ */ jsxs("dl", {
4926
+ className: "space-y-1.5",
4927
+ children: [
4928
+ /* @__PURE__ */ jsx(Field, {
4929
+ label: copy.to,
4930
+ children: to.join(", ") || "—"
4931
+ }),
4932
+ cc.length > 0 ? /* @__PURE__ */ jsx(Field, {
4933
+ label: copy.cc,
4934
+ children: cc.join(", ")
4935
+ }) : null,
4936
+ /* @__PURE__ */ jsx(Field, {
4937
+ label: copy.subject,
4938
+ children: /* @__PURE__ */ jsx("span", {
4939
+ className: "font-medium",
4940
+ children: text(mail.subject) ?? copy.noSubject
4941
+ })
4942
+ })
4943
+ ]
4944
+ }),
4945
+ text(mail.reply_to_message_id) ? /* @__PURE__ */ jsx("p", {
4946
+ className: "text-xs text-neutral-500",
4947
+ children: copy.replyInThread
4948
+ }) : null,
4949
+ /* @__PURE__ */ jsx("div", {
4950
+ className: "rounded-md border border-neutral-200 bg-neutral-50 px-3 py-2",
4951
+ children: /* @__PURE__ */ jsx(CollapsibleBody, {
4952
+ body: text(mail.body),
4953
+ copy
4954
+ })
4955
+ })
4956
+ ]
4957
+ });
4958
+ }
4959
+ function formatRange(start, end, allDay, locale, copy) {
4960
+ const from = parseDate(text(start));
4961
+ if (!from) return null;
4962
+ const day = dateFormatter(locale, {
4963
+ weekday: "short",
4964
+ day: "numeric",
4965
+ month: "short"
4966
+ }).format(from);
4967
+ if (allDay) return `${day} · ${copy.allDay}`;
4968
+ const time = dateFormatter(locale, {
4969
+ hour: "2-digit",
4970
+ minute: "2-digit"
4971
+ });
4972
+ const to = parseDate(text(end));
4973
+ return to ? `${day} · ${time.format(from)} – ${time.format(to)}` : `${day} · ${time.format(from)}`;
4974
+ }
4975
+ /** Old value struck through next to the new one; only the new one if unknown. */
4976
+ function Change({ before, after }) {
4977
+ if (before === null || before === void 0 || before === after) return /* @__PURE__ */ jsx(Fragment, { children: after });
4978
+ return /* @__PURE__ */ jsxs("span", {
4979
+ className: "flex flex-wrap items-baseline gap-x-2",
4980
+ children: [
4981
+ /* @__PURE__ */ jsx("span", {
4982
+ className: "text-neutral-500 line-through",
4983
+ children: before
4984
+ }),
4985
+ /* @__PURE__ */ jsx("span", {
4986
+ "aria-hidden": "true",
4987
+ children: "→"
4988
+ }),
4989
+ /* @__PURE__ */ jsx("span", { children: after })
4990
+ ]
4991
+ });
4992
+ }
4993
+ function PendingEventView({ operation, pending, locale, copy }) {
4994
+ const action = pending.action;
4995
+ const current = asRecord(pending.current);
4996
+ const has = (key) => action[key] !== void 0 && action[key] !== null;
4997
+ if (operation === "delete_event") return /* @__PURE__ */ jsxs("div", {
4998
+ className: "space-y-1 px-3 py-3",
4999
+ children: [
5000
+ /* @__PURE__ */ jsx("p", {
5001
+ className: "text-xs font-medium uppercase tracking-wide text-rose-700",
5002
+ children: copy.deleteEvent
5003
+ }),
5004
+ /* @__PURE__ */ jsx("p", {
5005
+ className: "text-sm font-medium text-neutral-900 line-through",
5006
+ children: text(current?.title) ?? text(action.event_id) ?? copy.noSubject
5007
+ }),
5008
+ current ? /* @__PURE__ */ jsx("p", {
5009
+ className: "text-xs text-neutral-500",
5010
+ children: formatRange(current.start, current.end, Boolean(current.all_day), locale, copy)
5011
+ }) : null,
5012
+ (current?.attendees?.length ?? 0) > 0 ? /* @__PURE__ */ jsx("p", {
5013
+ className: "pt-1 text-xs text-neutral-600",
5014
+ children: copy.attendeesNotified
5015
+ }) : null
5016
+ ]
5017
+ });
5018
+ const isUpdate = operation === "update_event";
5019
+ const before = (key) => isUpdate && current ? current[key] : null;
5020
+ const attendees = strings(action.attendees);
5021
+ const timesChanged = has("start") || has("end");
5022
+ const newWhen = formatRange(action.start ?? current?.start, action.end ?? current?.end, Boolean(current?.all_day) && !timesChanged, locale, copy);
5023
+ const oldWhen = isUpdate && current && timesChanged ? formatRange(current.start, current.end, Boolean(current.all_day), locale, copy) : null;
5024
+ return /* @__PURE__ */ jsxs("div", {
5025
+ className: "space-y-2 px-3 py-3",
5026
+ children: [
5027
+ /* @__PURE__ */ jsx("p", {
5028
+ className: "text-xs font-medium uppercase tracking-wide text-neutral-500",
5029
+ children: isUpdate ? copy.eventChange : copy.newEvent
5030
+ }),
5031
+ /* @__PURE__ */ jsxs("dl", {
5032
+ className: "space-y-1.5",
5033
+ children: [
5034
+ has("title") || !isUpdate ? /* @__PURE__ */ jsx(Field, {
5035
+ label: copy.title,
5036
+ children: /* @__PURE__ */ jsx("span", {
5037
+ className: "font-medium",
5038
+ children: /* @__PURE__ */ jsx(Change, {
5039
+ before: text(before("title")),
5040
+ after: text(action.title) ?? copy.noSubject
5041
+ })
5042
+ })
5043
+ }) : current ? /* @__PURE__ */ jsx(Field, {
5044
+ label: copy.title,
5045
+ children: /* @__PURE__ */ jsx("span", {
5046
+ className: "font-medium",
5047
+ children: text(current.title)
5048
+ })
5049
+ }) : null,
5050
+ newWhen && (timesChanged || !isUpdate) ? /* @__PURE__ */ jsx(Field, {
5051
+ label: copy.when,
5052
+ children: /* @__PURE__ */ jsx(Change, {
5053
+ before: oldWhen,
5054
+ after: newWhen
5055
+ })
5056
+ }) : null,
5057
+ has("location") ? /* @__PURE__ */ jsx(Field, {
5058
+ label: copy.location,
5059
+ children: /* @__PURE__ */ jsx(Change, {
5060
+ before: text(before("location")),
5061
+ after: text(action.location)
5062
+ })
5063
+ }) : null,
5064
+ has("attendees") ? /* @__PURE__ */ jsx(Field, {
5065
+ label: copy.attendees,
5066
+ children: /* @__PURE__ */ jsx(Change, {
5067
+ before: strings(before("attendees")).join(", ") || null,
5068
+ after: attendees.join(", ") || "—"
5069
+ })
5070
+ }) : null,
5071
+ has("description") ? /* @__PURE__ */ jsx(Field, {
5072
+ label: copy.description,
5073
+ children: /* @__PURE__ */ jsx("span", {
5074
+ className: "whitespace-pre-wrap",
5075
+ children: text(action.description)
5076
+ })
5077
+ }) : null
5078
+ ]
5079
+ }),
5080
+ attendees.length > 0 ? /* @__PURE__ */ jsx("p", {
5081
+ className: "text-xs text-neutral-600",
5082
+ children: copy.attendeesNotified
5083
+ }) : null
5084
+ ]
5085
+ });
5086
+ }
5087
+ function PendingBadge({ copy }) {
5088
+ return /* @__PURE__ */ jsxs("span", {
5089
+ 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",
5090
+ children: [/* @__PURE__ */ jsx(Clock, {
5091
+ className: "h-3 w-3",
5092
+ "aria-hidden": "true"
5093
+ }), copy.awaitingConfirmation]
5094
+ });
5095
+ }
5096
+ function PendingFooter({ copy }) {
5097
+ return /* @__PURE__ */ jsx("p", {
5098
+ className: "border-t border-amber-100 bg-amber-50/60 px-3 py-2 text-xs text-neutral-700",
5099
+ children: copy.confirmHint
5100
+ });
5101
+ }
5102
+ function headerCount(view, copy) {
5103
+ if (view.kind === "mail-list") return count(copy, view.messages.length, copy.emailCountOne, copy.emailCountOther);
5104
+ if (view.kind === "events") return count(copy, view.events.length, copy.eventCountOne, copy.eventCountOther);
5105
+ return null;
5106
+ }
5107
+ function ToolResultPersonalConnectorCard({ part, locale, className }) {
5108
+ const view = getView(part);
5109
+ if (!view) return null;
5110
+ const copy = getPersonalConnectorCopy(locale);
5111
+ const connector = getConnector(part);
5112
+ const Icon = isCalendar(connector) ? CalendarDays : Mail;
5113
+ const total = headerCount(view, copy);
5114
+ const isPending = view.kind === "pending-mail" || view.kind === "pending-event";
5115
+ return /* @__PURE__ */ jsxs("section", {
5116
+ className: joinClasses("plai-tool-result-personal-connector-card overflow-hidden rounded-lg border border-neutral-200 bg-white text-neutral-950", className),
5117
+ "data-tool-call-id": part.id,
5118
+ "data-tool-call-state": part.state,
5119
+ "data-connector-action": view.kind,
5120
+ children: [
5121
+ /* @__PURE__ */ jsxs("header", {
5122
+ className: "flex items-center gap-2 border-b border-neutral-200 px-3 py-2 text-xs text-neutral-600",
5123
+ children: [
5124
+ /* @__PURE__ */ jsx(Icon, {
5125
+ className: "h-4 w-4 shrink-0 text-neutral-700",
5126
+ "aria-hidden": "true"
5127
+ }),
5128
+ /* @__PURE__ */ jsx("span", {
5129
+ className: "shrink-0 font-medium text-neutral-900",
5130
+ children: connector?.label
5131
+ }),
5132
+ connector?.account_email ? /* @__PURE__ */ jsx("span", {
5133
+ className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
5134
+ children: connector.account_email
5135
+ }) : null,
5136
+ isPending ? /* @__PURE__ */ jsx(PendingBadge, { copy }) : total ? /* @__PURE__ */ jsx("span", {
5137
+ className: "ml-auto shrink-0",
5138
+ children: total
5139
+ }) : null
5140
+ ]
5141
+ }),
5142
+ view.kind === "mail-list" ? /* @__PURE__ */ jsx(MailList, {
5143
+ messages: view.messages,
5144
+ locale,
5145
+ copy
5146
+ }) : view.kind === "mail" ? /* @__PURE__ */ jsx(MailMessageView, {
5147
+ message: view.message,
5148
+ connector,
5149
+ locale,
5150
+ copy
5151
+ }) : view.kind === "events" ? /* @__PURE__ */ jsx(Agenda, {
5152
+ events: view.events,
5153
+ locale,
5154
+ copy
5155
+ }) : view.kind === "pending-mail" ? /* @__PURE__ */ jsx(PendingMailView, {
5156
+ pending: view.pending,
5157
+ copy
5158
+ }) : view.kind === "pending-event" ? /* @__PURE__ */ jsx(PendingEventView, {
5159
+ operation: view.operation,
5160
+ pending: view.pending,
5161
+ locale,
5162
+ copy
5163
+ }) : /* @__PURE__ */ jsx(DraftView, {
5164
+ view,
5165
+ copy
5166
+ }),
5167
+ isPending ? /* @__PURE__ */ jsx(PendingFooter, { copy }) : null
5168
+ ]
5169
+ });
5170
+ }
5171
+ const DONE_LABELS = {
5172
+ send: "emailSent",
5173
+ create_event: "eventCreated",
5174
+ update_event: "eventUpdated",
5175
+ delete_event: "eventDeleted"
5176
+ };
5177
+ function getConfirmedActions(part) {
5178
+ const actions = asRecord(part.metadata)?.actions;
5179
+ return Array.isArray(actions) ? actions.filter((action) => typeof asRecord(action)?.action_id === "string") : [];
5180
+ }
5181
+ /** Whether the confirmation result can be shown as a list of outcomes. */
5182
+ function hasToolConfirmationView(part) {
5183
+ return part.state !== "pending" && getConfirmedActions(part).length > 0;
5184
+ }
5185
+ function ConfirmedActionRow({ action, copy }) {
5186
+ const metadata = asRecord(action.metadata);
5187
+ const connector = asRecord(metadata?.connector);
5188
+ const operation = typeof metadata?.action === "string" ? metadata.action : "";
5189
+ const doneKey = DONE_LABELS[operation];
5190
+ const failed = action.status === "failed";
5191
+ const label = doneKey ? copy[doneKey] : fillCopy(copy.actionDone, { tool: action.tool_name });
5192
+ const link = text(asRecord(metadata?.result)?.link);
5193
+ return /* @__PURE__ */ jsxs("li", {
5194
+ className: "flex items-start gap-2 px-3 py-2",
5195
+ children: [
5196
+ failed ? /* @__PURE__ */ jsx(XCircle, {
5197
+ className: "mt-0.5 h-4 w-4 shrink-0 text-rose-600",
5198
+ "aria-hidden": "true"
5199
+ }) : /* @__PURE__ */ jsx(CheckCircle2, {
5200
+ className: "mt-0.5 h-4 w-4 shrink-0 text-emerald-600",
5201
+ "aria-hidden": "true"
5202
+ }),
5203
+ /* @__PURE__ */ jsxs("div", {
5204
+ className: "min-w-0 flex-1 space-y-0.5",
5205
+ children: [
5206
+ /* @__PURE__ */ jsx("p", {
5207
+ className: "text-sm font-medium text-neutral-950",
5208
+ children: failed ? `${copy.actionFailed}: ${label}` : label
5209
+ }),
5210
+ connector ? /* @__PURE__ */ jsxs("div", {
5211
+ className: "flex items-center gap-2 truncate text-xs text-neutral-500",
5212
+ children: [connector.label, connector.account_email ? /* @__PURE__ */ jsx("span", {
5213
+ className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
5214
+ children: connector.account_email
5215
+ }) : null]
5216
+ }) : null,
5217
+ failed && text(action.error) ? /* @__PURE__ */ jsx("p", {
5218
+ className: "line-clamp-2 text-xs text-rose-700",
5219
+ children: action.error
5220
+ }) : null
5221
+ ]
5222
+ }),
5223
+ !failed && link ? /* @__PURE__ */ jsx(ExternalAnchor, {
5224
+ href: link,
5225
+ className: "shrink-0",
5226
+ children: operation === "send" ? copy.openEmail : copy.openEvent
5227
+ }) : null
5228
+ ]
5229
+ });
5230
+ }
5231
+ function ToolResultToolConfirmationCard({ part, locale, className }) {
5232
+ const actions = getConfirmedActions(part);
5233
+ if (actions.length === 0) return null;
5234
+ const copy = getPersonalConnectorCopy(locale);
5235
+ return /* @__PURE__ */ jsx("ul", {
5236
+ 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),
5237
+ "data-tool-call-id": part.id,
5238
+ "data-tool-call-state": part.state,
5239
+ children: actions.map((action) => /* @__PURE__ */ jsx(ConfirmedActionRow, {
5240
+ action,
5241
+ copy
5242
+ }, action.action_id))
5243
+ });
5244
+ }
5245
+ function getPendingConfirmation(part) {
5246
+ const pending = asRecord(asRecord(part.metadata)?.pending_confirmation);
5247
+ return pending && asRecord(pending.action) ? pending : null;
5248
+ }
5249
+ function formatValue(value) {
5250
+ if (typeof value === "string") return value;
5251
+ return JSON.stringify(value, null, 2);
5252
+ }
5253
+ /** Generic preview of a held tool call: its name and the exact arguments. */
5254
+ function ToolResultPendingConfirmationCard({ part, locale, className }) {
5255
+ const pending = getPendingConfirmation(part);
5256
+ if (!pending) return null;
5257
+ const copy = getPersonalConnectorCopy(locale);
5258
+ const entries = Object.entries(pending.action).filter(([key, value]) => key !== "operation" && value !== null && value !== void 0);
5259
+ return /* @__PURE__ */ jsxs("section", {
5260
+ className: joinClasses("plai-tool-result-pending-confirmation-card overflow-hidden rounded-lg border border-neutral-200 bg-white text-neutral-950", className),
5261
+ "data-tool-call-id": part.id,
5262
+ "data-tool-call-state": part.state,
5263
+ children: [
5264
+ /* @__PURE__ */ jsxs("header", {
5265
+ className: "flex items-center gap-2 border-b border-neutral-200 px-3 py-2 text-xs text-neutral-600",
5266
+ children: [/* @__PURE__ */ jsx("span", {
5267
+ className: "truncate font-mono font-medium text-neutral-900",
5268
+ children: part.name
5269
+ }), /* @__PURE__ */ jsx(PendingBadge, { copy })]
5270
+ }),
5271
+ entries.length > 0 ? /* @__PURE__ */ jsx("dl", {
5272
+ className: "space-y-1.5 px-3 py-3",
5273
+ children: entries.map(([key, value]) => /* @__PURE__ */ jsx(Field, {
5274
+ label: key,
5275
+ children: /* @__PURE__ */ jsx("span", {
5276
+ className: "whitespace-pre-wrap font-mono text-xs",
5277
+ children: formatValue(value)
5278
+ })
5279
+ }, key))
5280
+ }) : null,
5281
+ /* @__PURE__ */ jsx(PendingFooter, { copy })
5282
+ ]
5283
+ });
5284
+ }
5285
+
3973
5286
  //#endregion
3974
5287
  //#region src/components/tool-result-workflow-dispatch-card.tsx
3975
5288
  function parseResult(value) {
@@ -4020,7 +5333,7 @@ function ToolResultWorkflowDispatchCard({ part, className, locale }) {
4020
5333
  children: copy.workflow
4021
5334
  }),
4022
5335
  /* @__PURE__ */ jsx("span", {
4023
- className: "min-w-0 truncate text-neutral-600",
5336
+ className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
4024
5337
  children: workflowName
4025
5338
  }),
4026
5339
  /* @__PURE__ */ jsxs("span", {
@@ -4111,7 +5424,9 @@ const TOOL_USE_ACTIONS = {
4111
5424
  mcp_tool: "request",
4112
5425
  office_documents: "documents",
4113
5426
  perplexity: "web",
5427
+ personal_connector: "tool",
4114
5428
  structured_datasource: "query",
5429
+ tool_confirmation: "tool",
4115
5430
  workflow_dispatch: "workflow",
4116
5431
  unknown: "tool"
4117
5432
  };
@@ -4227,7 +5542,35 @@ const TOOL_USE_TRANSLATIONS = {
4227
5542
  workflow: "Executando o fluxo {{toolName}}"
4228
5543
  }
4229
5544
  };
5545
+ const PERSONAL_CONNECTOR_SERVICES = {
5546
+ gmail: "Gmail",
5547
+ google_calendar: "Google Calendar",
5548
+ outlook_mail: "Outlook Mail",
5549
+ outlook_calendar: "Outlook Calendar"
5550
+ };
5551
+ const PERSONAL_CONNECTOR_ACTIONS = {
5552
+ search: "searchingMail",
5553
+ read: "readingMail",
5554
+ list_events: "checkingCalendar",
5555
+ create_draft: "savingDraft",
5556
+ send: "preparingMail",
5557
+ create_event: "preparingEvent",
5558
+ update_event: "preparingEvent",
5559
+ delete_event: "preparingEvent"
5560
+ };
5561
+ const PERSONAL_CONNECTOR_TOOL_NAME = /^(gmail|google_calendar|outlook_mail|outlook_calendar)_(.+?)(?:_\d+)?$/;
5562
+ function getPersonalConnectorLabel(name, locale) {
5563
+ const match = PERSONAL_CONNECTOR_TOOL_NAME.exec(name);
5564
+ const key = match ? PERSONAL_CONNECTOR_ACTIONS[match[2]] : void 0;
5565
+ if (!match || !key) return null;
5566
+ return fillCopy(getPersonalConnectorCopy(locale)[key], { service: PERSONAL_CONNECTOR_SERVICES[match[1]] });
5567
+ }
4230
5568
  function getToolUseLabel(part, locale) {
5569
+ if (part.toolType === "personal_connector") {
5570
+ const label = getPersonalConnectorLabel(part.name, locale);
5571
+ if (label) return label;
5572
+ }
5573
+ if (part.toolType === "tool_confirmation") return getPersonalConnectorCopy(locale).runningConfirmed;
4231
5574
  const action = part.toolType ? TOOL_USE_ACTIONS[part.toolType] ?? "tool" : "tool";
4232
5575
  return TOOL_USE_TRANSLATIONS[getSupportedToolLocale(locale)][action].replaceAll("{{toolName}}", part.name);
4233
5576
  }
@@ -4281,11 +5624,21 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
4281
5624
  locale,
4282
5625
  className
4283
5626
  });
5627
+ if (part.toolType === "tool_confirmation" && hasToolConfirmationView(part)) return /* @__PURE__ */ jsx(ToolResultToolConfirmationCard, {
5628
+ part,
5629
+ locale,
5630
+ className
5631
+ });
4284
5632
  if (part.state === "error") return /* @__PURE__ */ jsx(ToolError, {
4285
5633
  part,
4286
5634
  locale,
4287
5635
  className
4288
5636
  });
5637
+ if (part.toolType !== "personal_connector" && getPendingConfirmation(part)) return /* @__PURE__ */ jsx(ToolResultPendingConfirmationCard, {
5638
+ part,
5639
+ locale,
5640
+ className
5641
+ });
4289
5642
  const officeMediaFiles = getOfficeDocumentMediaFiles(part);
4290
5643
  const datasourceResources = getDatasourceResources$1(part);
4291
5644
  if (part.toolType === "email_send") return /* @__PURE__ */ jsx(ToolResultEmailSendCard, {
@@ -4324,6 +5677,11 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
4324
5677
  locale,
4325
5678
  className
4326
5679
  });
5680
+ if (part.toolType === "personal_connector" && hasPersonalConnectorView(part)) return /* @__PURE__ */ jsx(ToolResultPersonalConnectorCard, {
5681
+ part,
5682
+ locale,
5683
+ className
5684
+ });
4327
5685
  if (part.toolType === "workflow_dispatch") return /* @__PURE__ */ jsx(ToolResultWorkflowDispatchCard, {
4328
5686
  part,
4329
5687
  locale,
@@ -4352,7 +5710,7 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
4352
5710
  className: "text-sm font-semibold text-slate-900",
4353
5711
  children: part.name
4354
5712
  }), /* @__PURE__ */ jsx("span", {
4355
- className: "rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-xs font-medium text-emerald-800",
5713
+ className: "rounded-full border uppercase border-emerald-200 bg-emerald-50 px-2 py-0.5 text-xs text-emerald-800",
4356
5714
  children: copy.completed
4357
5715
  })]
4358
5716
  }),
@@ -4828,14 +6186,14 @@ function Message(props) {
4828
6186
 
4829
6187
  //#endregion
4830
6188
  //#region src/components/clipboard.tsx
4831
- async function writeTextToClipboard(text$1) {
6189
+ async function writeTextToClipboard(text$2) {
4832
6190
  if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
4833
- await navigator.clipboard.writeText(text$1);
6191
+ await navigator.clipboard.writeText(text$2);
4834
6192
  return;
4835
6193
  }
4836
6194
  if (typeof document === "undefined") throw new Error("Clipboard is not available in this environment.");
4837
6195
  const textarea = document.createElement("textarea");
4838
- textarea.value = text$1;
6196
+ textarea.value = text$2;
4839
6197
  textarea.setAttribute("readonly", "");
4840
6198
  textarea.style.position = "fixed";
4841
6199
  textarea.style.opacity = "0";
@@ -4847,7 +6205,7 @@ async function writeTextToClipboard(text$1) {
4847
6205
  textarea.remove();
4848
6206
  }
4849
6207
  }
4850
- function Clipboard({ text: text$1, onCopy, copiedDuration = 2e3, copyLabel, copiedLabel, locale, children, className, disabled, onClick, type = "button",...props }) {
6208
+ function Clipboard({ text: text$2, onCopy, copiedDuration = 2e3, copyLabel, copiedLabel, locale, children, className, disabled, onClick, type = "button",...props }) {
4851
6209
  const copy = getUiCopy(locale);
4852
6210
  const resolvedCopyLabel = copyLabel ?? copy.copy;
4853
6211
  const resolvedCopiedLabel = copiedLabel ?? copy.copied;
@@ -4862,12 +6220,12 @@ function Clipboard({ text: text$1, onCopy, copiedDuration = 2e3, copyLabel, copi
4862
6220
  if (event.defaultPrevented || disabled || isCopying) return;
4863
6221
  setIsCopying(true);
4864
6222
  try {
4865
- await writeTextToClipboard(text$1);
6223
+ await writeTextToClipboard(text$2);
4866
6224
  setIsCopied(true);
4867
6225
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
4868
6226
  timeoutRef.current = setTimeout(() => setIsCopied(false), copiedDuration);
4869
6227
  try {
4870
- await onCopy?.(text$1);
6228
+ await onCopy?.(text$2);
4871
6229
  } catch {}
4872
6230
  } catch {
4873
6231
  setIsCopied(false);
@@ -5087,10 +6445,10 @@ function PromptForm({ value, onValueChange, onSubmit, status = "ready", locale,
5087
6445
  if (!canSubmit) return;
5088
6446
  setIsSubmitting(true);
5089
6447
  try {
5090
- const text$1 = value.trim();
6448
+ const text$2 = value.trim();
5091
6449
  const selectedFiles = [...files];
5092
6450
  await onSubmit({
5093
- text: text$1,
6451
+ text: text$2,
5094
6452
  ...enabledTools ? { enabledTools } : {},
5095
6453
  files: selectedFiles
5096
6454
  });
@@ -5317,10 +6675,10 @@ function useSpeechToText({ transcribe, onTranscriptionComplete, onTranscriptionE
5317
6675
  if (operationIdRef.current !== operationId) return null;
5318
6676
  const transcription = await optionsRef.current.transcribe(audio, abortController.signal);
5319
6677
  if (operationIdRef.current !== operationId) return null;
5320
- const text$1 = transcription.trim();
5321
- if (!text$1) return null;
5322
- optionsRef.current.onTranscriptionComplete?.(text$1);
5323
- return text$1;
6678
+ const text$2 = transcription.trim();
6679
+ if (!text$2) return null;
6680
+ optionsRef.current.onTranscriptionComplete?.(text$2);
6681
+ return text$2;
5324
6682
  } catch (error) {
5325
6683
  if (operationIdRef.current !== operationId || abortController.signal.aborted || isAbortError(error)) return null;
5326
6684
  optionsRef.current.onTranscriptionError?.(normalizeError(error, "Transcription failed"));
@@ -5424,5 +6782,5 @@ async function dummyTranscribeAudio(_audio, signal) {
5424
6782
  }
5425
6783
 
5426
6784
  //#endregion
5427
- 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, useChat, useChatRegistryBusy, useOwnedChatRegistry, useRegistryChat, useSpeechToText, useStreamCoordinator };
6785
+ 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, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, isAllowedPromptFormFile, partitionPromptFormFiles, useChat, useChatRegistryBusy, useOwnedChatRegistry, useRegistryChat, useSpeechToText, useStreamCoordinator };
5428
6786
  //# sourceMappingURL=index.js.map