@plaisolutions/react 0.20.0 → 0.22.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,7 +1,7 @@
1
1
  import { ArrowUpRight, Bot, Brain, CalendarDays, Check, CheckCircle2, ChevronDown, ChevronUp, CircleAlert, CircleX, Clock, Copy, Database, Download, File, FileText, Globe, LoaderCircle, Mail, MessageSquare, Paperclip as Paperclip$1, Plug, RotateCcw, ThumbsDown, ThumbsUp, Video, Workflow, X as X$1, 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
- import { HttpStatusError, isHiddenMessage, toolConfirmationAt } from "@plaisolutions/client";
4
+ import { HttpStatusError, ToolDecisionRejectedError, ToolSubmissionConflictError, isHiddenMessage, toolConfirmationAt } from "@plaisolutions/client";
5
5
 
6
6
  //#region src/components/internal/join-classes.ts
7
7
  function joinClasses(...classes) {
@@ -4167,7 +4167,35 @@ const ENGLISH = {
4167
4167
  statusUnknown: "Outcome unknown: check before trying again",
4168
4168
  statusNotFound: "Not available in this conversation",
4169
4169
  toolUnavailable: "The tool for this action isn’t available right now",
4170
- decisionError: "Your decision couldn’t be sent. Try again."
4170
+ decisionError: "Your decision couldn’t be sent. Try again.",
4171
+ edit: "Edit",
4172
+ saveAndSend: "Save and send",
4173
+ saveAndConfirm: "Save and confirm",
4174
+ discardEdit: "Discard changes",
4175
+ fieldBody: "Message",
4176
+ fieldStart: "Starts",
4177
+ fieldEnd: "Ends",
4178
+ addressesHint: "Separate addresses with commas",
4179
+ timeZoneNote: "Time zone: {{zone}}",
4180
+ errorRequired: "This field can’t be empty",
4181
+ errorNoRecipients: "Add at least one recipient",
4182
+ errorInvalidAddress: "Enter valid email addresses",
4183
+ errorInvalidDateTime: "Enter a valid date and time",
4184
+ errorAmbiguousTime: "This time doesn’t exist or happens twice in {{zone}}. Pick another time.",
4185
+ errorEndBeforeStart: "The end must be after the start",
4186
+ editNoLongerApplies: "Your changes no longer apply to this action. Review them and try again.",
4187
+ editedLabel: "Edited",
4188
+ seeNewerVersion: "See the newer version",
4189
+ invalidatedConfigurationChanged: "The tool, account or its settings changed after this was prepared. Ask again in the chat.",
4190
+ invalidatedNoSnapshot: "This action was prepared by an older version and can’t run. Ask again in the chat.",
4191
+ invalidatedResourceChanged: "The event changed after this was prepared, so nothing was modified. Ask again in the chat.",
4192
+ unknownOutcome: "The provider didn’t confirm whether it happened. Check your sent mail or calendar before trying again.",
4193
+ unknownInterrupted: "The action was interrupted and it isn’t known whether it happened. Check your account before trying again.",
4194
+ applyingNow: "This is already being applied…",
4195
+ errorPlainText: "Use plain text, without HTML",
4196
+ errorOffsetMismatch: "The UTC offset doesn’t match the time zone of the event",
4197
+ errorNotEditable: "This field can’t be edited",
4198
+ errorInvalidValue: "This value isn’t valid"
4171
4199
  };
4172
4200
  const COPY = {
4173
4201
  en: {},
@@ -4241,7 +4269,35 @@ const COPY = {
4241
4269
  statusUnknown: "Resultado desconocido: compruébalo antes de repetirlo",
4242
4270
  statusNotFound: "No disponible en esta conversación",
4243
4271
  toolUnavailable: "La herramienta de esta acción no está disponible ahora",
4244
- decisionError: "No se pudo enviar tu decisión. Inténtalo de nuevo."
4272
+ decisionError: "No se pudo enviar tu decisión. Inténtalo de nuevo.",
4273
+ edit: "Editar",
4274
+ saveAndSend: "Guardar y enviar",
4275
+ saveAndConfirm: "Guardar y confirmar",
4276
+ discardEdit: "Descartar cambios",
4277
+ fieldBody: "Mensaje",
4278
+ fieldStart: "Empieza",
4279
+ fieldEnd: "Termina",
4280
+ addressesHint: "Separa las direcciones con comas",
4281
+ timeZoneNote: "Zona horaria: {{zone}}",
4282
+ errorRequired: "Este campo no puede estar vacío",
4283
+ errorNoRecipients: "Añade al menos un destinatario",
4284
+ errorInvalidAddress: "Introduce direcciones de correo válidas",
4285
+ errorInvalidDateTime: "Introduce una fecha y hora válidas",
4286
+ errorAmbiguousTime: "Esta hora no existe o se repite en {{zone}}. Elige otra hora.",
4287
+ errorEndBeforeStart: "El final debe ser posterior al inicio",
4288
+ editNoLongerApplies: "Tus cambios ya no se aplican a esta acción. Revísalos e inténtalo de nuevo.",
4289
+ editedLabel: "Editada",
4290
+ seeNewerVersion: "Ver la versión más reciente",
4291
+ invalidatedConfigurationChanged: "La herramienta, la cuenta o su configuración cambiaron después de preparar esto. Pídelo de nuevo en el chat.",
4292
+ invalidatedNoSnapshot: "Esta acción la preparó una versión anterior y no se puede ejecutar. Pídelo de nuevo en el chat.",
4293
+ invalidatedResourceChanged: "El evento cambió después de preparar esto, así que no se modificó nada. Pídelo de nuevo en el chat.",
4294
+ unknownOutcome: "El proveedor no confirmó si llegó a ocurrir. Comprueba tus enviados o tu calendario antes de intentarlo de nuevo.",
4295
+ unknownInterrupted: "La acción se interrumpió y no se sabe si llegó a ocurrir. Comprueba tu cuenta antes de intentarlo de nuevo.",
4296
+ applyingNow: "Ya se está aplicando…",
4297
+ errorPlainText: "Usa texto sin formato, sin HTML",
4298
+ errorOffsetMismatch: "El desfase UTC no coincide con la zona horaria del evento",
4299
+ errorNotEditable: "Este campo no se puede editar",
4300
+ errorInvalidValue: "Este valor no es válido"
4245
4301
  },
4246
4302
  ca: {
4247
4303
  searchingMail: "Cercant a {{service}}",
@@ -4313,7 +4369,35 @@ const COPY = {
4313
4369
  statusUnknown: "Resultat desconegut: comprova-ho abans de repetir-ho",
4314
4370
  statusNotFound: "No disponible en aquesta conversa",
4315
4371
  toolUnavailable: "L’eina d’aquesta acció no està disponible ara",
4316
- decisionError: "No s’ha pogut enviar la teva decisió. Torna-ho a provar."
4372
+ decisionError: "No s’ha pogut enviar la teva decisió. Torna-ho a provar.",
4373
+ edit: "Edita",
4374
+ saveAndSend: "Desa i envia",
4375
+ saveAndConfirm: "Desa i confirma",
4376
+ discardEdit: "Descarta els canvis",
4377
+ fieldBody: "Missatge",
4378
+ fieldStart: "Comença",
4379
+ fieldEnd: "Acaba",
4380
+ addressesHint: "Separa les adreces amb comes",
4381
+ timeZoneNote: "Zona horària: {{zone}}",
4382
+ errorRequired: "Aquest camp no pot estar buit",
4383
+ errorNoRecipients: "Afegeix com a mínim un destinatari",
4384
+ errorInvalidAddress: "Introdueix adreces de correu vàlides",
4385
+ errorInvalidDateTime: "Introdueix una data i hora vàlides",
4386
+ errorAmbiguousTime: "Aquesta hora no existeix o es repeteix a {{zone}}. Tria una altra hora.",
4387
+ errorEndBeforeStart: "El final ha de ser posterior a l’inici",
4388
+ editNoLongerApplies: "Els teus canvis ja no s’apliquen a aquesta acció. Revisa’ls i torna-ho a provar.",
4389
+ editedLabel: "Editada",
4390
+ seeNewerVersion: "Mostra la versió més recent",
4391
+ invalidatedConfigurationChanged: "L’eina, el compte o la seva configuració han canviat després de preparar això. Torna-ho a demanar al xat.",
4392
+ invalidatedNoSnapshot: "Aquesta acció la va preparar una versió anterior i no es pot executar. Torna-ho a demanar al xat.",
4393
+ invalidatedResourceChanged: "L’esdeveniment ha canviat després de preparar això, així que no s’ha modificat res. Torna-ho a demanar al xat.",
4394
+ unknownOutcome: "El proveïdor no ha confirmat si va arribar a passar. Comprova els enviats o el calendari abans de tornar-ho a provar.",
4395
+ unknownInterrupted: "L’acció s’ha interromput i no se sap si va arribar a passar. Comprova el teu compte abans de tornar-ho a provar.",
4396
+ applyingNow: "Ja s’està aplicant…",
4397
+ errorPlainText: "Utilitza text sense format, sense HTML",
4398
+ errorOffsetMismatch: "El desfasament UTC no coincideix amb la zona horària de l’esdeveniment",
4399
+ errorNotEditable: "Aquest camp no es pot editar",
4400
+ errorInvalidValue: "Aquest valor no és vàlid"
4317
4401
  },
4318
4402
  fr: {
4319
4403
  searchingMail: "Recherche dans {{service}}",
@@ -4385,7 +4469,35 @@ const COPY = {
4385
4469
  statusUnknown: "Résultat inconnu : vérifiez avant de réessayer",
4386
4470
  statusNotFound: "Indisponible dans cette conversation",
4387
4471
  toolUnavailable: "L’outil de cette action n’est pas disponible pour le moment",
4388
- decisionError: "Impossible d’envoyer votre décision. Réessayez."
4472
+ decisionError: "Impossible d’envoyer votre décision. Réessayez.",
4473
+ edit: "Modifier",
4474
+ saveAndSend: "Enregistrer et envoyer",
4475
+ saveAndConfirm: "Enregistrer et confirmer",
4476
+ discardEdit: "Annuler les modifications",
4477
+ fieldBody: "Message",
4478
+ fieldStart: "Début",
4479
+ fieldEnd: "Fin",
4480
+ addressesHint: "Séparez les adresses par des virgules",
4481
+ timeZoneNote: "Fuseau horaire : {{zone}}",
4482
+ errorRequired: "Ce champ ne peut pas être vide",
4483
+ errorNoRecipients: "Ajoutez au moins un destinataire",
4484
+ errorInvalidAddress: "Saisissez des adresses e-mail valides",
4485
+ errorInvalidDateTime: "Saisissez une date et une heure valides",
4486
+ errorAmbiguousTime: "Cette heure n’existe pas ou se répète en {{zone}}. Choisissez une autre heure.",
4487
+ errorEndBeforeStart: "La fin doit être postérieure au début",
4488
+ editNoLongerApplies: "Vos modifications ne s’appliquent plus à cette action. Vérifiez-les et réessayez.",
4489
+ editedLabel: "Modifiée",
4490
+ seeNewerVersion: "Voir la version la plus récente",
4491
+ invalidatedConfigurationChanged: "L’outil, le compte ou sa configuration ont changé après la préparation. Redemandez-le dans le chat.",
4492
+ invalidatedNoSnapshot: "Cette action a été préparée par une version antérieure et ne peut pas s’exécuter. Redemandez-la dans le chat.",
4493
+ invalidatedResourceChanged: "L’événement a changé après la préparation, donc rien n’a été modifié. Redemandez-le dans le chat.",
4494
+ unknownOutcome: "Le fournisseur n’a pas confirmé si cela a eu lieu. Vérifiez vos envois ou votre agenda avant de réessayer.",
4495
+ unknownInterrupted: "L’action a été interrompue et on ne sait pas si elle a eu lieu. Vérifiez votre compte avant de réessayer.",
4496
+ applyingNow: "Déjà en cours d’application…",
4497
+ errorPlainText: "Utilisez du texte brut, sans HTML",
4498
+ errorOffsetMismatch: "Le décalage UTC ne correspond pas au fuseau horaire de l’événement",
4499
+ errorNotEditable: "Ce champ ne peut pas être modifié",
4500
+ errorInvalidValue: "Cette valeur n’est pas valide"
4389
4501
  },
4390
4502
  it: {
4391
4503
  searchingMail: "Ricerca in {{service}}",
@@ -4457,7 +4569,35 @@ const COPY = {
4457
4569
  statusUnknown: "Esito sconosciuto: verifica prima di riprovare",
4458
4570
  statusNotFound: "Non disponibile in questa conversazione",
4459
4571
  toolUnavailable: "Lo strumento di questa azione non è disponibile ora",
4460
- decisionError: "Impossibile inviare la tua decisione. Riprova."
4572
+ decisionError: "Impossibile inviare la tua decisione. Riprova.",
4573
+ edit: "Modifica",
4574
+ saveAndSend: "Salva e invia",
4575
+ saveAndConfirm: "Salva e conferma",
4576
+ discardEdit: "Annulla le modifiche",
4577
+ fieldBody: "Messaggio",
4578
+ fieldStart: "Inizio",
4579
+ fieldEnd: "Fine",
4580
+ addressesHint: "Separa gli indirizzi con virgole",
4581
+ timeZoneNote: "Fuso orario: {{zone}}",
4582
+ errorRequired: "Questo campo non può essere vuoto",
4583
+ errorNoRecipients: "Aggiungi almeno un destinatario",
4584
+ errorInvalidAddress: "Inserisci indirizzi e-mail validi",
4585
+ errorInvalidDateTime: "Inserisci una data e un’ora valide",
4586
+ errorAmbiguousTime: "Questo orario non esiste o si ripete in {{zone}}. Scegli un altro orario.",
4587
+ errorEndBeforeStart: "La fine deve essere successiva all’inizio",
4588
+ editNoLongerApplies: "Le tue modifiche non si applicano più a questa azione. Controllale e riprova.",
4589
+ editedLabel: "Modificata",
4590
+ seeNewerVersion: "Vedi la versione più recente",
4591
+ invalidatedConfigurationChanged: "Lo strumento, l’account o la sua configurazione sono cambiati dopo la preparazione. Chiedilo di nuovo nella chat.",
4592
+ invalidatedNoSnapshot: "Questa azione è stata preparata da una versione precedente e non può essere eseguita. Chiedilo di nuovo nella chat.",
4593
+ invalidatedResourceChanged: "L’evento è cambiato dopo la preparazione, quindi non è stato modificato nulla. Chiedilo di nuovo nella chat.",
4594
+ unknownOutcome: "Il provider non ha confermato se sia avvenuto. Controlla la posta inviata o il calendario prima di riprovare.",
4595
+ unknownInterrupted: "L’azione è stata interrotta e non si sa se sia avvenuta. Controlla il tuo account prima di riprovare.",
4596
+ applyingNow: "È già in corso di applicazione…",
4597
+ errorPlainText: "Usa testo semplice, senza HTML",
4598
+ errorOffsetMismatch: "Lo scostamento UTC non corrisponde al fuso orario dell’evento",
4599
+ errorNotEditable: "Questo campo non può essere modificato",
4600
+ errorInvalidValue: "Questo valore non è valido"
4461
4601
  },
4462
4602
  de: {
4463
4603
  searchingMail: "Suche in {{service}}",
@@ -4529,7 +4669,35 @@ const COPY = {
4529
4669
  statusUnknown: "Ergebnis unbekannt: vor dem Wiederholen prüfen",
4530
4670
  statusNotFound: "In dieser Unterhaltung nicht verfügbar",
4531
4671
  toolUnavailable: "Das Tool für diese Aktion ist gerade nicht verfügbar",
4532
- decisionError: "Deine Entscheidung konnte nicht gesendet werden. Versuche es erneut."
4672
+ decisionError: "Deine Entscheidung konnte nicht gesendet werden. Versuche es erneut.",
4673
+ edit: "Bearbeiten",
4674
+ saveAndSend: "Speichern und senden",
4675
+ saveAndConfirm: "Speichern und bestätigen",
4676
+ discardEdit: "Änderungen verwerfen",
4677
+ fieldBody: "Nachricht",
4678
+ fieldStart: "Beginn",
4679
+ fieldEnd: "Ende",
4680
+ addressesHint: "Adressen durch Kommas trennen",
4681
+ timeZoneNote: "Zeitzone: {{zone}}",
4682
+ errorRequired: "Dieses Feld darf nicht leer sein",
4683
+ errorNoRecipients: "Füge mindestens einen Empfänger hinzu",
4684
+ errorInvalidAddress: "Gib gültige E-Mail-Adressen ein",
4685
+ errorInvalidDateTime: "Gib ein gültiges Datum und eine gültige Uhrzeit ein",
4686
+ errorAmbiguousTime: "Diese Uhrzeit existiert in {{zone}} nicht oder kommt doppelt vor. Wähle eine andere Uhrzeit.",
4687
+ errorEndBeforeStart: "Das Ende muss nach dem Beginn liegen",
4688
+ editNoLongerApplies: "Deine Änderungen gelten für diese Aktion nicht mehr. Prüfe sie und versuche es erneut.",
4689
+ editedLabel: "Bearbeitet",
4690
+ seeNewerVersion: "Neuere Version ansehen",
4691
+ invalidatedConfigurationChanged: "Das Tool, das Konto oder dessen Konfiguration haben sich nach der Vorbereitung geändert. Frag im Chat erneut an.",
4692
+ invalidatedNoSnapshot: "Diese Aktion wurde von einer älteren Version vorbereitet und kann nicht ausgeführt werden. Frag im Chat erneut an.",
4693
+ invalidatedResourceChanged: "Der Termin hat sich nach der Vorbereitung geändert, daher wurde nichts verändert. Frag im Chat erneut an.",
4694
+ unknownOutcome: "Der Anbieter hat nicht bestätigt, ob es passiert ist. Prüfe deine gesendeten Mails oder deinen Kalender, bevor du es erneut versuchst.",
4695
+ unknownInterrupted: "Die Aktion wurde unterbrochen und es ist nicht bekannt, ob sie ausgeführt wurde. Prüfe dein Konto, bevor du es erneut versuchst.",
4696
+ applyingNow: "Wird bereits angewendet…",
4697
+ errorPlainText: "Verwende reinen Text, ohne HTML",
4698
+ errorOffsetMismatch: "Der UTC-Versatz passt nicht zur Zeitzone des Termins",
4699
+ errorNotEditable: "Dieses Feld kann nicht bearbeitet werden",
4700
+ errorInvalidValue: "Dieser Wert ist ungültig"
4533
4701
  },
4534
4702
  da: {
4535
4703
  searchingMail: "Søger i {{service}}",
@@ -4601,7 +4769,35 @@ const COPY = {
4601
4769
  statusUnknown: "Ukendt resultat: tjek før du prøver igen",
4602
4770
  statusNotFound: "Ikke tilgængelig i denne samtale",
4603
4771
  toolUnavailable: "Værktøjet til denne handling er ikke tilgængeligt lige nu",
4604
- decisionError: "Din beslutning kunne ikke sendes. Prøv igen."
4772
+ decisionError: "Din beslutning kunne ikke sendes. Prøv igen.",
4773
+ edit: "Rediger",
4774
+ saveAndSend: "Gem og send",
4775
+ saveAndConfirm: "Gem og bekræft",
4776
+ discardEdit: "Kassér ændringer",
4777
+ fieldBody: "Besked",
4778
+ fieldStart: "Starter",
4779
+ fieldEnd: "Slutter",
4780
+ addressesHint: "Adskil adresser med komma",
4781
+ timeZoneNote: "Tidszone: {{zone}}",
4782
+ errorRequired: "Feltet må ikke være tomt",
4783
+ errorNoRecipients: "Tilføj mindst én modtager",
4784
+ errorInvalidAddress: "Angiv gyldige mailadresser",
4785
+ errorInvalidDateTime: "Angiv en gyldig dato og tid",
4786
+ errorAmbiguousTime: "Dette tidspunkt findes ikke eller forekommer to gange i {{zone}}. Vælg et andet tidspunkt.",
4787
+ errorEndBeforeStart: "Slutningen skal være efter starten",
4788
+ editNoLongerApplies: "Dine ændringer gælder ikke længere for denne handling. Gennemgå dem og prøv igen.",
4789
+ editedLabel: "Redigeret",
4790
+ seeNewerVersion: "Se den nyere version",
4791
+ invalidatedConfigurationChanged: "Værktøjet, kontoen eller dens konfiguration er ændret, efter at dette blev forberedt. Spørg igen i chatten.",
4792
+ invalidatedNoSnapshot: "Denne handling blev forberedt af en ældre version og kan ikke udføres. Spørg igen i chatten.",
4793
+ invalidatedResourceChanged: "Begivenheden er ændret, efter at dette blev forberedt, så intet blev ændret. Spørg igen i chatten.",
4794
+ unknownOutcome: "Udbyderen bekræftede ikke, om det skete. Tjek dine sendte mails eller din kalender, før du prøver igen.",
4795
+ unknownInterrupted: "Handlingen blev afbrudt, og det vides ikke, om den skete. Tjek din konto, før du prøver igen.",
4796
+ applyingNow: "Bliver allerede anvendt…",
4797
+ errorPlainText: "Brug almindelig tekst uden HTML",
4798
+ errorOffsetMismatch: "UTC-forskydningen passer ikke til begivenhedens tidszone",
4799
+ errorNotEditable: "Dette felt kan ikke redigeres",
4800
+ errorInvalidValue: "Denne værdi er ugyldig"
4605
4801
  },
4606
4802
  sv: {
4607
4803
  searchingMail: "Söker i {{service}}",
@@ -4673,7 +4869,35 @@ const COPY = {
4673
4869
  statusUnknown: "Okänt resultat: kontrollera innan du försöker igen",
4674
4870
  statusNotFound: "Inte tillgänglig i den här konversationen",
4675
4871
  toolUnavailable: "Verktyget för den här åtgärden är inte tillgängligt just nu",
4676
- decisionError: "Ditt beslut kunde inte skickas. Försök igen."
4872
+ decisionError: "Ditt beslut kunde inte skickas. Försök igen.",
4873
+ edit: "Redigera",
4874
+ saveAndSend: "Spara och skicka",
4875
+ saveAndConfirm: "Spara och bekräfta",
4876
+ discardEdit: "Ignorera ändringar",
4877
+ fieldBody: "Meddelande",
4878
+ fieldStart: "Börjar",
4879
+ fieldEnd: "Slutar",
4880
+ addressesHint: "Separera adresser med kommatecken",
4881
+ timeZoneNote: "Tidszon: {{zone}}",
4882
+ errorRequired: "Fältet får inte vara tomt",
4883
+ errorNoRecipients: "Lägg till minst en mottagare",
4884
+ errorInvalidAddress: "Ange giltiga e-postadresser",
4885
+ errorInvalidDateTime: "Ange ett giltigt datum och en giltig tid",
4886
+ errorAmbiguousTime: "Den här tiden finns inte eller inträffar två gånger i {{zone}}. Välj en annan tid.",
4887
+ errorEndBeforeStart: "Slutet måste vara efter starten",
4888
+ editNoLongerApplies: "Dina ändringar gäller inte längre för den här åtgärden. Granska dem och försök igen.",
4889
+ editedLabel: "Redigerad",
4890
+ seeNewerVersion: "Se den nyare versionen",
4891
+ invalidatedConfigurationChanged: "Verktyget, kontot eller dess inställningar ändrades efter att detta förbereddes. Fråga igen i chatten.",
4892
+ invalidatedNoSnapshot: "Den här åtgärden förbereddes av en äldre version och kan inte köras. Fråga igen i chatten.",
4893
+ invalidatedResourceChanged: "Händelsen ändrades efter att detta förbereddes, så inget ändrades. Fråga igen i chatten.",
4894
+ unknownOutcome: "Leverantören bekräftade inte om det hände. Kontrollera dina skickade mejl eller din kalender innan du försöker igen.",
4895
+ unknownInterrupted: "Åtgärden avbröts och det är inte känt om den hände. Kontrollera ditt konto innan du försöker igen.",
4896
+ applyingNow: "Tillämpas redan…",
4897
+ errorPlainText: "Använd vanlig text, utan HTML",
4898
+ errorOffsetMismatch: "UTC-förskjutningen stämmer inte med händelsens tidszon",
4899
+ errorNotEditable: "Det här fältet kan inte redigeras",
4900
+ errorInvalidValue: "Det här värdet är ogiltigt"
4677
4901
  },
4678
4902
  no: {
4679
4903
  searchingMail: "Søker i {{service}}",
@@ -4745,7 +4969,35 @@ const COPY = {
4745
4969
  statusUnknown: "Ukjent resultat: sjekk før du prøver igjen",
4746
4970
  statusNotFound: "Ikke tilgjengelig i denne samtalen",
4747
4971
  toolUnavailable: "Verktøyet for denne handlingen er ikke tilgjengelig nå",
4748
- decisionError: "Beslutningen din kunne ikke sendes. Prøv igjen."
4972
+ decisionError: "Beslutningen din kunne ikke sendes. Prøv igjen.",
4973
+ edit: "Rediger",
4974
+ saveAndSend: "Lagre og send",
4975
+ saveAndConfirm: "Lagre og bekreft",
4976
+ discardEdit: "Forkast endringer",
4977
+ fieldBody: "Melding",
4978
+ fieldStart: "Starter",
4979
+ fieldEnd: "Slutter",
4980
+ addressesHint: "Skill adresser med komma",
4981
+ timeZoneNote: "Tidssone: {{zone}}",
4982
+ errorRequired: "Feltet kan ikke være tomt",
4983
+ errorNoRecipients: "Legg til minst én mottaker",
4984
+ errorInvalidAddress: "Skriv inn gyldige e-postadresser",
4985
+ errorInvalidDateTime: "Skriv inn en gyldig dato og tid",
4986
+ errorAmbiguousTime: "Dette tidspunktet finnes ikke eller forekommer to ganger i {{zone}}. Velg et annet tidspunkt.",
4987
+ errorEndBeforeStart: "Slutten må være etter starten",
4988
+ editNoLongerApplies: "Endringene dine gjelder ikke lenger for denne handlingen. Gå gjennom dem og prøv igjen.",
4989
+ editedLabel: "Redigert",
4990
+ seeNewerVersion: "Se den nyere versjonen",
4991
+ invalidatedConfigurationChanged: "Verktøyet, kontoen eller konfigurasjonen ble endret etter at dette ble forberedt. Spør igjen i chatten.",
4992
+ invalidatedNoSnapshot: "Denne handlingen ble forberedt av en eldre versjon og kan ikke kjøres. Spør igjen i chatten.",
4993
+ invalidatedResourceChanged: "Hendelsen ble endret etter at dette ble forberedt, så ingenting ble endret. Spør igjen i chatten.",
4994
+ unknownOutcome: "Leverandøren bekreftet ikke om det skjedde. Sjekk sendte e-poster eller kalenderen før du prøver igjen.",
4995
+ unknownInterrupted: "Handlingen ble avbrutt, og det er ikke kjent om den skjedde. Sjekk kontoen din før du prøver igjen.",
4996
+ applyingNow: "Blir allerede brukt…",
4997
+ errorPlainText: "Bruk vanlig tekst, uten HTML",
4998
+ errorOffsetMismatch: "UTC-forskyvningen stemmer ikke med hendelsens tidssone",
4999
+ errorNotEditable: "Dette feltet kan ikke redigeres",
5000
+ errorInvalidValue: "Denne verdien er ugyldig"
4749
5001
  },
4750
5002
  pt: {
4751
5003
  searchingMail: "Pesquisando no {{service}}",
@@ -4817,7 +5069,35 @@ const COPY = {
4817
5069
  statusUnknown: "Resultado desconhecido: verifique antes de tentar de novo",
4818
5070
  statusNotFound: "Indisponível nesta conversa",
4819
5071
  toolUnavailable: "A ferramenta desta ação não está disponível agora",
4820
- decisionError: "Não foi possível enviar sua decisão. Tente novamente."
5072
+ decisionError: "Não foi possível enviar sua decisão. Tente novamente.",
5073
+ edit: "Editar",
5074
+ saveAndSend: "Salvar e enviar",
5075
+ saveAndConfirm: "Salvar e confirmar",
5076
+ discardEdit: "Descartar alterações",
5077
+ fieldBody: "Mensagem",
5078
+ fieldStart: "Início",
5079
+ fieldEnd: "Fim",
5080
+ addressesHint: "Separe os endereços com vírgulas",
5081
+ timeZoneNote: "Fuso horário: {{zone}}",
5082
+ errorRequired: "Este campo não pode ficar vazio",
5083
+ errorNoRecipients: "Adicione pelo menos um destinatário",
5084
+ errorInvalidAddress: "Informe endereços de e-mail válidos",
5085
+ errorInvalidDateTime: "Informe uma data e hora válidas",
5086
+ errorAmbiguousTime: "Este horário não existe ou se repete em {{zone}}. Escolha outro horário.",
5087
+ errorEndBeforeStart: "O fim deve ser posterior ao início",
5088
+ editNoLongerApplies: "Suas alterações não se aplicam mais a esta ação. Revise-as e tente novamente.",
5089
+ editedLabel: "Editada",
5090
+ seeNewerVersion: "Ver a versão mais recente",
5091
+ invalidatedConfigurationChanged: "A ferramenta, a conta ou a configuração mudaram depois de preparar isto. Peça de novo no chat.",
5092
+ invalidatedNoSnapshot: "Esta ação foi preparada por uma versão anterior e não pode ser executada. Peça de novo no chat.",
5093
+ invalidatedResourceChanged: "O evento mudou depois de preparar isto, então nada foi modificado. Peça de novo no chat.",
5094
+ unknownOutcome: "O provedor não confirmou se aconteceu. Verifique seus enviados ou sua agenda antes de tentar de novo.",
5095
+ unknownInterrupted: "A ação foi interrompida e não se sabe se aconteceu. Verifique sua conta antes de tentar de novo.",
5096
+ applyingNow: "Já está sendo aplicado…",
5097
+ errorPlainText: "Use texto simples, sem HTML",
5098
+ errorOffsetMismatch: "O deslocamento UTC não corresponde ao fuso horário do evento",
5099
+ errorNotEditable: "Este campo não pode ser editado",
5100
+ errorInvalidValue: "Este valor não é válido"
4821
5101
  }
4822
5102
  };
4823
5103
  function getPersonalConnectorCopy(locale) {
@@ -4830,6 +5110,349 @@ function fillCopy(template, values) {
4830
5110
  return template.replace(/\{\{(\w+)\}\}/g, (match, key) => key in values ? String(values[key]) : match);
4831
5111
  }
4832
5112
 
5113
+ //#endregion
5114
+ //#region src/components/internal/tool-confirmation-edit.ts
5115
+ const FIELD_KINDS = {
5116
+ to: "addresses",
5117
+ cc: "addresses",
5118
+ attendees: "addresses",
5119
+ subject: "text",
5120
+ title: "text",
5121
+ location: "text",
5122
+ body: "textarea",
5123
+ start: "datetime",
5124
+ end: "datetime"
5125
+ };
5126
+ /** Editable fields in the order the form shows them. */
5127
+ const FIELD_ORDER = [
5128
+ "to",
5129
+ "cc",
5130
+ "subject",
5131
+ "body",
5132
+ "title",
5133
+ "start",
5134
+ "end",
5135
+ "location",
5136
+ "attendees"
5137
+ ];
5138
+ /** Fields of this action the card can show a control for. */
5139
+ function editableFields(pending) {
5140
+ const allowed = new Set(pending.editable ?? []);
5141
+ return FIELD_ORDER.filter((field) => allowed.has(field));
5142
+ }
5143
+ /**
5144
+ * Copy of each stable code the server sends for a rejected edit. A code this client does
5145
+ * not know falls back to the server's English message instead of hiding the problem.
5146
+ */
5147
+ const SERVER_ERROR_COPY = {
5148
+ needs_recipient: "errorNoRecipients",
5149
+ invalid_address: "errorInvalidAddress",
5150
+ must_be_address_list: "errorInvalidAddress",
5151
+ too_many_addresses: "errorInvalidAddress",
5152
+ cannot_be_empty: "errorRequired",
5153
+ cannot_be_null: "errorRequired",
5154
+ plain_text_only: "errorPlainText",
5155
+ invalid_datetime: "errorInvalidDateTime",
5156
+ ambiguous_time: "errorAmbiguousTime",
5157
+ end_before_start: "errorEndBeforeStart",
5158
+ offset_mismatch: "errorOffsetMismatch",
5159
+ not_editable: "errorNotEditable",
5160
+ cannot_change: "errorNotEditable",
5161
+ not_replaceable: "errorNotEditable",
5162
+ must_be_text: "errorInvalidValue",
5163
+ too_long: "errorInvalidValue"
5164
+ };
5165
+ const OFFSET_SUFFIX = /(Z|[+-]\d{2}:?\d{2})$/i;
5166
+ function parseOffsetMinutes(value) {
5167
+ const match = OFFSET_SUFFIX.exec(value.trim());
5168
+ if (!match) return null;
5169
+ const text$2 = match[1].toUpperCase();
5170
+ if (text$2 === "Z") return 0;
5171
+ const sign = text$2[0] === "-" ? -1 : 1;
5172
+ const digits = text$2.slice(1).replace(":", "");
5173
+ return sign * (Number(digits.slice(0, 2)) * 60 + Number(digits.slice(2, 4)));
5174
+ }
5175
+ function formatOffset(minutes) {
5176
+ const sign = minutes < 0 ? "-" : "+";
5177
+ const abs = Math.abs(minutes);
5178
+ return `${sign}${String(Math.floor(abs / 60)).padStart(2, "0")}:${String(abs % 60).padStart(2, "0")}`;
5179
+ }
5180
+ function isValidZone(name) {
5181
+ try {
5182
+ new Intl.DateTimeFormat("en-US", { timeZone: name });
5183
+ return true;
5184
+ } catch {
5185
+ return false;
5186
+ }
5187
+ }
5188
+ /**
5189
+ * The zone of the action: its own `time_zone`, else the offset its dates were
5190
+ * prepared with, else UTC (how the server reads a date without offset).
5191
+ */
5192
+ function actionZone(action) {
5193
+ const named = action.time_zone;
5194
+ if (typeof named === "string" && isValidZone(named)) return {
5195
+ kind: "iana",
5196
+ name: named
5197
+ };
5198
+ for (const field of ["start", "end"]) {
5199
+ const value = action[field];
5200
+ const minutes = typeof value === "string" ? parseOffsetMinutes(value) : null;
5201
+ if (minutes !== null) return {
5202
+ kind: "offset",
5203
+ minutes,
5204
+ label: `UTC${formatOffset(minutes)}`
5205
+ };
5206
+ }
5207
+ return {
5208
+ kind: "offset",
5209
+ minutes: 0,
5210
+ label: "UTC"
5211
+ };
5212
+ }
5213
+ function zoneLabel(zone) {
5214
+ return zone.kind === "iana" ? zone.name : zone.label;
5215
+ }
5216
+ const formatters = /* @__PURE__ */ new Map();
5217
+ /** Wall clock of an instant in `zone`, as if it were UTC (ms). */
5218
+ function wallClockMs(instant, name) {
5219
+ let formatter = formatters.get(name);
5220
+ if (!formatter) {
5221
+ formatter = new Intl.DateTimeFormat("en-US", {
5222
+ timeZone: name,
5223
+ hourCycle: "h23",
5224
+ year: "numeric",
5225
+ month: "2-digit",
5226
+ day: "2-digit",
5227
+ hour: "2-digit",
5228
+ minute: "2-digit",
5229
+ second: "2-digit"
5230
+ });
5231
+ formatters.set(name, formatter);
5232
+ }
5233
+ const parts = {};
5234
+ for (const part of formatter.formatToParts(new Date(instant))) if (part.type !== "literal") parts[part.type] = Number(part.value);
5235
+ return Date.UTC(parts.year, parts.month - 1, parts.day, parts.hour === 24 ? 0 : parts.hour, parts.minute, parts.second);
5236
+ }
5237
+ /** Offset of `name` at `instant`, in minutes east of UTC. */
5238
+ function offsetMinutesAt(instant, name) {
5239
+ return Math.round((wallClockMs(instant, name) - instant) / 6e4);
5240
+ }
5241
+ const LOCAL_INPUT = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/;
5242
+ function pad(value) {
5243
+ return String(value).padStart(2, "0");
5244
+ }
5245
+ function toInputValue(wallMs) {
5246
+ const date = new Date(wallMs);
5247
+ return `${date.getUTCFullYear()}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}T${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}`;
5248
+ }
5249
+ /** `YYYY-MM-DDTHH:mm` (a `datetime-local` value) of an ISO date, in `zone`. */
5250
+ function isoToLocalInput(iso, zone) {
5251
+ const text$2 = iso.trim();
5252
+ if (!OFFSET_SUFFIX.test(text$2)) {
5253
+ const naive = LOCAL_INPUT.exec(text$2);
5254
+ return naive ? `${naive[1]}-${naive[2]}-${naive[3]}T${naive[4]}:${naive[5]}` : null;
5255
+ }
5256
+ const instant = Date.parse(text$2);
5257
+ if (Number.isNaN(instant)) return null;
5258
+ return toInputValue(zone.kind === "iana" ? wallClockMs(instant, zone.name) : instant + zone.minutes * 6e4);
5259
+ }
5260
+ /**
5261
+ * ISO 8601 with the UTC offset `zone` has at that wall clock time. A time that
5262
+ * happens twice (clocks go back) or never (clocks go forward) has no single
5263
+ * valid offset: it is rejected so the user picks another one.
5264
+ */
5265
+ function localInputToIso(local, zone) {
5266
+ const match = LOCAL_INPUT.exec(local.trim());
5267
+ if (!match) return { error: "invalid" };
5268
+ const [, year, month, day, hour, minute] = match;
5269
+ const wall = Date.UTC(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute));
5270
+ if (Number.isNaN(wall) || toInputValue(wall) !== local.trim().slice(0, 16)) return { error: "invalid" };
5271
+ const stamp = `${year}-${month}-${day}T${hour}:${minute}:00`;
5272
+ if (zone.kind === "offset") return { iso: `${stamp}${formatOffset(zone.minutes)}` };
5273
+ const candidates = /* @__PURE__ */ new Set();
5274
+ for (const probe of [wall - 864e5, wall + 864e5]) {
5275
+ const offset$1 = offsetMinutesAt(probe, zone.name);
5276
+ if (wallClockMs(wall - offset$1 * 6e4, zone.name) === wall) candidates.add(offset$1);
5277
+ }
5278
+ if (candidates.size !== 1) return { error: "ambiguous" };
5279
+ const [offset] = candidates;
5280
+ return { iso: `${stamp}${formatOffset(offset)}` };
5281
+ }
5282
+ const EMAIL = /^[^@\s<>,;]+@[^@\s<>,;]+\.[^@\s<>,;]+$/;
5283
+ function asString(value) {
5284
+ return typeof value === "string" ? value : "";
5285
+ }
5286
+ /** What each field shows when the form opens: the prepared values. */
5287
+ function initialDraft(pending) {
5288
+ const action = pending.action;
5289
+ const zone = actionZone(action);
5290
+ const draft = {};
5291
+ for (const field of editableFields(pending)) {
5292
+ const value = action[field];
5293
+ switch (FIELD_KINDS[field]) {
5294
+ case "addresses":
5295
+ draft[field] = Array.isArray(value) ? value.filter((item) => typeof item === "string").join(", ") : "";
5296
+ break;
5297
+ case "datetime":
5298
+ draft[field] = typeof value === "string" ? isoToLocalInput(value, zone) ?? "" : "";
5299
+ break;
5300
+ default: draft[field] = asString(value);
5301
+ }
5302
+ }
5303
+ return draft;
5304
+ }
5305
+ function splitAddresses(text$2) {
5306
+ return text$2.split(/[,;\n]/).map((address) => address.trim()).filter(Boolean);
5307
+ }
5308
+ /**
5309
+ * The patch for `draft` against the prepared values, or the field errors that
5310
+ * stop it. Unchanged fields are left out so the server keeps their exact value.
5311
+ */
5312
+ function buildPatch(pending, draft, initial = initialDraft(pending)) {
5313
+ const action = pending.action;
5314
+ const zone = actionZone(action);
5315
+ const zoneName = zoneLabel(zone);
5316
+ const patch = {};
5317
+ const errors = {};
5318
+ for (const field of editableFields(pending)) {
5319
+ const value = draft[field] ?? "";
5320
+ if (value === (initial[field] ?? "")) continue;
5321
+ switch (FIELD_KINDS[field]) {
5322
+ case "addresses": {
5323
+ const addresses = splitAddresses(value);
5324
+ if (addresses.some((address) => !EMAIL.test(address))) errors[field] = { key: "invalidAddress" };
5325
+ else if (field === "to" && addresses.length === 0) errors[field] = { key: "noRecipients" };
5326
+ else patch[field] = addresses;
5327
+ break;
5328
+ }
5329
+ case "datetime": {
5330
+ const converted = localInputToIso(value, zone);
5331
+ if (converted.error === "ambiguous") errors[field] = {
5332
+ key: "ambiguousTime",
5333
+ zone: zoneName
5334
+ };
5335
+ else if (converted.error) errors[field] = { key: "invalidDateTime" };
5336
+ else patch[field] = converted.iso;
5337
+ break;
5338
+ }
5339
+ case "text":
5340
+ if (value.trim() === "") if (field === "location") patch[field] = null;
5341
+ else errors[field] = { key: "required" };
5342
+ else patch[field] = value;
5343
+ break;
5344
+ default: patch[field] = value;
5345
+ }
5346
+ }
5347
+ const start = readInstant(patch.start, action.start);
5348
+ const end = readInstant(patch.end, action.end);
5349
+ if (!errors.end && !errors.start && (patch.start !== void 0 || patch.end !== void 0) && start !== null && end !== null && start >= end) errors.end = { key: "endBeforeStart" };
5350
+ return {
5351
+ patch,
5352
+ errors
5353
+ };
5354
+ }
5355
+ function readInstant(edited, original) {
5356
+ const value = typeof edited === "string" ? edited : original;
5357
+ if (typeof value !== "string") return null;
5358
+ const parsed = Date.parse(value);
5359
+ return Number.isNaN(parsed) ? null : parsed;
5360
+ }
5361
+
5362
+ //#endregion
5363
+ //#region src/components/tool-confirmation-edit-form.tsx
5364
+ const LABELS = {
5365
+ to: "to",
5366
+ cc: "cc",
5367
+ subject: "subject",
5368
+ body: "fieldBody",
5369
+ title: "title",
5370
+ start: "fieldStart",
5371
+ end: "fieldEnd",
5372
+ location: "location",
5373
+ attendees: "attendees"
5374
+ };
5375
+ const ERROR_COPY = {
5376
+ required: "errorRequired",
5377
+ noRecipients: "errorNoRecipients",
5378
+ invalidAddress: "errorInvalidAddress",
5379
+ invalidDateTime: "errorInvalidDateTime",
5380
+ ambiguousTime: "errorAmbiguousTime",
5381
+ endBeforeStart: "errorEndBeforeStart"
5382
+ };
5383
+ const INPUT_CLASS = "w-full rounded-md border border-border-strong bg-surface px-2 py-1.5 text-xs text-foreground disabled:opacity-50 aria-[invalid=true]:border-danger";
5384
+ /**
5385
+ * Inline form to change an action before confirming it. Only the fields the
5386
+ * server declared editable are shown. The draft lives in the parent, so it
5387
+ * survives validation errors and a busy thread.
5388
+ */
5389
+ function ToolConfirmationEditForm({ pending, draft, onChange, errors, serverErrors, disabled, copy }) {
5390
+ const baseId = useId();
5391
+ const fields = editableFields(pending);
5392
+ const zone = zoneLabel(actionZone(pending.action));
5393
+ return /* @__PURE__ */ jsx("div", {
5394
+ className: "space-y-2 border-t border-border bg-surface px-3 py-3",
5395
+ "data-confirmation-edit": pending.action_id,
5396
+ children: fields.map((field) => {
5397
+ const kind = FIELD_KINDS[field];
5398
+ const id = `${baseId}-${field}`;
5399
+ const errorId = `${id}-error`;
5400
+ const clientError = errors[field];
5401
+ const serverError = serverErrors[field];
5402
+ const serverKey = serverError?.code ? SERVER_ERROR_COPY[serverError.code] : void 0;
5403
+ const message = clientError ? fillCopy(copy[ERROR_COPY[clientError.key]], { zone: clientError.zone ?? zone }) : serverKey ? fillCopy(copy[serverKey], { zone }) : serverError?.message;
5404
+ const common = {
5405
+ id,
5406
+ name: field,
5407
+ value: draft[field] ?? "",
5408
+ disabled,
5409
+ "aria-invalid": message ? true : void 0,
5410
+ "aria-describedby": message ? errorId : void 0,
5411
+ className: INPUT_CLASS
5412
+ };
5413
+ return /* @__PURE__ */ jsxs("div", {
5414
+ className: "space-y-1",
5415
+ children: [
5416
+ /* @__PURE__ */ jsx("label", {
5417
+ htmlFor: id,
5418
+ className: "block text-xs font-medium text-strong",
5419
+ children: copy[LABELS[field]]
5420
+ }),
5421
+ kind === "textarea" ? /* @__PURE__ */ jsx("textarea", {
5422
+ ...common,
5423
+ rows: 5,
5424
+ onChange: (event) => onChange(field, event.target.value)
5425
+ }) : kind === "datetime" ? /* @__PURE__ */ jsx("input", {
5426
+ ...common,
5427
+ type: "datetime-local",
5428
+ step: 60,
5429
+ onChange: (event) => onChange(field, event.target.value)
5430
+ }) : /* @__PURE__ */ jsx("input", {
5431
+ ...common,
5432
+ type: "text",
5433
+ autoComplete: "off",
5434
+ onChange: (event) => onChange(field, event.target.value)
5435
+ }),
5436
+ kind === "addresses" ? /* @__PURE__ */ jsx("p", {
5437
+ className: "text-xs text-muted",
5438
+ children: copy.addressesHint
5439
+ }) : null,
5440
+ kind === "datetime" ? /* @__PURE__ */ jsx("p", {
5441
+ className: "text-xs text-muted",
5442
+ children: fillCopy(copy.timeZoneNote, { zone })
5443
+ }) : null,
5444
+ message ? /* @__PURE__ */ jsx("p", {
5445
+ id: errorId,
5446
+ role: "alert",
5447
+ className: joinClasses("text-xs text-danger-strong"),
5448
+ children: message
5449
+ }) : null
5450
+ ]
5451
+ }, field);
5452
+ })
5453
+ });
5454
+ }
5455
+
4833
5456
  //#endregion
4834
5457
  //#region src/components/tool-confirmation-controls.tsx
4835
5458
  const MINUTE = 6e4;
@@ -4873,6 +5496,26 @@ function statusLabel(status, copy) {
4873
5496
  const key = STATUS_COPY[status];
4874
5497
  return key ? copy[key] : null;
4875
5498
  }
5499
+ const REASON_COPY = {
5500
+ invalidated: {
5501
+ configuration_changed: "invalidatedConfigurationChanged",
5502
+ no_snapshot: "invalidatedNoSnapshot",
5503
+ resource_changed: "invalidatedResourceChanged"
5504
+ },
5505
+ unknown: {
5506
+ outcome_unknown: "unknownOutcome",
5507
+ interrupted: "unknownInterrupted"
5508
+ }
5509
+ };
5510
+ /**
5511
+ * Why an action ended as `invalidated` or `unknown`, from the safe reason code the
5512
+ * server stores. A code this client does not know shows nothing extra: the status
5513
+ * label still says what happened.
5514
+ */
5515
+ function reasonLabel(status, reason, copy) {
5516
+ const key = reason ? REASON_COPY[status]?.[reason] : void 0;
5517
+ return key ? copy[key] : null;
5518
+ }
4876
5519
  const BADGE_TONE = {
4877
5520
  pending: "border-warning-border bg-warning-subtle text-warning-strong",
4878
5521
  executing: "border-sky-200 bg-sky-50 text-sky-800",
@@ -4900,15 +5543,37 @@ function expiryText(state, serverOffsetMs, now, copy) {
4900
5543
  if (Number.isNaN(left) || left <= 0) return null;
4901
5544
  return left < MINUTE ? copy.expiresSoon : fillCopy(copy.expiresIn, { minutes: Math.floor(left / MINUTE) });
4902
5545
  }
5546
+ /** Label of the button that saves an edit and runs the action in one step. */
5547
+ function saveLabel(operation, copy) {
5548
+ return operation === "send" ? copy.saveAndSend : copy.saveAndConfirm;
5549
+ }
5550
+ /** Scrolls to the card of another version of the same action, if it is on screen. */
5551
+ function showAction(actionId) {
5552
+ if (typeof document === "undefined") return;
5553
+ for (const element of document.querySelectorAll("[data-confirmation-action]")) if (element.getAttribute("data-confirmation-action") === actionId) {
5554
+ element.scrollIntoView?.({
5555
+ block: "center",
5556
+ behavior: "smooth"
5557
+ });
5558
+ return;
5559
+ }
5560
+ }
4903
5561
  /**
4904
5562
  * Footer of a held action. Without `toolConfirmation` it keeps the text hint
4905
- * (reply "yes"); with it, buttons once the server state is known.
5563
+ * (reply "yes"); with it, buttons once the server state is known. When the
5564
+ * server lets the user edit the action, an inline form is offered and "Save
5565
+ * and send" confirms with the changes in a single step.
4906
5566
  */
4907
5567
  function PendingConfirmationFooter({ pending, toolConfirmation, copy }) {
4908
5568
  const state = useToolConfirmationState(pending, toolConfirmation);
4909
5569
  const now = useNow(state?.status === "pending");
4910
5570
  const [sending, setSending] = useState(null);
4911
5571
  const [failed, setFailed] = useState(false);
5572
+ const [editing, setEditing] = useState(false);
5573
+ const [draft, setDraft] = useState({});
5574
+ const [fieldErrors, setFieldErrors] = useState({});
5575
+ const [serverErrors, setServerErrors] = useState({});
5576
+ const [applying, setApplying] = useState(false);
4912
5577
  if (!toolConfirmation) return /* @__PURE__ */ jsx("p", {
4913
5578
  className: "border-t border-border bg-warning-subtle/60 px-3 py-2 text-xs text-strong",
4914
5579
  children: copy.confirmHint
@@ -4920,48 +5585,130 @@ function PendingConfirmationFooter({ pending, toolConfirmation, copy }) {
4920
5585
  });
4921
5586
  if (state.status !== "pending") {
4922
5587
  const label = statusLabel(state.status, copy);
5588
+ const reason = reasonLabel(state.status, state.error, copy);
4923
5589
  return label ? /* @__PURE__ */ jsxs("p", {
4924
- className: "border-t border-divider bg-surface-muted px-3 py-2 text-xs text-strong",
5590
+ className: "flex flex-wrap items-center gap-2 border-t border-divider bg-surface-muted px-3 py-2 text-xs text-strong",
4925
5591
  "aria-live": "polite",
4926
- children: [label, state.status === "failed" && state.error ? `: ${state.error}` : null]
5592
+ children: [
5593
+ /* @__PURE__ */ jsxs("span", { children: [label, state.status === "failed" && state.error ? `: ${state.error}` : null] }),
5594
+ reason ? /* @__PURE__ */ jsx("span", {
5595
+ className: "basis-full text-muted",
5596
+ "data-confirmation-reason": true,
5597
+ children: reason
5598
+ }) : null,
5599
+ state.status === "superseded" && state.supersededBy ? /* @__PURE__ */ jsx("button", {
5600
+ type: "button",
5601
+ className: "underline underline-offset-2 hover:text-foreground",
5602
+ onClick: () => showAction(state.supersededBy),
5603
+ children: copy.seeNewerVersion
5604
+ }) : null,
5605
+ state.effectiveAction ? /* @__PURE__ */ jsx("span", {
5606
+ className: "rounded-full border border-border bg-surface px-2 py-0.5 text-muted",
5607
+ children: copy.editedLabel
5608
+ }) : null
5609
+ ]
4927
5610
  }) : null;
4928
5611
  }
4929
- const decide = async (decision) => {
4930
- setSending(decision);
5612
+ const decide = async (decisions) => {
4931
5613
  setFailed(false);
5614
+ setApplying(false);
4932
5615
  try {
4933
- await toolConfirmation.decide([{
4934
- action_id: pending.action_id,
4935
- decision
4936
- }]);
4937
- } catch {
4938
- setFailed(true);
4939
- } finally {
4940
- setSending(null);
5616
+ await toolConfirmation.decide(decisions);
5617
+ } catch (error) {
5618
+ if (error instanceof ToolDecisionRejectedError && error.details.actionId === pending.action_id) setServerErrors(Object.fromEntries(error.details.errors.map(({ field, message, code }) => [field, {
5619
+ message,
5620
+ ...code ? { code } : {}
5621
+ }])));
5622
+ else if (error instanceof ToolSubmissionConflictError && error.details.code === "decision_in_progress") setApplying(true);
5623
+ else setFailed(true);
4941
5624
  }
4942
5625
  };
5626
+ const send = async (decision) => {
5627
+ setSending(decision);
5628
+ await decide([{
5629
+ action_id: pending.action_id,
5630
+ decision
5631
+ }]);
5632
+ setSending(null);
5633
+ };
5634
+ const saveAndConfirm = async () => {
5635
+ const { patch, errors } = buildPatch(pending, draft);
5636
+ setFieldErrors(errors);
5637
+ setServerErrors({});
5638
+ if (Object.keys(errors).length > 0) return;
5639
+ setSending("confirm");
5640
+ await decide([{
5641
+ action_id: pending.action_id,
5642
+ decision: "confirm",
5643
+ ...Object.keys(patch).length > 0 ? { arguments: patch } : {}
5644
+ }]);
5645
+ setSending(null);
5646
+ };
5647
+ const startEditing = () => {
5648
+ setDraft(initialDraft(pending));
5649
+ setFieldErrors({});
5650
+ setServerErrors({});
5651
+ setFailed(false);
5652
+ setEditing(true);
5653
+ };
5654
+ const stopEditing = () => {
5655
+ setEditing(false);
5656
+ setFieldErrors({});
5657
+ setServerErrors({});
5658
+ };
4943
5659
  const disabled = Boolean(toolConfirmation.disabled) || sending !== null;
4944
5660
  const destructive = pending.operation === "delete";
5661
+ const canEdit = state.canConfirm && editableFields(pending).length > 0;
4945
5662
  const expiry = expiryText(state, toolConfirmation.states.serverOffsetMs, now, copy);
4946
5663
  const unavailable = state.error === "tool_unavailable";
4947
- return /* @__PURE__ */ jsxs("div", {
5664
+ const editStale = state.error === "invalid_edit";
5665
+ return /* @__PURE__ */ jsxs(Fragment, { children: [editing && canEdit ? /* @__PURE__ */ jsx(ToolConfirmationEditForm, {
5666
+ pending,
5667
+ draft,
5668
+ onChange: (field, value) => {
5669
+ setDraft((current) => ({
5670
+ ...current,
5671
+ [field]: value
5672
+ }));
5673
+ setFieldErrors(({ [field]: _removed,...rest }) => rest);
5674
+ setServerErrors(({ [field]: _removed,...rest }) => rest);
5675
+ },
5676
+ errors: fieldErrors,
5677
+ serverErrors,
5678
+ disabled,
5679
+ copy
5680
+ }) : null, /* @__PURE__ */ jsxs("div", {
4948
5681
  className: "flex flex-wrap items-center gap-2 border-t border-border bg-warning-subtle/60 px-3 py-2",
4949
5682
  "data-confirmation-actions": pending.action_id,
4950
5683
  children: [
4951
5684
  state.canConfirm ? /* @__PURE__ */ jsxs("button", {
4952
5685
  type: "button",
4953
5686
  disabled,
4954
- onClick: () => void decide("confirm"),
5687
+ onClick: () => void (editing && canEdit ? saveAndConfirm() : send("confirm")),
4955
5688
  className: joinClasses("inline-flex items-center rounded-md px-3 py-1.5 text-xs font-medium text-inverse-foreground disabled:opacity-50", destructive ? "bg-danger hover:bg-danger-strong" : "bg-inverse hover:bg-inverse-hover"),
4956
5689
  children: [sending === "confirm" ? /* @__PURE__ */ jsx(LoaderCircle, {
4957
5690
  className: "mr-2 size-3 animate-spin",
4958
5691
  "aria-hidden": "true"
4959
- }) : null, sending === "confirm" ? copy.confirming : verbFor(pending.operation, copy)]
5692
+ }) : null, sending === "confirm" ? copy.confirming : editing && canEdit ? saveLabel(pending.operation, copy) : verbFor(pending.operation, copy)]
5693
+ }) : null,
5694
+ canEdit && !editing ? /* @__PURE__ */ jsx("button", {
5695
+ type: "button",
5696
+ disabled,
5697
+ onClick: startEditing,
5698
+ className: "inline-flex items-center rounded-md border border-border-strong bg-surface px-3 py-1.5 text-xs font-medium text-strong hover:bg-surface-muted disabled:opacity-50",
5699
+ children: copy.edit
5700
+ }) : null,
5701
+ editing && canEdit ? /* @__PURE__ */ jsx("button", {
5702
+ type: "button",
5703
+ disabled,
5704
+ onClick: stopEditing,
5705
+ className: "inline-flex items-center rounded-md border border-border-strong bg-surface px-3 py-1.5 text-xs font-medium text-strong hover:bg-surface-muted disabled:opacity-50",
5706
+ children: copy.discardEdit
4960
5707
  }) : null,
4961
5708
  state.canReject ? /* @__PURE__ */ jsxs("button", {
4962
5709
  type: "button",
4963
5710
  disabled,
4964
- onClick: () => void decide("reject"),
5711
+ onClick: () => void send("reject"),
4965
5712
  className: "inline-flex items-center rounded-md border border-border-strong bg-surface px-3 py-1.5 text-xs font-medium text-strong hover:bg-surface-muted disabled:opacity-50",
4966
5713
  children: [sending === "reject" ? /* @__PURE__ */ jsx(LoaderCircle, {
4967
5714
  className: "mr-2 size-3 animate-spin",
@@ -4971,10 +5718,10 @@ function PendingConfirmationFooter({ pending, toolConfirmation, copy }) {
4971
5718
  /* @__PURE__ */ jsx("span", {
4972
5719
  className: "ml-auto text-xs text-secondary",
4973
5720
  "aria-live": "polite",
4974
- children: failed ? copy.decisionError : unavailable ? copy.toolUnavailable : expiry
5721
+ children: failed ? copy.decisionError : applying ? copy.applyingNow : unavailable ? copy.toolUnavailable : editStale ? copy.editNoLongerApplies : expiry
4975
5722
  })
4976
5723
  ]
4977
- });
5724
+ })] });
4978
5725
  }
4979
5726
 
4980
5727
  //#endregion
@@ -5581,20 +6328,28 @@ function headerCount(view, copy) {
5581
6328
  return null;
5582
6329
  }
5583
6330
  function ToolResultPersonalConnectorCard({ part, locale, className, toolConfirmation }) {
5584
- const view = getView(part);
5585
- const pending = view?.kind === "pending-mail" || view?.kind === "pending-event" ? view.pending : null;
6331
+ const prepared = getView(part);
6332
+ const pending = prepared?.kind === "pending-mail" || prepared?.kind === "pending-event" ? prepared.pending : null;
5586
6333
  const confirmationState = useToolConfirmationState(pending, toolConfirmation);
5587
- if (!view) return null;
6334
+ if (!prepared) return null;
6335
+ const view = (prepared.kind === "pending-mail" || prepared.kind === "pending-event") && confirmationState?.effectiveAction ? {
6336
+ ...prepared,
6337
+ pending: {
6338
+ ...prepared.pending,
6339
+ action: confirmationState.effectiveAction
6340
+ }
6341
+ } : prepared;
5588
6342
  const copy = getPersonalConnectorCopy(locale);
5589
6343
  const connector = getConnector(part);
5590
6344
  const Icon = isCalendar(connector) ? CalendarDays : Mail;
5591
6345
  const total = headerCount(view, copy);
5592
6346
  const isPending = view.kind === "pending-mail" || view.kind === "pending-event";
5593
6347
  return /* @__PURE__ */ jsxs("section", {
5594
- className: joinClasses("plai-tool-result-personal-connector-card overflow-hidden rounded-lg border border-border bg-surface text-foreground", className),
6348
+ className: joinClasses("plai-tool-result-personal-connector-card overflow-hidden rounded-lg border border-border bg-surface text-foreground", confirmationState?.status === "superseded" ? "opacity-60" : void 0, className),
5595
6349
  "data-tool-call-id": part.id,
5596
6350
  "data-tool-call-state": part.state,
5597
6351
  "data-connector-action": view.kind,
6352
+ "data-confirmation-action": pending?.action_id,
5598
6353
  children: [
5599
6354
  /* @__PURE__ */ jsxs("header", {
5600
6355
  className: "flex items-center gap-2 border-b border-border px-3 py-2 text-xs text-secondary",
@@ -7460,5 +8215,5 @@ function ConversationFilesSheet({ messages, locale, className, open, onOpenChang
7460
8215
  }
7461
8216
 
7462
8217
  //#endregion
7463
- export { AggregatedSourceResults, ArrowUp, AssistantMessage, ChatError, Clipboard, ConfirmationBadge, ConversationFilesList, ConversationFilesSheet, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, MemoryProposalCard, Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader, MessageParts, MessageRoot, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PendingConfirmationFooter, 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, getConversationFiles, getLocalizedOpenGraphValue, getPendingConfirmation, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, hasPersonalConnectorView, hasToolConfirmationView, isAllowedPromptFormFile, partitionPromptFormFiles, useSpeechToText };
8218
+ export { AggregatedSourceResults, ArrowUp, AssistantMessage, ChatError, Clipboard, ConfirmationBadge, ConversationFilesList, ConversationFilesSheet, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, MemoryProposalCard, Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader, MessageParts, MessageRoot, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PendingConfirmationFooter, 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, getConversationFiles, getLocalizedOpenGraphValue, getPendingConfirmation, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, hasPersonalConnectorView, hasToolConfirmationView, isAllowedPromptFormFile, partitionPromptFormFiles, reasonLabel, useSpeechToText };
7464
8219
  //# sourceMappingURL=index.js.map