@redocly/replay 0.27.0-next.9 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/{replay-AiChatProvider-B94RnQsz.js → replay-AiChatProvider-LQhrLIDL.js} +44 -44
  2. package/dist/{replay-AiChatProvider-P2u2MtTk.js → replay-AiChatProvider-Oms5CFgT.js} +1 -1
  3. package/dist/{replay-AiChatSqliteDBStorage-z_QUPu2M.js → replay-AiChatSqliteDBStorage-3-p1mthX.js} +1 -1
  4. package/dist/{replay-AiChatSqliteDBStorage-BtTa9KkQ.js → replay-AiChatSqliteDBStorage-GZibdHOQ.js} +1 -1
  5. package/dist/replay-AiPanel-BvwwBTh1.js +742 -0
  6. package/dist/{replay-AiPanel-BCkDovN_.js → replay-AiPanel-lcDNvgo0.js} +973 -1176
  7. package/dist/replay-FileWatcher-ClVd_wG0.js +1 -0
  8. package/dist/replay-FileWatcher-DR-wJLe2.js +343 -0
  9. package/dist/replay-Observable-D6wKbFwB.js +31 -0
  10. package/dist/replay-Observable-bjJ6wkRB.js +1 -0
  11. package/dist/replay-SemanticSearchService-CCqwCRo6.js +1 -0
  12. package/dist/replay-SemanticSearchService-U1eXQGfF.js +723 -0
  13. package/dist/{replay-SqliteDBStorage-DMxFWJQ7.js → replay-SqliteDBStorage-Dn6DoVWW.js} +1 -1
  14. package/dist/{replay-SqliteDBStorage-D9b6LAKr.js → replay-SqliteDBStorage-d_ZK6ScA.js} +1 -1
  15. package/dist/replay-TauriFileSystemAdapter-CpiUuG3T.js +99 -0
  16. package/dist/replay-TauriFileSystemAdapter-dwJ0xBYr.js +1 -0
  17. package/dist/replay-TauriRootStorage-CuVbYMXX.js +605 -0
  18. package/dist/replay-TauriRootStorage-DhzbAahU.js +1 -0
  19. package/dist/{replay-agent-loop-C2QNfRSA.js → replay-agent-loop-BLSu4v_O.js} +1 -1
  20. package/dist/{replay-agent-loop-C8ERLqB5.js → replay-agent-loop-DgEHdXUt.js} +11 -11
  21. package/dist/{replay-ai-chat-mappers-fViZvzIy.js → replay-ai-chat-mappers-BvfcEubB.js} +5 -5
  22. package/dist/{replay-ai-chat-mappers-BMhtm64Y.js → replay-ai-chat-mappers-Dy2kJ7ZG.js} +1 -1
  23. package/dist/replay-core-BJmXmoC5.js +1 -0
  24. package/dist/replay-core-B_hiOZZr.js +10 -0
  25. package/dist/{replay-create-model-BhuazQ2q.js → replay-create-model-DNPFcOIp.js} +579 -578
  26. package/dist/{replay-create-model-BgR6vFGV.js → replay-create-model-bOIDB-e8.js} +10 -10
  27. package/dist/{replay-db-DAiJFj0l.js → replay-db-BQGv3PGw.js} +1 -1
  28. package/dist/{replay-db-DKzJowQC.js → replay-db-CMXZZs9v.js} +1 -1
  29. package/dist/{replay-external-resolver-UONYkON2.js → replay-external-resolver-mrykFC2h.js} +2 -2
  30. package/dist/{replay-external-resolver-BY6AAeGp.js → replay-external-resolver-n5OvQMRF.js} +1 -1
  31. package/dist/replay-index-3lwhSmvi.js +1 -0
  32. package/dist/{replay-index-BowK-_3Z.js → replay-index-Bc5RHu5L.js} +23698 -25407
  33. package/dist/replay-index-CFLu-XMV.js +25 -0
  34. package/dist/{replay-index-DWKlhkdU.js → replay-index-CHGVyIdG.js} +1 -1
  35. package/dist/replay-index-CSR_qlua.js +1 -0
  36. package/dist/replay-index-CepJ5Z0m.js +6875 -0
  37. package/dist/{replay-index-amF_dPN8.js → replay-index-CgCGhu4l.js} +6 -6
  38. package/dist/replay-index-DDjmUXWm.js +1 -0
  39. package/dist/{replay-index-DM12kT-D.js → replay-index-DiSy_1OY.js} +1 -1
  40. package/dist/replay-index-Oct6Dygd.js +1 -0
  41. package/dist/{replay-index-BubK_s3I.js → replay-index-QXosJxRc.js} +18 -18
  42. package/dist/replay-index-jkDlU0Lx.js +32 -0
  43. package/dist/{replay-lint-CAN3a2zf.js → replay-lint-DoHQIATV.js} +3 -3
  44. package/dist/{replay-lint-a0aMVdOC.js → replay-lint-PWaLESz5.js} +3 -3
  45. package/dist/{replay-lint-graphql-C3aqm51r.js → replay-lint-graphql-xh8VoAwd.js} +1 -1
  46. package/dist/{replay-lint-graphql-DnztHI0i.js → replay-lint-graphql-zO8zunug.js} +1 -1
  47. package/dist/replay-periodic-revalidation-BoyLQHtg.js +1 -0
  48. package/dist/replay-periodic-revalidation-Dsp-n7ui.js +21 -0
  49. package/dist/replay-promise-map-limit-DRDkHc-b.js +1 -0
  50. package/dist/replay-promise-map-limit-Db_42GvV.js +14 -0
  51. package/dist/replay-resolve-B0AjmaE9.js +47 -0
  52. package/dist/{replay-resolve-LjvT95Yw.js → replay-resolve-MVe_8Ube.js} +1104 -1094
  53. package/dist/{replay-respect-run-DLSZ4d4p.js → replay-respect-run-BJsR4a4m.js} +1 -1
  54. package/dist/{replay-respect-run-wqqp8WHA.js → replay-respect-run-X4PSO6Fj.js} +3 -3
  55. package/dist/{replay-tauri-path-Bg-T0cwI.js → replay-tauri-path-CkGiQWsb.js} +2 -2
  56. package/dist/{replay-tauri-path-DHZlqqfb.js → replay-tauri-path-D8FJsoZb.js} +1 -1
  57. package/dist/replay-useAiChatQueries-BXL-_N2Q.js +215 -0
  58. package/dist/{replay-useAiChatQueries-Dy-kPGKF.js → replay-useAiChatQueries-D7sHNAfV.js} +1078 -1022
  59. package/dist/{replay-validate-key-B2N6AiQk.js → replay-validate-key-CmzSfORv.js} +1 -1
  60. package/dist/{replay-validate-key-B7RBY-6z.js → replay-validate-key-CtZEJRP7.js} +2 -2
  61. package/dist/replay.cjs +1 -1
  62. package/dist/replay.js +12 -12
  63. package/package.json +5 -4
  64. package/dist/replay-AiPanel-COL9ADyD.js +0 -868
  65. package/dist/replay-index-ClVtMDHn.js +0 -6899
  66. package/dist/replay-index-F528jCaH.js +0 -1
  67. package/dist/replay-index-fpeoVNQb.js +0 -1
  68. package/dist/replay-resolve-BoryNVbu.js +0 -47
  69. package/dist/replay-useAiChatQueries-DuNxx5rQ.js +0 -215
@@ -1,868 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),p=require("react"),$=require("styled-components"),f=require("./replay-index-ClVtMDHn.js"),x=require("./replay-useAiChatQueries-DuNxx5rQ.js"),v=require("@redocly/theme"),M=require("./replay-db-DAiJFj0l.js");require("@tanstack/react-query");const Ve=require("react-router"),Fe=e=>e&&e.__esModule?e:{default:e},l=Fe($),Ge=e=>i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:i.jsx("path",{d:"M13.0094 7.61066L3.38435 2.79816C3.30892 2.76043 3.22418 2.74532 3.14035 2.75463C3.05652 2.76394 2.97717 2.79729 2.91186 2.85066C2.84948 2.90294 2.80292 2.97158 2.77742 3.04886C2.75191 3.12615 2.74847 3.20902 2.76748 3.28816L3.92685 7.56253H8.87498V8.43753H3.92685L2.74998 12.6988C2.73214 12.7649 2.73006 12.8342 2.7439 12.9013C2.75774 12.9683 2.78712 13.0312 2.82968 13.0848C2.87223 13.1384 2.92677 13.1813 2.98891 13.21C3.05106 13.2387 3.11907 13.2524 3.18748 13.25C3.25597 13.2496 3.3234 13.2331 3.38435 13.2019L13.0094 8.38941C13.081 8.35269 13.1412 8.29692 13.1832 8.22821C13.2252 8.15951 13.2474 8.08055 13.2474 8.00003C13.2474 7.91951 13.2252 7.84056 13.1832 7.77185C13.1412 7.70315 13.081 7.64737 13.0094 7.61066Z",fill:"white"})}),We=l.default(Ge).attrs({"data-component-name":"icons/SendIcon/SendIcon"})`
2
- path {
3
- fill: ${({color:e})=>f.getCssColorVariable(e)};
4
- }
5
-
6
- height: ${({size:e})=>e||"16px"};
7
- width: ${({size:e})=>e||"16px"};
8
- `,Ue=e=>i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 14 14",fill:"none",...e,children:i.jsx("path",{d:"M10.5 3.5V10.5H3.5V3.5H10.5ZM10.5 2.625H3.5C3.26794 2.625 3.04538 2.71719 2.88128 2.88128C2.71719 3.04538 2.625 3.26794 2.625 3.5V10.5C2.625 10.7321 2.71719 10.9546 2.88128 11.1187C3.04538 11.2828 3.26794 11.375 3.5 11.375H10.5C10.7321 11.375 10.9546 11.2828 11.1187 11.1187C11.2828 10.9546 11.375 10.7321 11.375 10.5V3.5C11.375 3.26794 11.2828 3.04538 11.1187 2.88128C10.9546 2.71719 10.7321 2.625 10.5 2.625Z"})}),qe=l.default(Ue).attrs({"data-component-name":"icons/StopIcon/StopIcon"})`
9
- path {
10
- fill: ${({color:e})=>f.getCssColorVariable(e)};
11
- }
12
-
13
- height: ${({size:e})=>e||"16px"};
14
- width: ${({size:e})=>e||"16px"};
15
- `;function Ye({placeholder:e="Ask anything...",className:t,disabled:n,isStreaming:o=!1,onStop:r,modelSelector:a,value:s,onValueChange:d,onSubmit:c,textareaRef:u}){const h=s.trim(),g=!n&&h.length>0&&!o,m=!n&&h.length>0,b=T=>{d(T.target.value)},y=()=>{!h||n||o||c()},A=()=>{!o||!r||r()},C=T=>{T.key==="Enter"&&!T.shiftKey&&!T.nativeEvent.isComposing&&(T.preventDefault(),o&&r?A():y())};return i.jsxs(Ke,{className:t,$isActive:m,children:[i.jsx(Je,{ref:u,rows:1,maxLength:v.AI_SEARCH_MAX_MESSAGE_LENGTH,placeholder:e,value:s,disabled:n,spellCheck:!1,onChange:b,onKeyDown:C}),i.jsxs(Ze,{children:[a,o&&r?i.jsx(Qe,{type:"button",size:"small","aria-label":"Stop generating",icon:i.jsx(qe,{color:"var(--icon-color-on-color)"}),onClick:A}):i.jsx(Xe,{type:"button",size:"small","aria-label":"Send message",icon:i.jsx(We,{color:"var(--icon-color-on-color)"}),onClick:y,disabled:!g})]})]})}const Ke=l.default.div`
16
- display: flex;
17
- flex-direction: column;
18
- gap: var(--spacing-xs);
19
- width: 100%;
20
- padding: var(--spacing-xs);
21
- border: var(--search-ai-conversation-input-border, 1px solid var(--border-color-secondary));
22
- border-radius: var(--search-ai-conversation-input-border-radius, var(--border-radius-lg));
23
- background-color: var(--layer-color);
24
- box-sizing: border-box;
25
-
26
- &:hover,
27
- &:focus-within {
28
- border-color: transparent;
29
- background:
30
- linear-gradient(var(--layer-color), var(--layer-color)) padding-box,
31
- var(--replay-ai-gradient-soft) border-box;
32
- }
33
-
34
- ${({$isActive:e})=>e&&$.css`
35
- border-color: transparent;
36
- background:
37
- linear-gradient(var(--layer-color), var(--layer-color)) padding-box,
38
- var(--replay-ai-gradient-soft) border-box;
39
- `}
40
- `,Je=l.default.textarea`
41
- max-height: 150px;
42
- min-height: var(--search-ai-conversation-input-min-height);
43
-
44
- resize: none;
45
- border: none;
46
- outline: none;
47
- padding: 0;
48
- font-family: var(--font-family-base);
49
- font-size: var(--font-size-base);
50
- line-height: var(--line-height-base);
51
- color: var(--text-color-primary);
52
- caret-color: var(--text-color-primary);
53
- background-color: transparent;
54
- field-sizing: content;
55
-
56
- &::placeholder {
57
- color: var(--text-color-helper);
58
- text-indent: 2px;
59
- }
60
- `,Ze=l.default.div`
61
- display: flex;
62
- justify-content: space-between;
63
- align-items: center;
64
- gap: var(--spacing-xs);
65
- `,Xe=l.default(v.Button)`
66
- box-sizing: border-box;
67
- background: var(--search-ai-gradient);
68
-
69
- &:disabled {
70
- background: var(--replay-ai-gradient-disabled);
71
- border: var(--replay-ai-send-button-disabled-border);
72
- width: 24px;
73
- height: 24px;
74
- }
75
- `,Qe=l.default(v.Button)`
76
- box-sizing: border-box;
77
- background: var(--color-warm-grey-9);
78
- border-radius: var(--border-radius-xxl);
79
- `,et=new Set(["collection","workflow","step","operation","workflow-run"]);function we(e){return`replay://step?${new URLSearchParams({collectionId:e.collectionId.trim(),workflowId:e.workflowId.trim(),stepId:e.stepId.trim()}).toString()}`}function O(e,t){const n=e.get(t);if(n==null)return null;const o=n.trim();return o.length>0?o:null}function tt(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="replay:")return null;const n=t.hostname.toLowerCase();if(!et.has(n))return null;const o=t.searchParams;switch(n){case"collection":{const r=O(o,"collectionId");return r?{kind:"collection",collectionId:r}:null}case"workflow":{const r=O(o,"collectionId"),a=O(o,"workflowId");return!r||!a?null:{kind:"workflow",collectionId:r,workflowId:a}}case"step":{const r=O(o,"collectionId"),a=O(o,"workflowId"),s=O(o,"stepId");return!r||!a||!s?null:{kind:"step",collectionId:r,workflowId:a,stepId:s}}case"operation":{const r=O(o,"operationId");return r?{kind:"operation",operationId:r}:null}case"workflow-run":{const r=O(o,"collectionId"),a=O(o,"workflowId");if(!r||!a)return null;const s=O(o,"historyId"),d=s==="null"||s==="undefined"?null:s;return{kind:"workflow-run",collectionId:r,workflowId:a,...d?{historyId:d}:{}}}default:return null}}function nt(e,t,n){return e.tabsState.tabs.get({noproxy:!0}).findIndex(({data:o})=>f.isTabType(o,f.TabDataType.WorkflowRun)&&o.collectionId===t&&o.workflowId===n)}function ot(e,t,n,o={}){switch(n.kind){case"collection":t.openCollectionTab({collectionId:n.collectionId,activeTabName:f.TAB_NAMES.COLLECTION_SETTINGS});break;case"workflow":t.openWorkflowTab({collectionId:n.collectionId,workflowId:n.workflowId,activeTabName:f.TAB_NAMES.WORKFLOW_SETTINGS});break;case"step":t.openStepTabFromCollection({collectionId:n.collectionId,workflowId:n.workflowId,stepId:n.stepId,state:f.TabState.Normal});break;case"workflow-run":{const r=o.workflowRunHistoryIds?.[x.workflowRunKey(n.collectionId,n.workflowId)]??[],a=n.historyId&&r.includes(n.historyId)?n.historyId:r.at(-1)??n.historyId;if(a){t.openWorkflowRunTabFromHistory(a,{state:f.TabState.Normal});break}const s=nt(e,n.collectionId,n.workflowId);if(s!==-1){e.tabsState.tabs.get({noproxy:!0})[s].state===f.TabState.Preview&&t.changeTabState(s,f.TabState.Normal),t.handleTabChange(s);break}t.openWorkflowRunTab({collectionId:n.collectionId,workflowId:n.workflowId});break}case"operation":{const r=x.resolveOperation(e,n.operationId);if(!r.ok){console.warn("[executeReplayChatLink] Operation not resolved",{operationId:n.operationId,message:r.message});return}x.openOrFocusOperationEditorTab(e,x.operationListItemToCollectionOperation(r.value),t);break}}}function rt(e,t,n,o={}){const r=tt(n);r&&ot(e,t,r,o)}function Ce({workflowRunHistoryIds:e}={}){const t=f.useGlobalStore(),{getApiOperation:n}=f.useApiOperation(),{handleTabChange:o,addNewTab:r,openCollectionTab:a,openWorkflowTab:s,openStepTabFromCollection:d,openWorkflowRunTab:c,openWorkflowRunTabFromHistory:u,changeTabState:h}=f.useTabHandlers();return p.useCallback(g=>{const m=g.target;if(!(m instanceof Element))return;const b=m.closest("a[href]");if(!(b instanceof HTMLAnchorElement))return;const y=b.getAttribute("href");y?.startsWith("replay:")&&(g.preventDefault(),g.stopPropagation(),rt(t,{getApiOperation:n,handleTabChange:o,addNewTab:r,openCollectionTab:a,openWorkflowTab:s,openStepTabFromCollection:d,openWorkflowRunTab:c,openWorkflowRunTabFromHistory:u,changeTabState:h},y,{workflowRunHistoryIds:e}))},[e,t,n,o,r,a,s,d,c,u,h])}class it{diff(t,n,o={}){let r;typeof o=="function"?(r=o,o={}):"callback"in o&&(r=o.callback);const a=this.castInput(t,o),s=this.castInput(n,o),d=this.removeEmpty(this.tokenize(a,o)),c=this.removeEmpty(this.tokenize(s,o));return this.diffWithOptionsObj(d,c,o,r)}diffWithOptionsObj(t,n,o,r){var a;const s=w=>{if(w=this.postProcess(w,o),r){setTimeout(function(){r(w)},0);return}else return w},d=n.length,c=t.length;let u=1,h=d+c;o.maxEditLength!=null&&(h=Math.min(h,o.maxEditLength));const g=(a=o.timeout)!==null&&a!==void 0?a:1/0,m=Date.now()+g,b=[{oldPos:-1,lastComponent:void 0}];let y=this.extractCommon(b[0],n,t,0,o);if(b[0].oldPos+1>=c&&y+1>=d)return s(this.buildValues(b[0].lastComponent,n,t));let A=-1/0,C=1/0;const T=()=>{for(let w=Math.max(A,-u);w<=Math.min(C,u);w+=2){let k;const R=b[w-1],P=b[w+1];R&&(b[w-1]=void 0);let B=!1;if(P){const W=P.oldPos-w;B=P&&0<=W&&W<d}const N=R&&R.oldPos+1<c;if(!B&&!N){b[w]=void 0;continue}if(!N||B&&R.oldPos<P.oldPos?k=this.addToPath(P,!0,!1,0,o):k=this.addToPath(R,!1,!0,1,o),y=this.extractCommon(k,n,t,w,o),k.oldPos+1>=c&&y+1>=d)return s(this.buildValues(k.lastComponent,n,t))||!0;b[w]=k,k.oldPos+1>=c&&(C=Math.min(C,w-1)),y+1>=d&&(A=Math.max(A,w+1))}u++};if(r)(function w(){setTimeout(function(){if(u>h||Date.now()>m)return r(void 0);T()||w()},0)})();else for(;u<=h&&Date.now()<=m;){const w=T();if(w)return w}}addToPath(t,n,o,r,a){const s=t.lastComponent;return s&&!a.oneChangePerToken&&s.added===n&&s.removed===o?{oldPos:t.oldPos+r,lastComponent:{count:s.count+1,added:n,removed:o,previousComponent:s.previousComponent}}:{oldPos:t.oldPos+r,lastComponent:{count:1,added:n,removed:o,previousComponent:s}}}extractCommon(t,n,o,r,a){const s=n.length,d=o.length;let c=t.oldPos,u=c-r,h=0;for(;u+1<s&&c+1<d&&this.equals(o[c+1],n[u+1],a);)u++,c++,h++,a.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return h&&!a.oneChangePerToken&&(t.lastComponent={count:h,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=c,u}equals(t,n,o){return o.comparator?o.comparator(t,n):t===n||!!o.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let o=0;o<t.length;o++)t[o]&&n.push(t[o]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,o){const r=[];let a;for(;t;)r.push(t),a=t.previousComponent,delete t.previousComponent,t=a;r.reverse();const s=r.length;let d=0,c=0,u=0;for(;d<s;d++){const h=r[d];if(h.removed)h.value=this.join(o.slice(u,u+h.count)),u+=h.count;else{if(!h.added&&this.useLongestToken){let g=n.slice(c,c+h.count);g=g.map(function(m,b){const y=o[u+b];return y.length>m.length?y:m}),h.value=this.join(g)}else h.value=this.join(n.slice(c,c+h.count));c+=h.count,h.added||(u+=h.count)}}return r}}class at extends it{constructor(){super(...arguments),this.tokenize=ct}equals(t,n,o){return o.ignoreWhitespace?((!o.newlineIsToken||!t.includes(`
80
- `))&&(t=t.trim()),(!o.newlineIsToken||!n.includes(`
81
- `))&&(n=n.trim())):o.ignoreNewlineAtEof&&!o.newlineIsToken&&(t.endsWith(`
82
- `)&&(t=t.slice(0,-1)),n.endsWith(`
83
- `)&&(n=n.slice(0,-1))),super.equals(t,n,o)}}const st=new at;function lt(e,t,n){return st.diff(e,t,n)}function ct(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
84
- `));const n=[],o=e.split(/(\n|\r\n)/);o[o.length-1]||o.pop();for(let r=0;r<o.length;r++){const a=o[r];r%2&&!t.newlineIsToken?n[n.length-1]+=a:n.push(a)}return n}const dt=500;function ut(e,t){const n=ft(e,t);if(n.length===0)return[];const o=[];let r=0;for(;r<n.length;){let a=r;const s=n[r].type==="context";for(;a<n.length&&n[a].type==="context"===s;)a++;const d=n.slice(r,a);o.push({start:r,end:a,rows:d,hasAdditions:d.some(c=>c.type==="add"),hasRemovals:d.some(c=>c.type==="remove")}),r=a}return o}function ft(e,t){if(e===void 0)return t===void 0?[]:H(t,"add");if(t===void 0)return H(e,"remove");if(e===t)return H(t,"context");const n=pt(e,t);return n?n.flatMap(o=>H(o.value,o.added?"add":o.removed?"remove":"context")):[...H(e,"remove"),...H(t,"add")]}function pt(e,t){try{return lt(e,t,{timeout:dt})}catch{return}}function H(e,t){const n=e.split(`
85
- `);return n.length>1&&n[n.length-1]===""&&n.pop(),n.map(o=>({type:t,text:o}))}const re=1,ie=e=>e&&e.hasAdditions!==e.hasRemovals,ae=e=>e&&(e.hasAdditions||e.hasRemovals);function ht(e,t,n){if(e.hasAdditions||e.hasRemovals)return U(e.rows);const o=n[t-1],r=n[t+1],a=ie(o)?re:0,s=ie(r)?re:0;if(a+s>=e.rows.length)return U(e.rows);const d=e.rows.slice(0,a),c=s>0?e.rows.slice(-s):[],u=[];return u.push(...U(d)),ae(o)&&ae(r)&&u.push({kind:"separator"}),u.push(...U(c)),u}function U(e){return e.map(t=>({kind:"row",row:t}))}const gt=200;function se({oldValue:e,newValue:t}){const n=p.useMemo(()=>ut(e,t),[e,t]),o=p.useMemo(()=>n.flatMap(ht),[n]);return p.useMemo(()=>n.some(a=>a.hasAdditions||a.hasRemovals),[n])?i.jsx(vt,{$maxHeight:gt,children:o.map((a,s)=>{if(a.kind==="separator")return i.jsx(Ct,{children:i.jsx(le,{children:"···"})},s);const{row:d}=a,c=xt(d.type);return i.jsxs(c,{children:[i.jsxs(wt,{children:[d.type==="remove"&&i.jsx(v.SubtractIcon,{size:"12px"}),d.type==="add"&&i.jsx(v.AddIcon,{size:"12px"})]}),i.jsx(le,{children:d.text===""?" ":d.text})]},s)})}):null}function xt(e){return e==="remove"?mt:e==="add"?yt:bt}const vt=l.default.div`
86
- display: flex;
87
- flex-direction: column;
88
- width: 100%;
89
- min-width: 0;
90
- max-height: ${({$maxHeight:e})=>e}px;
91
- overflow-y: auto;
92
- border-radius: var(--border-radius);
93
- &::-webkit-scrollbar-track {
94
- margin: var(--spacing-xxs) 0;
95
- }
96
- `,Q=l.default.div`
97
- display: flex;
98
- font-size: var(--font-size-sm);
99
- line-height: var(--line-height-sm);
100
- font-weight: var(--font-weight-regular);
101
- padding-right: var(--spacing-xxs);
102
- `,mt=l.default(Q)`
103
- background: var(--admonition-danger-bg-color);
104
- color: var(--color-raspberry-7);
105
- `,yt=l.default(Q)`
106
- background: var(--admonition-success-bg-color);
107
- color: var(--color-green-7);
108
- `,bt=l.default(Q)`
109
- background: transparent;
110
- color: var(--text-color-secondary);
111
- `,wt=l.default.span`
112
- display: flex;
113
- align-items: center;
114
- justify-content: center;
115
- min-width: 16px;
116
- height: 20px;
117
- flex-shrink: 0;
118
- `,le=l.default.span`
119
- width: 100%;
120
- min-width: 0;
121
- line-height: var(--line-height-sm);
122
- font-size: var(--font-size-sm);
123
- font-weight: var(--font-weight-regular);
124
- white-space: pre-wrap;
125
- word-break: break-all;
126
- `,Ct=l.default(Q)`
127
- user-select: none;
128
- `,At=e=>typeof e!="object"||e===null?!1:"kind"in e&&e.kind==="batch"?"changes"in e?Array.isArray(e.changes)&&e.changes.every(ce):!1:ce(e);function ce(e){return typeof e!="object"||e===null||!("id"in e)||!("target"in e)||!("included"in e)||!("kind"in e)?!1:e.kind==="single"}const Tt={approveLabel:"Approve",denyLabel:"Deny"};function jt(e,t){const n=I(t,"action");if(n){const r=x.TOOL_APPROVAL_ACTION_BUTTON_LABELS[n];if(r)return r}const o=x.TOOL_APPROVAL_BUTTON_LABELS[e];return o||Tt}function I(e,t){if(!e||typeof e!="object")return null;const n=e.payload;if(!n||typeof n!="object")return null;const o=n[t];return typeof o!="string"?null:o.trim()||null}function q(e,t){if(!(typeof t>"u"))return e?`${e}: ${t}`:t}function It(e){return e?"changes"in e?Array.isArray(e.changes)?e.changes.map(t=>!t||typeof t!="object"||!("approved"in t)?!1:t.approved===!0):[]:[]:[]}function St(e,t){if(!e||typeof e!="object")return;const n=J(e,f.REPLAY_MESSAGE_METADATA_NS),o=J(n,f.REPLAY_CHANGE_PREVIEW_SNAPSHOT_KEY);if(!(t in o))return;const r=o[t];if(Array.isArray(r)&&r.length!==0&&r.every(At))return r}function Ae(e,t){return x.isToolApprovalPart(e)&&x.isApprovalRequested(e)&&e.toolCallId===t}function kt(e,t,n){const o=e.parts.map(c=>Ae(c,t)?{...c,input:Et(c.input,n)}:c),r=e.metadata&&typeof e.metadata=="object"?e.metadata:{},a=J(r,f.REPLAY_MESSAGE_METADATA_NS),d={...J(a,f.REPLAY_CHANGE_PREVIEW_SNAPSHOT_KEY),[t]:f.cloneObject(n)};return{...e,parts:o,metadata:{...r,[f.REPLAY_MESSAGE_METADATA_NS]:{...a,[f.REPLAY_CHANGE_PREVIEW_SNAPSHOT_KEY]:d}}}}function J(e,t){const n=e[t];return typeof n=="object"&&n!==null?n:{}}function Et(e,t){if(!e||!("changes"in e)||!Array.isArray(e.changes))return e;const{changes:n,...o}=e;return{...o,changes:n.map((r,a)=>({...r,approved:t[a]?.included??!1}))}}function Lt({preview:e,isIncluded:t,onToggle:n,readOnly:o}){const{primaryLabel:r,categoryLabel:a,diffLineKey:s}=Rt(e.target);return i.jsx(Pt,{isIncluded:t,onToggle:n,readOnly:o,primaryLabel:r,categoryLabel:a,children:e.kind==="batch"?i.jsx(Ft,{children:e.changes.map(d=>i.jsx(se,{oldValue:q(d.target.key,d.oldValue),newValue:q(d.target.key,d.newValue)},d.id))}):i.jsx(se,{oldValue:q(s,e.oldValue),newValue:q(s,e.newValue)})})}function Rt(e){const t=e.schemeId??e.type;return e.stepId||e.schemeId?{primaryLabel:e.stepId??t,categoryLabel:e.stepId?t:void 0,diffLineKey:e.key}:{primaryLabel:e.key??e.type,categoryLabel:e.key?e.type:void 0,diffLineKey:void 0}}function Pt({isIncluded:e,onToggle:t,readOnly:n,primaryLabel:o,categoryLabel:r,children:a}){return i.jsxs(Ot,{$dimmed:n&&!e,children:[i.jsxs(_t,{children:[n?i.jsx(zt,{children:e?i.jsx(Bt,{size:"16px"}):i.jsx(Vt,{size:"16px"})}):i.jsxs($t,{children:[i.jsx(Dt,{checked:e}),i.jsx(Ht,{type:"checkbox",checked:e,onChange:t})]}),i.jsx(Mt,{children:o}),r?i.jsx(Nt,{children:r}):null]}),a]})}const Ot=l.default.div`
129
- display: flex;
130
- flex-direction: column;
131
- gap: var(--spacing-xs);
132
- min-width: 0;
133
- padding: var(--spacing-xs);
134
- border-bottom: 1px solid var(--border-color-secondary);
135
- box-sizing: border-box;
136
- opacity: ${({$dimmed:e})=>e?.4:1};
137
- &:last-child {
138
- border-bottom: none;
139
- }
140
- `,_t=l.default.div`
141
- display: flex;
142
- align-items: center;
143
- gap: var(--spacing-xs);
144
- min-width: 0;
145
- `,Mt=l.default.span`
146
- flex: 1;
147
- min-width: 0;
148
- color: var(--text-color-primary);
149
- font-size: var(--font-size-sm);
150
- font-weight: var(--font-weight-medium);
151
- line-height: var(--line-height-sm);
152
- overflow: hidden;
153
- text-overflow: ellipsis;
154
- white-space: nowrap;
155
- `,Nt=l.default.span`
156
- flex-shrink: 0;
157
- font-family: var(--code-block-font-family, var(--font-family-monospace, monospace));
158
- font-size: var(--font-size-sm);
159
- font-weight: var(--font-weight-regular);
160
- line-height: var(--line-height-sm);
161
- color: var(--text-color-secondary);
162
- `,Dt=l.default(v.CheckboxIcon).attrs({"aria-hidden":!0})`
163
- --checkbox-border-color: var(--color-blueberry-6);
164
- --checkbox-box-color: var(--color-blueberry-6);
165
- --checkbox-box-color-active: var(--color-blueberry-6);
166
- `,$t=l.default.span`
167
- position: relative;
168
- display: inline-flex;
169
- flex-shrink: 0;
170
- width: 16px;
171
- height: 16px;
172
- `,Ht=l.default.input`
173
- position: absolute;
174
- inset: 0;
175
- width: 16px;
176
- height: 16px;
177
- margin: 0;
178
- opacity: 0;
179
- cursor: pointer;
180
- `,zt=l.default.span`
181
- display: inline-flex;
182
- flex-shrink: 0;
183
- width: 16px;
184
- height: 16px;
185
- align-items: center;
186
- justify-content: center;
187
- `,Bt=l.default(v.CheckmarkFilledIcon)`
188
- color: var(--color-success-base);
189
- `,Vt=l.default(v.CloseFilledIcon)`
190
- color: var(--text-color-description);
191
- `,Ft=l.default.div`
192
- display: flex;
193
- flex-direction: column;
194
- gap: var(--spacing-xxs);
195
- min-width: 0;
196
- `;function Te({previews:e,handleToggle:t,readOnly:n}){return e.length===0?null:i.jsx(Gt,{children:e.map((o,r)=>i.jsx(Lt,{preview:o,isIncluded:o.included,onToggle:t?()=>t(r):void 0,readOnly:n},o.id))})}const Gt=l.default.div`
197
- display: flex;
198
- flex-direction: column;
199
- `,Wt={update_step:Yt,update_security:Kt,run_request:Qt,web_search:en,manage_environment:Zt,manage_collection:Xt};function Ut(e,t){const n=Wt[e];return n?n(t):qt(e)}function qt(e){return[{kind:"text",text:e.split("_").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}]}function Yt(e){return je(e,"Update step")}function Kt(e){const t=Jt(e);if(t.size>1)return S("Update security");const[n]=t;return je(e,"Update security",n)}function Jt(e){const t=e&&"changes"in e?e.changes:void 0;if(!Array.isArray(t))return new Set;const n=F(e,"stepId"),o=t.map(r=>F(r,"stepId")??n);return new Set(o.filter(r=>!!r))}function je(e,t,n){const{collectionId:o,workflowId:r,stepId:a}=tn(e),s=n??a;return!o||!r||!s?S(t):Ie(`${t} `,we({collectionId:o,workflowId:r,stepId:s}),s)}function S(e){return[{kind:"text",text:e}]}function L(e,t){return t?`${e} "${t}"`:e}function Ie(e,t,n){return[{kind:"text",text:e},{kind:"link",href:t,label:n}]}function Zt(e){const t=I(e,"action"),n=I(e,"environment"),o=n?` in environment "${n}"`:"";switch(t){case"add_environment":return S(L("Add environment",n));case"set_active_environment":return S(n?`Switch active environment to ${n}`:"Switch active environment");case"upsert_input":return S(L("Set input",I(e,"name"))+o);case"remove_input":return S(L("Remove input",I(e,"inputName"))+o);case"upsert_server":return S(L("Set server",I(e,"apiId"))+o);case"remove_server":return S(L("Remove server",I(e,"apiId"))+o);default:return S("Manage environment")}}function Xt(e){switch(I(e,"action")){case"create_collection":return S(L("Create collection",I(e,"title")));case"delete_collection":return S(L("Delete collection",I(e,"collectionId")));case"create_workflow":return S(L("Create workflow",I(e,"name")));case"delete_workflow":return S(L("Delete workflow",I(e,"workflowId")));case"create_step":return S(L("Create step",I(e,"stepName")));case"delete_step":{const n=I(e,"collectionId"),o=I(e,"workflowId"),r=I(e,"stepId");return!n||!o||!r?S("Delete step"):Ie("Delete step ",we({collectionId:n,workflowId:o,stepId:r}),r)}case"save_tab_to_collection":return S(L("Save tab as step",I(e,"newStepName")));default:return S("Manage collection")}}function Qt(){return[{kind:"text",text:"Run current request"}]}function en(e){return[{kind:"text",text:"Search the web at "},{kind:"link",href:e.url,label:e.url}]}function tn(e){return{collectionId:F(e,"collectionId"),workflowId:F(e,"workflowId"),stepId:F(e,"stepId")}}function F(e,t){if(typeof e!="object"||e===null||!(t in e))return null;const n=e[t];return typeof n=="string"&&n.trim()||null}function Se({toolName:e,input:t}){const n=Ut(e,t),o=Ce();return i.jsx(nn,{onClick:o,children:i.jsx(on,{children:n.map((r,a)=>r.kind==="text"?i.jsx("span",{children:r.text},a):i.jsx(rn,{href:r.href,children:r.label},a))})})}const nn=l.default.div`
200
- display: flex;
201
- flex-direction: column;
202
- gap: 0;
203
- min-width: 0;
204
- padding: var(--spacing-xs) var(--spacing-sm);
205
-
206
- &:not(:last-child) {
207
- border-bottom: 1px solid var(--border-color-secondary);
208
- }
209
- `,on=l.default.span`
210
- font-family: var(--font-family-base);
211
- font-size: var(--font-size-sm);
212
- font-weight: var(--font-weight-regular);
213
- line-height: var(--line-height-sm);
214
- color: var(--text-color-primary);
215
- `,rn=l.default.a`
216
- color: var(--link-color-primary);
217
- cursor: pointer;
218
- text-decoration: none;
219
-
220
- &:hover {
221
- color: var(--link-color-primary, var(--text-color-link));
222
- }
223
- `;function ke(e,t,n){const o={type:e};return t!==void 0&&(o.key=t),n&&(o.stepId=n),o}function j({id:e,targetType:t,targetKey:n,targetStepId:o,oldValue:r,newValue:a}){return{kind:"single",id:e,target:ke(t,n,o),oldValue:r,newValue:a,included:!0}}function D(e,t,n){return j({id:e,targetType:t,targetStepId:n,oldValue:void 0,newValue:void 0})}function z({data:e,baseId:t,targetType:n,batchTargetKey:o,targetStepId:r,getOldValue:a,getNewValue:s=(c,u)=>String(u??""),resolveTargetKey:d=c=>c}){const c=Object.entries(e).filter(([,g])=>g!==void 0);if(c.length===0)return D(t,n,r);if(c.length>=2){const g=c.map(([m,b])=>j({id:`${t}:${m}`,targetType:n,targetKey:d(m),oldValue:a(m),newValue:s(m,b)}));return{kind:"batch",id:t,target:ke(n,o,r),changes:g,included:!0}}const[u,h]=c[0];return j({id:t,targetType:n,targetKey:d(u),targetStepId:r,oldValue:a(u),newValue:s(u,h)})}function an({store:e,input:t}){if(!sn(t))return[];const n=new Map,o=r=>{const a=n.get(r);if(a)return a;const s=x.resolveStepOrDraft(e,t.collectionId,t.workflowId,r),d=s.ok?s.value:null,c=d?Array.from(d.security.get({noproxy:!0})):[];return n.set(r,c),c};return t.changes.map((r,a)=>{const s=r.stepId?.trim(),d=s||t.stepId;return ln(o(d),r,a,s)})}function sn(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.collectionId=="string"&&typeof t.workflowId=="string"&&typeof t.stepId=="string"&&Array.isArray(t.changes)&&t.changes.length>0}function ln(e,t,n,o){const r=`security[${n}]`;switch(t.action){case x.CHANGE_ACTION.ADD:{const{type:a,schemeId:s,data:d}=t;return!d||Object.keys(d).length===0?V(j({id:r,targetType:a,targetStepId:o,oldValue:void 0,newValue:a}),s):V(z({data:d,baseId:r,targetType:a,targetStepId:o,getOldValue:()=>{}}),s)}case x.CHANGE_ACTION.UPDATE:{const{type:a,data:s}=t,d=t.index!==void 0?e[t.index]:void 0,c=t.schemeId||ne(d);return!s||Object.keys(s).length===0?V(j({id:r,targetType:a,targetStepId:o,oldValue:ue(d),newValue:a}),c):V(z({data:s,baseId:r,targetType:a,targetStepId:o,getOldValue:u=>d?cn(d,u):void 0}),c)}case x.CHANGE_ACTION.REMOVE:{const a=x.resolveRemovalTarget(e,t),s=a.ok?a.entry:void 0;return V(j({id:r,targetType:s?.securityType??"Security",targetStepId:o,oldValue:ue(s),newValue:void 0}),ne(s))}}}function V(e,t){return t?{...e,target:{...e.target,schemeId:t}}:e}function cn(e,t){switch(e.securityType){case f.SecurityTypes.NoAuth:return;case f.SecurityTypes.OAuth2:return de(e[f.SecurityTypes.OAuth2],t);case f.SecurityTypes.OpenIDConnect:{const n=e[f.SecurityTypes.OpenIDConnect];return t==="openIdConnectUrl"?n.openIdConnectUrl||void 0:t==="userInfoUrl"?n.userInfoUrl||void 0:de(n,t)}case f.SecurityTypes.APIKey:{const n=e[f.SecurityTypes.APIKey];return t==="location"?Y(n,t)?.toLowerCase():Y(n,t)}default:{const n=e[e.securityType];return Y(n,t)}}}function de(e,t){if(t==="grantType")return e.grantType||void 0;if(!e.grantType)return;const n=e[e.grantType];return Y(n,t)}function Y(e,t){const n=e[t];return n!==void 0&&n!==""?String(n):void 0}function ue(e){if(!e||e.securityType===f.SecurityTypes.NoAuth)return;const t=ne(e);return t?`${e.securityType} (${t})`:e.securityType}function ne(e){return!e||e.securityType===f.SecurityTypes.NoAuth?void 0:e[e.securityType]?.schemeName||void 0}function dn({store:e,input:t}){if(!un(t))return[];const n=x.resolveStepOrDraft(e,t.collectionId,t.workflowId,t.stepId),o=n.ok?n.value:null;return t.changes.map((r,a)=>fn(o,r,a))}function un(e){return typeof e!="object"||e===null?!1:"collectionId"in e&&"workflowId"in e&&"stepId"in e&&"changes"in e&&Array.isArray(e.changes)&&e.changes.length>0&&typeof e.collectionId=="string"&&typeof e.workflowId=="string"&&typeof e.stepId=="string"}function fn(e,t,n){const o=t.id??`${t.field}[${n}]`;switch(t.field){case"method":case"url":case"description":return pn(e,t,o);case"parameters":return hn(e,t,o);case"outputs":return gn(e,t,o);case"body":return xn(e,t,o);case"successCriteria":return vn(e,t,o)}}function pn(e,t,n){const o=v.capitalize(t.field);switch(t.action){case x.CHANGE_ACTION.ADD:return j({id:n,targetType:o,oldValue:void 0,newValue:t.data});case x.CHANGE_ACTION.UPDATE:return j({id:n,targetType:o,oldValue:fe(e,t.field),newValue:t.data});case x.CHANGE_ACTION.REMOVE:return j({id:n,targetType:o,oldValue:fe(e,t.field),newValue:void 0})}}function hn(e,t,n){switch(t.action){case x.CHANGE_ACTION.ADD:{if(!t.data)return D(n,"parameter");const{in:o,name:r,value:a}=t.data;return j({id:n,targetType:v.capitalize(o),targetKey:r,oldValue:void 0,newValue:a})}case x.CHANGE_ACTION.UPDATE:{if(!t.id&&!t.data?.name)return D(n,"parameter");const o=pe(e,t),r=t.data?.in??o?.in??"parameter";return j({id:n,targetType:v.capitalize(r),targetKey:t.data?.name??o?.key,oldValue:o?o.value??"":void 0,newValue:t.data?.value})}case x.CHANGE_ACTION.REMOVE:{if(!t.id&&!t.data?.name)return D(n,"parameter");const o=pe(e,t),r=t.data?.in??o?.in??"parameter";return j({id:n,targetType:v.capitalize(r),targetKey:o?.key??t.data?.name,oldValue:o?o.value??"":void 0,newValue:void 0})}}}function gn(e,t,n){switch(t.action){case x.CHANGE_ACTION.ADD:return t.data?j({id:n,targetType:"Output",targetKey:t.data.name,oldValue:void 0,newValue:t.data.expression}):j({id:n,targetType:"Output",oldValue:void 0,newValue:void 0});case x.CHANGE_ACTION.UPDATE:{if(!t.data)return j({id:n,targetType:"Output",oldValue:void 0,newValue:void 0});const o=t.id&&e?ge(e,t.id):void 0;return j({id:n,targetType:"Output",targetKey:t.data.name,oldValue:o?.value,newValue:t.data.expression})}case x.CHANGE_ACTION.REMOVE:{if(!t.id&&!t.data?.name)return D(n,"Output");let o=t.id&&e?ge(e,t.id):void 0;return!o&&e&&t.data?.name&&(o=bn(e,t.data.name)),j({id:n,targetType:"Output",targetKey:o?.key??t.data?.name,oldValue:o?.value,newValue:void 0})}}}function xn(e,t,n){const{data:o}=t;switch(t.action){case x.CHANGE_ACTION.ADD:return z({data:o,baseId:n,targetType:"Body",getOldValue:()=>{},getNewValue:r=>r==="content"?te(o.content,o.contentType):X(o[r]),resolveTargetKey:r=>r==="content"?void 0:r});case x.CHANGE_ACTION.UPDATE:{const r=e?.requestBody.type.get(),a=o.contentType??r;return z({data:o,baseId:n,targetType:"Body",getOldValue:s=>{if(e){if(s==="content")return te(e.requestBody.content.get(),r)||void 0;if(s==="contentType")return r}},getNewValue:s=>s==="content"?te(o.content,a):X(o[s]),resolveTargetKey:s=>s==="content"?void 0:s})}case x.CHANGE_ACTION.REMOVE:{const r=e?f.toCompactJson({contentType:e.requestBody.type.get(),content:e.requestBody.content.get()}):void 0;return j({id:n,targetType:"Body",oldValue:r,newValue:void 0})}}}function vn(e,t,n){switch(t.action){case x.CHANGE_ACTION.ADD:return t.data?z({data:t.data,baseId:n,targetType:"successCriteria",getOldValue:()=>{},getNewValue:o=>X(t.data[o])}):D(n,"successCriteria");case x.CHANGE_ACTION.UPDATE:{if(!t.data)return D(n,"successCriteria");const o=typeof t.id=="string"&&e?he(e,t.id):void 0;return z({data:t.data,baseId:n,targetType:"successCriteria",getOldValue:r=>{if(o){if(r==="condition")return o.condition;if(r==="context")return o.context??void 0;if(r==="type")return o.type}},getNewValue:r=>X(t.data[r])})}case x.CHANGE_ACTION.REMOVE:{if(typeof t.id!="string")return D(n,"successCriteria");const o=e?he(e,t.id):void 0;return j({id:n,targetType:"successCriteria",targetKey:o?.condition,oldValue:o?f.toCompactJson(o):void 0,newValue:void 0})}}}function fe(e,t){if(e)switch(t){case"method":return e.xOperation.ornull?.method.get();case"url":return e.xOperation.ornull?.url.get();case"description":return e.description.get()}}function pe(e,t){let n=t.id&&e?mn(e,t.id):null;return!n&&e&&t.data?.name&&(n=yn(e,t.data.name)),n}function Ee(e,t){for(const n of["path","query","header","cookie"]){const o=e.parameters[x.LOCATION_TO_FIELD[n]].get().find(r=>f.isInlineRequestParameter(r)&&t(r));if(o)return o}return null}function mn(e,t){return Ee(e,n=>n.id===t)}function yn(e,t){return Ee(e,n=>n.key===t)}function he(e,t){return e.successCriteria.get().find(n=>n.condition===t)}function Le(e,t){for(const n of e.outputs.get())if(t(n))return{key:Z(n.key),value:Z(n.value)}}function ge(e,t){return Le(e,n=>Z(n.id)===t)}function bn(e,t){return Le(e,n=>Z(n.key)===t)}function Z(e){return typeof e=="string"?e:e.get()}function X(e){return e==null?"":typeof e=="string"?e:f.toCompactJson(e)}function te(e,t){if(!e||t!==f.TextContentType.JSON)return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}const wn={update_security:an,update_step:dn};function Re(e,t){const n=f.useGlobalStore(),o=p.useMemo(()=>{const c=e?wn[e]:void 0;if(!c)return[];try{return c({store:n,input:t})}catch(u){return console.error("Unable to build change previews",u),[]}},[e,n,t]),[r,a]=p.useState(()=>Object.fromEntries(o.map(c=>[c.id,c.included]))),s=p.useMemo(()=>o.map(c=>({...c,included:r[c.id]??c.included})),[o,r]),d=p.useCallback(c=>{a(typeof c=="function"?u=>{const h=o.map(g=>({...g,included:u[g.id]??g.included}));return Object.fromEntries(c(h).map(g=>[g.id,g.included]))}:Object.fromEntries(c.map(u=>[u.id,u.included])))},[o]);return{previews:s,setPreviews:d}}function Cn({toolCallId:e,toolName:t,input:n,onApprove:o,onDeny:r}){const{updateMessages:a}=x.useAiConversationContext(),{previews:s,setPreviews:d}=Re(t,n),{includedCount:c,totalCount:u}=p.useMemo(()=>({includedCount:s.filter(y=>y.included).length,totalCount:s.length}),[s]),{approveLabel:h,denyLabel:g}=p.useMemo(()=>jt(t,n),[t,n]),m=p.useCallback(()=>{a(y=>{const A=[];for(let C=0;C<y.length;C++){const T=y[C],{parts:w}=T,k=T.role==="assistant",R=w.some(P=>Ae(P,e));if(k&&R){const P=kt(T,e,s);A.push({index:C,message:P})}}return A}),o()},[s,o,a,e]),b=p.useCallback(y=>{d(A=>A.map((C,T)=>T===y?{...C,included:!C.included}:C))},[d]);return i.jsxs(An,{children:[i.jsx(Se,{toolName:t,input:n}),s.length?i.jsx(Tn,{children:i.jsx(Te,{previews:s,handleToggle:b})}):null,s.length?i.jsx(f.Divider,{}):null,i.jsxs(jn,{children:[u>1?i.jsxs(In,{children:[c," of ",u," selected"]}):null,i.jsx(Sn,{size:"small",variant:"secondary",onClick:r,children:g}),i.jsx(kn,{size:"small",variant:"primary",onClick:m,disabled:u>0?c===0:!1,children:h})]})]})}const An=l.default.div`
224
- display: flex;
225
- color: var(--text-color-primary);
226
- flex-direction: column;
227
- gap: var(--spacing-xs);
228
- width: 100%;
229
- min-width: 0;
230
- border-radius: var(--border-radius-md, 10px);
231
- border: 1px solid var(--border-color-secondary);
232
- background: var(--layer-color);
233
- line-height: var(--line-height-sm);
234
- `,Tn=l.default.div`
235
- display: flex;
236
- flex-direction: column;
237
- gap: var(--spacing-xs);
238
- min-width: 0;
239
- `,jn=l.default.div`
240
- display: flex;
241
- flex-wrap: wrap;
242
- justify-content: flex-end;
243
- align-items: center;
244
- padding: 0 var(--spacing-sm) var(--spacing-xs) var(--spacing-sm);
245
- gap: var(--spacing-xxs);
246
- `,In=l.default.span`
247
- flex: 1;
248
- font-size: var(--font-size-sm);
249
- font-weight: var(--font-weight-regular);
250
- line-height: var(--line-height-sm);
251
- color: var(--text-color-secondary);
252
- `,Sn=l.default(v.Button)`
253
- background: none;
254
- `,kn=l.default(v.Button)`
255
- border: 1px solid var(--button-bg-color);
256
- padding-top: 0;
257
- padding-bottom: 0;
258
- &:disabled {
259
- border: 1px solid var(--button-border-color-disabled);
260
- }
261
- `;function En({approvalId:e,toolCallId:t,toolName:n,input:o}){const{addToolApprovalResponse:r}=x.useAiConversationContext(),a=p.useCallback(()=>{r({id:e,approved:!0})},[e,r]),s=p.useCallback(()=>{r({id:e,approved:!1})},[e,r]);return i.jsx(Cn,{onApprove:a,onDeny:s,toolCallId:t,toolName:n,input:o})}function Ln({toolName:e,toolCallId:t,input:n,isDenied:o,messageMetadata:r,onUndo:a}){const s=p.useMemo(()=>St(r,t),[r,t]),{previews:d}=Re(s?void 0:e,n),c=p.useMemo(()=>{const m=s??d;if(o)return m.map(y=>({...y,included:!1}));const b=It(n);return m.map((y,A)=>({...y,included:b[A]??y.included}))},[s,d,n,o]);if(c.length===0)return null;const u=c.filter(m=>m.included).length,g=u===0?"Nothing applied":`${u} ${u===1?"change":"changes"} applied`;return i.jsxs(Rn,{children:[i.jsx(Se,{toolName:e,input:n}),i.jsx(Pn,{children:i.jsx(Te,{previews:c,readOnly:!0})}),i.jsx(f.Divider,{}),i.jsxs(On,{children:[i.jsx(_n,{children:g}),a?i.jsx(Mn,{size:"small",variant:"outlined",onClick:a,children:"Undo"}):null]})]})}const Rn=l.default.div`
262
- display: flex;
263
- color: var(--text-color-primary);
264
- flex-direction: column;
265
- width: 100%;
266
- min-width: 0;
267
- border-radius: var(--border-radius-md, 10px);
268
- border: 1px solid var(--border-color-secondary);
269
- background: var(--layer-color);
270
- line-height: var(--line-height-sm);
271
- `,Pn=l.default.div`
272
- display: flex;
273
- flex-direction: column;
274
- min-width: 0;
275
- `,On=l.default.div`
276
- display: flex;
277
- justify-content: space-between;
278
- align-items: center;
279
- padding: var(--spacing-xs) var(--spacing-sm);
280
- gap: var(--spacing-xs);
281
- `,_n=l.default.span`
282
- font-size: var(--font-size-sm);
283
- font-weight: var(--font-weight-regular);
284
- line-height: var(--line-height-sm);
285
- color: var(--text-color-secondary);
286
- `,Mn=l.default(v.Button)`
287
- padding-top: 0;
288
- padding-bottom: 0;
289
- `;function Nn({items:e,isLast:t}){const[n,o]=p.useState(t),r=p.useCallback(()=>{o(s=>!s)},[]),a=p.useMemo(()=>e.filter(s=>s.kind==="action"),[e]);return i.jsxs($n,{children:[i.jsxs(Hn,{type:"button",onClick:r,"aria-expanded":n,children:[i.jsx(zn,{children:n?i.jsx(v.ChevronDownIcon,{size:"12px",color:"var(--icon-color-additional)"}):i.jsx(v.ChevronRightIcon,{size:"12px",color:"var(--icon-color-additional)"})}),i.jsxs(Bn,{children:[a.length," ",a.length===1?"action":"actions"]})]}),n&&i.jsx(Vn,{children:a.map((s,d)=>i.jsx(Dn,{text:s.text},d))})]})}function Dn({text:e}){return i.jsxs(Fn,{children:[i.jsxs(Gn,{children:[i.jsx(Wn,{"aria-hidden":!0}),i.jsx(Un,{children:i.jsx(qn,{"aria-hidden":!0})}),i.jsx(Pe,{"aria-hidden":!0})]}),i.jsx(Yn,{children:e})]})}const $n=l.default.div`
290
- display: flex;
291
- flex-direction: column;
292
- width: 100%;
293
- min-width: 0;
294
- `,Hn=l.default.button`
295
- display: flex;
296
- align-items: center;
297
- cursor: pointer;
298
- user-select: none;
299
- width: fit-content;
300
- padding: 0;
301
- `,zn=l.default.span`
302
- display: flex;
303
- align-items: center;
304
- flex-shrink: 0;
305
- `,Bn=l.default.span`
306
- font-size: var(--font-size-sm);
307
- font-weight: var(--font-weight-regular);
308
- line-height: var(--line-height-sm);
309
- color: var(--text-color-description);
310
- `,Vn=l.default.div`
311
- display: flex;
312
- flex-direction: column;
313
- gap: 0;
314
- `,Pe=l.default.span`
315
- display: block;
316
- width: 1px;
317
- flex-shrink: 0;
318
- align-self: center;
319
- background: var(--border-color-secondary);
320
- flex: 1 1 auto;
321
- min-height: 8px;
322
- `,Fn=l.default.div`
323
- display: flex;
324
- flex-direction: row;
325
- align-items: stretch;
326
- gap: var(--spacing-xxs);
327
- min-width: 0;
328
-
329
- &:last-child {
330
- ${Pe} {
331
- display: none;
332
- }
333
- }
334
- `,Gn=l.default.div`
335
- display: flex;
336
- flex-direction: column;
337
- align-items: center;
338
- box-sizing: border-box;
339
- width: 12px;
340
- flex: 0 0 auto;
341
- align-self: stretch;
342
- min-height: 0;
343
- `,Wn=l.default.span`
344
- display: block;
345
- width: 1px;
346
- height: 4px;
347
- flex: 0 0 auto;
348
- flex-shrink: 0;
349
- background: var(--border-color-secondary);
350
- `,Un=l.default.div`
351
- width: 12px;
352
- height: 12px;
353
- flex: 0 0 auto;
354
- flex-shrink: 0;
355
- display: flex;
356
- align-items: center;
357
- justify-content: center;
358
- `,qn=l.default.span`
359
- width: 4px;
360
- height: 4px;
361
- flex-shrink: 0;
362
- border-radius: 50%;
363
- box-sizing: border-box;
364
- border: 1px solid var(--border-color-secondary);
365
- background: transparent;
366
- `,Yn=l.default.span`
367
- flex: 1;
368
- min-width: 0;
369
- align-self: flex-start;
370
- font-size: var(--font-size-sm);
371
- font-weight: var(--font-weight-regular);
372
- line-height: var(--line-height-sm);
373
- color: var(--text-color-helper);
374
- `;function Kn({items:e,messageMetadata:t}){return i.jsx(Zn,{children:e.map((n,o)=>{if(n.kind==="reasoning-block"){const s=o===e.length-1;return i.jsx(Nn,{items:n.items,isLast:s},n.key)}if(n.kind==="text")return i.jsx(Jn,{rawMarkdown:n.text,workflowRunHistoryIds:n.workflowRunHistoryIds},n.key);const{part:r}=n,a=x.parseToolName(r.type);return a&&x.isApprovalRequested(r)?i.jsx(En,{approvalId:r.approval.id,toolCallId:r.toolCallId,toolName:a,input:r.input},n.key):a&&x.isApprovalSettled(r)?i.jsx(Ln,{toolName:a,toolCallId:r.toolCallId,input:r.input,isDenied:r.state==="output-denied",messageMetadata:t},n.key):null})})}function Jn({rawMarkdown:e,workflowRunHistoryIds:t}){const n=Ce({workflowRunHistoryIds:t});return i.jsx(Xn,{onClick:n,children:i.jsx(f.Markdown,{rawMarkdown:e,parser:f.markdownParserMarked})})}const Zn=l.default.div`
375
- display: flex;
376
- flex-direction: column;
377
- gap: var(--spacing-xs);
378
- `,Xn=l.default.div`
379
- white-space: normal;
380
-
381
- max-width: 100%;
382
- overflow: hidden;
383
-
384
- p:first-child {
385
- margin-top: 0;
386
- }
387
-
388
- p:last-child {
389
- margin-bottom: 0;
390
- }
391
- `,Oe=l.default.div`
392
- font-family: var(--font-family-base);
393
- font-size: var(--font-size-sm);
394
- line-height: var(--line-height-sm);
395
- color: var(--text-color-primary);
396
- `,G=l.default.div`
397
- width: var(--search-ai-thinking-dot-size);
398
- height: var(--search-ai-thinking-dot-size);
399
- border-radius: 50%;
400
- background: var(--search-ai-thinking-dot-color);
401
- animation: bounce 1.4s infinite ease-in-out;
402
-
403
- &:nth-child(1) {
404
- animation-delay: -0.32s;
405
- }
406
-
407
- &:nth-child(2) {
408
- animation-delay: -0.16s;
409
- }
410
-
411
- &:nth-child(3) {
412
- animation-delay: 0s;
413
- }
414
-
415
- @keyframes bounce {
416
- 0%,
417
- 80%,
418
- 100% {
419
- opacity: 0.2;
420
- transform: scale(0.8);
421
- }
422
- 40% {
423
- opacity: 1;
424
- transform: scale(1);
425
- }
426
- }
427
- `;function Qn(){return i.jsxs(eo,{children:[i.jsx(G,{}),i.jsx(G,{}),i.jsx(G,{})]})}const eo=l.default.div`
428
- display: flex;
429
- align-items: center;
430
- justify-content: space-between;
431
- width: 24px;
432
- height: 24px;
433
- `;function to(){return i.jsxs(no,{children:[i.jsx(Qn,{}),i.jsx(oo,{children:"Thinking"})]})}const no=l.default.div`
434
- display: flex;
435
- align-items: center;
436
- gap: var(--spacing-xxs);
437
- `,oo=l.default.span`
438
- font-family: var(--font-family-base);
439
- font-size: var(--font-size-sm);
440
- line-height: var(--line-height-sm);
441
- color: var(--text-color-helper);
442
- `;function ro({items:e}){return i.jsx(p.Fragment,{children:e.map(t=>t.kind!=="text"?null:i.jsx(Oe,{children:t.text},t.key))})}const io="Something went wrong. Please try again.";function ao(e){const t=e?.message?.trim();return t||io}function so({message:e,isLastMessage:t}){const{chatStatus:n,chatError:o}=x.useAiConversationContext(),{role:r,parts:a}=e,s=r===M.MESSAGE_ROLE.ASSISTANT,d=p.useMemo(()=>x.getContentItems(a),[a]),c=d.length>0,u=n==="error"&&t&&s&&!c;return!c&&!u?null:i.jsx(_e,{$role:r,children:i.jsx(co,{isFailedEmptyAssistant:u,chatError:o,isAssistant:s,contentItems:d,messageMetadata:e.metadata})})}function lo(){return i.jsx(_e,{$role:M.MESSAGE_ROLE.ASSISTANT,children:i.jsx(oe,{children:i.jsx(to,{})})})}function co({isFailedEmptyAssistant:e,chatError:t,isAssistant:n,contentItems:o,messageMetadata:r}){return e?i.jsx(oe,{children:i.jsx(Oe,{children:ao(t)})}):i.jsx(oe,{children:n?i.jsx(Kn,{items:o,messageMetadata:r}):i.jsx(ro,{items:o})})}const _e=l.default.div`
443
- display: flex;
444
- flex-direction: column;
445
- padding: var(--spacing-xs) var(--spacing-sm);
446
- gap: var(--spacing-xxs);
447
- min-width: 0;
448
- width: ${({$role:e})=>e===M.MESSAGE_ROLE.ASSISTANT?"100%":"fit-content"};
449
- border-radius: ${({$role:e})=>e===M.MESSAGE_ROLE.USER?"6px 0px 6px 6px":"0px 6px 6px 6px"};
450
- background: ${({$role:e})=>e===M.MESSAGE_ROLE.USER?"var(--replay-ai-user-message-gradient)":"transparent"};
451
- border: none;
452
- color: var(--text-color-primary);
453
- box-sizing: border-box;
454
- word-wrap: break-word;
455
- white-space: pre-wrap;
456
- max-width: 100%;
457
- `,oe=l.default.div`
458
- display: flex;
459
- flex-direction: column;
460
- gap: var(--spacing-xxs);
461
- min-width: 0;
462
- width: 100%;
463
- `;function uo(){const{messages:e,isStreaming:t}=x.useAiConversationContext(),n=e.at(-1),o=p.useMemo(()=>{const r=n?.role===M.MESSAGE_ROLE.ASSISTANT,a=n?.parts.at(-1)?.type==="text";return t&&!(r&&a)},[t,n?.parts,n?.role]);return i.jsxs(fo,{children:[e.map((r,a)=>i.jsx(xe,{$role:r.role,children:i.jsx(ve,{$role:r.role,children:i.jsx(so,{message:r,isLastMessage:a===e.length-1})})},r.id)),o&&i.jsx(xe,{$role:M.MESSAGE_ROLE.ASSISTANT,children:i.jsx(ve,{$role:M.MESSAGE_ROLE.ASSISTANT,children:i.jsx(lo,{})})})]})}const fo=l.default.div`
464
- display: flex;
465
- flex-direction: column;
466
- gap: var(--spacing-xs);
467
- width: 100%;
468
- `,xe=l.default.div`
469
- display: flex;
470
- width: 100%;
471
- justify-content: ${({$role:e})=>e===M.MESSAGE_ROLE.USER?"flex-end":"flex-start"};
472
- `,ve=l.default.div`
473
- display: flex;
474
- flex-direction: column;
475
- align-items: ${({$role:e})=>e===M.MESSAGE_ROLE.USER?"flex-end":"stretch"};
476
- gap: var(--spacing-xs);
477
- min-width: 0;
478
- width: 100%;
479
- max-width: 100%;
480
- `;function po(e){const t=p.useRef(void 0);return p.useEffect(()=>{t.current=e}),t.current}const Me=l.default.div`
481
- display: flex;
482
- flex-direction: column;
483
- flex: 1;
484
- width: 100%;
485
- overflow: auto;
486
- padding: var(--spacing-xs);
487
- `,ho=e=>i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 14 14",fill:"none",...e,children:[i.jsx("path",{d:"M12.1683 8.65224C13.4439 7.91782 13.4439 6.08176 12.1683 5.34733L8.48891 3.22903L5.13033 6.57817C5.03961 6.66863 5.03961 6.8153 5.13033 6.90577L8.81674 10.5818L12.1683 8.65224Z",fill:"url(#replay-icon-gradient)"}),i.jsx("path",{d:"M7.56707 11.3013L3.81522 13.4613C2.53957 14.1957 0.945007 13.2777 0.945007 11.8088L0.945008 2.19072C0.945008 0.721872 2.53957 -0.196157 3.81522 0.538267L7.23924 2.50957L4.14475 5.59536C3.5097 6.22861 3.5097 7.25532 4.14475 7.88858L7.56707 11.3013Z",fill:"url(#replay-icon-gradient)"}),i.jsx("defs",{children:i.jsxs("linearGradient",{id:"replay-icon-gradient",x1:"12.0947",y1:"10.9627",x2:"1.65018",y2:"0.120816",gradientUnits:"userSpaceOnUse",children:[i.jsx("stop",{stopColor:"#C361FF"}),i.jsx("stop",{offset:"0.411322",stopColor:"#9461FF"}),i.jsx("stop",{offset:"0.73777",stopColor:"#207DFF"}),i.jsx("stop",{offset:"1",stopColor:"#1DA8F6"})]})})]}),go=l.default(ho)`
488
- height: ${({size:e})=>e||"14px"};
489
- width: ${({size:e})=>e||"14px"};
490
- `;function xo(e){const t="var(--font-size-base)";switch(e){case f.REUNITE_AI_PROVIDER:return i.jsx(go,{size:t});case f.AI_PROVIDERS.OPENAI:return i.jsx(v.ChatGptIcon,{size:t,color:"var(--text-color-primary)"});case f.AI_PROVIDERS.GEMINI:return i.jsx(v.GeminiIcon,{size:t});case f.AI_PROVIDERS.ANTHROPIC:return i.jsx(v.ClaudeIcon,{size:t,color:"var(--replay-claude-icon-color)"})}}function vo({models:e,selectedModelId:t,placement:n,onModelSelect:o,onSettingsOpen:r}){const a=e.find(g=>g.id===t),s=a?.label??"Replay AI",d=a?.id,c=e.filter(g=>g.provider===f.REUNITE_AI_PROVIDER),u=e.filter(g=>g.provider!==f.REUNITE_AI_PROVIDER),h=c.length>0&&u.length>0;return i.jsx(wo,{children:i.jsx(Co,{trigger:i.jsx(mo,{label:s}),placement:n,alignment:"start",withArrow:!0,children:i.jsxs(Ao,{children:[i.jsxs(Io,{children:[c.map(g=>i.jsx(me,{model:g,activeModelId:d,onModelSelect:o},g.id)),h&&i.jsx(ye,{"aria-hidden":!0}),u.length>0&&i.jsx(i.Fragment,{children:u.map(g=>i.jsx(me,{model:g,activeModelId:d,onModelSelect:o},g.id))})]}),r&&e.length>0&&i.jsx(ye,{"aria-hidden":!0}),r&&i.jsx(So,{prefix:i.jsx(v.SettingsCogIcon,{size:"var(--font-size-base)",color:"var(--text-color-secondary)"}),content:"Manage models",onAction:()=>r("ai-providers")})]})})})}function mo({label:e,icon:t,onClick:n,onKeyDown:o}){return i.jsxs(yo,{onClick:n,onKeyDown:o,children:[i.jsx(bo,{children:e}),t]})}function me({model:e,activeModelId:t,onModelSelect:n}){const o=e.id===t;return i.jsx(v.DropdownMenuItem,{prefix:xo(e.provider),suffix:o?i.jsx(jo,{size:"var(--font-size-base)",color:"var(--text-color-primary)"}):void 0,onAction:()=>n(e.id),active:o,children:i.jsx(To,{children:e.label})})}const yo=l.default.div`
491
- display: flex;
492
- align-items: center;
493
- min-width: 0;
494
- gap: var(--spacing-xxs);
495
- height: 24px;
496
- padding: 0 var(--spacing-xs);
497
- border-radius: var(--border-radius);
498
- background: var(--bg-color-active);
499
- cursor: pointer;
500
- user-select: none;
501
-
502
- &:hover {
503
- background: var(--layer-color-active);
504
- }
505
- `,bo=l.default.span`
506
- overflow: hidden;
507
- text-overflow: ellipsis;
508
- font-family: var(--font-family-base);
509
- font-size: var(--font-size-base);
510
- font-weight: var(--font-weight-regular);
511
- line-height: var(--line-height-base);
512
- color: var(--text-color-primary);
513
- white-space: nowrap;
514
- `,wo=l.default.div`
515
- --dropdown-menu-padding-top: 0;
516
-
517
- min-width: 0;
518
- flex: 1;
519
- position: relative;
520
- `,Co=l.default(v.Dropdown)`
521
- width: 100%;
522
- min-width: 0;
523
- flex: 1;
524
-
525
- > :last-child {
526
- width: 100%;
527
- max-width: 200px;
528
- }
529
- `,Ao=l.default(v.DropdownMenu)`
530
- --dropdown-menu-item-gap: calc(var(--spacing-unit) / 2);
531
- --dropdown-menu-item-padding-vertical: var(--spacing-xxs);
532
- --dropdown-menu-item-padding-horizontal: var(--spacing-xs);
533
-
534
- padding: var(--spacing-xxs);
535
- margin: 5px 0;
536
- border-radius: var(--border-radius-lg);
537
- background: var(--bg-color);
538
- `,To=l.default.span`
539
- flex: 1;
540
- min-width: 0;
541
- overflow: hidden;
542
- text-overflow: ellipsis;
543
- white-space: nowrap;
544
- `,jo=l.default(v.CheckmarkIcon)`
545
- margin-left: var(--spacing-xxs);
546
- `,ye=l.default.li`
547
- flex-shrink: 0;
548
- list-style: none;
549
- width: 100%;
550
- height: 1px;
551
- margin: 0;
552
- background: var(--border-color-secondary);
553
- `,Io=l.default.li`
554
- display: flex;
555
- flex-direction: column;
556
- gap: var(--dropdown-menu-item-gap);
557
- list-style: none;
558
- min-height: 0;
559
- overflow-y: auto;
560
- `,So=l.default(v.DropdownMenuItem)`
561
- flex-shrink: 0;
562
- `,ko=280;function Ne({pinToBottom:e=!1}){const[t,n]=p.useState(()=>f.getSemanticSearchService().getIndexingActivityState().inProgress);return p.useEffect(()=>f.getSemanticSearchService().subscribe("indexing-activity",r=>{n(r.inProgress)}),[]),i.jsx(Eo,{$open:t,$pinToBottom:e,"aria-hidden":!t,children:i.jsx(v.Tooltip,{tip:"We're building a search index of your project. Until it's ready, the assistant may need more context in each reply to stay accurate, which can use more tokens.",placement:"top",width:"240px",arrowPosition:"left",children:i.jsxs(Lo,{role:"status","aria-live":"polite","aria-label":"Indexing in progress...",children:[i.jsx("div",{children:i.jsx(G,{})}),i.jsx(Ro,{children:"Indexing in progress..."})]})})})}const Eo=l.default.div`
563
- width: 100%;
564
- display: block;
565
-
566
- ${({$pinToBottom:e})=>e?$.css`
567
- order: 1;
568
- margin-top: auto;
569
- `:$.css`
570
- position: absolute;
571
- left: 0;
572
- right: 0;
573
- bottom: 100%;
574
- z-index: 1;
575
- margin-bottom: 4px;
576
- `}
577
-
578
- opacity: ${({$open:e})=>e?1:0};
579
- transition: opacity ${ko}ms ease-out;
580
- pointer-events: ${({$open:e})=>e?"auto":"none"};
581
-
582
- ${G} {
583
- animation-play-state: ${({$open:e})=>e?"running":"paused"};
584
- }
585
- `,Lo=l.default.div`
586
- width: 100%;
587
- display: flex;
588
- align-items: center;
589
- gap: var(--spacing-xxs);
590
- background: var(--layer-color);
591
- padding: 2px var(--spacing-sm);
592
- border-radius: 4px;
593
- font-size: var(--font-size-sm);
594
- line-height: 12px;
595
- `,Ro=l.default.div`
596
- flex: 1;
597
- min-width: 0;
598
- `;function Po(){const{chatId:e,isLoading:t,pendingComposerPreset:n,clearPendingComposerPreset:o,availableModels:r,selectedModelId:a,selectModel:s,onSettingsOpen:d}=f.useAiChatContext(),{messages:c,isStreaming:u,sendMessage:h,stopGeneration:g}=x.useAiConversationContext(),{isOpen:m}=f.useAiPanel(),[b,y]=p.useState(""),A=p.useRef(null),C=p.useRef(null),T=p.useRef(!0),w=c.length>0,k=t||w,R=po(c.length),B=R!==void 0&&R>0&&!w,N=p.useCallback((E="smooth")=>{C.current&&C.current.scrollTo({top:C.current.scrollHeight,behavior:E})},[]),W=p.useCallback(()=>{const E=C.current;if(!E)return;E.scrollHeight-E.scrollTop-E.clientHeight<50&&(T.current=!0)},[]);p.useEffect(()=>{const E=C.current;if(!E)return;const ee=Be=>{Be.deltaY<0&&(T.current=!1)};return E.addEventListener("wheel",ee,{passive:!0}),()=>E.removeEventListener("wheel",ee)},[]);const He=p.useCallback(async()=>{b&&(y(""),T.current=!0,await h(b),A.current&&requestAnimationFrame(()=>A.current?.focus()))},[h,b]);p.useEffect(()=>{m&&(A.current&&A.current.focus(),T.current=!0,N())},[m,c.length,N]),p.useEffect(()=>{u&&T.current&&N()}),p.useEffect(function(){m&&A.current&&(A.current.focus(),N("instant"))},[e,m,N]),p.useEffect(function(){!m||n===null||(y(n),o())},[m,n,o]);const ze=i.jsx(Ye,{value:b,onValueChange:y,onSubmit:He,isStreaming:u,onStop:g,textareaRef:A,modelSelector:i.jsx(vo,{models:r,selectedModelId:a,placement:w?"top":"bottom",onModelSelect:s,onSettingsOpen:d})});return i.jsxs(Me,{children:[i.jsx(Oo,{ref:C,$isExpanded:k,$isAnimated:u||B,onScroll:W,children:t?i.jsx(Mo,{children:i.jsx(f.StyledSpinner,{size:"20px"})}):i.jsx(uo,{})}),i.jsxs(_o,{$isExpanded:!k,children:[i.jsx(Ne,{pinToBottom:!k}),ze]})]})}const Oo=l.default.div`
599
- flex: ${({$isExpanded:e})=>e?1:0};
600
- width: 100%;
601
- overflow: auto;
602
- padding-bottom: ${e=>e.$isExpanded?"var(--spacing-xs)":"0"};
603
- transition-property: flex;
604
- transition-duration: ${e=>e.$isAnimated?"var(--replay-transition-duration)":"0s"};
605
- transition-timing-function: var(--replay-transition-timing-function);
606
- `,_o=l.default.div`
607
- position: relative;
608
- display: flex;
609
- flex-direction: column;
610
- width: 100%;
611
- flex: ${({$isExpanded:e})=>e?1:0};
612
- `,Mo=l.default.div`
613
- display: flex;
614
- justify-content: center;
615
- height: 100%;
616
- padding-top: var(--spacing-lg);
617
- `,_={TODAY:"today",YESTERDAY:"yesterday",LAST_WEEK:"last_week",LAST_MONTH:"last_month",OLDER:"older"},No={[_.TODAY]:"Today",[_.YESTERDAY]:"Yesterday",[_.LAST_WEEK]:"Last 7 days",[_.LAST_MONTH]:"Last 30 days",[_.OLDER]:"Older"};function Do(e,t=Date.now()){const n=f.dayjs(e).startOf("day"),o=f.dayjs(t).startOf("day"),r=f.dayjs(t).subtract(1,"day").startOf("day"),a=f.dayjs(t).subtract(7,"day").startOf("day"),s=f.dayjs(t).subtract(30,"day").startOf("day");return n.isSame(o,"day")?_.TODAY:n.isSame(r,"day")?_.YESTERDAY:!n.isBefore(a,"day")&&n.isBefore(r,"day")?_.LAST_WEEK:!n.isBefore(s,"day")&&n.isBefore(a,"day")?_.LAST_MONTH:_.OLDER}function $o(e){const t=[];for(const n of e){const o=Do(n.updatedAt),r=t[t.length-1];!r||r.bucket!==o?t.push({bucket:o,chats:[n]}):r.chats.push(n)}return t}function Ho(e){const{scrollRef:t,sentinelRef:n,hasNextPage:o,isFetchingNextPage:r,fetchNextPage:a,observerResetKey:s}=e;p.useLayoutEffect(()=>{const d=t.current,c=n.current;if(!d||!c)return;const u=new IntersectionObserver(h=>{const g=h[0];g&&g.isIntersecting&&o&&(r||a())},{root:d,rootMargin:"80px"});return u.observe(c),()=>{u.disconnect()}},[s,a,o,r,t,n])}const De=l.default(Me)`
618
- gap: var(--spacing-xxs);
619
- user-select: none;
620
- `,zo=l.default.div`
621
- display: flex;
622
- flex-direction: column;
623
- gap: var(--spacing-xs);
624
- `,Bo=l.default.div`
625
- display: flex;
626
- flex-direction: column;
627
- gap: var(--spacing-xxs);
628
- `,Vo=l.default(De)`
629
- display: flex;
630
- flex-grow: 1;
631
- align-items: center;
632
- flex-direction: column;
633
- padding: var(--spacing-md);
634
- `,Fo=l.default.div`
635
- display: flex;
636
- flex-grow: 1;
637
- align-items: center;
638
- justify-content: center;
639
- `,Go=l.default.div`
640
- display: flex;
641
- flex-direction: column;
642
- align-items: center;
643
- max-width: 75%;
644
- gap: var(--spacing-xxs);
645
- `,Wo=l.default.div`
646
- display: flex;
647
- justify-content: center;
648
- padding: var(--spacing-xs);
649
- `,Uo=l.default(v.Typography)`
650
- padding-left: var(--spacing-xs);
651
- font-size: var(--font-size-sm);
652
- color: var(--color-warm-grey-7);
653
- `,qo=l.default.div`
654
- display: flex;
655
- flex-grow: 1;
656
-
657
- .tooltip-expanded {
658
- flex-grow: 1;
659
- min-width: 0;
660
- }
661
- `,Yo=l.default.div`
662
- display: flex;
663
- align-items: center;
664
- justify-content: space-between;
665
- flex-grow: 1;
666
- min-width: 0;
667
- border-radius: var(--border-radius);
668
- padding: calc(var(--spacing-xxs) / 2) var(--spacing-xs);
669
- gap: calc(var(--spacing-xxs) * 2.5);
670
- cursor: pointer;
671
-
672
- ${v.Button} {
673
- display: none;
674
- }
675
-
676
- &:focus-within,
677
- &:hover {
678
- background-color: var(--color-hover-base);
679
-
680
- ${v.Button} {
681
- display: inline-flex;
682
- }
683
- }
684
- `,Ko=l.default(v.Typography)`
685
- overflow: hidden;
686
- white-space: nowrap;
687
- text-overflow: ellipsis;
688
- `,Jo=l.default.div`
689
- height: 1px;
690
- flex-shrink: 0;
691
- `;function Zo(e){const{chat:t,onSelect:n,onRemove:o}=e;return i.jsx(qo,{children:i.jsx(v.Tooltip,{tip:f.dayjs(t.updatedAt).format("MMM DD, YYYY, hh:mm:ss A"),className:"expanded",children:i.jsxs(Yo,{role:"button",onClick:()=>n?.(t.id),children:[i.jsx(Ko,{children:t.title??"New chat"}),i.jsx(v.Button,{variant:"ghost",size:"small",tone:"danger",icon:i.jsx(v.TrashCanIcon,{}),onClick:r=>{r.stopPropagation(),o?.(t.id)}})]})})})}function Xo(e){const{group:t,onChatSelect:n,onChatRemove:o}=e;return i.jsxs(Bo,{children:[i.jsx(Uo,{children:No[t.bucket]}),t.chats.map(r=>i.jsx(Zo,{chat:r,onSelect:n,onRemove:o},r.id))]})}function Qo(){return i.jsx(Fo,{children:i.jsxs(Go,{children:[i.jsx(v.Typography,{textAlign:"center",fontWeight:"var(--font-weight-semibold)",children:"No chat history"}),i.jsx(v.Typography,{textAlign:"center",children:"Ask questions or let the assistant take action for you."})]})})}function er(){return i.jsx(Vo,{children:i.jsx(f.StyledSpinner,{})})}const tr=50;function nr(e){const{onChatSelect:t,onChatRemove:n}=e,o=p.useRef(null),r=p.useRef(null),{data:a,isPending:s,hasNextPage:d,isFetchingNextPage:c,fetchNextPage:u}=x.useInfiniteChatHistory(tr),h=p.useMemo(()=>(a?.pages??[]).flatMap(m=>m.items),[a?.pages]),g=p.useMemo(()=>$o(h),[h]);return Ho({scrollRef:o,sentinelRef:r,hasNextPage:d,isFetchingNextPage:c,fetchNextPage:u,observerResetKey:a?.pages.length}),s&&!a?i.jsx(er,{}):h.length===0?i.jsx(Qo,{}):i.jsxs(De,{ref:o,children:[i.jsx(zo,{children:g.map(m=>i.jsx(Xo,{group:m,onChatSelect:t,onChatRemove:n},`${m.bucket}-${m.chats[0]?.id??""}`))}),d&&i.jsx(Jo,{ref:r,"aria-hidden":!0}),c&&i.jsx(Wo,{children:i.jsx(f.StyledSpinner,{})})]})}const or=p.createContext(null);function rr(e){const t=p.useContext(or);if(t?.components){const{LinkComponent:s}=t.components;return i.jsx(s,{...e})}const{external:n,languageInsensitive:o,innerRef:r,...a}=e;return i.jsx(Ve.Link,{ref:r,...a})}const ir=()=>$.keyframes`
692
- 0% {
693
- color: var(--button-content-color);
694
- background-color: var(--button-bg-color-active);
695
- }
696
-
697
- 50% {
698
- background-color: var(--button-bg-color);
699
- }
700
-
701
- 100% {
702
- color: var(--button-content-color);
703
- background-color: var(--button-bg-color-active);
704
- }
705
- `,ar=l.default(rr)`
706
- text-decoration: none;
707
- &:focus-visible {
708
- outline: 1px solid var(--button-border-color-focused);
709
- }
710
- border-radius: var(--button-border-radius);
711
- `;function sr({variant:e="secondary",tone:t="default",size:n="medium",extraClass:o="",className:r=""}){return["button",o,`button-tone-${t}`,`button-variant-${e}`,`button-size-${n}`,r].filter(s=>s).join(" ").trim()}const lr=l.default.button`
712
- width: ${({$fullWidth:e})=>e?"100%":"auto"};
713
-
714
- display: inline-flex;
715
- align-items: center;
716
- justify-content: center;
717
- gap: var(--button-gap);
718
- margin: var(--button-margin);
719
- cursor: pointer;
720
- text-wrap: var(--button-text-wrap);
721
-
722
- color: var(--button-color);
723
- background-color: var(--button-bg-color);
724
- border: var(--button-border-width) var(--button-border-style) var(--button-border-color);
725
- box-shadow: var(--button-box-shadow);
726
- backdrop-filter: var(--button-backdrop-filter, none);
727
-
728
- font-weight: var(--button-font-weight);
729
- font-size: var(--button-font-size);
730
- line-height: var(--button-line-height);
731
- padding: ${({$icon:e,$iconPosition:t,$iconOnly:n})=>e?`var(--button-icon-${n?"":`${t||"left"}-`}padding)`:"var(--button-padding)"};
732
- border-radius: var(--button-border-radius);
733
-
734
- svg {
735
- width: var(--button-icon-size);
736
- height: var(--button-icon-size);
737
- }
738
-
739
- &:hover {
740
- background-color: var(--button-bg-color-hover);
741
- color: var(--button-color-hover);
742
- border-color: var(--button-border-color-hover);
743
- }
744
-
745
- &:active,
746
- &.active {
747
- background-color: var(--button-bg-color-active);
748
- border-color: var(--button-border-color-active);
749
- color: var(--button-color-active);
750
- }
751
-
752
- &:focus-visible {
753
- outline: 1px solid var(--button-border-color-focused);
754
- }
755
-
756
- &.button-tone-danger {
757
- color: var(--button-content-color-danger);
758
- border-color: var(--button-border-color-danger);
759
- background-color: var(--button-bg-color-danger);
760
-
761
- &:hover {
762
- color: var(--button-content-color-danger-hover);
763
- border-color: var(--button-border-color-danger-hover);
764
- background-color: var(--button-bg-color-danger-hover);
765
- }
766
-
767
- &:active {
768
- color: var(--button-content-color-danger-pressed);
769
- border-color: var(--button-border-color-danger-pressed);
770
- background-color: var(--button-bg-color-danger-pressed);
771
- }
772
- }
773
-
774
- &:disabled {
775
- pointer-events: none;
776
- background-color: var(--button-bg-color-disabled);
777
- color: var(--button-content-color-disabled);
778
- border-color: var(--button-border-color-disabled);
779
- border-width: var(--button-border-width-disabled);
780
- }
781
-
782
- ${({$variant:e,$size:t})=>(e==="link"||e==="ghost")&&t==="small"&&$.css`
783
- --button-font-size: var(--font-size-sm);
784
- --button-line-height: var(--line-height-sm);
785
- --button-icon-padding: var(--button-icon-padding-small) !important;
786
- `}
787
-
788
- ${({$blinking:e})=>e&&$.css`
789
- pointer-events: none;
790
- animation: ${ir()} 1.2s infinite;
791
- `}
792
- `,cr=e=>{const{languageInsensitive:t,fullWidth:n,blinking:o,iconPosition:r,icon:a,children:s,variant:d,tone:c,size:u,extraClass:h,to:g,external:m,className:b,...y}=e,A="tabIndex"in e?e.tabIndex:e.to?-1:void 0,C=i.jsxs(lr,{"data-component-name":"Button/Button",...y,className:sr({variant:d,tone:c,size:u,extraClass:h,className:b}),$fullWidth:n,$blinking:o,$iconPosition:r,$icon:a,$iconOnly:!s&&a!=null,$variant:d,$size:u,tabIndex:A,children:[a&&r!=="right"&&a,s,a&&r==="right"&&a]});return g?i.jsx(ar,{to:g,external:m,languageInsensitive:t,onClick:e.onClick,children:C}):C},K=l.default(cr)``;function dr(){const e=p.useRef(null),[t,n]=p.useState(!1);return p.useLayoutEffect(()=>{if(!e.current)return;const o=e.current;function r(){n(o.scrollWidth>o.clientWidth)}r();const a=new ResizeObserver(r);return a.observe(o),()=>a.disconnect()},[]),{ref:e,value:t}}function ur(e){const{ref:t,value:n}=dr();return i.jsx(fr,{children:i.jsx(v.Tooltip,{tip:e.value,className:"no-overflow",disabled:!n,children:i.jsx(pr,{ref:t,children:e.value})})})}const fr=l.default.div`
793
- overflow: hidden;
794
- .tooltip-no-overflow {
795
- overflow: hidden;
796
- }
797
- `,pr=l.default.div`
798
- color: var(--text-color-primary);
799
- font-size: var(--font-size-base);
800
- line-height: var(--line-height-base);
801
- overflow: hidden;
802
- white-space: nowrap;
803
- text-overflow: ellipsis;
804
- user-select: none;
805
- `;function $e(e){const{children:t,buttons:n}=e;return i.jsxs(hr,{children:[i.jsx(gr,{children:t}),n&&i.jsx(xr,{children:n})]})}const hr=l.default.div`
806
- display: flex;
807
- flex-direction: row;
808
- align-items: center;
809
- padding: var(--spacing-xs);
810
- gap: var(--spacing-xs);
811
- width: 100%;
812
- flex-shrink: 0;
813
- `,gr=l.default.div`
814
- display: flex;
815
- align-items: center;
816
- gap: var(--spacing-xs);
817
- min-width: 0;
818
- flex: 1;
819
- `,xr=l.default.div`
820
- display: flex;
821
- align-items: center;
822
- gap: 2px;
823
- `;function vr(e){const{title:t,onCreateNewChat:n,onViewHistory:o,onClose:r}=e,a=i.jsxs(i.Fragment,{children:[i.jsx(v.Tooltip,{tip:"New chat",children:i.jsx(K,{size:"small",variant:"text","aria-label":"Create new chat",onClick:n,icon:i.jsx(v.NewChatIcon,{})})}),i.jsx(v.Tooltip,{tip:"Chat history",children:i.jsx(K,{size:"small",variant:"text","aria-label":"View chat history",onClick:o,icon:i.jsx(v.RecentlyViewedIcon,{})})}),i.jsx(yr,{children:i.jsx(f.VerticalDivider,{})}),i.jsx(v.Tooltip,{tip:"Close",arrowPosition:"left",children:i.jsx(K,{variant:"text",size:"small","aria-label":"Close panel",icon:i.jsx(v.CloseIcon,{}),onClick:r})})]});return i.jsxs($e,{buttons:a,children:[i.jsx(mr,{children:i.jsx(v.AiStarsGradientIcon,{size:"14px"})}),i.jsx(ur,{value:t})]})}const mr=l.default.div`
824
- display: flex;
825
- `,yr=l.default.div`
826
- display: flex;
827
- height: 14px;
828
- `,br=new Set(["color","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","letterSpacing","marginBottom","marginTop","textAlign"]),wr=l.default.span.withConfig({shouldForwardProp:e=>!br.has(e)}).attrs({"data-component-name":"Typography/Typography"})`
829
- color: ${({color:e})=>e||"var(--text-color-primary)"};
830
- font-family: ${({fontFamily:e})=>e||"var(--font-family-base)"};
831
- font-size: ${({fontSize:e})=>e||"var(--font-size-base)"};
832
- font-style: ${({fontStyle:e})=>e};
833
- font-weight: ${({fontWeight:e})=>e||"var(--font-weight-regular)"};
834
- line-height: ${({lineHeight:e})=>e||"var(--line-height-base)"};
835
- letter-spacing: ${({letterSpacing:e})=>e};
836
- margin-bottom: ${({marginBottom:e})=>e};
837
- margin-top: ${({marginTop:e})=>e};
838
- text-align: ${({textAlign:e})=>e};
839
- `;function Cr(e){const{onReturnFromHistory:t}=e;return i.jsxs($e,{children:[i.jsx(K,{size:"small",variant:"text","aria-label":"Return to chat",onClick:t,icon:i.jsx(v.ArrowLeftIcon,{})}),i.jsx(Ar,{children:i.jsx(wr,{children:"Chat history"})})]})}const Ar=l.default.div`
840
- user-select: none;
841
- `;function Tr(){const[e,t]=p.useState(x.AI_TAB.CHAT),n=f.useAiPanel(),o=f.useAiChatContext(),r=()=>{t(x.AI_TAB.HISTORY)},a=()=>{t(x.AI_TAB.CHAT)},s=async d=>{o.selectChat(d),t(x.AI_TAB.CHAT)};return i.jsxs(jr,{children:[i.jsxs(be,{isActive:e===x.AI_TAB.CHAT,children:[i.jsx(vr,{title:o.title,onCreateNewChat:o.createNewChat,onViewHistory:r,onClose:n.closePanel}),i.jsx(Po,{})]}),i.jsxs(be,{isActive:e===x.AI_TAB.HISTORY,isSliding:!0,children:[i.jsx(Cr,{onReturnFromHistory:a}),i.jsx(nr,{onChatSelect:s,onChatRemove:o.removeChat}),i.jsx(Sr,{children:i.jsx(Ne,{pinToBottom:!0})})]})]})}function be(e){const{children:t,isActive:n,isSliding:o=!1}=e,r=i.jsx(Ir,{inert:!n,children:t});return o?i.jsx(kr,{$isExpanded:n,children:r}):r}const jr=l.default.div`
842
- position: relative;
843
- height: 100%;
844
- overflow: clip;
845
- `,Ir=l.default.div`
846
- display: flex;
847
- height: 100%;
848
- flex-direction: column;
849
- align-items: flex-start;
850
- border-radius: var(--border-radius-md);
851
- background: var(--bg-color);
852
- margin-left: var(--spacing-xxs);
853
- `,Sr=l.default.div`
854
- display: flex;
855
- flex-direction: column;
856
- width: 100%;
857
- padding: 0 var(--spacing-xs) var(--spacing-xs);
858
- `,kr=l.default.div`
859
- position: absolute;
860
- inset: 0;
861
- transform: translateX(${e=>e.$isExpanded?"0%":"100%"});
862
- transition-property: transform;
863
- transition-duration: 400ms;
864
- transition-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
865
- @media (prefers-reduced-motion: reduce) {
866
- transition-duration: 0ms;
867
- }
868
- `;exports.AiPanel=Tr;