@bigbinary/neeto-assist-frontend 1.1.0 → 1.2.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 (59) hide show
  1. package/README.md +193 -41
  2. package/app/javascript/src/translations/ar.json +27 -4
  3. package/app/javascript/src/translations/bg.json +27 -4
  4. package/app/javascript/src/translations/ca.json +27 -4
  5. package/app/javascript/src/translations/cs.json +27 -4
  6. package/app/javascript/src/translations/da.json +27 -4
  7. package/app/javascript/src/translations/de.json +27 -4
  8. package/app/javascript/src/translations/en.json +6 -0
  9. package/app/javascript/src/translations/es-MX.json +27 -4
  10. package/app/javascript/src/translations/es.json +27 -4
  11. package/app/javascript/src/translations/et.json +27 -4
  12. package/app/javascript/src/translations/fi.json +27 -4
  13. package/app/javascript/src/translations/fil.json +27 -4
  14. package/app/javascript/src/translations/fr.json +27 -4
  15. package/app/javascript/src/translations/he.json +27 -4
  16. package/app/javascript/src/translations/hi.json +27 -4
  17. package/app/javascript/src/translations/hr.json +27 -4
  18. package/app/javascript/src/translations/hu.json +27 -4
  19. package/app/javascript/src/translations/id.json +27 -4
  20. package/app/javascript/src/translations/it.json +27 -4
  21. package/app/javascript/src/translations/ja.json +27 -4
  22. package/app/javascript/src/translations/ko.json +27 -4
  23. package/app/javascript/src/translations/lv.json +27 -4
  24. package/app/javascript/src/translations/nl.json +27 -4
  25. package/app/javascript/src/translations/pl.json +27 -4
  26. package/app/javascript/src/translations/pt-BR.json +27 -4
  27. package/app/javascript/src/translations/pt.json +27 -4
  28. package/app/javascript/src/translations/ro.json +27 -4
  29. package/app/javascript/src/translations/ru.json +27 -4
  30. package/app/javascript/src/translations/sk.json +27 -4
  31. package/app/javascript/src/translations/sl.json +27 -4
  32. package/app/javascript/src/translations/sv.json +27 -4
  33. package/app/javascript/src/translations/th.json +27 -4
  34. package/app/javascript/src/translations/tr.json +27 -4
  35. package/app/javascript/src/translations/uk.json +27 -4
  36. package/app/javascript/src/translations/vi.json +27 -4
  37. package/app/javascript/src/translations/zh-CN.json +27 -4
  38. package/app/javascript/src/translations/zh-TW.json +27 -4
  39. package/dist/.ready +1 -1
  40. package/dist/NeetoAssistButton.js +3 -1
  41. package/dist/NeetoAssistButton.js.map +1 -1
  42. package/dist/NeetoAssistPane.js +586 -329
  43. package/dist/NeetoAssistPane.js.map +1 -1
  44. package/dist/cjs/NeetoAssistButton.js +3 -1
  45. package/dist/cjs/NeetoAssistButton.js.map +1 -1
  46. package/dist/cjs/NeetoAssistPane.js +575 -318
  47. package/dist/cjs/NeetoAssistPane.js.map +1 -1
  48. package/dist/cjs/index.js +3 -1
  49. package/dist/cjs/index.js.map +1 -1
  50. package/dist/index.js +3 -1
  51. package/dist/index.js.map +1 -1
  52. package/dist/{useNeetoAssistStore--JwP_Upt.js → useNeetoAssistStore-InICsbe8.js} +89 -6
  53. package/dist/useNeetoAssistStore-InICsbe8.js.map +1 -0
  54. package/dist/{useNeetoAssistStore-CGEUMbes.js → useNeetoAssistStore-VaZp3268.js} +91 -4
  55. package/dist/useNeetoAssistStore-VaZp3268.js.map +1 -0
  56. package/package.json +1 -1
  57. package/types.d.ts +31 -6
  58. package/dist/useNeetoAssistStore--JwP_Upt.js.map +0 -1
  59. package/dist/useNeetoAssistStore-CGEUMbes.js.map +0 -1
package/dist/cjs/index.js CHANGED
@@ -7,13 +7,15 @@ require('@babel/runtime/helpers/defineProperty');
7
7
  require('react');
8
8
  require('@bigbinary/neeto-atoms');
9
9
  require('react-i18next');
10
- require('../useNeetoAssistStore-CGEUMbes.js');
10
+ require('../useNeetoAssistStore-VaZp3268.js');
11
11
  require('@babel/runtime/helpers/objectWithoutProperties');
12
12
  require('react/jsx-runtime');
13
13
  require('@tanstack/react-query');
14
14
  require('@bigbinary/neeto-commons-frontend/v2/react-utils');
15
15
  require('../neeto_assist-CznTN_YY.js');
16
16
  require('axios');
17
+ require('@babel/runtime/helpers/toConsumableArray');
18
+ require('@babel/runtime/helpers/toArray');
17
19
  require('ramda');
18
20
  require('@bigbinary/neeto-commons-frontend/v2/utils');
19
21
  require('zustand');
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -5,13 +5,15 @@ import '@babel/runtime/helpers/defineProperty';
5
5
  import 'react';
6
6
  import '@bigbinary/neeto-atoms';
7
7
  import 'react-i18next';
8
- import './useNeetoAssistStore--JwP_Upt.js';
8
+ import './useNeetoAssistStore-InICsbe8.js';
9
9
  import '@babel/runtime/helpers/objectWithoutProperties';
10
10
  import 'react/jsx-runtime';
11
11
  import '@tanstack/react-query';
12
12
  import '@bigbinary/neeto-commons-frontend/v2/react-utils';
13
13
  import './neeto_assist-CpUBA-3Z.js';
14
14
  import 'axios';
15
+ import '@babel/runtime/helpers/toConsumableArray';
16
+ import '@babel/runtime/helpers/toArray';
15
17
  import 'ramda';
16
18
  import '@bigbinary/neeto-commons-frontend/v2/utils';
17
19
  import 'zustand';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;"}
@@ -4,7 +4,9 @@ import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
5
5
  import { useMutationWithInvalidation, withImmutableActions } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
6
6
  import { E as ERROR_MESSAGE_KEYS, P as PENDING_STATUSES, S as SKIPPED_REASON_MESSAGE_KEYS, R as RATEABLE_STATUSES, U as UNRATEABLE_SKIPPED_REASONS, a as REPLY_SUGGESTION, b as QUIET_SKIPPED_REASONS, n as neetoAssistApi, Q as QUERY_KEYS, c as PENDING_POLL_INTERVAL, I as IDLE_POLL_INTERVAL, d as EXPANDED_STORAGE_KEY } from './neeto_assist-CpUBA-3Z.js';
7
- import { propOr, any, propEq, reverse } from 'ramda';
7
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
8
+ import _toArray from '@babel/runtime/helpers/toArray';
9
+ import { isEmpty, any, propEq, propOr, reverse } from 'ramda';
8
10
  import { setToLocalStorage, getFromLocalStorage } from '@bigbinary/neeto-commons-frontend/v2/utils';
9
11
  import { create } from 'zustand';
10
12
 
@@ -39,6 +41,84 @@ var Sparkle = function Sparkle(_ref) {
39
41
  }));
40
42
  };
41
43
 
44
+ var wordsOf = function wordsOf(text) {
45
+ return text.toLowerCase().split(/\s+/).filter(Boolean);
46
+ };
47
+
48
+ // The commands as the engine listed them with the runs. It lists only what has
49
+ // a name, a title and a description, and an older engine lists none. Anything
50
+ // else that turns up is left out here, so a menu never has a row it cannot
51
+ // show.
52
+ var commandsOf = function commandsOf(commands) {
53
+ return (Array.isArray(commands) ? commands : []).filter(function (command) {
54
+ return [command === null || command === void 0 ? void 0 : command.name, command === null || command === void 0 ? void 0 : command.title, command === null || command === void 0 ? void 0 : command.description].every(function (text) {
55
+ return typeof text === "string";
56
+ });
57
+ });
58
+ };
59
+
60
+ // What a rep has typed of a command so far: the text after the "/", in lower
61
+ // case, or null when the box holds no command being typed. That is so once
62
+ // the text runs on to another line, and once a full name has a space after
63
+ // it: the command is chosen then, and what follows are the rep's own words.
64
+ var typedCommand = function typedCommand(text, commands) {
65
+ if (!text.startsWith("/") || text.includes("\n")) return null;
66
+ var typed = text.slice(1).toLowerCase();
67
+ var _typed$split = typed.split(/\s/),
68
+ _typed$split2 = _toArray(_typed$split),
69
+ name = _typed$split2[0],
70
+ rest = _typed$split2.slice(1);
71
+ var isChosen = !isEmpty(rest) && any(propEq(name, "name"), commands);
72
+ return isChosen ? null : typed;
73
+ };
74
+
75
+ // The commands that fit what was typed, as the menu lists them: all of them
76
+ // after a bare "/", otherwise those whose name starts with what was typed,
77
+ // then those whose title has a word that starts with each word typed.
78
+ var matchingCommands = function matchingCommands(text, commands) {
79
+ var typed = typedCommand(text, commands);
80
+ if (typed === null) return [];
81
+ var words = wordsOf(typed);
82
+ if (isEmpty(words)) return commands;
83
+ var fitsName = function fitsName(_ref) {
84
+ var name = _ref.name;
85
+ return words.length === 1 && name.startsWith(words[0]);
86
+ };
87
+ var fitsTitle = function fitsTitle(_ref2) {
88
+ var title = _ref2.title;
89
+ return words.every(function (word) {
90
+ return wordsOf(title).some(function (titleWord) {
91
+ return titleWord.startsWith(word);
92
+ });
93
+ });
94
+ };
95
+ return [].concat(_toConsumableArray(commands.filter(fitsName)), _toConsumableArray(commands.filter(function (command) {
96
+ return !fitsName(command) && fitsTitle(command);
97
+ })));
98
+ };
99
+
100
+ // What the box holds once a command is picked: the command and a space, for
101
+ // the rep to add words after or to send as it is.
102
+ var pickedCommand = function pickedCommand(_ref3) {
103
+ var name = _ref3.name;
104
+ return "/".concat(name, " ");
105
+ };
106
+
107
+ // The id of a command's row in the menu, which the box points at while the
108
+ // row is the marked one.
109
+ var optionId = function optionId(menuId, _ref4) {
110
+ var name = _ref4.name;
111
+ return "".concat(menuId, "-").concat(name);
112
+ };
113
+
114
+ // The command at the start of a question, as the rep typed it, or null for a
115
+ // question that NeetoAssist did not read as a command.
116
+ var commandPart = function commandPart(question, command) {
117
+ if (!command || typeof question !== "string") return null;
118
+ var typed = question.slice(0, command.length + 1);
119
+ return typed.toLowerCase() === "/".concat(command).toLowerCase() ? typed : null;
120
+ };
121
+
42
122
  // While a quiet rule holds, NeetoAssist skips every visitor message for the
43
123
  // same reason. One note says it, so of skips in a row for one of these
44
124
  // reasons, only the latest stays. Runs are in conversation order.
@@ -146,7 +226,8 @@ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t
146
226
 
147
227
  // Fresh on every mount, then polled: quickly while NeetoAssist is working on a
148
228
  // run, slowly otherwise. A failed poll is retried by the next one and never
149
- // shown as a toast. Comes with the workspace's credit state.
229
+ // shown as a toast. Comes with the workspace's credit state, and with the
230
+ // commands a rep can pick in the box, which an older engine does not list.
150
231
  var useFetchRuns = function useFetchRuns(conversationId) {
151
232
  return useQuery({
152
233
  queryKey: [QUERY_KEYS.RUNS, conversationId],
@@ -157,10 +238,12 @@ var useFetchRuns = function useFetchRuns(conversationId) {
157
238
  var _ref$runs = _ref.runs,
158
239
  runs = _ref$runs === void 0 ? [] : _ref$runs,
159
240
  _ref$credits = _ref.credits,
160
- credits = _ref$credits === void 0 ? null : _ref$credits;
241
+ credits = _ref$credits === void 0 ? null : _ref$credits,
242
+ commands = _ref.commands;
161
243
  return {
162
244
  runs: runs,
163
- credits: credits
245
+ credits: credits,
246
+ commands: commandsOf(commands)
164
247
  };
165
248
  },
166
249
  staleTime: 0,
@@ -273,5 +356,5 @@ var useNeetoAssistStore = create(withImmutableActions(function (set) {
273
356
  };
274
357
  }));
275
358
 
276
- export { Sparkle as S, useFetchRuns as a, useAskNeetoAssist as b, useApplyAction as c, useDismissAction as d, errorMessageKey as e, actionsOf as f, useUpdateFeedback as g, isPending as h, isWebUrl as i, hasRunningStep as j, hasWrittenReply as k, latestDraftId as l, skippedReasonMessageKey as m, isRateable as n, runsInConversationOrder as r, stepsOf as s, useNeetoAssistStore as u };
277
- //# sourceMappingURL=useNeetoAssistStore--JwP_Upt.js.map
359
+ export { Sparkle as S, useFetchRuns as a, useAskNeetoAssist as b, useApplyAction as c, useDismissAction as d, errorMessageKey as e, actionsOf as f, useUpdateFeedback as g, commandPart as h, isWebUrl as i, isPending as j, hasRunningStep as k, latestDraftId as l, matchingCommands as m, hasWrittenReply as n, optionId as o, pickedCommand as p, skippedReasonMessageKey as q, isRateable as r, stepsOf as s, runsInConversationOrder as t, useNeetoAssistStore as u };
360
+ //# sourceMappingURL=useNeetoAssistStore-InICsbe8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNeetoAssistStore-InICsbe8.js","sources":["../app/javascript/src/components/commons/Sparkle.jsx","../app/javascript/src/utils/commands.js","../app/javascript/src/utils/collapseRepeatedSkips.js","../app/javascript/src/utils/runs.js","../app/javascript/src/hooks/reactQuery/useRunsApi.js","../app/javascript/src/stores/useNeetoAssistStore.js"],"sourcesContent":["const Sparkle = ({ size = 18, className, ...otherProps }) => (\n <svg\n {...{ className }}\n aria-hidden=\"true\"\n fill=\"none\"\n height={size}\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"1.5\"\n viewBox=\"0 0 18 18\"\n width={size}\n xmlns=\"http://www.w3.org/2000/svg\"\n {...otherProps}\n >\n <path\n d=\"M5.658 2.99L4.395 2.569L3.974 1.306C3.837 0.898 3.162 0.898 3.025 1.306L2.604 2.569L1.341 2.99C1.137 3.058 0.999 3.249 0.999 3.464C0.999 3.679 1.137 3.87 1.341 3.938L2.604 4.359L3.025 5.622C3.093 5.826 3.285 5.964 3.5 5.964C3.715 5.964 3.906 5.826 3.975 5.622L4.396 4.359L5.659 3.938C5.863 3.87 6.001 3.679 6.001 3.464C6.001 3.249 5.862 3.058 5.658 2.99Z\"\n fill=\"currentColor\"\n stroke=\"none\"\n />\n <path d=\"M9.5 2.75L11.412 7.587L16.25 9.5L11.412 11.413L9.5 16.25L7.587 11.413L2.75 9.5L7.587 7.587L9.5 2.75Z\" />\n </svg>\n);\n\nexport default Sparkle;\n","// A command is a named way to ask NeetoAssist for one of the things it can do\n// here. A rep types \"/\" in the box, picks a command from the menu and may add\n// a few words. The engine lists the commands with the runs: NeetoAssist's own,\n// then those of the host's actions this rep is offered.\nimport { any, isEmpty, propEq } from \"ramda\";\n\nconst wordsOf = text => text.toLowerCase().split(/\\s+/).filter(Boolean);\n\n// The commands as the engine listed them with the runs. It lists only what has\n// a name, a title and a description, and an older engine lists none. Anything\n// else that turns up is left out here, so a menu never has a row it cannot\n// show.\nexport const commandsOf = commands =>\n (Array.isArray(commands) ? commands : []).filter(command =>\n [command?.name, command?.title, command?.description].every(\n text => typeof text === \"string\"\n )\n );\n\n// What a rep has typed of a command so far: the text after the \"/\", in lower\n// case, or null when the box holds no command being typed. That is so once\n// the text runs on to another line, and once a full name has a space after\n// it: the command is chosen then, and what follows are the rep's own words.\nexport const typedCommand = (text, commands) => {\n if (!text.startsWith(\"/\") || text.includes(\"\\n\")) return null;\n\n const typed = text.slice(1).toLowerCase();\n const [name, ...rest] = typed.split(/\\s/);\n const isChosen = !isEmpty(rest) && any(propEq(name, \"name\"), commands);\n\n return isChosen ? null : typed;\n};\n\n// The commands that fit what was typed, as the menu lists them: all of them\n// after a bare \"/\", otherwise those whose name starts with what was typed,\n// then those whose title has a word that starts with each word typed.\nexport const matchingCommands = (text, commands) => {\n const typed = typedCommand(text, commands);\n if (typed === null) return [];\n\n const words = wordsOf(typed);\n if (isEmpty(words)) return commands;\n\n const fitsName = ({ name }) =>\n words.length === 1 && name.startsWith(words[0]);\n\n const fitsTitle = ({ title }) =>\n words.every(word =>\n wordsOf(title).some(titleWord => titleWord.startsWith(word))\n );\n\n return [\n ...commands.filter(fitsName),\n ...commands.filter(command => !fitsName(command) && fitsTitle(command)),\n ];\n};\n\n// What the box holds once a command is picked: the command and a space, for\n// the rep to add words after or to send as it is.\nexport const pickedCommand = ({ name }) => `/${name} `;\n\n// The id of a command's row in the menu, which the box points at while the\n// row is the marked one.\nexport const optionId = (menuId, { name }) => `${menuId}-${name}`;\n\n// The command at the start of a question, as the rep typed it, or null for a\n// question that NeetoAssist did not read as a command.\nexport const commandPart = (question, command) => {\n if (!command || typeof question !== \"string\") return null;\n\n const typed = question.slice(0, command.length + 1);\n\n return typed.toLowerCase() === `/${command}`.toLowerCase() ? typed : null;\n};\n","// While a quiet rule holds, NeetoAssist skips every visitor message for the\n// same reason. One note says it, so of skips in a row for one of these\n// reasons, only the latest stays. Runs are in conversation order.\nexport const collapseRepeatedSkips = (runs, reasons) =>\n runs.filter((run, index) => {\n const next = runs[index + 1];\n\n return !(\n reasons.includes(run.skippedReason) &&\n next?.skippedReason === run.skippedReason\n );\n });\n","import { any, propEq, propOr, reverse } from \"ramda\";\n\nimport {\n ERROR_MESSAGE_KEYS,\n PENDING_STATUSES,\n QUIET_SKIPPED_REASONS,\n RATEABLE_STATUSES,\n REPLY_SUGGESTION,\n SKIPPED_REASON_MESSAGE_KEYS,\n UNRATEABLE_SKIPPED_REASONS,\n} from \"common/constants\";\nimport { collapseRepeatedSkips } from \"utils/collapseRepeatedSkips\";\n\n// A reply suggestion that is still waiting gets replaced by a newer one, which\n// answers its messages too, so only the newest shows as being worked on.\nconst withoutReplacedDrafts = runs =>\n runs.filter(\n (run, index) =>\n !(\n run.kind === REPLY_SUGGESTION &&\n run.status === \"queued\" &&\n runs.slice(index + 1).some(({ kind }) => kind === REPLY_SUGGESTION)\n )\n );\n\nexport const isPending = ({ status }) => PENDING_STATUSES.includes(status);\n\nexport const withoutRepeatedQuietSkips = runs =>\n collapseRepeatedSkips(runs, QUIET_SKIPPED_REASONS);\n\n// NeetoAssist lists the newest run first. The pane reads like the conversation\n// instead: oldest at the top, the latest at the bottom. A quiet rule skips every\n// message while it holds, and one note says so.\nexport const runsInConversationOrder = runs =>\n withoutRepeatedQuietSkips(withoutReplacedDrafts(reverse(runs)));\n\n// The newest reply NeetoAssist drafted on its own. Runs are newest first.\nexport const latestDraftId = runs =>\n runs.find(\n ({ kind, suggestedReply }) => kind === REPLY_SUGGESTION && !!suggestedReply\n )?.id;\n\n// A hello is skipped, since nothing was looked up, but it still gets a reply.\nexport const hasWrittenReply = ({ status, answer, suggestedReply }) =>\n status === \"completed\" ||\n (status === \"skipped\" && !!(answer || suggestedReply));\n\n// A rep's own hello or thanks got a friendly line, which is nothing to judge.\nexport const isRateable = ({ kind, status, skippedReason }) =>\n RATEABLE_STATUSES.includes(status) &&\n !UNRATEABLE_SKIPPED_REASONS.includes(skippedReason) &&\n !(kind === \"ask\" && status === \"skipped\");\n\n// What the pane polls quickly for: a run NeetoAssist is still working on. An\n// action someone is applying is not one. The rep who clicked has the answer\n// to the click, and an action whose end NeetoAssist never hears of would keep\n// every open pane polling quickly until NeetoAssist gives up on it.\nexport const hasPendingRun = (runs = []) => runs.some(isPending);\n\n// The lookups NeetoAssist made while answering, in the order they started. A\n// run from an older NeetoAssist carries none.\nexport const stepsOf = ({ steps }) => steps ?? [];\n\nexport const hasRunningStep = run =>\n any(propEq(\"running\", \"status\"), stepsOf(run));\n\n// A suggested action can only be applied once its run has finished. Until then\n// NeetoAssist may still take it back and start over, so its card waits.\nexport const actionsOf = ({ status, actions }) =>\n status === \"completed\" ? (actions ?? []) : [];\n\nexport const skippedReasonMessageKey = reason =>\n propOr(\"neetoAssist.run.skipped\", reason, SKIPPED_REASON_MESSAGE_KEYS);\n\n// No answer at all means the request never reached NeetoAssist.\nexport const errorMessageKey = error => {\n if (!error?.response) return ERROR_MESSAGE_KEYS[503];\n\n return propOr(\n \"neetoAssist.errors.generic\",\n error.response.status,\n ERROR_MESSAGE_KEYS\n );\n};\n\n// Sources come from a knowledge base, so only web links become links.\nexport const isWebUrl = url => /^https?:\\/\\//i.test(url ?? \"\");\n","import { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/v2/react-utils\";\n\nimport neetoAssistApi from \"apis/neeto_assist\";\nimport {\n IDLE_POLL_INTERVAL,\n PENDING_POLL_INTERVAL,\n QUERY_KEYS,\n} from \"common/constants\";\nimport { commandsOf } from \"utils/commands\";\nimport { hasPendingRun } from \"utils/runs\";\n\n// Fresh on every mount, then polled: quickly while NeetoAssist is working on a\n// run, slowly otherwise. A failed poll is retried by the next one and never\n// shown as a toast. Comes with the workspace's credit state, and with the\n// commands a rep can pick in the box, which an older engine does not list.\nconst useFetchRuns = conversationId =>\n useQuery({\n queryKey: [QUERY_KEYS.RUNS, conversationId],\n queryFn: () => neetoAssistApi.fetchRuns(conversationId),\n select: ({ runs = [], credits = null, commands }) => ({\n runs,\n credits,\n commands: commandsOf(commands),\n }),\n staleTime: 0,\n retry: false,\n refetchInterval: ({ state: { data, error } }) =>\n !error && hasPendingRun(data?.runs)\n ? PENDING_POLL_INTERVAL\n : IDLE_POLL_INTERVAL,\n });\n\nconst useAskNeetoAssist = conversationId =>\n useMutationWithInvalidation(neetoAssistApi.createRun, {\n keysToInvalidate: [[QUERY_KEYS.RUNS, conversationId]],\n });\n\nconst useUpdateFeedback = conversationId =>\n useMutationWithInvalidation(neetoAssistApi.updateFeedback, {\n keysToInvalidate: [[QUERY_KEYS.RUNS, conversationId]],\n });\n\n// A click on a card changes what its run shows whether it worked or not: the\n// action was applied, or someone else got to it first, or it expired. So the\n// runs are fetched again either way. The card does not wait for them: the\n// answer to the click already says what happened.\nconst useActOnAction = (mutationFn, conversationId, callbacks = {}) => {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn,\n onSettled: () => {\n queryClient.invalidateQueries({\n queryKey: [QUERY_KEYS.RUNS, conversationId],\n });\n },\n ...callbacks,\n });\n};\n\n// The host hears of an applied action from here and not from the card that\n// was clicked. React Query drops what a card hands to mutate once the card is\n// off the screen, as when the rep opens another conversation before the answer\n// arrives, and the change was made all the same. The click does not wait for\n// the host's handler, so what the handler returns is left alone.\nconst useApplyAction = (conversationId, onApplied) =>\n useActOnAction(neetoAssistApi.applyAction, conversationId, {\n onSuccess: data => {\n onApplied?.(data?.action);\n },\n });\n\nconst useDismissAction = conversationId =>\n useActOnAction(neetoAssistApi.dismissAction, conversationId);\n\nexport {\n useFetchRuns,\n useAskNeetoAssist,\n useUpdateFeedback,\n useApplyAction,\n useDismissAction,\n};\n","import { withImmutableActions } from \"neetocommons/v2/react-utils\";\nimport { getFromLocalStorage, setToLocalStorage } from \"neetocommons/v2/utils\";\nimport { create } from \"zustand\";\n\nimport { EXPANDED_STORAGE_KEY } from \"common/constants\";\n\n// The pane is mounted once in the host's layout and the button sits on the\n// ticket, so this is how they talk: whether the pane is open and how wide, and\n// which conversation it is about. A reload starts closed, and the width is kept.\n/** @type {import(\"neetocommons/react-utils\").ZustandStoreHook} */\nconst useNeetoAssistStore = create(\n withImmutableActions(set => ({\n isOpen: false,\n isExpanded: getFromLocalStorage(EXPANDED_STORAGE_KEY) || false,\n conversation: null,\n seenDrafts: {},\n\n close: () => set({ isOpen: false }),\n\n toggle: () => set(state => ({ isOpen: !state.isOpen })),\n\n setExpanded: value => {\n setToLocalStorage(EXPANDED_STORAGE_KEY, value);\n set({ isExpanded: value });\n },\n\n setConversation: conversation => set({ conversation }),\n\n // Only the conversation that is leaving: the next one's button may already\n // have taken its place.\n clearConversation: conversationId =>\n set(state =>\n state.conversation?.id === conversationId ? { conversation: null } : {}\n ),\n\n markDraftSeen: (conversationId, runId) =>\n set(state => ({\n seenDrafts: { ...state.seenDrafts, [conversationId]: runId },\n })),\n }))\n);\n\nexport default useNeetoAssistStore;\n"],"names":["Sparkle","_ref","_ref$size","size","className","otherProps","_objectWithoutProperties","_excluded","_jsxs","_objectSpread","fill","height","stroke","strokeLinecap","strokeLinejoin","strokeWidth","viewBox","width","xmlns","children","_jsx","d","wordsOf","text","toLowerCase","split","filter","Boolean","commandsOf","commands","Array","isArray","command","name","title","description","every","typedCommand","startsWith","includes","typed","slice","_typed$split","_typed$split2","_toArray","rest","isChosen","isEmpty","any","propEq","matchingCommands","words","fitsName","length","fitsTitle","_ref2","word","some","titleWord","concat","_toConsumableArray","pickedCommand","_ref3","optionId","menuId","_ref4","commandPart","question","collapseRepeatedSkips","runs","reasons","run","index","next","skippedReason","withoutReplacedDrafts","kind","REPLY_SUGGESTION","status","isPending","PENDING_STATUSES","withoutRepeatedQuietSkips","QUIET_SKIPPED_REASONS","runsInConversationOrder","reverse","latestDraftId","_runs$find","find","suggestedReply","id","hasWrittenReply","answer","isRateable","_ref5","RATEABLE_STATUSES","UNRATEABLE_SKIPPED_REASONS","hasPendingRun","arguments","undefined","stepsOf","_ref6","steps","hasRunningStep","actionsOf","_ref7","actions","skippedReasonMessageKey","reason","propOr","SKIPPED_REASON_MESSAGE_KEYS","errorMessageKey","error","response","ERROR_MESSAGE_KEYS","isWebUrl","url","test","useFetchRuns","conversationId","useQuery","queryKey","QUERY_KEYS","RUNS","queryFn","neetoAssistApi","fetchRuns","select","_ref$runs","_ref$credits","credits","staleTime","retry","refetchInterval","_ref2$state","state","data","PENDING_POLL_INTERVAL","IDLE_POLL_INTERVAL","useAskNeetoAssist","useMutationWithInvalidation","createRun","keysToInvalidate","useUpdateFeedback","updateFeedback","useActOnAction","mutationFn","callbacks","queryClient","useQueryClient","useMutation","onSettled","invalidateQueries","useApplyAction","onApplied","applyAction","onSuccess","action","useDismissAction","dismissAction","useNeetoAssistStore","create","withImmutableActions","set","isOpen","isExpanded","getFromLocalStorage","EXPANDED_STORAGE_KEY","conversation","seenDrafts","close","toggle","setExpanded","value","setToLocalStorage","setConversation","clearConversation","_state$conversation","markDraftSeen","runId","_defineProperty"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAMA,OAAO,GAAG,SAAVA,OAAOA,CAAAC,IAAA,EAAA;AAAA,EAAA,IAAAC,SAAA,GAAAD,IAAA,CAAME,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,SAAA;IAAEE,SAAS,GAAAH,IAAA,CAATG,SAAS;AAAKC,IAAAA,UAAU,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA,CAAA;AAAA,EAAA,oBACpDC,IAAA,CAAA,KAAA,EAAAC,eAAA,CAAAA,eAAA,CAAA;AACQL,IAAAA,SAAS,EAATA,SAAS;AACf,IAAA,aAAA,EAAY,MAAM;AAClBM,IAAAA,IAAI,EAAC,MAAM;AACXC,IAAAA,MAAM,EAAER,IAAK;AACbS,IAAAA,MAAM,EAAC,cAAc;AACrBC,IAAAA,aAAa,EAAC,OAAO;AACrBC,IAAAA,cAAc,EAAC,OAAO;AACtBC,IAAAA,WAAW,EAAC,KAAK;A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A,IAAAS,mBAAA,KAAA,MAAA,GAAA,MAAA,GAAlBA,mBAAA,CAAoBvF,EAAE,MAAK6B,cAAc,GAAG;AAAEiD,UAAAA,YAAY,EAAE;SAAM,GAAG,EAAE;AAAA,MAAA,CACzE,CAAC;AAAA,IAAA,CAAA;AAEHU,IAAAA,aAAa,EAAE,SAAfA,aAAaA,CAAG3D,cAAc,EAAE4D,KAAK,EAAA;MAAA,OACnChB,GAAG,CAAC,UAAA5B,KAAK,EAAA;QAAA,OAAK;AACZkC,UAAAA,UAAU,EAAA/J,aAAA,CAAAA,aAAA,CAAA,EAAA,EAAO6H,KAAK,CAACkC,UAAU,CAAA,EAAA,EAAA,EAAAW,eAAA,CAAA,EAAA,EAAG7D,cAAc,EAAG4D,KAAK,CAAA;SAC3D;AAAA,MAAA,CAAC,CAAC;AAAA,IAAA;GACN;AAAA,CAAC,CACJ;;;;"}
@@ -6,6 +6,8 @@ var jsxRuntime = require('react/jsx-runtime');
6
6
  var reactQuery = require('@tanstack/react-query');
7
7
  var reactUtils = require('@bigbinary/neeto-commons-frontend/v2/react-utils');
8
8
  var neeto_assist = require('./neeto_assist-CznTN_YY.js');
9
+ var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
10
+ var _toArray = require('@babel/runtime/helpers/toArray');
9
11
  var ramda = require('ramda');
10
12
  var utils = require('@bigbinary/neeto-commons-frontend/v2/utils');
11
13
  var zustand = require('zustand');
@@ -41,6 +43,84 @@ var Sparkle = function Sparkle(_ref) {
41
43
  }));
42
44
  };
43
45
 
46
+ var wordsOf = function wordsOf(text) {
47
+ return text.toLowerCase().split(/\s+/).filter(Boolean);
48
+ };
49
+
50
+ // The commands as the engine listed them with the runs. It lists only what has
51
+ // a name, a title and a description, and an older engine lists none. Anything
52
+ // else that turns up is left out here, so a menu never has a row it cannot
53
+ // show.
54
+ var commandsOf = function commandsOf(commands) {
55
+ return (Array.isArray(commands) ? commands : []).filter(function (command) {
56
+ return [command === null || command === void 0 ? void 0 : command.name, command === null || command === void 0 ? void 0 : command.title, command === null || command === void 0 ? void 0 : command.description].every(function (text) {
57
+ return typeof text === "string";
58
+ });
59
+ });
60
+ };
61
+
62
+ // What a rep has typed of a command so far: the text after the "/", in lower
63
+ // case, or null when the box holds no command being typed. That is so once
64
+ // the text runs on to another line, and once a full name has a space after
65
+ // it: the command is chosen then, and what follows are the rep's own words.
66
+ var typedCommand = function typedCommand(text, commands) {
67
+ if (!text.startsWith("/") || text.includes("\n")) return null;
68
+ var typed = text.slice(1).toLowerCase();
69
+ var _typed$split = typed.split(/\s/),
70
+ _typed$split2 = _toArray(_typed$split),
71
+ name = _typed$split2[0],
72
+ rest = _typed$split2.slice(1);
73
+ var isChosen = !ramda.isEmpty(rest) && ramda.any(ramda.propEq(name, "name"), commands);
74
+ return isChosen ? null : typed;
75
+ };
76
+
77
+ // The commands that fit what was typed, as the menu lists them: all of them
78
+ // after a bare "/", otherwise those whose name starts with what was typed,
79
+ // then those whose title has a word that starts with each word typed.
80
+ var matchingCommands = function matchingCommands(text, commands) {
81
+ var typed = typedCommand(text, commands);
82
+ if (typed === null) return [];
83
+ var words = wordsOf(typed);
84
+ if (ramda.isEmpty(words)) return commands;
85
+ var fitsName = function fitsName(_ref) {
86
+ var name = _ref.name;
87
+ return words.length === 1 && name.startsWith(words[0]);
88
+ };
89
+ var fitsTitle = function fitsTitle(_ref2) {
90
+ var title = _ref2.title;
91
+ return words.every(function (word) {
92
+ return wordsOf(title).some(function (titleWord) {
93
+ return titleWord.startsWith(word);
94
+ });
95
+ });
96
+ };
97
+ return [].concat(_toConsumableArray(commands.filter(fitsName)), _toConsumableArray(commands.filter(function (command) {
98
+ return !fitsName(command) && fitsTitle(command);
99
+ })));
100
+ };
101
+
102
+ // What the box holds once a command is picked: the command and a space, for
103
+ // the rep to add words after or to send as it is.
104
+ var pickedCommand = function pickedCommand(_ref3) {
105
+ var name = _ref3.name;
106
+ return "/".concat(name, " ");
107
+ };
108
+
109
+ // The id of a command's row in the menu, which the box points at while the
110
+ // row is the marked one.
111
+ var optionId = function optionId(menuId, _ref4) {
112
+ var name = _ref4.name;
113
+ return "".concat(menuId, "-").concat(name);
114
+ };
115
+
116
+ // The command at the start of a question, as the rep typed it, or null for a
117
+ // question that NeetoAssist did not read as a command.
118
+ var commandPart = function commandPart(question, command) {
119
+ if (!command || typeof question !== "string") return null;
120
+ var typed = question.slice(0, command.length + 1);
121
+ return typed.toLowerCase() === "/".concat(command).toLowerCase() ? typed : null;
122
+ };
123
+
44
124
  // While a quiet rule holds, NeetoAssist skips every visitor message for the
45
125
  // same reason. One note says it, so of skips in a row for one of these
46
126
  // reasons, only the latest stays. Runs are in conversation order.
@@ -148,7 +228,8 @@ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t
148
228
 
149
229
  // Fresh on every mount, then polled: quickly while NeetoAssist is working on a
150
230
  // run, slowly otherwise. A failed poll is retried by the next one and never
151
- // shown as a toast. Comes with the workspace's credit state.
231
+ // shown as a toast. Comes with the workspace's credit state, and with the
232
+ // commands a rep can pick in the box, which an older engine does not list.
152
233
  var useFetchRuns = function useFetchRuns(conversationId) {
153
234
  return reactQuery.useQuery({
154
235
  queryKey: [neeto_assist.QUERY_KEYS.RUNS, conversationId],
@@ -159,10 +240,12 @@ var useFetchRuns = function useFetchRuns(conversationId) {
159
240
  var _ref$runs = _ref.runs,
160
241
  runs = _ref$runs === void 0 ? [] : _ref$runs,
161
242
  _ref$credits = _ref.credits,
162
- credits = _ref$credits === void 0 ? null : _ref$credits;
243
+ credits = _ref$credits === void 0 ? null : _ref$credits,
244
+ commands = _ref.commands;
163
245
  return {
164
246
  runs: runs,
165
- credits: credits
247
+ credits: credits,
248
+ commands: commandsOf(commands)
166
249
  };
167
250
  },
168
251
  staleTime: 0,
@@ -277,6 +360,7 @@ var useNeetoAssistStore = zustand.create(reactUtils.withImmutableActions(functio
277
360
 
278
361
  exports.Sparkle = Sparkle;
279
362
  exports.actionsOf = actionsOf;
363
+ exports.commandPart = commandPart;
280
364
  exports.errorMessageKey = errorMessageKey;
281
365
  exports.hasRunningStep = hasRunningStep;
282
366
  exports.hasWrittenReply = hasWrittenReply;
@@ -284,6 +368,9 @@ exports.isPending = isPending;
284
368
  exports.isRateable = isRateable;
285
369
  exports.isWebUrl = isWebUrl;
286
370
  exports.latestDraftId = latestDraftId;
371
+ exports.matchingCommands = matchingCommands;
372
+ exports.optionId = optionId;
373
+ exports.pickedCommand = pickedCommand;
287
374
  exports.runsInConversationOrder = runsInConversationOrder;
288
375
  exports.skippedReasonMessageKey = skippedReasonMessageKey;
289
376
  exports.stepsOf = stepsOf;
@@ -293,4 +380,4 @@ exports.useDismissAction = useDismissAction;
293
380
  exports.useFetchRuns = useFetchRuns;
294
381
  exports.useNeetoAssistStore = useNeetoAssistStore;
295
382
  exports.useUpdateFeedback = useUpdateFeedback;
296
- //# sourceMappingURL=useNeetoAssistStore-CGEUMbes.js.map
383
+ //# sourceMappingURL=useNeetoAssistStore-VaZp3268.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNeetoAssistStore-VaZp3268.js","sources":["../app/javascript/src/components/commons/Sparkle.jsx","../app/javascript/src/utils/commands.js","../app/javascript/src/utils/collapseRepeatedSkips.js","../app/javascript/src/utils/runs.js","../app/javascript/src/hooks/reactQuery/useRunsApi.js","../app/javascript/src/stores/useNeetoAssistStore.js"],"sourcesContent":["const Sparkle = ({ size = 18, className, ...otherProps }) => (\n <svg\n {...{ className }}\n aria-hidden=\"true\"\n fill=\"none\"\n height={size}\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"1.5\"\n viewBox=\"0 0 18 18\"\n width={size}\n xmlns=\"http://www.w3.org/2000/svg\"\n {...otherProps}\n >\n <path\n d=\"M5.658 2.99L4.395 2.569L3.974 1.306C3.837 0.898 3.162 0.898 3.025 1.306L2.604 2.569L1.341 2.99C1.137 3.058 0.999 3.249 0.999 3.464C0.999 3.679 1.137 3.87 1.341 3.938L2.604 4.359L3.025 5.622C3.093 5.826 3.285 5.964 3.5 5.964C3.715 5.964 3.906 5.826 3.975 5.622L4.396 4.359L5.659 3.938C5.863 3.87 6.001 3.679 6.001 3.464C6.001 3.249 5.862 3.058 5.658 2.99Z\"\n fill=\"currentColor\"\n stroke=\"none\"\n />\n <path d=\"M9.5 2.75L11.412 7.587L16.25 9.5L11.412 11.413L9.5 16.25L7.587 11.413L2.75 9.5L7.587 7.587L9.5 2.75Z\" />\n </svg>\n);\n\nexport default Sparkle;\n","// A command is a named way to ask NeetoAssist for one of the things it can do\n// here. A rep types \"/\" in the box, picks a command from the menu and may add\n// a few words. The engine lists the commands with the runs: NeetoAssist's own,\n// then those of the host's actions this rep is offered.\nimport { any, isEmpty, propEq } from \"ramda\";\n\nconst wordsOf = text => text.toLowerCase().split(/\\s+/).filter(Boolean);\n\n// The commands as the engine listed them with the runs. It lists only what has\n// a name, a title and a description, and an older engine lists none. Anything\n// else that turns up is left out here, so a menu never has a row it cannot\n// show.\nexport const commandsOf = commands =>\n (Array.isArray(commands) ? commands : []).filter(command =>\n [command?.name, command?.title, command?.description].every(\n text => typeof text === \"string\"\n )\n );\n\n// What a rep has typed of a command so far: the text after the \"/\", in lower\n// case, or null when the box holds no command being typed. That is so once\n// the text runs on to another line, and once a full name has a space after\n// it: the command is chosen then, and what follows are the rep's own words.\nexport const typedCommand = (text, commands) => {\n if (!text.startsWith(\"/\") || text.includes(\"\\n\")) return null;\n\n const typed = text.slice(1).toLowerCase();\n const [name, ...rest] = typed.split(/\\s/);\n const isChosen = !isEmpty(rest) && any(propEq(name, \"name\"), commands);\n\n return isChosen ? null : typed;\n};\n\n// The commands that fit what was typed, as the menu lists them: all of them\n// after a bare \"/\", otherwise those whose name starts with what was typed,\n// then those whose title has a word that starts with each word typed.\nexport const matchingCommands = (text, commands) => {\n const typed = typedCommand(text, commands);\n if (typed === null) return [];\n\n const words = wordsOf(typed);\n if (isEmpty(words)) return commands;\n\n const fitsName = ({ name }) =>\n words.length === 1 && name.startsWith(words[0]);\n\n const fitsTitle = ({ title }) =>\n words.every(word =>\n wordsOf(title).some(titleWord => titleWord.startsWith(word))\n );\n\n return [\n ...commands.filter(fitsName),\n ...commands.filter(command => !fitsName(command) && fitsTitle(command)),\n ];\n};\n\n// What the box holds once a command is picked: the command and a space, for\n// the rep to add words after or to send as it is.\nexport const pickedCommand = ({ name }) => `/${name} `;\n\n// The id of a command's row in the menu, which the box points at while the\n// row is the marked one.\nexport const optionId = (menuId, { name }) => `${menuId}-${name}`;\n\n// The command at the start of a question, as the rep typed it, or null for a\n// question that NeetoAssist did not read as a command.\nexport const commandPart = (question, command) => {\n if (!command || typeof question !== \"string\") return null;\n\n const typed = question.slice(0, command.length + 1);\n\n return typed.toLowerCase() === `/${command}`.toLowerCase() ? typed : null;\n};\n","// While a quiet rule holds, NeetoAssist skips every visitor message for the\n// same reason. One note says it, so of skips in a row for one of these\n// reasons, only the latest stays. Runs are in conversation order.\nexport const collapseRepeatedSkips = (runs, reasons) =>\n runs.filter((run, index) => {\n const next = runs[index + 1];\n\n return !(\n reasons.includes(run.skippedReason) &&\n next?.skippedReason === run.skippedReason\n );\n });\n","import { any, propEq, propOr, reverse } from \"ramda\";\n\nimport {\n ERROR_MESSAGE_KEYS,\n PENDING_STATUSES,\n QUIET_SKIPPED_REASONS,\n RATEABLE_STATUSES,\n REPLY_SUGGESTION,\n SKIPPED_REASON_MESSAGE_KEYS,\n UNRATEABLE_SKIPPED_REASONS,\n} from \"common/constants\";\nimport { collapseRepeatedSkips } from \"utils/collapseRepeatedSkips\";\n\n// A reply suggestion that is still waiting gets replaced by a newer one, which\n// answers its messages too, so only the newest shows as being worked on.\nconst withoutReplacedDrafts = runs =>\n runs.filter(\n (run, index) =>\n !(\n run.kind === REPLY_SUGGESTION &&\n run.status === \"queued\" &&\n runs.slice(index + 1).some(({ kind }) => kind === REPLY_SUGGESTION)\n )\n );\n\nexport const isPending = ({ status }) => PENDING_STATUSES.includes(status);\n\nexport const withoutRepeatedQuietSkips = runs =>\n collapseRepeatedSkips(runs, QUIET_SKIPPED_REASONS);\n\n// NeetoAssist lists the newest run first. The pane reads like the conversation\n// instead: oldest at the top, the latest at the bottom. A quiet rule skips every\n// message while it holds, and one note says so.\nexport const runsInConversationOrder = runs =>\n withoutRepeatedQuietSkips(withoutReplacedDrafts(reverse(runs)));\n\n// The newest reply NeetoAssist drafted on its own. Runs are newest first.\nexport const latestDraftId = runs =>\n runs.find(\n ({ kind, suggestedReply }) => kind === REPLY_SUGGESTION && !!suggestedReply\n )?.id;\n\n// A hello is skipped, since nothing was looked up, but it still gets a reply.\nexport const hasWrittenReply = ({ status, answer, suggestedReply }) =>\n status === \"completed\" ||\n (status === \"skipped\" && !!(answer || suggestedReply));\n\n// A rep's own hello or thanks got a friendly line, which is nothing to judge.\nexport const isRateable = ({ kind, status, skippedReason }) =>\n RATEABLE_STATUSES.includes(status) &&\n !UNRATEABLE_SKIPPED_REASONS.includes(skippedReason) &&\n !(kind === \"ask\" && status === \"skipped\");\n\n// What the pane polls quickly for: a run NeetoAssist is still working on. An\n// action someone is applying is not one. The rep who clicked has the answer\n// to the click, and an action whose end NeetoAssist never hears of would keep\n// every open pane polling quickly until NeetoAssist gives up on it.\nexport const hasPendingRun = (runs = []) => runs.some(isPending);\n\n// The lookups NeetoAssist made while answering, in the order they started. A\n// run from an older NeetoAssist carries none.\nexport const stepsOf = ({ steps }) => steps ?? [];\n\nexport const hasRunningStep = run =>\n any(propEq(\"running\", \"status\"), stepsOf(run));\n\n// A suggested action can only be applied once its run has finished. Until then\n// NeetoAssist may still take it back and start over, so its card waits.\nexport const actionsOf = ({ status, actions }) =>\n status === \"completed\" ? (actions ?? []) : [];\n\nexport const skippedReasonMessageKey = reason =>\n propOr(\"neetoAssist.run.skipped\", reason, SKIPPED_REASON_MESSAGE_KEYS);\n\n// No answer at all means the request never reached NeetoAssist.\nexport const errorMessageKey = error => {\n if (!error?.response) return ERROR_MESSAGE_KEYS[503];\n\n return propOr(\n \"neetoAssist.errors.generic\",\n error.response.status,\n ERROR_MESSAGE_KEYS\n );\n};\n\n// Sources come from a knowledge base, so only web links become links.\nexport const isWebUrl = url => /^https?:\\/\\//i.test(url ?? \"\");\n","import { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/v2/react-utils\";\n\nimport neetoAssistApi from \"apis/neeto_assist\";\nimport {\n IDLE_POLL_INTERVAL,\n PENDING_POLL_INTERVAL,\n QUERY_KEYS,\n} from \"common/constants\";\nimport { commandsOf } from \"utils/commands\";\nimport { hasPendingRun } from \"utils/runs\";\n\n// Fresh on every mount, then polled: quickly while NeetoAssist is working on a\n// run, slowly otherwise. A failed poll is retried by the next one and never\n// shown as a toast. Comes with the workspace's credit state, and with the\n// commands a rep can pick in the box, which an older engine does not list.\nconst useFetchRuns = conversationId =>\n useQuery({\n queryKey: [QUERY_KEYS.RUNS, conversationId],\n queryFn: () => neetoAssistApi.fetchRuns(conversationId),\n select: ({ runs = [], credits = null, commands }) => ({\n runs,\n credits,\n commands: commandsOf(commands),\n }),\n staleTime: 0,\n retry: false,\n refetchInterval: ({ state: { data, error } }) =>\n !error && hasPendingRun(data?.runs)\n ? PENDING_POLL_INTERVAL\n : IDLE_POLL_INTERVAL,\n });\n\nconst useAskNeetoAssist = conversationId =>\n useMutationWithInvalidation(neetoAssistApi.createRun, {\n keysToInvalidate: [[QUERY_KEYS.RUNS, conversationId]],\n });\n\nconst useUpdateFeedback = conversationId =>\n useMutationWithInvalidation(neetoAssistApi.updateFeedback, {\n keysToInvalidate: [[QUERY_KEYS.RUNS, conversationId]],\n });\n\n// A click on a card changes what its run shows whether it worked or not: the\n// action was applied, or someone else got to it first, or it expired. So the\n// runs are fetched again either way. The card does not wait for them: the\n// answer to the click already says what happened.\nconst useActOnAction = (mutationFn, conversationId, callbacks = {}) => {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn,\n onSettled: () => {\n queryClient.invalidateQueries({\n queryKey: [QUERY_KEYS.RUNS, conversationId],\n });\n },\n ...callbacks,\n });\n};\n\n// The host hears of an applied action from here and not from the card that\n// was clicked. React Query drops what a card hands to mutate once the card is\n// off the screen, as when the rep opens another conversation before the answer\n// arrives, and the change was made all the same. The click does not wait for\n// the host's handler, so what the handler returns is left alone.\nconst useApplyAction = (conversationId, onApplied) =>\n useActOnAction(neetoAssistApi.applyAction, conversationId, {\n onSuccess: data => {\n onApplied?.(data?.action);\n },\n });\n\nconst useDismissAction = conversationId =>\n useActOnAction(neetoAssistApi.dismissAction, conversationId);\n\nexport {\n useFetchRuns,\n useAskNeetoAssist,\n useUpdateFeedback,\n useApplyAction,\n useDismissAction,\n};\n","import { withImmutableActions } from \"neetocommons/v2/react-utils\";\nimport { getFromLocalStorage, setToLocalStorage } from \"neetocommons/v2/utils\";\nimport { create } from \"zustand\";\n\nimport { EXPANDED_STORAGE_KEY } from \"common/constants\";\n\n// The pane is mounted once in the host's layout and the button sits on the\n// ticket, so this is how they talk: whether the pane is open and how wide, and\n// which conversation it is about. A reload starts closed, and the width is kept.\n/** @type {import(\"neetocommons/react-utils\").ZustandStoreHook} */\nconst useNeetoAssistStore = create(\n withImmutableActions(set => ({\n isOpen: false,\n isExpanded: getFromLocalStorage(EXPANDED_STORAGE_KEY) || false,\n conversation: null,\n seenDrafts: {},\n\n close: () => set({ isOpen: false }),\n\n toggle: () => set(state => ({ isOpen: !state.isOpen })),\n\n setExpanded: value => {\n setToLocalStorage(EXPANDED_STORAGE_KEY, value);\n set({ isExpanded: value });\n },\n\n setConversation: conversation => set({ conversation }),\n\n // Only the conversation that is leaving: the next one's button may already\n // have taken its place.\n clearConversation: conversationId =>\n set(state =>\n state.conversation?.id === conversationId ? { conversation: null } : {}\n ),\n\n markDraftSeen: (conversationId, runId) =>\n set(state => ({\n seenDrafts: { ...state.seenDrafts, [conversationId]: runId },\n })),\n }))\n);\n\nexport default useNeetoAssistStore;\n"],"names":["Sparkle","_ref","_ref$size","size","className","otherProps","_objectWithoutProperties","_excluded","_jsxs","_objectSpread","fill","height","stroke","strokeLinecap","strokeLinejoin","strokeWidth","viewBox","width","xmlns","children","_jsx","d","wordsOf","text","toLowerCase","split","filter","Boolean","commandsOf","commands","Array","isArray","command","name","title","description","every","typedCommand","startsWith","includes","typed","slice","_typed$split","_typed$split2","_toArray","rest","isChosen","isEmpty","any","propEq","matchingCommands","words","fitsName","length","fitsTitle","_ref2","word","some","titleWord","concat","_toConsumableArray","pickedCommand","_ref3","optionId","menuId","_ref4","commandPart","question","collapseRepeatedSkips","runs","reasons","run","index","next","skippedReason","withoutReplacedDrafts","kind","REPLY_SUGGESTION","status","isPending","PENDING_STATUSES","withoutRepeatedQuietSkips","QUIET_SKIPPED_REASONS","runsInConversationOrder","reverse","latestDraftId","_runs$find","find","suggestedReply","id","hasWrittenReply","answer","isRateable","_ref5","RATEABLE_STATUSES","UNRATEABLE_SKIPPED_REASONS","hasPendingRun","arguments","undefined","stepsOf","_ref6","steps","hasRunningStep","actionsOf","_ref7","actions","skippedReasonMessageKey","reason","propOr","SKIPPED_REASON_MESSAGE_KEYS","errorMessageKey","error","response","ERROR_MESSAGE_KEYS","isWebUrl","url","test","useFetchRuns","conversationId","useQuery","queryKey","QUERY_KEYS","RUNS","queryFn","neetoAssistApi","fetchRuns","select","_ref$runs","_ref$credits","credits","staleTime","retry","refetchInterval","_ref2$state","state","data","PENDING_POLL_INTERVAL","IDLE_POLL_INTERVAL","useAskNeetoAssist","useMutationWithInvalidation","createRun","keysToInvalidate","useUpdateFeedback","updateFeedback","useActOnAction","mutationFn","callbacks","queryClient","useQueryClient","useMutation","onSettled","invalidateQueries","useApplyAction","onApplied","applyAction","onSuccess","action","useDismissAction","dismissAction","useNeetoAssistStore","create","withImmutableActions","set","isOpen","isExpanded","getFromLocalStorage","EXPANDED_STORAGE_KEY","conversation","seenDrafts","close","toggle","setExpanded","value","setToLocalStorage","setConversation","clearConversation","_state$conversation","markDraftSeen","runId","_defineProperty"],"mappings":";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ANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-assist-frontend",
3
- "version": "1.1.0",
3
+ "version": "1.2.0-beta1",
4
4
  "description": "NeetoAssist pane and helpers for Neeto products",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://github.com/bigbinary/neeto-assist-nano",
package/types.d.ts CHANGED
@@ -8,14 +8,31 @@ import { UseQueryResult } from "@tanstack/react-query";
8
8
  */
9
9
  export interface NeetoAssistAction {
10
10
  id: string;
11
- /** The action's name in the host's catalog, such as `assign_conversation`. */
11
+ /**
12
+ * The action's name: one in the host's catalog, such as
13
+ * `assign_conversation`, or one of NeetoAssist's own, such as
14
+ * `save_help_article_draft`.
15
+ */
12
16
  name: string;
13
- /** The host's own words for what the action does. */
17
+ /** What the action does, in words written by code from the real values. */
14
18
  title: string;
15
- /** More of the host's words, one line each. */
19
+ /** More of those words, one line each. */
16
20
  details: string[];
21
+ /**
22
+ * The long text the action will save or send, such as a help article or the
23
+ * body of an issue, in plain text or light markdown. The card shows it in a
24
+ * box under the details. An action that writes nothing long has none, and an
25
+ * older NeetoAssist sends none.
26
+ */
27
+ content?: string | null;
17
28
  /** The model's one sentence on why it suggested the action. */
18
29
  reason: string | null;
30
+ /**
31
+ * Who makes the change when a rep clicks "Apply": the host, or NeetoAssist
32
+ * for one of its own actions, in a system the workspace connected to it. An
33
+ * older NeetoAssist names nobody, and means the host.
34
+ */
35
+ runner?: "host" | "neeto_assist";
19
36
  status:
20
37
  | "suggested"
21
38
  | "applying"
@@ -23,9 +40,15 @@ export interface NeetoAssistAction {
23
40
  | "failed"
24
41
  | "dismissed"
25
42
  | "expired";
26
- /** The host's sentence on what was done, once applied. */
43
+ /** The sentence on what was done, once applied. */
27
44
  result: string | null;
28
- /** The host's sentence on what went wrong, once failed. */
45
+ /**
46
+ * Where what the action made can be opened, once applied, such as the issue
47
+ * it created. The card shows it under the result when `url` is a web
48
+ * address.
49
+ */
50
+ link?: { label: string; url: string } | null;
51
+ /** The sentence on what went wrong, once failed. */
29
52
  error: string | null;
30
53
  /** Who applied or dismissed the action. */
31
54
  actedBy: { id: string; name: string } | null;
@@ -54,7 +77,9 @@ export interface NeetoAssistButtonProps {
54
77
  * not called for an action that failed or was dismissed. It is called even
55
78
  * when the rep opened another conversation before the answer arrived, and
56
79
  * the handler called is then the one last given for the conversation the
57
- * action was applied on.
80
+ * action was applied on. It is called for one of NeetoAssist's own actions
81
+ * too (`action.runner` is `"neeto_assist"`), which changed nothing in the
82
+ * host.
58
83
  */
59
84
  onActionApplied?: (action: NeetoAssistAction) => void;
60
85
  /**
@@ -1 +0,0 @@
1
- {"version":3,"file":"useNeetoAssistStore--JwP_Upt.js","sources":["../app/javascript/src/components/commons/Sparkle.jsx","../app/javascript/src/utils/collapseRepeatedSkips.js","../app/javascript/src/utils/runs.js","../app/javascript/src/hooks/reactQuery/useRunsApi.js","../app/javascript/src/stores/useNeetoAssistStore.js"],"sourcesContent":["const Sparkle = ({ size = 18, className, ...otherProps }) => (\n <svg\n {...{ className }}\n aria-hidden=\"true\"\n fill=\"none\"\n height={size}\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"1.5\"\n viewBox=\"0 0 18 18\"\n width={size}\n xmlns=\"http://www.w3.org/2000/svg\"\n {...otherProps}\n >\n <path\n d=\"M5.658 2.99L4.395 2.569L3.974 1.306C3.837 0.898 3.162 0.898 3.025 1.306L2.604 2.569L1.341 2.99C1.137 3.058 0.999 3.249 0.999 3.464C0.999 3.679 1.137 3.87 1.341 3.938L2.604 4.359L3.025 5.622C3.093 5.826 3.285 5.964 3.5 5.964C3.715 5.964 3.906 5.826 3.975 5.622L4.396 4.359L5.659 3.938C5.863 3.87 6.001 3.679 6.001 3.464C6.001 3.249 5.862 3.058 5.658 2.99Z\"\n fill=\"currentColor\"\n stroke=\"none\"\n />\n <path d=\"M9.5 2.75L11.412 7.587L16.25 9.5L11.412 11.413L9.5 16.25L7.587 11.413L2.75 9.5L7.587 7.587L9.5 2.75Z\" />\n </svg>\n);\n\nexport default Sparkle;\n","// While a quiet rule holds, NeetoAssist skips every visitor message for the\n// same reason. One note says it, so of skips in a row for one of these\n// reasons, only the latest stays. Runs are in conversation order.\nexport const collapseRepeatedSkips = (runs, reasons) =>\n runs.filter((run, index) => {\n const next = runs[index + 1];\n\n return !(\n reasons.includes(run.skippedReason) &&\n next?.skippedReason === run.skippedReason\n );\n });\n","import { any, propEq, propOr, reverse } from \"ramda\";\n\nimport {\n ERROR_MESSAGE_KEYS,\n PENDING_STATUSES,\n QUIET_SKIPPED_REASONS,\n RATEABLE_STATUSES,\n REPLY_SUGGESTION,\n SKIPPED_REASON_MESSAGE_KEYS,\n UNRATEABLE_SKIPPED_REASONS,\n} from \"common/constants\";\nimport { collapseRepeatedSkips } from \"utils/collapseRepeatedSkips\";\n\n// A reply suggestion that is still waiting gets replaced by a newer one, which\n// answers its messages too, so only the newest shows as being worked on.\nconst withoutReplacedDrafts = runs =>\n runs.filter(\n (run, index) =>\n !(\n run.kind === REPLY_SUGGESTION &&\n run.status === \"queued\" &&\n runs.slice(index + 1).some(({ kind }) => kind === REPLY_SUGGESTION)\n )\n );\n\nexport const isPending = ({ status }) => PENDING_STATUSES.includes(status);\n\nexport const withoutRepeatedQuietSkips = runs =>\n collapseRepeatedSkips(runs, QUIET_SKIPPED_REASONS);\n\n// NeetoAssist lists the newest run first. The pane reads like the conversation\n// instead: oldest at the top, the latest at the bottom. A quiet rule skips every\n// message while it holds, and one note says so.\nexport const runsInConversationOrder = runs =>\n withoutRepeatedQuietSkips(withoutReplacedDrafts(reverse(runs)));\n\n// The newest reply NeetoAssist drafted on its own. Runs are newest first.\nexport const latestDraftId = runs =>\n runs.find(\n ({ kind, suggestedReply }) => kind === REPLY_SUGGESTION && !!suggestedReply\n )?.id;\n\n// A hello is skipped, since nothing was looked up, but it still gets a reply.\nexport const hasWrittenReply = ({ status, answer, suggestedReply }) =>\n status === \"completed\" ||\n (status === \"skipped\" && !!(answer || suggestedReply));\n\n// A rep's own hello or thanks got a friendly line, which is nothing to judge.\nexport const isRateable = ({ kind, status, skippedReason }) =>\n RATEABLE_STATUSES.includes(status) &&\n !UNRATEABLE_SKIPPED_REASONS.includes(skippedReason) &&\n !(kind === \"ask\" && status === \"skipped\");\n\n// What the pane polls quickly for: a run NeetoAssist is still working on. An\n// action someone is applying is not one. The rep who clicked has the answer\n// to the click, and an action whose end NeetoAssist never hears of would keep\n// every open pane polling quickly until NeetoAssist gives up on it.\nexport const hasPendingRun = (runs = []) => runs.some(isPending);\n\n// The lookups NeetoAssist made while answering, in the order they started. A\n// run from an older NeetoAssist carries none.\nexport const stepsOf = ({ steps }) => steps ?? [];\n\nexport const hasRunningStep = run =>\n any(propEq(\"running\", \"status\"), stepsOf(run));\n\n// A suggested action can only be applied once its run has finished. Until then\n// NeetoAssist may still take it back and start over, so its card waits.\nexport const actionsOf = ({ status, actions }) =>\n status === \"completed\" ? (actions ?? []) : [];\n\nexport const skippedReasonMessageKey = reason =>\n propOr(\"neetoAssist.run.skipped\", reason, SKIPPED_REASON_MESSAGE_KEYS);\n\n// No answer at all means the request never reached NeetoAssist.\nexport const errorMessageKey = error => {\n if (!error?.response) return ERROR_MESSAGE_KEYS[503];\n\n return propOr(\n \"neetoAssist.errors.generic\",\n error.response.status,\n ERROR_MESSAGE_KEYS\n );\n};\n\n// Sources come from a knowledge base, so only web links become links.\nexport const isWebUrl = url => /^https?:\\/\\//i.test(url ?? \"\");\n","import { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/v2/react-utils\";\n\nimport neetoAssistApi from \"apis/neeto_assist\";\nimport {\n IDLE_POLL_INTERVAL,\n PENDING_POLL_INTERVAL,\n QUERY_KEYS,\n} from \"common/constants\";\nimport { hasPendingRun } from \"utils/runs\";\n\n// Fresh on every mount, then polled: quickly while NeetoAssist is working on a\n// run, slowly otherwise. A failed poll is retried by the next one and never\n// shown as a toast. Comes with the workspace's credit state.\nconst useFetchRuns = conversationId =>\n useQuery({\n queryKey: [QUERY_KEYS.RUNS, conversationId],\n queryFn: () => neetoAssistApi.fetchRuns(conversationId),\n select: ({ runs = [], credits = null }) => ({ runs, credits }),\n staleTime: 0,\n retry: false,\n refetchInterval: ({ state: { data, error } }) =>\n !error && hasPendingRun(data?.runs)\n ? PENDING_POLL_INTERVAL\n : IDLE_POLL_INTERVAL,\n });\n\nconst useAskNeetoAssist = conversationId =>\n useMutationWithInvalidation(neetoAssistApi.createRun, {\n keysToInvalidate: [[QUERY_KEYS.RUNS, conversationId]],\n });\n\nconst useUpdateFeedback = conversationId =>\n useMutationWithInvalidation(neetoAssistApi.updateFeedback, {\n keysToInvalidate: [[QUERY_KEYS.RUNS, conversationId]],\n });\n\n// A click on a card changes what its run shows whether it worked or not: the\n// action was applied, or someone else got to it first, or it expired. So the\n// runs are fetched again either way. The card does not wait for them: the\n// answer to the click already says what happened.\nconst useActOnAction = (mutationFn, conversationId, callbacks = {}) => {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn,\n onSettled: () => {\n queryClient.invalidateQueries({\n queryKey: [QUERY_KEYS.RUNS, conversationId],\n });\n },\n ...callbacks,\n });\n};\n\n// The host hears of an applied action from here and not from the card that\n// was clicked. React Query drops what a card hands to mutate once the card is\n// off the screen, as when the rep opens another conversation before the answer\n// arrives, and the change was made all the same. The click does not wait for\n// the host's handler, so what the handler returns is left alone.\nconst useApplyAction = (conversationId, onApplied) =>\n useActOnAction(neetoAssistApi.applyAction, conversationId, {\n onSuccess: data => {\n onApplied?.(data?.action);\n },\n });\n\nconst useDismissAction = conversationId =>\n useActOnAction(neetoAssistApi.dismissAction, conversationId);\n\nexport {\n useFetchRuns,\n useAskNeetoAssist,\n useUpdateFeedback,\n useApplyAction,\n useDismissAction,\n};\n","import { withImmutableActions } from \"neetocommons/v2/react-utils\";\nimport { getFromLocalStorage, setToLocalStorage } from \"neetocommons/v2/utils\";\nimport { create } from \"zustand\";\n\nimport { EXPANDED_STORAGE_KEY } from \"common/constants\";\n\n// The pane is mounted once in the host's layout and the button sits on the\n// ticket, so this is how they talk: whether the pane is open and how wide, and\n// which conversation it is about. A reload starts closed, and the width is kept.\n/** @type {import(\"neetocommons/react-utils\").ZustandStoreHook} */\nconst useNeetoAssistStore = create(\n withImmutableActions(set => ({\n isOpen: false,\n isExpanded: getFromLocalStorage(EXPANDED_STORAGE_KEY) || false,\n conversation: null,\n seenDrafts: {},\n\n close: () => set({ isOpen: false }),\n\n toggle: () => set(state => ({ isOpen: !state.isOpen })),\n\n setExpanded: value => {\n setToLocalStorage(EXPANDED_STORAGE_KEY, value);\n set({ isExpanded: value });\n },\n\n setConversation: conversation => set({ conversation }),\n\n // Only the conversation that is leaving: the next one's button may already\n // have taken its place.\n clearConversation: conversationId =>\n set(state =>\n state.conversation?.id === conversationId ? { conversation: null } : {}\n ),\n\n markDraftSeen: (conversationId, runId) =>\n set(state => ({\n seenDrafts: { ...state.seenDrafts, [conversationId]: runId },\n })),\n }))\n);\n\nexport default useNeetoAssistStore;\n"],"names":["Sparkle","_ref","_ref$size","size","className","otherProps","_objectWithoutProperties","_excluded","_jsxs","_objectSpread","fill","height","stroke","strokeLinecap","strokeLinejoin","strokeWidth","viewBox","width","xmlns","children","_jsx","d","collapseRepeatedSkips","runs","reasons","filter","run","index","next","includes","skippedReason","withoutReplacedDrafts","kind","REPLY_SUGGESTION","status","slice","some","isPending","_ref2","PENDING_STATUSES","withoutRepeatedQuietSkips","QUIET_SKIPPED_REASONS","runsInConversationOrder","reverse","latestDraftId","_runs$find","find","_ref3","suggestedReply","id","hasWrittenReply","_ref4","answer","isRateable","_ref5","RATEABLE_STATUSES","UNRATEABLE_SKIPPED_REASONS","hasPendingRun","arguments","length","undefined","stepsOf","_ref6","steps","hasRunningStep","any","propEq","actionsOf","_ref7","actions","skippedReasonMessageKey","reason","propOr","SKIPPED_REASON_MESSAGE_KEYS","errorMessageKey","error","response","ERROR_MESSAGE_KEYS","isWebUrl","url","test","useFetchRuns","conversationId","useQuery","queryKey","QUERY_KEYS","RUNS","queryFn","neetoAssistApi","fetchRuns","select","_ref$runs","_ref$credits","credits","staleTime","retry","refetchInterval","_ref2$state","state","data","PENDING_POLL_INTERVAL","IDLE_POLL_INTERVAL","useAskNeetoAssist","useMutationWithInvalidation","createRun","keysToInvalidate","useUpdateFeedback","updateFeedback","useActOnAction","mutationFn","callbacks","queryClient","useQueryClient","useMutation","onSettled","invalidateQueries","useApplyAction","onApplied","applyAction","onSuccess","action","useDismissAction","dismissAction","useNeetoAssistStore","create","withImmutableActions","set","isOpen","isExpanded","getFromLocalStorage","EXPANDED_STORAGE_KEY","conversation","seenDrafts","close","toggle","setExpanded","value","setToLocalStorage","setConversation","clearConversation","_state$conversation","markDraftSeen","runId","_defineProperty"],"mappings":";;;;;;;;;;;;;AAAA,IAAMA,OAAO,GAAG,SAAVA,OAAOA,CAAAC,IAAA,EAAA;AAAA,EAAA,IAAAC,SAAA,GAAAD,IAAA,CAAME,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,SAAA;IAAEE,SAAS,GAAAH,IAAA,CAATG,SAAS;AAAKC,IAAAA,UAAU,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA,CAAA;AAAA,EAAA,oBACpDC,IAAA,CAAA,KAAA,EAAAC,eAAA,CAAAA,eAAA,CAAA;AACQL,IAAAA,SAAS,EAATA,SAAS;AACf,IAAA,aAAA,EAAY,MAAM;AAClBM,IAAAA,IAAI,EAAC,MAAM;AACXC,IAAAA,MAAM,EAAER,IAAK;AACbS,IAAAA,MAAM,EAAC,cAAc;AACrBC,IAAAA,aAAa,EAAC,OAAO;AACrBC,IAAAA,cAAc,EAAC,OAAO;AACtBC,IAAAA,WAAW,EAAC,KAAK;AACjBC,IAAAA,OAAO,EAAC,WAAW;AACnBC,IAAAA,KAAK,EAAEd,IAAK;AACZe,IAAAA,KAAK,EAA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