@bigbinary/neeto-assist-frontend 1.3.0 → 1.4.0-beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +22 -20
  2. package/app/javascript/src/translations/ar.json +40 -7
  3. package/app/javascript/src/translations/bg.json +40 -7
  4. package/app/javascript/src/translations/ca.json +40 -7
  5. package/app/javascript/src/translations/cs.json +40 -7
  6. package/app/javascript/src/translations/da.json +40 -7
  7. package/app/javascript/src/translations/de.json +40 -7
  8. package/app/javascript/src/translations/en.json +3 -8
  9. package/app/javascript/src/translations/es-MX.json +40 -7
  10. package/app/javascript/src/translations/es.json +40 -7
  11. package/app/javascript/src/translations/et.json +40 -7
  12. package/app/javascript/src/translations/fi.json +40 -7
  13. package/app/javascript/src/translations/fil.json +40 -7
  14. package/app/javascript/src/translations/fr.json +40 -7
  15. package/app/javascript/src/translations/he.json +40 -7
  16. package/app/javascript/src/translations/hi.json +40 -7
  17. package/app/javascript/src/translations/hr.json +40 -7
  18. package/app/javascript/src/translations/hu.json +40 -7
  19. package/app/javascript/src/translations/id.json +40 -7
  20. package/app/javascript/src/translations/it.json +40 -7
  21. package/app/javascript/src/translations/ja.json +40 -7
  22. package/app/javascript/src/translations/ko.json +40 -7
  23. package/app/javascript/src/translations/lv.json +40 -4
  24. package/app/javascript/src/translations/nl.json +40 -7
  25. package/app/javascript/src/translations/pl.json +40 -7
  26. package/app/javascript/src/translations/pt-BR.json +40 -7
  27. package/app/javascript/src/translations/pt.json +40 -7
  28. package/app/javascript/src/translations/ro.json +40 -7
  29. package/app/javascript/src/translations/ru.json +40 -7
  30. package/app/javascript/src/translations/sk.json +40 -7
  31. package/app/javascript/src/translations/sl.json +40 -7
  32. package/app/javascript/src/translations/sv.json +40 -7
  33. package/app/javascript/src/translations/th.json +40 -7
  34. package/app/javascript/src/translations/tr.json +40 -7
  35. package/app/javascript/src/translations/uk.json +40 -7
  36. package/app/javascript/src/translations/vi.json +40 -7
  37. package/app/javascript/src/translations/zh-CN.json +40 -7
  38. package/app/javascript/src/translations/zh-TW.json +40 -7
  39. package/dist/.ready +1 -1
  40. package/dist/NeetoAssistPane.js +158 -171
  41. package/dist/NeetoAssistPane.js.map +1 -1
  42. package/dist/cjs/NeetoAssistPane.js +156 -169
  43. package/dist/cjs/NeetoAssistPane.js.map +1 -1
  44. package/package.json +1 -1
  45. package/types.d.ts +9 -9
@@ -2,26 +2,26 @@ import { n as neetoAssistApi, Q as QUERY_KEYS, M as MAX_ASSISTANT_SUGGESTIONS, h
2
2
  import { u as useNeetoAssistStore } from './useNeetoAssistStore-Dgt8aV52.js';
3
3
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
4
  import { useRef, useEffect, useId, useState, useLayoutEffect, Fragment, useMemo, createElement } from 'react';
5
- import { Typography, Textarea, Spinner, typographyVariants, Button, Tooltip, Badge } from '@bigbinary/neeto-atoms';
5
+ import { Typography, Textarea, Spinner, typographyVariants, Button, Tabs, Tooltip, Badge } from '@bigbinary/neeto-atoms';
6
6
  import { assoc, uniq, isEmpty, propOr, reject, pluck, not, prop, inc } from 'ramda';
7
7
  import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
8
8
  import _regeneratorRuntime from '@babel/runtime/regenerator';
9
9
  import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
10
10
  import { e as errorMessageKey, a as useAskNeetoAssist, i as isWebUrl, o as optionId, b as useStopRun, m as matchingCommands, p as pickedCommand, c as useApplyAction, d as useDismissAction, s as shownSources, f as actionsOf, g as useUpdateFeedback, h as commandPart, j as stepsOf, k as isPending, n as hasRunningStep, q as hasWrittenReply, r as skippedReasonMessageKey, t as isStopped, v as isRateable, u as useFetchRuns, l as latestDraftId, w as stoppableAsk, x as runsInConversationOrder, y as useIsAsking, z as hasPendingRun, S as Sparkle } from './useRunsApi-BgsICthX.js';
11
- import { isNotEmpty, findIndexBy } from '@bigbinary/neeto-cist';
11
+ import { isNotEmpty, findIndexBy, findBy } from '@bigbinary/neeto-cist';
12
12
  import { useTranslation } from 'react-i18next';
13
13
  import { withT } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
14
14
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
15
15
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
16
16
  import classnames from 'classnames';
17
17
  import { CirclePause, CircleArrowUp, ChevronUp, ChevronDown, Check, ExternalLink, CornerDownLeft, Copy, ThumbsUp, ThumbsDown, X, SquarePen, Minimize2, Maximize2 } from 'lucide-react';
18
+ import _toArray from '@babel/runtime/helpers/toArray';
18
19
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
19
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
20
20
  import { copyToClipboard } from '@bigbinary/neeto-commons-frontend/v2/utils';
21
+ import '@babel/runtime/helpers/objectWithoutProperties';
21
22
  import 'axios';
22
23
  import 'zustand';
23
24
  import '@babel/runtime/helpers/typeof';
24
- import '@babel/runtime/helpers/toArray';
25
25
 
26
26
  // The first questions the engine offers for an empty thread. Only sentences
27
27
  // are kept, each once, so a button never shows anything else.
@@ -375,8 +375,8 @@ var CommandMenu = function CommandMenu(_ref) {
375
375
  });
376
376
  };
377
377
 
378
- function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
379
- function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
378
+ function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
379
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
380
380
  var MessageInput = function MessageInput(_ref) {
381
381
  var _menu$at$name, _menu$at;
382
382
  var _ref$commands = _ref.commands,
@@ -490,7 +490,7 @@ var MessageInput = function MessageInput(_ref) {
490
490
  requestId: newRequestId()
491
491
  };
492
492
  }
493
- ask(_objectSpread$5(_objectSpread$5({}, where), requestRef.current), {
493
+ ask(_objectSpread$4(_objectSpread$4({}, where), requestRef.current), {
494
494
  onSuccess: function onSuccess() {
495
495
  requestRef.current = null;
496
496
  setQuestion("");
@@ -509,7 +509,7 @@ var MessageInput = function MessageInput(_ref) {
509
509
  if (stopRequestRef.current === runId) return;
510
510
  stopRequestRef.current = runId;
511
511
  setStoppingRunId(runId);
512
- stop(_objectSpread$5(_objectSpread$5({}, where), {}, {
512
+ stop(_objectSpread$4(_objectSpread$4({}, where), {}, {
513
513
  runId: runId
514
514
  }), {
515
515
  onError: function onError() {
@@ -643,6 +643,11 @@ var MessageInput = function MessageInput(_ref) {
643
643
  // that reads it.
644
644
  var ENGLISH = "en";
645
645
 
646
+ // The tabs of a suggested reply: the reading the customer is sent, and the
647
+ // English one.
648
+ var CUSTOMER_TAB = "customer";
649
+ var ENGLISH_TAB = "english";
650
+
646
651
  // The languages that are written from right to left, by the first part of
647
652
  // their tags: Arabic, Hebrew, Persian, Urdu, Pashto, Sindhi, Uyghur, Yiddish,
648
653
  // Dhivehi and Sorani.
@@ -657,12 +662,6 @@ var RIGHT_TO_LEFT_LANGUAGES = ["ar", "he", "fa", "ur", "ps", "sd", "ug", "yi", "
657
662
  // every letter of every script.
658
663
  var RIGHT_TO_LEFT_LETTER_PATTERN = /[\u05D0-\u05EA\u05EF-\u05F2\u0620-\u063F\u0641-\u064A\u066E-\u066F\u0671-\u06D3\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FC\u06FF\u0750-\u07A5\u07B1\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40-\uFB41\uFB43-\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]/;
659
664
 
660
- // For a team that reads English, NeetoAssist can send a suggested reply, and
661
- // what the customer wrote, in English beside another language. A reading is
662
- // one of the two: its text, the tag of the language it is in, and the
663
- // direction that language is written in. A run from an older NeetoAssist, or
664
- // from a workspace that has not switched this on, carries neither, and the
665
- // pane shows it as it always did.
666
665
  var hasText = function hasText(value) {
667
666
  return typeof value === "string" && value.trim() !== "";
668
667
  };
@@ -672,10 +671,9 @@ var languageOf = function languageOf(code) {
672
671
  return code.split("-")[0].toLowerCase();
673
672
  };
674
673
 
675
- // Two tags name one language when their first parts match, as "pt-BR" and
676
- // "pt-PT" do.
677
- var isSameLanguage = function isSameLanguage(code, other) {
678
- return hasText(code) && hasText(other) && languageOf(code) === languageOf(other);
674
+ // A tag of English, with or without a region: "en", "en-GB".
675
+ var isEnglish = function isEnglish(code) {
676
+ return hasText(code) && languageOf(code) === ENGLISH;
679
677
  };
680
678
 
681
679
  // The direction a reading in another language is set in: from the right when
@@ -699,16 +697,6 @@ var inEnglish = function inEnglish(text) {
699
697
  text: text
700
698
  };
701
699
  };
702
- var customerWritesIn = function customerWritesIn(t, name) {
703
- return name ? t("neetoAssist.languages.customerWritesIn", {
704
- language: name
705
- }) : t("neetoAssist.languages.customerWritesInAnotherLanguage");
706
- };
707
- var replyIsIn = function replyIsIn(t, name) {
708
- return name ? t("neetoAssist.languages.replyIsIn", {
709
- language: name
710
- }) : t("neetoAssist.languages.replyIsInAnotherLanguage");
711
- };
712
700
 
713
701
  // "Show in English", with English named by the browser like any other
714
702
  // language, or as the translation file has it when the browser names nothing.
@@ -718,19 +706,39 @@ var showInEnglish = function showInEnglish(t, english) {
718
706
  }) : t("neetoAssist.languages.showInEnglish");
719
707
  };
720
708
 
721
- // The two readings of a suggested reply: the English one, and the one the
722
- // customer is sent, in the language the run names for it. A reply is in two
723
- // languages only when the run has that language and the reply both ways, each
724
- // a text with something in it. One reading alone is none.
725
- // The language the customer writes in comes along when the run knows it. It
726
- // can be missing, when they wrote too little to tell by, and it can be another
727
- // than the reply's, when a rep asked for the reply in a language of their
728
- // choosing.
709
+ // A language's name on a tab of its own, which starts with a capital also in a
710
+ // language that writes such names without one: "Español" for "español". The
711
+ // capital is the one the pane's language writes, as the dotted "İ" of
712
+ // Turkish. There is a name only where the browser took the pane's language
713
+ // for a tag, so it takes it here too.
714
+ var tabName = function tabName(code, locale) {
715
+ var name = languageName(code, locale);
716
+ if (!name) return null;
717
+ var _name = _toArray(name),
718
+ first = _name[0],
719
+ rest = _name.slice(1);
720
+ return first.toLocaleUpperCase(locale) + rest.join("");
721
+ };
722
+
723
+ // The readings of a suggested reply, as its tabs show them. A reply is in two
724
+ // languages when the run has the language the customer is sent it in and the
725
+ // reply both ways, each a text with something in it: the English reading, and
726
+ // the one the customer is sent. A reply in English that has no other reading,
727
+ // for a customer who writes English or too little to tell by, has the English
728
+ // reading alone, which is the reply as written. The run says so by naming
729
+ // English as the reply's language. One reading of a reply in another language
730
+ // is none.
729
731
  var replyReadings = function replyReadings(_ref) {
730
- var customerLanguage = _ref.customerLanguage,
732
+ var suggestedReply = _ref.suggestedReply,
731
733
  suggestedReplyInCustomerLanguage = _ref.suggestedReplyInCustomerLanguage,
732
734
  suggestedReplyInEnglish = _ref.suggestedReplyInEnglish,
733
735
  suggestedReplyLanguage = _ref.suggestedReplyLanguage;
736
+ if (isEnglish(suggestedReplyLanguage)) {
737
+ return hasText(suggestedReply) ? {
738
+ english: inEnglish(suggestedReply),
739
+ customer: null
740
+ } : null;
741
+ }
734
742
  var isInTwoLanguages = [suggestedReplyLanguage, suggestedReplyInCustomerLanguage, suggestedReplyInEnglish].every(hasText);
735
743
  if (!isInTwoLanguages) return null;
736
744
  return {
@@ -739,8 +747,7 @@ var replyReadings = function replyReadings(_ref) {
739
747
  dir: directionOf(suggestedReplyLanguage, suggestedReplyInCustomerLanguage),
740
748
  lang: suggestedReplyLanguage,
741
749
  text: suggestedReplyInCustomerLanguage
742
- },
743
- customerLanguage: hasText(customerLanguage) ? customerLanguage : null
750
+ }
744
751
  };
745
752
  };
746
753
 
@@ -779,36 +786,27 @@ var languageName = function languageName(code, locale) {
779
786
  }
780
787
  };
781
788
 
782
- // What the card of a reply in two languages says: the line under the reply,
783
- // the link that turns the card either way, and the two buttons that hand a
784
- // reading to the host. The link and the buttons name the language of the
785
- // reading the customer is sent. The line says the customer writes in it when
786
- // they do, and otherwise only that the reply is in it: the customer may write
787
- // in another language, or in one nobody could tell. What the customer writes
788
- // in is named by their own tag, which may say more than the reply's ("pt-PT"
789
- // beside "pt-BR"), and by the reply's when the browser has no name for it.
790
- // Every sentence has a form without a name, for a language the browser has no
791
- // name for. The names come from the browser and not from a customer, so they
792
- // are safe to hand to the translator.
793
- var replyWords = function replyWords(t, locale, _ref3) {
794
- var _languageName;
789
+ // The tabs of a suggested reply, in the order the card shows them: the reading
790
+ // the customer is sent first, then the English one. A reply in English that
791
+ // has no other reading has its English tab alone. A tab is named by its
792
+ // language, in the language the pane is in, and by the translation file where
793
+ // the browser has no name for it, so the pane never shows a tag to a person.
794
+ // The names come from the browser and not from a customer.
795
+ var replyTabs = function replyTabs(t, locale, _ref3) {
796
+ var _tabName, _tabName2;
795
797
  var customer = _ref3.customer,
796
- customerLanguage = _ref3.customerLanguage;
797
- var theirs = languageName(customer.lang, locale);
798
- var english = languageName(ENGLISH, locale);
799
- return {
800
- line: isSameLanguage(customerLanguage, customer.lang) ? customerWritesIn(t, (_languageName = languageName(customerLanguage, locale)) !== null && _languageName !== void 0 ? _languageName : theirs) : replyIsIn(t, theirs),
801
- showCustomer: theirs ? t("neetoAssist.languages.showIn", {
802
- language: theirs
803
- }) : t("neetoAssist.languages.showInTheirLanguage"),
804
- showEnglish: showInEnglish(t, english),
805
- useCustomer: theirs ? t("neetoAssist.languages.useIn", {
806
- language: theirs
807
- }) : t("neetoAssist.languages.useInTheirLanguage"),
808
- useEnglish: english ? t("neetoAssist.languages.useIn", {
809
- language: english
810
- }) : t("neetoAssist.languages.useInEnglish")
798
+ english = _ref3.english;
799
+ var englishTab = {
800
+ value: ENGLISH_TAB,
801
+ label: (_tabName = tabName(ENGLISH, locale)) !== null && _tabName !== void 0 ? _tabName : t("neetoAssist.languages.english"),
802
+ reading: english
811
803
  };
804
+ if (!customer) return [englishTab];
805
+ return [{
806
+ value: CUSTOMER_TAB,
807
+ label: (_tabName2 = tabName(customer.lang, locale)) !== null && _tabName2 !== void 0 ? _tabName2 : t("neetoAssist.languages.customerLanguage"),
808
+ reading: customer
809
+ }, englishTab];
812
810
  };
813
811
 
814
812
  // What "Customer wrote" says under the customer's words: that they were
@@ -828,8 +826,8 @@ var questionWords = function questionWords(t, locale, customerLanguage) {
828
826
  };
829
827
  };
830
828
 
831
- function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
832
- function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
829
+ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
830
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
833
831
  var isSettled = function isSettled(_ref) {
834
832
  var status = _ref.status;
835
833
  return SETTLED_ACTION_STATUSES.includes(status);
@@ -851,7 +849,7 @@ var answeredAction = function answeredAction(_ref2) {
851
849
  if (status === 409) return body === null || body === void 0 ? void 0 : body.action;
852
850
  if (status === 422 && isApply) {
853
851
  var _body$message, _body$action;
854
- return _objectSpread$4(_objectSpread$4({}, body === null || body === void 0 ? void 0 : body.action), {}, {
852
+ return _objectSpread$3(_objectSpread$3({}, body === null || body === void 0 ? void 0 : body.action), {}, {
855
853
  status: "failed",
856
854
  error: (_body$message = body === null || body === void 0 ? void 0 : body.message) !== null && _body$message !== void 0 ? _body$message : body === null || body === void 0 || (_body$action = body.action) === null || _body$action === void 0 ? void 0 : _body$action.error
857
855
  });
@@ -866,7 +864,7 @@ var answeredAction = function answeredAction(_ref2) {
866
864
  var shownAction = function shownAction(action, answer) {
867
865
  if (!answer || isSettled(action)) return action;
868
866
  var answered = answeredAction(answer);
869
- return answered && isSettled(answered) ? _objectSpread$4(_objectSpread$4({}, action), answered) : action;
867
+ return answered && isSettled(answered) ? _objectSpread$3(_objectSpread$3({}, action), answered) : action;
870
868
  };
871
869
 
872
870
  // The long text an action will save or send, while it is suggested or being
@@ -943,8 +941,8 @@ var MAX_TABLE_CELLS = MAX_TABLE_COLUMNS * (MAX_TABLE_ROWS + 1);
943
941
  var ESCAPED_PIPE_PATTERN = /\\\|/g;
944
942
  var UNSAFE_HTML_CHARACTERS = /[&<>"']/g;
945
943
 
946
- function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
947
- function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
944
+ function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
945
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
948
946
  var escapeHtmlCharacter = function escapeHtmlCharacter(character) {
949
947
  switch (character) {
950
948
  case "&":
@@ -1241,7 +1239,7 @@ var parseLightMarkdown = function parseLightMarkdown() {
1241
1239
  } else if (listItem) {
1242
1240
  var _openBlock;
1243
1241
  if (((_openBlock = openBlock) === null || _openBlock === void 0 ? void 0 : _openBlock.type) !== listItem.type) {
1244
- startBlock(_objectSpread$3({
1242
+ startBlock(_objectSpread$2({
1245
1243
  type: listItem.type,
1246
1244
  items: []
1247
1245
  }, listItem.number === undefined ? {} : {
@@ -1738,8 +1736,8 @@ var Outcome = function Outcome(_ref) {
1738
1736
  return null;
1739
1737
  };
1740
1738
 
1741
- function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1742
- function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1739
+ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1740
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1743
1741
  var Card$1 = function Card(_ref) {
1744
1742
  var action = _ref.action,
1745
1743
  conversationId = _ref.conversationId,
@@ -1755,7 +1753,7 @@ var Card$1 = function Card(_ref) {
1755
1753
  // The host is told through the hook, which still hears the answer to a
1756
1754
  // click when this card is gone by then.
1757
1755
  var _useApplyAction = useApplyAction(conversationId, function (applied) {
1758
- return onActionApplied === null || onActionApplied === void 0 ? void 0 : onActionApplied(_objectSpread$2(_objectSpread$2({}, action), applied));
1756
+ return onActionApplied === null || onActionApplied === void 0 ? void 0 : onActionApplied(_objectSpread$1(_objectSpread$1({}, action), applied));
1759
1757
  }),
1760
1758
  apply = _useApplyAction.mutate,
1761
1759
  isApplying = _useApplyAction.isPending;
@@ -1921,34 +1919,36 @@ var Sources = function Sources(_ref) {
1921
1919
  });
1922
1920
  };
1923
1921
 
1924
- var _excluded = ["onUseReply", "reading"];
1925
- function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1926
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1927
1922
  var handOver = function handOver(onUseReply, text) {
1928
1923
  return onUseReply(replyText(text), lightMarkdownToHtml(text));
1929
1924
  };
1925
+ var Heading = function Heading(_ref) {
1926
+ var t = _ref.t;
1927
+ return /*#__PURE__*/jsx(Typography, {
1928
+ color: "muted",
1929
+ variant: "body3",
1930
+ weight: "medium",
1931
+ children: t("neetoAssist.run.suggestedReply")
1932
+ });
1933
+ };
1930
1934
 
1931
- // The frame and the heading that a reply as written and a reply in two
1932
- // languages share.
1933
- var Card = function Card(_ref) {
1934
- var children = _ref.children,
1935
- t = _ref.t;
1935
+ // The frame and the heading of a reply as written.
1936
+ var Card = function Card(_ref2) {
1937
+ var children = _ref2.children,
1938
+ t = _ref2.t;
1936
1939
  return /*#__PURE__*/jsxs("div", {
1937
1940
  className: "border-border space-y-2 rounded-lg border p-3",
1938
- children: [/*#__PURE__*/jsx(Typography, {
1939
- color: "muted",
1940
- variant: "body3",
1941
- weight: "medium",
1942
- children: t("neetoAssist.run.suggestedReply")
1941
+ children: [/*#__PURE__*/jsx(Heading, {
1942
+ t: t
1943
1943
  }), children]
1944
1944
  });
1945
1945
  };
1946
1946
 
1947
1947
  // Copies the reply that is showing, as NeetoAssist wrote it, and says so in a
1948
1948
  // toast.
1949
- var CopyButton = function CopyButton(_ref2) {
1950
- var t = _ref2.t,
1951
- text = _ref2.text;
1949
+ var CopyButton = function CopyButton(_ref3) {
1950
+ var t = _ref3.t,
1951
+ text = _ref3.text;
1952
1952
  return /*#__PURE__*/jsx(Button, {
1953
1953
  "data-testid": "neeto-assist-copy-reply-button",
1954
1954
  icon: Copy,
@@ -1963,106 +1963,93 @@ var CopyButton = function CopyButton(_ref2) {
1963
1963
  });
1964
1964
  };
1965
1965
 
1966
- // Hands the host one of a reply's two readings. Its name carries the name of a
1967
- // language, which can be long in a narrow pane ("Use in Brazilian Portuguese"),
1968
- // so the name wraps inside the button and the button never grows wider than
1969
- // the card.
1970
- var UseReading = function UseReading(_ref3) {
1971
- var onUseReply = _ref3.onUseReply,
1972
- reading = _ref3.reading,
1973
- buttonProps = _objectWithoutProperties(_ref3, _excluded);
1974
- return /*#__PURE__*/jsx(Button, _objectSpread$1(_objectSpread$1({}, buttonProps), {}, {
1975
- className: "h-auto min-h-7 max-w-full py-1 whitespace-normal",
1976
- icon: CornerDownLeft,
1977
- size: "sm",
1978
- onClick: function onClick() {
1979
- return handOver(onUseReply, reading.text);
1980
- }
1981
- }));
1982
- };
1983
-
1984
- // A reply that came in English and in the language the customer is sent it
1985
- // in, for a rep who reads English. The card shows the English reading. The
1986
- // link under it turns the card to what the customer will read, and back, and
1987
- // the rep picks which of the two goes to the composer. Copy copies the one
1988
- // that is showing. The card remembers its turn only while it is on screen.
1966
+ // A reply in the language the customer is sent it in and in English, for a
1967
+ // rep who reads English. Beside the heading is a tab for each, named by its
1968
+ // language: the customer's first, and showing to begin with, then English.
1969
+ // Use reply and Copy take the reading of the tab that is showing. A reply in
1970
+ // English that has no other reading has its English tab alone. The card
1971
+ // remembers its tab only while it is on screen.
1989
1972
  // The block that holds a reading names its language, so a screen reader picks
1990
- // the right voice, and it is read out again, whole, when the card turns. Its
1991
- // direction comes from that language too, so an Arabic reading that opens
1992
- // with the name of a product still reads right to left.
1993
- // The link stays the same button through a turn, so the keyboard stays on it.
1973
+ // the right voice. Its direction comes from that language too, so an Arabic
1974
+ // reading that opens with the name of a product still reads right to left.
1975
+ // A language's name can be long in a narrow pane ("Brazilian Portuguese"), so
1976
+ // the tabs go under the heading when the two do not fit side by side, and a
1977
+ // name that is still too long is cut short.
1994
1978
  var Readings = function Readings(_ref4) {
1979
+ var _findBy;
1995
1980
  var onUseReply = _ref4.onUseReply,
1996
1981
  readings = _ref4.readings;
1997
1982
  var _useTranslation = useTranslation(),
1998
1983
  t = _useTranslation.t,
1999
1984
  i18n = _useTranslation.i18n;
2000
- var _useState = useState(false),
1985
+ var _useState = useState(null),
2001
1986
  _useState2 = _slicedToArray(_useState, 2),
2002
- isInCustomerLanguage = _useState2[0],
2003
- setIsInCustomerLanguage = _useState2[1];
2004
- var customer = readings.customer,
2005
- english = readings.english;
2006
- var words = replyWords(t, i18n.resolvedLanguage, readings);
2007
- var shown = isInCustomerLanguage ? customer : english;
2008
- return /*#__PURE__*/jsxs(Card, {
2009
- t: t,
2010
- children: [/*#__PURE__*/jsx("div", {
2011
- "aria-atomic": "true",
2012
- "aria-live": "polite",
1987
+ chosen = _useState2[0],
1988
+ setChosen = _useState2[1];
1989
+ var tabs = replyTabs(t, i18n.resolvedLanguage, readings);
1990
+ var shown = (_findBy = findBy({
1991
+ value: chosen
1992
+ }, tabs)) !== null && _findBy !== void 0 ? _findBy : tabs[0];
1993
+ return /*#__PURE__*/jsxs(Tabs, {
1994
+ className: "border-border flex flex-col gap-2 rounded-lg border p-3",
1995
+ "data-testid": "neeto-assist-reply-tabs",
1996
+ value: shown.value,
1997
+ onValueChange: setChosen,
1998
+ children: [/*#__PURE__*/jsxs("div", {
1999
+ className: "flex flex-wrap items-center justify-between gap-2",
2000
+ children: [/*#__PURE__*/jsx(Heading, {
2001
+ t: t
2002
+ }), /*#__PURE__*/jsx(Tabs.List, {
2003
+ "aria-label": t("neetoAssist.languages.replyLanguage"),
2004
+ className: "max-w-full",
2005
+ children: tabs.map(function (_ref5) {
2006
+ var label = _ref5.label,
2007
+ value = _ref5.value;
2008
+ return /*#__PURE__*/createElement(Tabs.Item, {
2009
+ value: value,
2010
+ className: "min-w-0 flex-initial",
2011
+ "data-testid": "neeto-assist-reply-".concat(value, "-tab"),
2012
+ key: value
2013
+ }, /*#__PURE__*/jsx("span", {
2014
+ className: "truncate",
2015
+ children: label
2016
+ }));
2017
+ })
2018
+ })]
2019
+ }), /*#__PURE__*/jsx(Tabs.Content, {
2013
2020
  "data-testid": "neeto-assist-reply-reading",
2014
- dir: shown.dir,
2015
- lang: shown.lang,
2021
+ dir: shown.reading.dir,
2022
+ lang: shown.reading.lang,
2023
+ value: shown.value,
2016
2024
  children: /*#__PURE__*/jsx(FormattedText, {
2017
- text: shown.text
2025
+ text: shown.reading.text
2018
2026
  })
2019
2027
  }), /*#__PURE__*/jsxs("div", {
2020
- className: "flex flex-wrap items-baseline gap-x-1.5",
2021
- children: [/*#__PURE__*/jsx(Typography, {
2022
- color: "muted",
2023
- "data-testid": "neeto-assist-reply-language",
2024
- variant: "body3",
2025
- children: words.line
2026
- }), /*#__PURE__*/jsx(Button, {
2027
- className: "max-w-full text-start whitespace-normal",
2028
- "data-testid": "neeto-assist-reply-language-toggle",
2029
- label: isInCustomerLanguage ? words.showEnglish : words.showCustomer,
2030
- variant: "link",
2028
+ className: "flex flex-wrap gap-2",
2029
+ children: [onUseReply && /*#__PURE__*/jsx(Button, {
2030
+ "data-testid": "neeto-assist-use-reply-button",
2031
+ icon: CornerDownLeft,
2032
+ label: t("neetoAssist.run.useReply"),
2033
+ size: "sm",
2031
2034
  onClick: function onClick() {
2032
- return setIsInCustomerLanguage(not);
2035
+ return handOver(onUseReply, shown.reading.text);
2033
2036
  }
2034
- })]
2035
- }), /*#__PURE__*/jsxs("div", {
2036
- className: "flex flex-wrap gap-2",
2037
- children: [onUseReply && /*#__PURE__*/jsxs(Fragment$1, {
2038
- children: [/*#__PURE__*/jsx(UseReading, {
2039
- onUseReply: onUseReply,
2040
- "data-testid": "neeto-assist-use-reply-button",
2041
- label: words.useCustomer,
2042
- reading: customer
2043
- }), /*#__PURE__*/jsx(UseReading, {
2044
- onUseReply: onUseReply,
2045
- "data-testid": "neeto-assist-use-english-reply-button",
2046
- label: words.useEnglish,
2047
- reading: english,
2048
- variant: "outline"
2049
- })]
2050
2037
  }), /*#__PURE__*/jsx(CopyButton, {
2051
2038
  t: t,
2052
- text: shown.text
2039
+ text: shown.reading.text
2053
2040
  })]
2054
2041
  })]
2055
2042
  });
2056
2043
  };
2057
2044
 
2058
2045
  // A reply as NeetoAssist wrote it, with "Use reply" for a host that has a
2059
- // composer, and "Copy". A run that carries the reply in English and in the
2060
- // language the customer is sent it in shows its two readings instead.
2061
- var SuggestedReply$1 = function SuggestedReply(_ref5) {
2062
- var onUseReply = _ref5.onUseReply,
2063
- readings = _ref5.readings,
2064
- t = _ref5.t,
2065
- text = _ref5.text;
2046
+ // composer, and "Copy". A run that names the language of its reply shows its
2047
+ // readings in tabs instead.
2048
+ var SuggestedReply$1 = function SuggestedReply(_ref6) {
2049
+ var onUseReply = _ref6.onUseReply,
2050
+ readings = _ref6.readings,
2051
+ t = _ref6.t,
2052
+ text = _ref6.text;
2066
2053
  return readings ? /*#__PURE__*/jsx(Readings, {
2067
2054
  onUseReply: onUseReply,
2068
2055
  readings: readings