@interopio/io-assist-react 1.0.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 (99) hide show
  1. package/README.internal.md +467 -0
  2. package/README.md +503 -0
  3. package/changelog.md +2 -0
  4. package/dist/IoAssist.d.ts +12 -0
  5. package/dist/actions/abortActiveStream.d.ts +2 -0
  6. package/dist/actions/deleteThread.d.ts +2 -0
  7. package/dist/actions/elicitation.d.ts +13 -0
  8. package/dist/actions/initIoAiWeb.d.ts +3 -0
  9. package/dist/actions/initIoConnect.d.ts +9 -0
  10. package/dist/actions/mcpAppEvents.d.ts +4 -0
  11. package/dist/actions/newConversation.d.ts +2 -0
  12. package/dist/actions/processResponseStream.d.ts +3 -0
  13. package/dist/actions/renameThread.d.ts +2 -0
  14. package/dist/actions/sampling.d.ts +5 -0
  15. package/dist/actions/selectThread.d.ts +2 -0
  16. package/dist/actions/sendUserMessage.d.ts +3 -0
  17. package/dist/actions/toggleFavoritePrompt.d.ts +7 -0
  18. package/dist/actions/toggleTool.d.ts +2 -0
  19. package/dist/components/chat/ActivePanelModal.d.ts +6 -0
  20. package/dist/components/chat/AiDisclaimer.d.ts +6 -0
  21. package/dist/components/chat/Chat.d.ts +2 -0
  22. package/dist/components/chat/ConfirmModal.d.ts +8 -0
  23. package/dist/components/chat/WelcomeHeading.d.ts +6 -0
  24. package/dist/components/header/Header.d.ts +2 -0
  25. package/dist/components/input-area/InputArea.d.ts +8 -0
  26. package/dist/components/messages/AssistantMessage.d.ts +10 -0
  27. package/dist/components/messages/McpAppResource.d.ts +11 -0
  28. package/dist/components/messages/MdFormatter.d.ts +6 -0
  29. package/dist/components/messages/MessageArea.d.ts +7 -0
  30. package/dist/components/messages/ToolMessage.d.ts +9 -0
  31. package/dist/components/messages/ToolTraceMessage.d.ts +9 -0
  32. package/dist/components/messages/UserMessage.d.ts +9 -0
  33. package/dist/components/messages/mdUtils.d.ts +1 -0
  34. package/dist/components/messages/prismTwilightTheme.d.ts +2 -0
  35. package/dist/components/prompt/FavoritePromptList.d.ts +2 -0
  36. package/dist/components/prompt/PromptListItem.d.ts +8 -0
  37. package/dist/components/prompt/PromptListPanel.d.ts +6 -0
  38. package/dist/components/scroll-area/ScrollArea.d.ts +33 -0
  39. package/dist/components/shared/Icon.d.ts +8 -0
  40. package/dist/components/shared/IconButton.d.ts +11 -0
  41. package/dist/components/shared/Modal.d.ts +12 -0
  42. package/dist/components/shared/SearchInput.d.ts +8 -0
  43. package/dist/components/shared/ToggleInput.d.ts +8 -0
  44. package/dist/components/shared/Tooltip.d.ts +10 -0
  45. package/dist/components/shared/icons.d.ts +37 -0
  46. package/dist/components/threads/ThreadHistory.d.ts +6 -0
  47. package/dist/components/threads/ThreadHistoryListItem.d.ts +18 -0
  48. package/dist/components/threads/ThreadHistoryPanel.d.ts +7 -0
  49. package/dist/components/tool/ToolListItem.d.ts +8 -0
  50. package/dist/components/tool/ToolListPanel.d.ts +2 -0
  51. package/dist/components/working-context-panel/WorkingContextPanel.d.ts +2 -0
  52. package/dist/constants/modalActions.d.ts +11 -0
  53. package/dist/constants/uiStrings.d.ts +141 -0
  54. package/dist/context/IoAssistContext.d.ts +14 -0
  55. package/dist/files/inter-latin-wght-normal.woff2 +0 -0
  56. package/dist/hooks/useHoverMouseFollow.d.ts +27 -0
  57. package/dist/hooks/useIoAiWebApi.d.ts +19 -0
  58. package/dist/hooks/useIoAiWebBootstrap.d.ts +8 -0
  59. package/dist/hooks/useIoConnectApi.d.ts +12 -0
  60. package/dist/hooks/useIoConnectBootstrap.d.ts +10 -0
  61. package/dist/hooks/useIsMobileViewport.d.ts +1 -0
  62. package/dist/index.cjs +41 -0
  63. package/dist/index.cjs.map +1 -0
  64. package/dist/index.d.ts +2 -0
  65. package/dist/index.js +3624 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/stores/agent.d.ts +15 -0
  68. package/dist/stores/app-lifecycle.d.ts +21 -0
  69. package/dist/stores/confirm-modal.d.ts +29 -0
  70. package/dist/stores/index.d.ts +32 -0
  71. package/dist/stores/mcp-apps.d.ts +13 -0
  72. package/dist/stores/message.d.ts +33 -0
  73. package/dist/stores/prompt.d.ts +16 -0
  74. package/dist/stores/response-stream.d.ts +31 -0
  75. package/dist/stores/thread.d.ts +17 -0
  76. package/dist/stores/tool.d.ts +15 -0
  77. package/dist/stores/working-context.d.ts +16 -0
  78. package/dist/styles.css +1 -0
  79. package/dist/types/agent.d.ts +8 -0
  80. package/dist/types/config.d.ts +40 -0
  81. package/dist/types/icon.d.ts +5 -0
  82. package/dist/types/index.d.ts +15 -0
  83. package/dist/types/loading.d.ts +38 -0
  84. package/dist/types/message.d.ts +56 -0
  85. package/dist/types/panel.d.ts +6 -0
  86. package/dist/types/prompt.d.ts +17 -0
  87. package/dist/types/stream.d.ts +22 -0
  88. package/dist/types/thread.d.ts +15 -0
  89. package/dist/types/tool.d.ts +15 -0
  90. package/dist/utils/confirmModal.d.ts +5 -0
  91. package/dist/utils/ioModals.d.ts +21 -0
  92. package/dist/utils/logger.d.ts +34 -0
  93. package/dist/utils/mcpAppModal.d.ts +3 -0
  94. package/dist/utils/messageConverter.d.ts +3 -0
  95. package/dist/utils/messageUtils.d.ts +16 -0
  96. package/dist/utils/safeStringify.d.ts +1 -0
  97. package/dist/utils/streamUtils.d.ts +15 -0
  98. package/dist/utils/threadUtils.d.ts +16 -0
  99. package/package.json +65 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";var Ge=Object.create;var de=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Fe=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty;var $e=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ue(t))!We.call(e,a)&&a!==n&&de(e,a,{get:()=>t[a],enumerable:!(o=Be(t,a))||o.enumerable});return e};var Ve=(e,t,n)=>(n=e!=null?Ge(Fe(e)):{},$e(t||!e||!e.__esModule?de(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),S=require("react"),Ae=require("zustand"),ze=require("zustand/middleware"),Ze=require("react-dom"),Xe=require("prism-react-renderer"),qe=require("react-markdown"),Ke=require("remark-gfm"),y={GENERAL:{WELCOME_MESSAGE:e=>e?`Welcome, ${e}! How can I assist you today?`:"Welcome! How can I assist you today?",AI_CONTENT_INFO:"AI-generated content may be incorrect",INITIALIZING_SERVICES:"Initializing services, please wait...",CANNOT_CONNECT_TO_IO:"Cannot connect to IO.",IO_INTEL_INIT_ERROR:"Error initializing IO Intel Web API. Please check your configuration and refresh the page to try again.",DOCUMENTATION_LINK:e=>`For more information, please refer to the documentation: ${e&&e.length>0?e:"https://docs-ai.interop.io/"}`,REFRESH:"Refresh",EDIT:"Edit",DELETE:"Delete",SAVE:"Save",CANCEL:"Cancel",CONFIRM:"Confirm",SUBMIT:"Submit",SEARCH:"Search",LOADING:"Loading",COPY:"Copy",RELOAD:"Reload",NO_SEARCH_RESULTS:"No results found"},INPUT_COMPONENT:{INPUT_PLACEHOLDER:"Type your message..."},WORKING_CONTEXT_PANEL_COMPONENT:{VIEW_WORKING_CONTEXT_BUTTON:"View Context"},THREAD_HISTORY_COMPONENT:{NO_THREADS:"No available message threads.",DIVIDERS:{JUST_NOW:"Just now",FIVE_MINS_AGO:"5 mins ago",THIRTY_MINS_AGO:"30 mins ago",ONE_HOUR_AGO:"1 hour ago",TWO_HOURS_AGO:"2 hours ago",SIX_HOURS_AGO:"6 hours ago",TWELVE_HOURS_AGO:"12 hours ago",TODAY:"Today",YESTERDAY:"Yesterday",TWO_DAYS_AGO:"2 days ago",LAST_WEEK:"Last Week",TWO_WEEKS_AGO:"2 weeks ago",ONE_MONTH_AGO:"1 month ago",THREE_MONTHS_AGO:"3 months ago",SIX_MONTHS_AGO:"6 months ago",MORE_THAN_YEAR_AGO:"more than 1 year ago"}},PROMPT_LIST_COMPONENT:{AVAILABLE_PROMPTS:"Available Prompts",FAVORITE_PROMPTS:"Favorite Prompts",NO_PROMPTS:"No prompts available.",NO_PROMPTS_CONFIGURED:"No prompts are available. Prompts should be provided as a configuration.",NO_PROMPTS_SEE_MORE:"See more",INPUT_TOOLTIP:"Search prompts..."},TOOL_LIST_COMPONENT:{AVAILABLE_TOOLS:"Available Tools",NO_FILTERED_TOOLS:"No tools matching your search.",NO_TOOLS:"There are currently no tools available.",NO_TOOLS_SEE_MORE:"See more",LOADING_TOOLS:"Loading tools...",INPUT_TOOLTIP:"Search tools..."},TOOL_MESSAGE:{TOOL_EXECUTION_SUCCESS:"Tool executed successfully.",TOOL_EXECUTION_PENDING:"Tool execution in progress..."},TOOL_TRACE_MESSAGE:{EXPAND_BUTTON_TEXT:"Show Tool Trace Details",COLLAPSE_BUTTON_TEXT:"Hide Tool Trace Details",CLOSE_BUTTON_TEXT:"Close"},WORKING_CONTEXT_PANEL:{TITLE:"Working Context",DESCRIPTION:"The working context provides additional information to assist the agent in generating accurate responses."},LOADING_STATE:{ERROR:"Error initializing IO Intel Web API. Please check your configuration and refresh the page to try again.",RETRY:"Refresh"},SAMPLING_MODAL:{TITLE:"io.Assist",HEADING:"Permission to Proceed",TEXT:"I can dive deeper to give a clearer answer, but I'll need your permission first. Continue?"},ELICITATION_MODAL:{TITLE:"io.Assist",HEADING:"Permission to Proceed",FALLBACK_TEXT:"I can dive deeper to give a clearer answer, but I'll need your permission first. Continue?"},MCP_APP_REPLACE_MODAL:{TITLE:"MCP App Already Open",HEADING:"Replace Existing Instance?",TEXT:e=>`An instance of "${e}" is already open in the workspace. Replace it with the new instance, or open it alongside as a new instance?`,REPLACE_BUTTON:"Replace",NEW_INSTANCE_BUTTON:"New Instance"}},b={USER:"user",ASSISTANT:"assistant",TOOL:"tool"},ve={TEXT:"text"},Z={IDLE:"IDLE",ENABLING_DISABLING:"ENABLING_DISABLING"},F={WORKING_CONTEXT:"working-context",PROMPTS:"prompts",TOOLS:"tools"},R={IDLE:"idle",STREAMING:"streaming",COMPLETED:"completed",ERROR:"error",ABORTED:"aborted"},w={NOT_STARTED:"not-started",LOADING:"loading",SUCCESS:"success",ERROR:"error"},k={NOT_STARTED:"NOT_STARTED",LOADING_RESPONSE:"LOADING_RESPONSE",LOADING_FROM_THREAD:"LOADING_FROM_THREAD",GET_RESPONSE_SUCCESS:"GET_RESPONSE_SUCCESS",FETCH_MESSAGES_FROM_THREAD_SUCCESS:"FETCH_MESSAGES_FROM_THREAD_SUCCESS",ERROR:"ERROR"},Ye=e=>({agents:[],selectedAgent:null,agentsLoadingState:{type:w.NOT_STARTED},setAgents:t=>e({agents:t}),setSelectedAgent:t=>e({selectedAgent:t}),setAgentsLoadingState:t=>e({agentsLoadingState:t})}),Je=e=>({appLoadingState:{type:w.NOT_STARTED},isIoConnectReady:!1,isDarkMode:!1,ioConnectApi:null,ioAiWebApi:null,setAppLoadingState:t=>e({appLoadingState:t}),setIsIoConnectReady:t=>e({isIoConnectReady:t}),setIsDarkMode:t=>e({isDarkMode:t}),setIoConnectApi:t=>e({ioConnectApi:t}),setIoAiWebApi:t=>e({ioAiWebApi:t})}),Qe=e=>({isThreadHistoryVisible:!1,activePanelContent:null,currentConfirmModal:null,setIsThreadHistoryVisible:t=>e({isThreadHistoryVisible:t}),setActivePanelContent:t=>e({activePanelContent:t}),showConfirmModal:t=>e({currentConfirmModal:t}),closeConfirmModal:()=>e({currentConfirmModal:null})}),et=e=>({mcpAppInstances:[],addMcpApp:t=>e(n=>n.mcpAppInstances.find(o=>o.id===t.id)?{}:{mcpAppInstances:[...n.mcpAppInstances,t]}),removeMcpApp:t=>e(n=>({mcpAppInstances:n.mcpAppInstances.filter(o=>o.id!==t)})),resetMcpApps:()=>e({mcpAppInstances:[]})}),tt=e=>({messages:[],isGeneratingResponse:!1,messageLoadingState:{type:k.NOT_STARTED},isLastResponseSuccess:!1,toolTraceState:[],scrollAnchorRequestId:0,requestScrollAnchor:()=>e(t=>({scrollAnchorRequestId:t.scrollAnchorRequestId+1})),setMessages:t=>e({messages:t}),addMessage:t=>e(n=>({messages:[...n.messages,t]})),updateMessage:(t,n)=>e(o=>({messages:o.messages.map(a=>a.id===t?{...a,...n}:a)})),clearMessages:()=>e({messages:[],toolTraceState:[],isLastResponseSuccess:!1,messageLoadingState:{type:k.NOT_STARTED}}),setIsGeneratingResponse:t=>e({isGeneratingResponse:t}),setMessageLoadingState:t=>e({messageLoadingState:t}),setIsLastResponseSuccess:t=>e({isLastResponseSuccess:t}),setToolTraceState:t=>e({toolTraceState:t}),toggleToolTrace:t=>e(n=>({toolTraceState:n.toolTraceState.map(o=>o.stateForMessageId===t?{...o,isExpanded:!o.isExpanded}:o)})),toggleToolMessage:(t,n)=>e(o=>({toolTraceState:o.toolTraceState.map(a=>a.stateForMessageId===n?{...a,executedTools:a.executedTools.map(r=>r.id===t?{...r,isExpanded:!r.isExpanded}:r)}:a)})),mergeAccumulatedStreamContent:t=>e(n=>{const o=n.streamsByThreadId[t];if(!o)return{};let a=[...n.messages];o.userMessage&&!a.some(u=>u.id===o.userMessage.id)&&a.push(o.userMessage);for(const u of o.toolMessages)a.some(g=>g.id===u.id)||a.push(u);const r=o.messageId??(o.toolMessages.length>0?`accumulated-${Date.now()}`:null);if(o.content&&o.content.trim()!==""){const u=a.findIndex(g=>g.id===r&&g.role==="assistant");u>=0?a=a.map((g,d)=>d===u?{...g,content:o.content}:g):r&&a.push({id:r,role:"assistant",content:o.content})}else r&&o.toolMessages.length>0&&!a.some(u=>u.id===r&&u.role==="assistant")&&a.push({id:r,role:"assistant",content:""});let i=n.toolTraceState;if(r&&o.toolMessages.length>0){const u=o.toolMessages.length,g={stateForMessageId:r,executedTools:o.toolMessages,uiMessage:`Used ${u} tool${u!==1?"s":""}`,isExpanded:!1},d=i.findIndex(f=>f.stateForMessageId===r);i=d>=0?i.map((f,T)=>T===d?g:f):[...i,g]}const l=a.length!==n.messages.length,p=i!==n.toolTraceState;if(!l&&!p)return{};const x={};return l&&(x.messages=a),p&&(x.toolTraceState=i),x})}),st=e=>({allPrompts:[],favoritePromptNames:[],selectedPrompt:null,setAllPrompts:t=>e({allPrompts:t}),setFavoritePromptNames:t=>e({favoritePromptNames:t}),toggleFavoritePrompt:t=>e(n=>({favoritePromptNames:n.favoritePromptNames.includes(t)?n.favoritePromptNames.filter(a=>a!==t):[...n.favoritePromptNames,t]})),setSelectedPrompt:t=>e({selectedPrompt:t})}),nt=e=>({streamsByThreadId:{},completionNotifications:[],startStream:(t,n)=>e(o=>({streamsByThreadId:{...o.streamsByThreadId,[t]:{status:R.STREAMING,content:"",messageId:null,userMessage:n,toolMessages:[]}}})),updateStreamContent:(t,n,o)=>e(a=>{const r=a.streamsByThreadId[t];return!r||r.status!==R.STREAMING?{}:{streamsByThreadId:{...a.streamsByThreadId,[t]:{...r,content:n,messageId:o}}}}),addStreamToolMessage:(t,n)=>e(o=>{const a=o.streamsByThreadId[t];if(!a||a.status!==R.STREAMING)return{};const r=a.toolMessages.findIndex(l=>l.id===n.id),i=r>=0?a.toolMessages.map((l,p)=>p===r?{...l,...n}:l):[...a.toolMessages,n];return{streamsByThreadId:{...o.streamsByThreadId,[t]:{...a,toolMessages:i}}}}),completeStream:(t,n)=>e(o=>{const a=o.streamsByThreadId[t];return a?{streamsByThreadId:{...o.streamsByThreadId,[t]:{...a,status:R.COMPLETED}},completionNotifications:n?[...new Set([...o.completionNotifications,t])]:o.completionNotifications}:{}}),failStream:(t,n)=>e(o=>{const a=o.streamsByThreadId[t];return a?{streamsByThreadId:{...o.streamsByThreadId,[t]:{...a,status:R.ERROR,errorMessage:n}}}:{}}),abortStream:t=>e(n=>{const o=n.streamsByThreadId[t];return o?{streamsByThreadId:{...n.streamsByThreadId,[t]:{...o,status:R.ABORTED}}}:{}}),untrackStream:t=>e(n=>{const o=n.streamsByThreadId[t];if(!o)return{};if(!(o.status===R.COMPLETED||o.status===R.ERROR||o.status===R.ABORTED))return{};const r={...n.streamsByThreadId};return delete r[t],{streamsByThreadId:r}}),setStreamState:(t,n)=>e(o=>({streamsByThreadId:{...o.streamsByThreadId,[t]:{...o.streamsByThreadId[t]??{status:R.IDLE,content:"",messageId:null,userMessage:null,toolMessages:[]},...n}}})),clearStreamState:t=>e(n=>{const o={...n.streamsByThreadId};return delete o[t],{streamsByThreadId:o}}),addCompletionNotification:t=>e(n=>({completionNotifications:[...new Set([...n.completionNotifications,t])]})),clearCompletionNotification:t=>e(n=>({completionNotifications:n.completionNotifications.filter(o=>o!==t)})),clearAllCompletionNotifications:()=>e({completionNotifications:[]})}),ot=e=>({threads:[],activeThreadId:null,threadLoadingState:{type:w.NOT_STARTED},setThreads:t=>e({threads:t}),updateThread:(t,n)=>e(o=>({threads:o.threads.map(a=>a.id===t?{...a,...n}:a)})),removeThread:t=>e(n=>({threads:n.threads.filter(o=>o.id!==t)})),setActiveThreadId:t=>e({activeThreadId:t}),setThreadLoadingState:t=>e({threadLoadingState:t})}),at=e=>({tools:[],toolLoadingState:{type:w.NOT_STARTED},setTools:t=>e({tools:t}),updateToolEnabled:(t,n)=>e(o=>({tools:o.tools.map(a=>a.name===t?{...a,enabled:n}:a)})),updateToolState:(t,n)=>e(o=>({tools:o.tools.map(a=>a.name===t?{...a,state:n}:a)})),setToolLoadingState:t=>e({toolLoadingState:t})}),rt=e=>({isWorkingContextEnabled:!1,workingContext:null,workingContextLoadingState:{type:w.NOT_STARTED},setIsWorkingContextEnabled:t=>e({isWorkingContextEnabled:t}),setWorkingContext:t=>e({workingContext:t}),setWorkingContextLoadingState:t=>e({workingContextLoadingState:t})}),it=()=>Ae.create()(ze.subscribeWithSelector((...e)=>({...Je(...e),...Ye(...e),...ot(...e),...tt(...e),...nt(...e),...st(...e),...at(...e),...rt(...e),...et(...e),...Qe(...e)}))),O=it(),ye=S.createContext(null),be=S.createContext(null),lt=({staticConfig:e,dynamicConfig:t,children:n})=>s.jsx(ye.Provider,{value:e,children:s.jsx(be.Provider,{value:t,children:n})});function E(e){return Ae.useStore(O,e)}function we(){const e=S.useContext(ye);if(!e)throw new Error("useIoAssistConfig must be used inside IoAssistProvider");return e}function oe(){const e=S.useContext(be);if(!e)throw new Error("useIoAssistDynamicConfig must be used inside IoAssistProvider");return e}const ct="io-assist";class dt{_logger;_subLoggers=new Map;setLogger(t){this._logger=t,this._subLoggers.clear()}get isInitialized(){return this._logger!==void 0}get(t){const n=`${ct}.${t}`,o=()=>{if(!this._logger)return console;let a=this._subLoggers.get(n);return a||(a=this._logger.subLogger(n),this._subLoggers.set(n,a)),a};return new Proxy({},{get:(a,r)=>{const i=o(),l=i[r];return typeof l=="function"?l.bind(i):l}})}}const j=new dt,ut="ToggleFavoritePrompt",pt=j.get(ut);async function ft(e,t){const n=e.getState().favoritePromptNames;e.getState().toggleFavoritePrompt(t);const o=e.getState().favoritePromptNames,a=e.getState().ioConnectApi;if(a?.prefs)try{await a.prefs.update({favoritePrompts:o})}catch(r){pt.error("Failed to persist favorite prompts",r instanceof Error?r:new Error(String(r))),e.getState().setFavoritePromptNames(n)}}function gt(){const e=E(t=>t.ioConnectApi);return S.useMemo(()=>({api:e,isReady:e!==null,toggleFavoritePrompt:t=>ft(O,t)}),[e])}const G=({size:e=16,className:t,children:n})=>s.jsx("span",{className:["pointer-events-none inline-flex items-center justify-center",t??""].join(" "),style:{width:`${e}px`,height:`${e}px`},children:n}),Ie=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{fill:"currentColor",d:"M0 1.64C0 0.73 0.73 0 1.64 0L10.36 0C11.27 0 12 0.73 12 1.64L12 10.36C12 11.27 11.27 12 10.36 12L1.64 12C0.73 12 0 11.27 0 10.36L0 1.64ZM10.36 11.18C10.81 11.18 11.18 10.82 11.18 10.36L11.18 1.64C11.18 1.18 10.82 0.82 10.36 0.82L4.5 0.82L4.5 11.18L10.36 11.18ZM0.82 10.36C0.82 10.82 1.18 11.18 1.64 11.18L3.75 11.18L3.75 0.82L1.64 0.82C1.18 0.82 0.82 1.18 0.82 1.64L0.82 10.36ZM1.5 7.5L3 7.5L3 8.25L1.5 8.25L1.5 7.5ZM3 5.25L3 6L1.5 6L1.5 5.25L3 5.25ZM3 3L3 3.75L1.5 3.75L1.5 3L3 3Z"})}),ae=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),mt=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 13 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{fill:"currentColor",d:"M10.64 1.13C10.36 0.82 9.87 0.82 9.59 1.13L8.95 1.73L10.31 3.09L10.92 2.46C11.23 2.18 11.23 1.69 10.92 1.41L10.64 1.13ZM4.43 6.28C4.31 6.38 4.24 6.52 4.22 6.63L3.87 8.18L5.41 7.83C5.53 7.8 5.67 7.73 5.77 7.62L9.77 3.61L8.44 2.27L4.43 6.28ZM9.05 0.59C9.63 0 10.59 0 11.18 0.59L11.46 0.87C12.05 1.45 12.05 2.41 11.46 3L6.3 8.16C6.09 8.37 5.84 8.51 5.58 8.55L3.45 9.05C3.33 9.07 3.19 9.05 3.09 8.95C3 8.86 2.98 8.72 3 8.6L3.49 6.47C3.56 6.21 3.68 5.95 3.89 5.74L9.05 0.59ZM1.88 1.55H4.88C5.06 1.55 5.25 1.73 5.25 1.92C5.25 2.13 5.06 2.3 4.88 2.3H1.88C1.24 2.3 0.75 2.81 0.75 3.42V10.17C0.75 10.8 1.24 11.3 1.88 11.3H8.63C9.23 11.3 9.75 10.8 9.75 10.17V7.17C9.75 6.98 9.91 6.8 10.13 6.8C10.31 6.8 10.5 6.98 10.5 7.17V10.17C10.5 11.23 9.66 12.05 8.63 12.05H1.88C0.82 12.05 0 11.23 0 10.17V3.42C0 2.39 0.82 1.55 1.88 1.55Z"})}),xt=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:"M9 6l6 6-6 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),ht=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:"M6 15l6-6 6 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),re=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:"M6 9l6 6 6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Ct=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 8 8","aria-hidden":!0,children:s.jsx("circle",{cx:"4",cy:"4",r:"3.5",fill:"currentColor"})}),Tt=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 8 8","aria-hidden":!0,children:s.jsx("circle",{cx:"4",cy:"4",r:"3",fill:"none",stroke:"currentColor",strokeWidth:"1"})}),St=()=>s.jsxs("svg",{width:"100%",height:"100%",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Me=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 24 24",fill:"none",children:s.jsx("path",{d:"M20 6L9 17l-5-5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Nt=()=>s.jsxs("svg",{width:"100%",height:"100%",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("path",{d:"M1 4v6h6M23 20v-6h-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M20.49 9A9 9 0 005.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 013.51 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Et=()=>s.jsxs("svg",{width:"100%",height:"100%",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),At=()=>s.jsxs("svg",{width:"100%",height:"100%",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("polyline",{points:"3 6 5 6 21 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 11v6M14 11v6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),vt=e=>s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",...e,children:[s.jsx("circle",{cx:"11",cy:"11",r:"8",stroke:"currentColor",strokeWidth:"2"}),s.jsx("path",{d:"m21 21-4.35-4.35",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Oe=e=>s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",...e,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2"}),s.jsx("path",{d:"M12 16v-4M12 8h.01",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),yt=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M11.293 4.293a1 1 0 011.414 0l7 7a1 1 0 01-1.414 1.414L13 7.414V19a1 1 0 11-2 0V7.414l-5.293 5.293a1 1 0 01-1.414-1.414l7-7z"})}),bt=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",className:"rotate-45",children:s.jsx("path",{d:"M21.43 2.57a1.5 1.5 0 00-1.61-.33L2.93 8.83a1.5 1.5 0 00-.12 2.76l6.34 2.85a.5.5 0 00.57-.1l6.7-6.69a.5.5 0 01.71.71l-6.69 6.7a.5.5 0 00-.1.57l2.85 6.34a1.5 1.5 0 002.76-.12l6.59-16.89a1.5 1.5 0 00-.33-1.61z"})}),wt=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),It=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 12 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{fill:"currentColor",d:"M0 1.5C0 0.69 0.66 0 1.5 0H10.5C11.31 0 12 0.69 12 1.5V15.31C12 15.72 11.69 16 11.28 16C11.16 16 11.03 15.97 10.91 15.91L6 12.63L1.06 15.91C0.94 15.97 0.81 16 0.69 16C0.28 16 0 15.72 0 15.31V1.5ZM1.5 1C1.22 1 1 1.25 1 1.5V14.75L5.72 11.59C5.88 11.5 6.09 11.5 6.25 11.59L11 14.75V1.5C11 1.25 10.75 1 10.5 1H1.5Z"})}),Mt=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 16 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{fill:"currentColor",d:"M1 2H2V1H1V2ZM0 0.75C0 0.34 0.31 0 0.75 0H2.25C2.66 0 3 0.34 3 0.75V2.25C3 2.69 2.66 3 2.25 3H0.75C0.31 3 0 2.69 0 2.25V0.75ZM5 1H15C15.25 1 15.5 1.25 15.5 1.5C15.5 1.78 15.25 2 15 2H5C4.72 2 4.5 1.78 4.5 1.5C4.5 1.25 4.72 1 5 1ZM5 6H15C15.25 6 15.5 6.25 15.5 6.5C15.5 6.78 15.25 7 15 7H5C4.72 7 4.5 6.78 4.5 6.5C4.5 6.25 4.72 6 5 6ZM5 11H15C15.25 11 15.5 11.25 15.5 11.5C15.5 11.78 15.25 12 15 12H5C4.72 12 4.5 11.78 4.5 11.5C4.5 11.25 4.72 11 5 11ZM1 6V7H2V6H1ZM0.75 5H2.25C2.66 5 3 5.34 3 5.75V7.25C3 7.69 2.66 8 2.25 8H0.75C0.31 8 0 7.69 0 7.25V5.75C0 5.34 0.31 5 0.75 5ZM1 12H2V11H1V12ZM0 10.75C0 10.34 0.31 10 0.75 10H2.25C2.66 10 3 10.34 3 10.75V12.25C3 12.69 2.66 13 2.25 13H0.75C0.31 13 0 12.69 0 12.25V10.75Z"})}),Ot=()=>s.jsxs("svg",{width:"100%",height:"100%",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5",stroke:"currentColor"}),s.jsx("path",{d:"M4 6h8M4 9h5",stroke:"currentColor",strokeLinecap:"round"})]}),Lt=()=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 12 12",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M6 0.75l1.6 3.27 3.6.52-2.6 2.55.62 3.59L6 9.4l-3.22 1.7.61-3.59L.79 4.54l3.6-.52L6 .75z"})}),jt=({filled:e})=>s.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 24 24",fill:e?"currentColor":"none",children:s.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),K=({className:e})=>s.jsxs("svg",{className:["animate-spin text-text-default",e??""].join(" "),viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),_t=()=>s.jsxs("svg",{width:"68",height:"14",viewBox:"0 0 68 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M0.220798 3.28877H1.38651V13.2145H0.220798V3.28877ZM0.255084 1.38592C0.106512 1.22592 0.0322266 1.04306 0.0322266 0.837346C0.0322266 0.631632 0.106512 0.454489 0.255084 0.305918C0.415084 0.145918 0.597941 0.065918 0.803655 0.065918C1.00937 0.065918 1.18651 0.145918 1.33508 0.305918C1.49508 0.454489 1.57508 0.631632 1.57508 0.837346C1.57508 1.04306 1.49508 1.22592 1.33508 1.38592C1.18651 1.53449 1.00937 1.60877 0.803655 1.60877C0.597941 1.60877 0.415084 1.53449 0.255084 1.38592Z",fill:"white"}),s.jsx("path",{d:"M8.38897 12.3745C9.5204 12.3745 10.4804 11.9745 11.269 11.1745C12.069 10.3631 12.469 9.38592 12.469 8.24306C12.469 7.11163 12.069 6.14592 11.269 5.34592C10.4804 4.53449 9.5204 4.12877 8.38897 4.12877C7.26897 4.12877 6.30897 4.53449 5.50897 5.34592C4.70897 6.14592 4.30897 7.11163 4.30897 8.24306C4.30897 9.38592 4.70897 10.3631 5.50897 11.1745C6.30897 11.9745 7.26897 12.3745 8.38897 12.3745ZM8.38897 13.5059C6.93754 13.5059 5.69182 12.9916 4.65182 11.9631C3.62325 10.9345 3.10897 9.69449 3.10897 8.24306C3.10897 6.79163 3.62325 5.55735 4.65182 4.5402C5.69182 3.51163 6.93754 2.99735 8.38897 2.99735C9.85182 2.99735 11.0975 3.51163 12.1261 4.5402C13.1547 5.55735 13.669 6.79163 13.669 8.24306C13.669 9.69449 13.1547 10.9345 12.1261 11.9631C11.0975 12.9916 9.85182 13.5059 8.38897 13.5059Z",fill:"white"}),s.jsx("path",{d:"M16.4192 13.4039C16.072 13.4039 15.78 13.2855 15.5433 13.0488C15.3066 12.812 15.1882 12.528 15.1882 12.1965C15.1882 11.8651 15.3066 11.581 15.5433 11.3443C15.78 11.1076 16.072 10.9892 16.4192 10.9892C16.7349 10.9892 17.0111 11.1076 17.2478 11.3443C17.4845 11.581 17.6029 11.8651 17.6029 12.1965C17.6029 12.528 17.4845 12.812 17.2478 13.0488C17.0111 13.2855 16.7349 13.4039 16.4192 13.4039Z",fill:"#F25F1F"}),s.jsx("path",{d:"M22.7104 9.13449H28.1276L25.4361 2.08877H25.4018L22.7104 9.13449ZM30.9733 13.2145H29.7047L28.5733 10.2831H22.2476L21.1161 13.2145H19.8647L24.8361 0.357346H26.0018L30.9733 13.2145Z",fill:"white"}),s.jsx("path",{d:"M39.5573 5.84306H38.3744C38.3744 5.35163 38.1459 4.94592 37.6887 4.62592C37.243 4.29449 36.6487 4.12877 35.9059 4.12877C35.1401 4.12877 34.5401 4.26592 34.1059 4.5402C33.6716 4.80306 33.4544 5.15735 33.4544 5.60306C33.4544 6.11735 33.6144 6.51735 33.9344 6.80306C34.2544 7.07735 34.6544 7.24878 35.1344 7.31735C35.6144 7.38592 36.1287 7.47163 36.6773 7.57449C37.2373 7.66592 37.7573 7.7802 38.2373 7.91735C38.7173 8.05449 39.1173 8.3402 39.4373 8.77449C39.7573 9.19735 39.9173 9.76877 39.9173 10.4888C39.9173 11.4373 39.5573 12.1802 38.8373 12.7173C38.1287 13.2431 37.1516 13.5059 35.9059 13.5059C34.7059 13.5059 33.7402 13.2031 33.0087 12.5973C32.2773 11.9802 31.9116 11.1916 31.9116 10.2316H33.0944C33.0944 10.8602 33.3459 11.3745 33.8487 11.7745C34.3516 12.1745 35.0373 12.3745 35.9059 12.3745C36.7973 12.3745 37.4887 12.2088 37.9801 11.8773C38.4716 11.5345 38.7173 11.0545 38.7173 10.4373C38.7173 10.0031 38.5973 9.6602 38.3573 9.40877C38.1173 9.14592 37.8087 8.96306 37.4316 8.8602C37.0544 8.75735 36.6373 8.67735 36.1801 8.6202C35.723 8.56306 35.2602 8.49449 34.7916 8.41449C34.3344 8.32306 33.9173 8.19163 33.5401 8.0202C33.163 7.83735 32.8544 7.55163 32.6144 7.16306C32.3744 6.76306 32.2544 6.25449 32.2544 5.63735C32.2544 4.7802 32.5973 4.12877 33.283 3.68306C33.9802 3.22592 34.8544 2.99735 35.9059 2.99735C36.9916 2.99735 37.8716 3.26592 38.5459 3.80306C39.2201 4.32877 39.5573 5.00877 39.5573 5.84306Z",fill:"white"}),s.jsx("path",{d:"M48.9323 5.84306H47.7494C47.7494 5.35163 47.5209 4.94592 47.0637 4.62592C46.618 4.29449 46.0237 4.12877 45.2809 4.12877C44.5151 4.12877 43.9151 4.26592 43.4809 4.5402C43.0466 4.80306 42.8294 5.15735 42.8294 5.60306C42.8294 6.11735 42.9894 6.51735 43.3094 6.80306C43.6294 7.07735 44.0294 7.24878 44.5094 7.31735C44.9894 7.38592 45.5037 7.47163 46.0523 7.57449C46.6123 7.66592 47.1323 7.7802 47.6123 7.91735C48.0923 8.05449 48.4923 8.3402 48.8123 8.77449C49.1323 9.19735 49.2923 9.76877 49.2923 10.4888C49.2923 11.4373 48.9323 12.1802 48.2123 12.7173C47.5037 13.2431 46.5266 13.5059 45.2809 13.5059C44.0809 13.5059 43.1151 13.2031 42.3837 12.5973C41.6523 11.9802 41.2866 11.1916 41.2866 10.2316H42.4694C42.4694 10.8602 42.7209 11.3745 43.2237 11.7745C43.7266 12.1745 44.4123 12.3745 45.2809 12.3745C46.1723 12.3745 46.8637 12.2088 47.3551 11.8773C47.8466 11.5345 48.0923 11.0545 48.0923 10.4373C48.0923 10.0031 47.9723 9.6602 47.7323 9.40877C47.4923 9.14592 47.1837 8.96306 46.8066 8.8602C46.4294 8.75735 46.0123 8.67735 45.5551 8.6202C45.098 8.56306 44.6352 8.49449 44.1666 8.41449C43.7094 8.32306 43.2923 8.19163 42.9151 8.0202C42.538 7.83735 42.2294 7.55163 41.9894 7.16306C41.7494 6.76306 41.6294 6.25449 41.6294 5.63735C41.6294 4.7802 41.9723 4.12877 42.658 3.68306C43.3551 3.22592 44.2294 2.99735 45.2809 2.99735C46.3666 2.99735 47.2466 3.26592 47.9209 3.80306C48.5951 4.32877 48.9323 5.00877 48.9323 5.84306Z",fill:"white"}),s.jsx("path",{d:"M51.0044 3.28877H52.1701V13.2145H51.0044V3.28877ZM51.0387 1.38592C50.8901 1.22592 50.8159 1.04306 50.8159 0.837346C50.8159 0.631632 50.8901 0.454489 51.0387 0.305918C51.1987 0.145918 51.3816 0.065918 51.5873 0.065918C51.793 0.065918 51.9701 0.145918 52.1187 0.305918C52.2787 0.454489 52.3587 0.631632 52.3587 0.837346C52.3587 1.04306 52.2787 1.22592 52.1187 1.38592C51.9701 1.53449 51.793 1.60877 51.5873 1.60877C51.3816 1.60877 51.1987 1.53449 51.0387 1.38592Z",fill:"white"}),s.jsx("path",{d:"M61.5383 5.84306H60.3555C60.3555 5.35163 60.1269 4.94592 59.6697 4.62592C59.224 4.29449 58.6297 4.12877 57.8869 4.12877C57.1212 4.12877 56.5212 4.26592 56.0869 4.5402C55.6526 4.80306 55.4355 5.15735 55.4355 5.60306C55.4355 6.11735 55.5955 6.51735 55.9155 6.80306C56.2355 7.07735 56.6355 7.24878 57.1155 7.31735C57.5955 7.38592 58.1097 7.47163 58.6583 7.57449C59.2183 7.66592 59.7383 7.7802 60.2183 7.91735C60.6983 8.05449 61.0983 8.3402 61.4183 8.77449C61.7383 9.19735 61.8983 9.76877 61.8983 10.4888C61.8983 11.4373 61.5383 12.1802 60.8183 12.7173C60.1097 13.2431 59.1326 13.5059 57.8869 13.5059C56.6869 13.5059 55.7212 13.2031 54.9897 12.5973C54.2583 11.9802 53.8926 11.1916 53.8926 10.2316H55.0755C55.0755 10.8602 55.3269 11.3745 55.8297 11.7745C56.3326 12.1745 57.0183 12.3745 57.8869 12.3745C58.7783 12.3745 59.4697 12.2088 59.9612 11.8773C60.4526 11.5345 60.6983 11.0545 60.6983 10.4373C60.6983 10.0031 60.5783 9.6602 60.3383 9.40877C60.0983 9.14592 59.7897 8.96306 59.4126 8.8602C59.0355 8.75735 58.6183 8.67735 58.1612 8.6202C57.704 8.56306 57.2412 8.49449 56.7726 8.41449C56.3155 8.32306 55.8983 8.19163 55.5212 8.0202C55.144 7.83735 54.8355 7.55163 54.5955 7.16306C54.3555 6.76306 54.2355 6.25449 54.2355 5.63735C54.2355 4.7802 54.5783 4.12877 55.264 3.68306C55.9612 3.22592 56.8355 2.99735 57.8869 2.99735C58.9726 2.99735 59.8526 3.26592 60.5269 3.80306C61.2012 4.32877 61.5383 5.00877 61.5383 5.84306Z",fill:"white"}),s.jsx("path",{d:"M65.2562 4.45449V10.8831C65.2562 11.2716 65.3647 11.5631 65.5819 11.7573C65.799 11.9516 66.079 12.0488 66.4219 12.0488H67.3133V13.2145H66.4219C65.759 13.2145 65.2047 13.0031 64.759 12.5802C64.3133 12.1573 64.0905 11.5916 64.0905 10.8831V4.45449H62.9247V3.28877H64.0905V1.04306H65.2562V3.28877H67.3133V4.45449H65.2562Z",fill:"white"})]}),Rt=()=>s.jsxs("svg",{width:"68",height:"14",viewBox:"0 0 121 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M0.336735 5.7551H2.41837V23.4796H0.336735V5.7551ZM0.397959 2.35714C0.132653 2.07143 0 1.7449 0 1.37755C0 1.0102 0.132653 0.693878 0.397959 0.428571C0.683674 0.142857 1.0102 0 1.37755 0C1.7449 0 2.06122 0.142857 2.32653 0.428571C2.61225 0.693878 2.7551 1.0102 2.7551 1.37755C2.7551 1.7449 2.61225 2.07143 2.32653 2.35714C2.06122 2.62245 1.7449 2.7551 1.37755 2.7551C1.0102 2.7551 0.683674 2.62245 0.397959 2.35714Z",fill:"#26272A"}),s.jsx("path",{d:"M14.9228 21.9796C16.9432 21.9796 18.6574 21.2653 20.0656 19.8367C21.4942 18.3878 22.2085 16.6429 22.2085 14.602C22.2085 12.5816 21.4942 10.8571 20.0656 9.42857C18.6574 7.97959 16.9432 7.2551 14.9228 7.2551C12.9228 7.2551 11.2085 7.97959 9.77989 9.42857C8.35132 10.8571 7.63704 12.5816 7.63704 14.602C7.63704 16.6429 8.35132 18.3878 9.77989 19.8367C11.2085 21.2653 12.9228 21.9796 14.9228 21.9796ZM14.9228 24C12.3309 24 10.1064 23.0816 8.24928 21.2449C6.41255 19.4082 5.49418 17.1939 5.49418 14.602C5.49418 12.0102 6.41255 9.80612 8.24928 7.98979C10.1064 6.15306 12.3309 5.23469 14.9228 5.23469C17.535 5.23469 19.7595 6.15306 21.5962 7.98979C23.433 9.80612 24.3513 12.0102 24.3513 14.602C24.3513 17.1939 23.433 19.4082 21.5962 21.2449C19.7595 23.0816 17.535 24 14.9228 24Z",fill:"#26272A"}),s.jsx("path",{d:"M29.2625 23.8178C28.6425 23.8178 28.1211 23.6064 27.6984 23.1837C27.2756 22.7609 27.0643 22.2536 27.0643 21.6618C27.0643 21.07 27.2756 20.5627 27.6984 20.1399C28.1211 19.7172 28.6425 19.5058 29.2625 19.5058C29.8262 19.5058 30.3194 19.7172 30.7421 20.1399C31.1648 20.5627 31.3762 21.07 31.3762 21.6618C31.3762 22.2536 31.1648 22.7609 30.7421 23.1837C30.3194 23.6064 29.8262 23.8178 29.2625 23.8178Z",fill:"#F25F1F"}),s.jsx("path",{d:"M40.4968 16.1939H50.1702L45.3641 3.61224H45.3029L40.4968 16.1939ZM55.2519 23.4796H52.9866L50.9662 18.2449H39.6702L37.6498 23.4796H35.4151L44.2927 0.520407H46.3743L55.2519 23.4796Z",fill:"#26272A"}),s.jsx("path",{d:"M70.5805 10.3163H68.4682C68.4682 9.43878 68.0601 8.71428 67.2437 8.14286C66.4478 7.55102 65.3866 7.2551 64.0601 7.2551C62.6927 7.2551 61.6213 7.5 60.8458 7.98979C60.0703 8.45918 59.6825 9.09184 59.6825 9.88775C59.6825 10.8061 59.9682 11.5204 60.5397 12.0306C61.1111 12.5204 61.8254 12.8265 62.6825 12.949C63.5397 13.0714 64.458 13.2245 65.4376 13.4082C66.4376 13.5714 67.3662 13.7755 68.2233 14.0204C69.0805 14.2653 69.7948 14.7755 70.3662 15.551C70.9376 16.3061 71.2233 17.3265 71.2233 18.6122C71.2233 20.3061 70.5805 21.6327 69.2948 22.5918C68.0295 23.5306 66.2846 24 64.0601 24C61.9172 24 60.1927 23.4592 58.8866 22.3776C57.5805 21.2755 56.9274 19.8673 56.9274 18.1531H59.0397C59.0397 19.2755 59.4886 20.1939 60.3866 20.9082C61.2846 21.6224 62.509 21.9796 64.0601 21.9796C65.6519 21.9796 66.8866 21.6837 67.7642 21.0918C68.6417 20.4796 69.0805 19.6224 69.0805 18.5204C69.0805 17.7449 68.8662 17.1327 68.4376 16.6837C68.009 16.2143 67.458 15.8878 66.7846 15.7041C66.1111 15.5204 65.3662 15.3776 64.5499 15.2755C63.7335 15.1735 62.907 15.051 62.0703 14.9082C61.254 14.7449 60.5091 14.5102 59.8356 14.2041C59.1621 13.8776 58.6111 13.3673 58.1825 12.6735C57.754 11.9592 57.5397 11.051 57.5397 9.94898C57.5397 8.41837 58.1519 7.2551 59.3764 6.45918C60.6213 5.64286 62.1825 5.23469 64.0601 5.23469C65.9988 5.23469 67.5703 5.71429 68.7744 6.67347C69.9784 7.61224 70.5805 8.82653 70.5805 10.3163Z",fill:"#26272A"}),s.jsx("path",{d:"M87.3216 10.3163H85.2093C85.2093 9.43878 84.8011 8.71428 83.9848 8.14286C83.1889 7.55102 82.1277 7.2551 80.8011 7.2551C79.4338 7.2551 78.3624 7.5 77.5869 7.98979C76.8113 8.45918 76.4236 9.09184 76.4236 9.88775C76.4236 10.8061 76.7093 11.5204 77.2807 12.0306C77.8522 12.5204 78.5664 12.8265 79.4236 12.949C80.2807 13.0714 81.1991 13.2245 82.1787 13.4082C83.1787 13.5714 84.1073 13.7755 84.9644 14.0204C85.8216 14.2653 86.5358 14.7755 87.1073 15.551C87.6787 16.3061 87.9644 17.3265 87.9644 18.6122C87.9644 20.3061 87.3216 21.6327 86.0358 22.5918C84.7705 23.5306 83.0256 24 80.8011 24C78.6583 24 76.9338 23.4592 75.6277 22.3776C74.3215 21.2755 73.6685 19.8673 73.6685 18.1531H75.7807C75.7807 19.2755 76.2297 20.1939 77.1277 20.9082C78.0256 21.6224 79.2501 21.9796 80.8011 21.9796C82.393 21.9796 83.6277 21.6837 84.5052 21.0918C85.3828 20.4796 85.8215 19.6224 85.8215 18.5204C85.8215 17.7449 85.6073 17.1327 85.1787 16.6837C84.7501 16.2143 84.1991 15.8878 83.5256 15.7041C82.8522 15.5204 82.1073 15.3776 81.2909 15.2755C80.4746 15.1735 79.6481 15.051 78.8113 14.9082C77.995 14.7449 77.2501 14.5102 76.5767 14.2041C75.9032 13.8776 75.3522 13.3673 74.9236 12.6735C74.495 11.9592 74.2807 11.051 74.2807 9.94898C74.2807 8.41837 74.893 7.2551 76.1175 6.45918C77.3624 5.64286 78.9236 5.23469 80.8011 5.23469C82.7399 5.23469 84.3113 5.71429 85.5154 6.67347C86.7195 7.61224 87.3216 8.82653 87.3216 10.3163Z",fill:"#26272A"}),s.jsx("path",{d:"M91.0218 5.7551H93.1034V23.4796H91.0218V5.7551ZM91.083 2.35714C90.8177 2.07143 90.6851 1.7449 90.6851 1.37755C90.6851 1.0102 90.8177 0.693878 91.083 0.428571C91.3687 0.142857 91.6953 0 92.0626 0C92.43 0 92.7463 0.142857 93.0116 0.428571C93.2973 0.693878 93.4402 1.0102 93.4402 1.37755C93.4402 1.7449 93.2973 2.07143 93.0116 2.35714C92.7463 2.62245 92.43 2.7551 92.0626 2.7551C91.6953 2.7551 91.3687 2.62245 91.083 2.35714Z",fill:"#26272A"}),s.jsx("path",{d:"M109.832 10.3163H107.72C107.72 9.43878 107.312 8.71428 106.496 8.14286C105.7 7.55102 104.638 7.2551 103.312 7.2551C101.945 7.2551 100.873 7.5 100.098 7.98979C99.3221 8.45918 98.9343 9.09184 98.9343 9.88775C98.9343 10.8061 99.2201 11.5204 99.7915 12.0306C100.363 12.5204 101.077 12.8265 101.934 12.949C102.791 13.0714 103.71 13.2245 104.689 13.4082C105.689 13.5714 106.618 13.7755 107.475 14.0204C108.332 14.2653 109.047 14.7755 109.618 15.551C110.189 16.3061 110.475 17.3265 110.475 18.6122C110.475 20.3061 109.832 21.6327 108.547 22.5918C107.281 23.5306 105.536 24 103.312 24C101.169 24 99.4446 23.4592 98.1384 22.3776C96.8323 21.2755 96.1792 19.8673 96.1792 18.1531H98.2915C98.2915 19.2755 98.7405 20.1939 99.6384 20.9082C100.536 21.6224 101.761 21.9796 103.312 21.9796C104.904 21.9796 106.138 21.6837 107.016 21.0918C107.894 20.4796 108.332 19.6224 108.332 18.5204C108.332 17.7449 108.118 17.1327 107.689 16.6837C107.261 16.2143 106.71 15.8878 106.036 15.7041C105.363 15.5204 104.618 15.3776 103.802 15.2755C102.985 15.1735 102.159 15.051 101.322 14.9082C100.506 14.7449 99.7609 14.5102 99.0874 14.2041C98.4139 13.8776 97.8629 13.3673 97.4343 12.6735C97.0058 11.9592 96.7915 11.051 96.7915 9.94898C96.7915 8.41837 97.4037 7.2551 98.6282 6.45918C99.8731 5.64286 101.434 5.23469 103.312 5.23469C105.251 5.23469 106.822 5.71429 108.026 6.67347C109.23 7.61224 109.832 8.82653 109.832 10.3163Z",fill:"#26272A"}),s.jsx("path",{d:"M116.471 7.83673V19.3163C116.471 20.0102 116.665 20.5306 117.053 20.8776C117.441 21.2245 117.941 21.398 118.553 21.398H120.145V23.4796H118.553C117.369 23.4796 116.38 23.102 115.584 22.3469C114.788 21.5918 114.39 20.5816 114.39 19.3163V7.83673H112.308V5.7551H114.39V1.7449H116.471V5.7551H120.145V7.83673H116.471Z",fill:"#26272A"})]}),Le=({prompt:e,isDisplayedInFavoriteList:t})=>{const[n,o]=S.useState(!1),a=E(f=>f.favoritePromptNames),r=E(f=>f.setSelectedPrompt),i=E(f=>f.setActivePanelContent),{toggleFavoritePrompt:l}=gt(),p=a.includes(e.name),x=()=>{r({id:e.id,name:e.name,description:e.description}),t||i(null)},u=f=>{f.stopPropagation(),l(e.name)},g=["flex w-full",t?"md:w-auto md:max-w-[352px] md:min-w-[250px] border border-border-default hover:border-border-hover rounded-2xl bg-app-background-secondary":""].filter(Boolean).join(" "),d=["flex flex-1 justify-between items-center p-2 gap-2 cursor-pointer min-w-0",t?"h-[48px] rounded-2xl":["rounded-md",n?"bg-app-background-secondary":""].filter(Boolean).join(" ")].join(" ");return s.jsx("div",{"data-testid":"prompt-list-item","data-prompt-name":e.name,className:g,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:s.jsxs("div",{role:"button",tabIndex:0,className:d,onClick:x,onKeyUp:f=>{(f.key==="Enter"||f.key===" ")&&x()},title:e.description||void 0,children:[s.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-full text-text-default",children:s.jsx(G,{size:16,children:s.jsx(Ot,{})})}),s.jsx("span",{className:["flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-xs",n?"text-text-states-hover":"text-text-default"].join(" "),children:e.name}),s.jsx("button",{type:"button","data-testid":"prompt-favorite-toggle","aria-pressed":p,"aria-label":p?"Remove from favorites":"Add to favorites",title:p?"Remove from favorites":"Add to favorites",className:["p-2 ps-1 shrink-0 inline-flex items-center justify-center cursor-pointer bg-transparent border-0",p?"text-yellow-400":n?"text-text-default hover:text-yellow-400":"text-text-states-disabled"].join(" "),onClick:u,children:s.jsx(G,{size:12,children:p?s.jsx(Lt,{}):s.jsx(jt,{filled:!1})})})]})})},je=({value:e,onChange:t,placeholder:n})=>{const[o,a]=S.useState(!1),r=e.length>0;return s.jsx("div",{className:"sticky top-0 z-10 bg-panel-background pb-1",children:s.jsx("div",{className:["flex flex-col items-start justify-center w-full p-2 mb-1 rounded-input-radius border","bg-input-background border-input-border",!o&&"hover:bg-input-background-hover hover:border-input-border-hover",o&&"bg-input-background-active border-input-border-active"].filter(Boolean).join(" "),children:s.jsxs("div",{className:"flex gap-2 items-center w-full",children:[s.jsx("span",{className:["inline-flex items-center justify-center",o?"text-input-icon-active":"text-input-icon"].join(" "),children:s.jsx(G,{size:12,children:s.jsx(vt,{})})}),s.jsx("input",{type:"text","aria-label":n,className:["flex-1 min-w-0 bg-transparent border-0 outline-none text-xs",o?"text-input-text-active":"text-input-text"].join(" "),placeholder:n,value:e,onChange:i=>t(i.target.value),onFocus:()=>a(!0),onBlur:()=>a(!1)}),r&&s.jsx("button",{type:"button",className:["inline-flex items-center justify-center cursor-pointer",o?"text-input-icon-active":"text-input-icon"].join(" "),onClick:()=>t(""),"aria-label":"Clear search",children:s.jsx(G,{size:12,children:s.jsx(ae,{})})})]})})})},kt="https://docs-ai.interop.io/",Q="Default Prompts",Pt=e=>[...e].sort((t,n)=>t.name.localeCompare(n.name)),Dt=({className:e})=>{const t=E(x=>x.allPrompts),[n,o]=S.useState(""),a=t.length>0,r=S.useMemo(()=>{const x=n.trim().toLowerCase();return x?t.filter(u=>u.name.toLowerCase().includes(x)):t},[t,n]),i=S.useMemo(()=>{const x=new Map;for(const g of r){const d=g.category||Q,f=x.get(d)||[];x.set(d,[...f,g])}return Array.from(x.entries()).map(([g,d])=>({category:g,prompts:Pt(d)})).sort((g,d)=>g.category===Q?1:d.category===Q?-1:g.category.localeCompare(d.category))},[r]),l=r.length===0,p=()=>{window.open(kt,"_blank","noopener,noreferrer")};return s.jsxs("div",{"data-testid":"prompt-list",className:["flex flex-col w-full",e??""].filter(Boolean).join(" "),children:[a&&s.jsx(je,{value:n,onChange:o,placeholder:y.PROMPT_LIST_COMPONENT.INPUT_TOOLTIP}),s.jsxs("div",{className:"flex flex-col w-full gap-[10px] py-2 min-h-0",children:[!a&&s.jsx("div",{className:"flex justify-center items-center h-16",children:s.jsxs("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[s.jsx("span",{className:"text-text-default",children:y.PROMPT_LIST_COMPONENT.NO_PROMPTS_CONFIGURED}),s.jsx("button",{type:"button",className:"text-xs text-blue-500 hover:text-blue-600 underline cursor-pointer",onClick:p,children:y.PROMPT_LIST_COMPONENT.NO_PROMPTS_SEE_MORE})]})}),a&&l&&s.jsx("div",{className:"flex justify-center items-center h-16",children:s.jsx("span",{className:"text-text-default",children:y.PROMPT_LIST_COMPONENT.NO_PROMPTS})}),!l&&s.jsx("div",{className:"w-full min-h-0 flex flex-col gap-3 overflow-y-auto overflow-x-hidden custom-scrollbar",children:i.map(x=>s.jsxs(S.Fragment,{children:[s.jsx("div",{className:"flex items-center px-2 py-1 mb-1",children:s.jsx("span",{"data-testid":"prompt-category",className:"text-[10px] font-normal text-text-default leading-[13px] tracking-[0.1px]",children:x.category})}),x.prompts.map(u=>s.jsx(Le,{prompt:u,isDisplayedInFavoriteList:!1},u.name))]},x.category))})]})]})},Ht={default:"hover:text-text-states-hover",danger:"hover:text-app-danger"},B=({size:e=16,containerSize:t,className:n,testId:o,style:a,type:r="button",variant:i="default",children:l,...p})=>s.jsx("button",{type:r,"data-testid":o,className:["flex items-center justify-center cursor-pointer transition-colors rounded-full text-text-default disabled:opacity-50 disabled:cursor-not-allowed",Ht[i],n??""].join(" "),style:{...t?{width:`${t}px`,height:`${t}px`}:null,...a},...p,children:s.jsx(G,{size:e,children:l})}),_e=({open:e,onClose:t,title:n,showCloseIcon:o=!1,footer:a,testId:r="modal",children:i})=>(S.useEffect(()=>{if(!e||!t)return;const l=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e,t]),!e||typeof document>"u"?null:Ze.createPortal(s.jsx("div",{"data-testid":r,role:"presentation",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/[0.32]",onClick:l=>{l.target===l.currentTarget&&t?.()},onKeyDown:l=>l.key==="Escape"&&t?.(),children:s.jsxs("dialog",{"aria-modal":"true","aria-label":n,open:!0,className:"static flex flex-col box-border overflow-hidden bg-panel-background rounded-2xl border border-panel-border shadow-panel-box-shadow w-auto min-w-[320px] md:min-w-[540px] max-w-[960px] max-h-[90vh] p-0 m-0",children:[s.jsxs("div",{className:"flex justify-end items-center gap-2 px-6 pt-6 text-text-black-white text-xl font-weight-600 shrink-0",children:[n&&s.jsx("span",{className:"flex flex-1 items-center text-text-black-white leading-[24px] truncate",children:n}),o&&t&&s.jsx(B,{size:20,containerSize:28,onClick:t,title:"Close",className:"rounded-lg text-text-black-white hover:bg-app-icon-background-hover",children:s.jsx(ae,{})})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden custom-scrollbar mt-3",children:i}),a&&s.jsx("div",{className:"flex justify-end gap-2 shrink-0 w-full px-6 pb-6 pt-3",children:a})]})}),document.body)),Gt=({isChecked:e,onToggle:t,isDisabled:n=!1})=>{const o=r=>{r.stopPropagation(),n||t()},a=r=>{n||(r.key===" "||r.key==="Enter")&&(r.preventDefault(),t())};return s.jsxs("div",{role:"switch","aria-checked":e,"aria-disabled":n,tabIndex:n?-1:0,onClick:o,onKeyDown:a,className:["relative inline-flex items-center w-[34px] h-[16px] rounded-full transition-colors duration-300 ease-in-out",n?"cursor-not-allowed opacity-50":"cursor-pointer",!e&&!n?"hover:bg-toggle-background-hover-disabled":"",e&&!n?"hover:bg-toggle-background-hover-enabled":"",e?"bg-toggle-background-enabled":"bg-toggle-background-disabled"].filter(Boolean).join(" "),children:[s.jsx("div",{className:["flex flex-1 transition-all duration-300",e?"justify-start":"justify-end"].join(" "),children:s.jsx("span",{className:"m-[4px] inline-flex items-center justify-center text-text-states-active",children:s.jsx(G,{size:10,children:e?s.jsx(Me,{}):s.jsx(ae,{})})})}),s.jsx("div",{className:["absolute w-[12px] h-[12px] bg-toggle-circle rounded-full transition-all duration-300 ease-in-out",e?"left-[20px]":"left-[2px]"].join(" ")})]})},U=8,Bt=({content:e,position:t="top",offset:n=14,children:o})=>{const a=S.useRef(null),r=S.useRef(null),[i,l]=S.useState(!1),[p,x]=S.useState(!1),[u,g]=S.useState({x:0,y:0}),d=S.useCallback(()=>{const m=a.current,h=r.current;if(!m||!h)return;const N=m.getBoundingClientRect(),c=h.getBoundingClientRect();let v=0,C=0;t==="top"?(v=N.left+N.width/2-c.width/2,C=N.top-c.height-n,v=Math.max(U,Math.min(v,window.innerWidth-c.width-U))):t==="bottom"?(v=N.left+N.width/2-c.width/2,C=N.bottom+n,v=Math.max(U,Math.min(v,window.innerWidth-c.width-U))):t==="left"?(v=N.left-c.width-n,C=N.top+N.height/2-c.height/2,C=Math.max(U,Math.min(C,window.innerHeight-c.height-U))):t==="right"&&(v=N.right+n,C=N.top+N.height/2-c.height/2,C=Math.max(U,Math.min(C,window.innerHeight-c.height-U))),g({x:v,y:C})},[t,n]);S.useLayoutEffect(()=>{i&&(d(),x(!0))},[i,d]),S.useEffect(()=>{if(!i)return;const m=()=>d();return window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}},[i,d]);const f=()=>{x(!1),l(!0)},T=()=>{l(!1),x(!1)};return s.jsxs("span",{ref:a,className:"inline-block",onMouseEnter:f,onMouseLeave:T,onFocus:f,onBlur:T,children:[o,i&&s.jsx("div",{ref:r,className:["fixed z-[999999] pointer-events-none transition-opacity duration-150",p?"opacity-100":"opacity-0"].join(" "),style:{left:`${u.x}px`,top:`${u.y}px`},children:e})]})},Ut=({tool:e,onToggle:t})=>{const[n,o]=S.useState(!1);return s.jsxs("div",{"data-testid":"tool-list-item","data-tool-name":e.name,className:["flex justify-between items-center px-2 py-1 gap-2 cursor-pointer rounded-md w-full",n?"bg-app-background-secondary":""].filter(Boolean).join(" "),onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[s.jsx(Gt,{isChecked:e.enabled,onToggle:()=>t(e)}),s.jsx("span",{className:["flex flex-1 text-xs",n?"text-text-states-hover":"text-text-default"].join(" "),children:e.name}),s.jsx(Bt,{content:s.jsx("div",{className:"flex justify-center bg-app-background-secondary text-text-default border border-border-default p-4 rounded-md leading-[17px] text-xs min-w-[240px] max-w-[320px]",children:s.jsxs("div",{children:[s.jsxs("span",{className:"text-text-states-active font-weight-600",children:["Server name:"," "]}),e.mcpServerName]})}),children:s.jsx("span",{className:["inline-flex items-center justify-center rounded-sm hover:bg-app-icon-background-hover",n?"text-text-states-active":"text-text-default"].join(" "),"aria-label":"Tool info",children:s.jsx(G,{size:12,children:s.jsx(Oe,{})})})})]})},Ft="AbortActiveStream",Wt=j.get(Ft);function $t(e){const t=e.getState(),n=t.selectedAgent,o=t.activeThreadId;if(!n||!o)return;try{n.rawAgent.abortOperation(o)}catch(r){Wt.warn(`Failed to abort operation for thread ${o}: ${r?.message??r}`)}const a=e.getState();a.abortStream(o),a.untrackStream(o),a.setIsGeneratingResponse(!1)}const Vt="NewConversation",zt=j.get(Vt);async function Re(e){const t=e.getState();t.clearMessages(),t.setActiveThreadId(null),t.resetMcpApps();const n=t.ioAiWebApi;if(n?.mcpApps)try{await n.mcpApps.closeAll()}catch(o){zt.error("Failed to close MCP apps on new conversation",o instanceof Error?o:new Error(String(o)))}}const Zt="DeleteThread",Xt=j.get(Zt);async function qt(e,t){const n=e.getState(),o=n.threads.find(i=>i.id===t);if(!o)return;const a=n.activeThreadId===t;try{await o.delete()}catch{Xt.error(`Failed to delete thread on server: ${t}`);return}const r=e.getState();r.removeThread(t),r.untrackStream(t),a&&await Re(e)}async function Kt(e,t,n){const o=n.trim();if(!o)return;const a=e.getState(),r=a.threads.find(l=>l.id===t);if(!r)return;const i=r.title;a.updateThread(t,{title:o});try{await r.update({title:o})}catch{e.getState().updateThread(t,{title:i})}}function P(e){try{return JSON.stringify(e)}catch{return String(e)}}const Yt="MessageConverter",Jt=j.get(Yt);function Qt(e){const t=[],n=new Map;for(const o of e){const a=o;if(a.role==="user"){const r=ne(a.content);t.push({id:a.id,role:b.USER,content:r})}if(a.role==="assistant"){const i=(a.content&&typeof a.content=="object"&&!Array.isArray(a.content)?a.content:null)?.parts??[];if(i.length===0){const l=ne(a.content);l.trim()&&t.push({id:a.id,role:b.ASSISTANT,content:l});continue}for(let l=0;l<i.length;l++){const p=i[l];if(p.type==="text"&&p.text?.trim()&&t.push({id:`${a.id}_text_${l}`,role:b.ASSISTANT,content:p.text}),p.type==="tool-invocation"){const x=p.toolInvocation,u=x?.toolCallId??p.id;if(!u)continue;if(n.has(u)){const g=n.get(u);x?.result!==void 0&&(g.result=x.result)}else{const g={id:u,role:b.TOOL,toolName:x?.toolName??"unknown",args:x?.args??{},result:x?.result};n.set(u,g),t.push(g)}}}}}return Jt.debug(`Converted messages: ${P(t)}`),t}function ne(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>t?.text??"").join("");if(typeof e=="object"){const t=e;if(Array.isArray(t.parts))return t.parts.filter(n=>n.type==="text").map(n=>n.text??"").join("");if(typeof t.text=="string")return t.text}return JSON.stringify(e)}const es="ThreadUtils",ts=j.get(es),L=y.THREAD_HISTORY_COMPONENT.DIVIDERS,_={minute:60*1e3,hour:3600*1e3,day:1440*60*1e3,week:10080*60*1e3,month:720*60*60*1e3};function ss(e){return e<_.minute?L.JUST_NOW:e<5*_.minute?L.FIVE_MINS_AGO:e<30*_.minute?L.THIRTY_MINS_AGO:e<_.hour?L.ONE_HOUR_AGO:e<2*_.hour?L.TWO_HOURS_AGO:e<6*_.hour?L.SIX_HOURS_AGO:e<12*_.hour?L.TWELVE_HOURS_AGO:e<_.day?L.TODAY:e<2*_.day?L.YESTERDAY:e<3*_.day?L.TWO_DAYS_AGO:e<_.week?L.LAST_WEEK:e<2*_.week?L.TWO_WEEKS_AGO:e<_.month?L.ONE_MONTH_AGO:e<3*_.month?L.THREE_MONTHS_AGO:e<6*_.month?L.SIX_MONTHS_AGO:L.MORE_THAN_YEAR_AGO}function ns(e){const t=Date.now(),n=new Map,o=[],a=[...e].sort((r,i)=>(i.updatedAt??i.createdAt).getTime()-(r.updatedAt??r.createdAt).getTime());for(const r of a){const i=r.updatedAt??r.createdAt,l=t-i.getTime(),p=ss(l);n.has(p)||(n.set(p,[]),o.push(p)),n.get(p).push(r)}return o.map(r=>({label:r,threads:n.get(r)}))}function os(e){const t=[];let n=null,o=null;for(const a of e)(a.role===b.USER||a.role===b.ASSISTANT)&&(o&&(t.push(o),o=null),n=a.id),a.role===b.TOOL&&n&&(o||(o={stateForMessageId:n,executedTools:[],uiMessage:"",isExpanded:!1}),o.executedTools.push(a));o&&t.push(o);for(const a of t){const r=a.executedTools.length;a.uiMessage=r>0?`Used ${r} tool${r!==1?"s":""}`:""}return ts.debug(`Built tool traces: ${P(t)}`),t}const as="SelectThread",rs=j.get(as);async function is(e,t){const n=e.getState(),o=n.threads.find(a=>a.id===t);if(n.clearCompletionNotification(t),n.activeThreadId&&n.activeThreadId!==t&&n.untrackStream(n.activeThreadId),n.setActiveThreadId(t),n.clearMessages(),n.resetMcpApps(),n.setIsThreadHistoryVisible(!1),!!o){n.setMessageLoadingState({type:k.LOADING_FROM_THREAD});try{const a=await o.getMessages({limit:100}),r=Array.isArray(a)?a:a?.messages??[],i=Qt(r),l=os(i);e.getState().setMessages(i),e.getState().setToolTraceState(l);const p=e.getState().ioAiWebApi?.mcpApps;if(p){const u=i.filter(d=>d.role===b.TOOL).map(d=>({toolCallId:d.id,toolName:d.toolName,toolInput:d.args,toolResult:d.result})),g=u.length>0?p.recreate({threadId:t,apps:u}):p.closeAll();Promise.resolve(g).catch(d=>rs.error("Failed to restore MCP apps on thread reopen",d))}e.getState().streamsByThreadId[t]?.status===R.STREAMING&&e.getState().mergeAccumulatedStreamContent(t),e.getState().setMessageLoadingState({type:k.FETCH_MESSAGES_FROM_THREAD_SUCCESS})}catch(a){e.getState().setMessageLoadingState({type:k.ERROR,message:a instanceof Error?a.message:"Failed to load messages"})}}}function ke(e){return e>0?`Used ${e} tool${e!==1?"s":""}`:""}function ue(e,t){return e.map(n=>n.stateForMessageId===t?{...n,uiMessage:ke(n.executedTools.length)}:n)}function ls(e){return e.map(t=>({...t,uiMessage:ke(t.executedTools.length)}))}function pe(e,t,n){return e.map(o=>({...o,executedTools:o.executedTools.map(a=>a.id===t?{...a,...n}:a)}))}function cs(e,t,n){const o=e.find(a=>a.stateForMessageId===t||a.executedTools.some(r=>r.id===n.id));return o?e.map(a=>a.stateForMessageId===o.stateForMessageId?{...a,executedTools:[...a.executedTools,n]}:a):[...e,{stateForMessageId:t,executedTools:[n],uiMessage:"Executing tools...",isExpanded:!1}]}function fe(e,t,n){if(t&&e.messages.some(r=>r.id===t))return t;const a=t||n||crypto.randomUUID();return e.addMessage({id:a,role:b.ASSISTANT,content:""}),a}const ds="ResponseStream",us=j.get(ds);async function ps(e,t,n,o){if(!e||typeof e.subscribe!="function")throw new Error("Invalid response stream object");const a=new Map;let r="",i="",l=!1;return new Promise((p,x)=>{let u;const g=()=>u?.unsubscribe?.();u=e.subscribe({next:d=>{const f=d,T=n.getState(),m=!o();switch(us.debug(`AG-UI event ${f?.type??"unknown"}: ${P(f)}`),f.type){case"TEXT_MESSAGE_START":{const h=f.messageId;l&&(!h||h===i)?(r="",l=!1):(i=h||crypto.randomUUID(),r="",l=!1,m||T.addMessage({id:i,role:b.ASSISTANT,content:""}));break}case"TEXT_MESSAGE_CONTENT":{if(r+=f.delta||"",m){T.setStreamState(t,{content:r,messageId:i});return}const h=fe(T,i,f.messageId);h!==i&&(i=h),T.updateMessage(i,{content:r});break}case"TEXT_MESSAGE_END":l=!1;break;case"TEXT_MESSAGE_CHUNK":{const h=f.messageId;h&&h!==i&&(i=h,r="",l=!1,m||T.addMessage({id:i,role:b.ASSISTANT,content:""}));const N=f.delta??(typeof f.content=="string"?f.content:"");if(r+=N||"",m)T.setStreamState(t,{content:r,messageId:i});else{const c=fe(T,i,h);c!==i&&(i=c),T.updateMessage(i,{content:r})}break}case"MESSAGES_SNAPSHOT":{if(m)break;const h=Array.isArray(f.messages)?f.messages:[];for(const N of h){const c=N;if(c?.role!=="assistant")continue;const v=typeof c.content=="string"?c.content:c.content?.text??"";if(!v)continue;const C=c.id??crypto.randomUUID(),A=T.messages.find(M=>M.id===C);A?(!A.content||A.content.length<v.length)&&T.updateMessage(C,{content:v}):T.addMessage({id:C,role:b.ASSISTANT,content:v})}break}case"TOOL_CALL_START":{r="",i||(i=crypto.randomUUID(),l=!0,m||T.addMessage({id:i,role:b.ASSISTANT,content:""}));const h={id:f.toolCallId||crypto.randomUUID(),toolName:f.toolCallName||"unknown",args:{},role:b.TOOL};if(a.set(h.id,{args:"",toolName:h.toolName}),m){const N=T.streamsByThreadId[t];T.setStreamState(t,{toolMessages:[...N?.toolMessages??[],h]});return}T.addMessage(h),T.setToolTraceState(cs(T.toolTraceState,i,h));break}case"TOOL_CALL_ARGS":{const h=f.toolCallId||"";if(!h)return;const N=a.get(h)||{args:""};a.set(h,{...N,args:N.args+(f.delta||"")});break}case"TOOL_CALL_END":{const h=f.toolCallId||"";if(!h)return;const N=a.get(h);let c={};try{c=JSON.parse(N?.args||"{}")}catch{c={}}if(m){const v=T.streamsByThreadId[t];T.setStreamState(t,{toolMessages:(v?.toolMessages??[]).map(C=>C.id===h?{...C,args:c}:C)})}else{T.updateMessage(h,{args:c});let v=pe(T.toolTraceState,h,{args:c});v=ue(v,i),T.setToolTraceState(v)}break}case"TOOL_CALL_RESULT":{const h=f.toolCallId||"";if(!h)return;let N=f.content;if(typeof N=="string")try{N=JSON.parse(N)}catch{N={type:ve.TEXT,text:N}}if(m){const c=T.streamsByThreadId[t];T.setStreamState(t,{toolMessages:(c?.toolMessages??[]).map(v=>v.id===h?{...v,result:N}:v)})}else{T.updateMessage(h,{result:N});let c=pe(T.toolTraceState,h,{result:N});c=ue(c,i),T.setToolTraceState(c)}break}}},error:d=>{const f=n.getState();f.failStream(t,d.message||"Error during response generation"),f.setIsGeneratingResponse(!1),f.setIsLastResponseSuccess(!1),f.setMessageLoadingState({type:k.ERROR,message:d.message||"Error during response generation"}),g(),x(d)},complete:()=>{const d=n.getState();o()&&d.setToolTraceState(ls(d.toolTraceState));const f=!o();d.completeStream(t,f),d.setIsGeneratingResponse(!1),d.setIsLastResponseSuccess(!0),d.setMessageLoadingState({type:k.GET_RESPONSE_SUCCESS}),g(),p()}})})}const fs="SendUserMessage",ee=j.get(fs);async function Pe(e,t,n){ee.debug(`sendUserMessage called with text: ${t}`);const o=e.getState(),a=o.selectedAgent,r=o.ioAiWebApi;if(!a||!r)throw new Error("Agent or IoAiWeb API not ready");let i=o.activeThreadId;i||(i=crypto.randomUUID(),o.setActiveThreadId(i));const l=n.user.id,p={id:crypto.randomUUID(),role:b.USER,content:t};o.addMessage(p),o.requestScrollAnchor(),o.setIsGeneratingResponse(!0),o.setIsLastResponseSuccess(!1),o.setMessageLoadingState({type:k.LOADING_RESPONSE});const x={messages:[{id:p.id,role:p.role,content:p.content??""}],memory:{thread:i,resource:l},resourceId:l,tools:{autoIncludeEnabled:!0}};try{ee.debug(`Initiating agent stream with params: ${P(x)}`);const u=await a.rawAgent.stream(x);e.getState().startStream(i,p),await ps(u,i,e,()=>e.getState().activeThreadId===i),await gs(r,a.rawAgent.id,l,e)}catch(u){o.setIsGeneratingResponse(!1),o.setIsLastResponseSuccess(!1),o.setMessageLoadingState({type:k.ERROR,message:u instanceof Error?u.message:"Error during response generation"}),ee.error("Send message failed",u instanceof Error?u:new Error(String(u)))}}async function gs(e,t,n,o){try{const r=(await e.threads.list({agentId:t,resourceId:n})).map(i=>({id:i.id,title:i.title||i.id.substring(0,8),createdAt:i.createdAt?new Date(i.createdAt):new Date,updatedAt:i.updatedAt?new Date(i.updatedAt):void 0,rawThread:i,update:l=>i.update(l),delete:()=>i.delete(),getMessages:l=>i.getMessages(l)}));o.getState().setThreads(r)}catch{}}const ms="ToggleTool",xs=j.get(ms);async function hs(e,t,n){const o=e.getState(),a=o.ioAiWebApi;if(a?.tools){o.updateToolState(t,Z.ENABLING_DISABLING);try{const r=await a.tools.toggleTool(t,n);e.getState().updateToolEnabled(t,r?.enabled??n)}catch(r){xs.error("toggleTool error",r instanceof Error?r:new Error(String(r)))}finally{e.getState().updateToolState(t,Z.IDLE)}}}function Y(){const e=E(n=>n.ioAiWebApi),t=oe();return S.useMemo(()=>({api:e,isReady:e!==null,sendMessage:n=>Pe(O,n,t),abortMessage:()=>$t(O),newConversation:()=>Re(O),selectThread:n=>is(O,n),renameThread:(n,o)=>Kt(O,n,o),deleteThread:n=>qt(O,n),toggleTool:(n,o)=>hs(O,n,o)}),[e,t])}const Cs="https://docs-ai.interop.io/",Ts=()=>{const e=E(g=>g.tools),t=E(g=>g.toolLoadingState),{toggleTool:n}=Y(),[o,a]=S.useState(""),r=t.type===w.LOADING,i=e.length>0,l=S.useMemo(()=>{if(!o)return e;const g=o.toLowerCase();return e.filter(d=>d.name.toLowerCase().includes(g))},[e,o]),p=!r&&l.length>0,x=g=>{g.state===Z.IDLE&&n(g.name,!g.enabled)},u=()=>{window.open(Cs,"_blank","noopener,noreferrer")};return s.jsxs("div",{"data-testid":"tool-list",className:"flex flex-col",children:[!r&&i&&s.jsx(je,{value:o,onChange:a,placeholder:y.TOOL_LIST_COMPONENT.INPUT_TOOLTIP}),s.jsxs("div",{className:"flex flex-col items-center pt-2",children:[r&&s.jsx("span",{className:"text-text-default",children:y.TOOL_LIST_COMPONENT.LOADING_TOOLS}),p&&l.map(g=>s.jsx(Ut,{tool:g,onToggle:x},g.name)),i&&!p&&!r&&s.jsx("span",{className:"text-text-default",children:y.TOOL_LIST_COMPONENT.NO_FILTERED_TOOLS}),!i&&!r&&s.jsxs("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[s.jsx("span",{className:"text-text-default",children:y.TOOL_LIST_COMPONENT.NO_TOOLS}),s.jsx("button",{type:"button",className:"text-xs text-blue-500 hover:text-blue-600 underline cursor-pointer",onClick:u,children:y.TOOL_LIST_COMPONENT.NO_TOOLS_SEE_MORE})]})]})]})},Ss={plain:{color:"#ffffff",backgroundColor:"hsl(0, 0%, 8%)"},styles:[{types:["comment","prolog","doctype","cdata"],style:{color:"hsl(0, 0%, 47%)"}},{types:["punctuation","namespace"],style:{opacity:.7}},{types:["tag","boolean","number","deleted"],style:{color:"hsl(14, 58%, 55%)"}},{types:["keyword","property","selector","constant","symbol","builtin"],style:{color:"hsl(53, 89%, 79%)"}},{types:["attr-name","attr-value","string","char","operator","entity","url","variable","inserted"],style:{color:"hsl(76, 21%, 52%)"}},{types:["atrule"],style:{color:"hsl(218, 22%, 55%)"}},{types:["regex","important"],style:{color:"hsl(42, 75%, 65%)"}},{types:["important","bold"],style:{fontWeight:"bold"}},{types:["italic"],style:{fontStyle:"italic"}}]},Ns=({className:e,children:t})=>{const n=String(t).replace(/\n$/,""),o=e?.replace(/^language-/,"")??"";return s.jsx("div",{className:"io-assist-code-theme my-2",children:s.jsx(Xe.Highlight,{code:n,language:o,theme:Ss,children:({className:a,style:r,tokens:i,getLineProps:l,getTokenProps:p})=>s.jsx("pre",{className:`p-3 m-0 rounded-2xl overflow-x-auto ${a} `,style:r,children:s.jsx("code",{className:"block whitespace-pre-wrap break-words max-w-full box-border text-sm leading-normal",children:i.map((x,u)=>s.jsx("div",{...l({line:x}),children:x.map((g,d)=>s.jsx("span",{...p({token:g})},d))},u))})})})})},Es={code({className:e,children:t,...n}){return!e&&typeof t=="string"&&!t.includes(`
2
+ `)?s.jsx("code",{className:"bg-app-background-secondary px-1.5 py-0.5 rounded text-sm font-mono text-text-states-active",...n,children:t}):s.jsx(Ns,{className:e,children:t})},pre({children:e}){return s.jsx(s.Fragment,{children:e})},a({href:e,title:t,children:n}){return s.jsx("a",{href:e,title:t??"",className:"text-app-accent-color-1",target:"_blank",rel:"noopener noreferrer",children:n})},table({children:e}){return s.jsxs("div",{className:"relative z-1 my-2 p-0",children:[s.jsx("div",{className:"absolute z-0 top-[-2px] left-[-2px] size-[calc(100%+4px)] bg-[linear-gradient(90deg,var(--app-accent-color-1),var(--app-accent-color-2))]"}),s.jsx("table",{className:"relative z-1 w-full border-collapse",children:e})]})},thead({children:e}){return s.jsx("thead",{className:"relative z-1 text-left font-semibold text-text-states-active bg-app-background-secondary",children:e})},th({children:e}){return s.jsx("th",{className:"px-4 py-3",children:e})},td({children:e}){return s.jsx("td",{className:"px-4 py-3 text-text-default",children:e})},tr({children:e,...t}){return s.jsx("tr",{className:"even:bg-app-background-secondary odd:bg-app-background",...t,children:e})},ul({children:e}){return s.jsx("ul",{className:"list-disc pl-5 my-2 text-sm font-normal leading-[19px] text-text-default",children:e})},ol({children:e}){return s.jsx("ol",{className:"list-decimal pl-5 my-2 text-sm font-normal leading-[19px] text-text-default",children:e})},li({children:e}){return s.jsx("li",{className:"py-1",children:e})},blockquote({children:e}){return s.jsx("blockquote",{className:"p-4 my-4 rounded-2xl text-text-default flex flex-col gap-1 relative border border-app-accent-color-1",children:e})},hr(){return s.jsx("div",{className:"relative z-1 my-2 py-2",children:s.jsx("div",{className:"absolute p-0 z-0 top-0 left-0 w-full h-px bg-[linear-gradient(90deg,var(--app-accent-color-1),var(--app-accent-color-2))]"})})},p({children:e}){return s.jsx("p",{className:"text-base font-normal leading-[19px] my-2 first:mt-0 last:mb-0",children:e})},strong({children:e}){return s.jsx("strong",{className:"font-semibold",children:e})},h1({children:e}){return s.jsx("h1",{className:"font-default text-[revert] font-[revert] my-[revert]",children:e})},h2({children:e}){return s.jsx("h2",{className:"font-default text-[revert] font-[revert] my-[revert]",children:e})},h3({children:e}){return s.jsx("h3",{className:"font-default text-[revert] font-[revert] my-[revert]",children:e})},h4({children:e}){return s.jsx("h4",{className:"font-default text-[revert] font-[revert] my-[revert]",children:e})},h5({children:e}){return s.jsx("h5",{className:"font-default text-[revert] font-[revert] my-[revert]",children:e})},h6({children:e}){return s.jsx("h6",{className:"font-default text-[revert] font-[revert] my-[revert]",children:e})}},X=({content:e})=>s.jsx("div",{className:"io-assist-md w-full max-w-full box-border flex flex-col px-0.5",children:s.jsx(qe,{remarkPlugins:[Ke],components:Es,children:e})}),q=e=>"```json\n"+JSON.stringify(e,null,2)+"\n```",As=()=>{const e=E(t=>t.workingContext);return s.jsxs("div",{"data-testid":"working-context-panel",className:"working-context-panel flex flex-1 flex-col p-4 gap-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4 p-4 bg-app-background-secondary border border-border-default rounded",children:[s.jsx(G,{size:20,className:"text-app-accent-color-1 shrink-0",children:s.jsx(Oe,{})}),s.jsx("p",{className:"text-sm text-proto-text-default",children:y.WORKING_CONTEXT_PANEL.DESCRIPTION})]}),s.jsx(X,{content:q(e??{})})]})},vs=()=>{const e=E(a=>a.activePanelContent),t=E(a=>a.setActivePanelContent);if(!e)return null;const n=e===F.WORKING_CONTEXT?y.WORKING_CONTEXT_PANEL.TITLE:e===F.PROMPTS?y.PROMPT_LIST_COMPONENT.AVAILABLE_PROMPTS:y.TOOL_LIST_COMPONENT.AVAILABLE_TOOLS,o=()=>t(null);return s.jsx(_e,{open:!0,onClose:o,title:n,showCloseIcon:!0,testId:"active-panel-modal",children:s.jsxs("div",{className:"px-3 pb-6",children:[e===F.WORKING_CONTEXT&&s.jsx(As,{}),e===F.PROMPTS&&s.jsx(Dt,{}),e===F.TOOLS&&s.jsx(Ts,{})]})})},ys=({showMessageArea:e})=>s.jsx("div",{className:["flex justify-center items-end text-center p-4",e?"pt-4":"flex-1 pt-0"].join(" "),children:s.jsx("span",{className:"text-xs text-text-default tracking-wide",children:y.GENERAL.AI_CONTENT_INFO})}),J=Symbol("confirmModal.preempted");let W=null;function ie(e){return W&&(W(J),W=null),O.getState().showConfirmModal(e),new Promise(t=>{W=t})}function ge(e){const t=W;W=null,O.getState().closeConfirmModal(),t&&t(e)}const bs=()=>{const e=E(a=>a.currentConfirmModal);if(!e)return null;const t=()=>ge(null),n=e.isHeaderCloseButtonDisplayed??!1,o=e.buttons.length>0?e.buttons.map(a=>{const r=a.variant==="primary";return s.jsx("button",{"data-testid":`confirm-modal-${a.id}`,type:"button",onClick:()=>ge(a.id),className:r?"flex justify-center items-center rounded-sm cursor-pointer gap-1 px-spacing-6 py-spacing-3 bg-button-submit-background text-white hover:opacity-95 transition-opacity":"flex justify-center items-center rounded-sm cursor-pointer gap-1 px-spacing-6 py-spacing-3 border border-border-default text-text-default hover:text-text-states-active hover:border-border-hover transition-colors",children:a.label},a.id)}):null;return s.jsx(_e,{open:!0,onClose:t,title:e.title,showCloseIcon:n,footer:o,testId:"confirm-modal",children:s.jsxs("div",{className:"flex flex-col gap-2 px-6 pb-2",children:[e.heading&&s.jsx("span",{className:"text-text-black-white text-lg",children:e.heading}),e.text&&s.jsx("span",{className:"text-text-default text-sm whitespace-pre-wrap break-words",children:e.text})]})})},ws=({agentName:e})=>s.jsx("div",{className:"flex flex-col gap-3 items-center px-4 pt-[160px]",children:s.jsx("h2",{className:"text-[28px] md:text-[44px] font-bold text-text-states-active text-center",children:y.GENERAL.WELCOME_MESSAGE(e)})}),me="(min-width: 768px)";function Is(){const[e,t]=S.useState(()=>typeof window>"u"?!1:!window.matchMedia(me).matches);return S.useEffect(()=>{const n=window.matchMedia(me),o=a=>t(!a.matches);return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[]),e}function De(e={}){const{staticGradient:t}=e,n=S.useRef(null),o=S.useRef(null),a=S.useRef(null),r=S.useRef(null),i=S.useRef(null);S.useEffect(()=>{const u=n.current;if(!u)return;const g=getComputedStyle(u).position,d=u.style.position;g==="static"&&(u.style.position="relative"),u.style.transition="border-color 0.2s",u.style.isolation="isolate";const f=document.createElement("div");f.className="animation-effect__background",f.style.cssText=`
3
+ position: absolute; inset: 0; border-radius: inherit;
4
+ background: inherit; z-index: -1; pointer-events: none;
5
+ `;const T=document.createElement("div");T.className="animation-effect__gradient-layer",T.style.cssText=`
6
+ overflow: hidden; border-radius: inherit; position: absolute; inset: -1px;
7
+ pointer-events: none; opacity: 0; transition: opacity 400ms linear; z-index: -2;
8
+ -webkit-mask: linear-gradient(#fff 0, #fff 0) content-box, linear-gradient(#fff 0, #fff 0);
9
+ -webkit-mask-composite: xor;
10
+ mask: linear-gradient(#fff 0, #fff 0) content-box, linear-gradient(#fff 0, #fff 0);
11
+ mask-composite: exclude;
12
+ padding: 1px;
13
+ `;const m=document.createElement("div");m.className="animation-effect__blur-layer",m.style.cssText=`
14
+ overflow: hidden; border-radius: inherit; position: absolute; inset: -1px;
15
+ pointer-events: none; opacity: 0; transition: opacity 400ms linear; z-index: -2;
16
+ -webkit-mask: linear-gradient(#fff 0, #fff 0) content-box, linear-gradient(#fff 0, #fff 0);
17
+ -webkit-mask-composite: xor;
18
+ mask: linear-gradient(#fff 0, #fff 0) content-box, linear-gradient(#fff 0, #fff 0);
19
+ mask-composite: exclude;
20
+ padding: 1px; filter: blur(3px);
21
+ `;const h=document.createElement("div");h.style.cssText=`
22
+ background: conic-gradient(from 0deg, var(--app-accent-color-1) 0deg, var(--app-accent-color-2) 180deg, var(--app-accent-color-1) 360deg);
23
+ width: 1500%; height: 1500%; top: -700%; left: -700%; position: absolute;
24
+ `;const N=document.createElement("div");N.style.cssText=`
25
+ background: conic-gradient(from 0deg, var(--app-accent-color-1) 0deg, var(--app-accent-color-2) 180deg, var(--app-accent-color-1) 360deg);
26
+ width: 1500%; height: 1500%; top: -700%; left: -700%; position: absolute;
27
+ `,T.appendChild(h),m.appendChild(N),u.insertBefore(f,u.firstChild),u.insertBefore(T,u.firstChild),u.insertBefore(m,u.firstChild);let c=null;return t&&(c=document.createElement("div"),c.className="animation-effect__static-layer",c.style.cssText=`
28
+ border-radius: inherit; position: absolute; inset: -1px;
29
+ pointer-events: none; z-index: -2;
30
+ -webkit-mask: linear-gradient(#fff 0, #fff 0) content-box, linear-gradient(#fff 0, #fff 0);
31
+ -webkit-mask-composite: xor;
32
+ mask: linear-gradient(#fff 0, #fff 0) content-box, linear-gradient(#fff 0, #fff 0);
33
+ mask-composite: exclude;
34
+ padding: 1px;
35
+ background: ${t};
36
+ `,u.insertBefore(c,u.firstChild)),o.current=m,a.current=T,r.current=N,i.current=h,()=>{f.remove(),T.remove(),m.remove(),c?.remove(),u.style.isolation="",u.style.transition="",u.style.position=d}},[t]);const l=S.useCallback(()=>{const u=n.current;!u||!o.current||!a.current||(u.style.border="0.8px solid transparent",o.current.style.opacity="1",a.current.style.opacity="1")},[]),p=S.useCallback(()=>{const u=n.current;!u||!o.current||!a.current||(u.style.border="",o.current.style.opacity="0",a.current.style.opacity="0")},[]),x=S.useCallback(u=>{const g=n.current;if(!g||!r.current||!i.current)return;const d=g.getBoundingClientRect(),f=u.clientX-d.left,T=u.clientY-d.top,m=d.width/2,h=d.height/2,N=f-m,c=T-h;let v=Math.atan2(c,N)*(180/Math.PI);v=(v+360)%360,r.current.style.transform=`rotate(${v}deg)`,i.current.style.transform=`rotate(${v}deg)`},[]);return{ref:n,handlers:{onMouseEnter:l,onMouseLeave:p,onMouseMove:x}}}const Ms=()=>{const e=E(c=>c.isThreadHistoryVisible),t=E(c=>c.messages.length),n=E(c=>c.messageLoadingState),o=E(c=>c.completionNotifications),a=E(c=>c.isWorkingContextEnabled),r=E(c=>c.setIsThreadHistoryVisible),i=E(c=>c.setActivePanelContent),{newConversation:l}=Y(),p=t>0,x=n.type===k.LOADING_RESPONSE||n.type===k.LOADING_FROM_THREAD,u=o.length>0,g=!e,d=x||p,f=()=>{r(!0)},T=()=>{l()},m=()=>{i(F.WORKING_CONTEXT)},{ref:h,handlers:N}=De();return s.jsxs("div",{"data-testid":"header",className:"flex w-full items-center justify-start px-4 py-2 gap-4",children:[g||d?s.jsxs("div",{className:"flex",children:[g&&s.jsxs("div",{className:"relative",children:[s.jsx(B,{size:12,containerSize:24,onClick:f,title:"Thread history",children:s.jsx(Ie,{})}),u&&s.jsx("span",{className:"absolute -top-1 -right-1 size-2.5 rounded-full bg-orange-500"})]}),d&&s.jsx(B,{size:12,containerSize:24,testId:"header-new-conversation",onClick:T,title:"New conversation",children:s.jsx(mt,{})})]}):null,a&&s.jsx("button",{type:"button",ref:h,className:"flex justify-center items-center px-2 py-[5px] border-[1px] border-button-border-default bg-transparent rounded-[4px] text-text-default cursor-pointer hover:text-text-states-hover font-weight-400 text-xs leading-[100%]",onClick:m,...N,children:y.WORKING_CONTEXT_PANEL_COMPONENT.VIEW_WORKING_CONTEXT_BUTTON})]})},te=17,xe=260,Os=({onSend:e,onAbort:t,className:n})=>{const[o,a]=S.useState(""),r=S.useRef(null),{ref:i,handlers:l}=De({staticGradient:"linear-gradient(135deg, var(--app-accent-color-1), var(--app-accent-color-1), var(--app-accent-color-2, var(--app-accent-color-1)))"}),p=S.useRef(null),x=E(A=>{const M=A.activeThreadId;return!!M&&A.streamsByThreadId[M]?.status===R.STREAMING}),u=E(A=>A.messages),g=E(A=>A.selectedPrompt),d=E(A=>A.setSelectedPrompt),f=u.filter(A=>A.role===b.USER),T=S.useCallback(A=>{a(A),requestAnimationFrame(()=>{const M=r.current;M&&(M.style.height=`${te}px`,A.trim()!==""&&(M.style.height=`${Math.min(M.scrollHeight,xe)}px`))})},[]),m=A=>{T(A.target.value),p.current=null};S.useEffect(()=>{g?.description&&(T(g.description),d(null))},[g,T,d]);const h=S.useCallback(()=>{const A=o.trim();!A||x||(e(A),T(""),p.current=null)},[o,x,e,T]),N=S.useCallback(()=>{x?t():h()},[x,t,h]),c=A=>{if(A.key==="Enter"&&!A.shiftKey){A.preventDefault(),h();return}if(A.key==="ArrowUp"&&A.shiftKey){A.preventDefault(),v("up");return}if(A.key==="ArrowDown"&&A.shiftKey){A.preventDefault(),v("down");return}},v=A=>{if(f.length===0)return;const M=p.current;let z;if(M===null)z=A==="up"?f.length-1:0;else if(A==="up"&&M>0)z=M-1;else if(A==="down"&&M<f.length-1)z=M+1;else return;p.current=z,T(f[z].content??"")},C=x?"stop":o.trim().length>0?"send":"disabled";return s.jsx("div",{"data-testid":"input-area",className:["input-area w-full",n??""].filter(Boolean).join(" "),children:s.jsx("div",{className:"relative w-full",children:s.jsx("div",{ref:i,...l,className:"relative rounded-2xl border-[1px] border-button-border-default bg-transparent",children:s.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[s.jsx("div",{className:"flex gap-3 items-start px-2",children:s.jsx("textarea",{ref:r,"data-testid":"input-textarea","aria-label":y.INPUT_COMPONENT.INPUT_PLACEHOLDER,placeholder:y.INPUT_COMPONENT.INPUT_PLACEHOLDER,rows:1,className:"flex-1 custom-scrollbar custom-scrollbar-no-gutter text-text-default text-sm leading-4 resize-none border-none outline-none overflow-y-auto whitespace-pre-wrap placeholder:text-text-states-disabled hover:text-text-states-active bg-transparent",style:{height:`${te}px`,minHeight:`${te}px`,maxHeight:`${xe}px`},value:o,onChange:m,onKeyDown:c})}),s.jsxs("div",{className:"flex gap-3 items-center justify-between",children:[s.jsx(Ls,{}),s.jsx("button",{type:"button","data-testid":C==="stop"?"abort-button":"send-button",className:["flex size-8 shrink-0 items-center justify-center rounded-full transition-colors",C==="send"&&"bg-app-accent-color-1 text-white hover:opacity-90 cursor-pointer",C==="stop"&&"bg-app-accent-color-1 text-white hover:opacity-90 cursor-pointer",C==="disabled"&&"bg-app-icon-background-disabled text-text-states-disabled cursor-not-allowed"].filter(Boolean).join(" "),onClick:N,disabled:C==="disabled",title:C==="stop"?"Stop generation":"Send message",children:s.jsx(G,{size:C==="stop"?14:C==="send"?18:16,children:C==="stop"?s.jsx(wt,{}):C==="send"?s.jsx(yt,{}):s.jsx(bt,{})})})]})]})})})})},Ls=()=>{const e=E(t=>t.setActivePanelContent);return s.jsxs("div",{className:"flex flex-1 gap-0.5",children:[s.jsx(B,{size:16,containerSize:24,className:"hover:bg-app-icon-background-hover",onClick:()=>e(F.PROMPTS),title:"Browse prompts","aria-label":"Browse prompts",children:s.jsx(It,{})}),s.jsx(B,{size:16,containerSize:24,className:"hover:bg-app-icon-background-hover",onClick:()=>e(F.TOOLS),title:"Manage tools","aria-label":"Manage tools",children:s.jsx(Mt,{})})]})},js=({message:e,isLast:t=!1,onReload:n,isGenerating:o=!1})=>{const[a,r]=S.useState(!1),i=t&&!o&&!!e.content?.trim(),l=S.useCallback(()=>{const p=e.content??"";navigator.clipboard.writeText(p).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})},[e.content]);return s.jsxs("div",{"data-testid":"assistant-message",className:"flex flex-col flex-1 self-stretch text-text-states-active font-weight-weight-400 leading-[19px] safe-word-break",children:[e.content&&s.jsx("div",{"data-testid":"assistant-message-text",children:s.jsx(X,{content:e.content})}),i&&s.jsxs("div",{"data-testid":"message-footer",className:"flex flex-1 gap-[2px] text-text-secondary",children:[s.jsx(B,{size:12,containerSize:24,testId:"message-copy-button",onClick:l,title:a?"Copied":"Copy response",className:"hover:bg-app-icon-background-hover",children:a?s.jsx(Me,{}):s.jsx(St,{})}),n&&s.jsx(B,{size:12,containerSize:24,testId:"message-reload-button",onClick:n,title:"Reload response",className:"hover:bg-app-icon-background-hover",children:s.jsx(Nt,{})})]})]})},_s=({appInstance:e})=>{const t=S.useRef(null),n=S.useRef(null);return S.useEffect(()=>{const o=t.current;if(o&&e?.element&&n.current!==e.id){for(;o.firstChild;)o.removeChild(o.firstChild);o.appendChild(e.element),n.current=e.id}},[e]),s.jsx("div",{"data-testid":"mcp-app-resource",className:"rounded-xl border border-border-default bg-app-background-secondary overflow-hidden",children:s.jsx("div",{ref:t,"data-testid":"mcp-app-iframe",className:"w-full min-h-48"})})},he=e=>{if(e.type!==ve.TEXT)return e;try{return{type:e.type,text:JSON.parse(e.text)}}catch{return{type:e.type,text:e.text}}},Rs=e=>e==null?"No result available.":Array.isArray(e)?e.map(t=>q(he(t))).join(`
37
+
38
+ ---
39
+
40
+ `):q(he(e)),ks=({tool:e,parentToolTraceId:t,onToggle:n})=>{const o=e.result!==void 0&&e.result!==null,a=!!e.isExpanded,r=S.useMemo(()=>q(e.args??{}),[e.args]),i=S.useMemo(()=>Rs(e.result),[e.result]);return s.jsxs("div",{"data-testid":"tool-message",className:"flex flex-col justify-start py-2 px-[3px] text-[13px] font-medium leading-[100%] text-text-states-active",children:[s.jsxs("div",{className:"flex items-center gap-2 px-1",children:[s.jsx("span",{title:o?y.TOOL_MESSAGE.TOOL_EXECUTION_SUCCESS:y.TOOL_MESSAGE.TOOL_EXECUTION_PENDING,className:["w-2 h-2 shrink-0 inline-flex items-center justify-center",o?"text-app-accent-color-1":"text-text-states-active"].join(" "),children:o?s.jsx(Ct,{}):s.jsx(Tt,{})}),s.jsxs("button",{type:"button","data-testid":"tool-message-header",className:"flex flex-1 items-center cursor-pointer text-left",onClick:()=>n(e.id,t),children:[s.jsx("div",{className:"flex flex-1 ps-2 items-center",children:e.toolName}),s.jsx("span",{className:"size-3 shrink-0 inline-flex items-center justify-center",children:a?s.jsx(ht,{}):s.jsx(re,{})})]})]}),a&&s.jsx("div",{className:"flex flex-col gap-4 pt-2 px-2 w-full",children:s.jsx("div",{className:"px-3 border-l border-text-default",children:s.jsxs("div",{className:"px-2 flex flex-col",children:[s.jsx("span",{children:"Input"}),s.jsx(X,{content:r}),s.jsx("span",{children:"Output"}),s.jsx(X,{content:i})]})})})]})},Ce="linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",Ps=({trace:e,onToggle:t,onToggleTool:n})=>{const o=e.uiMessage||"No UI Message",a=e.executedTools,r=!!e.isExpanded,i=a.length>0,l=()=>{i&&t(e.stateForMessageId)};return s.jsxs("div",{"data-testid":"tool-trace-message",id:`tool-trace-message-${e.stateForMessageId}`,className:"relative flex flex-col flex-1 gap-2 text-text-default rounded-[8px] isolate",children:[r&&s.jsxs(s.Fragment,{children:[s.jsx("div",{"aria-hidden":!0,className:"absolute inset-0 z-[-2] rounded-[8px] pointer-events-none bg-app-background"}),s.jsx("div",{"aria-hidden":!0,className:"absolute inset-0 z-[-1] p-px rounded-[8px] pointer-events-none bg-[linear-gradient(90deg,var(--app-accent-color-1),var(--app-accent-color-2))]",style:{mask:Ce,WebkitMask:Ce,maskComposite:"exclude",WebkitMaskComposite:"xor"}})]}),s.jsxs("div",{className:"relative flex flex-col gap-2 px-4 py-6",children:[s.jsxs("button",{type:"button","data-testid":"tool-trace-header",tabIndex:0,className:["flex items-center gap-2 text-left transition-colors hover:text-text-states-active",i?"cursor-pointer":"cursor-default",r?"flex-row-reverse justify-end":""].filter(Boolean).join(" "),onClick:l,children:[s.jsx("span",{className:"text-[13px] leading-[19px]",children:o}),i&&s.jsx("span",{className:["w-3 h-3 shrink-0 inline-flex items-center justify-center",r?"text-app-accent-color-1":"text-text-default"].join(" "),title:r?y.TOOL_TRACE_MESSAGE.COLLAPSE_BUTTON_TEXT:y.TOOL_TRACE_MESSAGE.EXPAND_BUTTON_TEXT,children:r?s.jsx(re,{}):s.jsx(xt,{})})]}),r&&i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{"data-testid":"tool-trace-body",className:"flex flex-col",children:a.map(p=>s.jsx(ks,{tool:p,parentToolTraceId:e.stateForMessageId,onToggle:n},p.id))}),s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{type:"button","data-testid":"tool-trace-close-button",className:"px-3 py-1.5 rounded-[6px] text-sm text-text-default border border-border-default transition-colors hover:bg-app-icon-background-hover",onClick:l,children:y.TOOL_TRACE_MESSAGE.CLOSE_BUTTON_TEXT})})]})]})]})},Ds=({message:e,isLast:t=!1,isGenerating:n=!1})=>{const o=t&&n;return s.jsx("div",{"data-testid":"user-message",className:"flex flex-col justify-end",children:s.jsxs("div",{className:"flex items-end justify-end",children:[s.jsx("div",{className:"flex items-end px-2",children:o&&s.jsx(K,{className:"size-5"})}),s.jsx("div",{className:"flex min-w-0",children:s.jsx("div",{className:"p-4 list-none text-[14px] leading-[18px] font-weight-weight-400 text-user-message-text bg-user-message-background rounded-2xl max-w-[620px] min-w-0 whitespace-pre-wrap break-words",children:e.content??""})})]})})};function Hs(e,t,n=[]){const o=[],a=new Set(t.flatMap(d=>d.executedTools.map(f=>f.id))),r=new Map,i=new Map;e.forEach((d,f)=>{r.set(d.id,d.role),i.set(d.id,f)});const l=new Map,p=new Map,x=new Map;for(const d of t){if(r.get(d.stateForMessageId)===b.ASSISTANT){l.set(d.stateForMessageId,d),x.set(d,d.stateForMessageId);continue}const T=i.get(d.stateForMessageId)??-1;for(let m=T+1;m<e.length;m++)if(e[m].role===b.ASSISTANT){p.set(e[m].id,d),x.set(d,e[m].id);break}}const u=new Map;for(const d of t)for(const f of d.executedTools)u.set(f.id,d);const g=new Map;for(const d of n){const f=u.get(d.id);if(!f)continue;const T=x.get(f);if(!T)continue;const m=g.get(T)??[];m.push(d),g.set(T,m)}for(const d of e)if(!(d.role===b.TOOL&&a.has(d.id))){if(d.role===b.USER){o.push({type:"user",message:d});continue}if(d.role===b.ASSISTANT){const f=p.get(d.id);f&&o.push({type:"tool-trace",trace:f}),o.push({type:"assistant",message:d});const T=l.get(d.id);T&&o.push({type:"tool-trace",trace:T});const m=g.get(d.id);if(m)for(const h of m)o.push({type:"mcp-app",app:h});continue}}return o}const Te=20,Se=150,Gs=({children:e,className:t="",shouldExpandSpacer:n=!1,isForceScrollToBottomEnabled:o=!1,snapToTopTrigger:a})=>{const r=S.useRef(null),i=S.useRef(null),[l,p]=S.useState(!1),x=S.useRef({shouldExpandSpacer:n,isForceScrollToBottomEnabled:o});x.current={shouldExpandSpacer:n,isForceScrollToBottomEnabled:o};const u=S.useCallback(()=>{const m=r.current;return m?m.scrollHeight-m.scrollTop-m.clientHeight<=Te:!0},[]),g=S.useCallback(()=>{const m=r.current;m&&(m.scrollTop=m.scrollHeight)},[]),d=S.useCallback(()=>{const m=r.current,h=i.current;if(!m||!h)return;if(x.current.shouldExpandSpacer){h.style.minHeight=`${Math.max(0,m.clientHeight-Se)}px`;return}const N=m.scrollHeight-m.scrollTop-m.clientHeight;if(N<=Te)return;const c=Math.max(h.offsetHeight-N,0);h.style.minHeight=`${c}px`},[]),f=S.useCallback(()=>{const m=r.current,h=i.current;!m||!h||(h.style.minHeight=`${Math.max(0,m.clientHeight-Se)}px`,m.scrollTop=m.scrollHeight)},[]),T=S.useCallback(()=>{p(!u())},[u]);return S.useEffect(()=>{const m=r.current;if(!m)return;const h=new MutationObserver(()=>{d(),p(!u())});h.observe(m,{childList:!0,subtree:!0,characterData:!0});const N=new ResizeObserver(()=>d());return N.observe(m),()=>{h.disconnect(),N.disconnect()}},[d,u,g]),S.useEffect(()=>{if(a===void 0||a===0)return;const m=requestAnimationFrame(()=>f());return()=>cancelAnimationFrame(m)},[a,f]),S.useEffect(()=>{if(!o)return;const m=requestAnimationFrame(()=>g());return()=>cancelAnimationFrame(m)},[o,g]),s.jsxs("div",{className:`relative flex flex-col flex-1 min-h-0 ${t}`,children:[s.jsxs("div",{ref:r,className:"flex flex-col flex-1 min-h-0 overflow-y-auto custom-scrollbar custom-scrollbar-no-gutter",onScroll:T,children:[e,s.jsx("div",{ref:i,className:"shrink-0"})]}),l&&s.jsx("button",{type:"button","aria-label":"Scroll to bottom",title:"Scroll to bottom",className:"absolute bottom-5 left-1/2 -translate-x-1/2 z-10 size-8 rounded-full bg-app-background-secondary border border-border-default shadow flex items-center justify-center text-text-secondary hover:text-text-states-hover hover:border-border-hover transition-colors",onClick:()=>g(),children:s.jsx(G,{size:14,children:s.jsx(re,{})})})]})},Bs=({onReloadResponse:e,className:t})=>{const n=E(c=>c.messages),o=E(c=>c.toolTraceState),a=E(c=>{const v=c.activeThreadId;return!!v&&c.streamsByThreadId[v]?.status===R.STREAMING}),r=E(c=>c.messageLoadingState),i=E(c=>c.mcpAppInstances),l=E(c=>c.activeThreadId),p=E(c=>c.toggleToolTrace),x=E(c=>c.toggleToolMessage),u=E(c=>c.scrollAnchorRequestId),g=i.filter(c=>c.displayMode==="workspace"?!1:!l||!c.threadId||c.threadId===l),d=Hs(n,o,g),f=n[n.length-1],T=f?.role===b.ASSISTANT,m=f?.role===b.USER,h=[...n].reverse().find(c=>c.role===b.USER),N=r.type===k.FETCH_MESSAGES_FROM_THREAD_SUCCESS;return s.jsxs(Gs,{shouldExpandSpacer:m,isForceScrollToBottomEnabled:N,snapToTopTrigger:u,className:t,children:[r.type===k.LOADING_FROM_THREAD&&s.jsx("div",{className:"flex flex-1 justify-center items-center p-4",children:s.jsx("div",{className:"flex gap-1",children:[0,1,2].map(c=>s.jsx("div",{className:"size-1.5 rounded-full bg-app-accent-color-1",style:{animationDelay:`${c*.15}s`,animation:`rise 0.6s cubic-bezier(0.16,1,0.3,1) ${c*.15}s infinite alternate`}},c))})}),s.jsx("div",{"data-testid":"message-list",className:"flex flex-1 flex-col gap-8 w-full min-w-[200px] max-w-[920px] md:max-w-[720px] mx-auto px-3",children:d.map(c=>{if(c.type==="user"){const v=a?c.message.id===h?.id:c.message.id===f?.id&&m;return s.jsx(Ds,{message:c.message,isLast:v,isGenerating:a},c.message.id)}if(c.type==="assistant"){const v=c.message.id===f?.id&&T;return s.jsx(js,{message:c.message,isLast:v,isGenerating:a,onReload:v?e:void 0},c.message.id)}return c.type==="tool-trace"?s.jsx(Ps,{trace:c.trace,onToggle:p,onToggleTool:x},`trace-${c.trace.stateForMessageId}`):c.type==="mcp-app"?s.jsx(_s,{appInstance:c.app},c.app.id):null})})]})},Us=()=>{const e=E(o=>o.allPrompts),t=E(o=>o.favoritePromptNames),n=e.filter(o=>t.includes(o.name));return n.length===0?null:s.jsxs("div",{"data-testid":"favorite-prompt-list",className:"flex flex-col w-full gap-[10px] py-2 max-w-[920px] w-full px-4",children:[s.jsx("div",{className:"flex items-center p-2 w-full shrink-0",children:s.jsx("span",{className:"text-[10px] leading-[13px] tracking-[0.1px] text-text-default",children:y.PROMPT_LIST_COMPONENT.FAVORITE_PROMPTS})}),s.jsx("div",{className:"w-full flex flex-col md:flex-row md:flex-wrap md:justify-center gap-3",children:n.map(o=>s.jsx(Le,{prompt:o,isDisplayedInFavoriteList:!0},o.name))})]})},Fs=({threadId:e,title:t,isActive:n,isEditing:o,editValue:a,hasNotification:r,streamStatus:i,onSelect:l,onStartEditing:p,onCommitEdit:x,onEditChange:u,onEditKeyDown:g,onDelete:d})=>{const f=S.useRef(null);S.useEffect(()=>{o&&f.current&&(f.current.focus(),f.current.select())},[o]);const T=i===R.STREAMING,m=r&&!n,h=T;return s.jsx("div",{role:"button","data-testid":"thread-history-item","data-thread-id":e,"data-active":n?"true":"false","aria-current":n?"true":void 0,tabIndex:0,className:["group flex flex-1 justify-start gap-2 px-4 h-8 rounded-md cursor-pointer hover:bg-thread-list-item-hover-background",n?"bg-thread-list-item-hover-background":""].join(" "),onClick:()=>!o&&l(e),onKeyUp:N=>N.key==="Enter"&&!o&&l(e),children:s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer p-2 flex-1 min-w-0",children:[!o&&s.jsxs("div",{className:["flex items-center text-xs flex-1 min-w-0 overflow-hidden",n?"text-text-states-active":"text-text-default"].join(" "),children:[m&&s.jsx("span",{"data-testid":"thread-notification-dot",className:"size-2 rounded-full bg-orange-500 mr-2 flex-shrink-0",title:"New response available"}),s.jsx("span",{className:"truncate block",title:t,children:t}),h&&s.jsx(K,{className:"ml-2 flex-shrink-0 size-5 "})]}),o&&s.jsx("input",{ref:f,"data-testid":"thread-rename-input","aria-label":"Rename thread",className:"flex-1 px-2 border border-border-default rounded text-text-default text-xs bg-transparent outline-none",value:a,onChange:N=>u(N.target.value),onBlur:()=>x(e),onKeyDown:N=>g(N,e),onClick:N=>N.stopPropagation()}),s.jsxs("div",{className:["gap-2 ml-auto items-center",n?"flex":"hidden group-hover:flex"].join(" "),children:[s.jsx(B,{size:12,tabIndex:n?0:-1,title:"Rename",disabled:h,onClick:N=>p(e,t,N),children:s.jsx(Et,{})}),s.jsx(B,{size:12,tabIndex:n?0:-1,title:"Delete",disabled:n||h,onClick:N=>d(e,N),children:s.jsx(At,{})})]})]})})},Ws=({onThreadSelected:e})=>{const t=E(C=>C.threads),n=E(C=>C.activeThreadId),o=E(C=>C.completionNotifications),a=E(C=>C.streamsByThreadId),r=E(C=>C.threadLoadingState),{selectThread:i,renameThread:l,deleteThread:p}=Y(),[x,u]=S.useState(null),[g,d]=S.useState(""),f=ns(t),T=r.type===w.LOADING,m=(C,A,M)=>{M.stopPropagation(),u(C),d(A)},h=C=>{l(C,g),u(null)},N=(C,A)=>{C.key==="Enter"?(C.preventDefault(),h(A)):C.key==="Escape"&&u(null)},c=(C,A)=>{A.stopPropagation(),p(C)},v=async C=>{await i(C),e?.()};return s.jsxs("div",{"data-testid":"thread-history",className:"flex flex-1 flex-col p-2 overflow-y-scroll custom-scrollbar custom-scrollbar-no-gutter",children:[T&&s.jsx("div",{className:"flex flex-1 justify-center items-center",children:s.jsx(K,{})}),!T&&f.length===0&&s.jsx("p",{className:"flex flex-1 justify-center items-center text-text-default text-xs",children:y.THREAD_HISTORY_COMPONENT.NO_THREADS}),!T&&f.map(C=>s.jsxs("div",{"data-testid":"thread-history-list",children:[s.jsx("div",{"data-testid":"thread-history-divider",className:"p-2 pb-0",children:s.jsx("span",{className:"text-xs text-proto-text-disabled cursor-default",children:C.label})}),C.threads.map(A=>s.jsx(Fs,{threadId:A.id,title:A.title??A.id,isActive:A.id===n,isEditing:x===A.id,editValue:g,hasNotification:o.includes(A.id),streamStatus:a[A.id]?.status,onSelect:M=>{v(M)},onStartEditing:m,onCommitEdit:h,onEditChange:d,onEditKeyDown:N,onDelete:c},A.id))]},C.label))]})},$s=({userId:e,className:t})=>{const n=E(l=>l.setIsThreadHistoryVisible),o=E(l=>l.isDarkMode),a=()=>n(!1),r=e?e.charAt(0).toUpperCase():"U",i=!!e;return s.jsxs("aside",{"data-testid":"sidebar",className:["flex flex-col h-full w-[368px] min-w-[368px] max-w-[368px] bg-app-background-secondary",t??""].join(" "),children:[s.jsxs("div",{className:"flex items-center gap-4 px-4 py-2",children:[s.jsx(B,{size:12,containerSize:24,onClick:a,title:"Thread history",children:s.jsx(Ie,{})}),o?s.jsx(_t,{}):s.jsx(Rt,{})]}),s.jsx(Ws,{}),i&&s.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 mt-auto border-t border-border-default",children:[s.jsx("div",{className:"flex items-center justify-center size-6 rounded-full bg-app-accent-color-1 text-white font-semibold text-[12px] flex-shrink-0",children:r}),s.jsx("div",{className:"flex flex-col flex-1 min-w-0",children:s.jsx("span",{className:"text-text-default text-[12px] leading-[12px] font-normal truncate",title:e,children:e})})]})]})},Vs=()=>{const e=oe(),t=E(C=>C.isThreadHistoryVisible),n=E(C=>C.setIsThreadHistoryVisible),o=E(C=>C.messages),a=E(C=>C.messageLoadingState),r=E(C=>C.favoritePromptNames),{sendMessage:i,abortMessage:l}=Y(),p=Is(),x=o.length>0,u=a.type===k.LOADING_FROM_THREAD,g=x||u,d=!g,f=d&&r.length>0,T=e.user.name??e.user.id;S.useEffect(()=>{p&&n(!1)},[p,n]);const m=C=>{i(C)},h=()=>{const C=[...o].reverse().find(A=>A.role==="user");C&&"content"in C&&typeof C.content=="string"&&i(C.content)},N=()=>n(!1),c=["flex flex-col flex-1 min-h-0 pb-0 w-full overflow-x-hidden overflow-auto","custom-scrollbar custom-scrollbar-no-gutter",g?"pt-0 gap-0":"pt-24 md:pt-20 gap-12 md:gap-14"].join(" "),v=["flex flex-1 min-h-0 flex-col items-center w-full",g?"gap-0":"gap-6"].join(" ");return s.jsxs("div",{"data-testid":"io-assist-root",className:"flex h-full w-full overflow-hidden bg-app-background",children:[s.jsxs("div",{"data-testid":"chat",className:"flex flex-1 min-h-0 overflow-hidden",children:[t&&p&&s.jsx("div",{role:"presentation",className:"fixed inset-0 z-20 bg-black/45",onClick:N,onKeyDown:C=>C.key==="Escape"&&N()}),t&&s.jsx($s,{userId:e.user.id,className:p?"fixed left-0 top-0 h-full z-30":"relative h-full shrink-0"}),s.jsxs("div",{className:"flex flex-col flex-1 min-h-0 min-w-0 items-center justify-end relative",children:[s.jsx(Ms,{}),s.jsxs("div",{className:c,children:[d&&s.jsx(ws,{agentName:T}),s.jsxs("div",{className:v,children:[g&&s.jsx(Bs,{onReloadResponse:h,className:"flex-1 flex flex-col min-h-0 w-full"}),s.jsx(Os,{onSend:m,onAbort:l,className:"max-w-[920px] md:max-w-[720px] w-full px-4"}),f&&s.jsx(Us,{}),s.jsx(ys,{showMessageArea:g})]})]})]})]}),s.jsx(vs,{}),s.jsx(bs,{})]})},I={ACCEPT:"accept",DECLINE:"decline",CANCEL:"cancel"},se={ACCEPT:"accept",DECLINE:"decline"};async function le(){const t=O.getState().ioConnectApi?.modals,n=t?.dialogs;if(!t||!n)return!1;try{const o=await t.getStatus();return o?o.platformConfigured===!0:!1}catch{return!1}}function ce(e){const t=O.getState().ioConnectApi;return t?.modals?.dialogs?t.modals.dialogs.request(e):Promise.reject(new Error("IO Connect Modals API is not available."))}const zs="Elicitation",H=j.get(zs);function Zs(e){const t=e?.clientsConfig?.capabilities?.elicitation?.handler;return typeof t=="function"?(H.warn("Using a custom elicitation handler provided by user configuration."),t):(H.warn("No custom elicitation handler provided. Using built-in handler."),Xs)}async function Xs(e,t){const n=t?._meta?.threadId,o=O.getState().activeThreadId;if(!!(n&&o&&o!==n))return H.warn(`Elicitation request rejected: active thread (${o}) does not match request thread (${n})`),V(I.CANCEL,"Elicitation request rejected: User was not on the thread that the elicitation request was intended for.");if(!qs(t))return V(I.CANCEL,"Elicitation request validation failed.");try{return await Ks(e,t)}catch(r){const i="Error occurred while getting elicitation modal response. Request canceled. "+(r instanceof Error?r.message:String(r));return V(I.CANCEL,i)}}function qs(e){const t=e?._meta;if(!t||!t.toolName)return H.warn("Elicitation request is missing required _meta.toolName field."),!1;const n=t.toolName;return typeof n!="string"||n.trim().length===0?(H.warn("Elicitation request has invalid _meta.toolName field."),!1):n.startsWith("io_connect")?!0:(H.warn("Elicitation request is not intended for io_connect."),!1)}async function Ks(e,t){H.info(`Showing elicitation request from server: ${e}, requesting: ${P(t)}`);const n=typeof t?.message=="string"?t.message:y.ELICITATION_MODAL.FALLBACK_TEXT,a=await le()?await Ys(n):await Js(n);return a===I.ACCEPT?V(I.ACCEPT):a===I.DECLINE?V(I.DECLINE):V(I.CANCEL,"Elicitation dialog was closed without a response.")}async function Ys(e){return(await ce({templateName:"noInputsConfirmationDialog",variables:{title:y.ELICITATION_MODAL.TITLE,heading:y.ELICITATION_MODAL.HEADING,text:e,actionButtons:[{variant:"primary",text:"Accept",id:I.ACCEPT},{variant:"outline",text:"Decline",id:I.DECLINE},{variant:"outline",text:"Cancel",id:I.CANCEL}]}}))?.responseButtonClicked?.id??null}async function Js(e){const t=await ie({title:y.ELICITATION_MODAL.TITLE,heading:y.ELICITATION_MODAL.HEADING,text:e,buttons:[{id:I.ACCEPT,label:"Accept",variant:"primary"},{id:I.DECLINE,label:"Decline",variant:"default"},{id:I.CANCEL,label:"Cancel",variant:"default"}]});return t===J?(H.warn("Elicitation modal was preempted by another modal; treating as cancel."),I.CANCEL):t}function V(e,t){return e===I.ACCEPT?(H.info(t??"User accepted the elicitation request."),{action:I.ACCEPT,content:{}}):e===I.DECLINE?(H.info(t??"User declined the elicitation request."),{action:I.DECLINE}):(H.info(t??"User canceled the elicitation request."),{action:I.CANCEL})}const Qs="McpAppsModal",He=j.get(Qs);async function en(e){try{return await le()?await tn(e):await sn(e)}catch(t){return He.warn(`MCP app replace modal failed, defaulting to recreate: ${t instanceof Error?t.message:String(t)}`),"recreate"}}async function tn(e){const t=y.MCP_APP_REPLACE_MODAL;return(await ce({templateName:"noInputsConfirmationDialog",variables:{title:t.TITLE,heading:t.HEADING,text:t.TEXT(e),actionButtons:[{variant:"primary",text:t.REPLACE_BUTTON,id:"replace"},{variant:"outline",text:t.NEW_INSTANCE_BUTTON,id:"new"}]}}))?.responseButtonClicked?.id==="replace"?"recreate":"newInstance"}async function sn(e){const t=y.MCP_APP_REPLACE_MODAL,n=await ie({title:t.TITLE,heading:t.HEADING,text:t.TEXT(e),buttons:[{id:"replace",label:t.REPLACE_BUTTON,variant:"primary"},{id:"new",label:t.NEW_INSTANCE_BUTTON,variant:"default"}]});return n===J?(He.warn(`MCP app replace modal for "${e}" was preempted by another modal; defaulting to recreate.`),"recreate"):n==="replace"?"recreate":"newInstance"}const nn="McpAppEvents",$=j.get(nn);function on(e,t,n){if(!e.mcpApps){$.warn("ioIntelWeb.mcpApps is not available — MCP app + recreate prompt will not work. Check the mcpApps config + sandboxProxyUrl.");return}$.debug(`Wiring MCP app handlers: ${P({hasOnAppCreated:typeof e.mcpApps.onAppCreated=="function",hasOnRecreateRequested:typeof e.mcpApps.onRecreateRequested=="function",hasOnAppRecreated:typeof e.mcpApps.onAppRecreated=="function"})}`);let o=!1;const a=new Map;e.mcpApps.onAppCreated(r=>{$.debug(`mcpApps.onAppCreated: ${P({id:r?.id,threadId:r?.threadId,hasElement:!!r?.element,hasOnMessage:typeof r?.onMessage=="function"})}`);const i=t.getState().activeThreadId;i&&r.threadId!==i||(t.getState().addMcpApp(r),an(r,t,n,a))}),e.mcpApps.onRecreateRequested(r=>{if($.debug(`mcpApps.onRecreateRequested fired: ${P({toolName:r?.toolName,hasSelect:typeof r?.select=="function"})}`),o){r.select("recreate").catch(()=>{});return}o=!0,en(r.toolName??"this app").then(i=>r.select(i)).catch(()=>r.select("recreate").catch(()=>{})).finally(()=>{o=!1})}),e.mcpApps.onAppRecreated(r=>{t.getState().removeMcpApp(r.oldId);const i=a.get(r.oldId);if(i){try{i()}catch{}a.delete(r.oldId)}})}function an(e,t,n,o){if(typeof e?.onMessage!="function"){$.warn(`MCP app instance has no onMessage method: ${P({id:e?.id})}`);return}const a=e.onMessage(r=>{$.debug(`MCP app sent chat message: ${P({appId:e.id,text:r})}`);const i=t.getState().activeThreadId;i&&(e.threadId&&e.threadId!==i||Pe(t,r,n))});o.set(e.id,a)}const rn="Sampling",D=j.get(rn);function ln(e){const t=e?.clientsConfig?.capabilities?.sampling?.handler;return typeof t=="function"?(D.warn("Using a custom sampling handler provided by user configuration."),t):(D.warn("No custom sampling handler provided. Using built-in handler."),cn)}async function cn(e,t){const n=t?._meta?.threadId,o=O.getState().activeThreadId;if(!!(n&&o&&o!==n))return D.warn(`Sampling request rejected: active thread (${o}) does not match request thread (${n})`),{code:-1,message:"Sampling request rejected: User was not on the thread that the request was intended for."};try{return await dn(e,t)}catch(r){return D.error(`Error occurred while getting sampling modal response: ${r instanceof Error?r.message:String(r)}`),{code:-1,message:"An error occurred while processing the sampling request."}}}async function dn(e,t){return D.info(`Showing sampling request from server: ${e}, requesting: ${P(t)}`),(await le()?await un():await pn())?(D.info("User approved the sampling request."),await fn(t)):(D.info("User denied the sampling request."),{code:-1,message:"User denied the sampling request."})}async function un(){return(await ce({templateName:"noInputsConfirmationDialog",variables:{title:y.SAMPLING_MODAL.TITLE,heading:y.SAMPLING_MODAL.HEADING,text:y.SAMPLING_MODAL.TEXT,actionButtons:[{variant:"primary",text:"Continue",id:"yes"},{variant:"outline",text:"Cancel",id:"no"}]}}))?.responseButtonClicked?.id==="yes"}async function pn(){const e=await ie({title:y.SAMPLING_MODAL.TITLE,heading:y.SAMPLING_MODAL.HEADING,text:y.SAMPLING_MODAL.TEXT,buttons:[{id:se.ACCEPT,label:"Continue",variant:"primary"},{id:se.DECLINE,label:"Cancel",variant:"default"}]});return e===J?(D.warn("Sampling consent modal was preempted by another modal; treating as decline."),!1):e===se.ACCEPT}async function fn(e){const t=O.getState().selectedAgent;if(!t)return{code:-1,message:"No agent available for sampling."};D.debug(`Preparing to generate sampling response with request: ${P(e)}`);const n=(e?.messages??[]).map(a=>({id:crypto.randomUUID(),role:a?.role,content:ne(a?.content)}));D.debug(`Formatted messages for sampling request: ${P(n)}`),e?.systemPrompt&&n.unshift({id:crypto.randomUUID(),role:"system",content:e.systemPrompt});const o={messages:n,instructions:e?.systemPrompt,system:e?.systemPrompt,modelSettings:{maxTokens:e?.maxTokens,temperature:e?.temperature??void 0},requestContext:{modelPreferences:e?.modelPreferences||void 0},structuredOutput:{schema:e?._meta?.structuredOutput},tools:{autoIncludeEnabled:!1}};try{const a=await t.rawAgent.generate(o);if(!a)return{code:-1,message:"Failed to generate response for sampling success response."};const r={role:"assistant",content:{type:"text",text:a.text??""},model:t.modelId??"unknown",stopReason:"endTurn"};return D.info(`Generated response for sampling success: ${P(r)}`),r}catch(a){return D.error(`Failed to generate sampling response: ${a instanceof Error?a.message:String(a)}`),{code:-1,message:"Failed to generate sampling response."}}}const gn="InitIoAiWeb",Ne=j.get(gn);async function mn(e,t,n){try{const{IoAiWebFactory:o}=await import("@interopio/ai-web"),a=n.getState().ioConnectApi;if(!a)throw new Error("io.Connect API not available");const r=xn(e,t),i=await o(a,r);Ne.info("IoAiWeb initialised successfully.");const l=n.getState();l.setIoAiWebApi(i),l.setAppLoadingState({type:w.SUCCESS}),on(i,n,t);const p=t.user.id??"";await Promise.all([Cn(i,e.defaultAgentName,p,n),Sn(e.defaultPrompts??[],n),Ee(i,n),Nn(i,n)]);const x=i.tools;typeof x.onChanged=="function"&&x.onChanged(()=>{Ee(i,n)})}catch(o){const a=o instanceof Error?o.message:"Failed to initialise IO Intel Web API";n.getState().setAppLoadingState({type:w.ERROR,message:a}),Ne.error("IoAiWeb initialisation failed.",o instanceof Error?o:new Error(String(o)))}}function xn(e,t){const o={agentServer:{...e.aiWebConfig.agentServer,headers:{...t.agentServer?.headers??{}}}};return e.aiWebConfig.mcp&&(o.mcp=hn(e.aiWebConfig.mcp)),e.workingContext&&(o.context=e.workingContext),o}function hn(e){return{...e,clientsConfig:{...e.clientsConfig,capabilities:{...e.clientsConfig?.capabilities,sampling:{handler:ln(e)},elicitation:{handler:Zs(e)}}}}}async function Cn(e,t,n,o){const a=o.getState();a.setAgentsLoadingState({type:w.LOADING});try{const i=(await e.agents.list()).map(p=>({id:p.id,name:p.name,description:p.description,modelId:p.modelId,rawAgent:p}));a.setAgents(i),a.setAgentsLoadingState({type:w.SUCCESS});const l=t?i.find(p=>p.name===t)??i[0]:i[0];l&&(a.setSelectedAgent(l),await Tn(e,l.rawAgent.id,n,o))}catch(r){o.getState().setAgentsLoadingState({type:w.ERROR,message:r instanceof Error?r.message:"Failed to load agents"})}}async function Tn(e,t,n,o){const a=o.getState();a.setThreadLoadingState({type:w.LOADING});try{const i=(await e.threads.list({agentId:t,resourceId:n})).map(l=>({id:l.id,title:l.title||l.id.substring(0,8),createdAt:l.createdAt?new Date(l.createdAt):new Date,updatedAt:l.updatedAt?new Date(l.updatedAt):void 0,rawThread:l,update:p=>l.update(p),delete:()=>l.delete(),getMessages:p=>l.getMessages(p)}));a.setThreads(i),a.setThreadLoadingState({type:w.SUCCESS})}catch(r){o.getState().setThreadLoadingState({type:w.ERROR,message:r instanceof Error?r.message:"Failed to load threads"})}}function Sn(e,t){const n=e.flatMap(o=>(o.prompts??[]).map((a,r)=>({id:`${o.category??"default"}-${r}-${a.name}`,name:a.name,description:a.prompt,category:o.category,iconResource:a.iconResource})));t.getState().setAllPrompts(n)}async function Ee(e,t){const n=t.getState();n.setToolLoadingState({type:w.LOADING});try{const a=(await e.tools.list()).map(r=>({name:r.name,description:r.description??"",enabled:r.enabled??!0,mcpServerName:r.source?.mcpName??void 0,state:Z.IDLE,rawTool:r}));n.setTools(a),n.setToolLoadingState({type:w.SUCCESS})}catch{n.setToolLoadingState({type:w.ERROR,message:"Failed to load tools"})}}async function Nn(e,t){const n=t.getState();try{if(!e.context){n.setIsWorkingContextEnabled(!1);return}n.setIsWorkingContextEnabled(!0),n.setWorkingContextLoadingState({type:w.LOADING});const o=await e.context.get();n.setWorkingContext(o??null),n.setWorkingContextLoadingState({type:w.SUCCESS}),e.context.onChanged(a=>{t.getState().setWorkingContext(a)})}catch{n.setIsWorkingContextEnabled(!1)}}function En(){const e=E(r=>r.isIoConnectReady),t=E(r=>r.appLoadingState),n=we(),o=oe(),a=S.useRef(!1);S.useEffect(()=>{e&&(a.current||t.type===w.NOT_STARTED&&(a.current=!0,mn(n,o,O)))},[e,n,o,t.type])}async function An(e,t){const{setIoConnectApi:n,setIsIoConnectReady:o,setFavoritePromptNames:a,setIsDarkMode:r}=t,i=l=>{vn(l),r(l==="dark")};try{let l;const p=e.connectConfig?.desktop,x=e.connectConfig?.browser;if(p?.factory)l=await p.factory(p.config);else if(x?.factory)l=await x.factory(x.config);else throw new Error("No io.Connect factory provided. Supply connectConfig.browser or connectConfig.desktop.");j.setLogger(l.logger),n(l),o(!0);const u=l.themes;if(u)try{const g=await u.getCurrent();g&&i(g.name),u.onChanged(d=>i(d.name))}catch{i("dark")}else i("dark");try{const g=await l.prefs?.get();g?.data?.favoritePrompts&&a(g.data.favoritePrompts)}catch(g){console.error("[io-assist-react] io.Connect prefs not available:",g)}}catch(l){o(!1),console.error("[io-assist-react] io.Connect initialisation failed:",l)}}function vn(e){document.documentElement.className="",document.documentElement.classList.add(e)}function yn(){const e=we(),t=E(i=>i.setIoConnectApi),n=E(i=>i.setIsIoConnectReady),o=E(i=>i.setFavoritePromptNames),a=E(i=>i.setIsDarkMode),r=S.useRef(!1);S.useEffect(()=>{r.current||(r.current=!0,An(e,{setIoConnectApi:t,setIsIoConnectReady:n,setFavoritePromptNames:o,setIsDarkMode:a}))},[e,t,n,o,a])}function bn({staticConfig:e,dynamicConfig:t}){return s.jsx(lt,{staticConfig:e,dynamicConfig:t,children:s.jsx(wn,{})})}const wn=()=>{yn(),En();const e=E(t=>t.appLoadingState);return e.type===w.LOADING||e.type===w.NOT_STARTED?s.jsx(In,{}):e.type===w.ERROR?s.jsx(Mn,{onRetry:()=>window.location.reload()}):s.jsx(Vs,{})},In=()=>s.jsx("div",{className:"flex items-center justify-center w-full h-full bg-app-background",children:s.jsx(K,{className:"size-10"})}),Mn=({onRetry:e})=>s.jsx("div",{className:"flex items-center justify-center w-full h-full bg-app-background",children:s.jsxs("div",{className:"flex flex-col items-center gap-4 text-center px-6 max-w-sm",children:[s.jsx("p",{className:"text-4xl",children:"⚠️"}),s.jsx("p",{className:"text-sm font-medium text-text-default",children:y.LOADING_STATE.ERROR}),s.jsx("button",{type:"button",className:"px-4 py-2 rounded-xl bg-app-accent-color-1 text-white text-sm hover:opacity-90 transition-opacity",onClick:e,children:y.LOADING_STATE.RETRY})]})});exports.IoAssist=bn;
41
+ //# sourceMappingURL=index.cjs.map