@atlaskit/smart-card 26.49.0 → 26.49.2

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 (80) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/state/hooks/use-ai-summary/ai-summary-service/index.js +39 -27
  3. package/dist/cjs/state/hooks/use-ai-summary/index.js +16 -38
  4. package/dist/cjs/utils/analytics/analytics.js +1 -1
  5. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +37 -29
  6. package/dist/cjs/view/FlexibleCard/components/blocks/block/index.js +1 -4
  7. package/dist/cjs/view/FlexibleCard/components/blocks/element-group/index.js +8 -9
  8. package/dist/cjs/view/HoverCard/components/ContentContainer.js +39 -13
  9. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +1 -10
  10. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +63 -16
  11. package/dist/cjs/view/LinkUrl/index.js +1 -1
  12. package/dist/cjs/view/common/ai-prism/index.js +0 -1
  13. package/dist/cjs/view/common/ai-summary/index.js +9 -3
  14. package/dist/es2019/state/hooks/use-ai-summary/ai-summary-service/index.js +14 -5
  15. package/dist/es2019/state/hooks/use-ai-summary/index.js +17 -35
  16. package/dist/es2019/utils/analytics/analytics.js +1 -1
  17. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +33 -26
  18. package/dist/es2019/view/FlexibleCard/components/blocks/block/index.js +1 -1
  19. package/dist/es2019/view/FlexibleCard/components/blocks/element-group/index.js +0 -1
  20. package/dist/es2019/view/HoverCard/components/ContentContainer.js +35 -10
  21. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +2 -7
  22. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +56 -7
  23. package/dist/es2019/view/LinkUrl/index.js +1 -1
  24. package/dist/es2019/view/common/ai-prism/index.js +0 -1
  25. package/dist/es2019/view/common/ai-summary/index.js +7 -3
  26. package/dist/esm/state/hooks/use-ai-summary/ai-summary-service/index.js +39 -27
  27. package/dist/esm/state/hooks/use-ai-summary/index.js +17 -39
  28. package/dist/esm/utils/analytics/analytics.js +1 -1
  29. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +38 -30
  30. package/dist/esm/view/FlexibleCard/components/blocks/block/index.js +1 -1
  31. package/dist/esm/view/FlexibleCard/components/blocks/element-group/index.js +0 -1
  32. package/dist/esm/view/HoverCard/components/ContentContainer.js +39 -13
  33. package/dist/esm/view/HoverCard/components/HoverCardContent.js +2 -11
  34. package/dist/esm/view/HoverCard/components/views/resolved/index.js +66 -18
  35. package/dist/esm/view/LinkUrl/index.js +1 -1
  36. package/dist/esm/view/common/ai-prism/index.js +0 -1
  37. package/dist/esm/view/common/ai-summary/index.js +9 -3
  38. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +3 -1
  39. package/dist/types/state/hooks/use-ai-summary/index.d.ts +0 -1
  40. package/dist/types/view/BlockCard/views/flexible/unresolved-view/index.d.ts +2 -2
  41. package/dist/types/view/BlockCard/views/flexible/unresolved-view/types.d.ts +3 -2
  42. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/ai-event-error-viewed/index.d.ts +1 -2
  43. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/types.d.ts +2 -2
  44. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/types.d.ts +2 -3
  45. package/dist/types/view/FlexibleCard/components/blocks/block/index.d.ts +2 -3
  46. package/dist/types/view/FlexibleCard/components/blocks/element-group/index.d.ts +2 -3
  47. package/dist/types/view/FlexibleCard/components/blocks/element-group/types.d.ts +3 -2
  48. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +3 -3
  49. package/dist/types/view/FlexibleCard/components/container/hover-card-control/index.d.ts +2 -2
  50. package/dist/types/view/FlexibleCard/components/container/hover-card-control/types.d.ts +3 -2
  51. package/dist/types/view/FlexibleCard/components/container/index.d.ts +2 -4
  52. package/dist/types/view/FlexibleCard/components/container/types.d.ts +3 -2
  53. package/dist/types/view/HoverCard/components/ContentContainer.d.ts +3 -2
  54. package/dist/types/view/HoverCard/components/views/resolved/types.d.ts +0 -2
  55. package/dist/types/view/HoverCard/types.d.ts +1 -1
  56. package/dist/types/view/common/ai-prism/index.d.ts +3 -2
  57. package/dist/types/view/common/ai-prism/types.d.ts +3 -2
  58. package/dist/types/view/common/ai-summary/index.d.ts +4 -0
  59. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +3 -1
  60. package/dist/types-ts4.5/state/hooks/use-ai-summary/index.d.ts +0 -1
  61. package/dist/types-ts4.5/view/BlockCard/views/flexible/unresolved-view/index.d.ts +2 -2
  62. package/dist/types-ts4.5/view/BlockCard/views/flexible/unresolved-view/types.d.ts +3 -2
  63. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/ai-event-error-viewed/index.d.ts +1 -2
  64. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/types.d.ts +2 -2
  65. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/types.d.ts +2 -3
  66. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/block/index.d.ts +2 -3
  67. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/element-group/index.d.ts +2 -3
  68. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/element-group/types.d.ts +3 -2
  69. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/types.d.ts +3 -3
  70. package/dist/types-ts4.5/view/FlexibleCard/components/container/hover-card-control/index.d.ts +2 -2
  71. package/dist/types-ts4.5/view/FlexibleCard/components/container/hover-card-control/types.d.ts +3 -2
  72. package/dist/types-ts4.5/view/FlexibleCard/components/container/index.d.ts +2 -4
  73. package/dist/types-ts4.5/view/FlexibleCard/components/container/types.d.ts +3 -2
  74. package/dist/types-ts4.5/view/HoverCard/components/ContentContainer.d.ts +3 -2
  75. package/dist/types-ts4.5/view/HoverCard/components/views/resolved/types.d.ts +0 -2
  76. package/dist/types-ts4.5/view/HoverCard/types.d.ts +1 -1
  77. package/dist/types-ts4.5/view/common/ai-prism/index.d.ts +3 -2
  78. package/dist/types-ts4.5/view/common/ai-prism/types.d.ts +3 -2
  79. package/dist/types-ts4.5/view/common/ai-summary/index.d.ts +4 -0
  80. package/package.json +5 -5
@@ -7,7 +7,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
7
7
  import LinkWarningModal from './LinkWarningModal';
8
8
  const PACKAGE_DATA = {
9
9
  packageName: "@atlaskit/smart-card",
10
- packageVersion: "26.49.0",
10
+ packageVersion: "26.49.2",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -1,6 +1,5 @@
1
1
  /** @jsx jsx */
2
2
  import { css, jsx } from '@emotion/react';
3
- import React from 'react';
4
3
  import { useThemeObserver } from '@atlaskit/tokens';
5
4
  import { AI_BORDER_PALETTE, INNER_BORDER_RADIUS } from './constants';
6
5
  import AIGlowingBorder from './ai-glowing-border';
@@ -21,13 +21,14 @@ const AISummaryCSS = css({
21
21
  */
22
22
 
23
23
  const AISummary = ({
24
- content,
24
+ content = '',
25
25
  showIcon = false,
26
26
  iconComponent,
27
27
  overrideCss,
28
- testId = 'ai-summary'
28
+ testId = 'ai-summary',
29
+ minHeight = 0
29
30
  }) => {
30
- if (!content) {
31
+ if (!content && minHeight === 0) {
31
32
  return null;
32
33
  }
33
34
  return jsx(Markdown, {
@@ -39,6 +40,9 @@ const AISummary = ({
39
40
  overrides: {
40
41
  Icon: iconComponent !== null && iconComponent !== void 0 ? iconComponent : AITooltipIcon
41
42
  }
43
+ },
44
+ style: {
45
+ minHeight: minHeight
42
46
  }
43
47
  });
44
48
  };
@@ -44,8 +44,14 @@ export var AISummaryService = /*#__PURE__*/function () {
44
44
  return fetch(requestUrl, options);
45
45
  case 6:
46
46
  response = _context.sent;
47
+ if (!(!response.ok || response.status >= 400)) {
48
+ _context.next = 11;
49
+ break;
50
+ }
51
+ throw new Error("Status: ".concat(response.status, "\n URL: ").concat(_this.url, "\n StatusText ").concat(response.statusText));
52
+ case 11:
47
53
  return _context.abrupt("return", readStream(response));
48
- case 8:
54
+ case 12:
49
55
  case "end":
50
56
  return _context.stop();
51
57
  }
@@ -96,10 +102,11 @@ export var AISummaryService = /*#__PURE__*/function () {
96
102
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
97
103
  while (1) switch (_context2.prev = _context2.next) {
98
104
  case 0:
99
- summaryStyle = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : 'short';
100
- this.state = _objectSpread(_objectSpread({}, this.state), {}, {
101
- status: 'loading'
102
- });
105
+ summaryStyle = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : 'medium';
106
+ this.state = {
107
+ status: 'loading',
108
+ content: ''
109
+ };
103
110
  _iterator2 = _createForOfIteratorHelper(this.subscribedStateSetters);
104
111
  try {
105
112
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
@@ -126,7 +133,7 @@ export var AISummaryService = /*#__PURE__*/function () {
126
133
  return _iterator.next();
127
134
  case 15:
128
135
  if (!(_iteratorAbruptCompletion = !(_step = _context2.sent).done)) {
129
- _context2.next = 21;
136
+ _context2.next = 22;
130
137
  break;
131
138
  }
132
139
  chunk = _step.value;
@@ -146,53 +153,58 @@ export var AISummaryService = /*#__PURE__*/function () {
146
153
  _iterator3.f();
147
154
  }
148
155
  }
149
- case 18:
156
+
157
+ //if AI Mate service returns cached summary we get the summary text in one piece as the last message
158
+ if (chunk.type === 'FINAL_RESPONSE') {
159
+ bufferContent = chunk.message.message.content;
160
+ }
161
+ case 19:
150
162
  _iteratorAbruptCompletion = false;
151
163
  _context2.next = 13;
152
164
  break;
153
- case 21:
154
- _context2.next = 27;
165
+ case 22:
166
+ _context2.next = 28;
155
167
  break;
156
- case 23:
157
- _context2.prev = 23;
168
+ case 24:
169
+ _context2.prev = 24;
158
170
  _context2.t0 = _context2["catch"](11);
159
171
  _didIteratorError = true;
160
172
  _iteratorError = _context2.t0;
161
- case 27:
162
- _context2.prev = 27;
173
+ case 28:
163
174
  _context2.prev = 28;
175
+ _context2.prev = 29;
164
176
  if (!(_iteratorAbruptCompletion && _iterator.return != null)) {
165
- _context2.next = 32;
177
+ _context2.next = 33;
166
178
  break;
167
179
  }
168
- _context2.next = 32;
180
+ _context2.next = 33;
169
181
  return _iterator.return();
170
- case 32:
171
- _context2.prev = 32;
182
+ case 33:
183
+ _context2.prev = 33;
172
184
  if (!_didIteratorError) {
173
- _context2.next = 35;
185
+ _context2.next = 36;
174
186
  break;
175
187
  }
176
188
  throw _iteratorError;
177
- case 35:
178
- return _context2.finish(32);
179
189
  case 36:
180
- return _context2.finish(27);
190
+ return _context2.finish(33);
181
191
  case 37:
192
+ return _context2.finish(28);
193
+ case 38:
182
194
  this.state = {
183
195
  status: 'done',
184
196
  content: bufferContent
185
197
  };
186
- _context2.next = 43;
198
+ _context2.next = 44;
187
199
  break;
188
- case 40:
189
- _context2.prev = 40;
200
+ case 41:
201
+ _context2.prev = 41;
190
202
  _context2.t1 = _context2["catch"](4);
191
203
  this.state = {
192
204
  status: 'error',
193
205
  content: ''
194
206
  };
195
- case 43:
207
+ case 44:
196
208
  _iterator4 = _createForOfIteratorHelper(this.subscribedStateSetters);
197
209
  try {
198
210
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
@@ -204,11 +216,11 @@ export var AISummaryService = /*#__PURE__*/function () {
204
216
  } finally {
205
217
  _iterator4.f();
206
218
  }
207
- case 45:
219
+ case 46:
208
220
  case "end":
209
221
  return _context2.stop();
210
222
  }
211
- }, _callee2, this, [[4, 40], [11, 23, 27, 37], [28,, 32, 36]]);
223
+ }, _callee2, this, [[4, 41], [11, 24, 28, 38], [29,, 33, 37]]);
212
224
  }));
213
225
  function summariseUrl() {
214
226
  return _summariseUrl.apply(this, arguments);
@@ -1,13 +1,13 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { useState, useEffect, useMemo } from 'react';
2
+ import { useState, useEffect } from 'react';
3
3
  import { AISummariesStore } from './ai-summary-service/store';
4
4
  import { AISummaryService } from './ai-summary-service';
5
5
  export var useAISummary = function useAISummary(props) {
6
6
  var _AISummariesStore$get;
7
7
  var url = props.url,
8
8
  baseUrl = props.baseUrl,
9
- product = props.product,
10
- headers = props.headers;
9
+ headers = props.headers,
10
+ product = props.product;
11
11
  var _useState = useState(((_AISummariesStore$get = AISummariesStore.get(url)) === null || _AISummariesStore$get === void 0 ? void 0 : _AISummariesStore$get.state) || {
12
12
  status: 'ready',
13
13
  content: ''
@@ -15,47 +15,25 @@ export var useAISummary = function useAISummary(props) {
15
15
  _useState2 = _slicedToArray(_useState, 2),
16
16
  state = _useState2[0],
17
17
  setState = _useState2[1];
18
-
19
- // Can be used to know the summary status upon mounting a component (HoverCard UI state for example).
20
- // For other scenarios, opt for dynamic status updates via state.status.
21
- var isSummarisedOnMount = useMemo(function () {
22
- var _AISummariesStore$get2;
23
- return ((_AISummariesStore$get2 = AISummariesStore.get(url)) === null || _AISummariesStore$get2 === void 0 ? void 0 : _AISummariesStore$get2.state.status) === 'done';
24
- }, [url]);
25
18
  useEffect(function () {
26
- // Create or subscribe to an AI service only if a summary has not been previously generated.
27
- // Otherwise, use the data from the current state synchronized with a cache (AISummariesStore).
28
- if (!isSummarisedOnMount) {
29
- var aISummaryService = AISummariesStore.get(url);
30
- var isAISummaryServiceInitiated = !!aISummaryService;
31
- if (isAISummaryServiceInitiated) {
32
- //if we want to subscribe to updates from an existing AI service that has not yet provided a summary or is currently in progress.
33
- var unsubscribe = aISummaryService.subscribe(setState);
34
- return function () {
35
- return unsubscribe();
36
- };
37
- } else {
38
- var _AISummariesStore$get3;
39
- //if we want to create a new AI service and wish to subscribe for updates
40
- AISummariesStore.set(url, new AISummaryService({
41
- url: url,
42
- baseUrl: baseUrl,
43
- product: product,
44
- headers: headers
45
- }));
46
- var _unsubscribe = (_AISummariesStore$get3 = AISummariesStore.get(url)) === null || _AISummariesStore$get3 === void 0 ? void 0 : _AISummariesStore$get3.subscribe(setState);
47
- return function () {
48
- return _unsubscribe && _unsubscribe();
49
- };
50
- }
19
+ var _AISummariesStore$get2;
20
+ if (!AISummariesStore.get(url)) {
21
+ AISummariesStore.set(url, new AISummaryService({
22
+ url: url,
23
+ baseUrl: baseUrl,
24
+ headers: headers,
25
+ product: product
26
+ }));
51
27
  }
52
- }, [isSummarisedOnMount, url, baseUrl, product, headers]);
28
+
29
+ //returns function that calls unsubscribe method
30
+ return (_AISummariesStore$get2 = AISummariesStore.get(url)) === null || _AISummariesStore$get2 === void 0 ? void 0 : _AISummariesStore$get2.subscribe(setState);
31
+ }, [url, baseUrl, headers, product]);
53
32
  var summariseUrl = function summariseUrl() {
54
- var _AISummariesStore$get4;
55
- return (_AISummariesStore$get4 = AISummariesStore.get(url)) === null || _AISummariesStore$get4 === void 0 ? void 0 : _AISummariesStore$get4.summariseUrl();
33
+ var _AISummariesStore$get3;
34
+ return (_AISummariesStore$get3 = AISummariesStore.get(url)) === null || _AISummariesStore$get3 === void 0 ? void 0 : _AISummariesStore$get3.summariseUrl();
56
35
  };
57
36
  return {
58
- isSummarisedOnMount: isSummarisedOnMount,
59
37
  summariseUrl: summariseUrl,
60
38
  state: state
61
39
  };
@@ -15,7 +15,7 @@ export var ANALYTICS_CHANNEL = 'media';
15
15
  export var context = {
16
16
  componentName: 'smart-cards',
17
17
  packageName: "@atlaskit/smart-card",
18
- packageVersion: "26.49.0"
18
+ packageVersion: "26.49.2"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
- import React, { useCallback, useMemo, useState } from 'react';
4
+ import React, { useCallback, useMemo, useRef, useState, useEffect } from 'react';
5
5
  import { FormattedMessage } from 'react-intl-next';
6
6
  import { Box, Inline } from '@atlaskit/primitives';
7
7
  import { ActionName, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../../constants';
@@ -23,39 +23,46 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
23
23
  actions = _props$actions === void 0 ? [] : _props$actions,
24
24
  metadata = props.metadata,
25
25
  onActionMenuOpenChange = props.onActionMenuOpenChange,
26
- onAIActionChange = props.onAIActionChange,
27
26
  _props$size = props.size,
28
27
  size = _props$size === void 0 ? SmartLinkSize.Medium : _props$size,
29
- testId = props.testId;
30
- var _useState = useState('ready'),
31
- _useState2 = _slicedToArray(_useState, 2),
32
- aiState = _useState2[0],
33
- setAIState = _useState2[1];
28
+ testId = props.testId,
29
+ aiSummaryMinHeight = props.aiSummaryMinHeight;
30
+ var metadataElements = renderElementItems(metadata);
34
31
  var _useAnalyticsEvents = useAnalyticsEvents(),
35
32
  fireEvent = _useAnalyticsEvents.fireEvent;
36
- var metadataElements = renderElementItems(metadata);
37
33
  var context = useFlexibleUiContext();
38
34
  var url = (context === null || context === void 0 ? void 0 : context.url) || '';
39
- var aiSummary = useAISummary({
40
- url: url
41
- });
42
- var _aiSummary$state = aiSummary.state,
43
- content = _aiSummary$state.content,
44
- status = _aiSummary$state.status,
45
- isSummarisedOnMount = aiSummary.isSummarisedOnMount;
46
- var onAIActionClick = useCallback(function () {
47
- fireEvent('ui.button.clicked.aiSummary', {});
48
- setAIState('loading');
49
- if (onAIActionChange) {
50
- onAIActionChange('loading');
35
+ var _useAISummary = useAISummary({
36
+ url: url
37
+ }),
38
+ summariseUrl = _useAISummary.summariseUrl,
39
+ _useAISummary$state = _useAISummary.state,
40
+ content = _useAISummary$state.content,
41
+ status = _useAISummary$state.status;
42
+ var showAISummary = status !== 'ready' && status !== 'error';
43
+ var isSummarisedOnMountRef = useRef(status === 'done');
44
+ var isErroredOnMountRef = useRef(status === 'error');
45
+ var _useState = useState(false),
46
+ _useState2 = _slicedToArray(_useState, 2),
47
+ showAISummaryErrorMessage = _useState2[0],
48
+ setShowAISummaryErrorMessage = _useState2[1];
49
+ useEffect(function () {
50
+ if (isErroredOnMountRef.current && status === 'loading') {
51
+ isErroredOnMountRef.current = false;
52
+ setShowAISummaryErrorMessage(true);
53
+ } else {
54
+ setShowAISummaryErrorMessage(!isErroredOnMountRef.current && status === 'error');
51
55
  }
52
- }, [onAIActionChange, fireEvent]);
56
+ }, [status]);
53
57
  var combinedActions = useMemo(function () {
54
- if (aiState === 'ready') {
58
+ if (status === 'ready' || status === 'error') {
55
59
  var aiAction = {
56
60
  content: /*#__PURE__*/React.createElement(FormattedMessage, messages.ai_summarize),
57
61
  name: ActionName.CustomAction,
58
- onClick: onAIActionClick,
62
+ onClick: function onClick() {
63
+ fireEvent('ui.button.clicked.aiSummary', {});
64
+ summariseUrl();
65
+ },
59
66
  testId: "".concat(testId, "-ai-summary-action"),
60
67
  icon: /*#__PURE__*/React.createElement(AIIcon, {
61
68
  label: "AIIcon"
@@ -64,7 +71,7 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
64
71
  return [aiAction].concat(_toConsumableArray(actions));
65
72
  }
66
73
  return actions;
67
- }, [actions, aiState, onAIActionClick, testId]);
74
+ }, [actions, status, testId, summariseUrl, fireEvent]);
68
75
  var onDropdownOpenChange = useCallback(function (isOpen) {
69
76
  if (onActionMenuOpenChange) {
70
77
  onActionMenuOpenChange({
@@ -76,17 +83,18 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
76
83
  direction: SmartLinkDirection.Vertical,
77
84
  testId: "".concat(testId, "-resolved-view")
78
85
  }), status === 'done' && /*#__PURE__*/React.createElement(AIEventSummaryViewed, {
79
- fromCache: isSummarisedOnMount
80
- }), /*#__PURE__*/React.createElement(AISummary, {
86
+ fromCache: isSummarisedOnMountRef.current
87
+ }), showAISummary && /*#__PURE__*/React.createElement(AISummary, {
88
+ minHeight: aiSummaryMinHeight,
81
89
  content: content,
82
- showIcon: isSummarisedOnMount
90
+ showIcon: isSummarisedOnMountRef.current
83
91
  }), /*#__PURE__*/React.createElement(Inline, {
84
92
  alignBlock: "center",
85
93
  alignInline: "end",
86
94
  grow: "fill",
87
95
  spread: "space-between"
88
- }, /*#__PURE__*/React.createElement(Box, null, !isSummarisedOnMount && (aiState === 'loading' || aiState === 'done') ? /*#__PURE__*/React.createElement(AIStateIndicator, {
89
- state: aiState,
96
+ }, /*#__PURE__*/React.createElement(Box, null, !isSummarisedOnMountRef.current && (status === 'loading' || status === 'done') ? /*#__PURE__*/React.createElement(AIStateIndicator, {
97
+ state: status,
90
98
  testId: "".concat(testId, "-state-indicator")
91
99
  }) : /*#__PURE__*/React.createElement(ElementGroup, {
92
100
  width: SmartLinkWidth.FitToContent,
@@ -96,7 +104,7 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
96
104
  items: combinedActions,
97
105
  appearance: "default",
98
106
  size: size
99
- }))), status === 'error' && /*#__PURE__*/React.createElement(Inline, {
107
+ }))), showAISummaryErrorMessage && /*#__PURE__*/React.createElement(Inline, {
100
108
  grow: "fill"
101
109
  }, /*#__PURE__*/React.createElement(AIEventErrorViewed, null), /*#__PURE__*/React.createElement(AIStateIndicator, {
102
110
  state: status,
@@ -1,7 +1,7 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
2
  var _templateObject;
3
3
  /** @jsx jsx */
4
- import React, { useEffect } from 'react';
4
+ import { useEffect } from 'react';
5
5
  import { css, jsx } from '@emotion/react';
6
6
  import { ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../../constants';
7
7
  import { getBaseStyles, getGapSize, highlightRemoveStyles, renderChildren } from '../utils';
@@ -1,7 +1,6 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
2
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
3
3
  /** @jsx jsx */
4
- import React from 'react';
5
4
  import { css, jsx } from '@emotion/react';
6
5
  import { SmartLinkAlignment, SmartLinkDirection, SmartLinkPosition, SmartLinkSize, SmartLinkWidth } from '../../../../../constants';
7
6
  import { getBaseStyles, getGapSize, renderChildren } from '../utils';
@@ -1,31 +1,57 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["children", "isAIEnabled", "showPrism", "testId"];
4
+ var _excluded = ["children", "isAIEnabled", "testId", "url"],
5
+ _excluded2 = ["children", "isAIEnabled", "testId", "url"];
4
6
  /** @jsx jsx */
5
7
  import { jsx } from '@emotion/react';
6
- import React from 'react';
8
+ import { useState, useEffect } from 'react';
7
9
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
10
  import { HoverCardContainer, popupContainerStyles } from '../styled';
9
11
  import AIPrism from '../../common/ai-prism';
10
12
  import { hoverCardClassName } from './HoverCardContent';
11
- var ContentContainer = function ContentContainer(_ref) {
13
+ import { useAISummary } from '../../../state/hooks/use-ai-summary';
14
+ var ConnectedAIPrismContainer = function ConnectedAIPrismContainer(_ref) {
12
15
  var children = _ref.children,
13
16
  _ref$isAIEnabled = _ref.isAIEnabled,
14
17
  isAIEnabled = _ref$isAIEnabled === void 0 ? false : _ref$isAIEnabled,
15
- _ref$showPrism = _ref.showPrism,
16
- showPrism = _ref$showPrism === void 0 ? false : _ref$showPrism,
17
18
  testId = _ref.testId,
19
+ url = _ref.url,
18
20
  props = _objectWithoutProperties(_ref, _excluded);
21
+ var _useAISummary = useAISummary({
22
+ url: url
23
+ }),
24
+ status = _useAISummary.state.status;
25
+ var _useState = useState(status === 'loading'),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ showPrism = _useState2[0],
28
+ setShowPrism = _useState2[1];
29
+ useEffect(function () {
30
+ setShowPrism(status === 'loading');
31
+ }, [status]);
32
+ var container = jsx("div", _extends({
33
+ className: hoverCardClassName,
34
+ css: [HoverCardContainer, isAIEnabled && showPrism ? undefined : popupContainerStyles],
35
+ "data-testid": testId
36
+ }, props), children);
37
+ return isAIEnabled ? jsx(AIPrism, {
38
+ isVisible: showPrism,
39
+ testId: "".concat(testId, "-prism")
40
+ }, container) : container;
41
+ };
42
+ var ContentContainer = function ContentContainer(_ref2) {
43
+ var children = _ref2.children,
44
+ _ref2$isAIEnabled = _ref2.isAIEnabled,
45
+ isAIEnabled = _ref2$isAIEnabled === void 0 ? false : _ref2$isAIEnabled,
46
+ testId = _ref2.testId,
47
+ url = _ref2.url,
48
+ props = _objectWithoutProperties(_ref2, _excluded2);
19
49
  if (getBooleanFF('platform.linking-platform.smart-card.hover-card-ai-summaries')) {
20
- var container = jsx("div", _extends({
21
- className: hoverCardClassName,
22
- css: [HoverCardContainer, isAIEnabled && showPrism ? undefined : popupContainerStyles],
23
- "data-testid": testId
50
+ return jsx(ConnectedAIPrismContainer, _extends({
51
+ isAIEnabled: isAIEnabled,
52
+ url: url,
53
+ testId: testId
24
54
  }, props), children);
25
- return isAIEnabled ? jsx(AIPrism, {
26
- isVisible: showPrism,
27
- testId: "".concat(testId, "-prism")
28
- }, container) : container;
29
55
  }
30
56
  return jsx("div", _extends({
31
57
  className: hoverCardClassName,
@@ -1,11 +1,10 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
3
  /** @jsx jsx */
5
4
  import { jsx } from '@emotion/react';
6
5
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
7
6
  import CopyIcon from '@atlaskit/icon/glyph/copy';
8
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
7
+ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
9
8
  import { useSmartLinkContext } from '@atlaskit/link-provider';
10
9
  import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
11
10
  import { extractMetadata } from '../../../extractors/hover/extractMetadata';
@@ -86,10 +85,6 @@ var HoverCardContent = function HoverCardContent(_ref) {
86
85
  var services = getServices(linkState.details);
87
86
  var statusRef = useRef(linkStatus);
88
87
  var analyticsRef = useRef(analytics);
89
- var _useState = useState(false),
90
- _useState2 = _slicedToArray(_useState, 2),
91
- showPrism = _useState2[0],
92
- setShowPrism = _useState2[1];
93
88
  useEffect(function () {
94
89
  /**
95
90
  * Must access current analytics object value via ref because its not stable
@@ -162,9 +157,6 @@ var HoverCardContent = function HoverCardContent(_ref) {
162
157
  var onClickStopPropagation = useCallback(function (e) {
163
158
  return e.stopPropagation();
164
159
  }, []);
165
- var onAIActionChange = useCallback(function (state) {
166
- setShowPrism(state === 'loading');
167
- }, []);
168
160
  var getCardView = function getCardView(cardState) {
169
161
  if (cardState.metadataStatus === 'pending') {
170
162
  return jsx(HoverCardLoadingView, {
@@ -197,7 +189,6 @@ var HoverCardContent = function HoverCardContent(_ref) {
197
189
  flexibleCardProps: flexibleCardProps,
198
190
  isAISummaryEnabled: isAISummaryEnabled,
199
191
  onActionClick: onActionClick,
200
- onAIActionChange: onAIActionChange,
201
192
  titleBlockProps: titleBlockProps
202
193
  });
203
194
  }
@@ -209,7 +200,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
209
200
  onMouseLeave: onMouseLeave,
210
201
  onClick: onClickStopPropagation,
211
202
  isAIEnabled: isAISummaryEnabled,
212
- showPrism: showPrism
203
+ url: url
213
204
  }, cardView) : null;
214
205
  };
215
206
  export default HoverCardContent;